The cache dir must be with 0777, not 0666 !
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1566 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -6,6 +6,48 @@ class cachefile
|
||||
/** If TRUE : no information is cached */
|
||||
public $nocache = false;
|
||||
|
||||
/** Check if there is some garbage to clean */
|
||||
public function garbage ()
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->cachedir ();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
$res = $this->read ("CACHE-Garbage");
|
||||
if ($res === false)
|
||||
{
|
||||
$this->write ("CACHE-Garbage", "Let's go, garbage !", 24*60*60);
|
||||
$files = glob ($this->directory."/*", GLOB_NOSORT);
|
||||
foreach ($files as $fileCache)
|
||||
{
|
||||
$datas = file_get_contents ($fileCache);
|
||||
if ($datas === false)
|
||||
{
|
||||
unlink ($fileCache);
|
||||
continue;
|
||||
}
|
||||
|
||||
$datas = unserialize ($datas);
|
||||
if (! isset ($datas["ttl"]) || ! isset ($datas["data"]) ||
|
||||
! isset ($datas["createTime"]))
|
||||
{
|
||||
unlink ($fileCache);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($datas["createTime"] + $datas["ttl"]) >= time ())
|
||||
{
|
||||
unlink ($fileCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** This function check if the cachedir exists and create it if it is not the
|
||||
case.
|
||||
Check if the cache dir is writable and readable */
|
||||
@@ -24,7 +66,7 @@ class cachefile
|
||||
if (!mkdir ($this->directory))
|
||||
throw new Exception (sprintf (_("Can not create cache directory %s"),
|
||||
$this->directory), 500);
|
||||
chmod ($this->directory, 0666);
|
||||
chmod ($this->directory, 0777);
|
||||
}
|
||||
if (! is_writable ($this->directory))
|
||||
throw new Exception (sprintf (_("Cache directory %s is not writable"),
|
||||
|
||||
Reference in New Issue
Block a user