X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Flibs%2Fcache_functions.php;h=a3b1d0a15e77831db0bf6c1d430869a2d2f426d6;hb=357b2ca133fc1f89db74097955c366cb4bee6996;hp=81b65c436bf598a1d3f6d6c58fcaefb4fd49d84e;hpb=963e55ca1ea79e255f235e359cde9f7862191dc5;p=mailer.git
diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php
index 81b65c436b..a3b1d0a15e 100644
--- a/inc/libs/cache_functions.php
+++ b/inc/libs/cache_functions.php
@@ -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);
}
}
@@ -165,7 +162,7 @@ class mxchange_cache
}
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -187,7 +184,7 @@ class mxchange_cache
else
{
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -222,31 +219,26 @@ 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);
}
}
- function cache_destroy()
- {
- if (FILE_READABLE($this->cache_inc))
- {
+ // Destroy an existing cache file
+ function cache_destroy() {
+ // Is the cache file there?
+ if (FILE_READABLE($this->cache_inc)) {
// Remove cache file from system
@unlink($this->cache_inc);
- if (!FILE_READABLE($this->cache_inc))
- {
+ if (!FILE_READABLE($this->cache_inc)) {
// Close cache automatically (we don't need it anymore!)
$this->cache_close();
- }
- else
- {
+ } 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
- {
+ } 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);
}
}
@@ -291,7 +283,7 @@ class mxchange_cache
}
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -344,7 +336,7 @@ class mxchange_cache
}
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
}
}
@@ -358,7 +350,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);
}
}
@@ -379,7 +371,7 @@ class mxchange_cache
$line = "";
// String or non-string? ;-)
- if (is_string($value)) {
+ if ((is_string($value)) || (is_null($value))) {
// String...
$line = "\$data['".$key."'][] = \"".$value."\";\n";
} else {
@@ -390,6 +382,10 @@ class mxchange_cache
// Return line
return $line;
}
+
+ function getStatus () {
+ return $this->ret;
+ }
}
//
?>