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

    <?
(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
!checkapermission(39) && amessage(lang('no_apermission'));
if($sid && $sid_self) amessage(lang('msite admin item !'));
load_cache('localfiles');
$ftypearr = array(
				'image' => lang('image'),
				'flash' => lang('flash'),
				'media' => lang('media'),
				'file' => lang('download'),
				);
if($action == 'localfilesedit'){
	a_guide('localfilesedit');
	tabheader(lang('local upload project'),'','','5');
	trcategory(array(lang('sn'),lang('attachment type'),lang('all attachment type'),lang('allow upload type'),lang('setting')));
	$no = 0;
	foreach($localfiles as $k => $localfile){
		$extnames = $localnames = '';
		foreach($localfile as $ext => $v){
			$extnames .= $ext.'&nbsp;&nbsp;';
			!empty($v['islocal']) && $localnames .= $ext.'&nbsp;&nbsp;';
		}
		$no ++;
		echo "<tr>".
			"<td class=\"item1\" width=\"30\" align=\"center\">$no</td>\n".
			"<td class=\"item2\" width=\"60\" align=\"center\">$ftypearr[$k]</td>\n".
			"<td class=\"item1\">$extnames</td>\n".
			"<td class=\"item2\">$localnames</td>\n".
			"<td class=\"item1\" width=\"40\" align=\"center\"><a href=\"?entry=localfiles&action=localfiledetail&ftype=$k\">".lang('detail')."</a></td></tr>\n";
	}
	tabfooter();
}
elseif($action == 'localfiledetail' && $ftype){
	$localfile = $localfiles[$ftype];
	if(!submitcheck('bfilesedit') && !submitcheck('bfilesadd')){
		a_guide('localfiledetail');
		tabheader(lang('local upload file type').'&nbsp;-&nbsp; '.$ftypearr[$ftype],'filesedit',"?entry=localfiles&action=localfiledetail&ftype=$ftype",'6');
		trcategory(array('<input class="checkbox" type="checkbox" name="chkall" onclick="checkall(this.form,\'delete\')">'.lang('del'),lang('file ext'),lang('all attachment type'),lang('allow local upload'),lang('max upload limited').'(K)',lang('mini upload limited').'(K)'));
		foreach($localfile 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\">$k</td>\n".
				"<td class=\"item1\" width=\"100\">$ftypearr[$ftype]</td>\n".
				"<td class=\"item2\" width=\"100\"><input class=\"checkbox\" type=\"checkbox\" name=\"rmfilesnew[$k][islocal]\" value=\"1\"".(empty($rmfile['islocal']) ? "" : " checked").">\n".
				"<td class=\"item1\" width=\"100\"><input type=\"text\" size=\"10\" name=\"rmfilesnew[$k][maxsize]\" value=\"$rmfile[maxsize]\"></td>\n".
				"<td class=\"item2\" width=\"100\"><input type=\"text\" size=\"10\" name=\"rmfilesnew[$k][minisize]\" value=\"$rmfile[minisize]\"></td></tr>\n";
		}
		tabfooter('bfilesedit');

		tabheader(lang('add file type'),'filesadd',"?entry=localfiles&action=localfiledetail&ftype=$ftype");
		trbasic(lang('file type ( input ext , commadivide )'),'extnamestr');
		tabfooter('bfilesadd',lang('add'));

	}elseif(submitcheck('bfilesadd')){
		$extnames = array_unique(array_filter(explode(',',strtolower($extnamestr))));
		if($extnames){
			foreach($extnames as $extname){
				if(preg_match("/[^a-zA-Z0-9]+/",$extname) || in_array($extname,array_keys($localfile))) continue;
				$db->query("INSERT INTO {$tblprefix}localfiles SET ftype='$ftype',extname='$extname'");
			}
			updatecache('localfiles');
		}
		adminlog(lang('edit local upload project'),lang('add file type'));
		amessage(lang('file type add finish'),"?entry=localfiles&action=localfiledetail&ftype=$ftype");
	}elseif(submitcheck('bfilesedit')){
		if(!empty($delete)){
			foreach($delete as $id) {
				$db->query("DELETE FROM {$tblprefix}localfiles WHERE extname='$id'");
				unset($rmfilesnew[$id]);
			}
		}
		if(!empty($rmfilesnew)){
			foreach($rmfilesnew as $id => $rmfilenew) {
				$rmfilenew['islocal'] = empty($rmfilenew['islocal']) ? 0 : $rmfilenew['islocal'];
				$rmfilenew['maxsize'] = max(0,intval($rmfilenew['maxsize']));
				$rmfilenew['minisize'] = max(0,intval($rmfilenew['minisize']));
				$db->query("UPDATE {$tblprefix}localfiles SET 
						islocal='$rmfilenew[islocal]',
						maxsize='$rmfilenew[maxsize]',
						minisize='$rmfilenew[minisize]'
						WHERE extname='$id'");
			}
		}
		updatecache('localfiles');
		adminlog(lang('edit local upload project'),lang('modify file type'));
		amessage(lang('file type edit finish'),"?entry=localfiles&action=localfiledetail&ftype=$ftype");
	}
}
?>