X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fload_cache.php;h=0f22199809b3c8b81a868d1385ed227a041b64b3;hp=69aec9887beebeecad67665665860d7fc38c1d9c;hb=8a9324b2d931f54f54f4319fd7234910af77012c;hpb=e1653405d28923c78b2e292125306ccf61138f24 diff --git a/inc/load_cache.php b/inc/load_cache.php index 69aec9887b..0f22199809 100644 --- a/inc/load_cache.php +++ b/inc/load_cache.php @@ -32,42 +32,35 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) -{ +if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); } // Let's start with the admins table... -if (($CACHE->cache_file("admins", true) == true)) -{ +if (($CACHE->cache_file("admins", true) == true)) { // Load cache global $ADMINS; $ADMINS = $CACHE->cache_load(); // Check if valid - if (is_array($ADMINS['login']) && is_array($ADMINS['def_acl']) && is_array($ADMINS['aid'])) - { + if ((is_array($ADMINS['login'])) && (is_array($ADMINS['aid']))) { // Check count - if (count($ADMINS['login']) == count($ADMINS['aid']) && count($ADMINS['login']) == count($ADMINS['def_acl']) && count($ADMINS['aid']) == count($ADMINS['def_acl'])) - { + if (count($ADMINS['login']) == count($ADMINS['aid'])) { //* DEBUG: */ echo "
";
 			//* DEBUG: */ print_r($ADMINS);
 
 			// The cache file seems to be fine
