File size: 904B
<?php
class gcache
{
var $cacheFile;
function __construct ()
{
/* Читаем переданные параметры */
if (!empty ($_GET['room']))
{
$roomID = (int) $_GET['room'];
$this->cacheFile = 'r'.$roomID;
if (empty ($_GET['page']))
{
$this->cacheFile .= 'p1';
}
else
{
$pageID = (int) $_GET['page'];
$this->cacheFile .= 'p'.$pageID;
}
}
$this->cacheFile = 'cache/'.$this->cacheFile.'.txt';
}
function readCache ()
{
if (file_exists ($this->cacheFile))
{
return file_get_contents ($this->cacheFile);
}
else
return false;
}
function writeCache ($content = null)
{
if (!$content)
return false;
$cache = fopen ($this->cacheFile, 'w');
fwrite ($cache, $content);
fclose ($cache);
}
function cacheExists ()
{
if (file_exists ($this->cacheFile))
{
return true;
}
else
return false;
}
}