interface.php
4.34 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
// 启动目录
define('BOOT_DIR_PATH', dirname(__FILE__).'/../../../../..');
define('ROOT_DIR_PATH', dirname(__FILE__).'/../../../BASE');
define('POST_PARAM_NAME', 'CALL');
define('POST_ROUTER', 'r');
require_once BOOT_DIR_PATH.'/util/JSON/JSON.class.php';
require_once BOOT_DIR_PATH.'/util/unicode/Unicode.class.php';
require_once BOOT_DIR_PATH.'/util/db/DbMysqli.class.php';
require_once ROOT_DIR_PATH.'/config/YSMCMain.const.php';
require_once ROOT_DIR_PATH.'/web/YSMWLoginAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWValidateRandomKeyAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWMessageAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWContactAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWRegisterAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWSystemSettingAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWHeadListAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWLogoutAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWAppAction.class.php';
$router = explode('/',$_POST[POST_ROUTER]);
echo '输入格式为:';
print_r($router);
print_r(getCallParam());
echo '返回结果为:';
// 返回的结果
$result = '';
switch ($router[0])
{
case 'login':
login($router[1]);
break;
case 'validate':
validate($router[1]);
break;
case 'message':
message($router[1]);
break;
case 'app':
app($router[1]);
break;
case 'register':
register($router[1]);
break;
case 'contact':
contact($router[1]);
break;
case 'systemSetting':
systemSetting($router[1]);
break;
case 'head':
headList($router[1]);
break;
case 'logout':
logout($router[1]);
break;
}
function login($r)
{
$param = getCallParam();
if(isset($param['request']))
{
$param = $param['request'];
}
else
{
$param = array();
}
$loginAction = new YSMWLoginAction();
echo $loginAction->login($param);
}
function validate($r)
{
$param = getCallParam();
$validateAction = new YSMWValidateRandomKeyAction();
echo $validateAction->validateRandomKey($param);
}
function message($r)
{
$param = getCallParam();
$messageAction = new YSMWMessageAction();
echo $messageAction->router($r, $param);
}
function app($r)
{
$param = getCallParam();
$appAction = new YSMWAppAction();
echo $appAction->router($r, $param);
}
function register($r)
{
$param = getCallParam();
if(isset($param['request']))
{
$param = $param['request'];
}
else
{
$param = array();
}
$registerAction = new YSMWRegisterAction();
switch ($r)
{
case 'checkIDAndName':
echo $registerAction->checkIDAndName($param);
break;
case 'checkPassword':
echo $registerAction->checkPassword($param);
break;
case 'register':
echo $registerAction->register($param);
break;
}
}
function contact($r)
{
$param = getCallParam();
$contactAction = new YSMWContactAction();
echo $contactAction->router($r, $param);
}
function systemSetting($r)
{
$param = getCallParam();
$systemSettingAction = new YSMWSystemSettingAction();
echo $systemSettingAction->router($r, $param);
}
function headList($r)
{
$param = getCallParam();
$headListAction = new YSMWHeadListAction();
echo $headListAction->router($r, $param);
}
function logout($r)
{
$param = getCallParam();
$logout = new YSMWLogoutAction();
echo $logout->router($r, $param);
}
/******************************************************/
function getCallParam()
{
$param = array();
if (isset($_POST[POST_PARAM_NAME]))
{
$paramValue = urldecode($_POST[POST_PARAM_NAME]);
//去除格式
$paramValue = str_replace('\n', '', $paramValue);
$paramValue = str_replace('\r', '', $paramValue);
$paramValue = str_replace('\t', '', $paramValue);
$paramValue = str_replace('', '', $paramValue);
//echo Unicode::urlDecode($paramValue);
//echo Json::decode(stripslashes(Unicode::urlDecode($paramValue)), true);
$param = Json::decode(stripslashes(Unicode::urlDecode($paramValue)), true);
echo "notice:";
}
return $param;
}
?>