diff options
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/functions.php | 24 | ||||
| -rw-r--r-- | phpBB/includes/functions_admin.php | 8 | ||||
| -rw-r--r-- | phpBB/includes/session.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/template.php | 70 |
4 files changed, 77 insertions, 27 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6d5c404121..5ccd044545 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1348,8 +1348,10 @@ function page_header($page_title = '') 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'T_THEME_PATH' => 'styles/' . $user->theme['primary']['theme_path'] . '/theme/', - 'T_STYLESHEET_LINK' => (!$user->theme['primary']['css_storedb']) ? 'styles/' . $user->theme['primary']['theme_path'] . '/theme/stylesheet.css' : "style.$phpEx?sid=$user->session_id&id=" . $user->theme['primary']['theme_id'], - 'T_THEME_DATA' => (!$user->theme['primary']['css_storedb']) ? '' : $user->theme['primary']['css_data']) + 'T_TEMPLATE_PATH' => 'styles/' . $user->theme['primary']['template_path'] . 'template/', + 'T_IMAGESET_PATH' => 'styles/' . $user->theme['primary']['imageset_path'] . 'imageset/', + 'T_STYLESHEET_LINK' => (!$user->theme['primary']['theme_storedb']) ? 'styles/' . $user->theme['primary']['theme_path'] . '/theme/stylesheet.css' : "style.$phpEx?sid=$user->session_id&id=" . $user->theme['primary']['theme_id'], + 'T_THEME_DATA' => (!$user->theme['primary']['theme_storedb']) ? '' : $user->theme['primary']['theme_data']) ); if (!empty($config['send_encoding'])) @@ -1368,15 +1370,6 @@ function page_footer() { global $db, $config, $template, $SID, $user, $auth, $cache, $starttime, $phpEx; - // Close our DB connection. - $db->sql_close(); - - // Unload cache - if (!empty($cache)) - { - $cache->unload(); - } - // Output page creation time if (defined('DEBUG')) { @@ -1407,6 +1400,15 @@ function page_footer() ); $template->display('body'); + + // Close our DB connection. + $db->sql_close(); + + // Unload cache + if (!empty($cache)) + { + $cache->unload(); + } exit; } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index de9eb95dd9..85378c2491 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -165,15 +165,13 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') while ($fname = readdir($dh)) { - if (is_file($rootdir . $dir . '/' . $fname) && - preg_match('#\.' . $type . '$#i', $fname) && - filesize($rootdir . $dir . '/' . $fname)) + if (is_file("$rootdir$dir/$fname") && filesize("$rootdir$dir/$fname") && preg_match('#\.' . $type . '$#i', $fname)) { $matches[$dir][] = $fname; } - else if ($fname{0} != '.' && is_dir($rootdir . $dir . '/' . $fname)) + else if ($fname{0} != '.' && is_dir("$rootdir$dir/$fname")) { - $matches += filelist($rootdir, $dir . '/'. $fname, $type); + $matches += filelist($rootdir, "$dir/$fname", $type); } } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index e24e29ac58..8ae054b556 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -461,8 +461,6 @@ class user extends session include($this->lang_path . '/' . $lang_set . '.' . $phpEx); }*/ - // TODO ? - // Cheat if (!empty($_GET['style']) && $auth->acl_get('a_styles')) { global $SID; diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index d7de109602..51935ba9df 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -70,13 +70,13 @@ class template if (file_exists($phpbb_root_path . 'styles/' . $user->theme['primary']['template_path'] . '/template')) { -// $this->tpl = 'primary'; + $this->tpl = 'primary'; $this->root = $phpbb_root_path . 'styles/' . $user->theme['primary']['template_path']. '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . $user->theme['primary']['template_path'] . '_'; } else { -// $this->tpl = 'secondary'; + $this->tpl = 'secondary'; $this->root = $phpbb_root_path . 'styles/' . $user->theme['secondary']['template_path']. '/template'; $this->cachepath = $phpbb_root_path . 'cache/tpl_' . $user->theme['secondary']['template_path'] . '_'; } @@ -140,7 +140,7 @@ class template // Load a compiled template if possible, if not, recompile it function _tpl_load(&$handle) { - global $phpEx, $user; + global $phpEx, $user, $db; $filename = $this->cachepath . $this->filename[$handle] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx; @@ -165,28 +165,80 @@ class template if (!file_exists($this->files[$handle])) { -// $this->tpl = 'secondary'; + $this->tpl = 'secondary'; $this->files[$handle] = $phpbb_root_path . 'styles/' . $user->theme['secondary']['template_path'] . '/template/' . $this->filename[$handle]; } $str = ''; + if ($user->theme[$this->tpl]['template_storedb']) + { + $sql = 'SELECT * FROM ' . STYLES_TPLDATA_TABLE . ' + WHERE template_id = ' . $user->theme[$this->tpl]['template_id'] . " + AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' + OR template_included LIKE '%" . $db->sql_escape($this->filename[$handle]) . ":%')"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + if ($row['template_mtime'] < filemtime($phpbb_root_path . 'styles/' . $user->theme[$this->tpl]['template_path'] . '/template/' . $row['template_filename'])) + { + if ($row['template_filename'] == $this->filename[$handle]) + { + $this->_tpl_load_file($handle); + } + else + { + $this->files[$row['template_filename']] = $this->root . '/' . $row['template_filename']; + $this->_tpl_load_file($row['template_filename']); + unset($this->compiled_code[$row['template_filename']]); + unset($this->files[$row['template_filename']]); + } + } + + if ($row['template_filename'] == $this->filename[$handle]) + { + $this->compiled_code[$handle] = $this->compile(trim($row['template_data'])); + $this->compile_write($handle, $this->compiled_code[$handle]); + } + else + { + // Only bother compiling if it doesn't already exist + if (!file_exists($this->cachepath . $row['template_filename'] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx)) + { + $this->filename[$row['template_filename']] = $row['template_filename']; + $this->compile_write($row['template_filename'], $this->compile(trim($row['template_data']))); + unset($this->filename[$row['template_filename']]); + } + } + } + while ($row = $db->sql_fetchrow($result)); + } + $db->sql_freeresult($result); + return false; + } + + $this->_tpl_load_file($handle); + return false; + } + + // Load template source from file + function _tpl_load_file($handle) + { // Try and open template for read if (!($fp = @fopen($this->files[$handle], 'r'))) { trigger_error("template->_tpl_load(): File $filename does not exist or is empty", E_USER_ERROR); } - $str = @fread($fp, filesize($this->files[$handle])); + $this->compiled_code[$handle] = $this->compile(trim(@fread($fp, filesize($this->files[$handle])))); @fclose($fp); // Actually compile the code now. - $this->compiled_code[$handle] = $this->compile(trim($str)); $this->compile_write($handle, $this->compiled_code[$handle]); - - return false; } - // Assign key variable pairs from an array function assign_vars($vararray) { |
