elseif _POST method socket preg_match http a-z0-1- _POST url host path

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
} elseif ($_POST['method'] == 'socket') {
preg_match('|^http://([a-z0-1-\.]+)(.+)|i',$_POST['url'],$a);
$host = $a[1];
$path = $a[2];
//print_r($a);exit;
$fp = fsockopen($host, 80, $errno, $errstr, $_POST['timeout']);
if ($fp) {
if ($_POST['postfields']) $out = "POST $path HTTP/1.1\n";
else $out = "GET $path HTTP/1.1\n";
$out .= "Host: $host\n";
$out .= "User-Agent: ".$_POST['useragent']."\n";
if ($_POST['referer']) $out .= "Referer: ".$_POST['referer']."\n";
if ($_POST['postfields']) {
$out .= "Content-Type: application/x-www-form-urlencoded\n";
$out .= "Content-Length: ".strlen($_POST['postfields'])."\n";
}
if ($_POST['cookie']) $out .= "Set-Cookie: ".$_POST['cookie']."\n";
$out .= "Connection: close\n";
$out .= "\n";
if ($_POST['postfields']) $out .= $_POST['postfields']."\n\n";
//print $out;exit;
fputs($fp, $out);
while (!feof($fp)) {
$page .= fgets($fp, 2048);
}
fclose($fp);
} else {
$page = "$errstr ($errno)";
}
$md5 = md5($page);
echo "socket\n$md5\n$page";
}