-
Notifications
You must be signed in to change notification settings - Fork 0
/
TingExtHttpRequest.class.php
54 lines (50 loc) · 1.54 KB
/
TingExtHttpRequest.class.php
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
<?php
/**
* @file TingExtHttpRequest.class.php
* @brief http请求类
* @author sunhuai([email protected])
* @version 1.0
* @date 2013-1-31 8:56:53
*/
class TingExtHttpRequest {
public static function _getParam($name, $default) {
if (isset($_GET[$name])) {
return $_GET[$name];
}
return $default;
}
public static function _postParam($name, $default) {
if (isset($_POST[$name])) {
return $_POST[$name];
}
return $default;
}
public static function _getFields($filterFields = array(), $requestMethod = 'GET') {
if (empty($filterFields)) {
return array();
}
$fields = array();
if ($requestMethod == 'GET') {
$method = $_GET;
} else {
$method = $_POST;
}
foreach ($filterFields as $column => $filterMethodStr) {
if (isset($method[$column])) {
if ($filterMethodStr) {
$filterMethodArray = explode(',', $filterMethodStr);
if (count($filterMethodArray) == 1) {
$fields[$column] = $filterMethodArray[0]($method[$column]);
} else {
foreach ($filterMethodArray as $filterMethod) {
$fields[$column] = $filterMethod($method[$column]);
}
}
} else {
$fields[$column] = $method[$column];
}
}
}
return $fields;
}
}