Context.php
1.56 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
<?php
class LtContext
{
/**
* The uri property
*
* @var array
*/
public $uri;
protected $strip;
public function __construct()
{
}
/**
* return the client input in $_SERVER['argv']
*
* @param integer $offset
* @return string
*/
public function argv($offset)
{
return isset($_SERVER['argv']) && isset($_SERVER['argv'][$offset]) ? $_SERVER['argv'][$offset] : null;
}
/**
* return the client input in $_FILES
*
* @param string $name
* @return array
*/
public function file($name)
{
return isset($_FILES[$name]) ? $_FILES[$name] : null;
}
/**
* return the client input in $_GET
*
* @param string $name
* @return string
*/
public function get($name)
{
return isset($_GET[$name]) ? $_GET[$name] : null;
}
/**
* return the client input in $_POST
*
* @param string $name
* @return string
*/
public function post($name)
{
return isset($_POST[$name]) ? $_POST[$name] : null;
}
/**
* return the client input in $_REQUEST
*
* @param string $name
* @return string
*/
public function request($name)
{
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : null;
}
/**
* return the client input in $_SERVER
*
* @param string $name
* @return string
*/
public function server($name)
{
if ('REMOTE_ADDR' == $name)
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$clientIp = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$clientIp = $_SERVER[$name];
}
return $clientIp;
}
else
{
return isset($_SERVER[$name]) ? $_SERVER[$name] : null;
}
}
}