<?php define( '_BIGNIGHT_EXEC', 1 );?>
<?php session_start();?>

<?php require_once("helper.php"); ?>
<?php require_once("user.php"); ?>


<?php

	if(!isset($_GET["name"])) die("No event specified.");
	$username = str_replace("'","''",$_GET["name"]);
	
	if($user===NULL) die("Error! Not logged in.");
	
	global $DB;
	
	$profile = $DB->qry("SELECT username,permissions,blocked FROM users WHERE username LIKE '{$username}';",4);
	if ($DB->numrows()===0){
		echo "Invalid user.";
	} else {					
		if($user["permissions"]<=$profile["permissions"]){
			echo "Access denied.";
		} else {
			$DB->qry("UPDATE users SET blocked=" . ($profile["blocked"]==1?"0":"1") . " WHERE username='{$profile["username"]}';");
			if($DB->numrows()!==0) echo ($profile["blocked"]==1?"Unblocked.":"Blocked.");
			else echo "Unknown error.";
		}
	}

?>