보험최저가로 가입하는요령 쉬운 돈벌기 방법
글수 769
function HTTP_Post
fopen() 이나 fsockopen() 으로 열리지 않는 페이지는 file() 로 잘 열리더군요,
그리고 post 형식 form 페이지는 아래 함수로 잘 열립니다.
function HTTP_Post($URL,$data, $referrer="") {
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script-x as referrer
$referrer=$_SERVER["SCRIPT-x_URI"];
// making string from $data
foreach($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: $referer\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);
return $result;
}
사용은
$output=HTTP_Post("http://www.server.com/script-x.php",$_POST);
$_POST 는 post 폼에서 필요한 변수들의 배열입니다. 예를들면
$_POST["name"] = "php";
$_POST["pwd"] = "school";
$_POST["email"] = "webmaster@phpschool.com";
그리고 post 형식 form 페이지는 아래 함수로 잘 열립니다.
function HTTP_Post($URL,$data, $referrer="") {
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script-x as referrer
$referrer=$_SERVER["SCRIPT-x_URI"];
// making string from $data
foreach($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: $referer\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);
return $result;
}
사용은
$output=HTTP_Post("http://www.server.com/script-x.php",$_POST);
$_POST 는 post 폼에서 필요한 변수들의 배열입니다. 예를들면
$_POST["name"] = "php";
$_POST["pwd"] = "school";
$_POST["email"] = "webmaster@phpschool.com";
태초에 나는 개그이야기를 만들었다.
내말을 믿고 나를 따르면 천당,
내말을 믿지않고 나를 따르지 않으면 지옥,
나는 하늘나라(우주)에 사느니라.
그럼 난 외계인?




웃대가리
