bij php Highlight code geen enters?
ik krijg er iets niet uit. namelijk:
als iemand een code tussen de
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
151
152
153
154
155
156
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
151
152
153
154
155
156
en [/code ] tags invoer (zonder spaties bij []:p) dan geeft die alles achter elkaar aan wat die persoon invult. de code:
<?
$bericht = htmlspecialchars($bericht);
$bericht = str_replace("\n","<br>",$bericht);
//ubb codes
$bericht = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$bericht);
$bericht = eregi_replace("\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]","<font size=\"\\1\">\\2</font>",$bericht);
$bericht = eregi_replace("\\[font=([^\\[]*)\\]([^\\[]*)\\[/font\\]","<font face=\"\\1\">\\2</font>",$bericht);
$bericht = eregi_replace("\\[img height=([^\\[]*)\\ width=([^\\[]*)\\]([^\\[]*)\\[/img\\]","<img src=\"\\3\" height=\"\\1\" width=\"\\2\">",$bericht);
$bericht = eregi_replace("\\[img]([^\\[]*)\\[/img\\]","<img src=\"\\1\">",$bericht);
$bericht = eregi_replace("\\[flash=([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/flash\\]","<object classid=\"clsid: D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\\1 height=\\2><param name=movie value=\\3><param name=play value=true><param name=loop value=true><param name=quality value=high><embed src=\\3 width=\\1 height=\\2 play=true loop=true quality=high></embed></object>",$bericht);
$bericht = eregi_replace("\\[align=([^\\[]*)\\]([^\\[]*)\\[/align\\]","<p align=\"\\1\">\\2</p>",$bericht);
$bericht = eregi_replace("\\[shadow=([^\\[]*)\\,([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/shadow\\]","<font style=\"Filter: Shadow(color=\\1, Direction=\\2); Width=\\3px;\">\\4</font>",$bericht);
$bericht = eregi_replace("\\[glow=([^\\[]*)\\,([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/glow\\]","<font style=\"Filter: Glow(color=\\1, Strength=\\2); Width=\\3px;\">\\4</font>",$bericht);
$bericht = preg_replace('_\[code\](.*?)\[/code\]_ise', "phphighlite(' \\1 ')", $bericht);
$bericht = str_replace("[move]","<marquee>",$bericht);
$bericht = str_replace("[/move]","</marquee>",$bericht);
$bericht = str_replace("[hr]","<hr>",$bericht);
$bericht = str_replace("[sub]", "<sub>", $bericht);
$bericht = str_replace("[/sub]", "</sub>", $bericht);
$bericht = str_replace("[li]", "<li>", $bericht);
$bericht = str_replace("[/li]", "</li>", $bericht);
$bericht = str_replace("[tt]", "<tt>", $bericht);
$bericht = str_replace("[/tt]", "</tt>", $bericht);
$bericht = str_replace("[sup]", "<sup>", $bericht);
$bericht = str_replace("[/sup]", "</sup>", $bericht);
$bericht = str_replace("[s]","<s>",$bericht);
$bericht = str_replace("[/s]","</s>",$bericht);
$bericht = str_replace("[b]", "<b>",$bericht);
$bericht = str_replace("[/b]","</b>",$bericht);
$bericht = str_replace("[i]","<i>",$bericht);
$bericht = str_replace("[/i]","</i>",$bericht);
$bericht = str_replace("[u]","<u>",$bericht);
$bericht = str_replace("[/u]","</u>",$bericht);
$bericht = str_replace("[*]","<li>",$bericht);
$bericht = str_replace("[list]","<ul>",$bericht);
$bericht = str_replace("[/list]","</ul>",$bericht);
$bericht = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\1</a>",$bericht);
$bericht = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\2</a>",$bericht);
$bericht = str_replace("[quote]","<blockquote><span class=\"12px\">quote:</span><hr>",$bericht);
$bericht = str_replace("[/quote]","<hr></blockquote>",$bericht);
$bericht = str_replace("","<blockquote><pre>",$bericht);
$bericht = str_replace("","</pre></blockquote>",$bericht);
$bericht = eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]", "<a href=\"http://www.\\1\" target=_blank>\\1</a>",$bericht);
$bericht = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\1</a>",$bericht);
$bericht = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$bericht);
$bericht = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)","\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5",$bericht);
//smilies orange
$bericht = str_replace(":)","<img src=\"forum/images/smilies/smile.gif\">",$bericht);
$bericht = str_replace(":(","<img src=\"forum/images/smilies/mad.gif\">",$bericht);
$bericht = str_replace(":'(","<img src=\"forum/images/smilies/cry.gif\">",$bericht);
$bericht = str_replace(";)","<img src=\"forum/images/smilies/knipoog.gif\">",$bericht);
$bericht = str_replace(":D","<img src=\"forum/images/smilies/biggrin.gif\">",$bericht);
$bericht = str_replace(":S","<img src=\"forum/images/smilies/verbaasd.gif\">",$bericht);
$bericht = str_replace(":P","<img src=\"forum/images/smilies/tongue.gif\">",$bericht);
$bericht = str_replace(":nerd:","<img src=\"forum/images/smilies/nerd.gif\">",$bericht);
$bericht = str_replace(":cool:","<img src=\"forum/images/smilies/cool.gif\">",$bericht);
$bericht = str_replace("9:6","<img src=\"forum/images/smilies/worshippy.gif\">",$bericht);
$bericht = str_replace(":evil:","<img src=\"forum/images/smilies/evil.gif\">",$bericht);
$bericht = str_replace(":vinger:","<img src=\"forum/images/smilies/vinger.gif\">",$bericht);
$bericht = str_replace(":lijst:","<img src=\"forum/images/smilies/lijstje.gif\">",$bericht);
$bericht = str_replace(":bier:","<img src=\"forum/images/smilies/bier.gif\">",$bericht);
$bericht = str_replace(":king:","<img src=\"forum/images/smilies/koning.gif\">",$bericht);
$bericht = str_replace(":koffie:","<img src=\"forum/images/smilies/koffie.gif\">",$bericht);
$bericht = str_replace("|:/","<img src=\"forum/images/smilies/professor.gif\">",$bericht);
$bericht = str_replace(":trek:","<img src=\"forum/images/smilies/naamloos.bmp\">",$bericht);
$bericht = str_replace(":gangsertar:","<img src=\"forum/images/smilies/gun.gif\">",$bericht);
$bericht = str_replace(":shoot:","<img src=\"forum/images/smilies/schooting.gif\">",$bericht);
function phphighlite($code) {
//PHP 4 only
if (floor(phpversion())<4) {
$return = $code;
} else {
$code = str_replace("<br>", "", $code);
$code = str_replace("<br />", "", $code);
$code = str_replace(">", ">", $code);
$code = str_replace("<", "<", $code);
$code = str_replace("&", "&", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = stripslashes($code);
if (!strpos($code,"<?") and substr($code,0,2)!="<?") {
$code="<?\n".trim($code)."\n?>";
$addedtags=1;
}
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$code = ob_get_contents();
ob_end_clean();
$a = explode("<br />" , $code);
$b = explode("\n" , $code);
$c = count($a);
$d = count($b);
$data = $c + $d;
$return .= "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" width=\"100%\" bgcolor=\"#D6D6D6\">\n";
$return .= "<tr>\n";
$return .= "<td valign=\"middle\"><b>Code</b></td>\n";
$return .= "</tr>\n";
$return .= "</table>\n";
$return .= "<!-- code table -->\n";
$return .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
$return .= "<tr>\n";
$return .= "<td>\n";
$return .= "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" width=\"100%\" bgcolor=\"#D6D6D6\" style=\"border-left: 1px solid #D6D6D6; border-right: 1px solid #D6D6D6; border-bottom: 1px solid #D6D6D6;\">\n";
$return .= "<tr>\n";
$return .= "<td width=\"1\" valign=\"top\" align=\"left\">\n";
for($i = "1"; $i < $data; $i++)
{
$return .= $i."<br />";
}
$return .= "</td>\n";
$return .= "<td valign=\"top\" bgcolor=\"#FFFFFF\">\n";
$return .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" style=\"table-layout: fixed;\">\n";
$return .= "<tr>\n";
$return .= "<td nowrap>\n";
$return .= "<code style=\"font-family: Courier New\">\n";
$return .= "".$code."\n";
$return .= "</code>\n";
$return .= "</td>\n";
$return .= "</tr>\n";
$return .= "</table>\n";
$return .= "</td></tr></table>\n";
$return .= "</td></tr></table><br />\n";
if ($addedtags) {
$openingpos = strpos($buffer,"<?");
$closingpos = strrpos($buffer, "?");
$return=substr($return, 0, $openingpos).substr($return, $openingpos+5, $closingpos-($openingpos+5)).substr($return, $closingpos+5);
}
$return = str_replace(""", "\"", $return);
}
return $return;
}
?>
kan iemand me hierbij helpen? greetz jeffrey
<?
$bericht = htmlspecialchars($bericht);
$bericht = str_replace("\n","<br>",$bericht);
//ubb codes
$bericht = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$bericht);
$bericht = eregi_replace("\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]","<font size=\"\\1\">\\2</font>",$bericht);
$bericht = eregi_replace("\\[font=([^\\[]*)\\]([^\\[]*)\\[/font\\]","<font face=\"\\1\">\\2</font>",$bericht);
$bericht = eregi_replace("\\[img height=([^\\[]*)\\ width=([^\\[]*)\\]([^\\[]*)\\[/img\\]","<img src=\"\\3\" height=\"\\1\" width=\"\\2\">",$bericht);
$bericht = eregi_replace("\\[img]([^\\[]*)\\[/img\\]","<img src=\"\\1\">",$bericht);
$bericht = eregi_replace("\\[flash=([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/flash\\]","<object classid=\"clsid: D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\\1 height=\\2><param name=movie value=\\3><param name=play value=true><param name=loop value=true><param name=quality value=high><embed src=\\3 width=\\1 height=\\2 play=true loop=true quality=high></embed></object>",$bericht);
$bericht = eregi_replace("\\[align=([^\\[]*)\\]([^\\[]*)\\[/align\\]","<p align=\"\\1\">\\2</p>",$bericht);
$bericht = eregi_replace("\\[shadow=([^\\[]*)\\,([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/shadow\\]","<font style=\"Filter: Shadow(color=\\1, Direction=\\2); Width=\\3px;\">\\4</font>",$bericht);
$bericht = eregi_replace("\\[glow=([^\\[]*)\\,([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/glow\\]","<font style=\"Filter: Glow(color=\\1, Strength=\\2); Width=\\3px;\">\\4</font>",$bericht);
$bericht = preg_replace('_\[code\](.*?)\[/code\]_ise', "phphighlite(' \\1 ')", $bericht);
$bericht = str_replace("[move]","<marquee>",$bericht);
$bericht = str_replace("[/move]","</marquee>",$bericht);
$bericht = str_replace("[hr]","<hr>",$bericht);
$bericht = str_replace("[sub]", "<sub>", $bericht);
$bericht = str_replace("[/sub]", "</sub>", $bericht);
$bericht = str_replace("[li]", "<li>", $bericht);
$bericht = str_replace("[/li]", "</li>", $bericht);
$bericht = str_replace("[tt]", "<tt>", $bericht);
$bericht = str_replace("[/tt]", "</tt>", $bericht);
$bericht = str_replace("[sup]", "<sup>", $bericht);
$bericht = str_replace("[/sup]", "</sup>", $bericht);
$bericht = str_replace("[s]","<s>",$bericht);
$bericht = str_replace("[/s]","</s>",$bericht);
$bericht = str_replace("[b]", "<b>",$bericht);
$bericht = str_replace("[/b]","</b>",$bericht);
$bericht = str_replace("[i]","<i>",$bericht);
$bericht = str_replace("[/i]","</i>",$bericht);
$bericht = str_replace("[u]","<u>",$bericht);
$bericht = str_replace("[/u]","</u>",$bericht);
$bericht = str_replace("[*]","<li>",$bericht);
$bericht = str_replace("[list]","<ul>",$bericht);
$bericht = str_replace("[/list]","</ul>",$bericht);
$bericht = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\1</a>",$bericht);
$bericht = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\2</a>",$bericht);
$bericht = str_replace("[quote]","<blockquote><span class=\"12px\">quote:</span><hr>",$bericht);
$bericht = str_replace("[/quote]","<hr></blockquote>",$bericht);
$bericht = str_replace("","<blockquote><pre>",$bericht);
$bericht = str_replace("","</pre></blockquote>",$bericht);
$bericht = eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]", "<a href=\"http://www.\\1\" target=_blank>\\1</a>",$bericht);
$bericht = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\1</a>",$bericht);
$bericht = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$bericht);
$bericht = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)","\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5",$bericht);
//smilies orange
$bericht = str_replace(":)","<img src=\"forum/images/smilies/smile.gif\">",$bericht);
$bericht = str_replace(":(","<img src=\"forum/images/smilies/mad.gif\">",$bericht);
$bericht = str_replace(":'(","<img src=\"forum/images/smilies/cry.gif\">",$bericht);
$bericht = str_replace(";)","<img src=\"forum/images/smilies/knipoog.gif\">",$bericht);
$bericht = str_replace(":D","<img src=\"forum/images/smilies/biggrin.gif\">",$bericht);
$bericht = str_replace(":S","<img src=\"forum/images/smilies/verbaasd.gif\">",$bericht);
$bericht = str_replace(":P","<img src=\"forum/images/smilies/tongue.gif\">",$bericht);
$bericht = str_replace(":nerd:","<img src=\"forum/images/smilies/nerd.gif\">",$bericht);
$bericht = str_replace(":cool:","<img src=\"forum/images/smilies/cool.gif\">",$bericht);
$bericht = str_replace("9:6","<img src=\"forum/images/smilies/worshippy.gif\">",$bericht);
$bericht = str_replace(":evil:","<img src=\"forum/images/smilies/evil.gif\">",$bericht);
$bericht = str_replace(":vinger:","<img src=\"forum/images/smilies/vinger.gif\">",$bericht);
$bericht = str_replace(":lijst:","<img src=\"forum/images/smilies/lijstje.gif\">",$bericht);
$bericht = str_replace(":bier:","<img src=\"forum/images/smilies/bier.gif\">",$bericht);
$bericht = str_replace(":king:","<img src=\"forum/images/smilies/koning.gif\">",$bericht);
$bericht = str_replace(":koffie:","<img src=\"forum/images/smilies/koffie.gif\">",$bericht);
$bericht = str_replace("|:/","<img src=\"forum/images/smilies/professor.gif\">",$bericht);
$bericht = str_replace(":trek:","<img src=\"forum/images/smilies/naamloos.bmp\">",$bericht);
$bericht = str_replace(":gangsertar:","<img src=\"forum/images/smilies/gun.gif\">",$bericht);
$bericht = str_replace(":shoot:","<img src=\"forum/images/smilies/schooting.gif\">",$bericht);
function phphighlite($code) {
//PHP 4 only
if (floor(phpversion())<4) {
$return = $code;
} else {
$code = str_replace("<br>", "", $code);
$code = str_replace("<br />", "", $code);
$code = str_replace(">", ">", $code);
$code = str_replace("<", "<", $code);
$code = str_replace("&", "&", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = stripslashes($code);
if (!strpos($code,"<?") and substr($code,0,2)!="<?") {
$code="<?\n".trim($code)."\n?>";
$addedtags=1;
}
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$code = ob_get_contents();
ob_end_clean();
$a = explode("<br />" , $code);
$b = explode("\n" , $code);
$c = count($a);
$d = count($b);
$data = $c + $d;
$return .= "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" width=\"100%\" bgcolor=\"#D6D6D6\">\n";
$return .= "<tr>\n";
$return .= "<td valign=\"middle\"><b>Code</b></td>\n";
$return .= "</tr>\n";
$return .= "</table>\n";
$return .= "<!-- code table -->\n";
$return .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
$return .= "<tr>\n";
$return .= "<td>\n";
$return .= "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" width=\"100%\" bgcolor=\"#D6D6D6\" style=\"border-left: 1px solid #D6D6D6; border-right: 1px solid #D6D6D6; border-bottom: 1px solid #D6D6D6;\">\n";
$return .= "<tr>\n";
$return .= "<td width=\"1\" valign=\"top\" align=\"left\">\n";
for($i = "1"; $i < $data; $i++)
{
$return .= $i."<br />";
}
$return .= "</td>\n";
$return .= "<td valign=\"top\" bgcolor=\"#FFFFFF\">\n";
$return .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" style=\"table-layout: fixed;\">\n";
$return .= "<tr>\n";
$return .= "<td nowrap>\n";
$return .= "<code style=\"font-family: Courier New\">\n";
$return .= "".$code."\n";
$return .= "</code>\n";
$return .= "</td>\n";
$return .= "</tr>\n";
$return .= "</table>\n";
$return .= "</td></tr></table>\n";
$return .= "</td></tr></table><br />\n";
if ($addedtags) {
$openingpos = strpos($buffer,"<?");
$closingpos = strrpos($buffer, "?");
$return=substr($return, 0, $openingpos).substr($return, $openingpos+5, $closingpos-($openingpos+5)).substr($return, $closingpos+5);
}
$return = str_replace(""", "\"", $return);
}
return $return;
}
?>
kan iemand me hierbij helpen? greetz jeffrey
greetz jeffrey
Maak daar eens:
$bericht = nl2br($bericht); van
greetz jeffrey
graag gedaan
net zoals hier..
greetz jeffrey
misschien hidden in je form gebruiken met de cat en id, en in je phpscript een header gebruiken met die (geldige) waarden?
header("Location: diepagina.php");
}
Ongeveer ja, je kan ook met ankers werken.