isStaff()))
{
redirect("../404"); //u not admin nigga
}
$alert = "";
if(isset($_POST['unbanuser']))
{
$id = getID($_POST['unbanuser']);
if (unbanUser($id))
{
logStaffAction("Unbanned User ".$id);
$alert = "
Unbanned {$_POST['unbanuser']}
";
}
else
{
$alert = "Failed to unban user
";
}
}
if(isset($_POST['banuser']))
{
$postcount = count($_POST);
if ($postcount > 3)
{
$alert = "An error occurred
";
}
elseif (empty($_POST['banuser']))
{
$alert = "No username provided
";
}
elseif(usernameExists($_POST['banuser']) == false)
{
$alert = "No account with that username found
";
}
elseif (empty($_POST['banreason']))
{
$alert = "No ban reason provided
";
}
elseif ($postcount < 3)
{
$alert = "Please select a ban type
";
}
else
{
$bantype = 0; //default warning bantype
$banexpiration = 0;
if (isset($_POST['temp_checkbox']))
{
//tempban
$bantype = 1;
$banexpiration = time() + 86400; //add one day to current time
}
elseif (isset($_POST['perm_checkbox']))
{
//perm ban
$bantype = 2;
}
$id = getID($_POST['banuser']);
if (banUser($id, cleanInput($_POST['banreason']), $banexpiration, $bantype))
{
logStaffAction("Banned User ".$id);
$alert = "Banned {$_POST['banuser']}
";
}
else
{
$alert = "Failed to ban user
";
}
}
}
$b = $pdo->prepare("SELECT * FROM user_bans WHERE valid = 1");
$b->bindParam(":i", $id, PDO::PARAM_INT);
$b->execute();
$banneduser = "";
if ($b->rowCount() > 0)
{
foreach ($b as $bannedplayer)
{
$banneddate = date("m/d/Y", $bannedplayer['whenBanned']);
$bannedusername = getUsername($bannedplayer['uid']);
$bannedreason = cleanOutputNoFilter($bannedplayer['banReason']);
$bannedExpiration = (int)$bannedplayer['banExpiration'];
$bannedType = (int)$bannedplayer['banType'];
if ($bannedType == 0)
{
$bannedExpiration = "Warning";
}
elseif ($bannedType == 2)
{
$bannedExpiration = "Permanent";
}
else
{
$bannedExpiration = date("m/d/Y", $bannedplayer['banExpiration']);
}
$banneduser .= <<
{$banneddate} |
{$bannedusername} |
{$bannedreason} |
{$bannedExpiration} |
EOT;
}
}
$body = <<
{$alert}
User Management
| Date |
Username |
Reason |
Expiration |
{$banneduser}
EOT;
pageHandler();
$ph->pageTitle("User Manage");
$ph->body = $body;
$ph->output();
?>