App.class.php
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
/**
* ThinkPHP 精简模式应用程序类
*/
class App {
/**
* 应用程序初始化
* @access public
* @return void
*/
static public function run() {
// 取得模块和操作名称
define('MODULE_NAME', App::getModule()); // Module名称
define('ACTION_NAME', App::getAction()); // Action操作
// 记录应用初始化时间
if(C('SHOW_RUN_TIME')) $GLOBALS['_initTime'] = microtime(TRUE);
// 执行操作
R(MODULE_NAME.'/'.ACTION_NAME);
// 保存日志记录
if(C('LOG_RECORD')) Log::save();
return ;
}
/**
* 获得实际的模块名称
* @access private
* @return string
*/
static private function getModule() {
$var = C('VAR_MODULE');
$module = !empty($_POST[$var]) ?
$_POST[$var] :
(!empty($_GET[$var])? $_GET[$var]:C('DEFAULT_MODULE'));
if(C('URL_CASE_INSENSITIVE')) {
// URL地址不区分大小写
define('P_MODULE_NAME',strtolower($module));
// 智能识别方式 index.php/user_type/index/ 识别到 UserTypeAction 模块
$module = ucfirst(parse_name(strtolower($module),1));
}
unset($_POST[$var],$_GET[$var]);
return $module;
}
/**
* 获得实际的操作名称
* @access private
* @return string
*/
static private function getAction() {
$var = C('VAR_ACTION');
$action = !empty($_POST[$var]) ?
$_POST[$var] :
(!empty($_GET[$var])?$_GET[$var]:C('DEFAULT_ACTION'));
unset($_POST[$var],$_GET[$var]);
return $action;
}
};