From be4f83cd2a17a0ec05f5bce50c91befaafaa6e0c Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 20 Dec 2009 18:38:08 +0000 Subject: Test. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@376 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/admins/functions.php | 147 +++++++++++++++++++++++++++++++++++++++++++++ admin/admins/index.php | 53 ++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 admin/admins/functions.php create mode 100644 admin/admins/index.php (limited to 'admin/admins') diff --git a/admin/admins/functions.php b/admin/admins/functions.php new file mode 100644 index 0000000..031bd05 --- /dev/null +++ b/admin/admins/functions.php @@ -0,0 +1,147 @@ +. + */ + + function ListAdmins() + { + global $db; + $result = $db->Query("SELECT `user_id`, `username`, `level` FROM `bayonet_users` ORDER BY `level` DESC"); + while(($rows = $db->fetch($result))!=false) + { + $admins[] = $rows; + } + + $num = 1; + OpenTable("300px"); + echo "UsernameLevel"; + foreach($admins as $admin) + { + echo "{$num}.{$admin['username']}{$admin['level']}"; + $num++; + } + CloseTable(); + } + + function NewAdmin() + { + $maxLevel = $_SESSION['level']; + } + + function EditAdmin($user_id) + { + global $db; + $maxLevel = $_SESSION['level']; + + if(isset($_POST['processed'])) + { + $username = addslashes($_POST['username']); + $level = addslashes($_POST['level']); + + if(empty($username)) + { + echo "You must fill everything out before proceeding."; + return; + } + + $db->Query("UPDATE `bayonet_users` SET `username` = '$username', `level` = '$level' WHERE `user_id` = '$user_id' LIMIT 1"); + + echo "Admin, '$username' level '$level' has been edited.\n

+ Please wait while you are redirected.

+ Click here if you don't feel like waiting."; + + // 3 second redirect to go back to the edit page + PageRedirect(3, "?op=admins"); + return; + } + + $result = $db->Query("SELECT * FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1"); + while(($rows = $db->fetch($result))!=false) + { + $admin = $rows; + } + + if($maxLevel < $admin['level']){ + ReportError("You do not have permission to access this user."); + return; + } +?> +
+ Edit the attributes of this administrator.
+
+ + + + + + + + + +
Username:
Level: + +
+ + +
+
+
+Query("SELECT `username` FROM `bayonet_users` WHERE `user_id` = '$user_id'"); + $admin = $db->Fetch($result); + + if(isset($_POST['proceed'])) + { + echo "Admin '{$admin['username']}', was deleted."; + $db->Query("DELETE FROM `bayonet_users` WHERE `user_id` = '$user_id' LIMIT 1"); + PageRedirect(3,"?op=admins"); + return; + } + if(isset($_POST['cancel'])) + { + echo "User cancelled deletion of admin: '{$admin['username']}'"; + PageRedirect(3,"?op=admins"); + return; + } + ?> +
+
+ + + +
Are you SURE you want to delete the administrative user: ''?
   
+
+
+ \ No newline at end of file diff --git a/admin/admins/index.php b/admin/admins/index.php new file mode 100644 index 0000000..b000111 --- /dev/null +++ b/admin/admins/index.php @@ -0,0 +1,53 @@ +. + */ +?> +

- Edit Admins

+".LinkInternal('Add New Admin','?op=admins&create=true').""; + +ListAdmins(); + +?> \ No newline at end of file -- cgit