ubb-parse-script-zonder-gedoe

Gesponsorde koppelingen

PHP script bestanden

  1. ubb-parse-script-zonder-gedoe

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<style type="text/css">
.num {
float: left;
color: gray;
font-size: 13px;

text-align: right;
margin-right: 6pt;
padding-right: 6pt;
border-right: 1px solid gray;}
</style>

<?php

## Alle UBB-tags converteren
function makeUBB($string){

// HTML verbieden
$string = htmlspecialchars($string);
// Enters maken
$string = nl2br($string);
// Links maken
$string = preg_replace("_\[url]http://(.*)\[/url\]_si", '<a href="$1" target="_blank">$1</a>', $string);
$string = preg_replace("_\[url](.*)\[/url\]_si", '<a href="http://$1" target="_blank">$1</a>', $string);
$string = preg_replace("_\[url=http://(.*)\](.*?)\[/url\]_si", '<a href="$1" target="_blank">$2</a>', $string);
$string = preg_replace("_\[url=(.*)\](.*?)\[/url\]_si", '<a href="http://$1" target="_blank">$2</a>', $string);
$string = preg_replace("_\[email](.*)\[/email\]_si", '<a href="mailto://$1">$1</a>', $string);
$string = preg_replace("_\[email=(.*)\](.*?)\[/email\]_si", '<a href="mailto:$1">$2</a>', $string);
// Afbeeldingen
$string = preg_replace("_\[img](.*)\[/img\]_si", '<img src="$1" alt="Afbeelding" />', $string);
// Automatisch links maken
$string = preg_replace('#(^|[ \n\r\t])([a-z0-9]{1,6}://([a-z0-9\-]{1,}(\.?)){1,}[a-z]{2,5}(:[0-9]{2,5}){0,1}((\/|~|\#|\?|=|&amp;|&|\+){1}[a-z0-9\-._%]{0,}){0,})#si', '\\1<a href="\\2">\\2</a>', $string);
$string = preg_replace('#(^|[ \n\r\t])((www\.){1}([a-z0-9\-]{1,}(\.?)){1,}[a-z]{2,5}(:[0-9]{2,5}){0,1}((\/|~|\#|\?|=|&amp;|&|\+){1}[a-z0-9\-._%]{0,}){0,})#si', '\\1<a href="http://\\2">\\2</a>', $string);
$string = preg_replace('#(^|[ \n\r\t])(([a-z0-9\-_]{1,}(\.?)){1,}@([a-z0-9\-]{1,}(\.?)){1,}[a-z]{2,5})#si', '\\1<a href="mailto:\\2">\\2</a>', $string);
// Youtube video
$string = preg_replace('_\[youtube\].*?(v=|v/)(.+?)(&.*?|/.*?)?\[/youtube\]_is', '[youtube]$2[/youtube]', $string);
$string = preg_replace('_\[youtube\]([a-z0-9-]+?)\[/youtube\]_is', '<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/$1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>', $string);
// Uitlijnen
$string = preg_replace("_\[left](.*)\[/left\]_si", '<div align="left">$1</div>', $string);
$string = preg_replace("_\[right](.*)\[/right\]_si", '<div align="right" style="margin-right: 5px;">$1</div>', $string);
$string = preg_replace("_\[center](.*)\[/center\]_si", '<div align="center">$1</div>', $string);
// Kleuren
$string = preg_replace("_\[color=(.*)\](.*?)\[/color\]_si", '<span style="color: $1">$2</span>', $string);
// Tekstgrootte
$string = preg_replace("_\[size=(.*)\](.*?)\[/size\]_si", '<span style="font-size: $1">$2</span>', $string);
$string = preg_replace("_\[tt](.*)\[/tt\]_si", '<tt>$1</tt>', $string);
$string = preg_replace("_\[big](.*)\[/big\]_si", '<big>$1</big>', $string);
$string = preg_replace("_\[small](.*)\[/small\]_si", '<small>$1</small>', $string);
// Vetgedrukt
$string = preg_replace("_\[b\](.*?)\[/b\]_si", '<b>$1</b>', $string);
// Cursief
$string = preg_replace("_\[i\](.*?)\[/i\]_si", '<i>$1</i>', $string);
// Onderstrepen
$string = preg_replace("_\[u\](.*?)\[/u\]_si", '<u>$1</u>', $string);
// Doorstrepen
$string = preg_replace("_\[s\](.*?)\[/s\]_si", '<s>$1</s>', $string);
// Knipperen
$string = preg_replace("_\[blink\](.*?)\[/blink\]_si", '<blink>$1</blink>', $string);
// Superscript
$string = preg_replace("_\[sup\](.*?)\[/sup\]_si", '<sup>$1</sup>', $string);
// Subscript
$string = preg_replace("_\[sub\](.*?)\[/sub\]_si", '<sub>$1</sub>', $string);
// All caps
$string = preg_replace("_\[ac\](.*?)\[/ac\]_si", '<span style="text-transform:uppercase">$1</span>', $string);
// Small caps
$string = preg_replace("_\[sc\](.*?)\[/sc\]_si", '<span style="text-transform:lowercase">$1</span>', $string);
// Marquee, standaard "scroll", andere opties: "slide" & "alternate"
$string = preg_replace("_\[slide\](.*?)\[/slide\]_si", '<marquee>$1</marquee>', $string);
$string = preg_replace("_\[slide=(.*?)\](.*?)\[/slide\]_si", '<marquee behavior="$1">$2</marquee>', $string);
// Smilies
$string = str_replace(":)"," <img src=\"images/smilies/lach.gif\" alt=\"lach\" />", $string);
// Quotes
while(preg_match("((\[quote=(.+?)\](.+?)\[\/quote\])|(\[quote\](.+?)\[\/quote]))is", $string)) {
  $string = preg_replace("(\[quote=(.+?)\](.+?)\[\/quote\])is",'<fieldset><legend> <b>$1 schreef:</b> </legend><br />$2<br /></fieldset><br />' ,$string);
  $string = preg_replace("(\[quote\](.+?)\[\/quote])is",'<fieldset><legend> <b>Quote</b> </legend><br />$1<br /></fieldset><br />' ,$string);
}

// Highlighten
$string = preg_replace_callback("_\[code\](.*?)\[/code\]_is", "customHighlight", $string);

return $string;
}

function
customHighlight($code){
    $code = highlight_string(htmlspecialchars_decode(strip_tags($code[1])), true);
    $code = str_replace('\"', '"', $code);
    $code = str_replace("?&gt;", "<span style=\"color: #0000BB\">?&gt;</span>", $code);
    
    $aLines = explode("<br />", $code);
    $iLines = count($aLines);
    
    $output = "<br /><div style=\"width: 116%;\"><b>PHP code</b><br /><div class=\"num\">";
    for($i = 1; $i <= $iLines; $i++){
    $output .= $i ."<br />";
    }

    $output .= "</div><div style=\"float: left;overflow-x: scroll;overflow: auto;display: block;width:80%;\">\n$code\n</div><div style=\"clear:left;\"></div></div>";
 
    return $output;
}



?>
  

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.