Example #1
0
 /**
  * 将html字符串输出返回给游览器
  * 内部调用fetch和render方法,而非直接使用模板引擎的方法
  *
  */
 public function display($templateFile = '', $charset = '', $contentType = '', $content = '', $prefix = '')
 {
     // 标记统计
     Debug::mark('viewStartTime');
     // 视图开始标签
     Tag::listen('view_begin', $templateFile);
     // 解析并获取模板内容
     $content = $this->fetch($templateFile, $content, $prefix);
     // 输出模板内容
     $this->render($content, $charset, $contentType);
     // 视图结束标签
     Tag::listen('view_end');
 }
Example #2
0
 /**
  * 执行语句
  * @access public
  * @param string $str  sql指令
  * @return integer|false
  */
 public function execute($str)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     //释放前次的查询结果
     if ($this->queryID) {
         $this->free();
     }
     Debug::record('db_write', 1);
     // 记录开始执行时间
     Debug::mark('queryStartTime');
     $result = mysql_query($str, $this->_linkID);
     $this->debug();
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = mysql_affected_rows($this->_linkID);
         $this->lastInsID = mysql_insert_id($this->_linkID);
         return $this->numRows;
     }
 }
Example #3
0
 /**
  * 数据库调试 记录当前SQL
  * @access protected
  */
 protected function debug()
 {
     $this->modelSql[$this->model] = $this->queryStr;
     $this->model = '_think_';
     // 记录操作结束时间
     if (C('DB_SQL_LOG')) {
         Debug::mark('queryEndTime');
         Debug::trace($this->queryStr . ' [ RunTime:' . Debug::mark('queryStartTime', 'queryEndTime', 6) . 's ]', '', 'SQL');
     }
 }
Example #4
0
 /**
  * 注册异常、autoload
  * 解析路由、加载配置
  * 启动session
  * 运行控制器
  *
  * @return void
  */
 public static function run()
 {
     // -------------------------------------------
     // 解析分配器,找到分组设置
     // -------------------------------------------
     Dispatch::init();
     // -------------------------------------------
     // 加载配置
     // -------------------------------------------
     static::load_config();
     // -------------------------------------------
     // 加载行为
     // -------------------------------------------
     static::load_tag();
     // -------------------------------------------
     // 语言包标签
     // -------------------------------------------
     Tag::listen('app_lang');
     // -------------------------------------------
     // 加载语言包
     // -------------------------------------------
     static::load_lang();
     // -------------------------------------------
     // 分配分组内路由细节
     // -------------------------------------------
     static::load_route();
     // -------------------------------------------
     // 项目初始化标签
     // -------------------------------------------
     Tag::listen('app_init');
     // -------------------------------------------
     // 初始化
     // -------------------------------------------
     static::init();
     // -------------------------------------------
     // 项目开始标签
     // -------------------------------------------
     Tag::listen('app_begin');
     // -------------------------------------------
     // Session初始化
     // -------------------------------------------
     Session::config(Config::get('SESSION_OPTIONS'));
     // -------------------------------------------
     // 记录应用初始化时间
     // -------------------------------------------
     Debug::mark('initTime');
     // -------------------------------------------
     // 项目执行前检查访问者权限
     // -------------------------------------------
     Tag::listen('app_auth');
     // -------------------------------------------
     // 执行程序
     // -------------------------------------------
     static::exec();
     // -------------------------------------------
     // 项目结束标签
     // -------------------------------------------
     Tag::listen('app_end');
     // -------------------------------------------
     // 保存日志记录
     // -------------------------------------------
     if (Config::get('LOG_RECORD')) {
         // Log::save();
         // Log::info('------------------- |' . CONTROLLER_NAME . ' & ' . ACTION_NAME);
     }
 }
Example #5
0
 /**
  * 加载运行时所需要的文件
  * 检查调试模式创建目录
  *
  * @return void
  */
 public static function load_runtime_file()
 {
     try {
         // 载入临时的Helper文件,将重构
         include CORE_PATH . 'Library/Helper' . EXT;
         // 调试模式下检查路径和文件
         if (APP_DEBUG) {
             // 创建项目目录结构
             if (!is_dir(LIB_PATH)) {
                 throw new Exception("不存在项目目录结构");
             }
             // 检查缓存目录
             if (!is_dir(CACHE_PATH)) {
                 // 如果不存在Runtime则创建
                 if (!is_dir(RUNTIME_PATH)) {
                     mkdir(RUNTIME_PATH);
                 } else {
                     if (!is_writeable(RUNTIME_PATH)) {
                         throw new Exception(RUNTIME_PATH . "is no writeable");
                     }
                 }
                 // 检查并创建Runtime下的缓存目录
                 foreach (array(CACHE_PATH, LOG_PATH, TEMP_PATH, DATA_PATH) as $key => $value) {
                     if (!is_dir($value)) {
                         mkdir($value);
                     }
                 }
             }
         }
         // 记录文件加载时间
         Debug::mark('loadTime');
         // 启动
         App::run();
     } catch (Exception $error) {
         exit($error->getMessage());
     }
 }