mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
oi... index page looks good...
git-svn-id: file:///svn/phpbb/trunk@9246 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
11e76473aa
commit
1106aed2f6
4 changed files with 48 additions and 79 deletions
|
@ -180,9 +180,6 @@ class phpbb_template
|
||||||
$_rootref = &$this->_rootref;
|
$_rootref = &$this->_rootref;
|
||||||
$_lang = &phpbb::$user->lang;
|
$_lang = &phpbb::$user->lang;
|
||||||
|
|
||||||
// These _are_ used the included files.
|
|
||||||
$_tpldata; $_rootref; $_lang;
|
|
||||||
|
|
||||||
if (($filename = $this->_tpl_load($handle)) !== false)
|
if (($filename = $this->_tpl_load($handle)) !== false)
|
||||||
{
|
{
|
||||||
($include_once) ? include_once($filename) : include($filename);
|
($include_once) ? include_once($filename) : include($filename);
|
||||||
|
@ -497,9 +494,6 @@ class phpbb_template
|
||||||
$_rootref = &$this->_rootref;
|
$_rootref = &$this->_rootref;
|
||||||
$_lang = &phpbb::$user->lang;
|
$_lang = &phpbb::$user->lang;
|
||||||
|
|
||||||
// These _are_ used the included files.
|
|
||||||
$_tpldata; $_rootref; $_lang;
|
|
||||||
|
|
||||||
if ($filename)
|
if ($filename)
|
||||||
{
|
{
|
||||||
include($filename);
|
include($filename);
|
||||||
|
|
|
@ -17,11 +17,10 @@ if (!defined('IN_PHPBB'))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The template filter that does the actual compilation
|
* The template filter that does the actual compilation
|
||||||
* @see template_compile
|
* @see template_compile
|
||||||
* @package phpBB3
|
* @package phpBB3
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
class phpbb_template_filter extends php_user_filter
|
class phpbb_template_filter extends php_user_filter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -184,25 +183,33 @@ class phpbb_template_filter extends php_user_filter
|
||||||
$text_blocks = str_replace($var_val[0], $new, $text_blocks);
|
$text_blocks = str_replace($var_val[0], $new, $text_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle special language tags L_ and LA_
|
||||||
|
$this->compile_language_tags($text_blocks);
|
||||||
|
|
||||||
// This will handle the remaining root-level varrefs
|
// This will handle the remaining root-level varrefs
|
||||||
|
$text_blocks = preg_replace('#\{([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; ?>", $text_blocks);
|
||||||
|
$text_blocks = preg_replace('#\{\$([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks);
|
||||||
|
|
||||||
|
return $text_blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handlse special language tags L_ and LA_
|
||||||
|
*/
|
||||||
|
private function compile_language_tags(&$text_blocks)
|
||||||
|
{
|
||||||
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
|
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
|
||||||
if (strpos($text_blocks, '{L_') !== false)
|
if (strpos($text_blocks, '{L_') !== false)
|
||||||
{
|
{
|
||||||
$text_blocks = preg_replace('#\{L_([a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); ?>", $text_blocks);
|
$text_blocks = preg_replace('#\{L_([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : (isset(\$_lang['\\1']) ? \$_lang['\\1'] : '{ \\1 }'); ?>", $text_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle addslashed language variables prefixed with LA_
|
// Handle addslashed language variables prefixed with LA_
|
||||||
// If a template variable already exist, it will be used in favor of it...
|
// If a template variable already exist, it will be used in favor of it...
|
||||||
if (strpos($text_blocks, '{LA_') !== false)
|
if (strpos($text_blocks, '{LA_') !== false)
|
||||||
{
|
{
|
||||||
$text_blocks = preg_replace('#\{LA_([a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); ?>", $text_blocks);
|
$text_blocks = preg_replace('#\{LA_([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : (isset(\$_lang['\\1']) ? addslashes(\$_lang['\\1']) : '{ \\1 }')); ?>", $text_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle remaining varrefs
|
|
||||||
$text_blocks = preg_replace('#\{([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; ?>", $text_blocks);
|
|
||||||
$text_blocks = preg_replace('#\{\$([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks);
|
|
||||||
|
|
||||||
return $text_blocks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -508,7 +515,13 @@ class phpbb_template_filter extends php_user_filter
|
||||||
private function compile_tag_if($tag_args, $elseif)
|
private function compile_tag_if($tag_args, $elseif)
|
||||||
{
|
{
|
||||||
$tokens = $this->compile_expression($tag_args);
|
$tokens = $this->compile_expression($tag_args);
|
||||||
return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { ');
|
|
||||||
|
// @todo We suppress notices within IF statements until we find a way to correctly check them
|
||||||
|
$tpl = ($elseif) ? '} else if (@(' : 'if (@(';
|
||||||
|
$tpl .= implode(' ', $tokens);
|
||||||
|
$tpl .= ')) { ';
|
||||||
|
|
||||||
|
return $tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2575,7 +2575,7 @@ function page_header($page_title = '', $display_online_list = true)
|
||||||
'T_ICONS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['icons_path'] . '/',
|
'T_ICONS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['icons_path'] . '/',
|
||||||
'T_RANKS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['ranks_path'] . '/',
|
'T_RANKS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['ranks_path'] . '/',
|
||||||
'T_UPLOAD_PATH' => PHPBB_ROOT_PATH . phpbb::$config['upload_path'] . '/',
|
'T_UPLOAD_PATH' => PHPBB_ROOT_PATH . phpbb::$config['upload_path'] . '/',
|
||||||
'T_STYLESHEET_LINK' => (!phpbb::$user->theme['theme_storedb']) ? PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : phpbb::$url->get(PHPBB_ROOT_PATH . 'style.' . PHP_EXT . '?sid=' . phpbb::$user->session_id . '&id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang']), //PHPBB_ROOT_PATH . "store/{$user->theme['theme_id']}_{$user->theme['imageset_id']}_{$user->lang_name}.css"
|
'T_STYLESHEET_LINK' => (!phpbb::$user->theme['theme_storedb']) ? PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : phpbb::$url->get(PHPBB_ROOT_PATH . 'style.' . PHP_EXT . '?id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang']), //PHPBB_ROOT_PATH . "store/{$user->theme['theme_id']}_{$user->theme['imageset_id']}_{$user->lang_name}.css"
|
||||||
'T_STYLESHEET_NAME' => phpbb::$user->theme['theme_name'],
|
'T_STYLESHEET_NAME' => phpbb::$user->theme['theme_name'],
|
||||||
|
|
||||||
'SITE_LOGO_IMG' => phpbb::$user->img('site_logo'),
|
'SITE_LOGO_IMG' => phpbb::$user->img('site_logo'),
|
||||||
|
@ -2712,9 +2712,9 @@ function garbage_collection()
|
||||||
function exit_handler()
|
function exit_handler()
|
||||||
{
|
{
|
||||||
// needs to be run prior to the hook
|
// needs to be run prior to the hook
|
||||||
if (request::super_globals_disabled())
|
if (phpbb_request::super_globals_disabled())
|
||||||
{
|
{
|
||||||
request::enable_super_globals();
|
phpbb_request::enable_super_globals();
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a pre-caution... some setups display a blank page if the flush() is not there.
|
// As a pre-caution... some setups display a blank page if the flush() is not there.
|
||||||
|
|
|
@ -15,19 +15,10 @@ define('IN_PHPBB', true);
|
||||||
if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './');
|
if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './');
|
||||||
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
|
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
|
||||||
|
|
||||||
$sid = (isset($_GET['sid']) && !is_array($_GET['sid'])) ? htmlspecialchars($_GET['sid']) : '';
|
|
||||||
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
|
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
|
||||||
|
|
||||||
if (strspn($sid, 'abcdefABCDEF0123456789') !== strlen($sid))
|
|
||||||
{
|
|
||||||
$sid = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a simple script to grab and output the requested CSS data stored in the DB
|
// This is a simple script to grab and output the requested CSS data stored in the DB
|
||||||
// We include a session_id check to try and limit 3rd party linking ... unless they
|
// We cache the resulting CSS data for five minutes
|
||||||
// happen to have a current session it will output nothing. We will also cache the
|
|
||||||
// resulting CSS data for five minutes ... anything to reduce the load on the SQL
|
|
||||||
// server a little
|
|
||||||
if (!$id)
|
if (!$id)
|
||||||
{
|
{
|
||||||
exit;
|
exit;
|
||||||
|
@ -35,36 +26,15 @@ if (!$id)
|
||||||
|
|
||||||
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
|
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
|
||||||
|
|
||||||
$user = false;
|
|
||||||
|
|
||||||
if ($sid)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT u.user_id, u.user_lang
|
|
||||||
FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u
|
|
||||||
WHERE s.session_id = '" . $db->sql_escape($sid) . "'
|
|
||||||
AND s.session_user_id = u.user_id";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
$user = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
$recompile = phpbb::$config['load_tplcompile'];
|
|
||||||
if (!$user)
|
|
||||||
{
|
|
||||||
$id = phpbb::$config['default_style'];
|
|
||||||
$recompile = false;
|
|
||||||
$user = array('user_id' => ANONYMOUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT s.style_id, c.theme_id, c.theme_data, c.theme_path, c.theme_name, c.theme_mtime, i.*, t.template_path
|
$sql = 'SELECT s.style_id, c.theme_id, c.theme_data, c.theme_path, c.theme_name, c.theme_mtime, i.*, t.template_path
|
||||||
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . ' i
|
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . ' i
|
||||||
WHERE s.style_id = ' . $id . '
|
WHERE s.style_id = ' . $id . '
|
||||||
AND t.template_id = s.template_id
|
AND t.template_id = s.template_id
|
||||||
AND c.theme_id = s.theme_id
|
AND c.theme_id = s.theme_id
|
||||||
AND i.imageset_id = s.imageset_id';
|
AND i.imageset_id = s.imageset_id';
|
||||||
$result = $db->sql_query($sql, 300);
|
$result = phpbb::$db->sql_query($sql, 300);
|
||||||
$theme = $db->sql_fetchrow($result);
|
$theme = phpbb::$db->sql_fetchrow($result);
|
||||||
$db->sql_freeresult($result);
|
phpbb::$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (!$theme)
|
if (!$theme)
|
||||||
{
|
{
|
||||||
|
@ -72,34 +42,27 @@ if (!$theme)
|
||||||
exit_handler();
|
exit_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user['user_id'] == ANONYMOUS)
|
$user_lang = basename(request_var('lang', phpbb::$config['default_lang']));
|
||||||
{
|
$user_image_lang = (file_exists(PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset/' . $user_lang)) ? $user_lang : phpbb::$config['default_lang'];
|
||||||
$user['user_lang'] = phpbb::$config['default_lang'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_image_lang = (file_exists(PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset/' . $user['user_lang'])) ? $user['user_lang'] : phpbb::$config['default_lang'];
|
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . STYLES_IMAGESET_DATA_TABLE . '
|
FROM ' . STYLES_IMAGESET_DATA_TABLE . '
|
||||||
WHERE imageset_id = ' . $theme['imageset_id'] . "
|
WHERE imageset_id = ' . $theme['imageset_id'] . "
|
||||||
AND image_filename <> ''
|
AND image_filename <> ''
|
||||||
AND image_lang IN ('" . $db->sql_escape($user_image_lang) . "', '')";
|
AND image_lang IN ('" . phpbb::$db->sql_escape($user_image_lang) . "', '')";
|
||||||
$result = $db->sql_query($sql, 3600);
|
$result = phpbb::$db->sql_query($sql, 3600);
|
||||||
|
|
||||||
$img_array = array();
|
$img_array = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = phpbb::$db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$img_array[$row['image_name']] = $row;
|
$img_array[$row['image_name']] = $row;
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
phpbb::$db->sql_freeresult($result);
|
||||||
|
|
||||||
// gzip_compression
|
// gzip_compression
|
||||||
if (phpbb::$config['gzip_compress'])
|
if (phpbb::$config['gzip_compress'])
|
||||||
{
|
{
|
||||||
// IE6 is not able to compress the style (do not ask us why!)
|
if (strpos(strtolower(phpbb::$user->system['browser']), 'msie 6.0') === false && @extension_loaded('zlib') && !headers_sent())
|
||||||
$browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? strtolower(htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT'])) : '';
|
|
||||||
|
|
||||||
if ($browser && strpos($browser, 'msie 6.0') === false && @extension_loaded('zlib') && !headers_sent())
|
|
||||||
{
|
{
|
||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
}
|
}
|
||||||
|
@ -110,7 +73,7 @@ $expire_time = 7 * 86400;
|
||||||
$recache = false;
|
$recache = false;
|
||||||
|
|
||||||
// Re-cache stylesheet data if necessary
|
// Re-cache stylesheet data if necessary
|
||||||
if ($recompile || empty($theme['theme_data']))
|
if (phpbb::$config['load_tplcompile'] || empty($theme['theme_data']))
|
||||||
{
|
{
|
||||||
$recache = (empty($theme['theme_data'])) ? true : false;
|
$recache = (empty($theme['theme_data'])) ? true : false;
|
||||||
$update_time = time();
|
$update_time = time();
|
||||||
|
@ -141,11 +104,12 @@ if ($recompile || empty($theme['theme_data']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We store new data within database
|
||||||
if ($recache)
|
if ($recache)
|
||||||
{
|
{
|
||||||
if (!class_exists('acp_styles'))
|
if (!class_exists('acp_styles'))
|
||||||
{
|
{
|
||||||
include(PHPBB_ROOT_PATH . 'includes/acp/acp_styles.' . PHP_EXT);
|
include PHPBB_ROOT_PATH . 'modules/acp/acp_styles.' . PHP_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$theme['theme_data'] = acp_styles::db_theme_data($theme);
|
$theme['theme_data'] = acp_styles::db_theme_data($theme);
|
||||||
|
@ -157,11 +121,7 @@ if ($recache)
|
||||||
'theme_data' => $theme['theme_data']
|
'theme_data' => $theme['theme_data']
|
||||||
);
|
);
|
||||||
|
|
||||||
// @TODO: rewrite with the new param db functions
|
phpbb::$db->sql_handle_data('UPDATE', STYLES_THEME_TABLE, $sql_ary, 'theme_id = ' . $theme['theme_id']);
|
||||||
$sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
|
|
||||||
WHERE theme_id = {$theme['theme_id']}";
|
|
||||||
$db->sql_query($sql);
|
|
||||||
|
|
||||||
phpbb::$acm->destroy_sql(STYLES_THEME_TABLE);
|
phpbb::$acm->destroy_sql(STYLES_THEME_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,11 +144,12 @@ $replace = array(
|
||||||
'{T_IMAGESET_PATH}' => PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset',
|
'{T_IMAGESET_PATH}' => PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset',
|
||||||
'{T_IMAGESET_LANG_PATH}' => PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset/' . $user_image_lang,
|
'{T_IMAGESET_LANG_PATH}' => PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset/' . $user_image_lang,
|
||||||
'{T_STYLESHEET_NAME}' => $theme['theme_name'],
|
'{T_STYLESHEET_NAME}' => $theme['theme_name'],
|
||||||
'{S_USER_LANG}' => $user['user_lang']
|
'{S_USER_LANG}' => $user_lang,
|
||||||
);
|
);
|
||||||
|
|
||||||
$theme['theme_data'] = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']);
|
$theme['theme_data'] = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']);
|
||||||
|
|
||||||
|
// Replace IMG_*_WIDTH/HEIGHT/SRC tags
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match_all('#\{IMG_([A-Za-z0-9_]*?)_(WIDTH|HEIGHT|SRC)\}#', $theme['theme_data'], $matches);
|
preg_match_all('#\{IMG_([A-Za-z0-9_]*?)_(WIDTH|HEIGHT|SRC)\}#', $theme['theme_data'], $matches);
|
||||||
|
|
||||||
|
@ -210,6 +171,7 @@ if (isset($matches[0]) && sizeof($matches[0]))
|
||||||
{
|
{
|
||||||
$img_data = &$img_array[$img];
|
$img_data = &$img_array[$img];
|
||||||
$imgsrc = ($img_data['image_lang'] ? $img_data['image_lang'] . '/' : '') . $img_data['image_filename'];
|
$imgsrc = ($img_data['image_lang'] ? $img_data['image_lang'] . '/' : '') . $img_data['image_filename'];
|
||||||
|
|
||||||
$imgs[$img] = array(
|
$imgs[$img] = array(
|
||||||
'src' => PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset/' . $imgsrc,
|
'src' => PHPBB_ROOT_PATH . 'styles/' . $theme['imageset_path'] . '/imageset/' . $imgsrc,
|
||||||
'width' => $img_data['image_width'],
|
'width' => $img_data['image_width'],
|
||||||
|
|
Loading…
Add table
Reference in a new issue