帝国cms后台采集支持https开头的协议地址修改方法

admin 建站教程评论757字数 1327阅读模式

修改:/e/class/connect.php文件
在该文件最上面加上以下函数

  1. //获取https链接内容
  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函数如下代码

  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. }

自此可实现采集https开头的网页链接

版权声明:文章图片资源来源于网络,如有侵权,请留言删除!!!
admin
  • 本文由 发表于 2021年9月29日 17:47:01
  • 转载请务必保留本文链接:https://www.58pxe.com/7828.html
匿名

发表评论

匿名网友 填写信息

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