$ Uinfo = parse_url ($ url); // parse the URL address, such as the http://php100.com/archives/1.html If ($ uinfo ['path']) // $ Data = $ uinfo ['path']; // get/archives/1.html Else $ Data = '/'; // Default Root If (! $ Fsp = @ fsockopen ($ uinfo ['host'], ($ uinfo ['Port'])? $ Uinfo ['Port']: "80"), $ errno, $ errstr, 12 )){ Echo "sorry, the recipient's website cannot be opened at the moment. Please visit later:". $ uinfo ['host']; exit; } Else { Fputs ($ fsp, "GET". $ data. "HTTP/1.0rn"); // if it is a cross-site POST submission, you can use the POST Method Fputs ($ fsp, "Host:". $ uinfo ['host']. "rn "); Fputs ($ fsp, "Referer: php100.comrn"); // counterfeit REFERER address Fputs ($ fsp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) rnrn "); $ Res = ''; While (! Feof ($ fsp )){ $ Res. = fgets ($ fsp, 128 ); If (strstr ($ res, "200 OK ")){ Header ("Location: $ url"); exit; } } } // If the status code is 301 or 302, you can continue to process the code. // Return URL approximate form: HTTP/1.1 301 Moved PermanentlynContent-Length: 164nContent-Type: text/htmlnLocation: http://php100.com/ $ Arr = explode ("n", $ res ); $ Arr = explode (":", $ arr [3]); // The Location is followed by a real redirection address. Header ("location:". $ arr [0]); // jump to the target address Exit; |