Files
majestic/core/Env.class.php
akulikov 62eef89248 core added
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@2 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
2008-12-02 08:59:06 +00:00

64 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Класс для работы с переменными окружения.
*
*/
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 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 function parseTimer($time)
{
$hours = intval($time / 3600);
$minutes = intval($time/60 - $hours*60);
return sprintf('%02d:%02d:%02d', $hours, $minutes, $time - $hours*3600 - $minutes*60);
}
}
?>