mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
First-pass syntax highlightning. Will fix quotes later
git-svn-id: file:///svn/phpbb/trunk@3901 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -70,7 +70,6 @@ class bbcode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count($str['search']))
|
||||
{
|
||||
$message = str_replace($str['search'], $str['replace'], $message);
|
||||
@@ -307,38 +306,11 @@ class bbcode
|
||||
|
||||
function bbcode_second_pass_code($type, $code)
|
||||
{
|
||||
$code = stripslashes(str_replace("\r\n", "\n", $code));
|
||||
$code = stripslashes($code);
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'php':
|
||||
$str_from = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}', '.', '@');
|
||||
$str_to = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}', '.', '@');
|
||||
|
||||
$code = str_replace($str_to, $str_from, $code);
|
||||
|
||||
$remove_tags = FALSE;
|
||||
if (!preg_match('/\<\?.*?\?\>/is', $code))
|
||||
{
|
||||
$remove_tags = TRUE;
|
||||
$code = "<?php $code ?>";
|
||||
}
|
||||
|
||||
ob_start();
|
||||
highlight_string($code);
|
||||
$code = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if ($remove_tags)
|
||||
{
|
||||
$code = preg_replace('!^<code>[\n\r\s\t]*<font color="#[a-z0-9]+">[\n\r\s\t]*(<font color="#[a-z0-9]+">)<\?php (.*)\?></font>[\n\r\s\t]*(</font>)[\n\r\s\t]*</code>[\n\r\s\t]*!is', '\1\2\3', $code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = preg_replace('!^<code>[\n\r\s\t]*<font color="#[a-z0-9]+">[\n\r\s\t]*(.*)</font>[\n\r\s\t]*</code>[\n\r\s\t]*!is', '\1', $code);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$code = str_replace("\t", ' ', $code);
|
||||
$code = str_replace(' ', ' ', $code);
|
||||
|
Reference in New Issue
Block a user