Mb_strlen httpdown PHP

Source: Internet
Author: User
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 Chinese in our city");

function Socketdata ($host, $url, $headers = ", $data) {$fp = @fsockopen ($host, N, $errno, $errstr,), if (! $fp) {return FA Lse } 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, $);} 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]), the 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 ")

  • 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.