public function run(&$params)
 {
     // 开启静态缓存
     if (IS_GET && C('HTML_CACHE_ON')) {
         $cacheTime = $this->requireHtmlCache();
         if (false !== $cacheTime && $this->checkHTMLCache(HTML_FILE_NAME, $cacheTime)) {
             $mtime = self::fileMTime(HTML_FILE_NAME);
             if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 if ($_SERVER['HTTP_IF_NONE_MATCH'] >= $mtime) {
                     header('Etag:' . $_SERVER['HTTP_IF_NONE_MATCH'], true, 304);
                     exit;
                 }
                 self::httpCached($mtime, false);
             } else {
                 self::httpCached($mtime);
             }
             header('Etag:' . $mtime, true, 200);
             //静态页面有效
             // 读取静态页面输出
             echo Storage::read(HTML_FILE_NAME, 'html');
             exit;
         }
         $mtime = NOW_TIME + 5;
         header('Etag:' . $mtime, true, 200);
         self::httpCached($mtime, false);
     }
 }
 public function run(&$params)
 {
     // 开启静态缓存
     if (IS_GET && C('HTML_CACHE_ON')) {
         $cacheTime = $this->requireHtmlCache();
         if (false !== $cacheTime && $this->checkHTMLCache(HTML_FILE_NAME, $cacheTime)) {
             //静态页面有效
             // 读取静态页面输出
             echo Storage::read(HTML_FILE_NAME, 'html');
             exit;
         }
     }
 }
 public function run(&$content)
 {
     if (!APP_DEBUG && C('BUILD_LITE_RUNTIME')) {
         $litefile = RUNTIME_PATH . APP_MODE . '~lite.php';
         $runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
         if (!Storage::has($litefile)) {
             $defs = get_defined_constants(TRUE);
             $content = Storage::read($runtimefile);
             // $content   .=   'namespace { $GLOBALS[\'_beginTime\'] = microtime(TRUE);';
             $content .= compile(CORE_PATH . 'Think' . EXT);
             $content .= 'namespace {' . $this->array_define($defs['user']) . 'Think\\Think::start();}';
             Storage::put($litefile, $content);
         }
     }
 }
Exemple #4
0
/**
 * 文件内容读取
 * @param string $filename  文件名
 * @param string $type     其他参数
 * @return bool
 */
function file_read($filename, $type = '')
{
    switch (strtoupper(C('FILE_UPLOAD_TYPE'))) {
        case 'SAE':
            $arr = explode('/', ltrim($filename, './'));
            $domain = array_shift($arr);
            $filePath = implode('/', $arr);
            $s = new SaeStorage();
            return $s->read($domain, $filePath);
            break;
        case 'FTP':
            $storage = new \Common\Plugin\Ftp();
            return $storage->read($filename);
            break;
        default:
            return \Think\Storage::read($filename, $type);
    }
}
Exemple #5
0
 /**
  * 文件查看
  */
 public function fileView($filename)
 {
     $filename = urldecode($filename);
     $filename = $this->fileBathPath . $filename;
     if (\Think\Storage::has($filename)) {
         echo str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;&nbsp;&nbsp;'), htmlspecialchars(\Think\Storage::read($filename)));
     }
 }
Exemple #6
0
/**
 * 文件内容读取
 * @param string $filename  文件名
 * @return boolean         
 */
function file_read($filename, $type = '')
{
    switch (STORAGE_TYPE) {
        case 'Sae':
            $arr = explode('/', ltrim($filename, './'));
            $domain = array_shift($arr);
            $filePath = implode('/', $arr);
            $s = new SaeStorage();
            return $s->read($domain, $filePath);
            break;
        default:
            return \Think\Storage::read($filename, $type);
    }
}