X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Fcache_functions.php;h=93af044caa08e1ef379860b8db4ffb43b25ae346;hb=dfaa8c1675da4071ea451406a6f6fedd4c568416;hp=e8f750bee8f55e94767d3af40d451b666b024488;hpb=7ef451f330894cc47e810faefd0ed35a48086199;p=mailer.git diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php index e8f750bee8..93af044caa 100644 --- a/inc/libs/cache_functions.php +++ b/inc/libs/cache_functions.php @@ -32,11 +32,11 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) -{ +if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); } + // Caching class class mxchange_cache { @@ -52,11 +52,14 @@ class mxchange_cache // Constructor function mxchange_cache($interval, $path, $tested) { + // Failed is the default + $this->ret = "failed"; + // Remember interval in class - $this->update_interval=$interval; + $this->update_interval = $interval; // Remeber path - $this->cache_path=$path; + $this->cache_path = $path; // Check if path exists if ((is_dir($path)) && (!$tested)) { @@ -72,22 +75,16 @@ class mxchange_cache UPDATE_CONFIG("cache_tested", 1); // All done! - return "done"; + $this->ret = "done"; } else { // Stop! Set a .htaccess file first - $this->ret="htaccess"; - return "htaccess"; + $this->ret = "htaccess"; } } } elseif ($tested) { // System already tested - $this->ret="done"; - return "done"; + $this->ret = "done"; } - - // Something goes wrong here! - $this->ret="failed"; - return "failed"; } function cache_file($file, $ignore_ctime=false) { @@ -135,7 +132,7 @@ class mxchange_cache $this->cache_pointer = $fp; } else { // Cannot create file - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); } } @@ -155,14 +152,17 @@ class mxchange_cache if (($k == "ext_keep") && ($v == "Y")) { $cacheArray['active_extensions'][$data['ext_name']] = $v; } // END - if - } // END - if + } elseif (is_array($v)) { + // Serialize and BASE64-encode the array + $v = base64_encode(serialize($v)); + } // Write cache line to file @fwrite($this->cache_pointer, $this->add_raw_row($k, $v)); } } else { // Cannot create file - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); } } @@ -184,7 +184,7 @@ class mxchange_cache else { // Cannot create file - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); } } @@ -219,7 +219,7 @@ class mxchange_cache } } else { // Cache file not found or not readable - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_LOAD_1.$this->cache_inc.CACHE_CANNOT_LOAD_2); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_LOAD_1.$this->cache_inc.CACHE_CANNOT_LOAD_2); } } @@ -237,13 +237,13 @@ class mxchange_cache else { // Not removed! - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2); } } else { // Does not exist! - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2); } } @@ -288,7 +288,7 @@ class mxchange_cache } } else { // Cannot write to cache! - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); } } @@ -341,7 +341,7 @@ class mxchange_cache } } else { // Cannot write to cache! - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); } } @@ -355,7 +355,7 @@ class mxchange_cache @fwrite($this->cache_pointer, "\$cache_version['".$ext_name."'] = \"".$ext_ver."\";\n"); } else { // Cannot create file - ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); + ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED); } } @@ -387,6 +387,10 @@ class mxchange_cache // Return line return $line; } + + function getStatus () { + return $this->ret; + } } // ?>