/**
成都創(chuàng)新互聯(lián)公司服務(wù)項目包括鶴城網(wǎng)站建設(shè)、鶴城網(wǎng)站制作、鶴城網(wǎng)頁制作以及鶴城網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,鶴城網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到鶴城省份的部分城市,未來相信會繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!* post數(shù)據(jù)
* @param string $url post的url
* @param int $limit 返回的數(shù)據(jù)的長度
* @param string $post post數(shù)據(jù),字符串形式username=\'dalarge\'&password=\'123456\'
* @param string $cookie 模擬 cookie,字符串形式username=\'dalarge\'&password=\'123456\'
* @param string $ip ip地址
* @param int $timeout 連接超時時間
* @param bool $block 是否為阻塞模式
* @return string 返回字符串
*/
private function _ps_post($url, $limit = 0, $post = \'\', $cookie = \'\', $ip = \'\', $timeout = 15, $block = true) {
$return = \'\';
$matches = parse_url($url);
$host = $matches[\'host\'];
$path = $matches[\'path\'] ? $matches[\'path\'].($matches[\'query\'] ? \'?\'.$matches[\'query\'] : \'\') : \'/\';
$port = !empty($matches[\'port\']) ? $matches[\'port\'] : 80;
$siteurl = $this->_get_url();
if($post) {
$out = "POST $path HTTP/1.1rn";
$out .= "Accept: */*rn";
$out .= "Referer: ".$siteurl."rn";
$out .= "Accept-Language: zh-cnrn";
$out .= "Content-Type: application/x-www-form-urlencodedrn";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]rn";
$out .= "Host: $hostrn" ;
$out .= \'Content-Length: \'.strlen($post)."rn" ;
$out .= "Connection: Closern" ;
$out .= "Cache-Control: no-cachern" ;
$out .= "Cookie: $cookiernrn" ;
$out .= $post ;
} else {
$out = "GET $path HTTP/1.1rn";
$out .= "Accept: */*rn";
$out .= "Referer: ".$siteurl."rn";
$out .= "Accept-Language: zh-cnrn";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]rn";
$out .= "Host: $hostrn";
$out .= "Connection: Closern";
$out .= "Cookie: $cookiernrn";
}
$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
if(!$fp) return \'\';
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if($status[\'timed_out\']) return \'\';
while (!feof($fp)) {
if(($header = @fgets($fp)) && ($header == "rn" || $header == "n")) break;
}
$stop = false;
while(!feof($fp) && !$stop) {
$data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
$return .= $data;
if($limit) {
$limit -= strlen($data);
$stop = $limit <= 0;
}
}
@fclose($fp);
//部分虛擬主機(jī)返回數(shù)值有誤,暫不確定原因,過濾返回數(shù)據(jù)格式
$return_arr = explode("n", $return);
if(isset($return_arr[1])) {
$return = trim($return_arr[1]);
}
unset($return_arr);
return $return;
}