织梦开启附件远程同步

系统-核心,开启远程站点和远程发布

让缩略图支持同步和加入附件服务器域名
1、打开 /dede/imagecut.php 找到
//对任意裁剪方式再次缩小图片至限定大小
if($newwidth > $cfg_ddimg_width || $newheight > $cfg_ddimg_height)
{
ImageResize($ddpicokurl, $cfg_ddimg_width, $cfg_ddimg_height);
}
在下面加入
if($cfg_remote_site=='Y' && $remoteuploads == 1)
{
//启用远程站点则创建FTP类
require_once(DEDEINC.'/ftp.class.php');
if(file_exists(DEDEDATA."/cache/inc_remote_config.php"))
{
require_once DEDEDATA."/cache/inc_remote_config.php";
}
if(empty($remoteuploads)) $remoteuploads = 0;
if(empty($remoteupUrl)) $remoteupUrl = '';
//初始化FTP配置
$ftpconfig = array(
'hostname'=>$rmhost,
'port'=>$rmport,
'username'=>$rmname,
'password'=>$rmpwd
);
$ftp = new FTP;
$ftp->connect($ftpconfig);
//分析远程文件路径
$remotefile = str_replace(DEDEROOT, '', $ddpicokurl);
$localfile = '..'.$remotefile;
//创建远程文件夹
$remotedir = preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/', '', $remotefile);
$ftp->rmkdir($remotedir);
$ftp->upload($localfile, $remotefile);
}