diff options
| author | Oleg Pudeyev <oleg@bsdpower.com> | 2011-05-09 22:00:38 -0400 |
|---|---|---|
| committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-05-12 20:13:30 -0400 |
| commit | 0462ab3a4a5cea64699eaf4b2e9900e36d027e50 (patch) | |
| tree | c9c3b357fef34a77c962378789a1bca61fc885dc /phpBB/includes/template/compile.php | |
| parent | 49cf28a9c43060d2a4c4d5fe882fc3c7dedd7d0b (diff) | |
| download | forums-0462ab3a4a5cea64699eaf4b2e9900e36d027e50.tar forums-0462ab3a4a5cea64699eaf4b2e9900e36d027e50.tar.gz forums-0462ab3a4a5cea64699eaf4b2e9900e36d027e50.tar.bz2 forums-0462ab3a4a5cea64699eaf4b2e9900e36d027e50.tar.xz forums-0462ab3a4a5cea64699eaf4b2e9900e36d027e50.zip | |
[feature/template-engine] Add back IN_PHPBB preamble.
PHPBB3-9726
Diffstat (limited to 'phpBB/includes/template/compile.php')
| -rw-r--r-- | phpBB/includes/template/compile.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php index 4132fb2e34..18a52e87a6 100644 --- a/phpBB/includes/template/compile.php +++ b/phpBB/includes/template/compile.php @@ -54,6 +54,7 @@ class phpbb_template_filter extends php_user_filter public function filter($in, $out, &$consumed, $closing) { $written = false; + $first = false; while ($bucket = stream_bucket_make_writeable($in)) { @@ -71,7 +72,13 @@ class phpbb_template_filter extends php_user_filter $written = true; - $bucket->data = $this->compile($data); + $data = $this->compile($data); + if (!$first) + { + $data = $this->prepend_preamble($data); + $first = false; + } + $bucket->data = $data; $bucket->datalen = strlen($bucket->data); stream_bucket_append($out, $bucket); } @@ -150,6 +157,18 @@ class phpbb_template_filter extends php_user_filter return $data; } + /** + * Prepends a preamble to compiled template. + * Currently preamble checks if IN_PHPBB is defined and calls exit() if it is not. + * @param string $data Compiled template chunk + * @return string Compiled template chunk with preamble prepended + */ + private function prepend_preamble($data) + { + $data = "<?php if (!defined('IN_PHPBB')) exit;" . ((strncmp($data, '<?php', 5) === 0) ? substr($data, 5) : ' ?>' . $data); + return $data; + } + private function replace($matches) { if ($this->in_php && $matches[1] != 'ENDPHP') |
