You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

  1. <?php
  2. /**
  3. * Класс для работы с переменными окружения.
  4. *
  5. * @copyright
  6. * @link
  7. * @package Majestic
  8. * @subpackage Core
  9. * @since
  10. * @version SVN: $Id$
  11. * @filesource $URL$
  12. */
  13. final class Env
  14. {
  15. static public $params = array();
  16. static function Get($var, $default = false)
  17. {
  18. return isset($_GET[$var]) ? $_GET[$var] : $default;
  19. }
  20. static function Post($var, $default = false)
  21. {
  22. return isset($_POST[$var]) ? $_POST[$var] : $default;
  23. }
  24. static function Server($var, $default = false)
  25. {
  26. return isset($_SERVER[$var]) ? $_SERVER[$var] : $default;
  27. }
  28. static function Session($var, $default = false)
  29. {
  30. return isset($_SESSION[$var]) ? $_SESSION[$var] : $default;
  31. }
  32. static function getCookie($var, $default = false)
  33. {
  34. return isset($_COOKIE[$var]) ? $_COOKIE[$var] : $default;
  35. }
  36. static function setCookie($var, $value, $time = 0, $path = '/')
  37. {
  38. return setcookie($var, $value, $time, $path);
  39. }
  40. static function getParam($var, $default = false)
  41. {
  42. return isset(self::$params[$var]) ? self::$params[$var] : $default;
  43. }
  44. static function setParam($var, $val)
  45. {
  46. self::$params[$var] = $val;
  47. }
  48. static function setParams($params=array())
  49. {
  50. self::$params = self::$params + $params;
  51. }
  52. }
  53. ?>