diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index e761592..d5b740e 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -32,17 +32,36 @@ margin-bottom: 10px; } -.admin-filter { +.admin-filter, .admin-filtertype, .admin-groupfilter { display: inline-block; margin: 10px; vertical-align: top; - margin-right: 100px; + margin-right: 50px; + margin-left: 50px; +} + +.admin-filter, .admin-groupfilter { + width: 120px; +} + +.admin-groupfilter { + display: none; } .admin-users { margin: 10px; } +.admin-userpage { + width: 170px; + margin-bottom: 20px; + float: right; +} + +.usertitle { + width: 150px; +} + .usertable { width: 100%; } diff --git a/website/queries/group_page.php b/website/queries/group_page.php index d8bab8f..c6db01b 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -53,4 +53,47 @@ function select20GroupsByStatusFromN($db, $n, $status) { "); } -?> \ No newline at end of file +function search20GroupsFromNByStatus($db, $n, $keyword, $status) { + $q = $db->prepare(" + SELECT + `groupID`, + `name`, + `status`, + `description` + FROM + `group_page` + WHERE + `name` LIKE :keyword AND + FIND_IN_SET (`status`, :statuses) + ORDER BY + `name` + LIMIT + :n, 20 + "); + + $keyword = "%$keyword%"; + $q->bindParam(':keyword', $keyword); + $q->bindParam(':n', $n, PDO::PARAM_INT); + $statuses = implode(',', $status); + $q->bindParam(':statuses', $statuses); + $q->execute(); + return $q; +} + +function changeGroupStatusByID($db, $id, $status) { + $q = $db->query(" + UPDATE + `group_page` + SET + `status` = $status + WHERE + `groupID` = $id + "); + + return $q; +} + + + + +?> diff --git a/website/queries/user.php b/website/queries/user.php new file mode 100644 index 0000000..bfd9579 --- /dev/null +++ b/website/queries/user.php @@ -0,0 +1,86 @@ +query(" + SELECT + `userID`, + `username`, + `role`, + `bancomment` + FROM + `user` + ORDER BY + `role`, + `username` + LIMIT + $n, 20 + "); +} + +function search20UsersFromN($db, $n, $keyword) { + $q = $db->prepare(" + SELECT + `userID`, + `username`, + `role`, + `bancomment` + FROM + `user` + WHERE + `username` LIKE :keyword + ORDER BY + `username` + LIMIT + :n, 20 + "); + + $keyword = "%$keyword%"; + $q->bindParam(':keyword', $keyword); + $q->bindParam(':n', $n, PDO::PARAM_INT); + $q->execute(); + return $q; +} + +function search20UsersFromNByStatus($db, $n, $keyword, $status) { + $q = $db->prepare(" + SELECT + `userID`, + `username`, + `role`, + `bancomment` + FROM + `user` + WHERE + `username` LIKE :keyword AND + FIND_IN_SET (`role`, :statuses) + ORDER BY + `role`, + `username` + LIMIT + :n, 20 + "); + + $keyword = "%$keyword%"; + $q->bindParam(':keyword', $keyword); + $q->bindParam(':n', $n, PDO::PARAM_INT); + $statuses = implode(',', $status); + $q->bindParam(':statuses', $statuses); + $q->execute(); + return $q; +} + +function changeUserStatusByID($db, $id, $status) { + $q = $db->query(" + UPDATE + `user` + SET + `role` = $status + WHERE + `userID` = $id + "); + + return $q; +} + + +?> diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index b789aad..5a3ba97 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -1,98 +1,266 @@ - - - Admin Panel - - - -
-
-
-

User Management Panel

-

-
-
- - -
-

Show users:

- Active
- Muted
- Banned -
- -
-

Batch Actions:

- Mute
- Ban
- Unban

- -
-
-
-
-

Users:

- - - - - - - - - - - - - - - - - - - - - - -
- - UserStatusCommentAction
John SmithBannedunregulated time travel -
- - -
-
poey jokeaimBannedl33t h4xx -
- - -
-
-
- + } + + function changeFilter() { + if (document.getElementById('group').checked) { + document.getElementById('admin-filter').style.display = 'none'; + document.getElementById('admin-groupfilter').style.display = 'inline-block'; + } else { + document.getElementById('admin-filter').style.display = 'inline-block'; + document.getElementById('admin-groupfilter').style.display = 'none'; + } + } + + + + + + + + + +
+
+
+

User Management Panel

+

+
" + method="post"> +
+ " + method="post"> + + +
+

Show:

+ + > +
+ > +
+ > +
+ > +
+ > +
+ > + +
+ +
+

Show:

+ + > +
+ > +
+ > +
+
+ +
+

Page Type:

+ + onchange="changeFilter()"> +
+ + onchange="changeFilter()"> + +
+ + +
+

Batch Actions:

+ +
+ +
+ +

+ +
-
- +
+ +
+

Users:

+ +
+ + 1 / 1 + +

+ + + + + + + + + + + + fetch(PDO::FETCH_ASSOC)) { + $userID = $user['userID']; + $username = $user['username']; + $role = $user['role']; + $bancomment = $user['bancomment']; + $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + + echo(" + + + + + + + + "); + } + } else { + $q = search20GroupsFromNByStatus($db, $listnr, $search, $groupstatus); + + while ($group = $q->fetch(PDO::FETCH_ASSOC)) { + $groupID = $group['groupID']; + $name = $group['name']; + $role = $group['status']; + $description = $group['description']; + $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + + echo(" + + + + + + + + "); + } + } + ?> +
+ + UserStatusCommentAction
+ $username$role$bancomment +
+ + + +
+
+ $name$role$description +
+ + + +
+
+
+ +
+            
+        
+
+
+ diff --git a/website/views/head.php b/website/views/head.php index 39e29af..7d701f5 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -18,5 +18,3 @@ include_once("../queries/connect.php"); session_start(); - -?> \ No newline at end of file