query('SELECT * FROM admins'); while ($line = $DatabaseQuery->fetchArray()) { if ($Key == $line['key']) { if ($line['primaryadmin'] == 1) { $AdminIsPrimary = 1; } $AuthorizedRemoval = 1; break; } } $DatabaseQuery = $Database->query('SELECT * FROM keys'); while ($line = $DatabaseQuery->fetchArray()) { if ($line['id'] == $id && $line['id'] != "" && $id != "") { // passed ID is a key that exists if ($AuthorizedRemoval == 1) { $Database->exec("DELETE FROM keys WHERE id='$id'"); $Removed = 1; } else { print "You aren't authorized to perform this action."; die(); } break; } } $DatabaseQuery = $Database->query('SELECT * FROM tkeys'); while ($line = $DatabaseQuery->fetchArray()) { if ($line['id'] == $id && $line['id'] != "" && $id != "" && $Removed != 1) { // passed ID is a key that exists if ($AuthorizedRemoval == 1) { $Database->exec("DELETE FROM tkeys WHERE id='$id'"); $Removed = 1; } else { print "You aren't authorized to perform this action."; die(); } break; } } $DatabaseQuery = $Database->query('SELECT * FROM admins'); while ($line = $DatabaseQuery->fetchArray()) { if ($line['id'] == $id && $line['id'] != "" && $id != "" && $Removed != 1 && $line['primaryadmin'] != 1) { // passed ID is a key that exists if ($AuthorizedRemoval == 1 && $AdminIsPrimary == 1) { // in order to delete an admin key you must be a primary admin $Database->exec("DELETE FROM admins WHERE id='$id'"); $Removed = 1; } else { print "You aren't authorized to perform this action."; die(); } break; } } if ($AuthorizedRemoval != 1) { print "You aren't authorized to perform this action."; die(); } ?>