[PHP]Code
Alles wat tussen de [*code*] tags staat krijg ik niet meer terug
Index.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
include "inc/functions.inc.php";
if($_SERVER['REQUEST_METHOD'] == "POST"){
echo parse_ubb(safe_output(highlight_encode($_POST['input'])));
}else{
?>
Test hier mijn UBB parser, nog niet af.
<form method="post" action="index.php">
<textarea name="input" cols="75" rows="35"></textarea>
<Br />
<input type="submit" value="Parse" />
</form>
<?php
}
?>
include "inc/functions.inc.php";
if($_SERVER['REQUEST_METHOD'] == "POST"){
echo parse_ubb(safe_output(highlight_encode($_POST['input'])));
}else{
?>
Test hier mijn UBB parser, nog niet af.
<form method="post" action="index.php">
<textarea name="input" cols="75" rows="35"></textarea>
<Br />
<input type="submit" value="Parse" />
</form>
<?php
}
?>
Klik hier voor de gebruikte functies
Iemand een idee hoe ik dit ga oplossen?>
Ty alvast
Gewijzigd op 01/01/1970 01:00:00 door Gebruiker PHP
Gewijzigd op 01/01/1970 01:00:00 door Gebruiker PHP
Dit is het probleem
Je witl hem hightlighten?
Ik wil heb eerst highlighten en dan encoden zodat hij niet word geparsed door de ubb parser en in de parser weer decoden zodat hij word teruggegeven..
Code (php)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
[code]
//function.php
//ubb phraser
function showsource($text){
$text = str_replace("<br />","",$text);
$text = str_replace("<","<",$text);
$text = str_replace(">",">",$text);
ob_start();
highlight_string(stripslashes($text));
$source = ob_get_contents();
ob_end_clean();
$source = explode('<br />',$source);
$geheel .= '</p><div id="code"><div id="num"><code id="select">';
for ($i = 1; $i < count($source)+1; $i++) {
$geheel .= $i.'.<br />';
}
$geheel .= '</code></div><code>';
for ($i = 0; $i < count($source); $i++) {
$src .= $source[$i].'<br />';
}
$src .= $source[count($source)];
$geheel .= $src.'</code></div><p>';
$geheel = str_replace('&','&',$geheel);
$geheel = str_replace('<font color="','<span style="color:',$geheel);
$geheel = str_replace("</font>","</span>",$geheel);
return $geheel;
}
function ubb($text)
{
global $basedir;
//replace html/php
$text = htmlentities($text);
$text = preg_replace('/\[quote\](.*?)\[\/quote\]/si','<div class="quote">\\1</div>',$text);
$text = nl2br($text);
$smiley = array(':)',';)',':D','8)',':p',':rolleyes:',':S',':@',':(',':O',':|',':cry:');
$image = array('smile','wink','laughing','cool','tongue','rolleyes','confused','angry','sad','surprised','wasset','crying');
for($s=0;$s < 12; $s++)
{
$smil = "<img src=\"".$basedir."images/smiles/".$image[$s].".gif\" alt=\"(".$image[$s].")\" />";
$text = str_replace($smiley[$s],$smil, $text);
}
//layout
$text = preg_replace('/\[b\](.*?)\[\/b\]/si','<strong>\\1</strong>',$text);
$text = preg_replace('/\[i\](.*?)\[\/i\]/si','<em>\\1</em>',$text);
$text = preg_replace('/\[u\](.*?)\[\/u\]/si','<span class="underline">\\1</span>',$text);
//images
$text = preg_replace("#\[img\](http(s)?://)([a-zA-Z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\[/img\]#", "<img src='\\1\\3' alt='\\1\\3'/>", $text);
$images = array();
$replace = array();
$images[0] = '#\[img height=([0-9]*?) width=([0-9]*?)\](.*?)\[\/img\]#si';
$images[1] = '#\[img width=([0-9]*?) height=([0-9]*?)\](.*?)\[\/img\]#si';
$images[2] = '#\[imgl\](.*?)\[\/imgl\]#si';
$images[3] = '#\[imgr\](.*?)\[\/imgr\]#si';
$replace[0] = '<img src="\\3" height="\\1" width="\\2" alt="\\3"/>';
$replace[1] = '<img src="\\3" height="\\2" width="\\1" alt="\\3"/>';
$replace[2] = '<img scr="\\1" class="imageleft" alt="\\1"/>';
$replace[3] = '<img scr="\\1" class="imageright" alt="\\1"/>';
$text = preg_replace($images,$replace,$text);
//links
$linktype = array();
$replacement = array();
$linktype[0] = '#\[url\]([a-z]*?://){1}(.*?)\[\/url\]#si';
$replacement[0] = '<a href="\\1\\2" rel="external">\\1\\2</a>';
$linktype[1] = '#\[url\](.*?)\[\/url\]#si';
$replacement[1] = '<a href="http://\\1" rel="external">\\1</a>';
$linktype[2] = '#\[url=([a-z]*?://){1}(.*?)\](.*?)\[\/url\]#si';
$replacement[2] = '<a href="\\1\\2" rel="external">\\3</a>';
$linktype[3] = '#\[url=(.*?)\](.*?)\[\/url\]#si';
$replacement[3] = '<a href="http://\\1" rel="external">\\2</a>';
$linktype[4] = '#\[email\](.*?)\[\/email\]#si';
$replacement[4] = '<a href="mailto:\\1">\\1</a>';
$linktype[5] = '#\[email=(.*?)\](.*?)\[\/email\]#si';
$replacement[5] = '<a href="mailto:\\1">\\2</a>';
$text = preg_replace($linktype,$replacement,$text);
//other nice options:
$text = preg_replace('/\[warning\](.*?)\[\/warning\]/si','</p><div class="warning">\\1</div><p>',$text);
$text = preg_replace('/\[code\](.*?)\[\/code\]/esiU', "showsource('$1')",$text);
$text = preg_replace('/\[quote\](.*?)\[\/quote\]/si','</p><div class="quote">\\1</div><p>',$text);
$text = preg_replace('/\[quote=([0-9]*?),(.*?)\](.*?)\[\/quote\]/si','</p><div class="quote"><a href="#reactie\\1">\\2</a><br />\\3</div><p>',$text);
//Om als voorbeeld BB weer tegen moeten [ BB ] om gezet worden naar [BB]
$text = preg_replace('/\[ (.*?) \](.*?)\[ \/(.*?) \]/si','[\\1]\\2[/\\3]',$text);
return $text;
}
function newsletter($text)
{
//replace html/php
$text = htmlentities($text);
$text = nl2br($text);
//layout
$text = preg_replace('/\[b\](.*?)\[\/b\]/si','<strong>\\1</strong>',$text);
$text = preg_replace('/\[i\](.*?)\[\/i\]/si','<em>\\1</em>',$text);
$text = preg_replace('/\[u\](.*?)\[\/u\]/si','<span class="underline">\\1</span>',$text);
//images
$text = preg_replace('/\[img\](.*?)\[\/img\]/si','<img src="\\1" alt="\\1" />',$text);
$images = array();
$replace = array();
$images[0] = '#\[img height=([0-9]*?) width=([0-9]*?)\](.*?)\[\/img\]#si';
$images[1] = '#\[img width=([0-9]*?) height=([0-9]*?)\](.*?)\[\/img\]#si';
$images[2] = '#\[imgl\](.*?)\[\/imgl\]#si';
$images[3] = '#\[imgr\](.*?)\[\/imgr\]#si';
$replace[0] = '<img src="\\3" height="\\1" width="\\2" alt="\\3"/>';
$replace[1] = '<img src="\\3" height="\\2" width="\\1" alt="\\3"/>';
$replace[2] = '<img scr="\\1" class="imageleft" alt="\\1"/>';
$replace[3] = '<img scr="\\1" class="imageright" alt="\\1"/>';
$text = preg_replace($images,$replace,$text);
//links
$linktype = array();
$replacement = array();
$linktype[0] = '#\[url\]([a-z]*?://){1}(.*?)\[\/url\]#si';
$replacement[0] = '<a href="\\1\\2" rel="external">\\1\\2</a>';
$linktype[1] = '#\[url\](.*?)\[\/url\]#si';
$replacement[1] = '<a href="http://\\1" rel="external">\\1</a>';
$linktype[2] = '#\[url=([a-z]*?://){1}(.*?)\](.*?)\[\/url\]#si';
$replacement[2] = '<a href="\\1\\2" rel="external">\\3</a>';
$linktype[3] = '#\[url=(.*?)\](.*?)\[\/url\]#si';
$replacement[3] = '<a href="http://\\1" rel="external">\\2</a>';
$linktype[4] = '#\[email\](.*?)\[\/email\]#si';
$replacement[4] = '<a href="mailto:\\1">\\1</a>';
$linktype[5] = '#\[email=(.*?)\](.*?)\[\/email\]#si';
$replacement[5] = '<a href="mailto:\\1">\\2</a>';
$text = preg_replace($linktype,$replacement,$text);
//other nice options:
$text = preg_replace('/\[warning\](.*?)\[\/warning\]/si','</p><div class="warning">\\1</div><p>',$text);
$text = preg_replace('/\[code\](.*?)\[\/code\]/esiU', "showsource('$1')",$text);
$text = preg_replace('/\[quote\](.*?)\[\/quote\]/si','</p><div class="quote">\\1</div><p>',$text);
$text = preg_replace('/\[quote=([0-9]*?),(.*?)\](.*?)\[\/quote\]/si','</p><div class="quote"><a href="#reactie\\1">\\2</a><br />\\3</div><p>',$text);
//Om als voorbeeld BB weer tegen moeten [ BB ] om gezet worden naar [BB]
$text = preg_replace('/\[ (.*?) \](.*?)\[ \/(.*?) \]/si','[\\1]\\2[/\\3]',$text);
return $text;
}
?>
[code]
//function.php
//ubb phraser
function showsource($text){
$text = str_replace("<br />","",$text);
$text = str_replace("<","<",$text);
$text = str_replace(">",">",$text);
ob_start();
highlight_string(stripslashes($text));
$source = ob_get_contents();
ob_end_clean();
$source = explode('<br />',$source);
$geheel .= '</p><div id="code"><div id="num"><code id="select">';
for ($i = 1; $i < count($source)+1; $i++) {
$geheel .= $i.'.<br />';
}
$geheel .= '</code></div><code>';
for ($i = 0; $i < count($source); $i++) {
$src .= $source[$i].'<br />';
}
$src .= $source[count($source)];
$geheel .= $src.'</code></div><p>';
$geheel = str_replace('&','&',$geheel);
$geheel = str_replace('<font color="','<span style="color:',$geheel);
$geheel = str_replace("</font>","</span>",$geheel);
return $geheel;
}
function ubb($text)
{
global $basedir;
//replace html/php
$text = htmlentities($text);
$text = preg_replace('/\[quote\](.*?)\[\/quote\]/si','<div class="quote">\\1</div>',$text);
$text = nl2br($text);
$smiley = array(':)',';)',':D','8)',':p',':rolleyes:',':S',':@',':(',':O',':|',':cry:');
$image = array('smile','wink','laughing','cool','tongue','rolleyes','confused','angry','sad','surprised','wasset','crying');
for($s=0;$s < 12; $s++)
{
$smil = "<img src=\"".$basedir."images/smiles/".$image[$s].".gif\" alt=\"(".$image[$s].")\" />";
$text = str_replace($smiley[$s],$smil, $text);
}
//layout
$text = preg_replace('/\[b\](.*?)\[\/b\]/si','<strong>\\1</strong>',$text);
$text = preg_replace('/\[i\](.*?)\[\/i\]/si','<em>\\1</em>',$text);
$text = preg_replace('/\[u\](.*?)\[\/u\]/si','<span class="underline">\\1</span>',$text);
//images
$text = preg_replace("#\[img\](http(s)?://)([a-zA-Z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\[/img\]#", "<img src='\\1\\3' alt='\\1\\3'/>", $text);
$images = array();
$replace = array();
$images[0] = '#\[img height=([0-9]*?) width=([0-9]*?)\](.*?)\[\/img\]#si';
$images[1] = '#\[img width=([0-9]*?) height=([0-9]*?)\](.*?)\[\/img\]#si';
$images[2] = '#\[imgl\](.*?)\[\/imgl\]#si';
$images[3] = '#\[imgr\](.*?)\[\/imgr\]#si';
$replace[0] = '<img src="\\3" height="\\1" width="\\2" alt="\\3"/>';
$replace[1] = '<img src="\\3" height="\\2" width="\\1" alt="\\3"/>';
$replace[2] = '<img scr="\\1" class="imageleft" alt="\\1"/>';
$replace[3] = '<img scr="\\1" class="imageright" alt="\\1"/>';
$text = preg_replace($images,$replace,$text);
//links
$linktype = array();
$replacement = array();
$linktype[0] = '#\[url\]([a-z]*?://){1}(.*?)\[\/url\]#si';
$replacement[0] = '<a href="\\1\\2" rel="external">\\1\\2</a>';
$linktype[1] = '#\[url\](.*?)\[\/url\]#si';
$replacement[1] = '<a href="http://\\1" rel="external">\\1</a>';
$linktype[2] = '#\[url=([a-z]*?://){1}(.*?)\](.*?)\[\/url\]#si';
$replacement[2] = '<a href="\\1\\2" rel="external">\\3</a>';
$linktype[3] = '#\[url=(.*?)\](.*?)\[\/url\]#si';
$replacement[3] = '<a href="http://\\1" rel="external">\\2</a>';
$linktype[4] = '#\[email\](.*?)\[\/email\]#si';
$replacement[4] = '<a href="mailto:\\1">\\1</a>';
$linktype[5] = '#\[email=(.*?)\](.*?)\[\/email\]#si';
$replacement[5] = '<a href="mailto:\\1">\\2</a>';
$text = preg_replace($linktype,$replacement,$text);
//other nice options:
$text = preg_replace('/\[warning\](.*?)\[\/warning\]/si','</p><div class="warning">\\1</div><p>',$text);
$text = preg_replace('/\[code\](.*?)\[\/code\]/esiU', "showsource('$1')",$text);
$text = preg_replace('/\[quote\](.*?)\[\/quote\]/si','</p><div class="quote">\\1</div><p>',$text);
$text = preg_replace('/\[quote=([0-9]*?),(.*?)\](.*?)\[\/quote\]/si','</p><div class="quote"><a href="#reactie\\1">\\2</a><br />\\3</div><p>',$text);
//Om als voorbeeld BB weer tegen moeten [ BB ] om gezet worden naar [BB]
$text = preg_replace('/\[ (.*?) \](.*?)\[ \/(.*?) \]/si','[\\1]\\2[/\\3]',$text);
return $text;
}
function newsletter($text)
{
//replace html/php
$text = htmlentities($text);
$text = nl2br($text);
//layout
$text = preg_replace('/\[b\](.*?)\[\/b\]/si','<strong>\\1</strong>',$text);
$text = preg_replace('/\[i\](.*?)\[\/i\]/si','<em>\\1</em>',$text);
$text = preg_replace('/\[u\](.*?)\[\/u\]/si','<span class="underline">\\1</span>',$text);
//images
$text = preg_replace('/\[img\](.*?)\[\/img\]/si','<img src="\\1" alt="\\1" />',$text);
$images = array();
$replace = array();
$images[0] = '#\[img height=([0-9]*?) width=([0-9]*?)\](.*?)\[\/img\]#si';
$images[1] = '#\[img width=([0-9]*?) height=([0-9]*?)\](.*?)\[\/img\]#si';
$images[2] = '#\[imgl\](.*?)\[\/imgl\]#si';
$images[3] = '#\[imgr\](.*?)\[\/imgr\]#si';
$replace[0] = '<img src="\\3" height="\\1" width="\\2" alt="\\3"/>';
$replace[1] = '<img src="\\3" height="\\2" width="\\1" alt="\\3"/>';
$replace[2] = '<img scr="\\1" class="imageleft" alt="\\1"/>';
$replace[3] = '<img scr="\\1" class="imageright" alt="\\1"/>';
$text = preg_replace($images,$replace,$text);
//links
$linktype = array();
$replacement = array();
$linktype[0] = '#\[url\]([a-z]*?://){1}(.*?)\[\/url\]#si';
$replacement[0] = '<a href="\\1\\2" rel="external">\\1\\2</a>';
$linktype[1] = '#\[url\](.*?)\[\/url\]#si';
$replacement[1] = '<a href="http://\\1" rel="external">\\1</a>';
$linktype[2] = '#\[url=([a-z]*?://){1}(.*?)\](.*?)\[\/url\]#si';
$replacement[2] = '<a href="\\1\\2" rel="external">\\3</a>';
$linktype[3] = '#\[url=(.*?)\](.*?)\[\/url\]#si';
$replacement[3] = '<a href="http://\\1" rel="external">\\2</a>';
$linktype[4] = '#\[email\](.*?)\[\/email\]#si';
$replacement[4] = '<a href="mailto:\\1">\\1</a>';
$linktype[5] = '#\[email=(.*?)\](.*?)\[\/email\]#si';
$replacement[5] = '<a href="mailto:\\1">\\2</a>';
$text = preg_replace($linktype,$replacement,$text);
//other nice options:
$text = preg_replace('/\[warning\](.*?)\[\/warning\]/si','</p><div class="warning">\\1</div><p>',$text);
$text = preg_replace('/\[code\](.*?)\[\/code\]/esiU', "showsource('$1')",$text);
$text = preg_replace('/\[quote\](.*?)\[\/quote\]/si','</p><div class="quote">\\1</div><p>',$text);
$text = preg_replace('/\[quote=([0-9]*?),(.*?)\](.*?)\[\/quote\]/si','</p><div class="quote"><a href="#reactie\\1">\\2</a><br />\\3</div><p>',$text);
//Om als voorbeeld BB weer tegen moeten [ BB ] om gezet worden naar [BB]
$text = preg_replace('/\[ (.*?) \](.*?)\[ \/(.*?) \]/si','[\\1]\\2[/\\3]',$text);
return $text;
}
?>
Zo los ik het altijd op :)
Gewijzigd op 01/01/1970 01:00:00 door Eris -