IsOwner())) {
if ($user->IsAdmin()) {
WebContextManager::Redirect("/");
}
die('bababooey');
}
adminPanelStats();
$alert = '';
if(isset($_POST['submitgiveasset']))
{
$username = $_POST['username'];
$catalogid = (int)$_POST['catalogid'];
if(empty($username))
{
$alert = "
Please provide a Username
";
}
elseif(!usernameExists($username))
{
$alert = "User doesn't exist
";
}
elseif(empty($catalogid))
{
$alert = "Please provide a valid Asset ID
";
}
else
{
$checkforitem = $pdo->prepare("SELECT * FROM assets WHERE id = :i");
$checkforitem->bindParam(":i", $catalogid, PDO::PARAM_INT);
$checkforitem->execute();
if ($checkforitem->rowCount() > 0) //check if item exist in the catalog
{
$userid = getID($username);
$checkuserforitem = $pdo->prepare("SELECT * FROM owned_assets WHERE uid = :ui AND aid = :ad");
$checkuserforitem->bindParam(":ui", $userid, PDO::PARAM_INT);
$checkuserforitem->bindParam(":ad", $catalogid, PDO::PARAM_INT);
$checkuserforitem->execute();
if ($checkuserforitem->rowCount() > 0) //check if the user already owns the item
{
$alert = "User already owns the Item
";
}
else
{
if (giveItem($userid, $catalogid))
{
$alert = "Successfully gave user the item
";
}
else
{
$alert = "Failed to give user the item
";
}
}
}
else
{
$alert = "Asset ID doesn't exist
";
}
}
}
$body = <<
{$alert}
Give Asset
EOT;
pageHandler();
$ph->pagetitle = "";
$ph->navbar = "";
$ph->body = $body;
$ph->footer = "";
$ph->output();