Changeset 383
- Timestamp:
- 06/21/09 12:18:40 (13 years ago)
- Location:
- dev/common
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/includes/class.cache.php
r370 r383 32 32 } 33 33 34 function shouldCache( )34 function shouldCache($page = '') 35 35 { 36 36 // never cache for admins … … 39 39 return false; 40 40 } 41 41 // Don't cache the image files. 42 if (strpos($_SERVER['REQUEST_URI'],'thumb') || 43 strpos($_SERVER['REQUEST_URI'],'mapview')) return false; 42 44 if (config::get('auto_reinforced') && config::get('is_reinforced') && count($_POST) == 0) 43 45 { … … 46 48 47 49 $cacheignore = explode(',', config::get('cache_ignore')); 48 if (KB_CACHE == 1 && count($_POST) == 0 && !in_array($page, $cacheignore))50 if (KB_CACHE == 1 && count($_POST) == 0 && !($page != '' && in_array($page, $cacheignore))) 49 51 { 50 52 return true; 51 53 } 52 54 return false; 53 55 } 54 56 55 57 function check($page) 56 58 { 57 if (cache::shouldCache( ))59 if (cache::shouldCache($page)) 58 60 { 59 61 if (!file_exists(KB_CACHEDIR.'/'.KB_SITE)) … … 61 63 mkdir(KB_CACHEDIR.'/'.KB_SITE); 62 64 } 63 $cachefile = KB_CACHEDIR.'/'.KB_SITE.'/'.md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'.cache'; 64 65 // Include session info in the hash to support session-based security. 66 $cachefile = KB_CACHEDIR.'/'.KB_SITE.'/'.md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].implode($_SESSION)).'.cache'; 67 /* 65 68 // cache is unlimited in reinforced mode 66 69 if (config::get('is_reinforced') && file_exists($cachefile)) … … 76 79 $smarty->assign('message', 'Note: This killboard has entered reinforced operation mode.'); 77 80 } 78 81 */ 79 82 $times = explode(',', config::get('cache_times')); 80 83 foreach ($times as $string) … … 90 93 else 91 94 { 92 $cachetime = 5;95 $cachetime = 1; 93 96 } 94 97 $cachetime = $cachetime * 60; 95 98 96 $timestamp = ((@file_exists($cachefile))) ? @filemtime($cachefile) : 0; 99 if (config::get('is_reinforced')) 100 { 101 global $smarty; 102 $smarty->assign('message', 'Note: This killboard has entered reinforced operation mode.'); 103 // cache is extended in reinforced mode 104 $cachetime = $cachetime * 20; 105 } 106 if(file_exists($cachefile)) 107 { 108 $timestamp = @filemtime($cachefile); 109 if(time() - $cachetime > $timestamp) unlink($cachefile); 110 } 111 else $timestamp = 0; 112 //$timestamp = ((@file_exists($cachefile))) ? @filemtime($cachefile) : 0; 97 113 if (time() - $cachetime < $timestamp) 98 114 { … … 112 128 $cachefile = KB_CACHEDIR.'/'.KB_SITE.'/'.md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'.cache'; 113 129 $fp = @fopen($cachefile, 'w'); 114 @fwrite($fp, ob_get_contents()); 115 @fwrite($fp, '<!-- Generated from cache -->'); 130 //@fwrite($fp, ob_get_contents()); 131 132 @fwrite($fp, preg_replace('/profile -->.*<!-- \/profile/','profile -->Cached '.gmdate("d M Y H:i:s").'<!-- /profile',ob_get_contents())); 133 //if(!strpos($_SERVER['REQUEST_URI'], 'feed')) @fwrite($fp, '<!-- Generated from cache -->'); 116 134 @fclose($fp); 117 135 ob_end_flush(); -
dev/common/includes/globals.php
r376 r383 7 7 else 8 8 { 9 $svn_rev = '3 76';9 $svn_rev = '383'; 10 10 } 11 11 define('SVN_REV', $svn_rev); … … 21 21 // add new corporations here once you've added the logo to img/corps/ 22 22 $corp_npc = array('Guristas', 'Serpentis Corporation', 'Sansha\'s Nation', 'CONCORD', 23 'Mordus Legion', 'Blood Raider', 'Archangels', 'Guardian Angels' );23 'Mordus Legion', 'Blood Raider', 'Archangels', 'Guardian Angels', 'True Power'); 24 24 25 25 function shorten($shorten, $by = 22) -
dev/common/index.php
r370 r383 134 134 } 135 135 } 136 // Enable page caching if set. 137 if(config::get('cache_enabled')) define('KB_CACHE', 1); 138 else define('KB_CACHE', 0); 136 139 137 140 // all admin files are now in the admin directory and preload the menu … … 193 196 $page = 'home'; 194 197 } 195 198 // Serve feeds to feed fetchers. 199 if(strpos($_SERVER['HTTP_USER_AGENT'], 'EDK Feedfetcher') !== false) $page = 'feed'; 196 200 cache::check($page); 197 201 if ($settingsPage)