<?php defined( '_BIGNIGHT_EXEC' ) or die( 'Restricted access' );?>
<?php
	global $user;
	require_once("include/admin_profile.php");
?>
<?php 
	if (empty($_GET["name"])) 
		header('Location: index.php');	// redirect to index if no user chosen
	else {
		$profile = get_user_by_name($_GET["name"]);
		if(strcasecmp($_GET["name"],$user["username"])===0 || $profile["permissions"]>=$user["permissions"]){
			echo "Cannot moderate this user's profile profile.<br>\n";
			echo "<a href=\"index.php\">back to index</a>";
		} else if(!empty($_POST["delete"])){
			delete_confirm($_GET["name"]);
		} else {
			if(!empty($_POST["profile-submit"])) {
				global $error;
				if(edit_admin_profile($_GET["name"])) $error = "Changes saved";
				else $error = "Error saving changes";
			}
			admin_profile(get_user_by_name($_GET["name"]));
		}
	}

?>