diff --git a/website/public/API/loadFriendRequest.php b/website/public/API/loadFriendRequest.php index b99d2c3..02dedb3 100644 --- a/website/public/API/loadFriendRequest.php +++ b/website/public/API/loadFriendRequest.php @@ -4,5 +4,12 @@ session_start(); require_once ("../../queries/connect.php"); require_once ("../../queries/friendship.php"); +require_once ("../../queries/user.php"); -echo selectAllFriendRequests(); \ No newline at end of file +if (isset($_SESSION["userID"]) && + getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { + echo selectAllFriendRequests(); +} else { + echo "[]"; +} diff --git a/website/public/API/loadFriends.php b/website/public/API/loadFriends.php index 38158c9..c5c8797 100644 --- a/website/public/API/loadFriends.php +++ b/website/public/API/loadFriends.php @@ -6,11 +6,15 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/checkInput.php"); require_once ("../../queries/friendship.php"); -if (isset($_POST["limit"])) { - echo selectLimitedFriends($_SESSION["userID"], (int) test_input($_POST["limit"])); -} else if (isset($_GET["limit"])) { - echo selectLimitedFriends($_SESSION["userID"], (int) test_input($_GET["limit"])); +if (isset($_SESSION["userID"])) { + if (isset($_POST["limit"])) { + echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"])); + } else if (isset($_GET["limit"])) { + echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_GET["limit"])); + } else { + echo selectFriends($_SESSION["userID"]); + } } else { - echo selectFriends($_SESSION["userID"]); + echo "[]"; } diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index e1d7617..3864cc8 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -2,28 +2,36 @@ session_start(); -require("../../queries/post.php"); +require_once("../../queries/post.php"); require_once("../../queries/connect.php"); -require("../../queries/checkInput.php"); -print_r($_POST); -if ($_POST['button'] == 'reaction') { - if (empty($_POST['newcomment-content'])) { - echo 0; - } else { - if (makeComment($_POST['postID'], - $_SESSION['userID'], - test_input($_POST['newcomment-content']))) { +require_once("../../queries/checkInput.php"); +require_once("../../queries/user.php"); + + +if (isset($_SESSION["userID"]) && + getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { + if ($_POST['button'] == 'reaction') { + if (empty($_POST['newcomment-content'])) { + echo 0; + } else { + if (makeComment($_POST['postID'], + $_SESSION['userID'], + test_input($_POST['newcomment-content']))) { + echo 1; + } else { + echo 0; + } + } + } else if ($_POST['button'] == 'nietslecht') { + if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) { echo 1; } else { echo 0; } - } -} else if ($_POST['button'] == 'nietslecht') { - if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) { - echo 1; } else { echo 0; } } else { - echo 0; + echo "frozen"; } \ No newline at end of file diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b52e96b..7a33857 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -2,16 +2,53 @@ session_start(); -require("../../queries/post.php"); -require("../../queries/connect.php"); -require("../../queries/checkInput.php"); +require_once("../../queries/post.php"); +require_once("../../queries/group_page.php"); +require_once("../../queries/connect.php"); +require_once("../../queries/checkInput.php"); -if (empty($_POST['newpost-title'])) { -} else { - makePost($_SESSION['userID'], - null, - test_input($_POST['newpost-title']), - test_input($_POST['newpost-content'])); +if (empty($_POST["title"]) or + empty($_POST["content"]) or + empty($_SESSION["userID"])) { + header('HTTP/1.1 500 Non enough arguments'); } -header("Location: ../profile.php"); \ No newline at end of file +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; + } + + makePost( + $_SESSION["userID"], + $_POST["group"], + test_input($_POST["title"]), + test_input($_POST["content"]) + ); +} + + + + + + +//if (empty($_POST['newpost-title'])) { +//} else { +// makePost($_SESSION['userID'], +// null, +// test_input($_POST['newpost-title']), +// test_input($_POST['newpost-content'])); +//} +// +//header("Location: ../profile.php"); \ No newline at end of file diff --git a/website/public/API/searchPageNumber.php b/website/public/API/searchPageNumber.php new file mode 100644 index 0000000..4a76516 --- /dev/null +++ b/website/public/API/searchPageNumber.php @@ -0,0 +1,41 @@ +fetchColumn(); +$group_count = countSomeGroups($search)->fetchColumn(); + +$filter = "all"; +if (isset($_POST['filter'])) { + $filter = test_input($_POST['filter']); +} + +$option = "user"; +if (isset($_POST['option'])) { + $option = test_input($_POST['option']); +} + +include ("../../views/searchPageNumber.php"); diff --git a/website/public/API/searchUsers.php b/website/public/API/searchUsers.php index 15b03ed..f431f88 100644 --- a/website/public/API/searchUsers.php +++ b/website/public/API/searchUsers.php @@ -8,13 +8,15 @@ require_once ("../../queries/friendship.php"); require_once ("../../queries/user.php"); $n = 0; -if (isset($_POST["n"])) { - $n = (int) test_input($_POST["n"]); -} $m = 20; -if (isset($_POST["m"])) { - $m = (int) test_input($_POST["m"]); + +$page = 1; +if (isset($_POST["user-pageselect"])) { + $page = (int) test_input($_POST['user-pageselect']); } + +$n = ($page - 1) * $m; + $search = ""; if (isset($_POST["search"])) { $search = test_input($_POST["search"]); diff --git a/website/public/API/sendMessage.php b/website/public/API/sendMessage.php index c5d47d1..2d0b092 100644 --- a/website/public/API/sendMessage.php +++ b/website/public/API/sendMessage.php @@ -4,14 +4,22 @@ session_start(); require_once("../../queries/connect.php"); require_once("../../queries/private_message.php"); require_once("../../queries/checkInput.php"); +require_once("../../queries/user.php"); -if (!empty(test_input($_POST["destination"])) && - !empty(test_input($_POST["content"]))) { - if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) { - echo 1; +if (isset($_SESSION["userID"]) && + getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { + if (!empty(test_input($_POST["destination"])) && + !empty(test_input($_POST["content"])) + ) { + if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) { + echo 1; + } else { + echo 0; + } } else { echo 0; } } else { - echo 0; + echo "frozen"; } \ No newline at end of file diff --git a/website/public/admin.php b/website/public/admin.php index 13a025d..ddcbbf2 100644 --- a/website/public/admin.php +++ b/website/public/admin.php @@ -19,9 +19,9 @@ include_once ("../queries/user.php"); // auth -$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC); +$role = getRoleByID($_SESSION['userID']); -if ($userinfo['role'] != 'admin' AND $userinfo['role'] != 'owner') { +if ($role != 'admin' AND $role != 'owner') { header("location:profile.php"); } diff --git a/website/public/bits/friend-item.php b/website/public/bits/friend-item.php index a69d12a..40bc8a8 100644 --- a/website/public/bits/friend-item.php +++ b/website/public/bits/friend-item.php @@ -33,7 +33,7 @@ foreach($friends as $i => $friend) { } ?>'>
- PF + PF
fullname ?>
diff --git a/website/public/js/chat.js b/website/public/js/chat.js index e35f85c..1d70834 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -33,7 +33,11 @@ function sendMessage() { $.post( "API/sendMessage.php", $("#sendMessageForm").serialize() - ); + ).done(function(response) { + if (response == "frozen") { + alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is."); + } + }); $("#newContent").val(""); loadMessages(); diff --git a/website/public/js/main.js b/website/public/js/main.js index d23bbbf..2983fdb 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -3,7 +3,7 @@ var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "a function fancyText(text) { // Add links, images, gifs and (youtube) video's. - var regex = /(https?:\/\/.[^ ]*)/ig; + var regex = /(https?:\/\/.[^ <>"]*)/ig; text = text.replace(regex, function(link) { // Add images if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) { @@ -93,4 +93,14 @@ function showGroups(groups, list) { } else { return false; } -} \ No newline at end of file +} + +$(document).ready(function() { + $("body").delegate("textarea[maxlength]", "keydown", function() { + if ($(this).val().length / .9 >= $(this).attr("maxlength")) { + $(this).next().text($(this).val().length + "/" + $(this).attr("maxlength")); + } else { + $(this).next().text(""); + } + }); +}); \ No newline at end of file diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 8d2080b..b4370b7 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -19,10 +19,32 @@ function requestPost(postID) { var scrollBarWidth = window.innerWidth - document.body.offsetWidth; scrollbarMargin(scrollBarWidth, 'hidden'); $('#modal-response').show(); - $('#modal-response').html(data); + $('#modal-response').html(fancyText(data)); }); } +function postPost() { + title = $("input.newpost[name='title']").val(); + content = $("textarea.newpost[name='content']").val(); + + if (masonryMode == 2) { + $.post("API/postPost.php", { title: title, + content : content, + group : groupID }) + .done(function() { + masonry(masonryMode); + }); + } else { + $.post("API/postPost.php", { title: title, + content : content }) + .done(function() { + masonry(masonryMode); + }); + } + + +} + $(window).on("load", function() { $(".modal-close").click(function () { $(".modal").hide(); @@ -33,11 +55,15 @@ $(window).on("load", function() { }); var masonryMode = 0; +var windowWidth = $(window).width(); $(window).resize(function() { clearTimeout(window.resizedFinished); window.resizeFinished = setTimeout(function() { - masonry(masonryMode); + if ($(window).width() != windowWidth) { + windowWidth = $(window).width(); + masonry(masonryMode); + } }, 250); }); @@ -52,7 +78,7 @@ function masonry(mode) { * Initialise columns. */ var columns = new Array(columnCount); - var $columns = new Array(columnCount); + for (i = 0; i < columnCount; i++) { $column = $("
"); $column.width(100/columnCount + "%"); @@ -60,13 +86,17 @@ function masonry(mode) { columns[i] = [0, $column]; } - if(mode == 1) { + if(mode > 0) { $postInput = $("
"); - $form = $("
"); + $form = $(""); $postInput.append($form); - $form.append($("")); - $form.append($("")); $form.append($("")); columns[0][1].append($postInput); @@ -100,7 +130,7 @@ function masonry(mode) { $.each(posts, function() { $post = $("
"); $post.append($("

").html(this["title"])); - $post.append($("

").html(this["content"])); + $post.append($("

").html(fancyText(this["content"]))); $post.append($("

").text(this["nicetime"])); $post.append($("

").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"])); diff --git a/website/public/js/post.js b/website/public/js/post.js index 4a8ebc7..27bc34e 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -4,8 +4,10 @@ function postComment(buttonValue) { $.post( "API/postComment.php", formData - ).done(function(data) { - console.log(data); + ).done(function (response) { + if (response == "frozen") { + alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is."); + } }); $("#newcomment").val(""); @@ -15,6 +17,6 @@ function postComment(buttonValue) { "API/loadPost.php", $("#newcommentform").serialize() ).done(function (data) { - $('#modal-response').html(data); + $('#modal-response').html(fancyText(data)); }); } \ No newline at end of file diff --git a/website/public/js/search.js b/website/public/js/search.js index c026b64..f7c4bbe 100644 --- a/website/public/js/search.js +++ b/website/public/js/search.js @@ -1,12 +1,11 @@ -function searchUsers(n, m) { +$(window).on('load', function () { + pageNumber(); +}); + +function searchUsers() { $.post( "API/searchUsers.php", - { - n: n, - m: m, - search: $("#search-input").val(), - filter: $("#search-filter").val() - } + $('#search-form').serialize() ).done(function(data) { if (!showFriends(data, "#search-users-list", 0, "profile.php", "GET")) { $("#search-users-list").text("Niemand gevonden"); @@ -14,18 +13,29 @@ function searchUsers(n, m) { }); } -function searchGroups(n, m) { +function searchGroups() { $.post( "API/searchGroups.php", - { - n: n, - m: m, - search: $("#search-input").val(), - filter: $("#search-filter").val() - } + $('#search-form').serialize() ).done(function(data) { if (!showGroups(data, "#search-groups-list")) { $("#search-groups-list").text("Geen groepen gevonden"); } }); +} + +function pageNumber() { + var input = input2 = $('#search-form').serialize(); + $.post( + "API/searchPageNumber.php", + input + "&option=user" + ).done(function (data) { + $('#user-pageselect').html(data); + }); + $.post( + "API/searchPageNumber.php", + input2 + "&option=group" + ).done(function (data) { + $('#group-pageselect').html(data); + }); } \ No newline at end of file diff --git a/website/public/profile.php b/website/public/profile.php index 83b9d10..05c661d 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -13,10 +13,11 @@ = DATE_SUB(NOW(),INTERVAL 15 MINUTE) + WHEN TRUE THEN 'online' + WHEN FALSE THEN 'offline' + END AS `onlinestatus`, `role` FROM `user` @@ -28,11 +32,8 @@ function selectLimitedFriends($userID, $limit) { `friendship`.`user1ID` = `user`.`userID`) AND `user`.`role` != 'banned' AND `friendship`.`status` = 'confirmed' - ORDER BY - CASE - WHEN `friendship`.`user2ID` = `user`.`userID` THEN `friendship`.`chatLastVisted1` - WHEN `friendship`.`user1ID` = `user`.`userID` THEN `friendship`.`chatLastVisted2` - END + ORDER BY + `user`.`lastactivity` DESC LIMIT :limitCount "); diff --git a/website/queries/group_page.php b/website/queries/group_page.php index b3e454c..83911f8 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -11,6 +11,12 @@ function selectGroupByName($name) { `description`, `picture`, `status`, + ( + SELECT `role` + FROM `group_member` + WHERE `group_member`.`groupID` = `group_page`.`groupID` AND + `userID` = :userID + ) AS `role`, COUNT(`group_member`.`groupID`) as `members` FROM `group_page` @@ -22,13 +28,36 @@ function selectGroupByName($name) { name LIKE :name "); - $stmt->bindParam(':name', $name); + $stmt->bindParam(':name', $name, PDO::PARAM_STR); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); if (!$stmt->execute()) { return False; } return $stmt->fetch(); } +function selectGroupRole(int $groupID) { + $stmt = prepareQuery(" + SELECT + `role` + FROM + `group_member` + WHERE + `groupID` = :groupID AND + `userID` = :userID + "); + + $stmt->bindParam(':groupID', $groupID, PDO::PARAM_INT); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); + if(!$stmt->execute()) { + return False; + } + if($stmt->rowCount() == 0) { + return "none"; + } + return $stmt->fetch()["role"]; +} + function selectGroupMembers(int $groupID) { $stmt = prepareQuery(" SELECT diff --git a/website/queries/picture.php b/website/queries/picture.php new file mode 100644 index 0000000..8e99d9a --- /dev/null +++ b/website/queries/picture.php @@ -0,0 +1,138 @@ + 4000000) { + throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); + } + $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif"; + $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + move_uploaded_file($tmpImg, $publicDir . $relativePath); + } else { + $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png"; + $scaledImg = scaleAvatar($tmpImg); + $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + imagepng($scaledImg, $publicDir . $relativePath); + } + + $group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath); + throw new HappyAlert("Profielfoto veranderd."); +} + +/** + * Removes the old avatar from the uploads folder, for a user. + */ +function removeOldUserAvatar() { + $stmt = prepareQuery(" + SELECT + `profilepicture` + FROM + `user` + WHERE + `userID` = :userID + "); + $stmt->bindParam(":userID", $_SESSION["userID"]); + $stmt->execute(); + $old_avatar = $stmt->fetch()["profilepicture"]; + if ($old_avatar != NULL) { + unlink("/var/www/html/public/uploads/" . $old_avatar); + } +} +/** + * Removes the old avatar from the uploads folder, for a group. + * @param int $groupID + */ +function removeOldGroupAvatar(int $groupID) { + $stmt = prepareQuery(" + SELECT + `picture` + FROM + `group_page` + WHERE + groupID = :groupID + "); + $stmt->bindParam(":groupID", $groupID); + $stmt->execute(); + $old_avatar = $stmt->fetch()["picture"]; + if ($old_avatar != NULL) { + unlink("/var/www/html/public/uploads/" . $old_avatar); + } +} + +/** + * Inserts the the path to the avatar into the database, for Users. + * @param string $url path to the avatar + */ +function setUserAvatarToDatabase(string $url) { + $stmt = prepareQuery(" + UPDATE + `user` + SET + `profilepicture` = :avatar + WHERE + `userID` = :userID + "); + + $stmt->bindParam(":avatar", $url); + $stmt->bindParam(":userID", $_SESSION["userID"]); + $stmt->execute(); +} + +/** + * Inserts the the path to the avatar into the database, for Groups. + * @param string $url path to the avatar + * @param int $groupID + */ +function setGroupAvatarToDatabase(string $url, int $groupID) { + $stmt = prepareQuery(" + UPDATE + `group_page` + SET + `picture` = :avatar + WHERE + `groupID` = :groupID + "); + $stmt->bindParam(":avatar", $url); + $stmt->bindParam(":groupID", $groupID); + $stmt->execute(); +} + +/** + * Checks the resoluton of a picture. + * @param string $img + * @throws AngryAlert + */ +function checkAvatarSize(string $img) { + $minResolution = 200; + $imgSize = getimagesize($img); + if ($imgSize[0] < $minResolution or $imgSize[1] < $minResolution) { + throw new AngryAlert("Afbeelding te klein, minimaal 200x200 pixels."); + } +} + +/** + * Scales a picture, standard width is 600px. + * @param string $imgLink Path to a image file + * @param int $newWidth Custom image width. + * @return bool|resource Returns the image as an Resource. + * @throws AngryAlert + */ +function scaleAvatar(string $imgLink, int $newWidth = 600) { + $img = imagecreatefromstring(file_get_contents($imgLink)); + if ($img) { + return imagescale($img, $newWidth); + } else { + throw new AngryAlert("Afbeelding wordt niet ondersteund."); + } +} \ No newline at end of file diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 430fddb..4ac04a7 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -16,6 +16,8 @@ function getOldChatMessages($user2ID) { `destination` = :user1 ORDER BY `creationdate` ASC + LIMIT + 100 "); $stmt->bindParam(":user1", $user1ID); diff --git a/website/queries/settings.php b/website/queries/settings.php index bdc9d38..03f794f 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -1,49 +1,7 @@ 4000000) { - throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); - } - $relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.gif"; - move_uploaded_file($tmpImg, $profilePictureDir . $relativePath); - } else { - $relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.png"; - $scaledImg = scaleAvatar($tmpImg); - imagepng($scaledImg, $profilePictureDir . $relativePath); - } - removeOldAvatar(); - setAvatarToDatabase("../" . $relativePath); - throw new HappyAlert("Profielfoto veranderd."); -} - -function removeOldAvatar() { - $stmt = prepareQuery(" - SELECT - `profilepicture` - FROM - `user` - WHERE - `userID` = :userID - "); - $stmt->bindParam(":userID", $_SESSION["userID"]); - $stmt->execute(); - $old_avatar = $stmt->fetch()["profilepicture"]; - if ($old_avatar != NULL) { - unlink("/var/www/html/public/uploads/" . $old_avatar); - } -} - -function setAvatarToDatabase(string $url) { - $stmt = prepareQuery(" - UPDATE - `user` - SET - `profilepicture` = :avatar - WHERE - `userID` = :userID - "); - - $stmt->bindParam(":avatar", $url); - $stmt->bindParam(":userID", $_SESSION["userID"]); - $stmt->execute(); -} - -function checkAvatarSize(string $img) { - $minResolution = 200; - $imgSize = getimagesize($img); - if ($imgSize[0] < $minResolution or $imgSize[1] < $minResolution) { - throw new AngryAlert("Afbeelding te klein, minimaal 200x200 pixels."); - } -} - -function scaleAvatar(string $imgLink, int $newWidth = 600) { - $img = imagecreatefromstring(file_get_contents($imgLink)); - if ($img) { - return imagescale($img, $newWidth); - } else { - throw new AngryAlert("Afbeelding wordt niet ondersteund."); - } } \ No newline at end of file diff --git a/website/queries/user.php b/website/queries/user.php index 39f1c4e..e712a6c 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -2,6 +2,19 @@ require_once ("connect.php"); +function updateLastActivity() { + $stmt = prepareQuery(" + UPDATE + `user` + SET + `lastactivity` = NOW() + WHERE + `userID` = :userID + "); + $stmt->bindParam(":userID", $_SESSION["userID"]); + return $stmt->execute(); +} + function getUserID($username) { $stmt = prepareQuery(" SELECT @@ -107,48 +120,6 @@ function selectAllUserGroups($userID) { return $stmt; } -function selectAllUserPosts($userID) { - $stmt = prepareQuery(" - SELECT - `post`.`postID`, - `post`.`author`, - `title`, - CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE 'bindParam(':userID', $userID, PDO::PARAM_INT); - if(!$stmt->execute()) { - return False; - } - return $stmt; -} - function select20UsersFromN($n) { $q = prepareQuery(" SELECT @@ -396,9 +367,10 @@ function countSomeUsers($search) { FROM `user` WHERE - `username` LIKE :keyword OR + (`username` LIKE :keyword OR `fname` LIKE :keyword OR - `lname` LIKE :keyword + `lname` LIKE :keyword) AND + `role` != 'banned' ORDER BY `fname`, `lname`, @@ -423,7 +395,7 @@ function getRoleByID($userID) { $stmt->bindParam(':userID', $userID); $stmt->execute(); - return $stmt; + return $stmt->fetch()["role"]; } function editBanCommentByID($userID, $comment) { diff --git a/website/views/group.php b/website/views/group.php index 24cf9d5..f2f797d 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -1,6 +1,6 @@

- +

Groep verlaten

diff --git a/website/views/head.php b/website/views/head.php index 6e8ca0a..284abb4 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -19,9 +19,12 @@ require_once ("../queries/checkInput.php"); require_once ("../queries/connect.php"); +require_once ("../queries/user.php"); session_start(); if(!isset($_SESSION["userID"])){ header("location:login.php"); -} \ No newline at end of file +} else { + updateLastActivity(); +} diff --git a/website/views/header.php b/website/views/header.php index 9d2aa56..c1379fc 100644 --- a/website/views/header.php +++ b/website/views/header.php @@ -25,8 +25,7 @@ $userinfo = getHeaderInfo();
- "/> - + "/>

diff --git a/website/views/notification-center.php b/website/views/notification-center.php index 7630b75..7bd03ea 100644 --- a/website/views/notification-center.php +++ b/website/views/notification-center.php @@ -7,9 +7,9 @@ include_once ("../queries/user.php"); // auth - $userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC); + $role = getRoleByID($_SESSION['userID']); - if ($userinfo['role'] == 'admin' OR $userinfo['role'] == 'owner') { + if ($role == 'admin' OR $role == 'owner') { echo ""; echo ""; } diff --git a/website/views/post-view.php b/website/views/post-view.php index 264d67c..d961334 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -24,7 +24,7 @@ echo("
-
+
@@ -29,7 +29,7 @@

Informatie

    -
  • Geboren op:
  • +
  • Leeftijd: jaar
  • Locatie:
  • Lid sinds:
diff --git a/website/views/search-view.php b/website/views/search-view.php index 392ea45..e42f985 100644 --- a/website/views/search-view.php +++ b/website/views/search-view.php @@ -21,10 +21,8 @@ if (isset($_GET['filter'])) { } $user_n = ($user_currentpage - 1) * $user_perpage; -$user_count = countSomeUsers($search)->fetchColumn(); $group_n = ($group_currentpage - 1) * $group_perpage; -$group_count = countSomeGroups($search)->fetchColumn(); ?>
@@ -40,8 +38,10 @@ $group_count = countSomeGroups($search)->fetchColumn(); id="search-input" name="search" onkeyup=" - searchUsers(, ); - searchGroups(, );" + $('#user-pagenumber, #group-pagenumber').prop('value', 1); + searchUsers(); + searchGroups(); + pageNumber();" placeholder="Zoek" value= > @@ -66,26 +66,12 @@ $group_count = countSomeGroups($search)->fetchColumn();

Gebruikers

- +
@@ -94,26 +80,12 @@ $group_count = countSomeGroups($search)->fetchColumn();

Groepen

- +
diff --git a/website/views/searchPageNumber.php b/website/views/searchPageNumber.php new file mode 100644 index 0000000..b98d4ef --- /dev/null +++ b/website/views/searchPageNumber.php @@ -0,0 +1,36 @@ +"; + + for ($i=1; $i <= ceil($user_count / $user_perpage); $i++) { + if ($user_currentpage == $i) { + echo ""; + } else { + echo ""; + } + } + + echo ""; +} else { + echo ""; +} + +?> diff --git a/website/views/settings-view.php b/website/views/settings-view.php index b7f554a..41f093e 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -99,7 +99,8 @@ $settings = getSettings(); rows="5" title="bio" id="bio" - > + maxlength="1000" + >