request.php

来自「a short sketch about linux syntex lines.」· PHP 代码 · 共 176 行

PHP
176
字号
<?php/*对用户前段端数据进行数量秀影EasyFrame1.0.0最后修改日期2008-11-28email:24498936@qq.comwebsite:http://www.vodcm.com*/class Easy_Controller_Request{	public $namespace = 'vodcms';	/*获取$_GET数据	@param $string 知道键名可为空	return string array	*/	function getParam($key = null){		if (is_null($key) == false ){			if(isset($_GET[$key])){				return $this->quotes($_GET[$key]);			}else{				return null;			}		}else{			return $this->quotes($_GET);		}	}	/*	获取$_REQUEST数据	*/	function getParams($key = null){		if (is_null($key) == false ){			if(isset($_REQUEST[$key])){				return $this->quotes($_REQUEST[$key]);			}else{				return null;			}		}else{			return $this->quotes($_REQUEST);		}	}	/*	检测是否是POST提交的数据	成功返回true否则返回false	*/	public function isPost(){		if ($_SERVER['REQUEST_METHOD']==='POST')		{			return true;		}else{			return false;		}	}	/*	获取指定键名POST数据否则返回全部post数据	*/	function getPost($key=null){		if (is_null($key)){			return $this->quotes($_POST);		}else{			if (isset($_POST[$key])){				return $this->quotes($_POST[$key]);			}else{				return null;			}		}	}	public function setSession($key, $value){		//echo $key;		return $_SESSION[$this->namespace][$key] = $value;	}	function getSession($key = null){		if (is_null($key)==false){			if ( isset($_SESSION[$this->namespace][$key])){				return  $_SESSION[$this->namespace][$key];			}else{				return false;			}		}		else{			return  $_SESSION[$this->namespace];		}	}	/*	锟斤拷锟斤拷站锟斤拷cookie	array('username'=>array('value',d,')	*/	function setCookie($name, $value, $lifetime=0, $path='/', $domain=null){		if (intval($lifetime)){			$lifetime = time() + $lifetime;		}		setcookie($this->namespace.'_'.$name, $value, $lifetime, $path, $domain);	}	/*	获取COOKIE值	*/	function getCookie($key=null){		if (is_null($key)){			return $_COOKIE;		}elseif(isset($_COOKIE[$this->namespace.'_'.$key])){			return $_COOKIE[$this->namespace.'_'.$key];		}	}	/*	锟斤拷锟?cookie	*/	function clearCookie($array = null){				if(is_null($array)===false){			foreach($array as $key){				call_user_func_array('setcookie', array($key, 'null',86400, '/'));			}					}	}	/*	url锟斤拷转	$uri  为指锟斤拷转锟斤拷URL;	*/	public function redirect($uri){		header('location:'.$uri);	}	public function strUserIp(){		return $_SERVER['REMOTE_ADDR'];	}	public function sendHeader($num = 200 ){			static $http = array (			100 => "HTTP/1.1 100 Continue",			101 => "HTTP/1.1 101 Switching Protocols",			200 => "HTTP/1.1 200 OK",			201 => "HTTP/1.1 201 Created",			202 => "HTTP/1.1 202 Accepted",			203 => "HTTP/1.1 203 Non-Authoritative Information",			204 => "HTTP/1.1 204 No Content",			205 => "HTTP/1.1 205 Reset Content",			206 => "HTTP/1.1 206 Partial Content",			300 => "HTTP/1.1 300 Multiple Choices",			301 => "HTTP/1.1 301 Moved Permanently",			302 => "HTTP/1.1 302 Found",			303 => "HTTP/1.1 303 See Other",			304 => "HTTP/1.1 304 Not Modified",			305 => "HTTP/1.1 305 Use Proxy",			307 => "HTTP/1.1 307 Temporary Redirect",			400 => "HTTP/1.1 400 Bad Request",			401 => "HTTP/1.1 401 Unauthorized",			402 => "HTTP/1.1 402 Payment Required",			403 => "HTTP/1.1 403 Forbidden",			404 => "HTTP/1.1 404 Not Found",			405 => "HTTP/1.1 405 Method Not Allowed",			406 => "HTTP/1.1 406 Not Acceptable",			407 => "HTTP/1.1 407 Proxy Authentication Required",			408 => "HTTP/1.1 408 Request Time-out",			409 => "HTTP/1.1 409 Conflict",			410 => "HTTP/1.1 410 Gone",			411 => "HTTP/1.1 411 Length Required",			412 => "HTTP/1.1 412 Precondition Failed",			413 => "HTTP/1.1 413 Request Entity Too Large",			414 => "HTTP/1.1 414 Request-URI Too Large",			415 => "HTTP/1.1 415 Unsupported Media Type",			416 => "HTTP/1.1 416 Requested range not satisfiable",			417 => "HTTP/1.1 417 Expectation Failed",			500 => "HTTP/1.1 500 Internal Server Error",			501 => "HTTP/1.1 501 Not Implemented",			502 => "HTTP/1.1 502 Bad Gateway",			503 => "HTTP/1.1 503 Service Unavailable",			504 => "HTTP/1.1 504 Gateway Time-out"			);			header($http[$num]);			echo '<h1>' .$http[$num].'</h1>';				}	/*字符转移处理	@param $data array*/	public function quotes($data){		return strAddslashes($data);	}}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?