Imperial CMS remote image localization is a very important function. It is often used even if you do not need to collect daily updates. We sometimes find that this function does not take effect. What are the common reasons why it does not take effect?
Reasons why the remote image localization of Empire CMS does not take effect
1. Image format and size setting issues
The default image format of Empire does not include png, but our current QQ screenshots and so on are all in png image format, just add it. If the image format of the source site does not exist in the Empire backend, it will definitely not be saved.
System parameter settings - file settings - file extension
At the same time, set the size of the images that can be uploaded.
2. Server configuration issues
You need to set allow_url_fopen to on in php.in
3. Storage timeout 502 problem
This may occur when there are a large number of pictures. Set the PHP execution time to be longer. The default is 60s. Change it to a few minutes.
4. The source site image link is https
A new website built with Imperial CMS7.5. When publishing an article, I checked "Remotely save images" under the editor, but it had no effect. There was no normal remote download to the server, and the absolute address of the image in the editor did not become the corresponding relative address.
After inspection, it turns out that the current site is http, and the image address to be downloaded remotely is https. If the image address is changed to the http protocol, the remote download can be normal. After checking on the official forum of Empire CMS, some netizens suggested that saving images remotely does not support https and requires PHP to enable the SSL module.
Open the file /e/class/connect.php:
Step 1: At the top of the connect.php file, add the following function below <?php:
function getHTTPS($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}Step 2: Search for function ReadFiletext and find the following function:
function ReadFiletext($filepath){
$filepath=trim($filepath);
$htmlfp=@fopen($filepath,"r");
//远程
if(strstr($filepath,"://"))
{
while($data=@fread($htmlfp,500000))
{
$string.=$data;
}
}
//本地
else
{
$string=@fread($htmlfp,@filesize($filepath));
}
@fclose($htmlfp);
return $string;
}Replace with the following code:
function ReadFiletext($filepath){
$filepath=trim($filepath);
$htmlfp=@fopen($filepath,"r");
//远程
if(strstr($filepath,"https://")){
return getHTTPS($filepath);
}
if(strstr($filepath,"://"))
{
while($data=@fread($htmlfp,500000))
{
$string.=$data;
}
}
//本地
else
{
$string=@fread($htmlfp,@filesize($filepath));
}
@fclose($htmlfp);
return $string;
}