Context.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. class LtContext
  3. {
  4. /**
  5. * The uri property
  6. *
  7. * @var array
  8. */
  9. public $uri;
  10. protected $strip;
  11. public function __construct()
  12. {
  13. }
  14. /**
  15. * return the client input in $_SERVER['argv']
  16. *
  17. * @param integer $offset
  18. * @return string
  19. */
  20. public function argv($offset)
  21. {
  22. return isset($_SERVER['argv']) && isset($_SERVER['argv'][$offset]) ? $_SERVER['argv'][$offset] : null;
  23. }
  24. /**
  25. * return the client input in $_FILES
  26. *
  27. * @param string $name
  28. * @return array
  29. */
  30. public function file($name)
  31. {
  32. return isset($_FILES[$name]) ? $_FILES[$name] : null;
  33. }
  34. /**
  35. * return the client input in $_GET
  36. *
  37. * @param string $name
  38. * @return string
  39. */
  40. public function get($name)
  41. {
  42. return isset($_GET[$name]) ? $_GET[$name] : null;
  43. }
  44. /**
  45. * return the client input in $_POST
  46. *
  47. * @param string $name
  48. * @return string
  49. */
  50. public function post($name)
  51. {
  52. return isset($_POST[$name]) ? $_POST[$name] : null;
  53. }
  54. /**
  55. * return the client input in $_REQUEST
  56. *
  57. * @param string $name
  58. * @return string
  59. */
  60. public function request($name)
  61. {
  62. return isset($_REQUEST[$name]) ? $_REQUEST[$name] : null;
  63. }
  64. /**
  65. * return the client input in $_SERVER
  66. *
  67. * @param string $name
  68. * @return string
  69. */
  70. public function server($name)
  71. {
  72. if ('REMOTE_ADDR' == $name)
  73. {
  74. if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  75. {
  76. $clientIp = $_SERVER['HTTP_X_FORWARDED_FOR'];
  77. }
  78. else
  79. {
  80. $clientIp = $_SERVER[$name];
  81. }
  82. return $clientIp;
  83. }
  84. else
  85. {
  86. return isset($_SERVER[$name]) ? $_SERVER[$name] : null;
  87. }
  88. }
  89. }