<?
$fp=fsockopen("ssl://members.satgate.ru",443);
$hostname='members.satgate.ru';
$path1='/';
$buffer='';
$fp = fsockopen("ssl://".$hostname,443,$errno, $errstr, 120) or die("can't connect");
$out = "GET https://$hostname$path1 HTTP/1.1\r\n";
$out .= "Host: $hostname\r\n";
$out .= "Referer: $hostname\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
$out .= "Connection: Close\r\n";
$out .= "\r\n";
fwrite($fp, $out);
while(!feof($fp)){ $buffer.=fgets($fp,4096); }
fclose($fp);
// Находим куки
preg_match_all("/Set-Cookie: ([^=]+)=([^;]+);/", $buffer, $matches);
$size = sizeof(@$matches[0]);
$cookie = null;
for($i = 0; $i < $size; $i++)
{
if( !is_null($cookie) )
$cookie .= "&";
$cookie .= $matches[1][$i] . "=" . $matches[2][$i];
}
$cookie=substr(strrchr($cookie,"="),1);
$buffer='';
$data="PHPSESSID=".$cookie."&login=логин&password=пароль";
$fp = fsockopen("ssl://".$hostname,443,$errno, $errstr, 120) or die("can't connect");
$headers = "POST https://$hostname$path1 HTTP/1.1\r\n";
$headers .= "Host: $hostname\r\n";
$headers .= "Content-type: application/x-www-form-urlencoded\r\n";
$headers .= "Referer: http://".$hostname.$path1."\r\n";
$headers .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
$headers .= "Cookie: PHPSESSID=$cookie;\r\n";
$headers .= "Content-Length: ".strlen($data)."\r\n\r\n";
fwrite($fp,$headers.$data);
while(!feof($fp)){
$buffer.=fgets($fp,4096); }
fclose($fp);
// Находим куки
preg_match_all("/Set-Cookie: ([^=]+)=([^;]+);/", $buffer, $matches);
$size = sizeof(@$matches[0]);
$cookie = null;
for($i = 0; $i < $size; $i++)
{
if( !is_null($cookie) )
$cookie .= "&";
$cookie .= $matches[1][$i] . "=" . $matches[2][$i];
}
$cookie=substr(strrchr($cookie,"="),1);
echo $buffer;
?>