// 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)) {
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) {
$this->cache_pointer = $fp;
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
}
} else {
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
else
{
// Cannot create file
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
}
} 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__."(<font color=\"#0000aa\">".__LINE__."</font>): ".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__."(<font color=\"#0000aa\">".__LINE__."</font>): ".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__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);
}
}
}
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
}
} else {
// Cannot write to cache!
- ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_PROBLEMS_DETECTED);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
@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__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
$line = "";
// String or non-string? ;-)
- if (is_string($value)) {
+ if ((is_string($value)) || (is_null($value))) {
// String...
$line = "\$data['".$key."'][] = \"".$value."\";\n";
} else {
// Return line
return $line;
}
+
+ function getStatus () {
+ return $this->ret;
+ }
}
//
?>