帝国CMS7.5版本远程保存图片会存在一个问题,就是传上去的图片没有任何后缀,这个问题相信很多人都遇到了,而且束手无策,今天我就来讲下解决帝国CMS7.5远程保存图片没有后缀的解决方法。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
帝国CMS7.0,在路径 e/class/functions.PHP中修改e/class/functions.php大概第1455行和1456行,代码如下:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(\.jpg|\.JPG|\.gif|\.GIF|\.png|\.PNG|\.bmp|\.BMP|\.jpeg|\.JPEG)(.*?)>/is"; $text=preg_replace($zz1,"<\\1 \\2\\3=\\4".$exp1."\\5\\6".$exp2."\\7>",$text);
修改成下面的样子:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)([^'|\"|\\\\\"|]*)('|\"|\\\\\"|)(.*?)>/is"; $text=preg_replace($zz1,"<\\1 \\2\\3=\\4".$exp1."\\5".$exp2."\\6\\7>",$text);
然后在修改 e/class/connect.php 的大概2862行文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$r[filetype]=GetFiletype($url);
在这句话的后面加入如下代码:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
if ((strlen($r[filetype]) !==4 ) OR (strlen($r[filetype]) !==5 )) $r[filetype]=".jpg";
修改完后不影响原来正常的使用,也就是普通形式的图片,和不带扩展名形式的图片都能够正确的远程保存下来。 帝国CMS7.2和7.5需要替换e/class/functions.php中的两个位置,
第一个位置:e/class/functions.php
//替换图片标签文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
function RepImg($text,$copyflash){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
global $ecms_config;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$exp1="";文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$exp2="";文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//去掉图片链接文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
if($ecms_config['sets']['saveurlimgclearurl']==1)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
{文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$zz2="/\<(a|A) (.*?)(href|Href)=('|\"|\\\\\"|)(.+?)><(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(\.jpg|\.JPG|\.gif|\.GIF|\.png|\.PNG|\.bmp|\.BMP|\.jpeg|\.JPEG)(.*?)><\/(a|A)>/is";文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$text=preg_replace($zz2,"<\\6 \\7\\8=\\9\\10\\11\\12>",$text);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(\.jpg|\.JPG|\.gif|\.GIF|\.png|\.PNG|\.bmp|\.BMP|\.jpeg|\.JPEG)(.*?)>/is";文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$text=preg_replace($zz1,"<\\1 \\2\\3=\\4".$exp1."\\5\\6".$exp2."\\7>",$text);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
return $text;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
第二个位置:替换位置2: 修改e/class/connect.php大概3119行文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//远程保存文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
function DoTranUrl($url,$classid){文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
global $public_r,$class_r,$ecms_config,$efileftp_fr;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$classid=(int)$classid;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//处理地址文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$url=trim($url);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$url=str_replace(" ","%20",$url);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$r[tran]=1;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//附件地址文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$r[url]=$url;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//文件类型文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$r[filetype]=GetFiletype($url);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
if(CheckSaveTranFiletype($r[filetype]))文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
{文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$r[tran]=0;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
return $r;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//是否已上传的文件文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$havetr=CheckNotSaveUrl($url);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
if($havetr)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
{文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
$r[tran]=0;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
return $r;文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html
//是否地址文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22860.html