模拟登录

<?php
$data = array(
        'username'=>'ghhost',
        'pwd' => 'ghost123',
        'act' => 'act_login',
        'back_act'=>'http://localhost/ecshop/index.php',
    );

$data = http_build_query($data);

$fp = fsockopen("localhost",80,$errno,$errstr,5);
$request = "POST http://localhost/ecshop/user.php HTTP/1.1\r\n";
$request .= "HOST:localhost\r\n";
$request .= "Proxy-Connection:keep-alive"."\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\r\n";
$request .= "Referer: http://www.iphpcms.net/index.php?m=member&c=index&a=login\r\n";
$request .= "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36\r\n";
$request .= $data."\r\n";
fwrite($fp, $request);
$str = '';
while (!feof($fp)) {
    $str .= fgets($fp,1024);
}
file_put_contents("./user.html", $str);
preg_match('/ECS_ID=(.*)?;/', $str,$match);
setcookie("ECS_ID",$match[1],0,'/');
fclose($fp);
if (preg_match('/登录成功/', $str)) {
    echo "ok";
}else{
    echo "error";
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容