Nieuw lid |
|
Probleem opgelost!
Hoi,
Ik heb een UBB-systeem gemaakt, alleen daarbij heb ik een probleempje: de highlight voor codes returned niet goed (zie hier voor de fout)
<?php
function code($code) {
$code = str_replace("&", "&", $code);
$code = str_replace("<", "<", $code);
$code = str_replace(">", ">", $code);
$code = str_replace(" <?", "<?", $code);
$code = str_replace("<br>", "", $code);
$code = str_replace("<br />", "", $code);
$code = str_replace("" ", "\"", $code);
$code = str_replace(""", "\"", $code);
if (!strpos($code,"<?") and substr($code,0,2)!="<?") {
$code="<?".trim($code)."?>";
$addedtags=1;
}
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$buffer = ob_get_contents();
ob_end_clean();
if(!empty($addedtags)) {
$openingpos = strpos($buffer,'<?');
$closingpos = strrpos($buffer, '?');
$buffer = substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5);
}
return "<TABLE width=\"100%\">
<TR>
<TH>Code</TH>
</TR>
<TR>
<TD>".$buffer."</TD>
</TR>
</TABLE>";
}
function ubb($t) {
$t = htmlspecialchars($t);
$t = trim($t);
$t = nl2br($t);
$t = preg_replace('_\[b\](.*?)\[\/b\]_is', '<b>\\1</b>', $t);
$t = preg_replace('_\[u\](.*?)\[\/u\]_is', '<u>\\1</u>', $t);
$t = preg_replace('_\[i\](.*?)\[\/i\]_is', '<i>\\1</i>', $t);
$t = preg_replace('_\[s\](.*?)\[\/s\]_is', '<s>\\1</s>', $t);
$t = preg_replace('_\[small\](.*?)\[\/small\]_is', '<small>\\1</small>', $t);
$t = preg_replace('_\[url\](.*?)\[\/url\]_is', '<a href="\\1" target="_blank">\\1</a>', $t);
$t = preg_replace('_\[url=(.*?)\](.*?)\[\/url\]_is', '<a href="\\1" target="_blank">\\2</a>', $t);
$t = preg_replace("_\[php=(.*?)\](.*?)\[\/php\]_is", "<A href=\"http://www.php.net/\\1\" target=\"_php\">\\2</A>", $t);
$t = preg_replace("_\[img\](.*?)\[\/img\]_is", "<IMG src=\"\\1\" border=\"0\">", $t);
$t = preg_replace("_\[font=(.*?)\](.*?)\[\/font\]_is", "<FONT style=\"font-family: \\1\">\\2</FONT>", $t);
$t = preg_replace("_\[color=(.*?)\](.*?)\[\/color\]_is", "<FONT style=\"color: \\1\">\\2</FONT>", $t);
$t = preg_replace("_\[size=(.*?)\](.*?)\[\/size\]_is", "<FONT style=\"font-size: \\1px\">\\2</FONT>", $t);
$t = preg_replace("_\[img=(.*?)\]_is", "<IMG src=\"\\1\" alt=\"AFBEELDING\" border=\"0\">", $t);
$t = preg_replace("_\[code](.*?)
<?php function code($code) { $code="<?".trim($code)."?>"; $addedtags=1; } $openingpos = strpos($buffer,'<?'); $closingpos = strrpos($buffer, '?'); $buffer = substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5); } return "<TABLE width=\"100%\"> <TR> <TH>Code</TH> </TR> <TR> <TD>".$buffer."</TD> </TR> </TABLE>"; } function ubb($t) { $t = preg_replace('_\[b\](.*?)\[\/b\]_is', '<b>\\1</b>', $t); $t = preg_replace('_\[u\](.*?)\[\/u\]_is', '<u>\\1</u>', $t); $t = preg_replace('_\[i\](.*?)\[\/i\]_is', '<i>\\1</i>', $t); $t = preg_replace('_\[s\](.*?)\[\/s\]_is', '<s>\\1</s>', $t); $t = preg_replace('_\[small\](.*?)\[\/small\]_is', '<small>\\1</small>', $t); $t = preg_replace('_\[url\](.*?)\[\/url\]_is', '<a href="\\1" target="_blank">\\1</a>', $t); $t = preg_replace('_\[url=(.*?)\](.*?)\[\/url\]_is', '<a href="\\1" target="_blank">\\2</a>', $t); $t = preg_replace("_\[php=(.*?)\](.*?)\[\/php\]_is", "<A href=\"http://www.php.net/\\1\" target=\"_php\">\\2</A>", $t); $t = preg_replace("_\[img\](.*?)\[\/img\]_is", "<IMG src=\"\\1\" border=\"0\">", $t); $t = preg_replace("_\[font=(.*?)\](.*?)\[\/font\]_is", "<FONT style=\"font-family: \\1\">\\2</FONT>", $t); $t = preg_replace("_\[color=(.*?)\](.*?)\[\/color\]_is", "<FONT style=\"color: \\1\">\\2</FONT>", $t); $t = preg_replace("_\[size=(.*?)\](.*?)\[\/size\]_is", "<FONT style=\"font-size: \\1px\">\\2</FONT>", $t); $t = preg_replace("_\[img=(.*?)\]_is", "<IMG src=\"\\1\" alt=\"AFBEELDING\" border=\"0\">", $t);
_is", code('\\1'), $t);
$t = str_replace("Citaat: ", "<TABLE width="100%" class="quote">
<TR>
<TH class="quote">Quote</small></TH>
</TR>
<TR>
<TD>", $t);
$t = str_replace(" ", " </TD>
</TR>
</TABLE><br />", $t);
$smilies = Array (
":@" => "smilie_boos",
":-@" => "smilie_boos",
"[afgestudeerd]" => "smilie_afgestudeerd",
"<:o)" => "smilie_feest",
":)" => "smilie_blij",
":-)" => "smilie_blij",
";-)" => "smilie_knipoog",
";)" => "smilie_knipoog",
"(y)" => "smilie_duim",
"(Y)" => "smilie_duim",
"(n)" => "smilie_duimomlaag",
"(N)" => "smilie_duimomlaag",
"(6)" => "smilie_duivels",
"(A)" => "smilie_engel",
"(a)" => "smilie_engel",
":D" => "smilie_ergblij",
":d" => "smilie_ergblij",
":-D" => "smilie_ergblij",
":-d" => "smilie_ergblij",
":O" => "smilie_geschokt",
":o" => "smilie_geschokt",
":-O" => "smilie_geschokt",
":-o" => "smilie_geschokt",
":P" => "smilie_grappig",
":p" => "smilie_grappig",
":-p" => "smilie_grappig",
":-P" => "smilie_grappig",
":'(" => "smilie_huilen",
"(i)" => "smilie_idee",
"(I)" => "smilie_idee",
"[kerstman]" => "smilie_kerstman",
"(C)" => "smilie_koffie",
"(c)" => "smilie_koffie",
"lol" => "smilie_lachen",
":|" => "smilie_neutraal",
":-|" => "smilie_neutraal",
":(" => "smilie_nietblij",
":-(" => "smilie_nietblij",
"[nieuwjaar]" => "smilie_nieuwjaar",
"[piet]" => "smilie_piet",
":$" => "smilie_schamen",
":-$" => "smilie_schamen",
"[sint]" => "smilie_sint",
":S" => "smilie_verward",
":-S" => "smilie_verward",
":s" => "smilie_verward",
":-s" => "smilie_verward",
"(H)" => "smilie_zon",
"(h)" => "smilie_zon"
);
foreach ($smilies as $code => $image) {
$t = str_replace($code, "<IMG src=\"smilies/".$image.".gif\" border=\"0\">", $t);
}
return $t;
}
?>[/code]
|