📄 正在查看:twcms/kongphp/kongphp.php
1<?php
2/**
3 * Copyright (C) 2013-2014 www.kongphp.com All rights reserved.
4 * Licensed http://www.gnu.org/licenses/lgpl.html
5 * Author: wuzhaohuan <kongphp@gmail.com>
6 */
7
8//KongPHP 入口文件
9defined('KONG_PATH') || die('Error Accessing');
10
11version_compare(PHP_VERSION, '5.2.0', '>') || die('require PHP > 5.2.0 !');
12
13// 记录开始运行时间
14$_ENV['_start_time'] = microtime(1);
15
16// 记录内存初始使用
17define('MEMORY_LIMIT_ON', function_exists('memory_get_usage'));
18if(MEMORY_LIMIT_ON) $_ENV['_start_memory'] = memory_get_usage();
19
20define('KONG_VERSION', '1.0.0'); //框架版本
21defined('DEBUG') || define('DEBUG', 2); //调试模式
22defined('CONFIG_PATH') || define('CONFIG_PATH', APP_PATH.'config/'); //配置目录
23defined('CONTROL_PATH') || define('CONTROL_PATH', APP_PATH.'control/'); //控制器目录
24defined('BLOCK_PATH') || define('BLOCK_PATH', APP_PATH.'block/'); //模块目录
25defined('MODEL_PATH') || define('MODEL_PATH', APP_PATH.'model/'); //模型目录
26defined('VIEW_PATH') || define('VIEW_PATH', APP_PATH.'view/'); //视图目录
27defined('LOG_PATH') || define('LOG_PATH', APP_PATH.'log/'); //日志目录
28defined('PLUGIN_PATH') || define('PLUGIN_PATH', APP_PATH.'plugin/'); //插件目录
29defined('RUNTIME_PATH') || define('RUNTIME_PATH', APP_PATH.'runtime/'); //运行缓存目录
30defined('RUNTIME_MODEL') || define('RUNTIME_MODEL', RUNTIME_PATH.APP_NAME.'_model/'); //模型缓存目录
31defined('RUNTIME_CONTROL') || define('RUNTIME_CONTROL', RUNTIME_PATH.APP_NAME.'_control/'); //控制器缓存目录
32
33include CONFIG_PATH.'config.inc.php';
34
35if(DEBUG) {
36 include KONG_PATH.'base/base.func.php';
37 include KONG_PATH.'base/core.class.php';
38 include KONG_PATH.'base/debug.class.php';
39 include KONG_PATH.'base/log.class.php';
40 include KONG_PATH.'base/model.class.php';
41 include KONG_PATH.'base/view.class.php';
42 include KONG_PATH.'base/control.class.php';
43 include KONG_PATH.'db/db.interface.php';
44 include KONG_PATH.'db/db_mysql.class.php';
45 include KONG_PATH.'cache/cache.interface.php';
46 include KONG_PATH.'cache/cache_memcache.class.php';
47}else{
48 $runfile = RUNTIME_PATH.'_runtime.php';
49 if(!is_file($runfile)) {
50 $s = trim(php_strip_whitespace(KONG_PATH.'base/base.func.php'), "<?ph>\r\n");
51 $s .= trim(php_strip_whitespace(KONG_PATH.'base/core.class.php'), "<?ph>\r\n");
52 $s .= trim(php_strip_whitespace(KONG_PATH.'base/debug.class.php'), "<?ph>\r\n");
53 $s .= trim(php_strip_whitespace(KONG_PATH.'base/log.class.php'), "<?ph>\r\n");
54 $s .= trim(php_strip_whitespace(KONG_PATH.'base/model.class.php'), "<?ph>\r\n");
55 $s .= trim(php_strip_whitespace(KONG_PATH.'base/view.class.php'), "<?ph>\r\n");
56 $s .= trim(php_strip_whitespace(KONG_PATH.'base/control.class.php'), "<?ph>\r\n");
57 $s .= trim(php_strip_whitespace(KONG_PATH.'db/db.interface.php'), "<?ph>\r\n");
58 $s .= trim(php_strip_whitespace(KONG_PATH.'db/db_mysql.class.php'), "<?ph>\r\n");
59 $s .= trim(php_strip_whitespace(KONG_PATH.'cache/cache.interface.php'), "<?ph>\r\n");
60 $s .= trim(php_strip_whitespace(KONG_PATH.'cache/cache_memcache.class.php'), "<?ph>\r\n");
61 $s = str_replace('defined(\'KONG_PATH\') || exit;', '', $s);
62 file_put_contents($runfile, '<?php '.$s);
63 unset($s);
64 }
65 include $runfile;
66}
67core::start();
68
69if(DEBUG > 1 && !R('ajax', 'R')) {
70 debug::sys_trace();
71}
72