From c184fb86c9c6fb6a9dfdb731e785a145069a33ab Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 20 Sep 2011 23:12:07 +0100 Subject: [PATCH] [feature/remove-db-styles] Removed style.php! Finally sanity has arrived! No more delivering CSS through PHP. Better 3 years late than never. PHPBB3-9741 --- phpBB/includes/functions.php | 2 +- phpBB/style.php | 164 ----------------------------------- 2 files changed, 1 insertion(+), 165 deletions(-) delete mode 100644 phpBB/style.php diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 23f3e88be4..5ccb9edd07 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4566,7 +4566,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->lang_name), + 'T_STYLESHEET_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css', 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/' . $user->lang_name . '/stylesheet.css', 'T_STYLESHEET_NAME' => $user->theme['theme_name'], diff --git a/phpBB/style.php b/phpBB/style.php deleted file mode 100644 index c84713f267..0000000000 --- a/phpBB/style.php +++ /dev/null @@ -1,164 +0,0 @@ -register(); - - // set up caching - $cache_factory = new phpbb_cache_factory($acm_type); - $cache = $cache_factory->get_service(); - $class_loader->set_cache($cache->get_driver()); - - $request = new phpbb_request(); - $db = new $sql_db(); - - // make sure request_var uses this request instance - request_var('', 0, false, false, $request); // "dependency injection" for a function - - // Connect to DB - if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) - { - exit; - } - unset($dbpasswd); - - $config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); - set_config(null, null, null, $config); - set_config_count(null, null, null, $config); - - $user = false; - - // try to get a session ID from REQUEST array - $sid = request_var('sid', ''); - - if (!$sid) - { - // if that failed, then look in the cookies - $sid = request_var($config['cookie_name'] . '_sid', '', false, true); - } - - if (strspn($sid, 'abcdefABCDEF0123456789') !== strlen($sid)) - { - $sid = ''; - } - - 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 = $config['load_tplcompile']; - if (!$user) - { - $id = ($id) ? $id : $config['default_style']; -// Commented out because calls do not always include the SID anymore -// $recompile = false; - $user = array('user_id' => ANONYMOUS); - } - - $sql = 'SELECT s.style_id, c.theme_id, c.theme_path, c.theme_name, t.template_path - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c - WHERE s.style_id = ' . $id . ' - AND t.template_id = s.template_id - AND c.theme_id = s.theme_id'; - $result = $db->sql_query($sql, 300); - $theme = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$theme) - { - exit; - } - - if ($user['user_id'] == ANONYMOUS) - { - $user['user_lang'] = $config['default_lang']; - } - - // gzip_compression - if ($config['gzip_compress']) - { - // IE6 is not able to compress the style (do not ask us why!) - $browser = strtolower($request->header('User-Agent')); - - if ($browser && strpos($browser, 'msie 6.0') === false && @extension_loaded('zlib') && !headers_sent()) - { - ob_start('ob_gzhandler'); - } - } - - // Expire time of seven days if not recached - $expire_time = 7*86400; - - include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx); - - $theme['theme_data'] = acp_styles::db_theme_data($theme); - - header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire_time)); - header('Content-type: text/css; charset=UTF-8'); - - // Echo Theme Data - echo $theme['theme_data']; - - if (!empty($cache)) - { - $cache->unload(); - } - $db->sql_close(); -}