huanayun
hengtianyun
vps567
莱卡云

ECshop 后台编辑器fckeditor上传文件按年月并非重命名的最新解决方法 -云主机博士

PikPak

推荐阅读:

[AI-人工智能]免翻墙的AI利器:樱桃茶·智域GPT,让你轻松使用ChatGPT和Midjourney - 免费AIGC工具 - 拼车/合租账号 八折优惠码: AIGCJOEDISCOUNT2024

[AI-人工智能]银河录像局: 国内可靠的AI工具与流媒体的合租平台 高效省钱、现号秒发、翻车赔偿、无限续费|95折优惠码: AIGCJOE

[AI-人工智能]免梯免翻墙-ChatGPT拼车站月卡 | 可用GPT4/GPT4o/o1-preview | 会话隔离 | 全网最低价独享体验ChatGPT/Claude会员服务

[AI-人工智能]边界AICHAT - 超级永久终身会员激活 史诗级神器,口碑炸裂!300万人都在用的AI平台

ecshop是套非常好的网店系统,fckeditor也是个不错的html编辑器,常用于各种cms及商城系统实现在纺编辑html代码,然后ecshop使用的fckeditor在上传图片和其它文件时是没有按目录存放的,我们很多人都习惯上传的文件按年和月这样的日期存放这样不至于上传文件夹存放的内容太多太杂,影响系统的稳定性,同时上传的文件也没有进行重命名,当我们上传中文文件名的文件时有些时候会出错,下面我们就来实现:
一、ecshop的fckeditor上传文件时按年和日存放,假如我们是2012年3月存放的,系统会自动建一个文件夹201207,方法
打开includes/fckeditor/editor/filemanager/connectors/php/config.php,找到:
修改前的代码:
// Path to user files relative to the document root.
Config['UserFilesPath'] =Config[′UserFilesPath′]=root_path . IMAGE_DIR . '/upload/';

// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = ROOT_PATH . IMAGE_DIR . '/upload/' ;
修改后的代码:
// Path to user files relative to the document root.
Config['UserFilesPath'] =Config[′UserFilesPath′]=root_path . IMAGE_DIR . '/upload/'.date('Ym').'/';

// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = ROOT_PATH . IMAGE_DIR . '/upload/'.date('Ym').'/';
然后保存,非常简单,仅是在这两行后面增加了  .date('Ym').'/'
、ecshop的fckeditor上传文件时自动重命名,方法:
找到文件:includes/fckeditor/editor/filemanager/connectors/php/io.php,找到
修改前的代码:
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: … )
{
    globalConfig ;

    sNewFileName = stripslashes(sNewFileName=stripslashes(sNewFileName ) ;

    // Replace dots in the name with underscores (only one dot can be there... security issue).
    if ( Config['ForceSingleExtension'] )Config[′ForceSingleExtension′])sNewFileName = preg_replace( '/\\.(?![^.]*ParseError: KaTeX parse error: Expected group after '_' at position 7: )/', '_̲',sNewFileName ) ;

    // Remove \ / | : ? * " < >
    ParseError: KaTeX parse error: Expected group after '_' at position 79: …[:cntrl:]]/', '_̲',sNewFileName ) ;

    return $sNewFileName ;
}
修改后的代码:
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: … )
{
    globalConfig ;

    sNewFileName = stripslashes(sNewFileName=stripslashes(sNewFileName ) ;

    // Replace dots in the name with underscores (only one dot can be there... security issue).
    if ( Config['ForceSingleExtension'] )Config[′ForceSingleExtension′])sNewFileName = preg_replace( '/\\.(?![^.]*ParseError: KaTeX parse error: Expected group after '_' at position 7: )/', '_̲',sNewFileName ) ;

    // Remove \ / | : ? * " < >
    //ParseError: KaTeX parse error: Expected group after '_' at position 79: …[:cntrl:]]/', '_̲',sNewFileName ) ;
    sExtension = substr(sExtension=substr(sNewFileName, (strrpos(sNewFileName,'.') + 1 ) ) ;sNewFileName,′.′)+1));sNewFileName = date('YmdHis').rand(0,999).'.'.sExtension;
    returnsExtension;returnsNewFileName ;
}
就是把
$sNewFileName = preg_replace( '/\\|\/|\||\:|\?|\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ;

注释掉,新增加:

$sExtension = substr( $sNewFileName, (strrpos($sNewFileName,'.') + 1 ) ) ;
$sNewFileName = date('YmdHis').rand(0,999).'.'.$sExtension;
保存后,在ecshop的后台测试就会发现我们上传的图片按年月分目录保存并自动重命名了!
经测试ecshop V2.7.3 20120411版本还未失效的!

宝塔服务器面板,一键全能部署及管理,送你3188元礼包,点我领取

bwg Vultr justhost.asia racknerd hostkvm pesyun Pawns


本文标签属性:

ECshop:Ecshop起诉怎么办

fckeditor:fckeditor的内容如何进行大小限制

原文链接:,转发请注明来源!