去评论
dz插件网

修复Discuz开启远程附件后,DIY缩略图路径错误的BUG

admin
2020/07/08 10:09:42
当Discuz开启FTP远程附件(或者其他插件远程附件后),DIY的缩略图被上传到远程空间后,Discuz没有把缩略图同步标记为远程状态,仍然调用本地连接,导致缩略图无法显示,手动更新DIY缓存可正常,但每次都手动去更新不现实,1314学习网给出修复此BUG的解决办法:
打开:source\function\function_block.php
1.找到
  1. if($blockitem['picflag'] == '1') {  $replacevalue = $_G['setting']['attachurl'].$replacevalue; } elseif ($blockitem['picflag'] == '2') {  $replacevalue = $_G['setting']['ftp']['attachurl'].$replacevalue;}
修改为
  1. if ($blockitem['picflag'] == '2') {        $replacevalue = (preg_match('/^https?:\/\//is', $replacevalue) ? '' : $_G['setting']['ftp']['attachurl']).$replacevalue;} else {        if(file_exists($_G['setting']['attachdir'].$replacevalue)) {                $replacevalue = $_G['setting']['attachurl'].$replacevalue;        }else{                $replacevalue = (preg_match('/^https?:\/\//is', $replacevalue) ? '' : $_G['setting']['ftp']['attachurl']).$replacevalue;        }}
2.找到
  1. if($blockitem['picflag'] == '1') {        $replacevalue = $_G['setting']['attachurl'].$blockitem['thumbpath'];} elseif ($blockitem['picflag'] == '2') {        $replacevalue = $_G['setting']['ftp']['attachurl'].$blockitem['thumbpath'];}
修改为
  1. if ($blockitem['picflag'] == '2') {        $replacevalue = (preg_match('/^https?:\/\//is', $blockitem['thumbpath']) ? '' : $_G['setting']['ftp']['attachurl']).$blockitem['thumbpath'];}else{        if(file_exists($_G['setting']['attachdir'].$blockitem['thumbpath'])) {                $replacevalue = $_G['setting']['attachurl'].$blockitem['thumbpath'];        }else{                $replacevalue = (preg_match('/^https?:\/\//is', $blockitem['thumbpath']) ? '' : $_G['setting']['ftp']['attachurl']).$blockitem['thumbpath'];        }}
3.找到
  1. @unlink($_G['setting']['attachdir'].'./'.$thumbpath);
在下边添加:
  1. C::t('common_block_item')->update($itemid, array('picflag' => 2));$replacevalue = (preg_match('/^https?:\/\//is', $thumbpath) ? '' : $_G['setting']['ftp']['attachurl']).$thumbpath;
修改后更新下对应的页面的DIY缓存,以便实时生效


X3.4已改好文件下载
function_block.zip(9.72 KB, 下载次数: 0)<div class="tip tip_4" id="attach_31970_menu" style="position: absolute; display: none" disautofocus="true"><div class="tip_c xs0">2020-6-24 22:05 上传
点击文件名下载附件