From cfe2928f7b277b5224700fac2086903c6f4556c6 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Wed, 1 Feb 2017 14:28:03 +0100 Subject: [PATCH 01/37] Fixed member list --- website/public/group.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/website/public/group.php b/website/public/group.php index 72da9c8..bb393e3 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -14,12 +14,7 @@ include_once("../queries/group_page.php"); $group = selectGroupByName($_GET["groupname"]); -$members = selectGroupMembers(2); - -?> - - - Date: Wed, 1 Feb 2017 14:31:18 +0100 Subject: [PATCH 02/37] Added noposts div to group. --- website/views/group.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/views/group.php b/website/views/group.php index c12b552..aaec353 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -22,6 +22,10 @@ +
+

Geen posts meer!

+
+ + \ No newline at end of file From 9d675dd897b01d2a5e4e13a124ab9944b2b63a46 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 13:11:05 +0100 Subject: [PATCH 10/37] Fixed default image for group members. --- website/queries/group_page.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 511ff4d..b66ca54 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -81,7 +81,10 @@ function selectGroupMembers(int $groupID) { `username`, `fname`, `lname`, - `profilepicture` + IFNULL( + `profilepicture`, + '../img/avatar-standard.png' + ) AS profilepicture FROM `group_member` LEFT JOIN From d4d16661dffb7ecf3c64eea28aff40aa8e4a4c4a Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 13:42:59 +0100 Subject: [PATCH 11/37] added alert box when emptpy posting --- website/public/API/postPost.php | 51 ++++++++++++++++--------------- website/public/js/masonry.js | 25 ++++++++++----- website/public/js/post.js | 2 ++ website/public/styles/profile.css | 5 +++ website/views/profile.php | 4 +++ 5 files changed, 56 insertions(+), 31 deletions(-) diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b1c6649..241bda6 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -12,36 +12,39 @@ if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'frozen' && getRoleByID($_SESSION["userID"]) != 'banned') { - if (empty($_POST["title"]) or - empty($_POST["content"]) or - empty($_SESSION["userID"]) - ) { + if (empty($_SESSION["userID"])) { header('HTTP/1.1 500 Non enough arguments'); } - if (empty($_POST["group"])) { - // User Post - makePost( - $_SESSION["userID"], - null, - test_input($_POST["title"]), - test_input($_POST["content"]) - ); + if (empty(test_input($_POST["title"])) or + empty(test_input($_POST["content"])) + ) { + echo "empty"; } else { - // Group Post + if (empty($_POST["group"])) { + // User Post + makePost( + $_SESSION["userID"], + null, + test_input($_POST["title"]), + test_input($_POST["content"]) + ); + } else { + // Group Post - // Check if the user is an admin or mod of the group. - if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) { - header('HTTP/1.1 500 Non enough rights'); - return; + // Check if the user is an admin or mod of the group. + if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) { + header('HTTP/1.1 500 Non enough rights'); + return; + } + + makePost( + $_SESSION["userID"], + $_POST["group"], + test_input($_POST["title"]), + test_input($_POST["content"]) + ); } - - makePost( - $_SESSION["userID"], - $_POST["group"], - test_input($_POST["title"]), - test_input($_POST["content"]) - ); } } else { echo "frozen"; diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 4f638c2..d0d2074 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -31,14 +31,28 @@ function postPost() { $.post("API/postPost.php", { title: title, content : content, group : groupID }) - .done(function() { - masonry(masonryMode); + .done(function(data) { + if (data == "empty") { + $('#alertbox').show(); + $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); + window.scrollTo(0,0); + } else { + $('#alertbox').hide(); + masonry(masonryMode); + } }); } else { $.post("API/postPost.php", { title: title, content : content }) - .done(function() { - masonry(masonryMode); + .done(function(data) { + if (data == "empty") { + $('#alertbox').show(); + $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); + window.scrollTo(0,0); + } else { + $('#alertbox').hide(); + masonry(masonryMode); + } }); } @@ -153,9 +167,6 @@ function loadMorePosts(uID, gID, offset, limit) { return; } - console.log(uID, gID, offset, limit); - - $.post("API/getPosts.php", { usr : uID, grp : gID, offset : offset, diff --git a/website/public/js/post.js b/website/public/js/post.js index f176950..7c73793 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -32,6 +32,8 @@ function deletePost(postID) { alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is."); } }); + noposts = false; + postAmount = 0; closeModal(); masonry(masonryMode); diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 1bacafa..27d2bdd 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -1,5 +1,10 @@ /* New */ +.alertbox { + display: none; + background-color: firebrick; +} + .user-box { text-align: center; } diff --git a/website/views/profile.php b/website/views/profile.php index 2bb117f..120dae4 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -1,4 +1,8 @@
+
+ +
+
" src="">
From feba1d978627948b73445a0016c1bd51e7d3bcd9 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 13:47:41 +0100 Subject: [PATCH 12/37] fix reload after posting post --- website/public/js/masonry.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 7128a8a..5a4ca4c 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -38,6 +38,8 @@ function postPost() { window.scrollTo(0,0); } else { $('#alertbox').hide(); + noposts = false; + postAmount = 0; masonry(masonryMode); } }); @@ -51,6 +53,8 @@ function postPost() { window.scrollTo(0,0); } else { $('#alertbox').hide(); + noposts = false; + postAmount = 0; masonry(masonryMode); } }); From 93e63111de4738629b0921cc5ca9882ef35a7581 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 13:54:52 +0100 Subject: [PATCH 13/37] cleaned fix --- website/public/js/masonry.js | 8 ++++---- website/public/js/post.js | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 5a4ca4c..a628e96 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -38,8 +38,6 @@ function postPost() { window.scrollTo(0,0); } else { $('#alertbox').hide(); - noposts = false; - postAmount = 0; masonry(masonryMode); } }); @@ -53,8 +51,6 @@ function postPost() { window.scrollTo(0,0); } else { $('#alertbox').hide(); - noposts = false; - postAmount = 0; masonry(masonryMode); } }); @@ -116,6 +112,10 @@ function masonry(mode) { masonryMode = mode; $container.children().remove(); + // reinit posts + noposts = false; + postAmount = 0; + /* * Initialise columns. */ diff --git a/website/public/js/post.js b/website/public/js/post.js index 20da034..4009023 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -32,8 +32,6 @@ function deletePost(postID) { alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is."); } }); - noposts = false; - postAmount = 0; closeModal(); masonry(masonryMode); } \ No newline at end of file From d24ed8909681d7cf9f85d5e20f41d6b6ad2d87a0 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:04:59 +0100 Subject: [PATCH 14/37] BUG FIX: mobile support fix --- website/public/bits/niet_slecht.php | 7 +++++++ website/public/js/chat.js | 3 +++ website/views/head.php | 1 - 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 website/public/bits/niet_slecht.php diff --git a/website/public/bits/niet_slecht.php b/website/public/bits/niet_slecht.php new file mode 100644 index 0000000..05b981a --- /dev/null +++ b/website/public/bits/niet_slecht.php @@ -0,0 +1,7 @@ + - MyHyvesbook+ From 417124a1fed22f85cd86615e83df488455baeb30 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:13:20 +0100 Subject: [PATCH 15/37] BUG FIX: added 0 in chat time if needed --- website/public/js/chat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 1141334..a3ff430 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -59,7 +59,7 @@ function addMessages(messages) { for(var i in messages) { // Initialize message variables. var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); - var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); + var thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2); var type; thisDate.setHours(0,0,0,0); @@ -81,6 +81,8 @@ function addMessages(messages) {
'; } previousDate = thisDate; + previousTime = thisTime; + previousType = type; messagesText += '
'; // If it is not the first message, and has a different date/time/type then the previous message, } else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) { From 4a7a91ecd964f1cb0827765078314d04ac6534dc Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 14:20:17 +0100 Subject: [PATCH 16/37] Fixed bug (not showing profile when on own profile) --- website/public/profile.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/website/public/profile.php b/website/public/profile.php index d9a317c..aa4cf7c 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -21,19 +21,14 @@ include_once("../queries/calcAge.php"); if(empty($_GET["username"])) { $userID = $_SESSION["userID"]; - $showProfile = True; } else { $userID = getUserID($_GET["username"]); - $showProfile = False; } $user = selectUser($_SESSION["userID"], $userID); $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); -$showProfile = $showProfile || $user["showProfile"] || ($user["status"] == 'confirmed'); -echo " friendship status: " . $user["status"]; -echo " showprofile: $showProfile"; -echo " userID: " . $user["userID"]; +$showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID; if ($userID == $_SESSION["userID"]) { From 188741ddf5ded574767a0115f06af8bd2a97487b Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:22:13 +0100 Subject: [PATCH 17/37] BUG FIX: link in fancy text now opens in new tab --- website/public/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/main.js b/website/public/js/main.js index b6ab703..30cd3ed 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -31,7 +31,7 @@ function fancyText(text) { } // Add links else { - return "" + link + ""; + return "" + link + ""; } }); From 1672ce6086deed96f1325a3044e9fe9c632adaf6 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:23:36 +0100 Subject: [PATCH 18/37] Changed offline status to 5 minutes after inactive --- website/queries/friendship.php | 8 ++++---- website/queries/user.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 7edada9..3dcd53b 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -17,7 +17,7 @@ function selectLimitedFriends($userID, $limit) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -58,7 +58,7 @@ function selectAllFriends($userID) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -94,7 +94,7 @@ function selectAllFriendRequests() { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -245,7 +245,7 @@ function searchSomeFriends($n, $m, $search) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, diff --git a/website/queries/user.php b/website/queries/user.php index e8bda13..7b8ef3f 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -62,7 +62,7 @@ function selectUser($me, $other) { ) AS profilepicture, `bio`, `user`.`creationdate`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -131,7 +131,7 @@ function select20UsersFromN($n) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -156,7 +156,7 @@ function search20UsersFromN($n, $keyword) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -184,7 +184,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -218,7 +218,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -362,7 +362,7 @@ function searchSomeUsers($n, $m, $search) { '../img/avatar-standard.png' ) AS profilepicture, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` From 6fc2f715176a34529d129a0f1a79d4d57f9ae659 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:27:23 +0100 Subject: [PATCH 19/37] Added meta data in the login page --- website/views/login_head.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/views/login_head.php b/website/views/login_head.php index e319a9d..bb7d7cf 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,5 +1,8 @@ - + + + + MyHyvesbook+ Date: Thu, 2 Feb 2017 14:50:51 +0100 Subject: [PATCH 20/37] Added "add group" under group menu --- website/views/menu.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..1c1cf01 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -12,6 +12,8 @@ + +
@@ -122,6 +122,7 @@ if (isset($_GET["groupstatus"])) { + Maak Owner"; + value=\"owner\">Maak Eigenaar"; } ?> @@ -139,9 +140,9 @@ if (isset($_GET["groupstatus"])) { onsubmit="adminUpdate(this); return false;"> - - - + + +
From cfa7c870f08417b80d5d7c285207deb0e94db228 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 15:13:35 +0100 Subject: [PATCH 25/37] fix profile error color --- website/public/styles/profile.css | 4 ++++ website/views/profile.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index dbb3d24..46906d2 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -5,6 +5,10 @@ background-color: firebrick; } +.alerttext { + color: white; +} + .user-box { text-align: center; } diff --git a/website/views/profile.php b/website/views/profile.php index 7348642..4139099 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -1,6 +1,6 @@
- +
From 8a3cfebf55bbc8380034c25741f52682beb2b9aa Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 15:34:45 +0100 Subject: [PATCH 26/37] Redirect to 404 from profile and group --- website/public/group.php | 9 ++++++++- website/public/profile.php | 7 ++++++- website/queries/group_page.php | 7 ++++++- website/queries/user.php | 4 +++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/website/public/group.php b/website/public/group.php index bb393e3..84726fa 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -13,9 +13,16 @@ include_once("../queries/group_page.php"); -$group = selectGroupByName($_GET["groupname"]); +if(!$group = selectGroupByName($_GET["groupname"])) { + header("HTTP/1.0 404 Not Found"); + header("Location: error/404.php"); + die(); +} + + $members = selectGroupMembers($group["groupID"]); + /* * This view adds the main layout over the screen. * Header, menu, footer. diff --git a/website/public/profile.php b/website/public/profile.php index aa4cf7c..126c87f 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -25,7 +25,12 @@ if(empty($_GET["username"])) { $userID = getUserID($_GET["username"]); } -$user = selectUser($_SESSION["userID"], $userID); +if(!$user = selectUser($_SESSION["userID"], $userID)) { + header("HTTP/1.0 404 Not Found"); + header("Location: error/404.php"); + die(); +} + $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); $showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID; diff --git a/website/queries/group_page.php b/website/queries/group_page.php index f2f028f..a6676c4 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -33,7 +33,12 @@ function selectGroupByName($name) { if (!$stmt->execute()) { return False; } - return $stmt->fetch(); + $row = $stmt->fetch(); + if($row["groupID"] == null) { + return False; + } + + return $row; } function selectGroupRole(int $groupID) { diff --git a/website/queries/user.php b/website/queries/user.php index 972937d..836c956 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -101,7 +101,9 @@ function selectUser($me, $other) { $stmt->bindParam(':me', $me, PDO::PARAM_INT); $stmt->bindParam(':other', $other, PDO::PARAM_INT); - $stmt->execute(); + if(!$stmt->execute() || $stmt->rowCount() == 0) { + return False; + } return $stmt->fetch(); } From 1c53eab2fa77c02aaeb7340a38b053d38c0cf335 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 15:50:12 +0100 Subject: [PATCH 27/37] Fixed user group list on profile page. --- website/queries/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/queries/user.php b/website/queries/user.php index 06487be..422edc4 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -122,7 +122,7 @@ function selectAllUserGroups($userID) { `group_page`.`groupID` = `group_member`.`groupID` WHERE `userID` = :userID AND - `role` = 'member' + `role` IN ('member', 'mod', 'admin') "); $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); From 380d8fa83a7ea8780f09fd8c1a8df7965b8f45b1 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 16:01:45 +0100 Subject: [PATCH 28/37] Group Shit --- website/public/createGroup.php | 36 +++++++++++++++ website/public/groupAdmin.php | 46 ++++++++++++++++++++ website/queries/createGroup.php | 37 ++++++++++++++++ website/queries/groupAdmin.php | 61 ++++++++++++++++++++++++++ website/queries/picture.php | 12 ++--- website/views/createGroup.php | 42 ++++++++++++++++++ website/views/groupAdmin.php | 77 +++++++++++++++++++++++++++++++++ website/views/menu.php | 2 +- 8 files changed, 306 insertions(+), 7 deletions(-) create mode 100644 website/public/createGroup.php create mode 100644 website/public/groupAdmin.php create mode 100644 website/queries/createGroup.php create mode 100644 website/queries/groupAdmin.php create mode 100644 website/views/createGroup.php create mode 100644 website/views/groupAdmin.php diff --git a/website/public/createGroup.php b/website/public/createGroup.php new file mode 100644 index 0000000..ffeb6e3 --- /dev/null +++ b/website/public/createGroup.php @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php new file mode 100644 index 0000000..13ff7e0 --- /dev/null +++ b/website/public/groupAdmin.php @@ -0,0 +1,46 @@ + + + + + + + + +getClass(); + $alertMessage = $w->getMessage(); + } +} + +/* Add your view files here. */ +include("../views/groupAdmin.php"); + +/* This adds the footer. */ +include("../views/footer.php"); +?> + + diff --git a/website/queries/createGroup.php b/website/queries/createGroup.php new file mode 100644 index 0000000..20ee28b --- /dev/null +++ b/website/queries/createGroup.php @@ -0,0 +1,37 @@ +bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $createGroup->bindValue(':description', test_input($_POST["bio"])); + $createGroup->execute(); + + $getGroupID = prepareQuery(" + SELECT + `groupID` + FROM + `group_page` + WHERE + `name` LIKE :name"); + $getGroupID->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $getGroupID->execute(); + $groupID = $getGroupID->fetch()["groupID"]; + + $makeUserAdmin = prepareQuery(" + INSERT INTO + `group_member` (userID, groupID, role) + VALUES (:userID, :groupID, 'admin') + "); + $makeUserAdmin->bindValue(":userID", $_SESSION["userID"]); + $makeUserAdmin->bindValue("groupID", $groupID); + $makeUserAdmin->execute(); + + updateAvatar($groupID); +} \ No newline at end of file diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php new file mode 100644 index 0000000..ae2abd3 --- /dev/null +++ b/website/queries/groupAdmin.php @@ -0,0 +1,61 @@ +bindParam(":groupID", $groupID); + $stmt->execute(); + return $stmt->fetch(); +} + +function updateGroupSettings(int $groupID) +{ + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Je hebt geen rechten in deze groep"); + } + $stmt = prepareQuery(" + UPDATE + `group_page` + SET + `name` = :name, + `description` = :bio + WHERE + `groupID` = :groupID + "); + $stmt->bindValue(":bio", test_input($_POST["bio"])); + $stmt->bindValue(":name", test_input($_POST["name"])); + $stmt->bindValue(":groupID", test_input($_POST["groupID"])); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Groep aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } +} + +function checkGroupAdmin(int $groupID, int $userID) : bool { + $stmt = prepareQuery(" + SELECT + `role` + FROM + `group_member` + WHERE + `groupID` = :groupID AND + `userID` = :userID + "); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":groupID", $groupID); + $stmt->execute(); + if (!$stmt->rowCount()) { + return false; + } + $role = $stmt->fetch()["role"]; + return ($role == "admin"); +} \ No newline at end of file diff --git a/website/queries/picture.php b/website/queries/picture.php index 8e99d9a..ba27f72 100644 --- a/website/queries/picture.php +++ b/website/queries/picture.php @@ -6,7 +6,7 @@ * @throws AngryAlert * @throws HappyAlert */ -function updateAvatar(bool $group = false) { +function updateAvatar(int $group = 0) { $publicDir = "/var/www/html/public/"; $tmpImg = $_FILES["pp"]["tmp_name"]; $avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/"; @@ -16,17 +16,17 @@ function updateAvatar(bool $group = false) { if ($_FILES["pp"]["size"] > 4000000) { throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); } - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif"; - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif"; + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); move_uploaded_file($tmpImg, $publicDir . $relativePath); } else { - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png"; + $relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png"; $scaledImg = scaleAvatar($tmpImg); - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); imagepng($scaledImg, $publicDir . $relativePath); } - $group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath); + $group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath); throw new HappyAlert("Profielfoto veranderd."); } diff --git a/website/views/createGroup.php b/website/views/createGroup.php new file mode 100644 index 0000000..736fc45 --- /dev/null +++ b/website/views/createGroup.php @@ -0,0 +1,42 @@ + + +
+
+
+
Maak een groep!
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+
diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php new file mode 100644 index 0000000..66b38f5 --- /dev/null +++ b/website/views/groupAdmin.php @@ -0,0 +1,77 @@ + +
+
+ +
+ +
+ +
+
Groep Instellingen
+ "> +
    +
  • + + " + > +
  • +
  • + + + +
  • +
  • + + +
  • +
