(1)打开phpcmsmodulescollectionclassescollection.class.php
在类里边添加新函数:
- protected static function curl_request($url){
- if (!function_exists('curl_init')) {
- throw new Exception('server not install curl');
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_HEADER,0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//禁止调用时就输出获取到的数据
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
(2)找到函数function get_htm把该函数
改成
- protected static function get_html($url, &$config) {
- if (!empty($url) && $html = @file_get_contents($url)) {
- if ($syscharset != $config['sourcecharset'] && $config['sourcetype'] != 4) {
- $html = iconv($config['sourcecharset'], CHARSET.'//TRANSLIT//IGNORE', $html);
- }
- return $html;
- } else {
- return false;
- }
- }
然后保存即可获取,测试结果
- protected static function get_html($url, &$config) {
- if(substr(trim($url),0, 5) == "https"){
$html = @self::curl_request($url);}else{$html = @file_get_contents($url);}- if (!empty($url) && $html) {
- if ($syscharset != $config['sourcecharset'] && $config['sourcetype'] != 4) {
- $html = iconv($config['sourcecharset'], CHARSET.'//TRANSLIT//IGNORE', $html);
- }
- return $html;
- } else {
- return false;
- }
- }

不知道是否还有其他bug,欢迎留言反馈!
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, LeCMS, ClassCMS, Fastadmin, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。