Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as PHP by shaw ( 13 years ago )
<?
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 = "[php]" . $before_replace . "[/php]";
$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 \\\\\\\\\\\\\\\\1;">’, $after_replace);
$after_replace = str_replace(’</font>’, ’</span>’, $after_replace);
$after_replace = str_replace("", ’’, $after_replace);
$replacement .= $after_replace;
$text = str_replace($str_to_match, $replacement, $text);
}
return $text;
}
?>
Revise this Paste
Parent: 9926