Пример #1
0
 public function __construct($driver = 'file', $config = array())
 {
     \mPHP::inc(MPHP_PATH . 'inc/functions.php');
     //加载常用函数集
     $driver = "cache\\{$driver}";
     $this->cache = M($driver, $config);
 }
Пример #2
0
 public function __construct()
 {
     $this->path = CACHE_PATH . 'file';
     \mPHP::inc(MPHP_PATH . 'inc/functions.php');
     //加载常用函数集
     $this->in('main');
 }
Пример #3
0
 public function __construct($arrConfig)
 {
     mPHP::inc(MPHP_PATH . 'inc/functions.php');
     //加载常用函数集
     $type = $arrConfig['type'];
     $name = $arrConfig['dbname'];
     $host = $arrConfig['host'];
     $port = $arrConfig['port'];
     $this->link = "{$type}:host={$host};dbname={$name}";
     $this->user = $arrConfig['user'];
     $this->pass = $arrConfig['password'];
     $this->charset = $arrConfig['charset'];
     $this->connect();
 }
Пример #4
0
 public static function dirCache()
 {
     mPHP::inc(MPHP_PATH . 'inc/functions.php');
     //加载常用函数集
     if ($arrDir = C('cache', 'html_cache_dir')) {
         if (is_dir(CACHE_PATH . 'html')) {
             foreach ($arrDir as $key => $value) {
                 $dir = CACHE_PATH . 'html/' . $key . '/';
                 if (is_dir($dir)) {
                     $i = 0;
                     while ($i < $value) {
                         if (!is_dir($dir . $i)) {
                             mkdir($dir . $i);
                         }
                         ++$i;
                     }
                 } else {
                     mkdir($dir);
                     $i = 0;
                     while ($i < $value) {
                         if (!is_dir($dir . $i)) {
                             mkdir($dir . $i);
                         }
                         ++$i;
                     }
                 }
             }
         } else {
             mkdir(CACHE_PATH . 'html');
             dirCache();
         }
     }
 }
Пример #5
0
 public function loadTpl($tpl, $file = '', $time = 0)
 {
     mPHP::inc(MPHP_PATH . 'inc/functions.php');
     //加载常用函数集
     ob_start();
     $arrData = $this->_include($tpl, $file);
     ob_end_clean();
     if (!mPHP::$debug) {
         if ($this->is_merger) {
             $arrData['html'] = $this->merger($arrData['html']);
         }
         if ($this->is_mini_html) {
             $arrData['html'] = mini_html($arrData['html']);
         }
     }
     //路由缓存逻辑
     if ($time && !empty(mPHP::$CFG['router'])) {
         $ctime = $_SERVER['REQUEST_TIME'];
         $date = date('Y-m-d H:i:s');
         $arrData['html'] .= "<!-- mPHP html cache {$date} -->";
         $strDir = dirname($arrData['file']);
         if (!is_dir($strDir)) {
             mkdir($strDir, 0775, true);
         }
         file_put_contents($arrData['file'], $arrData['html']);
         mPHP::header('Cache-Control', 'max-age=0');
         mPHP::header('Last-Modified', date("D, d M Y H:i:s", $ctime));
         $data = array('ctime' => $ctime, 'etime' => $ctime + $time, 'file' => $arrData['file']);
         router::set($data);
     }
     echo $arrData['html'];
 }