diff --git a/class2.php b/class2.php index cb7761b5c..06b4e9643 100644 --- a/class2.php +++ b/class2.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/class2.php,v $ -| $Revision: 1.11 $ -| $Date: 2007-02-03 12:43:53 $ -| $Author: e107steved $ +| $Revision: 1.12 $ +| $Date: 2007-02-04 17:36:16 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ // @@ -267,7 +267,7 @@ e107_require_once(e_HANDLER.'cache_handler.php'); e107_require_once(e_HANDLER.'arraystorage_class.php'); $eArrayStorage = new ArrayData(); -$PrefCache = ecache::retrieve('SitePrefs', 24 * 60, true); +$PrefCache = ecache::retrieve_sys('SitePrefs', 24 * 60, true); if(!$PrefCache){ // No cache of the prefs array, going for the db copy.. $retrieve_prefs[] = 'SitePrefs'; @@ -311,7 +311,7 @@ if(!$PrefCache){ // write pref cache array $PrefCache = $eArrayStorage->WriteArray($pref, false); // store the prefs in cache if cache is enabled - ecache::set('SitePrefs', $PrefCache); + ecache::set_sys('SitePrefs', $PrefCache); } else { // cache of core prefs was found, so grab all the useful core rows we need if(!isset($sysprefs->DefaultIgnoreRows)){ @@ -715,7 +715,7 @@ define("TIMEOFFSET", $e_deltaTime); $sql->db_Mark_Time('Start: Get menus'); -$menu_data = $e107cache->retrieve("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE)); +$menu_data = $e107cache->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE)); $menu_data = $eArrayStorage->ReadArray($menu_data); $eMenuList=array(); $eMenuActive=array(); @@ -729,7 +729,7 @@ if(!is_array($menu_data)) { $menu_data['menu_list'] = $eMenuList; $menu_data['menu_active'] = $eMenuActive; $menu_data = $eArrayStorage->WriteArray($menu_data, false); - $e107cache->set("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE), $menu_data); + $e107cache->set_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE), $menu_data); unset($menu_data); } else { $eMenuList = $menu_data['menu_list']; @@ -1030,7 +1030,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '') $msqlPrefCache = $eArrayStorage->WriteArray($_pref); $sql->db_Select_gen("INSERT INTO #core (e107_name,e107_value) values ('SitePrefs', '{$msqlPrefCache}') ON DUPLICATE KEY UPDATE e107_value='{$msqlPrefCache}'"); - ecache::clear('SitePrefs'); + ecache::clear_sys('SitePrefs'); } } else diff --git a/e107_admin/cache.php b/e107_admin/cache.php index 0e6098fc5..15e1e320d 100644 --- a/e107_admin/cache.php +++ b/e107_admin/cache.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $ -| $Revision: 1.1.1.1 $ -| $Date: 2006-12-02 04:33:12 $ +| $Revision: 1.2 $ +| $Date: 2007-02-04 17:36:16 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -27,54 +27,81 @@ require_once(e_HANDLER."cache_handler.php"); $ec = new ecache; if ($pref['cachestatus'] == '2') { $pref['cachestatus'] = '1'; + save_prefs(); } -if (isset($_POST['submit_cache'])) { - if ($pref['cachestatus'] != $_POST['cachestatus']) { + +if(!is_writable(e_BASE.$FILES_DIRECTORY.'cache/')) +{ + $ns->tablerender(CACLAN_3, CACLAN_10); + require_once("footer.php"); + exit; +} + +if (isset($_POST['submit_cache'])) +{ + if ($pref['cachestatus'] != $_POST['cachestatus'] || $pref['syscachestatus'] != $_POST['syscachestatus']) + { $pref['cachestatus'] = $_POST['cachestatus']; + $pref['syscachestatus'] = $_POST['syscachestatus']; save_prefs(); $ec->clear(); + $ec->clear_sys(); $update = true; + admin_update($update, 'update', CACLAN_4); } - admin_update($update, 'update', CACLAN_4); } - + +if (isset($_POST['empty_syscache'])) { + $ec->clear_sys(); + $ns->tablerender(LAN_UPDATE, "
".CACLAN_15."
"); +} + if (isset($_POST['empty_cache'])) { $ec->clear(); $ns->tablerender(LAN_UPDATE, "
".CACLAN_6."
"); } +$syscache_files = glob($e107->file_path.$FILES_DIRECTORY."cache/S_*.*"); +$cache_files = glob($e107->file_path.$FILES_DIRECTORY."cache/C_*.*"); + +$syscache_files_num = count($syscache_files); +$cache_files_num = count($cache_files); + +$sys_count = CACLAN_17." ".$syscache_files_num." ".($syscache_files_num != 1 ? CACLAN_19 : CACLAN_18); +$nonsys_count = CACLAN_17." ".$cache_files_num." ".($cache_files_num != 1 ? CACLAN_19 : CACLAN_18); + $text = "
- + - + + - + - + + - + + -
".CACLAN_1."".CACLAN_1."
"; -$text .= (!$pref['cachestatus']) ? "" : - ""; -$text .= CACLAN_7." + +
".CACLAN_11.":
".CACLAN_13."

