Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to solve the problem that the collection function of phpcms v9 can not be used

Shulou Source: shulou.com Published: 2022-06-02 05:45:22 09月26日 Update

This article mainly introduces how to solve the problem that the collection function of phpcms v9 can not be used. It is very detailed and has a certain reference value. Interested friends must finish reading it!

What if the collection function of phpcms v9 cannot be used?

The content of the website that cannot be collected by https is mainly because https does not support file_get_contents to obtain content, so you can consider using curl to obtain the content. (you need to enable curl, which can be viewed in pathinfo)

(1) Open phpcms\ modules\ collection\ classes\ collection.class.php

Add a new function to the class:

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) / / output the acquired data 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;} when the call is prohibited

(2) find the function function get_htm and change the function

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

Change to

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

Then save it and get the test results.

Do not know if there are any other bug, welcome to comment!

The above is all the content of how to solve the problem that the phpcms v9 collection function can not be used, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Content function function question value interest guy partner what to do data method more knowledge article results website industry information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia macOS Shulou Information Shulou Tech Info