diff --git a/website/public/API/deletePost.php b/website/public/API/deletePost.php index fffadf5..37f89a1 100644 --- a/website/public/API/deletePost.php +++ b/website/public/API/deletePost.php @@ -3,10 +3,10 @@ session_start(); require_once "../../queries/post.php"; require_once "../../queries/user.php"; - -if (isset($_SESSION["userID"]) and - getRoleByID($_SESSION["userID"]) != 'frozen' and - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' and + getRoleByID($_SESSION["userID"]) != 'banned') { if (empty($_POST["postID"]) or empty($_SESSION["userID"])) { header('HTTP/1.1 500 Non enough arguments'); diff --git a/website/public/API/loadChatNotifications.php b/website/public/API/loadChatNotifications.php index baceabc..8ef0aa5 100644 --- a/website/public/API/loadChatNotifications.php +++ b/website/public/API/loadChatNotifications.php @@ -6,6 +6,7 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/private_message.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { echo selectAllUnreadChat(); diff --git a/website/public/API/loadFriendRequest.php b/website/public/API/loadFriendRequest.php index 91a1cc7..7eca6a8 100644 --- a/website/public/API/loadFriendRequest.php +++ b/website/public/API/loadFriendRequest.php @@ -6,6 +6,7 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/friendship.php"); require_once ("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'frozen' && getRoleByID($_SESSION["userID"]) != 'banned') { diff --git a/website/public/API/loadFriends.php b/website/public/API/loadFriends.php index b59b34c..13a25d8 100644 --- a/website/public/API/loadFriends.php +++ b/website/public/API/loadFriends.php @@ -7,9 +7,11 @@ require_once ("../../queries/checkInput.php"); require_once ("../../queries/friendship.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { if (isset($_SESSION["userID"])) { + // Echo the limited or unlimited users. if (isset($_POST["limit"])) { echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"])); } else if (isset($_GET["limit"])) { diff --git a/website/public/API/loadGroups.php b/website/public/API/loadGroups.php index 3c562b1..5bbc111 100644 --- a/website/public/API/loadGroups.php +++ b/website/public/API/loadGroups.php @@ -8,8 +8,10 @@ require_once ("../../queries/group_member.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { + // Echo the limited or unlimited groups. if (isset($_POST["limit"])) { echo selectLimitedGroupsFromUser($_SESSION["userID"], (int)test_input($_POST["limit"])); } else { diff --git a/website/public/API/loadMessages.php b/website/public/API/loadMessages.php index d78d058..d1a7e15 100644 --- a/website/public/API/loadMessages.php +++ b/website/public/API/loadMessages.php @@ -8,8 +8,10 @@ require_once("../../queries/checkInput.php"); require_once("../../queries/friendship.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to get the messages. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { + // Check if the users wants new messages or old ones, and give the right one back. if (isset($_POST["lastID"]) && $_POST["lastID"] != "") { setLastVisited(test_input($_POST["destination"])); echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"])); diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index 3864cc8..c9f8a53 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -7,10 +7,10 @@ require_once("../../queries/connect.php"); require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); - -if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'frozen' && - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { if ($_POST['button'] == 'reaction') { if (empty($_POST['newcomment-content'])) { echo 0; diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b1c6649..2d703d3 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -8,40 +8,44 @@ require_once("../../queries/connect.php"); require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); -if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'frozen' && - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (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/API/searchPageNumber.php b/website/public/API/searchPageNumber.php index df5483a..8248c34 100644 --- a/website/public/API/searchPageNumber.php +++ b/website/public/API/searchPageNumber.php @@ -6,11 +6,11 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/checkInput.php"); require_once ("../../queries/user.php"); require_once ("../../queries/group_page.php"); +require_once ("../../queries/friendship.php"); +require_once ("../../queries/group_member.php"); if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'banned') { - - $user_perpage = $group_perpage = 20; + getRoleByID($_SESSION["userID"]) != 'banned') {$user_perpage = $group_perpage = 20; $user_currentpage = $group_currentpage = 1; if (isset($_POST['user-pageselect'])) { @@ -28,20 +28,26 @@ if (isset($_SESSION["userID"]) && $search = test_input($_POST['search']); } - $user_count = countSomeUsers($search)->fetchColumn(); - $group_count = countSomeGroups($search)->fetchColumn(); - $filter = "all"; if (isset($_POST['filter'])) { $filter = test_input($_POST['filter']); } + if ($filter == "all") { + $user_count = countSomeUsers($search)->fetchColumn(); + $group_count = countSomeGroups($search)->fetchColumn(); + } else { + $user_count = countSomeFriends($search); + $group_count = countSomeOwnGroups($search); + } + + $option = "user"; if (isset($_POST['option'])) { $option = test_input($_POST['option']); } - include("../../views/searchPageNumber.php"); + include ("../../views/searchPageNumber.php"); } else { header('HTTP/1.0 403 Forbidden'); -} \ No newline at end of file +} diff --git a/website/public/API/sendMessage.php b/website/public/API/sendMessage.php index 2d0b092..a2d411b 100644 --- a/website/public/API/sendMessage.php +++ b/website/public/API/sendMessage.php @@ -6,12 +6,16 @@ require_once("../../queries/private_message.php"); require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); -if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'frozen' && - getRoleByID($_SESSION["userID"]) != 'banned') { +// Check if the user is allowed to send a message. +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { if (!empty(test_input($_POST["destination"])) && !empty(test_input($_POST["content"])) ) { + // Send the message. + // Returns false when it didn't succeed sending the message. if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) { echo 1; } else { diff --git a/website/public/bits/friend-item.php b/website/public/bits/friend-item.php index 40bc8a8..6a0c868 100644 --- a/website/public/bits/friend-item.php +++ b/website/public/bits/friend-item.php @@ -4,6 +4,7 @@ session_start(); include_once ("../../queries/friendship.php"); +// Initialize variables to given or default values. if (isset($_POST["action"])) { $action = $_POST["action"]; } else { @@ -18,6 +19,8 @@ if (isset($_POST["actionType"])) { $friends = json_decode($_POST["friends"]); + +// Foreach friend, return them as list item. foreach($friends as $i => $friend) { $friendshipStatus = getFriendshipStatus($friend->userID); ?> @@ -38,7 +41,7 @@ foreach($friends as $i => $friend) { fullname ?>
username)) { - echo $friend->username; + echo $friend->usernameshort; } else if (isset($friend->content)) { echo $friend->content; } @@ -48,6 +51,7 @@ foreach($friends as $i => $friend) { 1) { if ($friendshipStatus == 2) { $denyName = "Annuleer"; diff --git a/website/public/bits/group-item.php b/website/public/bits/group-item.php index 92eccfc..dbe799d 100644 --- a/website/public/bits/group-item.php +++ b/website/public/bits/group-item.php @@ -6,6 +6,7 @@ include_once ("../../queries/group_member.php"); $groups = json_decode($_POST["groups"]); +// Add each group as list item. foreach($groups as $i => $group) { ?>
  • diff --git a/website/public/bits/niet-slecht.php b/website/public/bits/niet-slecht.php new file mode 100644 index 0000000..432fe41 --- /dev/null +++ b/website/public/bits/niet-slecht.php @@ -0,0 +1,8 @@ + +\"Niet slecht\" ons op MyHyvesbook+ 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/group.php b/website/public/group.php index 72da9c8..84726fa 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -13,13 +13,15 @@ include_once("../queries/group_page.php"); -$group = selectGroupByName($_GET["groupname"]); -$members = selectGroupMembers(2); +if(!$group = selectGroupByName($_GET["groupname"])) { + header("HTTP/1.0 404 Not Found"); + header("Location: error/404.php"); + die(); +} + + +$members = selectGroupMembers($group["groupID"]); -?> - - - + + + + + + + +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/public/js/chat.js b/website/public/js/chat.js index 6a027c8..f431b91 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -9,18 +9,25 @@ $(document).ready(function() { $(".chat-field").hide(); }); +// This function loads the new messages and runs the addMessages function to show them. function loadMessages() { + // If the function is not running elsewhere, run it here. if (!gettingMessages) { gettingMessages = true; + // Get the messages. $.post( "API/loadMessages.php", $("#lastIDForm").serialize() ).done(function (data) { + // Post the messages in the chat. if (data && data != "[]") { messages = JSON.parse(data); addMessages(messages); $("#lastID").val(messages[messages.length - 1].messageID); } + + loadUnreadMessages(); + gettingMessages = false; }); } else { @@ -28,7 +35,7 @@ function loadMessages() { } } - +// Send a message to a friend of the user. function sendMessage() { $.post( "API/sendMessage.php", @@ -36,43 +43,59 @@ function sendMessage() { ).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."); + } else if (response == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; } + // Load messages if the message has been send, so it shows in the chat. + loadMessages(); }); $("#newContent").val(""); - loadMessages(); } +// Add messages to the chat. function addMessages(messages) { var messagesText = ""; + + // Loop over all the messages. for(var i in messages) { - // Initialize message variables + // 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); + // See where the message has been send from, so it shows on the right side. if (messages[i].destination == $(".destinationID").val()) { type = "chat-message-self"; } else { type = "chat-message-other"; } + + // If it is the first message, open the message box and maybe add a year. if (i == 0) { + if (thisDate.getTime() > previousDate.getTime()) { + messagesText += '\ +
    \ +
    \ + ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ +
    \ +
    '; + } previousDate = thisDate; - messagesText += '\ -
    \ -
    \ - ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ -
    \ -
    '; + 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()) { + // Close the previous message. messagesText += '
    \ ' + thisTime + '\
    '; previousTime = thisTime; previousType = type; + // If the date is different, add a new date. if (thisDate > previousDate) { previousDate = thisDate; messagesText += '\ @@ -83,8 +106,11 @@ function addMessages(messages) { '; } + // Open the new message. messagesText += '
    '; } + + // Add the content of the message in the new box. messagesText += fancyText(messages[i].content) + "
    "; } @@ -93,11 +119,14 @@ function addMessages(messages) { ' + thisTime + '\
    '; + // Add all the new created messaged to the chat. $("#chat-history").append(messagesText); + // Scroll down, so the user can see the new messages. $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight); } +// Switch to a different user. function switchUser(userID) { previousDate = new Date("1970-01-01 00:00:00"); $(".chat-field").show(); @@ -108,6 +137,7 @@ function switchUser(userID) { $("#friend-item-" + userID).addClass("active-friend-chat"); } +// Insert a message in the chat, this is used when it is empty. function sayEmpty() { $("#chat-history").html("Probeer ook eens foto's en video's te sturen"); } \ No newline at end of file diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 47c476a..87222e9 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 e6ada67..caf3ab8 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -3,31 +3,41 @@ function placeGroupButtons() { .done(function(data) { var $buttonContainer = $("div.group-button-container"); - if(data == 'none') { + if (data == 'none') { $buttonContainer.append( - ""); - } else if(data == 'request') { + } else if (data == 'request') { $buttonContainer.append( - ""); + } else if (data == 'admin') { + $buttonContainer.append( + "" + ); } else { $buttonContainer.append( - ""); } $buttonContainer.children().click(function() { - $.post("API/editMembership.php", { grp: groupID, role: this.value }) - .done(function() { - $buttonContainer.children().remove(); - placeGroupButtons(); - updateMenus(); - }).fail(function() { - }); + if (this.value == 'admin') { + window.location.href='groupAdmin.php?groupID=' + groupID; + } else { + $.post("API/editMembership.php", {grp: groupID, role: this.value}) + .done(function () { + $buttonContainer.children().remove(); + placeGroupButtons(); + updateMenus(); + }).fail(function () { + }); + } }); }); diff --git a/website/public/js/main.js b/website/public/js/main.js index 7741406..2ce58e4 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -3,8 +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; - text = text.replace(regex, function(link) { + text = text.replace(/(https?:\/\/.[^ \n<>"]*)/ig, function(link) { // Add images if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) { return "" + link + ""; @@ -14,14 +13,14 @@ function fancyText(text) { return "" + "" + "Je browser ondersteund geen video" + - ""; + ""; } // Add ogg video's else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) { return "" + "" + "Je browser ondersteund geen video" + - ""; + ""; } // Add youtube video's else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) { @@ -31,13 +30,15 @@ function fancyText(text) { } // Add links else { - return "" + link + ""; + return "" + link + ""; } }); return text; } +// This function gets the value of a cookie when given a key. +// If it didn“t find any compatible cookie, it returns false. function getCookie(key) { cookies = document.cookie.split("; "); for (var i in cookies) { @@ -49,6 +50,7 @@ function getCookie(key) { return false; } +// Edit the friendship status of two users. function editFriendship(userID, value) { $.post("API/editFriendship.php", { usr: userID, action: value }) .done(function() { @@ -57,6 +59,8 @@ function editFriendship(userID, value) { }); } +// Show the given friends in the given list. +// The friends are giving in JSON, and the list is giving with a hashtag. function showFriends(friends, list) { if(friends && friends != "[]") { $(list).load("bits/friend-item.php", { @@ -69,6 +73,8 @@ function showFriends(friends, list) { } } +// Show the given friends in the given list. +// This function supports more options given as parameters. This adds extra functionality. function showFriendsPlus(friends, list, limit, action, actionType) { if(friends && friends != "[]") { $(list).load("bits/friend-item.php", { @@ -84,6 +90,7 @@ function showFriendsPlus(friends, list, limit, action, actionType) { } } +// Show the given groups in the given list. function showGroups(groups, list) { if(groups && groups != "[]") { $(list).load("bits/group-item.php", { diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 4f638c2..d43577b 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -26,19 +26,41 @@ function requestPost(postID) { function postPost() { title = $("input.newpost[name='title']").val(); content = $("textarea.newpost[name='content']").val(); - + console.log(masonryMode); if (masonryMode == 2) { $.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 if (data == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; + } else if (data == "frozen") { + alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is."); + } 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 if (data == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; + } else if (data == "frozen") { + alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is."); + } else { + $('#alertbox').hide(); + masonry(masonryMode); + } }); } @@ -98,6 +120,10 @@ function masonry(mode) { masonryMode = mode; $container.children().remove(); + // reinit posts + noposts = false; + postAmount = 0; + /* * Initialise columns. */ @@ -120,7 +146,7 @@ function masonry(mode) { $form.append($("")); $form.append($("")); - $form.append($("")); + $form.append($("")); columns[0][1].append($postInput); columns[0][0] = $postInput.height() + margin; @@ -153,9 +179,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 4009023..4f77d4d 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -8,6 +8,8 @@ function postComment(buttonValue) { ).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."); + } else if (response == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; } }); @@ -30,6 +32,8 @@ function deletePost(postID) { ).done(function (response) { if (response == "frozen") { alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is."); + } else if (response == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; } }); closeModal(); diff --git a/website/public/js/search.js b/website/public/js/search.js index f7c4bbe..affe758 100644 --- a/website/public/js/search.js +++ b/website/public/js/search.js @@ -2,6 +2,7 @@ $(window).on('load', function () { pageNumber(); }); +// Search for the users and put them in the user list. function searchUsers() { $.post( "API/searchUsers.php", @@ -13,6 +14,7 @@ function searchUsers() { }); } +// Search for the groups and put them in the group list. function searchGroups() { $.post( "API/searchGroups.php", @@ -24,6 +26,7 @@ function searchGroups() { }); } +// Get the page numbers and return them in the select. function pageNumber() { var input = input2 = $('#search-form').serialize(); $.post( diff --git a/website/public/profile.php b/website/public/profile.php index 05c661d..126c87f 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -25,9 +25,15 @@ 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; if ($userID == $_SESSION["userID"]) { diff --git a/website/public/settings.php b/website/public/settings.php index e40f042..9247d26 100644 --- a/website/public/settings.php +++ b/website/public/settings.php @@ -18,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { try { switch ($_POST["form"]) { case "profile": - updateSettings(); + checkUpdateSettings(); break; case "password": changePassword(); diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 94fdea9..5bb7b1d 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -102,7 +102,6 @@ p { .group-picture { border-radius: 5px; - border: none; } .item-box, .item-box-full-width { @@ -117,7 +116,7 @@ p { @media only screen and (max-width: 1400px) { .item-box { - width: calc(100% - 50px); + width: calc(100% - 50px)!important; } } @@ -257,8 +256,6 @@ div[data-title]:hover:after { top: 150%; z-index: 200; white-space: nowrap; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; border-radius: 3px; box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22); background-color: #333; @@ -291,19 +288,6 @@ div[data-title]:hover:after { vertical-align: middle; } -::-webkit-scrollbar { - width: 5px; - height: 5px; -} -::-webkit-scrollbar-track { - background: none; -} -::-webkit-scrollbar-thumb { - -webkit-border-radius: 20px; - border-radius: 20px; - background: #4CAF50; -} - @media only screen and (max-width: 1080px) { body { font-size: 28px!important; diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 3f37ffd..e82129b 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -48,6 +48,10 @@ width: 90%; } +.post-content a { + text-decoration: underline; +} + .commentfield { margin-bottom: 20px; } @@ -87,17 +91,5 @@ .deleteButton { background-color: firebrick; - -} - -.deleteButton i { - display: inline-block; -} - -.deleteButton:hover span { - display: inline-block; -} - -.deleteButton span { - display: none; + float: right; } \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 1bacafa..8a93d12 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -1,5 +1,14 @@ /* New */ +.alertbox { + display: none; + background-color: firebrick; +} + +.alerttext { + color: white; +} + .user-box { text-align: center; } @@ -11,21 +20,29 @@ display: inline-block; } -.friend-button-container { +.friend-button-container, .group-button-container { position: relative; float: right; width: 200px; 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; - width: 200px; font-size: 18px; } +.status-buttons-container button { + float: left; +} .group-button-container button { float: right; @@ -62,10 +79,24 @@ .group-picture { border: none; - margin-bottom: 0; - margin-right: 15px; } +.fancy-button span { + display: none; +} + +.fancy-button:hover { + text-align: right; +} + +.fancy-button i { + display: inline-block; +} + +.fancy-button:hover span { + display: inline-block; + margin-right: 5px; +} /* Old */ @@ -90,6 +121,10 @@ div.posts div.post { word-wrap: break-word; } +div.posts div.post a { + text-decoration: underline; +} + div.posts div.post:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } @@ -108,7 +143,7 @@ div.posts .post form input, div.posts .post form textarea { width: calc(100% - 15px); } -div.posts .post form input[type="submit"] { +div.posts .post form input[type="submit"], .post button{ width: 100%; } diff --git a/website/public/styles/settings.css b/website/public/styles/settings.css index 933e7fd..6a2c2f2 100644 --- a/website/public/styles/settings.css +++ b/website/public/styles/settings.css @@ -32,6 +32,11 @@ text-align: right; } +.settings-password, .settings-email { + width: calc(50% - 60px); + display: inline-flex; +} + .settings-password label, .settings-email label { text-align: left; } 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/friendship.php b/website/queries/friendship.php index a16d859..3dcd53b 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -10,13 +10,14 @@ function selectLimitedFriends($userID, $limit) { $stmt = prepareQuery(" SELECT `userID`, + LEFT(`username`, 12) as `usernameshort`, `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `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`, @@ -50,13 +51,14 @@ function selectAllFriends($userID) { $stmt = prepareQuery(" SELECT `userID`, + LEFT(`username`, 12) as `usernameshort`, `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `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`, @@ -85,13 +87,14 @@ function selectAllFriendRequests() { $stmt = prepareQuery(" SELECT `userID`, + LEFT(`username`, 12) as `usernameshort`, `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `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`, @@ -235,13 +238,14 @@ function searchSomeFriends($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, + LEFT(`username`, 12) as `usernameshort`, `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `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`, @@ -275,4 +279,35 @@ function searchSomeFriends($n, $m, $search) { $stmt->bindParam(':m', $m, PDO::PARAM_INT); $stmt->execute(); return json_encode($stmt->fetchAll()); +} + +function countSomeFriends($search) { + $stmt = prepareQuery(" + SELECT + COUNT(*) + FROM + `user` + INNER JOIN + `friendship` + WHERE + ((`friendship`.`user1ID` = :userID AND + `friendship`.`user2ID` = `user`.`userID` OR + `friendship`.`user2ID` = :userID AND + `friendship`.`user1ID` = `user`.`userID`) AND + `user`.`role` != 'banned' AND + `friendship`.`status` = 'confirmed') AND + (`username` LIKE :keyword OR + `fname` LIKE :keyword OR + `lname` LIKE :keyword) + ORDER BY + `fname`, + `lname`, + `username` + "); + + $search = "%$search%"; + $stmt->bindParam(':keyword', $search); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetchColumn(); } \ No newline at end of file diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php new file mode 100644 index 0000000..e3580b6 --- /dev/null +++ b/website/queries/groupAdmin.php @@ -0,0 +1,109 @@ +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"); +} + +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/group_member.php b/website/queries/group_member.php index 50e6117..7844235 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -55,6 +55,29 @@ function searchSomeOwnGroups($n, $m, $search) { return json_encode($stmt->fetchAll()); } +function countSomeOwnGroups($search) { + $stmt = prepareQuery(" + SELECT + COUNT(*) + FROM + `group_page` + INNER JOIN + `group_member` + WHERE + `group_member`.`userID` = :userID AND + `group_member`.`groupID` = `group_page`.`groupID` AND + `group_page`.`status` != 'hidden' AND + `name` LIKE :keyword + "); + + $search = "%$search%"; + $stmt->bindParam(':keyword', $search); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); + $stmt->execute(); + + return $stmt->fetchColumn(); +} + function addMember($groupID, $userID, $role) { $stmt = prepareQuery(" INSERT INTO diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 588e2fd..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) { @@ -81,7 +86,10 @@ function selectGroupMembers(int $groupID) { `username`, `fname`, `lname`, - `profilepicture` + IFNULL( + `profilepicture`, + '../img/avatar-standard.png' + ) AS profilepicture FROM `group_member` LEFT JOIN diff --git a/website/queries/picture.php b/website/queries/picture.php index 8e99d9a..9c92540 100644 --- a/website/queries/picture.php +++ b/website/queries/picture.php @@ -6,7 +6,10 @@ * @throws AngryAlert * @throws HappyAlert */ -function updateAvatar(bool $group = false) { +function updateAvatar(int $group = 0) { + if (!array_key_exists("pp", $_FILES)) { + throw new AngryAlert("Geen afbeelding meegegeven!"); + } $publicDir = "/var/www/html/public/"; $tmpImg = $_FILES["pp"]["tmp_name"]; $avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/"; @@ -16,17 +19,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/queries/private_message.php b/website/queries/private_message.php index 4ac04a7..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"]); @@ -95,7 +100,7 @@ function getNewChatMessages($lastID, $destination) { function selectAllUnreadChat() { $stmt = prepareQuery(" SELECT - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, `user`.`userID`, IFNULL( `profilepicture`, diff --git a/website/queries/settings.php b/website/queries/settings.php index dfd65a0..26237ec 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -50,6 +50,15 @@ function getPasswordHash() { return $stmt->fetch(); } +function checkUpdateSettings() { + if (empty(test_input($_POST['fname'])) || empty(test_input($_POST['lname']))) { + throw new AngryAlert("Geen voornaam of achternaam."); + return; + } + + updateSettings(); +} + /** * Changes the setting from post. * @throws HappyAlert @@ -139,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"])) { @@ -155,6 +168,11 @@ function changeEmail() { } } +/** + * Checks if an emailadres is available in the database. + * @param $email + * @throws AngryAlert + */ function emailIsAvailableInDatabase($email) { $stmt = prepareQuery(" SELECT @@ -172,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/queries/user.php b/website/queries/user.php index f7d8abe..422edc4 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -52,19 +52,27 @@ function selectUser($me, $other) { `username`, `birthdate`, `location`, + `showBday`, + `showEmail`, + `showProfile`, + `email`, IFNULL( `profilepicture`, '../img/avatar-standard.png' ) 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`, `role`, `fname`, `lname`, + `showBday`, + `showEmail`, + `showProfile`, + `status`, CASE `status` IS NULL WHEN TRUE THEN 0 WHEN FALSE THEN @@ -93,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(); } @@ -112,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); @@ -127,7 +137,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` @@ -152,7 +162,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` @@ -180,7 +190,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` @@ -214,7 +224,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` @@ -351,13 +361,14 @@ function searchSomeUsers($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, + LEFT(`username`, 12) as `usernameshort`, `username`, IFNULL( `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` diff --git a/website/views/adminpanel-grouptable.php b/website/views/adminpanel-grouptable.php index 9d2c8e8..2449b3d 100644 --- a/website/views/adminpanel-grouptable.php +++ b/website/views/adminpanel-grouptable.php @@ -1,8 +1,8 @@ - Gebruikersnaam + Groepsnaam Status - Aantekening + Beschrijving Actie @@ -33,9 +33,9 @@ while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
    diff --git a/website/views/adminpanel-table.php b/website/views/adminpanel-table.php index aa790e6..f7bc966 100644 --- a/website/views/adminpanel-table.php +++ b/website/views/adminpanel-table.php @@ -55,7 +55,8 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) { OR $user['role'] == 'owner'))) { echo " - "; + + "; if ($userinfo == 'owner') { echo " diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index a4da648..2c0bec2 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -67,13 +67,13 @@ if (isset($_GET["groupstatus"])) { id="frozen" value="frozen" > -
    +
    > -
    +
    > - +
    @@ -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;"> - - - + + +
    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/group.php b/website/views/group.php index c12b552..250fc9f 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -1,12 +1,17 @@
    -
    - -
    -

    -

    - +
    + <?= $group[" class="group-picture main-picture" src="">
    +
    +
    + +
    +
    +
    +

    + +
    +
    -

    Leden ()

    @@ -22,6 +27,10 @@

    +
    +

    Geen posts meer!

    +
    +
    diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php new file mode 100644 index 0000000..54fbee8 --- /dev/null +++ b/website/views/groupAdmin.php @@ -0,0 +1,126 @@ + +
    +
    + +
    + +
    + +
    +
      +
    • + + "> + + +
    • +
    +
    +
    +
    Groep Instellingen
    + "> +
      +
    • + + " + > +
    • +
    • + + + +
    • +
    • + + +
    • +
    +
    +
    +
    Verander groepsafbeelding.
    + "> +
      +
    • + + " + class="group-picture" + > +
    • +
    • + + +
    • +
    • + + +
    • +
    +
    +
    +
    Voeg een admin/mod toe
    +
      + + " type="hidden"> + + + + + +
    +
    +
    +
      +
    • + + "> +
    • +
    +
    +
    +
    \ No newline at end of file diff --git a/website/views/head.php b/website/views/head.php index 284abb4..3ec8a79 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,4 +1,7 @@ - + + + + MyHyvesbook+ @@ -23,8 +26,8 @@ require_once ("../queries/user.php"); session_start(); -if(!isset($_SESSION["userID"])){ - header("location:login.php"); +if(!isset($_SESSION["userID"])) { + header("location:login.php?url=" . "$_SERVER[REQUEST_URI]"); } else { updateLastActivity(); } diff --git a/website/views/header.php b/website/views/header.php index c1379fc..e13eca6 100644 --- a/website/views/header.php +++ b/website/views/header.php @@ -23,9 +23,9 @@ $userinfo = getHeaderInfo();
    Hallo
    - +
    - "/> + <?= $userinfo[" id="own-profile-picture" class="profile-picture" src=""/>
    diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index 2e00905..8ccc198 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -29,6 +29,7 @@ $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": diff --git a/website/views/login_head.php b/website/views/login_head.php index 61bf9c3..9e580df 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,5 +1,8 @@ - + + + + MyHyvesbook+
    + +
    • - + Maak een groep aan
    • diff --git a/website/views/notification-center.php b/website/views/notification-center.php index 7bd03ea..f6f4a03 100644 --- a/website/views/notification-center.php +++ b/website/views/notification-center.php @@ -14,7 +14,7 @@ echo ""; } ?> - +

    diff --git a/website/views/post-view.php b/website/views/post-view.php index da1c86f..fadc791 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -5,14 +5,6 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . " ?>

    - -
    - gepost door , '> @@ -20,7 +12,14 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
    - + +
    +

    @@ -30,7 +29,7 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "

    - + - +
    + +
    +
    + +

    :)

    @@ -15,25 +25,30 @@

    - " . $user["bio"] . "

    "; } ?>
    - 50) { + 50 and $showProfile) { echo "

    Bio:

    " . $user["bio"] . "

    "; } ?> +

    Informatie

    -

    -

      -
    • Leeftijd: jaar
    • -
    • Locatie:
    • -
    • Lid sinds:
    • -
    -

    +
      + +
    • Leeftijd: jaar
    • + + +
    • Email:
    • + +
    • Locatie:
    • +
    • Lid sinds:
    • +
    @@ -41,7 +56,7 @@

    fetch()) { - echo "${friend["username"]}"; + echo "${friend["username"]}"; } @@ -85,4 +100,5 @@

    + \ No newline at end of file diff --git a/website/views/search-view.php b/website/views/search-view.php index e42f985..f00fd3c 100644 --- a/website/views/search-view.php +++ b/website/views/search-view.php @@ -48,7 +48,12 @@ $group_n = ($group_currentpage - 1) * $group_perpage; - diff --git a/website/views/settings-view.php b/website/views/settings-view.php index f72e243..0800cc8 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -17,6 +17,7 @@ $settings = getSettings(); " @@ -27,6 +28,7 @@ $settings = getSettings(); " > @@ -36,14 +38,15 @@ $settings = getSettings(); " >
  • - - - - format("Y"); for ($year = $now; $year >= 1900; $year--): ?> @@ -194,6 +197,7 @@ $settings = getSettings(); " disabled > @@ -202,6 +206,7 @@ $settings = getSettings(); @@ -211,14 +216,16 @@ $settings = getSettings();
  • + value="email"> + Verander Email +