<?php
	define('IN_MANAGE',true);
	require dirname(__FILE__).'/include/common.inc.php';
	header("Cache-Control: no-store, no-cache, must-revalidate");  
	header("Cache-Control: post-check=0, pre-check=0", false);  
	header("Pragma: no-cache");

	/******** ³υΚΌ»― ********/
	$_userid=$_roleid=0;
	$file=preg_replace('/[^a-z0-9_]/i','',$file);
	$action=preg_replace('/[^a-z0-9_]/i','',$action);
	$mod=preg_replace('/[^a-z0-9_]/i','',$mod);

	$file=isset($file) && $file?$file:'index';
	$action=isset($action) && $action?$action:'';
	$mod=isset($mod) && $mod?$mod:'index';
	
	include SYSTEM_ROOT.'data/lang/admin.lang.php';
	include_once SYSTEM_ROOT.'include/adminer.class.php';
	$adminobj=new adminer();

	if(!$_SESSION['isadmin'] && $file!='login')
	{
		exit('<script language="javascript">{self.top.location.href="'.ADMIN_FILE.'?file=login";}</script>');
	}
	else
	{
		$ainfo=$adminobj->get($_SESSION['isadmin']);

		
		extract($ainfo,EXTR_PREFIX_ALL,'');

		$_SESSION['siteid']=(intval($_siteid) && SITETYPE)?intval($_siteid):1;//////////////
	}

	if($file=='login' && (!$_SESSION['isadmin'] || $action=='logout'))
	{
		include SYSTEM_ROOT.'/admin/login.inc.php';
	}
	else
	{
		if($mod!='index')
		{
			$modinfo=$moduleobj->get($mod,'folder');
			$adminrole=explode(',',$modinfo['adminrole']);
			
			if($action!='main' && (!$modinfo || (!in_array($_roleid,$adminrole) && !in_array($_userid,$admin_founders))))
			{
				exit('<script language="javascript">{self.top.location.href="'.ADMIN_FILE.'";}</script>');
			}

			$adminmenurole=string2array($modinfo['adminmenu']);
			if($adminmenurole && isset($adminmenurole[$action]) && $action)
			{
				$adminmenurole=explode(',',$adminmenurole[$action]['role']);
				if($action!='main' && (!in_array($_roleid,$adminmenurole) && !in_array($_userid,$admin_founders)))
				{
					exit('<script language="javascript">{self.top.location.href="'.ADMIN_FILE.'";}</script>');
				}
			}

			if($modinfo['issystem'] && !in_array($mod,array('member')))
			{
				include SYSTEM_ROOT.'admin/'.$file.'.inc.php';
			}
			else
			{
				include SYSTEM_ROOT.$modinfo['folder'].'/admin/'.$file.'.inc.php';
			}
		}
		else
		{
			include SYSTEM_ROOT.'/admin/index.inc.php';
		}
	}


?>