URL, form data, IP and other processing class php URL parameter url parameter array jquery get URL argument

Source: Internet
Author: User
Tags setcookie
 Phpclassev{ Public$cookie;  Public$post;  Public$Get;  Public$file;  Public$url;  Public$G; Private$e;  Publicfunction __construct ()    {if(Ini_get ('MAGIC_QUOTES_GPC') {//Determine if php.ini has MAGIC_QUOTES_GPC filter (Escape) function $Get= $ This-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-cookies); }    //parsing URLs Publicfunction parseURL () {if(Isset ($_request['Route']))        {            returnExplode'-', $_request['Route']); Parse route} elseif (Isset ($_server['query_string']) {$tmp= Explode ('#', $_server['query_string'],2); $TP= Explode ('&', $tmp [0],2); returnExplode'-', $TP [0]); }        Elsereturnfalse; }    //returns the value in the $_request array PublicfunctionGet($par) {if(Isset ($ This-Get[$par]))return$ This-Get[$par]; Elsereturnfalse; }    //returns the value in the $_post array Publicfunction Post ($par) {if(Isset ($ This->post[$par]))return$ This-post[$par]; Elsereturnfalse; }    //returns the value in the URL array Publicfunction URL ($par) {$par=intval ($par); if(Isset ($ This->url[$par]))return$ This-url[$par]; Elsereturnfalse; }    //Set Cookies Publicfunction Setcookie ($name, $value, $time =3600)    {        if($time) $time = time +$time; Else$time =0; if(CDO) Setcookie (CH. $name, $value, $time, CP,CDO); ElseSetcookie (CH. $name, $value, $time, CP); }    //Get Cookies Publicfunction 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]; Elsereturnfalse; }    //Get $_file Publicfunction GetFile ($par) {if(Isset ($ This->file[$par]))return$ This-file[$par]; Elsereturnfalse; }    //Initializing Data Publicfunction 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) >= One)return$ This->addslashes (Htmlspecialchars (Str_replace ("'","'", $data))); if(Strpos ($data,'.'))returnfloatval ($data); Elsereturnintval ($data); }            if(Is_string ($data))return$ This->addslashes (Htmlspecialchars (Str_replace ("'","'", $data))); if(Is_bool ($data))return(BOOL) $data; returnfalse; }    }    //Remove escape characters Publicfunction Stripslashes ($data) {if(Is_array ($data)) {foreach($data as$key =$value) {$data [$key]= $ This-stripslashes ($value); }        } Else{$data=stripslashes (Trim ($data)); }        return$data; }    //To add an escape character Publicfunction Addslashes ($data) {if(Is_array ($data)) {foreach($data as$key =$value) {$data [$key]= $ This-addslashes ($value); }        } Else{$data=addslashes (Trim ($data)); }        return$data; }    //Get client IP Publicfunction Getclientip () {if(!isset ($ This->e['IP']))        {            if(Getenv ("http_client_ip") && strcasecmp (getenv ("http_client_ip"),"Unknown")) $ip= Getenv ("http_client_ip"); Elseif(Getenv ("http_x_forwarded_for") && strcasecmp (getenv ("http_x_forwarded_for"),"Unknown")) $ip= Getenv ("http_x_forwarded_for"); Elseif(Getenv ("REMOTE_ADDR") && strcasecmp (getenv ("REMOTE_ADDR"),"Unknown")) $ip= Getenv ("REMOTE_ADDR"); Elseif(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']; }    //get information based on level two domain name Publicfunction 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) <3)returnfalse; ElseIf (Is_numeric ($tmp [0]))returnfalse; Elsereturn$tmp [0]; }}?>

The above describes the URL, form data, IP and other processing classes, including the URL, singular content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.