add support for gzip compression to style.php as well as adding a much higher expire date - though could be much more effective (but also error prone) due to the session id.

git-svn-id: file:///svn/phpbb/trunk@7949 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2007-07-26 10:08:52 +00:00
parent 074b6e127a
commit 04c3add2ee

View file

@ -126,6 +126,19 @@ if ($id && $sid)
exit; exit;
} }
// gzip_compression
if ($config['gzip_compress'])
{
if (@extension_loaded('zlib') && !headers_sent())
{
ob_start('ob_gzhandler');
}
}
// Expire time of seven days if not recached
$expire_time = 7*86400;
$recache = false;
// Re-cache stylesheet data if necessary // Re-cache stylesheet data if necessary
if ($recompile || empty($theme['theme_data'])) if ($recompile || empty($theme['theme_data']))
{ {
@ -156,36 +169,38 @@ if ($id && $sid)
closedir($dir); closedir($dir);
} }
} }
}
if ($recache) header('Content-type: text/css; charset=UTF-8');
{
include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx);
$theme['theme_data'] = acp_styles::db_theme_data($theme); if ($recache)
$theme['theme_mtime'] = $update_time; {
include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx);
// Save CSS contents $theme['theme_data'] = acp_styles::db_theme_data($theme);
$sql_ary = array( $theme['theme_mtime'] = $update_time;
'theme_mtime' => $theme['theme_mtime'],
'theme_data' => $theme['theme_data']
);
$sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " // Save CSS contents
WHERE theme_id = $id"; $sql_ary = array(
$db->sql_query($sql); 'theme_mtime' => $theme['theme_mtime'],
'theme_data' => $theme['theme_data']
);
$cache->destroy('sql', STYLES_THEME_TABLE); $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE theme_id = $id";
$db->sql_query($sql);
header('Expires: 0'); $cache->destroy('sql', STYLES_THEME_TABLE);
}
header('Cache-Control: private, no-cache="set-cookie"');
header('Expires: 0');
header('Pragma: no-cache');
} }
else else
{ {
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 3600)); header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire_time));
} }
header('Content-type: text/css');
// Parse Theme Data // Parse Theme Data
$replace = array( $replace = array(
'{T_THEME_PATH}' => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme', '{T_THEME_PATH}' => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme',
@ -260,4 +275,6 @@ if ($id && $sid)
$db->sql_close(); $db->sql_close();
} }
exit;
?> ?>