+
+
+
Verander groepsafbeelding.
+ "> +
    +
  • + + " + class="group-picture" + > +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+
\ No newline at end of file diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..03e0f56 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -14,7 +14,7 @@ +
+ +
\ No newline at end of file From 74e91ed7cb18acebaabd5b6356f87aec25830977 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 21:14:25 +0100 Subject: [PATCH 33/37] Add mods/admin to a group. --- website/public/groupAdmin.php | 27 ++++++++++++++----- website/queries/groupAdmin.php | 48 ++++++++++++++++++++++++++++++++++ website/queries/settings.php | 15 +++++++++++ website/views/groupAdmin.php | 29 ++++++++++++++++++++ 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php index 13ff7e0..6095149 100644 --- a/website/public/groupAdmin.php +++ b/website/public/groupAdmin.php @@ -23,12 +23,27 @@ $alertClass; $alertMessage; if ($_SERVER["REQUEST_METHOD"] == "POST") { try { - if ($_POST["form"] == "group") { - updateGroupSettings($_POST["groupID"]); - } else if ($_POST["form"] == "picture") { - if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { - updateAvatar($_POST["groupID"]); - } + switch ($_POST["form"]) { + case "group": + updateGroupSettings($_POST["groupID"]); + break; + case "picture": + if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { + updateAvatar($_POST["groupID"]); + } + break; + case "mod": + if (!array_key_exists("userID", $_POST)) { + throw new AngryAlert("Geen gebruiker geselecteerd."); + } + upgradeUser($_POST["groupID"], $_POST["userID"], "mod"); + break; + case "admin": + if (!array_key_exists("userID", $_POST)) { + throw new AngryAlert("Geen gebruiker geselecteerd."); + } + upgradeUser($_POST["groupID"], $_POST["userID"], "admin"); + break; } } catch (AlertMessage $w) { $alertClass = $w->getClass(); diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php index ae2abd3..e3580b6 100644 --- a/website/queries/groupAdmin.php +++ b/website/queries/groupAdmin.php @@ -58,4 +58,52 @@ function checkGroupAdmin(int $groupID, int $userID) : bool { } $role = $stmt->fetch()["role"]; return ($role == "admin"); +} + +function getAllGroupMembers(int $groupID) { + $stmt = prepareQuery(" + SELECT + `username`, + `user`.`userID`, + CONCAT(`fname`, ' ', `lname`) AS `fullname`, + `group_member`.`role` + FROM + `group_member` + LEFT JOIN + `user` + ON + `group_member`.`userID` = `user`.`userID` + WHERE + `groupID` = :groupID AND `group_member`.`role` = 'member' + "); + + $stmt->bindParam(':groupID', $groupID); + if (!$stmt->execute()) { + return False; + } + return $stmt->fetchAll(); +} + +function upgradeUser(int $groupID, int $userID, string $role) { + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Geen toestemming om te wijzigen"); + } + + $stmt = prepareQuery(" + UPDATE + `group_member` + SET + `role` = :role + WHERE + `userID` = :userID AND `groupID` = :groupID + "); + $stmt->bindValue(":groupID", $groupID); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":role", $role); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Permissie aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } } \ No newline at end of file diff --git a/website/queries/settings.php b/website/queries/settings.php index 9b17d17..26237ec 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -148,6 +148,10 @@ function doChangePassword() { } } +/** + * Changes the users email if it is valid. + * @throws AngryAlert + */ function changeEmail() { if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) { @@ -164,6 +168,11 @@ function changeEmail() { } } +/** + * Checks if an emailadres is available in the database. + * @param $email + * @throws AngryAlert + */ function emailIsAvailableInDatabase($email) { $stmt = prepareQuery(" SELECT @@ -181,6 +190,12 @@ function emailIsAvailableInDatabase($email) { } } +/** + * Does the actual changing of an email-adress. + * @param $email + * @throws AngryAlert + * @throws HappyAlert + */ function doChangeEmail($email) { $stmt = prepareQuery(" UPDATE diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php index a28553e..54fbee8 100644 --- a/website/views/groupAdmin.php +++ b/website/views/groupAdmin.php @@ -85,6 +85,35 @@ $groupinfo = getGroupSettings($_GET["groupID"]); +
+
Voeg een admin/mod toe
+
    + + " type="hidden"> + + + + + +
+
  • From 7e4107ac8b357bc1335c9657293182a5ce18720c Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:13:23 +0100 Subject: [PATCH 34/37] Added fancy buttons in profile --- website/public/js/friendButtons.js | 28 +++++++++++++++------------- website/public/js/groupButtons.js | 12 ++++++------ website/public/styles/post-popup.css | 12 ------------ website/public/styles/profile.css | 19 ++++++++++++------- website/views/post-view.php | 4 ++-- website/views/profile.php | 14 ++++++++++---- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 47c476a..303ccf9 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -19,24 +19,24 @@ function placeFriendButtons() { case "0": value1 = "request"; class1 = "green"; - text1 = "Bevriend"; - icon1 = "fa-handshake-o"; + text1 = "Word vrienden"; + icon1 = "fa-user-plus"; break; case "1": value1 = userID; class1 = "green"; text1 = "Chat"; - icon1 = "fa-comment-o"; + icon1 = "fa-comment"; value2 = "delete"; class2 = "red"; - text2 = "Verwijder"; - icon2 = "fa-times"; + text2 = "Ontvriend"; + icon2 = "fa-user-times"; break; case "2": value1 = "delete"; class1 = "red"; text1 = "Trek verzoek in"; - icon1 = "fa-cross"; + icon1 = "fa-times"; break; case "3": value1 = "accept"; @@ -51,16 +51,18 @@ function placeFriendButtons() { } $buttonContainer.append( - ""); + "
    "); $buttonContainer.append( - ""); + "
    "); - $buttonContainer.children().click(function() { + $buttonContainer.find("button").click(function() { if (isNaN(this.value)) editFriendship(userID, this.value); else if (this.value != "") diff --git a/website/public/js/groupButtons.js b/website/public/js/groupButtons.js index 549277d..caf3ab8 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -5,23 +5,23 @@ function placeGroupButtons() { if (data == 'none') { $buttonContainer.append( - ""); } else if (data == 'request') { $buttonContainer.append( - ""); } else if (data == 'admin') { $buttonContainer.append( - "" ); } else { $buttonContainer.append( - ""); } diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 9493b83..e82129b 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -92,16 +92,4 @@ .deleteButton { background-color: firebrick; float: right; -} - -.deleteButton i { - display: inline-block; -} - -.deleteButton:hover span { - display: inline-block; -} - -.deleteButton span { - display: none; } \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 18e105e..8a93d12 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -27,16 +27,21 @@ display: inline-block; } +.friend-button-container div, .status-buttons-container div { + width: 200px; + display: inline-block; +} + .friend-button-container button, .status-buttons-container button, .group-button-container button { display: block; + float: right; margin: 7px 0; font-size: 18px; } - -.friend-button-container button, .status-buttons-container button, .group-button-fixed { - width: 200px; +.status-buttons-container button { + float: left; } .group-button-container button { @@ -76,19 +81,19 @@ border: none; } -.group-button-fancy span { +.fancy-button span { display: none; } -.group-button-fancy:hover { +.fancy-button:hover { text-align: right; } -.group-button-fancy i { +.fancy-button i { display: inline-block; } -.group-button-fancy:hover span { +.fancy-button:hover span { display: inline-block; margin-right: 5px; } diff --git a/website/views/post-view.php b/website/views/post-view.php index 717e6a8..fadc791 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -13,11 +13,11 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
-
diff --git a/website/views/profile.php b/website/views/profile.php index 62157f4..0cb5cc2 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -7,10 +7,16 @@ <?= $user[" class="profile-picture main-picture " src="">
- - +
+ +
+
+ +

:)

From 6d739a4480019709d6abe9addea37ade0ebbc34d Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:24:38 +0100 Subject: [PATCH 35/37] Chat is now only loading the last 100 messages --- website/queries/private_message.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 3b88563..f2df887 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -6,18 +6,23 @@ function getOldChatMessages($user2ID) { if (getFriendshipStatus($user2ID) == 1) { $stmt = prepareQuery(" SELECT - * + * FROM - `private_message` - WHERE - `origin` = :user1 AND - `destination` = :user2 OR - `origin` = :user2 AND - `destination` = :user1 + (SELECT + * + FROM + `private_message` + WHERE + `origin` = :user1 AND + `destination` = :user2 OR + `origin` = :user2 AND + `destination` = :user1 + ORDER BY + `messageID` DESC + LIMIT + 100) sub ORDER BY - `creationdate` ASC - LIMIT - 100 + `messageID` ASC "); $stmt->bindParam(":user1", $user1ID); @@ -76,7 +81,7 @@ function getNewChatMessages($lastID, $destination) { `destination` = :user1) AND `messageID` > :lastID ORDER BY - `creationdate` ASC + `messageID` ASC "); $stmt->bindParam(':user1', $_SESSION["userID"]); From 02349dbe2846597ee77772bfef19eeb454455419 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 10:30:44 +0100 Subject: [PATCH 36/37] Changed description --- website/public/js/friendButtons.js | 4 ++-- website/views/head.php | 2 +- website/views/login_head.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 303ccf9..87222e9 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -53,12 +53,12 @@ function placeFriendButtons() { $buttonContainer.append( "
"); $buttonContainer.append( "
"); diff --git a/website/views/head.php b/website/views/head.php index 52bcab8..3ec8a79 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,5 +1,5 @@ - + MyHyvesbook+ diff --git a/website/views/login_head.php b/website/views/login_head.php index b4b2724..9e580df 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,6 +1,6 @@ - + MyHyvesbook+ From ecd24ef442190bfbc986266f411a440d4a5f9274 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 10:34:07 +0100 Subject: [PATCH 37/37] Revert "Merge branch 'joey-testing' into 'master'" This reverts merge request !196 --- website/views/homeLoginRegister.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index 24fa266..ad7be40 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -29,12 +29,13 @@ $user = $psw = $remember =""; $loginErr = $resetErr = $fbRegisterErr =""; if ($_SERVER["REQUEST_METHOD"] == "POST") { + $url = $_POST["url"]; // Checks for which button is pressed switch ($_POST["submit"]) { case "login": try { $user = ($_POST["user"]); - validateLogin($_POST["user"], $_POST["psw"], $_POST["url"];); + validateLogin($_POST["user"], $_POST["psw"], $url); } catch(loginException $e) { $loginErr = $e->getMessage(); }