<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
	$r=cache_read('module.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$r=$r['system']['roleid']; 
	if(!in_array($_roleid,$r) && $_userid!=ADMIN_FOUNDERS)showmsg_nourl('您没有该操作的权限!');
	$action=empty($action)?'manage':trim($action);
	$c=new cache();
	switch($action)
	{
		case 'manage':
			if(isset($do_submit)) 
			{
				if(!$id)showmsg('请选择需要操作的来源!',ADMIN_FILE.'?file=copyfrom&action=manage');
				foreach($id as $val)
				{
					switch($do)
					{
						case 'delete':
							$db->mysql_delete(DB_PRE.'copyfrom',intval($val));
							break;
						default:
							$db->update(DB_PRE.'copyfrom',array('copyfrom'=>$copyfrom[$val],'orderby'=>$orderby[$val],'url'=>$url[$val]),'id='.intval($val));
							break;
					}
				}
				$c->cache_copyfrom();
				showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=copyfrom&action=manage');
			}

			$c->cache_copyfrom();
			$result=$db->fetch_all("SELECT * FROM ".DB_PRE."copyfrom ORDER BY ".DB_PRE."copyfrom.orderby ASC,id DESC");
			include admin_tlp('copyfrom_manage');			
			break;
		case 'add':
			if(isset($do_submit)) 
			{
				if(!$copyfrom['copyfrom'])showmsg('稿件来源不能为空!');
				$db->insert(DB_PRE.'copyfrom',$copyfrom,true);
				$c->cache_copyfrom();
				showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=copyfrom&action=manage');
			}
			include admin_tlp('copyfrom_add');
			break;
		case 'delete':
			$db->mysql_delete(DB_PRE.'copyfrom',intval($id));
			$c->cache_copyfrom();
			showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=copyfrom&action=manage');
			break;
	}
?>
