From c6bdf349a8217ecd77b5c0308591581cf310630b Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 10:34:30 +0100 Subject: [PATCH 01/10] fixed forms for php, user status and page type --- website/styles/adminpanel.css | 7 +++--- website/views/adminpanel.php | 47 ++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/website/styles/adminpanel.css b/website/styles/adminpanel.css index e761592..edeb9c8 100644 --- a/website/styles/adminpanel.css +++ b/website/styles/adminpanel.css @@ -1,6 +1,6 @@ .admin-panel { margin: auto; - min-width: 800px; + /*min-width: 800px;*/ } .admin-title { @@ -32,11 +32,12 @@ margin-bottom: 10px; } -.admin-filter { +.admin-filter, .admin-filtertype { display: inline-block; margin: 10px; vertical-align: top; - margin-right: 100px; + margin-left: 20px; + margin-right: 20px; } .admin-users { diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index b789aad..96c02d3 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -21,26 +21,43 @@

User Management Panel


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

Show users:

- Active
- Muted
- Banned +

Show:

+ +
+ +
+ +
+ +
+ + +
+
+

Page Type:

+ +
+ +

Batch Actions:

- Mute
- Ban
- Unban

+ +
+ +
+ +

@@ -63,11 +80,11 @@ Banned unregulated time travel -
+ " method="post">
@@ -79,11 +96,11 @@ Banned l33t h4xx -
+ " method="post">
From b60d118ac603355bf36463892735cfd743e658e6 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 12:40:41 +0100 Subject: [PATCH 02/10] added form complete on search in adminpanel --- website/public/styles/adminpanel.css | 6 +- website/views/adminpanel.php | 261 ++++++++++++++++----------- 2 files changed, 156 insertions(+), 111 deletions(-) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index edeb9c8..019924e 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -1,6 +1,6 @@ .admin-panel { margin: auto; - /*min-width: 800px;*/ + min-width: 800px; } .admin-title { @@ -36,8 +36,8 @@ display: inline-block; margin: 10px; vertical-align: top; - margin-left: 20px; - margin-right: 20px; + margin-right: 50px; + margin-left: 50px; } .admin-users { diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 96c02d3..95d518d 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -1,115 +1,160 @@ - - - Admin Panel - - - -
-
-
-

User Management Panel

-

-
" method="post"> -
- " method="post"> - -
-

Show:

- -
- -
- -
- -
- - -
-
-

Page Type:

- -
- - -
- -
-

Batch Actions:

- -
- -
- -

- -
-
-
-
-

Users:

- - - - - - - - - - - - - - - - - - - - - - -
- - UserStatusCommentAction
John SmithBannedunregulated time travel -
" method="post"> - - -
-
poey jokeaimBannedl33t h4xx -
" method="post"> - - -
-
-
- + } + + + + + + + +
+
+
+

User Management Panel

+

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

Show:

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

Page Type:

+ > +
+ > + +
+ +
+

Batch Actions:

+ +
+ +
+ +

+ +
-
- +
+
+

Users:

+ + + + + + + + + + + + + + + + + + + + + + +
+ + UserStatusCommentAction
John SmithBannedunregulated time travel +
" + method="post"> + + +
+
poey jokeaimBannedl33t h4xx +
" + method="post"> + + +
+
+
+ +
+
+ From f00b3d9a231ff7073c3fc77ea8d1b8600ce60d02 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 12:55:15 +0100 Subject: [PATCH 03/10] add page selector in adminpanel --- website/public/styles/adminpanel.css | 6 ++++++ website/views/adminpanel.php | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index 019924e..5a9fb7e 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -44,6 +44,12 @@ margin: 10px; } +.admin-userpage { + width: 170px; + margin-bottom: 20px; + float: right; +} + .usertable { width: 100%; } diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 95d518d..9c1c818 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -105,6 +105,11 @@ function test_input($data) {

Users:

+
+ + 1 / 1 + +

+ fetch(PDO::FETCH_ASSOC)) { $userID = $user['userID']; @@ -135,6 +182,7 @@ function test_input($data) { $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(" + + + + + + + + "); + } } ?>
From e3e72b8ef6f4687b2421542d131dc08a7f2ee81f Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 14:02:33 +0100 Subject: [PATCH 04/10] fixed connect.php location in head --- website/views/head.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/views/head.php b/website/views/head.php index fc28320..997f2d1 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -15,6 +15,6 @@ \ No newline at end of file +?> From 877072f9e3092378ddeef8e9767cd0c54f552749 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 15:12:56 +0100 Subject: [PATCH 05/10] add sql usersearch base in adminpanel --- website/views/adminpanel.php | 45 +++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 9c1c818..21fe476 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -5,7 +5,7 @@ Admin Panel + @@ -110,6 +111,8 @@ function test_input($data) { 1 / 1
+ + - + + fetch(PDO::FETCH_ASSOC)) { + $userID = $user['userID']; + $username = $user['username']; + $role = $user['role']; + $bancomment = $user['bancomment']; + $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + echo(" + + + + + + + + "); + } + ?> + +
@@ -120,7 +123,43 @@ function test_input($data) { Comment Action
+ $username$role$bancomment +
+ + + +
+
From 146fc7108ba63eb1d565cff7a7b23567bd5d6e1c Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 15:13:32 +0100 Subject: [PATCH 06/10] add usersearch query --- website/queries/user.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 website/queries/user.php diff --git a/website/queries/user.php b/website/queries/user.php new file mode 100644 index 0000000..d355771 --- /dev/null +++ b/website/queries/user.php @@ -0,0 +1,19 @@ +query(" + SELECT + `userID`, + `username`, + `role`, + `bancomment` + FROM + `user` + ORDER BY + `username` + LIMIT + $n + "); +} + +?> From 8ce6cd1aa2303db0e910cb6ecc6ecc39e64fafa8 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 17 Jan 2017 16:23:44 +0100 Subject: [PATCH 07/10] add rudimentary search --- website/queries/user.php | 29 +++++++++++++++++++-- website/views/adminpanel.php | 50 +++++++----------------------------- 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/website/queries/user.php b/website/queries/user.php index d355771..8029154 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -1,6 +1,6 @@ query(" SELECT `userID`, @@ -10,10 +10,35 @@ function selectSomeUsers($db, $n) { FROM `user` ORDER BY + `role`, `username` LIMIT - $n + $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; +} + ?> diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 21fe476..a8cdb73 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -20,11 +20,14 @@
- fetch(PDO::FETCH_ASSOC)) { $userID = $user['userID']; $username = $user['username']; @@ -158,46 +161,11 @@ function test_input($data) { "); } ?> - -
@@ -125,7 +127,8 @@ function test_input($data) {
+ +
From b5ceb1b5e0fe7edee7d0dcec754e68ac03fbabe1 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Wed, 18 Jan 2017 14:20:32 +0100 Subject: [PATCH 08/10] add pagetype selector, add search filter --- website/public/styles/adminpanel.css | 10 +++- website/queries/user.php | 28 +++++++++ website/views/adminpanel.php | 88 +++++++++++++++++++++------- 3 files changed, 104 insertions(+), 22 deletions(-) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index 5a9fb7e..c8e29b6 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -32,7 +32,7 @@ margin-bottom: 10px; } -.admin-filter, .admin-filtertype { +.admin-filter, .admin-filtertype, .admin-groupfilter { display: inline-block; margin: 10px; vertical-align: top; @@ -40,6 +40,14 @@ margin-left: 50px; } +.admin-filter, .admin-groupfilter { + width: 120px; +} + +.admin-groupfilter { + display: none; +} + .admin-users { margin: 10px; } diff --git a/website/queries/user.php b/website/queries/user.php index 8029154..42d90bc 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -41,4 +41,32 @@ function search20UsersFromN($db, $n, $keyword) { 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 + `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; +} + + ?> diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index a8cdb73..8ce9fb1 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -4,6 +4,10 @@ Admin Panel @@ -20,13 +35,14 @@ ">
-
+ +

Show:

- > + + >
- > + >
- > + >
- > + >
- > - + > +
+ > +
+ +
+

Show:

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

Page Type:

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

Batch Actions:

@@ -107,8 +151,10 @@ function test_input($data) {

+

Users:

+
1 / 1 @@ -126,8 +172,9 @@ function test_input($data) {
Action
- -
From 71dc7bae2cb0b137a72ae24019e02bc9f7bcea98 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Wed, 18 Jan 2017 15:19:07 +0100 Subject: [PATCH 09/10] add group search, add user individual actions --- website/public/styles/adminpanel.css | 4 + website/queries/group_page.php | 31 +++++++- website/queries/user.php | 13 ++++ website/views/adminpanel.php | 108 +++++++++++++++++++-------- 4 files changed, 124 insertions(+), 32 deletions(-) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index c8e29b6..d5b740e 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -58,6 +58,10 @@ float: right; } +.usertitle { + width: 150px; +} + .usertable { width: 100%; } diff --git a/website/queries/group_page.php b/website/queries/group_page.php index d8bab8f..8f04ca3 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -53,4 +53,33 @@ 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; +} + + + +?> diff --git a/website/queries/user.php b/website/queries/user.php index 42d90bc..de8c52b 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -68,5 +68,18 @@ function search20UsersFromNByStatus($db, $n, $keyword, $status) { 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 8ce9fb1..d478003 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -29,7 +29,10 @@ } - + @@ -57,6 +60,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $groupstatus = $_POST["groupstatus"]; } + if (!empty($_POST["actions"]) && !empty($_POST["userID"])) { + changeUserStatusByID($db, $_POST["userID"], $_POST["actions"]); + } } @@ -153,7 +159,7 @@ function test_input($data) {
-

Users:

+

Users:

@@ -174,44 +180,84 @@ function test_input($data) { fetch(PDO::FETCH_ASSOC)) { - $userID = $user['userID']; - $username = $user['username']; - $role = $user['role']; - $bancomment = $user['bancomment']; - $thispage = htmlspecialchars($_SERVER['PHP_SELF']); + while($user = $q->fetch(PDO::FETCH_ASSOC)) { + $userID = $user['userID']; + $username = $user['username']; + $role = $user['role']; + $bancomment = $user['bancomment']; + $thispage = htmlspecialchars($_SERVER['PHP_SELF']); - echo(" + echo("
- $username$role$bancomment -
- - - -
-
+ $username$role$bancomment +
+ + + +
+
+ $name$role$description +
+ + + +
+
+
+            
+        
From e7e3ae9c8be3492b20fcddd0c16d444099ee17b9 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Wed, 18 Jan 2017 15:57:39 +0100 Subject: [PATCH 10/10] add changing single group status --- website/queries/group_page.php | 14 ++++++++++++++ website/queries/user.php | 1 + website/views/adminpanel.php | 8 +++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 8f04ca3..c6db01b 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -80,6 +80,20 @@ function search20GroupsFromNByStatus($db, $n, $keyword, $status) { 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 index de8c52b..bfd9579 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -54,6 +54,7 @@ function search20UsersFromNByStatus($db, $n, $keyword, $status) { `username` LIKE :keyword AND FIND_IN_SET (`role`, :statuses) ORDER BY + `role`, `username` LIMIT :n, 20 diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index d478003..5a3ba97 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -62,6 +62,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { if (!empty($_POST["actions"]) && !empty($_POST["userID"])) { changeUserStatusByID($db, $_POST["userID"], $_POST["actions"]); + } elseif (!empty($_POST["actions"]) && !empty($_POST["groupID"])) { + changeGroupStatusByID($db, $_POST["groupID"], $_POST["actions"]); } } @@ -239,9 +241,9 @@ function test_input($data) { action='$thispage' method='post'>