isOwner())) { if ($user->isAdmin()) { redirect("/"); } die('bababooey'); } adminPanelStats(); $alert = ''; if(isset($_POST['submitgiveasset'])) { $username = $_POST['username']; $catalogid = (int)$_POST['catalogid']; if(empty($username)) { $alert = ""; } elseif(!usernameExists($username)) { $alert = ""; } elseif(empty($catalogid)) { $alert = ""; } 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 = ""; } else { if (giveItem($userid, $catalogid)) { $alert = ""; } else { $alert = ""; } } } else { $alert = ""; } } } $body = << {$alert}
Give Asset
EOT; pageHandler(); $ph->pagetitle = ""; $ph->navbar = ""; $ph->body = $body; $ph->footer = ""; $ph->output();