ok people after some searching, i found some tutorials and codes and here it is!
btw, thank evilwalrus,jam and all people this one saved my life!
here it is
Code: Select all
<?
function bbencode_highlight_php($text) {
$matches = array();
$match_count = preg_match_all("#\[php\](.*?)\[/php\]#si", $text, $matches);
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = trim($matches[1][$i]);
$str_to_match = "
";
$replacement = "";
$after_replace = str_replace('<', '<', $after_replace);
$after_replace = str_replace('>', '>', $after_replace);
$after_replace = str_replace('&', '&', $after_replace);
$added = FALSE;
if (preg_match('/^<\?.*?\?>$/si', $after_replace) <= 0) {
$after_replace = "<?php $after_replace ?>";
$added = TRUE;
}
if(strcmp('4.2.0', phpversion()) > 0) {
ob_start();
highlight_string($after_replace);
$after_replace = ob_get_contents();
ob_end_clean();
}
else {
$after_replace = highlight_string($after_replace, TRUE);
}
if ($added == TRUE) {
$after_replace = str_replace('<font color="#0000BB"><?php <br>', '<font color="#0000BB">', $after_replace);
$after_replace = str_replace('<font color="#0000BB"><br>?></font>', '', $after_replace);
}
$after_replace = preg_replace('/<font color="(.*?)">/si', '<span style="color: \\1;" class="kod">', $after_replace);
$after_replace = str_replace('</font>', '</span>', $after_replace);
$after_replace = str_replace("", '', $after_replace);
$replacement .= '<table width="90%" border="0" align="center"><tr><td class="kod">'.$after_replace.'</td></tr></table>';
$text = str_replace($str_to_match, $replacement, $text);
}
return $text;
}
function text_edit($text) {
// <KOD> EDIT
$text = str_replace("[kod]","<br><table width=\"90%\" border=\"0\" align=\"center\"><tr><td class=\"kod\">",$text);
$text = str_replace("[/kod]","</td></tr></table><br>",$text);
// <URL> EDIT
$pattern = "#\[url=([\w]+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
$text = preg_replace($pattern, '<a href="$1" target="_blank" class="infokonusiyah">$2</a>', $text);
$text = bbencode_highlight_php($text);
return ($text);
}
?>