2
我讓遠程服務器登錄system.For這個機器人,我編碼的東西,遠程登錄,捲曲
sample.php
<?php
$EMAIL = "***";
$PASSWORD = "***";
function cURL($url, $header=NULL, $cookie, $p=NULL)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_NOBODY, $header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if ($p) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$result = curl_exec($ch);
if ($result) {
return $result;
} else {
return curl_error($ch);
}
curl_close($ch);
}
$a = cURL("http://forum.donanimhaber.com/login2.asp",true,null,"Login=$EMAIL&password=$PASSWORD");
preg_match('%Set-Cookie: ([^;]+);%',$a,$b);
$c = cURL("http://forum.donanimhaber.com/login2.asp",true,$b[1],"Login=$EMAIL&password=$PASSWORD");
preg_match_all('%Set-Cookie: ([^;]+);%',$c,$d);
for($i=0;$i<count($d[0]);$i++)
$cookie.=$d[1][$i].";";
echo cURL("forum.donanimhaber.com",null,$cookie,null);
?>
我使用此代碼www.myhost.com/ sample.php ...登錄成功。但我沒有重定向forum.donanimhaber.com ...在forum.donanimhaber.com,當我點擊任何鏈接時,我的瀏覽器重定向myhost.com/link.php並出現空白頁面正常要求爲forum.donanimhaber.com/link.php ...