function wfopen($url,$post='',$cookie='',$timeout=15) {
$matches = parse_url($url);
$out = "POST {$matches['path']} HTTP/1.0rn";
$out .= "受け入れる: */*rn";
$out .= "Accept-Language: zh-cnrn";
$out .= "Content-Type: application/x-www-form-urlencodedrn";
$out .= "ユーザーエージェント: $_SERVER[HTTP_USER_AGENT] rn";
$out .= "ホスト: {$matches['host']}rn";
$out .= 'Content-Length: '.strlen($post)."rn";
$out .= "接続: 閉じる";
$out .= "キャッシュ制御: キャッシュなし";
$out .= "クッキー: $cookiernrn";
$out .= $post;
$socket = @fsockopen($matches['host'],80,$errno,$errstr,$timeout) または die("$errstr($errno)");
fwrite($socket,$out);
$header = $data = "";
while($infos = trim(fgets($socket,4096))) {
$header.=$infos;
}
while(!feof($socket)) {
$data .= fgets($socket,4096);
}
$data を返す;
}
echo wfopen('http://localhost/te.php','id=5');
?>
te.php
if(!empty($_POST['id'])) {
echo setcookie('auth','haowei',time()+3600,'/') 1 : 0;
}
|