Home > Backend Development > PHP Tutorial > mb_strlen httpdown php

mb_strlen httpdown php

WBOY
Release: 2016-06-23 14:35:55
Original
1248 people have browsed it

if(!function_exists("mb_strlen1"))
{
 function mb_strlen1($str,$enc='gb2312')
 {
  $l=0;
  for($i=0;$i   {
   if(ord($str[$i])>128)
   {
    if($enc=='gb2312')
    {
     $i++;
    }
    else if($enc=='utf8'||$enc=='utf-8')
    {
     $i+=2;
    }
   }
   $l++;
  }
  return $l;
 }
}

echo "/$l=".mb_strlen1("我市1ge中国人");

 

function socketData($host,$url,$headers='',$data){ $fp = @fsockopen($host, 80, $errno, $errstr, 30); if (!$fp) { return false; } else { $out = ($data?"POST":"GET")." ".$url." HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= $headers; $out .= "Connection: Close\r\n\r\n".$data; fwrite($fp, $out); $rtn = ""; while (!feof($fp)) { $rtn.= fgets($fp, 128); } fclose($fp); } //echo $rtn; $rtn=explode("\r\n\r\n",$rtn,2); $headerstr=explode("\r\n",$rtn[0]); //echo print_r($headerstr,1).'->'.__LINE__."
\r\n"; $headers=array(); foreach($headerstr as $str) { $tmp=explode(':',$str,2); if(count($tmp)==2) { $headers[$tmp[0]]=trim($tmp[1]); } } if(isset($headers['Transfer-Encoding'])&&$headers['Transfer-Encoding']=='chunked') { $body=$rtn[1]; $rs=explode("\r\n",$body,2); $tmp=''; while(count($rs)==2) { $l=hexdec($rs[0]); if($l==0) break; $tmp.=substr($rs[1],0,$l); $body=substr($rs[1],$l+2); if($body=='') break; $rs=explode("\r\n",$body,2); } $rtn[1]=$tmp; } //Set-Cookie if($headers['Location']) { return ($headers['Set-Cookie']?"Set-Cookie: ".$headers['Set-Cookie']."\r\n":"").'Location: '.$headers['Location']; } return $rtn[1]; }


 

echo socketData(**.cn','/index.php',"Cookie: lstat_bc_644048=27325049701746404581; PHPSESSID=addf71fbaf5e1efd9520d1aea8a69b66/r/n")

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template