root / tags / milestone_3 / phpBB / style.php
History | View | Annotate | Download (3.4 kB)
| 1 | 4321 | psotfx | <?php
|
|---|---|---|---|
| 2 | 5114 | acydburn | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package phpBB3 |
| 5 | 5114 | acydburn | * @version $Id$ |
| 6 | 5114 | acydburn | * @copyright (c) 2005 phpBB Group |
| 7 | 5114 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5114 | acydburn | * |
| 9 | 5114 | acydburn | */ |
| 10 | 4321 | psotfx | |
| 11 | 5114 | acydburn | /**
|
| 12 | 5114 | acydburn | */ |
| 13 | 4321 | psotfx | define('IN_PHPBB', true); |
| 14 | 4321 | psotfx | $phpbb_root_path = './'; |
| 15 | 4473 | psotfx | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 16 | 4321 | psotfx | require($phpbb_root_path . 'config.'.$phpEx); |
| 17 | 4321 | psotfx | |
| 18 | 4321 | psotfx | set_magic_quotes_runtime(0); |
| 19 | 4321 | psotfx | |
| 20 | 4321 | psotfx | // Load Extensions
|
| 21 | 4321 | psotfx | if (!empty($load_extensions)) |
| 22 | 4321 | psotfx | {
|
| 23 | 4321 | psotfx | $load_extensions = explode(',', $load_extensions); |
| 24 | 4321 | psotfx | |
| 25 | 4321 | psotfx | foreach ($load_extensions as $extension) |
| 26 | 4321 | psotfx | {
|
| 27 | 4321 | psotfx | @dl(trim($extension)); |
| 28 | 4321 | psotfx | } |
| 29 | 4321 | psotfx | } |
| 30 | 4321 | psotfx | |
| 31 | 4321 | psotfx | // This is a simple script to grab and output the requested CSS data stored in the DB
|
| 32 | 4321 | psotfx | // We include a session_id check to try and limit 3rd party linking ... unless they
|
| 33 | 4321 | psotfx | // happen to have a current session it will output nothing. We will also cache the
|
| 34 | 4321 | psotfx | // resulting CSS data for five minutes ... anything to reduce the load on the SQL
|
| 35 | 4321 | psotfx | // server a little
|
| 36 | 4321 | psotfx | if (!empty($_GET['id']) && !empty($_GET['sid'])) |
| 37 | 4321 | psotfx | {
|
| 38 | 4321 | psotfx | // Include files
|
| 39 | 4321 | psotfx | require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx); |
| 40 | 5255 | acydburn | require($phpbb_root_path . 'includes/acm/acm_main.' . $phpEx); |
| 41 | 4321 | psotfx | require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx); |
| 42 | 4321 | psotfx | |
| 43 | 5199 | acydburn | $db = new $sql_db(); |
| 44 | 5255 | acydburn | $cache = new cache(); |
| 45 | 4321 | psotfx | |
| 46 | 4321 | psotfx | // Connect to DB
|
| 47 | 4321 | psotfx | if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false)) |
| 48 | 4321 | psotfx | {
|
| 49 | 4321 | psotfx | exit;
|
| 50 | 4321 | psotfx | } |
| 51 | 4321 | psotfx | |
| 52 | 4321 | psotfx | $sid = htmlspecialchars($_GET['sid']); |
| 53 | 4321 | psotfx | $id = intval($_GET['id']); |
| 54 | 4321 | psotfx | |
| 55 | 5068 | acydburn | $sql = "SELECT s.session_id, u.user_lang |
| 56 | 5068 | acydburn | FROM {$table_prefix}sessions s, {$table_prefix}users u |
| 57 | 5068 | acydburn | WHERE s.session_id = '" . ((!get_magic_quotes_gpc()) ? $db->sql_escape($sid) : $sid) . "' |
| 58 | 5068 | acydburn | AND s.session_user_id = u.user_id";
|
| 59 | 4321 | psotfx | $result = $db->sql_query($sql); |
| 60 | 4321 | psotfx | |
| 61 | 5068 | acydburn | if ($user = $db->sql_fetchrow($result)) |
| 62 | 4321 | psotfx | {
|
| 63 | 5068 | acydburn | $sql = "SELECT s.style_id, c.theme_data, c.theme_path, c.theme_mtime, i.imageset_path, t.template_path |
| 64 | 5068 | acydburn | FROM {$table_prefix}styles s, {$table_prefix}styles_template t, {$table_prefix}styles_theme c, {$table_prefix}styles_imageset i |
| 65 | 5068 | acydburn | WHERE s.style_id = $id |
| 66 | 5068 | acydburn | AND t.template_id = s.template_id |
| 67 | 5068 | acydburn | AND c.theme_id = s.theme_id |
| 68 | 5068 | acydburn | AND i.imageset_id = s.imageset_id";
|
| 69 | 5257 | acydburn | $result2 = $db->sql_query($sql, 300); |
| 70 | 4321 | psotfx | |
| 71 | 5068 | acydburn | if (!($theme = $db->sql_fetchrow($result2))) |
| 72 | 4321 | psotfx | {
|
| 73 | 5068 | acydburn | exit;
|
| 74 | 5068 | acydburn | } |
| 75 | 5068 | acydburn | $db->sql_freeresult($result2); |
| 76 | 4321 | psotfx | |
| 77 | 5068 | acydburn | if ($theme['theme_mtime'] < filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css')) |
| 78 | 5068 | acydburn | {
|
| 79 | 5068 | acydburn | $theme['theme_data'] = implode('', file("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css')); |
| 80 | 5068 | acydburn | |
| 81 | 5068 | acydburn | $db->sql_query("UPDATE {$table_prefix}styles_theme SET theme_data = '" . $db->sql_escape($theme['theme_data']) . "', theme_mtime = " . time() . " |
| 82 | 5068 | acydburn | WHERE theme_id = $id"); |
| 83 | 4321 | psotfx | } |
| 84 | 5068 | acydburn | |
| 85 | 5068 | acydburn | header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 3600)); |
| 86 | 5068 | acydburn | header('Content-type: text/css'); |
| 87 | 5068 | acydburn | |
| 88 | 5068 | acydburn | // Parse Theme Data
|
| 89 | 5068 | acydburn | $replace = array( |
| 90 | 5068 | acydburn | '{T_THEME_PATH}' => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme', |
| 91 | 5068 | acydburn | '{T_TEMPLATE_PATH}' => "{$phpbb_root_path}styles/" . $theme['template_path'] . '/template', |
| 92 | 5068 | acydburn | '{T_IMAGESET_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset', |
| 93 | 5068 | acydburn | '{T_IMAGESET_LANG_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset/' . $user['user_lang'], |
| 94 | 5068 | acydburn | '{T_STYLESHEET_NAME}' => $theme['theme_name'], |
| 95 | 5068 | acydburn | '{S_USER_LANG}' => $user['user_lang'] |
| 96 | 5068 | acydburn | ); |
| 97 | 5068 | acydburn | |
| 98 | 5068 | acydburn | $theme['theme_data'] = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']); |
| 99 | 5068 | acydburn | |
| 100 | 5068 | acydburn | echo $theme['theme_data']; |
| 101 | 4321 | psotfx | } |
| 102 | 4321 | psotfx | $db->sql_freeresult($result); |
| 103 | 4321 | psotfx | |
| 104 | 4321 | psotfx | if (!empty($cache)) |
| 105 | 4321 | psotfx | {
|
| 106 | 4321 | psotfx | $cache->unload();
|
| 107 | 4321 | psotfx | } |
| 108 | 4321 | psotfx | $db->sql_close();
|
| 109 | 4321 | psotfx | } |
| 110 | 4321 | psotfx | |
| 111 | 4321 | psotfx | ?> |

