/** * 获取COOKIE * * @access public * @param string * @param string * @param bool * @return mixed */ public static function get($index = null, $default = '', $prefix = '', $xssClean = FALSE) { $data = $_COOKIE; if ($prefix == '' and Config::get('request', 'cookiePrefix', '') != '') { $prefix = Config::get('request', 'cookiePrefix'); } if ($prefix == '') { if ($index === null) { $name = null; $default = array(); } else { $name = $prefix . $index; } } else { if ($index === null) { foreach ($_COOKIE as $key => $v) { if (!preg_match("#^" . $prefix . "#", $key)) { unset($data[$key]); } } $name = null; $default = array(); } else { $name = $prefix . $index; } } return Util::fetch($data, $name, $default, $xssClean); }
/** * 获取 $_SERVER 值 * * @access public * @param string 键值 * @param string 默认值 * @param bool 是否清除xss字符 * @return mix */ public static function server($index = null, $default = '', $xssClean = FALSE) { if ($index === null) { $default = array(); } return Util::fetch($_SERVER, $index, $default, $xssClean); }