No Description

Context.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. }