dedecms突击收费,这样远程发布功能就香了起来,而远程发布中除了前人总结的坑,在调试中还发现了一些新坑,比如,提示无法创建目录,无法上传,是否同步远程发布中不显示FTP站点,总结出来,供参考。
1.使用阿里云linux云虚拟主机做为远程站点发布提示无法创建目录和无法上传文件是因为程序是在站点根目录创建文件夹,而linux的站点根目录是/htdocs,程序是要在/创建,而ftp根目录下是不能创建目录的,所以要修改archives_add.php,archives_edit.等相关的文件中的目录位置,主要集中在这两个文件arc.listview.class.php,arc.archives.class.php中的function MakeHtml(),关联的就是ftp.class.php,修改如下:
//如果启用远程发布则需要进行判断
if($cfg_remote_site=='Y' && $isremote == 1)
{
//分析远程文件路径
$remotefile1 = str_replace(DEDEROOT, '', $TRUEfilename);
$remotefile = '/htdocs'.$remotefile1; //针对阿里云linux虚拟主机要目录为htdocs增加相应的上级目录,这样才不会提示无法创建目录。
$localfile = '..'.$remotefile1;
//创建远程文件夹
$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, 'ascii');
}
其他远程相关的修改与此类似。
2.远程时不显示配置好的ftp站点
经过排查,是因为config.php中的function GetFtp()中的$userlist中使用的是userid字段,而getUserName()获取的是username字段,当你在增加用户时如果userid和username不同,就会导致这里不能显示站点,需要修改为里的getusername获取的应当是userid。
if(strstr($userlist,$cuserLogin->getUserName())
{
$select.="<option value='".$servurl.",".$servuser.",".$servpwd."'{$checked}>".$servname."</option>";
}
用户少于10的情况下,最方便的方法就是将站点配置中的用户名改成id,就可以显示了,修改sys_multiserv.htm中的$adminList['userid']为$adminList['id'],用户较多还是使用userid字段合适
<tr>
<td height="7" align="right" style="line-height:28px;">管理员:</td>
<td height="7" align="left" style="line-height:28px;"> <select name="c_userlist" size="3" multiple id="c_userlist">
<?php foreach ($adminLists as $adminList) { ?>
<option value="<?php echo $adminList['id'];?>"><?php echo $adminList['uname'];?> | <?php echo $adminList['typename'];?></option>
<?php }?>
</select>
<br/>(多选)</td>
</tr>
。