织梦dede开启多站点后上传图片路径出错 临时解决办法

做大站,或者做站群的进修都可能需要用到织梦DEDECMS的多站点功能,但是织梦DEDECMS的这个功能还有一些问题,比如说图片路径问题,默认图片上传是用的相对路径,启用多站点后,图片路径就不对了。

这时我今天搞了半天找到一个临时决办法,还不能确定是否带来新的问题,希望大家提出宝贵意见。
 

1、打开/include/dialog/select_images_post.php 把

$inquery = "INSERT INTO `idea_uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)

  VALUES ('0','$filename','".$activepath."/".$filename."','1','$imgwidthValue','$imgheightValue','0','{$imgsize}','{$nowtme}','".$cuserLogin->getUserID()."'); ";

$dsql->ExecuteNoneQuery($inquery);

$fid = $dsql->GetLastID();

AddMyAddon($fid, $activepath.'/'.$filename);

$CKUpload = isset($CKUpload)? $CKUpload : FALSE;

if ($GLOBALS['cfg_html_editor']=='ckeditor' && $CKUpload)

{

    $fileurl = $activepath.'/'.$filename;

    $message = '';

    

    $str='<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction('.$CKEditorFuncNum.', \''.$fileurl.'\', \''.$message.'\');</script>';

    exit($str);

}

修改成

if($cfg_multi_site=='Y')

{

if(empty($cfg_basehost)) $cfg_basehost = ''.$_SERVER["HTTP_HOST"];

$activepath2 = $cfg_basehost.$activepath;

} else {

$activepath2 = $activepath;

}

 

$inquery = "INSERT INTO `idea_uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)

  VALUES ('0','$filename','".$activepath2."/".$filename."','1','$imgwidthValue','$imgheightValue','0','{$imgsize}','{$nowtme}','".$cuserLogin->getUserID()."'); ";

$dsql->ExecuteNoneQuery($inquery);

$fid = $dsql->GetLastID();

AddMyAddon($fid, $activepath2.'/'.$filename);

$CKUpload = isset($CKUpload)? $CKUpload : FALSE;

if ($GLOBALS['cfg_html_editor']=='ckeditor' && $CKUpload)

{

    $fileurl = $activepath2.'/'.$filename;

    $message = '';

    

    $str='<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction('.$CKEditorFuncNum.', \''.$fileurl.'\', \''.$message.'\');</script>';

    exit($str);

}

这是为了决CKEditor 上传图片的时候返回绝对路径

2、打开/include/dialog/select_images.php 把

$activeurl = '..'.$activepath;

改成

$activeurl = $activepath;

把两处的 

$reurl = "$activeurl/$file";

改成

if($cfg_multi_site=='Y')

{

if(empty($cfg_basehost)) $cfg_basehost = ''.$_SERVER["HTTP_HOST"];

$reurl = $cfg_basehost."$activeurl/$file";

} else {

$reurl = "$activeurl/$file";

}

这是为了解决图片浏览器 上传图片的时候返回绝对路径

3、打开/dede/media_add.pp 找到最下面的这段代码

$inquery = "INSERT INTO `idea_uploads`(title,url,mediatype,width,height,playtime,filesize,uptime,mid)

       VALUES ('$ntitle','$filename','$mediatype','$width','$height','$playtime','$filesize','$uptime','$adminid'); ";

在其上方添加

if($cfg_multi_site=='Y')

{

if(empty($cfg_basehost)) $cfg_basehost = ''.$_SERVER["HTTP_HOST"];

$filename = $cfg_basehost.$filename;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/225a7b9d761579f91ec5f453caf44221.html