php 通过fsockopen 模拟POST提交
来源:互联网 发布:北京it网络工程师学校 编辑:程序博客网 时间:2024/05/17 04:06
$URL=‘http://xxx.xxx.xxx.xx/xx/xxx/top.php';
$post_data['clientname'] = "test08";
$post_data['clientpasswd'] = "test08";
$post_data['submit'] = "ログイン";
$referrer="";
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=$_SERVER["SCRIPT_URI"];
// making string from $data
foreach($post_data as $key=>$value)
$values[]="$key=".urlencode($value);
$data_string=implode("&",$values);
// Find out which port is needed - if not given use standard (=80)
if(!isset($URL_Info["port"]))
$URL_Info["port"]=80;
// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1/n";
$request.="Host: ".$URL_Info["host"]."/n";
$request.="Referer: $referrer/n";
$request.="Content-type: application/x-www-form-urlencoded/n";
$request.="Content-length: ".strlen($data_string)."/n";
$request.="Connection: close/n";
$request.="/n";
$request.=$data_string."/n";
$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp);
$post_data['clientname'] = "test08";
$post_data['clientpasswd'] = "test08";
$post_data['submit'] = "ログイン";
$referrer="";
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=$_SERVER["SCRIPT_URI"];
// making string from $data
foreach($post_data as $key=>$value)
$values[]="$key=".urlencode($value);
$data_string=implode("&",$values);
// Find out which port is needed - if not given use standard (=80)
if(!isset($URL_Info["port"]))
$URL_Info["port"]=80;
// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1/n";
$request.="Host: ".$URL_Info["host"]."/n";
$request.="Referer: $referrer/n";
$request.="Content-type: application/x-www-form-urlencoded/n";
$request.="Content-length: ".strlen($data_string)."/n";
$request.="Connection: close/n";
$request.="/n";
$request.=$data_string."/n";
$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp);
- php 通过fsockopen 模拟POST提交
- php利用fsockopen 模拟post 提交
- PHP之fsockopen提交POST数据讲解
- PHP fsockopen模拟发送post set请求
- PHP模拟POST提交的2种方法 curl,fsockopen,HttpClient
- php 模拟POST提交
- php 利用fsockopen GET/POST 提交表单及上传文件
- php 利用fsockopen GET/POST 提交表单及上传文件
- PHP 利用 fsockopen GET/POST 提交表单及上传文件
- php socket模拟POST GET请求 fsockopen版
- fsockopen 模拟 post get 请求
- php模拟post提交数据
- php模拟post提交数据
- php模拟post提交数据
- php模拟post提交数据
- php curl 模拟post提交
- php模拟post提交请求
- PHP模拟发送POST请求之三、用Telnet和fsockopen()模拟发送POST信息
- linux httpd.conf文件配置详解
- linux parted创建GPT分区
- 授课感想
- 生成SQL Server数据库脚本四法
- ASP.NET常用JS脚本整理
- php 通过fsockopen 模拟POST提交
- WinCE5.0的USB Camera流接口驱动开发
- 开博目的
- flash 游戏设计笔记:人物行走一种做法
- 2009.12.16mark
- bat 批处理文件
- Linux配置WWW服务器全攻略
- xml解析与创建
- 关于页面动态添加控件