亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

不支持fsockopen但支持culr環(huán)境下下ucenter與modoer通訊問題

 更新時間:2011年08月12日 16:20:30   作者:  
網(wǎng)站上線,modoer與ucenter 下不能通訊折騰了我差不多二天,開始都以為自己的配置出問題,移植了平臺后就不能通訊了,修改了幾次配置,都沒有成功
所以就懷疑是否編碼問題,或者文件權(quán)限問題,或者是不是函數(shù)不支持問題,經(jīng)過排查發(fā)現(xiàn)原來是萬網(wǎng)的L1主機不支持fsockopen,在文件uc_client/client.php中的uc_fopen中出現(xiàn)了問題,這里的代碼是這樣:
復(fù)制代碼 代碼如下:

function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$matches = parse_url($url);
!isset($matches['host']) && $matches['host'] = '';
!isset($matches['path']) && $matches['path'] = '';
!isset($matches['query']) && $matches['query'] = '';
!isset($matches['port']) && $matches['port'] = '';
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80;
if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= 'Content-Length: '.strlen($post)."\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cache-Control: no-cache\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
$out .= $post;
} else {
$out = "GET $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
}
$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
if(!$fp) {
return '';//note $errstr : $errno \r\n
} else {
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if(!$status['timed_out']) {
while (!feof($fp)) {
if(($header = @fgets($fp)) && ($header == "\r\n" || $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);
return $return;
}
}

fsockopen函數(shù)不能使用,因些就只能靠其它方法了,幸虧支持curl,file_get_contents也支持,經(jīng)考慮就用curl吧,修改了uc_fopen函數(shù),如下;
復(fù)制代碼 代碼如下:

function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
if($post) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
}
if($cookie) {
curl_setopt($curl, CURLOPT_COOKIE, $cookie);
}
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($curl);
if (curl_errno($curl)) {
echo '<pre><b>錯誤:</b><br />'.curl_error($curl);
}
curl_close($curl);
return $return;
}

于是modoer下的uc_client/client.php和uchome下的uc_cilent/client.php,就這樣修改了uc_open函數(shù),呵呵,第一次使用curl,網(wǎng)上的資料還是好多的,所以也沒有什么阻礙,不過就不知這個修改會不會影響其它的東西,還有待測試羅。。。。

相關(guān)文章

  • php中把對象轉(zhuǎn)換為數(shù)組幾種簡單巧妙的方法

    php中把對象轉(zhuǎn)換為數(shù)組幾種簡單巧妙的方法

    在PHP中,對象是一種復(fù)雜的數(shù)據(jù)類型,它可以包含多個屬性和方法,有時候我們需要將對象轉(zhuǎn)換為數(shù)組進(jìn)行操作,比如將對象存儲到數(shù)據(jù)庫中,或者將對象轉(zhuǎn)換為JSON格式等情況,對象轉(zhuǎn)數(shù)組不能用遞歸實現(xiàn)轉(zhuǎn)換,本文幾種簡單巧妙的方法
    2023-09-09
  • phpinfo()中Loaded Configuration File(none)的解決方法

    phpinfo()中Loaded Configuration File(none)的解決方法

    這篇文章主要給大家介紹了phpinfo()中Loaded Configuration File(none)問題的解決方法,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-01-01
  • PHP使用flock實現(xiàn)文件加鎖的方法

    PHP使用flock實現(xiàn)文件加鎖的方法

    這篇文章主要介紹了PHP使用flock實現(xiàn)文件加鎖的方法,實例分析了flock文件鎖的使用技巧,需要的朋友可以參考下
    2015-07-07
  • php實現(xiàn)專業(yè)獲取網(wǎng)站SEO信息類實例

    php實現(xiàn)專業(yè)獲取網(wǎng)站SEO信息類實例

    這篇文章主要介紹了php實現(xiàn)專業(yè)獲取網(wǎng)站SEO信息類,實例分析了seoreport類針對網(wǎng)站SEO信息檢查與獲取的技巧,非常具有實用價值,需要的朋友可以參考下
    2015-04-04
  • PHPExcel實現(xiàn)表格導(dǎo)出功能示例【帶有多個工作sheet】

    PHPExcel實現(xiàn)表格導(dǎo)出功能示例【帶有多個工作sheet】

    這篇文章主要介紹了PHPExcel實現(xiàn)表格導(dǎo)出功能,結(jié)合實例形式分析了PHPExcel針對帶有多個工作sheet的表格導(dǎo)出相關(guān)操作實現(xiàn)技巧,需要的朋友可以參考下
    2018-06-06
  • PHP7基于curl實現(xiàn)的上傳圖片功能

    PHP7基于curl實現(xiàn)的上傳圖片功能

    這篇文章主要介紹了PHP7基于curl實現(xiàn)的上傳圖片功能,結(jié)合實例形式對比分析了php5.5之前與php7版本的curl圖片上傳功能相關(guān)實現(xiàn)與使用技巧,需要的朋友可以參考下
    2018-05-05
  • php內(nèi)核解析:PHP中的哈希表

    php內(nèi)核解析:PHP中的哈希表

    PHP中使用最為頻繁的數(shù)據(jù)類型非字符串和數(shù)組莫屬,PHP比較容易上手也得益于非常靈活的數(shù)組類型。 在開始詳細(xì)介紹這些數(shù)據(jù)類型之前有必要介紹一下哈希表(HashTable)。 哈希表是PHP實現(xiàn)中尤為關(guān)鍵的數(shù)據(jù)結(jié)構(gòu)
    2014-01-01
  • php 判斷訪客是否為搜索引擎蜘蛛的函數(shù)代碼

    php 判斷訪客是否為搜索引擎蜘蛛的函數(shù)代碼

    php 判斷訪客是否為搜索引擎蜘蛛的函數(shù)代碼。需要的朋友可以參考下。
    2011-07-07
  • ini_set的用法介紹

    ini_set的用法介紹

    PHP ini_set用來設(shè)置php.ini的值,在函數(shù)執(zhí)行的時候生效,對于虛擬空間來說,很方便,下面為大家介紹下此方法的使用
    2014-01-01
  • php實現(xiàn)的雙向隊列類實例

    php實現(xiàn)的雙向隊列類實例

    這篇文章主要介紹了php實現(xiàn)的雙向隊列類,是數(shù)據(jù)結(jié)構(gòu)中非常重要的一個數(shù)據(jù)結(jié)構(gòu)類型,需要的朋友可以參考下
    2014-09-09

最新評論