四虎影视在线影院在线观看,小s货再浪些再咬紧点h,国产精品水嫩水嫩,97精产国品一二三产区
標(biāo)題:
[求助]
一個php異步,在服務(wù)器上,得不到支持,發(fā)出來看一下!
[打印本頁]
作者:
else
時間:
2016-12-7 13:35
標(biāo)題:
一個php異步,在服務(wù)器上,得不到支持,發(fā)出來看一下!
function request_by_fsockopen($url,$post_data=array()){
global $config;
if(!strstr($url, 'http://'))
{
$url="http://" . $_SERVER['SERVER_NAME'] .$url;
}
$url_array = parse_url($url);
$hostname = $url_array['host'];
$port = isset($url_array['port'])? $url_array['port'] : 80;
$requestPath = $url_array['path'] ."?". $url_array['query'];
$fp = fsockopen($hostname, $port, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)";
return false;
}
$method = "GET";
if(!empty($post_data)){
$method = "POST";
}
$header = "$method $requestPath HTTP/1.1\r\n";
$header.="Host: ". $_SERVER['SERVER_NAME']."\r\n";
if(!empty($post_data)){
$_post = strval(NULL);
foreach($post_data as $k => $v){
$_post[]= $k."=".urlencode($v); //必須做url轉(zhuǎn)碼以防模擬post提交的數(shù)據(jù)中有&符而導(dǎo)致post參數(shù)鍵值對紊亂
}
$_post = implode('&', $_post);
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; //POST數(shù)據(jù)
$header .= "Content-Length: ". strlen($_post) ."\r\n"; //POST數(shù)據(jù)的長度
$header .= "Referer: http://".$_SERVER['SERVER_NAME']."/function.php\r\n"; //構(gòu)造參數(shù),防止外步提交!
$header .= "AppKey: ". $config['appkey'] ."\r\n";
$header.="Connection: Close\r\n\r\n";//長連接關(guān)閉
$header .= $_post; //傳遞POST數(shù)據(jù)
}else{
$header.="Connection: Close\r\n\r\n";//長連接關(guān)閉
}
fwrite($fp, $header);
//-----------------調(diào)試代碼區(qū)間-----------------
/*$html = '';
while (!feof($fp)) {
$html.=fgets($fp);
}
echo $html;*/
//-----------------調(diào)試代碼區(qū)間-----------------
fclose($fp);
}
復(fù)制代碼
歡迎光臨 WDlinux官方論壇 (http://cd-genova.com/bbs/)
Powered by Discuz! 7.2