phpcms分布式站群解决无法帮定子目录的FTP空间

/ 0评 / 0

Sandy在做站群的群下发现一个郁闷的问题,在DA下无法绑定子目录。而PHPCMSV9发布是发到子目录的。一下郁闷了!幸亏找到这个文章,大家分享一下!

第一步:修改 phpcms/modules/admin/templates/site_add.tpl.php 找到

<legend><?php echo L('release_point_configuration')?></legend>

大约在64行的位置
将他下面的整个table 替换成如下代码

<table width="100%">
<tr>
<th width="80" valign="top"><?php echo L('release_point')?>:</th>
<td> <select name="release_point[]" size="3" id="release_point" multiple title="<?php echo L('ctrl_more_selected')?>" onchange="if($(this).val() > 0){$('#ftp_top').show();}else{$('#ftp_top').hide();}">
<option value='' selected><?php echo L('not_use_the_publishers_some')?></option>
<?php if(is_array($release_point_list) && !empty($release_point_list)): foreach($release_point_list as $v):?>
<option value="<?php echo $v['id']?>"><?php echo $v['name']?></option>
<?php endforeach;endif;?>
</select> </td>

</tr>
<tr id="ftp_top" style="display:none" >
<th width="120" valign="top">发布到FTP根目录:</th>
<td><input type="radio" name="setting[ftp_top]" value="1" /> 是 <input type="radio" name="setting[ftp_top]" value="0" checked /> 否 <br />注:如果选择是 那么远程FTP将不会包含站点目录,适用于不能子目录绑定的FTP!!</td>
</tr>

</table>

第二步 :修改 phpcms/modules/admin/templates/site_edit.tpl.php 找到

<legend><?php echo L('release_point_configuration')?></legend>

大约在61行的位置

将他下面的整个table 替换成如下代码

<table width="100%">
<tr>
<th width="80" valign="top"><?php echo L('release_point')?>:</th>
<td> <select name="release_point[]" size="3" id="release_point" multiple title="<?php echo L('ctrl_more_selected')?>" onchange="if($(this).val() > 0){$('#ftp_top').show();}else{$('#ftp_top').hide();}">
<option value='' <?php if(!$data['release_point']) echo 'selected';?>><?php echo L('not_use_the_publishers_some')?></option>
<?php if(is_array($release_point_list) && !empty($release_point_list)): foreach($release_point_list as $v):?>
<option value="<?php echo $v['id']?>"<?php if(in_array($v['id'], explode(',',$data['release_point']))){echo ' selected';}?>><?php echo $v['name']?></option>
<?php endforeach;endif;?>
</select></td>
</tr>
<tr id="ftp_top" <?php echo $data['release_point'] ? '' : 'style="display:none"'?> >
<th width="120" valign="top">发布到FTP根目录:</th>
<td><input type="radio" name="setting[ftp_top]" value="1" <?php echo $setting['ftp_top'] ? 'checked' : '';?> /> 是 <input type="radio" name="setting[ftp_top]" value="0" <?php echo $setting['ftp_top'] ? '' : 'checked';?> /> 否 <br />注:如果选择是 那么远程FTP将不会包含站点目录,适用于不能子目录绑定的FTP!!</td>
</tr>

</table>

第三步: 修改  phpcms/modules/release/index.php

找到

foreach ($data as $v) {

..................................................

} else {

将整个foreach循环改成如下

if(strpos($this->site['setting'], "'ftp_top' => '1'"))$ftp_top = pc_base::load_config('system','html_root');
foreach ($data as $v) {
$status = -1;
$n_path = isset($ftp_top) ? preg_replace(array('|^'.$ftp_top.'/'.$this->site['dirname'].'/|iUs', '|^/'.$this->site['dirname'].'/|iUs'), '', $v['path']) : $v['path'];
switch ($v['type']) {
case 'del':
if ($ftps->f_delete($release_point['path'].$n_path)) {
$status = 1;
}
break;
case 'add':
case 'edit':
if ($ftps->put($release_point['path'].$n_path, PHPCMS_PATH.$v['path'])) {
$status = 1;
}
break;
}
$queue->update(array('status'.($id+1)=>$status, 'times'=>SYS_TIME), array('id'=>$v['id']));
}

 

发表评论

邮箱地址不会被公开。 必填项已用*标注