Lid |
|
hoi iedereen,
Ik ben bezig met men forum wat uit te breiden... en nu heb ik iets lastig voor... ik voegde een tag toe [ c o d e ] [ / c o d e ] en dit moet dan via een functie de rijen nummeren en de code kleuren... maar dat doet hij niet, voledigmen design word verkl**t en ik krijg geen error?! dit is het script...
<?
function kleuren($code) {
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 align='center' width='90%' border='0' cellspacing='0' cellpadding='0' class='border'>";
$return .= "<tr><td class='quote_kop' colspan='2'><b>Quote</b></td></tr>";
$return .= "<tr><td width='10%' class='code_num'>";
for($i = "1"; $i < $data; $i++) {
$return .= $i."<br />";
}
$return .= "</td>";
$return .= "<td width='10%' class='code_main'>";
$return .= "<code>".$code."</code>";
$return .= "</td></tr>";
$return .= "</table>";
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;
}
$bericht = preg_replace('_\[code\](.*?)\[/code\]_ise', "kleuren(' \\1 ')", $bericht);
?>
<? function kleuren($code) { $return = $code; } else { $code="<?\n".trim($code)."\n?>"; $addedtags=1; } $data = $c + $d; $return .= "<table align='center' width='90%' border='0' cellspacing='0' cellpadding='0' class='border'>"; $return .= "<tr><td class='quote_kop' colspan='2'><b>Quote</b></td></tr>"; $return .= "<tr><td width='10%' class='code_num'>"; for($i = "1"; $i < $data; $i++) { $return .= $i."<br />"; } $return .= "</td>"; $return .= "<td width='10%' class='code_main'>"; $return .= "<code>".$code."</code>"; $return .= "</td></tr>"; $return .= "</table>"; 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 $return; } $bericht = preg_replace('_\[code\](.*?)\[/code\]_ise', "kleuren(' \\1 ')", $bericht); ?>
Dit is eigenlijk de voledige code...
http://www.plaatscode.be/1579/
|