最新公告
  • 欢迎您光临站盟网(原知事网),一个优质的网站源码基地、精品网站模板和插件。欢迎加入永久SVIP
  • 使用帝国CMS模板程序一般都是做大型网站,所以需要存储的附件比较多,这样的情况下就需要分离附件了,方便网站维护和管理。比如网站的附件图片可以分离到阿里云OSS上,速度快,安全性高。现在很多网站都会使用这种存储方案,这里开发的插件就是为了配合帝国CMS对接阿里云OSS实现网站附件分离,也就是远程调用附件的功能了,需要其他类型的网站插件,可以前往帝国CMS插件专区。

    推荐:帝国cms阿里云OSS插件PRo版

    插件介绍

    1、帝国cms附件在后台和前台用户的所有操作中可以与阿里云oss同步上传;

    2、支持火车头发布时自动上传到阿里云OSS;

    环境要求

    php版本5.3以上,且安装了Curl 扩展;

    安装步骤

    1.上传liuge_aliyunoss.zip到e目录,然后解压;

    2.浏览器访问HTTP://www.xxx.com/e/liuge/aliyunoss/install安装;

    3.安装完后在插件设置里配置好对应的参数;

    accessKeyId和accessKeySecret在 https://ak-console.aliyun.com/?spm=5176.8465980.quick-entry-bucket.d2.43d99720yWGk0Z#/accesskey 里面新建即可;

    endpoint在 https://oss.console.aliyun.com/overview 查看;

    bucket 自己新建一个即可。

    配置步骤

    1.打开 e/class/connect.php

    找到

    if(!defined('EmpireCMSConfig'))
    {
    exit();
    }
    

    在下面增加

    //阿里云上传
    require_once(ECMS_PATH.'e/liuge/aliyunoss/autoload.php');
    use OSSOssClient;
    use OSSCoreOssException;
    function aliup($filename,$img){
    global $accessKeyId,$accessKeySecret,$endpoint,$bucket;
    $object = $filename;
    $content = $img;
    $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
    $content = $ossClient->putObject($bucket, $object, $content);
    return "";
    }
    //阿里云上传结束
    

    继续找到

    function DoTranFile($file,$file_name,$file_type,$file_size,$classid,$ecms=0){
    

    global $public_r,$class_r,$doetran,$efileftp_fr;
    

    替换为

    global $public_r,$class_r,$doetran,$efileftp_fr,$ossoff,$endpoint,$bucket,$alihttp;
    

    继续在下面找到

    //FileServer
    if($public_r['openfileserver'])
    {
    $efileftp_fr[]=$r['yname'];
    }
    return $r;
    

    在上面增加

    //开始存储到阿里云oss
    if($ossoff==1){
    $uri = $r["url"];
    if (file_exists($_SERVER["DOCUMENT_ROOT"].$uri)) {
    $string=ReadFiletext($_SERVER["DOCUMENT_ROOT"].$uri);
    $alfile=$fspath['filepath'].$filepath.$r[filename];
    aliup($alfile,$string);
    if($alihttp){
    $r[url]=$alihttp.$r[url];
    } else {
    $r[url]="http://".$bucket.".".$endpoint.$r[url];
    }
    }
    }
    

    然后继续查找

    //远程保存
    function DoTranUrl($url,$classid){
    

    把下面一行的

    global $public_r,$class_r,$ecms_config,$efileftp_fr;
    

    替换为

    global $public_r,$class_r,$ecms_config,$efileftp_fr,$ossoff,$endpoint,$bucket,$alihttp;
    

    继续找到

    $r[yname]=$r[savepath].$r[filename];
    

    在下面增加

    if($ossoff==1){
    $alfile=$fspath['filepath'].$filepath.$r[filename];
    aliup($alfile,$string);
    if($alihttp){
    $r[url]=$alihttp.$r[url];
    } else {
    $r[url]="http://".$bucket.".".$endpoint.$r[url];
    }
    }
    

    然后找到

    WriteFiletext_n($r[yname],$string);
    

    修改为

    if($ossoff==0){WriteFiletext_n($r[yname],$string)};
    

    2.打开/e/admin/ecmseditor/fileinc/editorpic.php

    找到

    if(!defined('InEmpireCMS'))
    {
    exit();
    }
    

    在下面加

    require_once(ECMS_PATH.'e/liuge/aliyunoss/config.php');
    

    继续找到

    $file=$fspath['fileurl'].$filepath.$r[filename];
    

    修改为

    if($ossoff==1){
    if($alihttp){
    $file=$alihttp.$fspath['fileurl'].$filepath.$r[filename];
    } else {
    $file="http://".$bucket.".".$endpoint.$fspath['fileurl'].$filepath.$r[filename];
    }
    }else{
    $file=$fspath['fileurl'].$filepath.$r[filename];
    }
    

    3.继续打开 e/class/functions.php

    在<?下面加

    require_once(ECMS_PATH.'e/liuge/aliyunoss/config.php');
    

    找到

    function GetFpicToTpic($classid,$id,$num=1,$getfirsttitlespic=0,$swidth=0,$sheight=0,$fstb=1){
    

    把下面的

    global $empire,$dbtbpre,$public_r,$class_r,$loginin,$logininid;
    

    修改为

    global $empire,$dbtbpre,$public_r,$class_r,$loginin,$logininid,$ossoff,$endpoint,$bucket,$alihttp;
    

    继续找到

    return $firsttitlepic;
    

    在上面加

    if($ossoff==1){
    if($alihttp){
    $r[url]=$alihttp.$firsttitlepic;
    } else {
    $r[url]="http://".$bucket.".".$endpoint.$firsttitlepic;
    }
    }
    

    4.新增 如果是帝国cms7.5 安装了多图上传功能 再按下面的进行修改

    打开 /e/admin/ecmseditor/tranmore/tranmorefun.php

    找到

    global $empire,$dbtbpre,$public_r,$ecms_config;
    

    替换为

    global $empire,$dbtbpre,$public_r,$ecms_config,$ossoff,$endpoint,$bucket,$alihttp;
    

    继续找到

    $tranmore_picr[$i]['picname']=stripSlashes($fileno);
    

    在下面加

    if($ossoff==1){
    if($alihttp){
    $tranmore_picr[$i]['bigpicurl']=$alihttp.$tranmore_picr[$i]['bigpicurl'];
    if($tranmore_picr[$i]['smallpicurl']){
    $tranmore_picr[$i]['smallpicurl']=$alihttp.$tranmore_picr[$i]['smallpicurl'];
    }
    } else {
    $tranmore_picr[$i]['bigpicurl']="http://".$bucket.".".$endpoint.$tranmore_picr[$i]['bigpicurl'];
    if($tranmore_picr[$i]['smallpicurl']){
    $tranmore_picr[$i]['smallpicurl']="http://".$bucket.".".$endpoint.$tranmore_picr[$i]['smallpicurl'];
    }
    }
    }
    

    按照以上的步骤修改完成后就可以用了。

    插件界面截图

    帝国CMS同类插件:帝国cms7.5七牛云存储插件下载 附件自动同步到七牛云

    猜你喜欢

    猜你在找

    站盟网,一个优质的源码资源平台!
    站盟网 » 帝国cms阿里云OSS远程附件插件 支持7.2/7.5附件分离

    发表评论

    还没有评论,快来抢沙发吧!

    如需帝国cms功能定制以及二次开发请联系我们

    联系作者
    热门文章
    请选择支付方式
    ×
    支付宝支付
    微信支付
    余额支付
    ×
    微信扫码支付 0 元