You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.1 KiB
PHTML

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class MY_Output extends CI_Output
{
// --------------------------------------------------------------------
/**
* Write a Cache File
*
* @access public
* @param string
* @return void
*/
function _write_cache($output)
{
$cache_path = APPPATH.'cache/static_html';
if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
{
log_message('error', "Unable to write cache file: ".$cache_path);
return;
}
///////<2F>ijɰ<C4B3><C9B0><EFBFBD>URL<52><4C><EFBFBD><EFBFBD><E6BBBA>
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static_html_url<72><6C><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD>̬<EFBFBD>ļ<EFBFBD><C4BC>õIJ<C3B5><C4B2><EFBFBD>
if(empty($_GET['static_html_url']))
{
return FALSE;
}
$cache_path=$cache_path.$_GET['static_html_url'];
if(mb_substr($cache_path,-1,1)=='/')
{
$cache_path.='index.htm';
}
$this->create_folder_by_path(dirname($cache_path));
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
if (@file_exists($cache_path))
{
if ( ! $fp_read = @fopen($cache_path, FOPEN_READ))
{
return FALSE;
}
flock($fp_read, LOCK_SH);
$cache = '';
if (filesize($cache_path) > 0)
{
$cache = fread($fp_read, filesize($cache_path));
}
flock($fp_read, LOCK_UN);
fclose($fp_read);
if(strpos($cache,'<!-- Generated by ')===false)
{
log_message('error', "is not cache file.".$cache_path);
return FALSE;
}
}
///////
if ( ! $fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))
{
log_message('error', "Unable to write cache file: ".$cache_path);
return;
}
if (flock($fp, LOCK_EX))
{
fwrite($fp, $output.'<!-- Generated by '.$_SERVER['HTTP_HOST'].' ('.date('c').') -->');
flock($fp, LOCK_UN);
}
else
{
log_message('error', "Unable to secure a file lock for file at: ".$cache_path);
return;
}
fclose($fp);
@chmod($cache_path, FILE_WRITE_MODE);
log_message('debug', "Cache file written: ".$cache_path);
}
// --------------------------------------------------------------------
/*
* <20>ݹ鴴<DDB9><E9B4B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
*/
function create_folder_by_path($dir, $mode = 0777)
{
if (!is_dir($dir))
{
return @mkdir($dir, $mode, true);
}
return;
}
}