www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/admina/rprojects.inc.php

    <?
(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
!checkapermission(40) && amessage(lang('no_apermission'));
if($sid && $sid_self) amessage(lang('msite admin item !'));
load_cache('rprojects,channels');
if($action == 'rprojectedit'){
	if(!submitcheck('brprojectadd') && !submitcheck('brprojectedit')){
		a_guide('rprojectedit');
		tabheader(lang('remote project manager'),'rprojectedit','?entry=rprojects&action=rprojectedit','5');
		trcategory(array(lang('delete'),lang('project cname'),lang('project type'),lang('file type ext'),lang('edit')));
		foreach($rprojects as $k => $rproject){
			$extnames = implode('&nbsp;&nbsp;',array_keys($rproject['rmfiles']));
			$rproject['issystemstr'] = empty($rproject['issystem']) ? lang('iscustom') : lang('system');
			echo "<tr>".
				"<td class=\"item1\" width=\"40\" align=\"center\"><input class=\"checkbox\" type=\"checkbox\" name=\"delete[$k]\" value=\"$k\"".(!empty($rproject['issystem']) ? ' disabled' : '').">\n".
				"<td class=\"item2\" width=\"200\" align=\"center\"><input type=\"text\" size=\"30\" name=\"rprojectsnew[$k][cname]\" value=\"$rproject[cname]\"".(!empty($rproject['issystem']) ? " unselectable=\"on\"" : "")."></td>\n".
				"<td class=\"item1\" width=\"80\" align=\"center\">$rproject[issystemstr]</td>\n".
				"<td class=\"item2\">$extnames</td>\n".
				"<td class=\"item1\" width=\"40\" align=\"center\"><a href=\"?entry=rprojects&action=rprojectdetail&rpid=$k\">".lang('detail')."</a></td></tr>\n";
		}

		tabfooter('brprojectedit',lang('modify'));
		tabheader(lang('add remote project'),'rprojectadd','?entry=rprojects&action=rprojectedit');
		trbasic(lang('project cname'),'rprojectadd[cname]');
		tabfooter('brprojectadd',lang('add'));
	}
	elseif(submitcheck('brprojectedit')) {
		if(!empty($delete)){
			foreach($delete as $k){
				$db->query("DELETE FROM {$tblprefix}rprojects WHERE rpid=$k");
				unset($rprojectsnew[$k]);
			}
		}
		foreach($rprojectsnew as $k => $rprojectnew){
			if(empty($rprojects[$k]['issystem'])){
				$rprojectnew['cname'] = empty($rprojectnew['cname']) ? $rprojects[$k]['cname'] : $rprojectnew['cname'];
				$db->query("UPDATE {$tblprefix}rprojects SET cname='$rprojectnew[cname]' WHERE rpid=$k");
			}
		}
		updatecache('rprojects');
		adminlog(lang('edit remote upload project'),lang('edit project list'));
		amessage(lang('project modify finish'), '?entry=rprojects&action=rprojectedit');
	}
	elseif(submitcheck('brprojectadd')) {
		if(!$rprojectadd['cname']) {
			amessage(lang('project data missiong'), '?entry=rprojects&action=rprojectedit');
		}
		$db->query("INSERT INTO {$tblprefix}rprojects SET cname='$rprojectadd[cname]'");
		updatecache('rprojects');
		adminlog(lang('add remote upload project'),lang('add remote upload project'));
		amessage(lang('project add finish'), '?entry=rprojects&action=rprojectedit');
	}
}
if($action =='rprojectdetail' && $rpid){
	$rmfiles = $rprojects[$rpid]['rmfiles'];
	$excludes = implode("\n",$rprojects[$rpid]['excludes']);
	$timeout = empty($rprojects[$rpid]['timeout']) ? 0 : intval($rprojects[$rpid]['timeout']);
	if(!submitcheck('bfilesedit') && !submitcheck('bfilesadd')){
		a_guide('rprojectdetail');
		tabheader(lang('remote download file type').'&nbsp; - &nbsp;'.$rprojects[$rpid]['cname'],'filesedit',"?entry=rprojects&action=rprojectdetail&rpid=$rpid",6);
		trcategory(array('<input class="checkbox" type="checkbox" name="chkall" onclick="checkall(this.form)">'.lang('del'),lang('file ext'),lang('max limited').'(K)',lang('mini limited').'(K)','MIME'.lang('type'),lang('save coclass')));
		$ftypearr = array(
						'image' => lang('image'),
						'flash' => lang('flash'),
						'media' => lang('media'),
						'file' => lang('other'),
		);
		foreach($rmfiles as $k => $rmfile) {
			echo "<tr align=\"center\">".
				"<td class=\"item1\" width=\"40\"><input class=\"checkbox\" type=\"checkbox\" name=\"delete[$k]\" value=\"$k\">\n".
				"<td class=\"item2\">$rmfile[extname]</td>\n".
				"<td class=\"item1\" width=\"100\"><input type=\"text\" size=\"6\" name=\"rmfilesnew[$k][maxsize]\" value=\"$rmfile[maxsize]\"></td>\n".
				"<td class=\"item2\" width=\"100\"><input type=\"text\" size=\"6\" name=\"rmfilesnew[$k][minisize]\" value=\"$rmfile[minisize]\"></td>\n".
				"<td class=\"item1\" width=\"200\"><input type=\"text\" size=\"25\" name=\"rmfilesnew[$k][mime]\" value=\"$rmfile[mime]\"></td>\n".
				"<td class=\"item2\" width=\"50\"><select name=\"rmfilesnew[$k][ftype]\">".makeoption($ftypearr,$rmfile['ftype'])."</select></td></tr>\n";
		}
		tabfooter();
		tabheader(lang('other setting').'&nbsp; - &nbsp;'.$rprojects[$rpid]['cname']);
		trbasic(lang('down_timeout'),'timeoutnew',$timeout,'text',lang('agnolimit'));
		trbasic(lang('excludestxt'),'excludesnew',$excludes,'textarea',lang('agexcludes'));
		tabfooter('bfilesedit');

		tabheader(lang('add file type'),'filesadd',"?entry=rprojects&action=rprojectdetail&rpid=$rpid",2,0,1);
		trbasic(lang('file ext'),'rmfileadd[extname]');
		trbasic(lang('file save coclass'),'rmfileadd[ftype]',makeoption($ftypearr),'select');
		tabfooter('bfilesadd',lang('add'));
		$submitstr = '';
		$submitstr .= makesubmitstr('rmfileadd[extname]',1,'numberletter',0,10);
		check_submit_func($submitstr);

	}elseif(submitcheck('bfilesadd')){
		$rmfileadd['extname'] = trim(strtolower($rmfileadd['extname']));
		$rmfileadd['mime'] = '';
		if(!$rmfileadd['extname']){
			amessage(lang('data missing'), '?entry=rprojects&action=rprojectdetail&rpid='.$rpid);
		}
		if(preg_match("/[^a-zA-Z0-9]+/",$rmfileadd['extname'])) {
			amessage(lang('file ext illegal'),'?entry=rprojects&action=rprojectdetail&rpid='.$rpid);
		}
		if(in_array($rmfileadd['extname'],array_keys($rmfiles))) {
			amessage(lang('file ext repeat'),'?entry=rprojects&action=rprojectdetail&rpid='.$rpid);
		}
		$rmfileadd['maxsize'] = 0;
		$rmfileadd['minisize'] = 0;
		$rmfiles[$rmfileadd['extname']] = $rmfileadd;
		$rmfiles = addslashes(serialize($rmfiles));
		$db->query("UPDATE {$tblprefix}rprojects SET rmfiles='$rmfiles' WHERE rpid='$rpid'");
		updatecache('rprojects');
		adminlog(lang('edit remote upload project'),lang('add remote upload project file type'));
		amessage(lang('file type add finish'),'?entry=rprojects&action=rprojectdetail&rpid='.$rpid);
	}elseif(submitcheck('bfilesedit')){
		if(isset($delete)){
			foreach($delete as $id) {
				unset($rmfilesnew[$id]);
			}
		}
		if(!empty($rmfilesnew)){
			foreach($rmfilesnew as $id => $rmfilenew) {
				$rmfilenew['extname'] = $rmfiles[$id]['extname'];
				$rmfilenew['mime'] = trim(strtolower($rmfilenew['mime']));
				$rmfilenew['maxsize'] = max(0,intval($rmfilenew['maxsize']));
				$rmfilenew['minisize'] = max(0,intval($rmfilenew['minisize']));
				$rmfilesnew[$id] = $rmfilenew;
			}
			$rmfilesnew = addslashes(serialize($rmfilesnew));
		}else{
			$rmfilesnew = '';
		}	
		if(!empty($excludesnew)){
			$excludesnew = str_replace(array("\r","\n"),',',$excludesnew);
			$excludesarr = array_filter(explode(',',$excludesnew));
			$excludesnew = implode(',',$excludesarr);
		}else $excludesnew = '';
		$timeoutnew = max(0,intval($timeoutnew));
		$db->query("UPDATE {$tblprefix}rprojects SET 
			rmfiles='$rmfilesnew',
			timeout='$timeoutnew',
			excludes='$excludesnew' 
			WHERE rpid='$rpid'");
		updatecache('rprojects');
		adminlog(lang('edit remote upload project'),lang('detail0 modify remote upload project'));
		amessage(lang('remote project edit finish'),'?entry=rprojects&action=rprojectdetail&rpid='.$rpid);
	}
}
?>