<?php 
	if(!defined('IN_SYS'))exit('crack die');
	$task = $_GET['task'];
	$type = $_GET['type'];
	$type = empty($type)?'default':$type;
	$type = html_encode(strtolower($type));
	$tpl->assign('type',$type);
	$tem = array('default','flash','other','flv');
	if(!in_array($type,$tem))$type = 'default';
	switch ($task){
		case 'delete':
			$id = to_int($_GET['id']);
			if(empty($id))exit('crack die');
			$check = $db->fetch("select * from ##__core_file where `fid` = '$id' order by fid limit 0,1 ",TRUE);
			if(empty($check))exit($sp->bgmsg('无可用数据'));
			$file = $check['source_file'];
			@unlink(SYS_ROOT.$file);
			$db->query("delete from ##__core_file where `fid` = '$id'");
			exit($sp->bgmsg('操作成功','admincp.php?action=filemanager&type='.$type));
			break;
		default:
			$t = $db->fetch("select count(1) AS T from ##__core_file where `type` = '$type'  order by fid limit 0,1",TRUE);
			$total = $t['T'];
			$sql = "SELECT * FROM ##__core_file where `type` = '$type' order by fid desc ";
			$data = page_for_db_extend($total,$sql,'admincp.php?action=filemanager',20);
			$dt = get_cache(array('siteBase','sys_url'));
			foreach ($data['data'] as &$d){
				$d['source_file'] = substr($d['source_file'],0,7)=='http://'?$d['source_file']:$dt.$d['source_file'];
			}
	}
	$tpl->assign('data',$data);
	$tpl->display('filemanager.tpl');
?>