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.
|
|
<?php /** * Класс для работы с переменными окружения. * * @copyright netmonsters.ru * @link * @package Majestic * @subpackage Core * @since * @version SVN: $Id$ * @filesource $URL$ */ final class Env { static public $params = array();
static function Get($var, $default = false) { return isset($_GET[$var]) ? $_GET[$var] : $default; }
static function Post($var, $default = false) { return isset($_POST[$var]) ? $_POST[$var] : $default; }
static function Server($var, $default = false) { return isset($_SERVER[$var]) ? $_SERVER[$var] : $default; }
static function Session($var, $default = false) { return isset($_SESSION[$var]) ? $_SESSION[$var] : $default; } static function setSession($var, $value) { $_SESSION[$var] = $value; } /** * Unsets session var * * @param string $var */ static function unsetSession($var) { if (isset($_SESSION[$var])) { unset($_SESSION[$var]); } }
static function getCookie($var, $default = false) { return isset($_COOKIE[$var]) ? $_COOKIE[$var] : $default; }
static function setCookie($var, $value, $time = 0, $path = '/') { return setcookie($var, $value, $time, $path); }
static function getParam($var, $default = false) { return isset(self::$params[$var]) ? self::$params[$var] : $default; }
static function setParam($var, $val) { self::$params[$var] = $val; }
static function setParams($params=array()) { self::$params = self::$params + $params; }
static public function Files($name = '', $default = array(), $param = false) { if(!isset($_FILES)){ return $default; } if(empty($name)){ return $_FILES; } $res = isset($_FILES[$name]) ? $_FILES[$name] : $default; return $param ? $res[$param] : $res; } } ?>
|