-			foreach ($ADMINS['login'] as $k=>$login)
-			{
+			foreach ($ADMINS['login'] as $k=>$login) {
 				// Rewrite default_acl
 				$ADMINS['aid'][$login]      = $ADMINS['aid'][$k];
 				$ADMINS['password'][$login] = $ADMINS['password'][$k];
 				$ADMINS['email'][$login]    = $ADMINS['email'][$k];
 
 				// Some extra data depening on version
-				if (GET_EXT_VERSION("admins") >= "0.3")
-				{
+				if (GET_EXT_VERSION("admins") >= "0.3") {
 					$ADMINS['def_acl'][$login]  = $ADMINS['def_acl'][$k];
-					if (GET_EXT_VERSION("admins") >= "0.6.7")
-					{
+					if (GET_EXT_VERSION("admins") >= "0.6.7") {
 						$ADMINS['la_mode'][$login]  = $ADMINS['la_mode'][$k];
 					}
 				}
@@ -85,11 +78,9 @@ if (($CACHE->cache_file("admins", true) == true))
 			//* DEBUG: */ print_r($ADMINS);
 
 			// Rewrite Login
-			foreach ($ADMINS['login'] as $k=>$login)
-			{
+			foreach ($ADMINS['login'] as $k=>$login) {
 				$ADMINS['login'][$ADMINS['aid'][$login]] = $login;
-				if (!in_array($k, $ADMINS['aid']))
-				{
+				if (!in_array($k, $ADMINS['aid'])) {
 					unset($ADMINS['login'][$k]);
 				}
 			}
@@ -98,22 +89,16 @@ if (($CACHE->cache_file("admins", true) == true))
 			//* DEBUG: */ print_r($ADMINS);
 			//* DEBUG: */ echo "
"; //* DEBUG: */ die(); - } - else - { + } else { // Nope, cache file is corrupted! $CACHE->cache_destroy(); } - } - else - { + } else { // Nope, cache file is corrupted! $CACHE->cache_destroy(); unset($ADMINS); } -} - elseif (($CONFIG['cache_admins'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) -{ +} elseif (($CONFIG['cache_admins'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) { // Create cache file $CACHE->cache_init("ADMINS"); @@ -122,11 +107,11 @@ if (($CACHE->cache_file("admins", true) == true)) if (GET_EXT_VERSION("admins") >= "0.3") $ADD = ", default_acl AS def_acl"; if (GET_EXT_VERSION("admins") >= "0.6.7") $ADD .= ", la_mode"; + // Query the database about this $result_admins = SQL_QUERY("SELECT id AS aid, login, password, email".$ADD." FROM "._MYSQL_PREFIX."_admins ORDER BY login", __FILE__, __LINE__); - while($dummy = SQL_FETCHARRAY($result_admins)) - { + while($dummy = SQL_FETCHARRAY($result_admins)) { // Save row $CACHE->add_row($dummy); } @@ -139,16 +124,14 @@ ORDER BY login", __FILE__, __LINE__); $CACHE->cache_close(); // Next cached table is the module registry (mod_reg)... -if ($CACHE->cache_file("mod_reg", true) == true) -{ +if ($CACHE->cache_file("mod_reg", true) == true) { // Load cache global $MODULES; $MODULES = $CACHE->cache_load(); // Valid cache file $CNT = 0; - foreach ($MODULES as $k=>$array) - { + foreach ($MODULES as $k=>$array) { $CNT += count($array); } @@ -156,18 +139,14 @@ if ($CACHE->cache_file("mod_reg", true) == true) // damaged/corrupted $TEST = "failed"; if (count($MODULES) > 0 ) $TEST = ($CNT / (count($MODULES))); - if ($TEST != bigintval($TEST)) - { + if ($TEST != bigintval($TEST)) { // Cache file is corrupted! $CACHE->cache_destroy(); unset($MODULES); - } - else - { + } else { // Rewrite module cache $MOD = $MODULES; - foreach ($MODULES['module'] as $key=>$mod) - { + foreach ($MODULES['module'] as $key=>$mod) { $MODULES['id'][$mod] = $MODULES['id'][$key]; unset($MODULES['id'][$key]); $MODULES['title'][$mod] = $MODULES['title'][$key]; @@ -184,27 +163,21 @@ if ($CACHE->cache_file("mod_reg", true) == true) unset($MODULES['has_menu'][$key]); } } -} - elseif (($CONFIG['cache_modreg'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) -{ +} elseif (($CONFIG['cache_modreg'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) { // Create cache file here $CACHE->cache_init("MODULES"); // Load all modules and their data - if (GET_EXT_VERSION("sql_patches") >= "0.3.6") - { + if (GET_EXT_VERSION("sql_patches") >= "0.3.6") { // Load has_menu $result = SQL_QUERY("SELECT id, module, title, locked, hidden, admin_only, title, mem_only, has_menu FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__); - } - else - { + } else { // Don't load has_menu $result = SQL_QUERY("SELECT id, module, title, locked, hidden, admin_only, title, mem_only FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__); } - while ($DATA = SQL_FETCHARRAY($result)) - { + while ($DATA = SQL_FETCHARRAY($result)) { // Add row to cache file $CACHE->add_row($DATA); } @@ -217,16 +190,14 @@ FROM "._MYSQL_PREFIX."_mod_reg ORDER BY id", __FILE__, __LINE__); $CACHE->cache_close(); // Next cached table is the configuration (config)... -if ($CACHE->cache_file("config", true) == true) -{ +if ($CACHE->cache_file("config", true) == true) { // Load config from cache global $CFG_CACHE; $CFG_CACHE = $CACHE->cache_load(); // Valid cache file $CNT = 0; - foreach ($CFG_CACHE as $k=>$array) - { + foreach ($CFG_CACHE as $k=>$array) { $CNT += count($array); } @@ -234,22 +205,18 @@ if ($CACHE->cache_file("config", true) == true) // damaged/corrupted $TEST = "failed"; if (count($CFG_CACHE) > 0 ) $TEST = ($CNT / (count($CFG_CACHE))); - if ($TEST != bigintval($TEST)) - { + if ($TEST != bigintval($TEST)) { // Cache file is corrupted! $CACHE->cache_destroy(); unset($CFG_CACHE); } -} - elseif (($CONFIG['cache_config'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) -{ +} elseif (($CONFIG['cache_config'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) { // Create cache file here $CACHE->cache_init("CONFIG"); // Load all modules and their data $result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX."_config ORDER BY config", __FILE__, __LINE__); - while ($DATA = SQL_FETCHARRAY($result)) - { + while ($DATA = SQL_FETCHARRAY($result)) { // Add row to cache file $CACHE->add_row($DATA); } @@ -262,16 +229,14 @@ if ($CACHE->cache_file("config", true) == true) $CACHE->cache_close(); // Next cached table is the referral system (refsystem)... -if ($CACHE->cache_file("refsystem", true) == true) -{ +if ($CACHE->cache_file("refsystem", true) == true) { // Load referral system from cache global $REF_SYSTEM; $REF_SYSTEM = $CACHE->cache_load(); // Valid cache file $CNT = 0; - foreach ($REF_SYSTEM as $k=>$array) - { + foreach ($REF_SYSTEM as $k=>$array) { $CNT += count($array); } @@ -279,22 +244,18 @@ if ($CACHE->cache_file("refsystem", true) == true) // damaged/corrupted $TEST = "failed"; if (count($REF_SYSTEM) > 0 ) $TEST = ($CNT / (count($REF_SYSTEM))); - if ($TEST != bigintval($TEST)) - { + if ($TEST != bigintval($TEST)) { // Cache file is corrupted! $CACHE->cache_destroy(); unset($REF_SYSTEM); } -} - elseif (($CONFIG['cache_refsys'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) -{ +} elseif (($CONFIG['cache_refsys'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) { // Create cache file here $CACHE->cache_init("REFSYSTEM"); // Load all modules and their data $result = SQL_QUERY("SELECT id, userid, level, counter FROM "._MYSQL_PREFIX."_refsystem ORDER BY userid, level", __FILE__, __LINE__); - while ($DATA = SQL_FETCHARRAY($result)) - { + while ($DATA = SQL_FETCHARRAY($result)) { // Add row to cache file $CACHE->add_row($DATA); } @@ -307,16 +268,14 @@ if ($CACHE->cache_file("refsystem", true) == true) $CACHE->cache_close(); // Next cached table is the referral system (refdepths)... -if ($CACHE->cache_file("refdepths", true) == true) -{ +if ($CACHE->cache_file("refdepths", true) == true) { // Load referral system from cache global $REF_DEPTHS; $REF_DEPTHS = $CACHE->cache_load(); // Valid cache file $CNT = 0; - foreach ($REF_DEPTHS as $k=>$array) - { + foreach ($REF_DEPTHS as $k=>$array) { $CNT += count($array); } @@ -324,22 +283,18 @@ if ($CACHE->cache_file("refdepths", true) == true) // damaged/corrupted $TEST = "failed"; if (count($REF_DEPTHS) > 0 ) $TEST = ($CNT / (count($REF_DEPTHS))); - if ($TEST != bigintval($TEST)) - { + if ($TEST != bigintval($TEST)) { // Cache file is corrupted! $CACHE->cache_destroy(); unset($REF_DEPTHS); } -} - elseif (($CONFIG['cache_refdepth'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) -{ +} elseif (($CONFIG['cache_refdepth'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) { // Create cache file here $CACHE->cache_init("REFDEPTHS"); // Load all modules and their data $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__); - while ($DATA = SQL_FETCHARRAY($result)) - { + while ($DATA = SQL_FETCHARRAY($result)) { // Add row to cache file $CACHE->add_row($DATA); } @@ -352,45 +307,37 @@ if ($CACHE->cache_file("refdepths", true) == true) $CACHE->cache_close(); // Next cached table is the referral system (admins_acls)... -if (GET_EXT_VERSION("admins") >= "0.3") -{ +if (GET_EXT_VERSION("admins") >= "0.3") { // Check for cache file - if ($CACHE->cache_file("admins_acls", true) == true) - { + if ($CACHE->cache_file("admins_acls", true) == true) { // Load referral system from cache global $ADMINS_ACLS; $ADMINS_ACLS = $CACHE->cache_load(); // Valid cache file $CNT = 0; - foreach ($ADMINS_ACLS as $k=>$array) - { + foreach ($ADMINS_ACLS as $k=>$array) { $CNT += count($array); } // When there is a period (.) in the result this test will fail and so the cache file is // damaged/corrupted - if (count($ADMINS_ACLS) > 0) - { + if (count($ADMINS_ACLS) > 0) { $TEST = "failed"; if (count($ADMINS_ACLS) > 0 ) $TEST = ($CNT / (count($ADMINS_ACLS))); - if ($TEST != bigintval($TEST)) - { + if ($TEST != bigintval($TEST)) { // Cache file is corrupted! $CACHE->cache_destroy(); unset($ADMINS_ACLS); } } - } - elseif (($CONFIG['cache_acls'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) - { + } elseif (($CONFIG['cache_acls'] == 'Y') && ($CSS != "1") && ($CSS != "-1")) { // Create cache file here $CACHE->cache_init("ADMINS_ACLS"); // Load all modules and their data $result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__); - while ($DATA = SQL_FETCHARRAY($result)) - { + while ($DATA = SQL_FETCHARRAY($result)) { // Add row to cache file $CACHE->add_row($DATA); }