Item cache related functionality removed
This commit is contained in:
parent
844727dc19
commit
a06d699480
9 changed files with 0 additions and 136 deletions
87
boot.php
87
boot.php
|
@ -444,93 +444,6 @@ function get_temppath()
|
|||
return '';
|
||||
}
|
||||
|
||||
function get_cachefile($file, $writemode = true)
|
||||
{
|
||||
$cache = get_itemcachepath();
|
||||
|
||||
if ((!$cache) || (!is_dir($cache))) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$subfolder = $cache . "/" . substr($file, 0, 2);
|
||||
|
||||
$cachepath = $subfolder . "/" . $file;
|
||||
|
||||
if ($writemode) {
|
||||
if (!is_dir($subfolder)) {
|
||||
mkdir($subfolder);
|
||||
chmod($subfolder, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
return $cachepath;
|
||||
}
|
||||
|
||||
function clear_cache($basepath = "", $path = "")
|
||||
{
|
||||
if ($path == "") {
|
||||
$basepath = get_itemcachepath();
|
||||
$path = $basepath;
|
||||
}
|
||||
|
||||
if (($path == "") || (!is_dir($path))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (substr(realpath($path), 0, strlen($basepath)) != $basepath) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cachetime = (int) DI::config()->get('system', 'itemcache_duration');
|
||||
if ($cachetime == 0) {
|
||||
$cachetime = 86400;
|
||||
}
|
||||
|
||||
if (is_writable($path)) {
|
||||
if ($dh = opendir($path)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
$fullpath = $path . "/" . $file;
|
||||
if ((filetype($fullpath) == "dir") && ($file != ".") && ($file != "..")) {
|
||||
clear_cache($basepath, $fullpath);
|
||||
}
|
||||
if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) {
|
||||
unlink($fullpath);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_itemcachepath()
|
||||
{
|
||||
// Checking, if the cache is deactivated
|
||||
$cachetime = (int) DI::config()->get('system', 'itemcache_duration');
|
||||
if ($cachetime < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$itemcache = DI::config()->get('system', 'itemcache');
|
||||
if (($itemcache != "") && System::isDirectoryUsable($itemcache)) {
|
||||
return BasePath::getRealPath($itemcache);
|
||||
}
|
||||
|
||||
$temppath = get_temppath();
|
||||
|
||||
if ($temppath != "") {
|
||||
$itemcache = $temppath . "/itemcache";
|
||||
if (!file_exists($itemcache) && !is_dir($itemcache)) {
|
||||
mkdir($itemcache);
|
||||
}
|
||||
|
||||
if (System::isDirectoryUsable($itemcache)) {
|
||||
DI::config()->set("system", "itemcache", $itemcache);
|
||||
return $itemcache;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path where spool files are stored
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue