mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
- Make "<?" and/or "<%" in template files not break the compiled template.
- Enable <!-- PHP --> and <!-- INCLUDEPHP --> again. git-svn-id: file:///svn/phpbb/trunk@8699 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1b67e80422
commit
8c186d97c6
1 changed files with 14 additions and 7 deletions
|
@ -74,11 +74,14 @@ class template_filter extends php_user_filter
|
||||||
|
|
||||||
private function compile($data)
|
private function compile($data)
|
||||||
{
|
{
|
||||||
|
$data = preg_replace('#<(?:[\\?%]|script)#s', '<?php echo\'\\0\';?>', $data);
|
||||||
return str_replace('?><?php', '', preg_replace_callback($this->regex, array($this, 'replace'), $data));
|
return str_replace('?><?php', '', preg_replace_callback($this->regex, array($this, 'replace'), $data));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function replace($matches)
|
private function replace($matches)
|
||||||
{
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (isset($matches[3]))
|
if (isset($matches[3]))
|
||||||
{
|
{
|
||||||
return $this->compile_var_tags($matches[0]);
|
return $this->compile_var_tags($matches[0]);
|
||||||
|
@ -129,14 +132,18 @@ class template_filter extends php_user_filter
|
||||||
return '<?php ' . $this->compile_tag_include($matches[2]) . ' ?>';
|
return '<?php ' . $this->compile_tag_include($matches[2]) . ' ?>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* case 'INCLUDEPHP':
|
case 'INCLUDEPHP':
|
||||||
$this->compile_blocks[] = ($config['tpl_allow_php']) ? '<?php ' . $this->compile_tag_include_php(array_shift($includephp_blocks)) . ' ?>' : '';
|
return ($config['tpl_allow_php']) ? '<?php ' . $this->compile_tag_include_php($matches[2]) . ' ?>' : '';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHP':
|
case 'PHP':
|
||||||
$this->compile_blocks[] = ($config['tpl_allow_php']) ? '<?php ' . array_shift($php_blocks) . ' ?>' : '';
|
return ($config['tpl_allow_php']) ? '<?php ' : '<!-- ';
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
|
case 'ENDPHP':
|
||||||
|
return ($config['tpl_allow_php']) ? ' ?>' : ' -->';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $matches[0];
|
return $matches[0];
|
||||||
break;
|
break;
|
||||||
|
@ -737,9 +744,9 @@ class template_compile
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_filter_append($source_handle, 'template');
|
@flock($destination_handle, LOCK_EX);
|
||||||
|
|
||||||
@flock($destination_handle);
|
stream_filter_append($source_handle, 'template');
|
||||||
stream_copy_to_stream($source_handle, $destination_handle);
|
stream_copy_to_stream($source_handle, $destination_handle);
|
||||||
|
|
||||||
@fclose($source_handle);
|
@fclose($source_handle);
|
||||||
|
@ -775,4 +782,4 @@ class template_compile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue