帝國cms后臺采集支持https開頭的協(xié)議地址修改方法

admin 建站教程評論887字數(shù) 1327閱讀模式

修改:/e/class/connect.php文件
在該文件最上面加上以下函數(shù)

  1. //獲取https鏈接內(nèi)容
  2. function?getHTTPS($url)?{
  3. ????????$ch?=?curl_init();
  4. ????????curl_setopt($ch,?CURLOPT_SSL_VERIFYPEER,?FALSE);
  5. ????????curl_setopt($ch,?CURLOPT_HEADER,?false);
  6. ????????curl_setopt($ch,?CURLOPT_FOLLOWLOCATION,?true);
  7. ????????curl_setopt($ch,?CURLOPT_URL,?$url);
  8. ????????curl_setopt($ch,?CURLOPT_REFERER,?$url);
  9. ????????curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?TRUE);
  10. ????????$result?=?curl_exec($ch);
  11. ????????curl_close($ch);
  12. ????????return?$result;
  13. }

找到ReadFiletext函數(shù)如下代碼

  1. function?ReadFiletext($filepath){
  2. ????$filepath=trim($filepath);
  3. ????$htmlfp=@fopen($filepath,"r");
  4. ????//遠程
  5. ????if(strstr($filepath,"://"))
  6. ????{
  7. ????????while($data=@fread($htmlfp,500000))
  8. ????????{
  9. ????????????$string.=$data;
  10. ????????}
  11. ????}
  12. ????//本地
  13. ????else
  14. ????{
  15. ????????$string=@fread($htmlfp,@filesize($filepath));
  16. ????}
  17. ????@fclose($htmlfp);
  18. ????return?$string;
  19. }

改成

  1. function?ReadFiletext($filepath){
  2. ????$filepath=trim($filepath);
  3. ????$htmlfp=@fopen($filepath,"r");
  4. ????//遠程
  5. ????if(strstr($filepath,"https://")){
  6. ????????????????return?getHTTPS($filepath);
  7. ????????}
  8. ????if(strstr($filepath,"://"))
  9. ????{
  10. ????????while($data=@fread($htmlfp,500000))
  11. ????????{
  12. ????????????$string.=$data;
  13. ????????}
  14. ????}
  15. ????//本地
  16. ????else
  17. ????{
  18. ????????$string=@fread($htmlfp,@filesize($filepath));
  19. ????}
  20. ????@fclose($htmlfp);
  21. ????return?$string;
  22. }

自此可實現(xiàn)采集https開頭的網(wǎng)頁鏈接

版權(quán)聲明:文章圖片資源來源于網(wǎng)絡,如有侵權(quán),請留言刪除!!!
廣告也精彩
admin
  • 本文由 發(fā)表于 2021年9月29日 17:47:01
  • 轉(zhuǎn)載請務必保留本文鏈接:http://yudch.cn/7828.html
匿名

發(fā)表評論

匿名網(wǎng)友 填寫信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: