function BuildHeader($method,$page,$host,$ref,$cookie,$data) { $ret="{$method} /{$page} HTTP/1.0\r\n". "Host: {$host}\r\n". "Referer: {$ref}\r\n"; if (!empty($cookie)>0) { $ret.="Cookie: {$cookie}\r\n"; } if ($method=='POST') { $ret.="Content-Length: ".strlen($data)."\r\n". "Content-Type: application/x-www-form-urlencoded\r\n\r\n{$data}\r\n"; } else $ret.="\r\n"; return $ret; } function Login($email,$pass) { $email=htmlspecialchars($email); $pass=htmlspecialchars($pass); $data="success_url=&fail_url=&try_to_login=1&email={$email}&pass={$pass}"; $head=BuildHeader('POST','login.php','vkontakte.ru','http://vkontakte.ru/login.php','',$data); $page=LoadPage('vkontakte.ru',80,$head); if ($page) { if ($id=okLogin($page)) { if ($cookie=ParseCookie($page)) { $c=''; for ($x=0;$x<count($cookie);$x++) $c.=$cookie[$x].'; '; $_SESSION[$id]=$c; header("Location: ?id={$id}"); die(); } else ShowError('Get COokie Error',true); } else ShowError('Login Error',true); } else ShowError('getPage Error',true); return false; }