function req($url,$post) { global $HTTP_HOST,$debug; if(!ereg("^[a-z]{3,5}://[a-z0-9.:-]+/[^ ]+$",$url)) die("Неправильный URL!"); $a=explode("://",$url); $type=$a[0]; $url=substr($url,strlen($type)+3); $a=explode("/",$url); $domain=$a[0]; $path="/".substr($url,strlen($domain)); $a=explode(":",$domain); $domain=$a[0]; $port=(int)$a[1]; if(!$port) {if($type=="https") $port=443; else $port=80;} if($type=="https") $type="ssl://"; else $type=""; if($debug) echo $post."<br>"; $post=urlencode($post); $post=str_replace("%3D","=",$post);$post=str_replace("%26","&",$post); if($fp = fsockopen ("$type$domain", $port, $errno, $errstr, 30)) { fwrite ($fp, "POST $path HTTP/1.0\r\nHost: $domain\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ".strlen($post)."\r\n\r\n$post"); $response=""; while (!feof($fp)) $response.=fread($fp,8192); fclose($fp); } else die("Нет связи!"); $pos=strpos($response,"\r\n\r\n");if($pos) $response=substr($response,$pos+4); return $response; }