您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

URL、表单数据、IP等处理类,url表单_PHP教程

2024/6/9 1:35:33发布12次查看
url、表单数据、ip等处理类,url表单stripslashes($_request); $post = $this->stripslashes($_post); $this->cookie = $this->stripslashes($_cookie); } else { $get = $_request; $post = $_post; $this->cookie = $_cookie; } $this->file = $_files; $this->get = $this->initdata($get); $this->post = $this->initdata($post); $this->url = $this->parseurl(); $this->cookie = $this->initdata($this->cookie); } //解析url public function parseurl() { if(isset($_request['route'])) { return explode('-',$_request['route']); //解析路由 } elseif(isset($_server['query_string'])) { $tmp = explode('#',$_server['query_string'],2); $tp = explode('&',$tmp[0],2); return explode('-',$tp[0]); } else return false; } //返回$_request数组内的值 public function get($par) { if(isset($this->get[$par]))return $this->get[$par]; else return false; } //返回$_post数组内的值 public function post($par) { if(isset($this->post[$par]))return $this->post[$par]; else return false; } //返回url数组中的值 public function url($par) { $par = intval($par); if(isset($this->url[$par]))return $this->url[$par]; else return false; } //设置cookie public function setcookie($name,$value,$time=3600) { if($time)$time = time + $time; else $time = 0; if(cdo)setcookie(ch.$name,$value,$time,cp,cdo); else setcookie(ch.$name,$value,$time,cp); } //获取cookie public function getcookie($par,$nohead = 0) { if(isset($this->cookie[ch.$par]))return $this->cookie[ch.$par]; elseif(isset($this->cookie[$par]) && $nohead)return $this->cookie[$par]; else return false; } //获取$_file public function getfile($par) { if(isset($this->file[$par]))return $this->file[$par]; else return false; } //初始化数据 public function initdata($data) { if(is_array($data)) { foreach($data as $key => $value) { if($this->strings->isallowkey($key) === false) { unset($data[$key]); } else $data[$key] = $this->initdata($value); } return $data; } else { if(is_numeric($data)) { if($data[0] === 0)return $this->addslashes(htmlspecialchars(str_replace(',',$data))); if(strlen($data) >= 11)return $this->addslashes(htmlspecialchars(str_replace(',',$data))); if(strpos($data,'.'))return floatval($data); else return intval($data); } if(is_string($data))return $this->addslashes(htmlspecialchars(str_replace(',',$data))); if(is_bool($data))return (bool)$data; return false; } } //去除转义字符 public function stripslashes($data) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = $this->stripslashes($value); } } else { $data = stripslashes(trim($data)); } return $data; } //添加转义字符 public function addslashes($data) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = $this->addslashes($value); } } else { $data = addslashes(trim($data)); } return $data; } //获取客户端ip public function getclientip() { if(!isset($this->e['ip'])) { if (getenv(http_client_ip) && strcasecmp(getenv(http_client_ip), unknown)) $ip = getenv(http_client_ip); else if (getenv(http_x_forwarded_for) && strcasecmp(getenv(http_x_forwarded_for), unknown)) $ip = getenv(http_x_forwarded_for); else if (getenv(remote_addr) && strcasecmp(getenv(remote_addr), unknown)) $ip = getenv(remote_addr); else if (isset($_server['remote_addr']) && $_server['remote_addr'] && strcasecmp($_server['remote_addr'], unknown)) $ip = $_server['remote_addr']; else $ip = unknown; $this->e['ip'] = $ip; } return $this->e['ip']; } //根据二级域名获取信息 public function getseconddomain() { $domain = $_server['http_host']; $domain = str_replace(array('com.cn','net.cn','gov.cn','org.cn'),'com',$domain); $tmp = explode('.',$domain); if(count($tmp)
http://www.bkjia.com/phpjc/1115244.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1115244.htmltecharticleurl、表单数据、ip等处理类,url表单 ? php class ev{ public $cookie; public $post; public $ get ; public $file; public $url; public $g; private $e; public function __con...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product