mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
Adjust cache paths to prevent loading old cache
This commit is contained in:
parent
0c1ee32073
commit
1ab9a2899b
2 changed files with 40 additions and 61 deletions
|
|
@ -3,26 +3,6 @@
|
||||||
|
|
||||||
class pageMobile extends pageView
|
class pageMobile extends pageView
|
||||||
{
|
{
|
||||||
function init()
|
|
||||||
{
|
|
||||||
switch($this->module_info->page_type)
|
|
||||||
{
|
|
||||||
case 'WIDGET' :
|
|
||||||
{
|
|
||||||
$this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.m.cache.php", RX_BASEDIR, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus());
|
|
||||||
$this->interval = (int)($this->module_info->page_caching_interval);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'OUTSIDE' :
|
|
||||||
{
|
|
||||||
$this->cache_file = sprintf("./files/cache/opage/%d.%s.m.cache.php", $this->module_info->module_srl, Context::getSslStatus());
|
|
||||||
$this->interval = (int)($this->module_info->page_caching_interval);
|
|
||||||
$this->path = $this->module_info->mpath ?: $this->module_info->path;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function dispPageIndex()
|
function dispPageIndex()
|
||||||
{
|
{
|
||||||
// Variables used in the template Context:: set()
|
// Variables used in the template Context:: set()
|
||||||
|
|
@ -51,36 +31,34 @@ class pageMobile extends pageView
|
||||||
// Arrange a widget ryeolro
|
// Arrange a widget ryeolro
|
||||||
if($this->module_info->mcontent)
|
if($this->module_info->mcontent)
|
||||||
{
|
{
|
||||||
$cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", RX_BASEDIR, $this->module_info->module_srl, Context::getLangType());
|
if($this->interval>0)
|
||||||
$interval = (int)($this->module_info->page_caching_interval);
|
|
||||||
if($interval>0)
|
|
||||||
{
|
{
|
||||||
if(!file_exists($cache_file) || filesize($cache_file) < 1)
|
if(!file_exists($this->cache_file) || filesize($this->cache_file) < 1)
|
||||||
{
|
{
|
||||||
$mtime = 0;
|
$mtime = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mtime = filemtime($cache_file);
|
$mtime = filemtime($this->cache_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($mtime + $interval*60 > $_SERVER['REQUEST_TIME'])
|
if($mtime + $this->interval*60 > $_SERVER['REQUEST_TIME'])
|
||||||
{
|
{
|
||||||
$page_content = FileHandler::readFile($cache_file);
|
$page_content = FileHandler::readFile($this->cache_file);
|
||||||
$page_content = str_replace('<!--#Meta:', '<!--Meta:', $page_content);
|
$page_content = str_replace('<!--#Meta:', '<!--Meta:', $page_content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$oWidgetController = getController('widget');
|
$oWidgetController = getController('widget');
|
||||||
$page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
|
$page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
|
||||||
FileHandler::writeFile($cache_file, $page_content);
|
FileHandler::writeFile($this->cache_file, $page_content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(file_exists($cache_file))
|
if(file_exists($this->cache_file))
|
||||||
{
|
{
|
||||||
FileHandler::removeFile($cache_file);
|
FileHandler::removeFile($this->cache_file);
|
||||||
}
|
}
|
||||||
$page_content = $this->module_info->mcontent;
|
$page_content = $this->module_info->mcontent;
|
||||||
}
|
}
|
||||||
|
|
@ -135,18 +113,6 @@ class pageMobile extends pageView
|
||||||
|
|
||||||
return $page_content;
|
return $page_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getOutsideContent()
|
|
||||||
{
|
|
||||||
// check if it is http or internal file
|
|
||||||
if($this->path)
|
|
||||||
{
|
|
||||||
if(preg_match("/^([a-z]+):\/\//i",$this->path)) $content = $this->getHtmlPage($this->path, $this->interval, $this->cache_file);
|
|
||||||
else $content = $this->executeFile($this->path, $this->interval, $this->cache_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* End of file page.mobile.php */
|
/* End of file page.mobile.php */
|
||||||
/* Location: ./modules/page/page.mobile.php */
|
/* Location: ./modules/page/page.mobile.php */
|
||||||
|
|
|
||||||
|
|
@ -7,29 +7,43 @@
|
||||||
*/
|
*/
|
||||||
class pageView extends page
|
class pageView extends page
|
||||||
{
|
{
|
||||||
var $module_srl = 0;
|
const COMPILE_TEMPLATE = false;
|
||||||
var $list_count = 20;
|
|
||||||
var $page_count = 10;
|
public $module_srl = 0;
|
||||||
var $cache_file;
|
public $list_count = 20;
|
||||||
var $interval;
|
public $page_count = 10;
|
||||||
var $path;
|
public $cache_file = null;
|
||||||
|
public $interval = 0;
|
||||||
|
public $path = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialization
|
* @brief Initialization
|
||||||
*/
|
*/
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
switch($this->module_info->page_type)
|
if ($this->module_info->page_type === 'WIDGET')
|
||||||
{
|
{
|
||||||
case 'WIDGET':
|
|
||||||
$this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.cache.php", \RX_BASEDIR, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus());
|
|
||||||
$this->interval = (int)($this->module_info->page_caching_interval ?? 0);
|
$this->interval = (int)($this->module_info->page_caching_interval ?? 0);
|
||||||
break;
|
$this->cache_file = vsprintf('%sfiles/cache/page/%d.%s.%s.%s.cache.php', [
|
||||||
case 'OUTSIDE':
|
\RX_BASEDIR,
|
||||||
$this->cache_file = sprintf("%sfiles/cache/opage/%d.%s.cache.php", \RX_BASEDIR, $this->module_info->module_srl, Context::getSslStatus());
|
$this->module_info->module_srl,
|
||||||
|
Context::getLangType(),
|
||||||
|
Context::getSslStatus(),
|
||||||
|
$this instanceof pageMobile ? 'm' : 'pc',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->module_info->page_type === 'OUTSIDE')
|
||||||
|
{
|
||||||
$this->interval = (int)($this->module_info->page_caching_interval ?? 0);
|
$this->interval = (int)($this->module_info->page_caching_interval ?? 0);
|
||||||
$this->path = $this->module_info->path ?? '';
|
$this->path = $this->module_info->path ?? '';
|
||||||
break;
|
$this->cache_file = vsprintf('%sfiles/cache/opage/%d.%s.%s.%s.cache.php', [
|
||||||
|
\RX_BASEDIR,
|
||||||
|
$this->module_info->module_srl,
|
||||||
|
Context::getSslStatus(),
|
||||||
|
self::COMPILE_TEMPLATE ? 'ct' : 'nt',
|
||||||
|
$this instanceof pageMobile ? 'm' : 'pc',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +202,6 @@ class pageView extends page
|
||||||
$filename = $tmp_path[count($tmp_path)-1];
|
$filename = $tmp_path[count($tmp_path)-1];
|
||||||
$filepath = preg_replace('/'.$filename."$/i","",$cache_file);
|
$filepath = preg_replace('/'.$filename."$/i","",$cache_file);
|
||||||
$cache_file = FileHandler::getRealPath($cache_file);
|
$cache_file = FileHandler::getRealPath($cache_file);
|
||||||
$compile_template = false;
|
|
||||||
|
|
||||||
// Verify cache
|
// Verify cache
|
||||||
if ($caching_interval < 1 || !file_exists($cache_file) || filemtime($cache_file) + ($caching_interval * 60) <= \RX_TIME || filemtime($cache_file) < filemtime($real_target_file))
|
if ($caching_interval < 1 || !file_exists($cache_file) || filemtime($cache_file) + ($caching_interval * 60) <= \RX_TIME || filemtime($cache_file) < filemtime($real_target_file))
|
||||||
|
|
@ -210,7 +223,7 @@ class pageView extends page
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to compile
|
// Attempt to compile
|
||||||
if ($compile_template)
|
if (self::COMPILE_TEMPLATE)
|
||||||
{
|
{
|
||||||
$oTemplate = TemplateHandler::getInstance();
|
$oTemplate = TemplateHandler::getInstance();
|
||||||
$script = $oTemplate->compileDirect($filepath, $filename);
|
$script = $oTemplate->compileDirect($filepath, $filename);
|
||||||
|
|
@ -223,7 +236,7 @@ class pageView extends page
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return content if not compiling as template.
|
// Return content if not compiling as template.
|
||||||
if (!$compile_template)
|
if (!self::COMPILE_TEMPLATE)
|
||||||
{
|
{
|
||||||
return file_get_contents($cache_file);
|
return file_get_contents($cache_file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue