From 7d605da65bda85c26d13c810bbfc051b3495b76d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 19 Jun 2009 22:07:27 +0000 Subject: Fix bug #45805 - INCLUDEPHP not depending on phpbb_root_path Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9633 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 47 +++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/template.php') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 0098c484bd..0263783849 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -55,7 +55,7 @@ class template { $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; - + if ($user->theme['template_inherits_id']) { $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template'; @@ -105,13 +105,13 @@ class template $this->filename[$handle] = $filename; $this->files[$handle] = $this->root . '/' . $filename; - + if ($this->inherit_root) { $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; } } - + return true; } @@ -209,7 +209,7 @@ class template return true; } - + /** * Load a compiled template if possible, if not, recompile it * @access private @@ -220,7 +220,7 @@ class template $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx; $this->files_template[$handle] = $user->theme['template_id']; - + $recompile = false; if (!file_exists($filename) || @filesize($filename) === 0) { @@ -236,7 +236,7 @@ class template } $recompile = (@filemtime($filename) < filemtime($this->files[$handle])) ? true : false; } - + // Recompile page if the original template is newer, otherwise load the compiled version if (!$recompile) { @@ -249,14 +249,14 @@ class template { include($phpbb_root_path . 'includes/functions_template.' . $phpEx); } - + // Inheritance - we point to another template file for this one. Equality is also used for store_db if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($this->files[$handle])) { $this->files[$handle] = $this->files_inherit[$handle]; $this->files_template[$handle] = $user->theme['template_inherits_id']; } - + $compile = new template_compile($this); // If we don't have a file assigned to this handle, die. @@ -282,7 +282,7 @@ class template $ids[] = $user->theme['template_inherits_id']; } $ids[] = $user->theme['template_id']; - + foreach ($ids as $id) { $sql = 'SELECT * @@ -290,7 +290,7 @@ class template WHERE template_id = ' . $id . " AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')'; - + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { @@ -298,7 +298,7 @@ class template } $db->sql_freeresult($result); } - + if (sizeof($rows)) { foreach ($rows as $row) @@ -326,7 +326,7 @@ class template { $this->files_template[$row['template_filename']] = $user->theme['template_id']; } - + if ($force_reload || $row['template_mtime'] < filemtime($file)) { if ($row['template_filename'] == $this->filename[$handle]) @@ -468,7 +468,7 @@ class template { unset($this->_tpldata[$blockname][($s_row_count - 1)]['S_LAST_ROW']); } - + // Add a new iteration to this block with the variable assignments we were given. $this->_tpldata[$blockname][] = $vararray; } @@ -511,7 +511,7 @@ class template // Nested blocks are not supported return false; } - + // Change key to zero (change first position) if false and to last position if true if ($key === false || $key === true) { @@ -614,6 +614,25 @@ class template eval(' ?>' . $this->compiled_code[$handle] . '_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty'; + return; + } + include($file); + } } ?> \ No newline at end of file -- cgit v1.2.1 From b613781d3af6d7c5e5d9d0fa1592e78b54647c0f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 21 Jul 2009 10:58:31 +0000 Subject: Preserve newlines in template files (one newline had been always dropped after a template variable due to PHP's handling of closing tags) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9811 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/template.php') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 0263783849..7cf865072f 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -82,6 +82,8 @@ class template $this->root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; + $this->_rootref = &$this->_tpldata['.'][0]; + return true; } -- cgit v1.2.1 From 89332c00b7198b5bd07fdb98b21d4734c300da15 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 08:47:10 +0000 Subject: Fix Bug #40515 - Fix set_custom_template for database-stored styles Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9839 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/template.php') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 7cf865072f..fa7cf437fd 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -39,6 +39,8 @@ class template var $files_inherit = array(); var $files_template = array(); var $inherit_root = ''; + var $orig_tpl_storedb = 'undefined'; + var $orig_tpl_inherits_id = 'undefined'; // this will hash handle names to the compiled/uncompiled code for that handle. var $compiled_code = array(); @@ -55,6 +57,16 @@ class template { $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; + if ($this->orig_tpl_storedb == 'undefined') + { + $this->orig_tpl_storedb = $user->theme['template_storedb']; + } + if ($this->orig_tpl_inherits_id == 'undefined') + { + $this->orig_tpl_inherits_id = $user->theme['template_inherits_id']; + } + $user->theme['template_storedb'] = $this->orig_tpl_storedb; + $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; if ($user->theme['template_inherits_id']) { @@ -77,10 +89,12 @@ class template */ function set_custom_template($template_path, $template_name) { - global $phpbb_root_path; + global $phpbb_root_path, $user; $this->root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; + $user->theme['template_storedb'] = false; + $user->theme['template_inherits_id'] = false; $this->_rootref = &$this->_tpldata['.'][0]; -- cgit v1.2.1 From b902fc20ae78438af7eb44e9b1f078cdcc213e16 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 25 Jul 2009 10:16:13 +0000 Subject: Small change to r9839 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9847 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/template.php') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index fa7cf437fd..fece30e4cd 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -39,8 +39,8 @@ class template var $files_inherit = array(); var $files_template = array(); var $inherit_root = ''; - var $orig_tpl_storedb = 'undefined'; - var $orig_tpl_inherits_id = 'undefined'; + var $orig_tpl_storedb; + var $orig_tpl_inherits_id; // this will hash handle names to the compiled/uncompiled code for that handle. var $compiled_code = array(); @@ -57,14 +57,17 @@ class template { $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; - if ($this->orig_tpl_storedb == 'undefined') + + if ($this->orig_tpl_storedb === null) { $this->orig_tpl_storedb = $user->theme['template_storedb']; } - if ($this->orig_tpl_inherits_id == 'undefined') + + if ($this->orig_tpl_inherits_id === null) { $this->orig_tpl_inherits_id = $user->theme['template_inherits_id']; } + $user->theme['template_storedb'] = $this->orig_tpl_storedb; $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; -- cgit v1.2.1 From edc5061f1df0fd3ce6f307b91f309a52e037cf73 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 20 Aug 2009 14:53:25 +0000 Subject: Check for valid $template_path in includes/template.php - Bug #50055 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10036 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/template.php') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index fece30e4cd..80434aca4c 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -94,6 +94,12 @@ class template { global $phpbb_root_path, $user; + // Make sure $template_path has no ending slash + if (substr($template_path, -1) == '/') + { + $template_path = substr($template_path, 0, -1); + } + $this->root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; $user->theme['template_storedb'] = false; -- cgit v1.2.1