<?php
if(!defined('MOD'))  exit("非法调用");
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
{
	$type = intval( $_POST[type]); //1:channel;2:category
	$val  = intval( $_POST[val]);
	switch( $admin_info[groupid] )
	{
		case 1:
		case 2://等级过高，有权限操作
			success();
		break;

		case 3:
			if( !isset($manage_channel))
			{
				require_once(C_P."/purview/admin/".$_SESSION['uid'].".php");
			}
			if( $type == 1)
			{
				if( in_array( $val, $manage_channel))
				{
					success();
				}
				else
				{
					error();
				}
			}
			else
			{//需要多提供channelid参数
				if( in_array( $val, $manage_category[$GLOBALS[channelid]]))
				{
					success();
				}
				else
				{
					$channelid = qdb::QueryAlone("select channelid from ".TABLEPRE."acategory where cid='$val' limit 1");	
					if( in_array( $channelid, $manage_channel))
					{
						success();
					}
					else
					{
						error();
					}
				}
			}
		break;

		case 4:
			if( !isset($manage_channel))
			{
				require_once(C_P."/purview/admin/".$_SESSION['uid'].".php");
			}
			if( $type == 1)
			{
				error();
			}
			else
			{
				if( in_array( $val, $manage_category[$GLOBALS[channelid]]))
				{
					success();
				}
				else
				{
					error();
				}
			}
		break;

		default:
			qbase::showmsg("非法的参数");
		break;
	}
}
else
{
	qbase::showmsg("非法的参数传递途径");
}
function success()
{
	$data = "[200]";
	header("x-json: " .  $data);
	exit();
}
function error()
{
	$data = "[417]";
	header("x-json: " .  $data);
	exit();
}
?>
