request.class.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Provides access to various HTTP request elements: GET, POST, FILE, etc paramaters.
  4. * @license see /license.txt
  5. * @deprecated
  6. * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
  7. */
  8. class Request
  9. {
  10. public static function get($key, $default = null)
  11. {
  12. return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
  13. }
  14. public static function has($key) {
  15. return isset($_REQUEST[$key]);
  16. }
  17. /**
  18. * Returns true if the request is a GET request. False otherwise.
  19. *
  20. * @return bool
  21. */
  22. public static function is_get()
  23. {
  24. $method = self::server()->request_method();
  25. $method = strtoupper($method);
  26. return $method == 'GET';
  27. }
  28. public static function post($key, $default = null)
  29. {
  30. return isset($_POST[$key]) ? $_POST[$key] : $default;
  31. }
  32. /**
  33. * Returns true if the request is a POST request. False otherwise.
  34. *
  35. * @return bool
  36. */
  37. public static function is_post()
  38. {
  39. $method = self::server()->request_method();
  40. $method = strtoupper($method);
  41. return $method == 'POST';
  42. }
  43. static function file($key, $default = null)
  44. {
  45. return isset($_FILES[$key]) ? $_FILES[$key] : $default;
  46. }
  47. static function environment($key, $default = null)
  48. {
  49. return isset($_ENV[$key]) ? $_ENV[$key] : $default;
  50. }
  51. }