<?php
	define('DIRCMS_MANAGE',true);
	require dirname(__FILE__).'/include/common.inc.php';
	header("Cache-Control: no-cache, must-revalidate");
	require DIRCMS_ROOT.'/include/version.inc.php';
	$LANG=cache_read('lang.inc.php',DIRCMS_ROOT.'language/'.LANG.'/');
	require DIRCMS_ROOT.'/include/admin/global.func.php';

	$file=isset($file)?$file:'index';
	$action=isset($action)?$action:'';

	(!preg_match('/^[0-9a-z_]+$/i',$file) || !file_exists(DIRCMS_ROOT.'admin/'.$file.'.inc.php')) && fatal_error($LANG['DIRCMS_TLPFILE_ERROR']); 
	session_start();
	if($_userid && $_groupid==1 && $_SESSION['is_admin']==true)
	{
		$file=($file=='login' && $action!='logout')?'index':$file;
		$roleid_array=cache_read('admin'.$_userid.'_role.inc.php',DIRCMS_ROOT.'data/cache_admin/');
		$roleid=$roleid_array?implode(',',$roleid_array):0;
		if(!$roleid)showmsg_nourl($LANG['NO_ADMINPRI']);
		$_roleid=$roleid=$roleid_array[0];
		$_categorypriv=cache_read('admin'.$_userid.'_categorypriv.inc.php',DIRCMS_ROOT.'data/cache_admin/');
	}
	else if($file!='login')
	{
		exit('<script language="javascript">{self.top.location.href="'.ADMIN_FILE.'?file=login";}</script>');
	}
	include DIRCMS_ROOT.'admin/'.$file.'.inc.php';
?>