1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 14:30:32 +02:00

More bbcode fixes

git-svn-id: file:///svn/phpbb/trunk@3879 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Ludovic Arnaud
2003-04-17 23:47:26 +00:00
parent a79524cb33
commit ff6fdd67be
3 changed files with 22 additions and 18 deletions

View File

@@ -312,18 +312,18 @@ class bbcode
switch ($type)
{
case 'php':
$remove_tags = FALSE;
if (!preg_match('/<\?(php)? .*? \?>/', $code))
{
$remove_tags = TRUE;
$code = "<?php $code ?>";
}
$str_from = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}', '.', '@');
$str_to = array('&lt;', '&gt;', '&quot;', '&#58;', '&#91;', '&#93;', '&#40;', '&#41;', '&#123;', '&#125;', '&#46;', '&#64;');
$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();
@@ -331,10 +331,12 @@ class bbcode
if ($remove_tags)
{
$code = preg_replace('/(.*?)&lt;\?php&nbsp;(.*)\?&gt;(.*?)/', '\1\2\3', $code);
$code = preg_replace('!^<code>[\n\r\s\t]*<font color="#[a-z0-9]+">[\n\r\s\t]*(<font color="#[a-z0-9]+">)&lt;\?php&nbsp;(.*)\?&gt;</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);
}
$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: