模拟登陆

$webdb['cookie'] = '6o0xxdevwm16371195l2897615';
$webdb['datesite'] = 'http://66.133.87.55';
$webdb['user'] = 'qq1234';
$webdb['pawd'] = '123456';
$webdb['uid'] = '1';
 
$curl = new Curl_HTTP_Client();
$curl->store_cookies("tmp/cookies.txt"); 
$curl->set_user_agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
$v=$webdb["datesite"];
$login=array();
$login['username']=$webdb["user"];
$login['passwd']=$webdb["pawd"];
$login['langx']="zh-cn";
$curl->set_referrer("".$v."");
$html_date=$curl->fetch_url("".$v."/app/member/","",5);
$html_date=$curl->send_post_data("".$v."/app/member/new_login.php",$login,"",5);
$new_uid=explode("|",$html_date);
//preg_match("/top.uid = '([^']+)/si",$html_date,$new_uid);
/*preg_match("/location.href = '([^']+)/si",$html_date,$turl);
$curl->set_referrer("".$v."/app/member/login.php");
$tdate=$curl->fetch_url($turl[1]);
preg_match("/action='([^']+)/si",$tdate,$wurl);
$v=$wurl[1];
 
if(!$v)$v=$webdb["datesite"];*/
//$v='http://hg3088.com';
if(strlen($new_uid[3])>0  ){
$uid=$new_uid[3];
$cache = "<?php ";
$cache .= "$webdb['cookie'] = '".$uid."'; ";
$cache .= "$webdb['datesite'] = '".$v."'; ";
$cache .= "$webdb['user'] = '".$webdb['user']."'; ";
$cache .= "$webdb['pawd'] = '".$webdb['pawd']."'; ";
$cache .= "$webdb['uid'] = '1'; ?>";
if(!write_file("db.php",$cache)){ //写入缓存失败
$meg = "缓存文件写入失败!请先设db.php文件权限为:0777";
}
 
write_file("../../../wap/zxcv567890/cj/db.php",$cache);
}
if($new_uid[3]){
echo '成功獲取繁體的uid: '.$uid.'<br>';
}else{
echo "繁體登陸錯誤!\請檢查繁體用戶名和密碼!!<br><br>";
}
echo $webdb['user'].'<br />'.$v;
?>
原文地址:https://www.cnblogs.com/csjoz/p/7243853.html