From 2e26cf6f03a1c83e149609e7d3a49eb5c1282687 Mon Sep 17 00:00:00 2001 From: ycc Date: Tue, 10 Jan 2017 11:38:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9D=99=E6=80=81=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/information.php | 1 + application/core/MY_Output.php | 107 ++++++++++++++++++++++++ index.php | 2 +- 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 application/core/MY_Output.php diff --git a/application/controllers/information.php b/application/controllers/information.php index 098ff98d..7f69208d 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -59,6 +59,7 @@ class Information extends CI_Controller { $this->load->view('header', $data); $this->load->view('information_' . $data['detail']->ic_template); $this->load->view('footer'); + $this->output->cache(10080); } } diff --git a/application/core/MY_Output.php b/application/core/MY_Output.php new file mode 100644 index 00000000..43cc4482 --- /dev/null +++ b/application/core/MY_Output.php @@ -0,0 +1,107 @@ +create_folder_by_path(dirname($cache_path)); + + //如果文件存在,先判断是否为缓存文件,防止覆盖原始程序文件 + 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,''); + 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); + } + + // -------------------------------------------------------------------- + +/* +* 递归创建文件夹 +*/ +function create_folder_by_path($dir, $mode = 0777) +{ + if (!is_dir($dir)) + { + return @mkdir($dir, $mode, true); + } + return; +} + +} \ No newline at end of file diff --git a/index.php b/index.php index b2693528..21b7a4d6 100644 --- a/index.php +++ b/index.php @@ -68,7 +68,7 @@ if (defined('ENVIRONMENT')) * as this file. * */ - $system_path = 'D:/CI-system';//../system + $system_path = '../system';//../system /* *---------------------------------------------------------------