Changeset 243 for branch/rev3/common/index.php
- Timestamp:
- 10/10/07 14:31:28 (13 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branch/rev3/common/index.php
r240 r243 31 31 require_once('common/includes/class.user.php'); 32 32 require_once('common/includes/class.session.php'); 33 require_once('common/includes/class.cache.php'); 33 34 require_once('common/includes/class.involvedloader.php'); 34 35 require_once('common/smarty/Smarty.class.php'); … … 59 60 } 60 61 61 // killboard is instantiated by class::Page62 //$killboard = new Killboard(KB_SITE);63 64 62 // load the config from the database 65 63 $config = new Config(KB_SITE); 64 define('KB_HOST', config::get('cfg_kbhost')); 65 define('MAIN_SITE', config::get('cfg_mainsite')); 66 define('STYLE_URL', config::get('cfg_style')); 67 define('COMMON_URL', config::get('cfg_common')); 68 define('IMG_URL', config::get('cfg_img')); 69 define('DB_HALTONERROR', (bool)config::get('cfg_sqlhalt')); 70 define('DB_USE_QCACHE', (bool)config::get('cfg_qcache')); 71 define('KB_TITLE', config::get('cfg_kbtitle')); 72 73 // corporation OR alliance id 74 if (config::get('cfg_corpid')) 75 { 76 define('CORP_ID', config::get('cfg_corpid')); 77 define('ALLIANCE_ID', 0); 78 } 79 else 80 { 81 define('CORP_ID', 0); 82 define('ALLIANCE_ID', config::get('cfg_allianceid')); 83 } 84 if (!$dir = config::get('cache_dir')) 85 { 86 $dir = 'cache/data'; 87 } 88 define('KB_CACHEDIR', $dir); 66 89 67 90 // setting up smarty and feed it with some config … … 79 102 80 103 // start session management 81 Session::init(); 104 session::init(); 105 106 // reinforced management 107 if (config::get('auto_reinforced')) 108 { 109 // first check if we are in reinforced 110 if (config::get('is_reinforced')) 111 { 112 // every 1/x request we check for disabling RF 113 if (rand(1, config::get('reinforced_rf_prob')) == 1) 114 { 115 cache::checkLoad(); 116 } 117 } 118 else 119 { 120 // reinforced not active 121 // check for load and activate reinforced if needed 122 if (rand(1, config::get('reinforced_prob')) == 1) 123 { 124 cache::checkLoad(); 125 } 126 } 127 } 82 128 83 129 // this is to make sure that smarty is able to create output … … 134 180 } 135 181 136 if (KB_CACHE == 1 && count($_POST) == 0 && !in_array($page, $cacheignore)) 137 { 138 $docache = true; 139 } 140 else 141 { 142 $docache = false; 143 } 144 145 if ($docache) 146 { 147 if (!file_exists(KB_CACHEDIR.'/'.KB_SITE)) 148 { 149 @mkdir(KB_CACHEDIR.'/'.KB_SITE); 150 } 151 152 if ($cachetimes[$page]) 153 { 154 $cachetime = $cachetimes[$page]; 155 } 156 else 157 { 158 $cachetime = 5; 159 } 160 161 $cachetime = $cachetime * 60; 162 163 $cachefile = KB_CACHEDIR.'/'.KB_SITE.'/'.md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'.cache'; 164 $timestamp = ((@file_exists($cachefile))) ? @filemtime($cachefile) : 0; 165 166 if (time() - $cachetime < $timestamp) 167 { 168 ob_start('ob_gzhandler'); 169 @readfile($cachefile); 170 ob_end_flush(); 171 exit(); 172 } 173 174 ob_start(); 175 } 176 182 cache::check($page); 177 183 if ($settingsPage) 178 184 { 179 if (! Session::isAdmin())185 if (!session::isAdmin()) 180 186 { 181 187 header('Location: ?a=login'); … … 195 201 } 196 202 197 if ($docache) 198 { 199 $fp = @fopen($cachefile, 'w'); 200 @fwrite($fp, ob_get_contents()); 201 @fwrite($fp, '<!-- Generated from cache -->'); 202 @fclose($fp); 203 ob_end_flush(); 204 } 203 cache::generate(); 205 204 ?>