Beispiel #1
0
 /**
  * 模板显示
  * @param string    $tpl_file       模板文件
  * @param number    $cacheTime      缓存时间
  * @param string    $contentType    文件类型
  * @param string    $charset        字符集
  * @param boolean   $show           是否显示
  */
 public function display($tplFile = "", $cacheTime = null, $contentType = "text/html", $charset = "", $show = true)
 {
     $this->endFix = '.' . trim(C("TPL_FIX"), '.');
     $this->tplFile = $this->getTemplateFile($tplFile);
     $this->set_cache_file();
     //设置缓存文件
     $this->set_cache_time($cacheTime);
     //设置缓存时间
     $this->compileFile = CACHE_COMPILE_PATH . '/' . md5_d($this->tplFile) . '.php';
     if (C("debug")) {
         tplCompile(array(basename($this->tplFile), $this->compileFile));
         //记录模板编译文件
     }
     $content = false;
     //静态缓存数据内容
     if ($this->cacheTime > 0) {
         //缓存控制ssp
         dir::create(CACHE_TPL_PATH);
         //缓存目录
         if ($this->cacheStat || $this->is_cache($this->cacheTime)) {
             $content = file_get_contents($this->cacheFile);
         }
     }
     if ($content === false) {
         //不使用缓存
         if ($this->checkCompile($tplFile)) {
             //编译文件失效
             $this->compile();
         }
         $_CONFIG = C();
         $_LANGUAGE = L();
         if (!empty(self::$vars)) {
             //加载全局变量
             extract(self::$vars);
         }
         ob_start();
         include $this->compileFile;
         $content = ob_get_clean();
         if ($this->cacheTime > 0) {
             file_put_contents($this->cacheFile, $content);
         }
     }
     if ($show) {
         $charset = strtoupper(C("CHARSET")) == 'UTF8' ? "UTF-8" : strtoupper(C("CHARSET"));
         header("Content-type:" . $contentType . ';charset=' . $charset);
         echo $content;
     } else {
         return $content;
     }
 }
Beispiel #2
0
 /**
  * 显示调试信息
  */
 public static function show($start, $end)
 {
     if (!C("DEBUG")) {
         return;
     }
     $load_file_list = load_file();
     $serverInfo = empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SIGNATURE'] : $_SERVER['SERVER_SOFTWARE'];
     $system = "<div class='debug_server'>";
     $system .= "<strong>" . L("debug_show1") . "</strong>: " . $serverInfo . "<br/>";
     $system .= "<strong>" . L("debug_show2") . "</strong>: " . $_SERVER['HTTP_USER_AGENT'] . "<br/>";
     $system .= "<strong>" . L("debug_show3") . "</strong>: " . phpversion() . "<br/>";
     $system .= "<strong>" . L("debug_show4") . "</strong>: " . $_SERVER['HTTP_HOST'] . "<br/>";
     $system .= "<strong>" . L("debug_show5") . "</strong>: " . $_SERVER['REQUEST_METHOD'] . "<br/>";
     $system .= "<strong>" . L("debug_show6") . "</strong>: " . $_SERVER['SERVER_PROTOCOL'] . "<br/>";
     if (defined("PATH_CONTROL")) {
         $system .= "<strong>" . L("debug_show7") . "</strong>: " . PATH_CONTROL . '/' . CONTROL . C("CONTROL_FIX") . ".php<br/>";
     }
     $system .= "<strong>" . L("debug_show8") . "</strong>: " . session_id() . "<br/>";
     $system .= "</div>";
     $e['system'] = $system;
     $compileFiles = tplCompile();
     if (!empty($compileFiles)) {
         $tplCompileFiles = '<table width=100%>
         <thead><tr>
         <td style="font-size:13px;width:80px;padding:5px;">' . L("debug_show16") . '</td>
         <td style="font-size:13px;padding:5px;">' . L("debug_show18") . '</td>
         </tr></thead>';
         foreach ($compileFiles as $k => $v) {
             $tplCompileFiles .= '<tr><td style="font-size:12px;width:80px;padding:6px;">' . $v[0] . ' </td>
                 <td style="font-size:12px;padding:6px;">' . str_replace(array("/", "\\"), DIRECTORY_SEPARATOR, $v[1]) . "</td></tr>";
         }
         $tplCompileFiles .= "</table>";
     }
     /**
      * 数据库操作DEBG
      */
     if (self::$sqlCount > 0) {
         $e['sqlCount'] = self::$sqlCount;
         //SQL统计
         $e['sqlExeArr'] = self::$SqlExeArr;
         //SQL数组
         $sqlExeArr = '<table width=100%>
         <thead><tr>
         <td>' . L("debug_show10") . '</td>
         <td>' . L("debug_show11") . '</td>
         </tr></thead>';
         foreach ($e['sqlExeArr'] as $k => $v) {
             $sqlExeArr .= "<tr><td width='35'>[" . $k . "] </td><td>" . htmlspecialchars($v) . "</td></tr>";
         }
         $sqlExeArr .= "</table>";
         $sqlExeArr .= "<p>" . L("debug_show12") . $e['sqlCount'] . L("debug_show13") . "</p>";
     }
     /**
      * 文件载入DEBUG 
      */
     $loadfile = '<table width=100%>
         <thead><tr>
         <td width="30">ID</td>
         <td>File</td>
         <td width="45">Time</td>
         <td width="60">Memory</td>
         </tr></thead>';
     $message = L("debug_show14") . ": " . self::runtime($start, $end) . "&nbsp;&nbsp;" . L("debug_show15") . number_format(self::memory_perk($start, $end) / pow(1024, 1), 0) . 'kb';
     $i = 1;
     foreach ($load_file_list as $k => $v) {
         $loadfile .= "<tr><td>[" . $i++ . "] </td><td>" . $v['path'] . "</td><td>" . $v['time'] . "</td><td>" . $v['memory'] . "</td></tr>";
     }
     $loadfile .= "</table>";
     $e['loadfile'] = $loadfile . "<p>{$message}</p>";
     include C("DEBUG_TPL");
 }