{$nonsys_count}
+ ".LAN_ENABLED."   + ".LAN_DISABLED."   +
"; -if (is_writable(e_FILE."cache")) { - $text .= ('1' == $pref['cachestatus']) ? "" : - ""; - $text .= CACLAN_9; -} else { - $text .= CACLAN_9."

".CACLAN_10.""; -} -$text .= "
".CACLAN_12.":
".CACLAN_14."

{$sys_count}
+ ".LAN_ENABLED."   + ".LAN_DISABLED."   + +
- + +
- - +
diff --git a/e107_handlers/cache_handler.php b/e107_handlers/cache_handler.php index 0c604da43..8feafc437 100644 --- a/e107_handlers/cache_handler.php +++ b/e107_handlers/cache_handler.php @@ -12,8 +12,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/cache_handler.php,v $ -| $Revision: 1.1.1.1 $ -| $Date: 2006-12-02 04:33:42 $ +| $Revision: 1.2 $ +| $Date: 2007-02-04 17:36:16 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -24,7 +24,7 @@ if (!defined('e107_INIT')) { exit; } * Class to cache data as files, improving site speed and throughput. * * @package e107 -* @version $Revision: 1.1.1.1 $ +* @version $Revision: 1.2 $ * @author $Author: mcfly_e107 $ */ class ecache { @@ -39,7 +39,8 @@ class ecache { * @scope private * If the tag begins 'menu_', e_QUERY is not included in the hash which creates the file name */ - function cache_fname($CacheTag) { + function cache_fname($CacheTag, $syscache = false) + { global $FILES_DIRECTORY; if(strpos($CacheTag, "nomd5_") === 0) { // Add 'nomd5' to indicate we are not calculating an md5 @@ -68,8 +69,9 @@ class ecache { } else { $CheckTag = ''; } - $q = preg_replace("#\W#", "_", $CacheTag); + $q = ($syscache ? "S_" : "C_").preg_replace("#\W#", "_", $CacheTag); $fname = './'.e_BASE.$FILES_DIRECTORY.'cache/'.$q.$CheckTag.'.cache.php'; + //echo "cache f_name = $fname
"; return $fname; } @@ -80,10 +82,11 @@ class ecache { * @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query. * @scope public */ - function retrieve($CacheTag, $MaximumAge = false, $ForcedCheck = false) { + function retrieve($CacheTag, $MaximumAge = false, $ForcedCheck = false, $syscache = false) { global $pref, $FILES_DIRECTORY, $tp; - if (($pref['cachestatus'] || $ForcedCheck == true) && !$tp->checkHighlighting()) { - $cache_file = (isset($this) ? $this->cache_fname($CacheTag) : ecache::cache_fname($CacheTag)); + if(($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting()) + { + $cache_file = (isset($this) ? $this->cache_fname($CacheTag, $syscache) : ecache::cache_fname($CacheTag, $syscache)); if (file_exists($cache_file)) { if ($MaximumAge != false && (filemtime($cache_file) + ($MaximumAge * 60)) < time()) { unlink($cache_file); @@ -100,6 +103,26 @@ class ecache { return false; } + /** + * @return string + * @param string $query + * @param int $MaximumAge the time in minutes before the cache file 'expires' + * @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query. + * @scope public + */ + function retrieve_sys($CacheTag, $MaximumAge = false, $ForcedCheck = false) + { + if(isset($this)) + { + return $this->retrieve($CacheTag, $MaximumAge, $ForcedCheck, true); + } + else + { + return ecache::retrieve($CacheTag, $MaximumAge, $ForcedCheck, true); + } + } + + /** * @return void * @param string $CacheTag - name of tag for future retrieval @@ -109,29 +132,69 @@ class ecache { * @desc Creates / overwrites the cache file for $query, $text is the data to store for $query. * @scope public */ - function set($CacheTag, $Data, $ForceCache = false, $bRaw=0) { + function set($CacheTag, $Data, $ForceCache = false, $bRaw=0, $syscache = false) { global $pref, $FILES_DIRECTORY, $tp; - if (($pref['cachestatus'] || $ForceCache == true) && !$tp->checkHighlighting()) { - $cache_file = (isset($this) ? $this->cache_fname($CacheTag) : ecache::cache_fname($CacheTag)); + if(($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting()) + { + $cache_file = (isset($this) ? $this->cache_fname($CacheTag, $syscache) : ecache::cache_fname($CacheTag, $syscache)); file_put_contents($cache_file, ($bRaw? $Data : 'set($CacheTag, $Data, $ForceCache, $bRaw, true); + } + else + { + ecache::set($CacheTag, $Data, $ForceCache, $bRaw, true); + } + } + + /** * @return bool * @param string $CacheTag * @desc Deletes cache files. If $query is set, deletes files named {$CacheTag}*.cache.php, if not it deletes all cache files - (*.cache.php) */ - function clear($CacheTag = '') { + function clear($CacheTag = '', $syscache = false) { global $pref, $FILES_DIRECTORY; $file = ($CacheTag) ? preg_replace("#\W#", "_", $CacheTag)."*.cache.php" : "*.cache.php"; $dir = "./".e_BASE.$FILES_DIRECTORY."cache/"; - $ret = ecache::delete($dir, $file); + $ret = ecache::delete($dir, $file, $syscache); return $ret; } + /** + * @return bool + * @param string $CacheTag + * @desc Deletes cache files. If $query is set, deletes files named {$CacheTag}*.cache.php, if not it deletes all cache files - (*.cache.php) + */ + function clear_sys($CacheTag = '') + { + if(isset($this)) + { + return $this->clear($CacheTag, true); + } + else + { + ecache::clear($CacheTag, true); + } + } + /** * @return bool * @param string $dir @@ -139,8 +202,9 @@ class ecache { * @desc Internal class function to allow deletion of cache files using a pattern, default '*.*' * @scope private */ - function delete($dir, $pattern = "*.*") { + function delete($dir, $pattern = "*.*", $syscache = false) { $deleted = false; + $pattern = ($syscache ? "S_" : "C_").$pattern; $pattern = str_replace(array("\*", "\?"), array(".*", "."), preg_quote($pattern)); if (substr($dir, -1) != "/") { $dir .= "/"; diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index bd94b040d..f1f968f72 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -12,9 +12,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $ -| $Revision: 1.3 $ -| $Date: 2006-12-05 09:15:05 $ -| $Author: mrpete $ +| $Revision: 1.4 $ +| $Date: 2007-02-04 17:36:16 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -169,9 +169,9 @@ class e_shortcode { $cur_shortcodes = array(); if($type == 'file') { - $batch_cachefile = "nomd5_".md5($fname); + $batch_cachefile = "nomd5_scbatch_".md5($fname); // $cache_filename = $e107cache->cache_fname("nomd5_{$batchfile_md5}"); - $sc_cache = $e107cache->retrieve($batch_cachefile); + $sc_cache = $e107cache->retrieve_sys($batch_cachefile); if(!$sc_cache) { $sc_batch = file($fname); @@ -209,7 +209,7 @@ class e_shortcode { if($type == 'file') { $sc_cache = $eArrayStorage->WriteArray($cur_shortcodes, false); - $e107cache->set($batch_cachefile, $sc_cache); + $e107cache->set_sys($batch_cachefile, $sc_cache); } } diff --git a/e107_languages/English/admin/lan_cache.php b/e107_languages/English/admin/lan_cache.php index 3e6bc8286..dbcb31787 100644 --- a/e107_languages/English/admin/lan_cache.php +++ b/e107_languages/English/admin/lan_cache.php @@ -4,8 +4,8 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_cache.php,v $ -| $Revision: 1.1.1.1 $ -| $Date: 2006-12-02 04:34:40 $ +| $Revision: 1.2 $ +| $Date: 2007-02-04 17:36:16 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -16,8 +16,17 @@ define("CACLAN_4", "Cache status set"); define("CACLAN_5", "Empty Cache"); define("CACLAN_6", "Cache Emptied"); -define("CACLAN_7", "Cache Disabled"); -// define("CACLAN_8", "Cache data saved to MySQL"); -define("CACLAN_9", "Cache data saved to disk file"); define("CACLAN_10", "The cache directory is not writable. Please ensure this directory is set CHMOD 0777"); + +define("CACLAN_11", "Content Cache"); +define("CACLAN_12", "System Cache"); +define("CACLAN_13", "Content cache contains page rendered content. This includes any content (html) that you see rendered on your site."); +define("CACLAN_14", "System cache contains system config information. This includes site pref, currently active menus, etc. No actual content will be contained here."); +define("CACLAN_15", "System Cache Emptied"); +define("CACLAN_16", "Empty System Cache"); +define("CACLAN_17", "Currently contains"); +define("CACLAN_18", "file"); +define("CACLAN_19", "files"); + + ?> \ No newline at end of file