diff --git a/website/public/.htaccess b/website/public/.htaccess index f08898a..5b6a2ef 100644 --- a/website/public/.htaccess +++ b/website/public/.htaccess @@ -1,7 +1,7 @@ Options +FollowSymLinks RewriteEngine On -ErrorDocument 404 /error404.jpg +ErrorDocument 404 /error/404.php RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f diff --git a/website/public/API/getPosts.php b/website/public/API/getPosts.php index eef8261..620a707 100644 --- a/website/public/API/getPosts.php +++ b/website/public/API/getPosts.php @@ -1,13 +1,17 @@ prepare(" + $stmt = prepareQuery(" SELECT `userID` FROM @@ -19,7 +19,7 @@ function getNietSlechtCountForPost(int $postID) : int { } function getNietSlechtUsersForPost(int $postID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `fname`, `lname`, diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index 30c02eb..e1d7617 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -3,7 +3,7 @@ session_start(); require("../../queries/post.php"); -require("../../queries/connect.php"); +require_once("../../queries/connect.php"); require("../../queries/checkInput.php"); print_r($_POST); if ($_POST['button'] == 'reaction') { diff --git a/website/public/emailconfirm.php b/website/public/emailconfirm.php index 2812eaa..d0cc5a3 100644 --- a/website/public/emailconfirm.php +++ b/website/public/emailconfirm.php @@ -2,7 +2,7 @@ include_once("../queries/connect.php"); include_once("../views/messagepage.php"); if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) { - $checkHash = $GLOBALS["db"]->prepare(" + $checkHash = prepareQuery(" SELECT `email`, `role` @@ -28,7 +28,7 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) { function doActivate(string $email) { if (password_verify($email, $_GET["h"])) { - $confirmUser = $GLOBALS["db"]->prepare(" + $confirmUser = prepareQuery(" UPDATE `user` SET diff --git a/website/public/error/404.php b/website/public/error/404.php new file mode 100644 index 0000000..15ad06b --- /dev/null +++ b/website/public/error/404.php @@ -0,0 +1,9 @@ + +

404

+

Verkeerde link...


+ +"); \ No newline at end of file diff --git a/website/public/group.php b/website/public/group.php index fa45090..2ef3493 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -4,6 +4,8 @@ @@ -30,6 +32,20 @@ include("../views/group.php"); /* This adds the footer. */ include("../views/footer.php"); + +$masonry_mode = 0; ?> + + + + + diff --git a/website/public/img/zelda.png b/website/public/img/zelda.png new file mode 100644 index 0000000..0c1580a Binary files /dev/null and b/website/public/img/zelda.png differ diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 773a819..014d723 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -1,25 +1,31 @@ var previousDate = new Date("1970-01-01 00:00:00"); +var previousTime = "00:00"; +var gettingMessages = false; +var previousType = "robot"; $(document).ready(function() { - loadMessages(); + setInterval(loadMessages, 1000); sayEmpty(); $(".chat-field").hide(); }); function loadMessages() { - $.post( - "API/loadMessages.php", - $("#lastIDForm").serialize() - ).done(function(data) { - if (data && data != "[]") { - messages = JSON.parse(data); - addMessages(messages); - $("#lastID").val(messages[messages.length - 1].messageID); - $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight); - } - }); - - setTimeout(loadMessages, 1000); + if (!gettingMessages) { + gettingMessages = true; + $.post( + "API/loadMessages.php", + $("#lastIDForm").serialize() + ).done(function (data) { + if (data && data != "[]") { + messages = JSON.parse(data); + addMessages(messages); + $("#lastID").val(messages[messages.length - 1].messageID); + } + gettingMessages = false; + }); + } else { + setTimeout(loadMessages, 500); + } } @@ -30,35 +36,55 @@ function sendMessage() { ); $("#newContent").val(""); + loadMessages(); } function addMessages(messages) { + var messagesText = ""; for(var i in messages) { - thisDate = new Date(messages[i].creationdate); + // Initialize message variables + var thisDate = new Date(messages[i].creationdate); + var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); + var type; thisDate.setHours(0,0,0,0); + if (messages[i].destination == $(".destinationID").val()) { type = "chat-message-self"; } else { type = "chat-message-other"; } - if (thisDate > previousDate) { + if (i == 0) { + messagesText += '
'; + } else if (type != previousType || thisTime != previousTime || thisDate > previousDate) { + messagesText += '
\ + ' + thisTime + '\ +
'; + previousDate = thisDate; - $("#chat-history").append('\ -
\ -
\ - ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ -
\ -
\ - '); + previousTime = thisTime; + previousType = type; + if (thisDate > previousDate) { + messagesText += '\ +
\ +
\ + ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ +
\ +
'; + } + + messagesText += '
'; } - $("#chat-history").append('\ -
\ -
\ - ' + fancyText(messages[i].content) + '\ -
\ -
\ - '); + messagesText += fancyText(messages[i].content) + "
"; } + + // Close the last message + messagesText += '
\ + ' + thisTime + '\ +
'; + + $("#chat-history").append(messagesText); + + $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight); } function switchUser(userID) { @@ -72,5 +98,5 @@ function switchUser(userID) { } function sayEmpty() { - $("#chat-history").html("Begin nu met chatten!"); + $("#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 bdc3cc8..d62e919 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -1,26 +1,73 @@ function placeFriendButtons() { $.post("API/getFriendshipStatus.php", { usr: userID }) .done(function(data) { - friendshipStatus = data; - $buttonContainer = $("div.friend-button-container"); - $buttonContainer.children().remove(); - $("#start-profile-chat-form").hide(); - if (friendshipStatus == -1) { - return; - } else if(friendshipStatus == 0) { - $buttonContainer.append($("")); - } else if(friendshipStatus == 1) { - $buttonContainer.append($("")); - $("#start-profile-chat-form").show(); - } else if(friendshipStatus == 2) { - $buttonContainer.append($("")); - } else if(friendshipStatus == 3) { - $buttonContainer.append($("")); - $buttonContainer.append($("")); - } + var friendshipStatus = data; + var $buttonContainer = $("div.friend-button-container"); + $("#start-profile-chat").hide(); + $buttonContainer.html(""); + var value1 = ""; + var class1 = "empty-button"; + var icon1 = ""; + var text1 = ""; + + var value2 = ""; + var class2 = "empty-button"; + var icon2 = ""; + var text2 = ""; + + switch (friendshipStatus) { + case "0": + value1 = "request"; + class1 = "green"; + text1 = "Bevriend"; + icon1 = "fa-handshake-o"; + break; + case "1": + value1 = userID; + class1 = "green"; + text1 = "Chat"; + icon1 = "fa-comment-o"; + value2 = "delete"; + class2 = "red"; + text2 = "Verwijder"; + icon2 = "fa-times"; + break; + case "2": + value1 = "delete"; + class1 = "red"; + text1 = "Trek verzoek in"; + icon1 = "fa-cross"; + break; + case "3": + value1 = "accept"; + class1 = "green"; + text1 = "Accepteer"; + icon1 = "fa-check"; + value2 = "delete"; + class2 = "red"; + text2 = "Weiger"; + icon2 = "fa-times"; + break; + default: + console.log(friendshipStatus); + break; + } + + $buttonContainer.append( + ""); + $buttonContainer.append( + ""); + $buttonContainer.children().click(function() { - editFriendship(userID, this.value); + if (isNaN(this.value)) + editFriendship(userID, this.value); + else if (this.value != "") + window.location.href = "chat.php?username=" + this.value; }); }); } \ No newline at end of file diff --git a/website/public/js/main.js b/website/public/js/main.js index dfd6c38..d23bbbf 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -2,19 +2,39 @@ var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"] function fancyText(text) { - - // Add images and gifs. - var regex = /(https:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig; - text = text.replace(regex, function(img) { - return ""; + // Add links, images, gifs and (youtube) video's. + var regex = /(https?:\/\/.[^ ]*)/ig; + text = text.replace(regex, function(link) { + // Add images + if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) { + return "" + link + ""; + } + // Add mp4 video's + else if (link.match(/(https?:\/\/.[^ ]*\.(?:mp4))/ig)) { + return ""; + } + // Add ogg video's + else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) { + return ""; + } + // Add youtube video's + else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) { + return ''; + } + // Add links + else { + return "" + link + ""; + } }); - // Add links. - // regex = /(https:\/\/.[^ ]*\.(?:net|com|nl))/ig; - // text = text.replace(regex, function(link) { - // return "LINK"; - // }); - return text; } diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index f30f0af..8d2080b 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -90,7 +90,7 @@ function masonry(mode) { /* * Get the posts from the server. */ - $.post("API/getPosts.php", { usr : userID }) + $.post("API/getPosts.php", { usr : userID, grp : groupID }) .done(function(data) { posts = JSON.parse(data); diff --git a/website/public/js/post.js b/website/public/js/post.js index 1906428..4a8ebc7 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -4,7 +4,9 @@ function postComment(buttonValue) { $.post( "API/postComment.php", formData - ); + ).done(function(data) { + console.log(data); + }); $("#newcomment").val(""); diff --git a/website/public/profile.php b/website/public/profile.php index 95c5b86..83b9d10 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -27,7 +27,6 @@ if(empty($_GET["username"])) { $user = selectUser($_SESSION["userID"], $userID); $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); -$posts = selectAllUserPosts($userID); if ($userID == $_SESSION["userID"]) { @@ -54,23 +53,12 @@ include("../views/footer.php"); diff --git a/website/public/resetpassword.php b/website/public/resetpassword.php index 3ca2698..795e6e3 100644 --- a/website/public/resetpassword.php +++ b/website/public/resetpassword.php @@ -28,7 +28,7 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") { } function changePassword() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `user` SET @@ -42,7 +42,7 @@ function changePassword() { } function verifyLink(int $userID, string $hash) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `password` FROM diff --git a/website/public/styles/adminbutton.css b/website/public/styles/adminbutton.css new file mode 100644 index 0000000..2a8fb2a --- /dev/null +++ b/website/public/styles/adminbutton.css @@ -0,0 +1,3 @@ +#quick-links i { + font-size: 32px; +} \ No newline at end of file diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css index 0ba5af4..47b0639 100644 --- a/website/public/styles/chat.css +++ b/website/public/styles/chat.css @@ -130,4 +130,18 @@ body { .chat-message img { max-width: 100%; +} + +.chat-message a { + text-decoration: underline; +} + +.chat-time { + color: #666666; + font-size: 12px; + margin-bottom: -3px; +} + +.chat-message-other .chat-time { + text-align: right; } \ No newline at end of file diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 0c37afa..abb1604 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -97,16 +97,16 @@ p { } .item-box, .item-box-full-width { - margin: 20px 0 0 0; padding: 25px; background-color: #FFFFFF; } .item-box { - width: calc(50% - 60px); + width: calc(33% - 50px); + display: inline-table; } -@media only screen and (max-width: 900px) { +@media only screen and (max-width: 1400px) { .item-box { width: calc(100% - 50px); } @@ -183,6 +183,10 @@ button.green { background-color: forestgreen; } +button.gray{ + background-color: #FFF; + color: #333; +} button, input[type="submit"], @@ -224,6 +228,7 @@ td { /* Custom title box, appears instantaneously */ a[data-title]:hover, +i[data-title]:hover, img[data-title]:hover, span[data-title]:hover, div[data-title]:hover { @@ -231,6 +236,7 @@ div[data-title]:hover { } a[data-title]:hover:after, +i[data-title]:hover:after, img[data-title]:hover:after, span[data-title]:hover:after, div[data-title]:hover:after { diff --git a/website/public/styles/resetpassword.css b/website/public/styles/message-page.css similarity index 64% rename from website/public/styles/resetpassword.css rename to website/public/styles/message-page.css index a3d7942..7cc6f4b 100644 --- a/website/public/styles/resetpassword.css +++ b/website/public/styles/message-page.css @@ -1,6 +1,9 @@ +body { + background-color: #FBC02D; +} + .password-change { height: 100%; - background-color: #FBC02D; margin: auto; } @@ -12,6 +15,14 @@ margin: 30px auto auto; display: block; } -.password-change img { +.top-logo img { width: 50%; } + +.error-page { + text-align: center; +} + +.error-page img { + vertical-align: middle; +} \ No newline at end of file diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index c6e96c1..7bbeb48 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -71,7 +71,16 @@ width: 95%; } -.nietslecht { +.nietslecht-text { font-family: Impact, Anton, sans-serif; - text-shadow: -1.5px 0 1px black, 0 1.5px 1px black, 1px 0 1.5px black, 0 -1.5px 1px black; + text-shadow: -1px 0 1px black, 0 1px 1px black, 1px 0 1px black, 0 -1px 1px black; +} + +.nietslecht { +} + +.nietslecht img { + vertical-align: middle; + height: 24px; + width: 24px; } \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index becbeca..03ab19f 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -1,15 +1,60 @@ -.profile-box { - min-height: 150px; - padding: 25px; - background-color: #FFFFFF; +/* New */ + +.user-box { + text-align: center; } -.profile-box .profile-picture, .profile-box .group-picture { +.status-buttons-container { + position: relative; + float: left; + width: 200px; + display: inline-block; +} + +.friend-button-container { + position: relative; + float: right; + width: 200px; + display: inline-block; +} + +.friend-button-container button, .status-buttons-container button { + display: block; + + margin: 7px 0; + width: 200px; + + font-size: 18px; +} + +.empty-button { + background: none; + cursor: auto; +} +.empty-button:active { + box-shadow: none; +} + +.profile-info { + display: inline-block; + + min-width: 250px; + width: auto; + padding-top: 30px; +} + +.main-picture { + position: relative; + border: #4CAF50 solid 5px; + + display: inline-block; width: 150px; height: 150px; - margin: 0 20px 20px 0; + margin-bottom: -45px; } +/* Old */ + .profile-box h1.profile-username { padding-top: 50px; } @@ -18,14 +63,12 @@ } div.posts { - padding-top: 20px; width: calc(100% + 20px); display: inline-flex; } div.posts div.post { display: block; - margin: 20px 0 0 0; padding: 10px; width: calc(100% - 40px); cursor: pointer; @@ -60,6 +103,12 @@ div.posts .post form textarea.newpost { height: 100px; } +.post .post-date { + float: right; + color: #aaaaaa; + font-size: 0.8em; +} + @media only screen and (max-width: 1500px) { .post-box { width: calc(50% - 68px); @@ -72,23 +121,3 @@ div.posts .post form textarea.newpost { width: calc(100% - 65px); } } - -.post .post-date { - float: right; - color: #aaaaaa; - font-size: 0.8em; -} - -button.friend-button { - float: right; - height: auto; - padding: 10px; - margin-left: 10px; - border-radius: 5px; - transition-duration: 250ms; - cursor: pointer; -} - -button.friend-button:hover { - box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); -} \ No newline at end of file diff --git a/website/queries/connect.php b/website/queries/connect.php index ddb3c9b..3971a74 100644 --- a/website/queries/connect.php +++ b/website/queries/connect.php @@ -8,4 +8,8 @@ else { $GLOBALS["db"] = new PDO("mysql:host=$dbconf->mysql_host;dbname=$dbconf->mysql_database;charset=utf8", "$dbconf->mysql_username", "$dbconf->mysql_password") or die('Error connecting to mysql server'); +} + +function prepareQuery(string $query) : PDOStatement { + return $GLOBALS["db"]->prepare($query); } \ No newline at end of file diff --git a/website/queries/emailconfirm.php b/website/queries/emailconfirm.php index 0b3224f..0e6aab1 100644 --- a/website/queries/emailconfirm.php +++ b/website/queries/emailconfirm.php @@ -1,7 +1,7 @@ prepare(" + $stmt = prepareQuery(" SELECT `userID` FROM @@ -16,7 +16,7 @@ function sendConfirmEmailUsername(string $username) { } function sendConfirmEmail(int $userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `email`, `fname` diff --git a/website/queries/friendship.php b/website/queries/friendship.php index a1a23d8..038752d 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -7,7 +7,7 @@ function selectFriends($userID) { } function selectLimitedFriends($userID, $limit) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username`, @@ -29,6 +29,12 @@ 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 + DESC LIMIT :limitCount "); @@ -41,7 +47,7 @@ function selectLimitedFriends($userID, $limit) { function selectAllFriends($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username`, @@ -73,7 +79,7 @@ function selectAllFriends($userID) { } function selectAllFriendRequests() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username`, @@ -115,7 +121,7 @@ function getFriendshipStatus($userID) { return -1; } - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT CASE `status` IS NULL WHEN TRUE THEN 0 @@ -148,7 +154,7 @@ function getFriendshipStatus($userID) { } function requestFriendship($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" INSERT INTO `friendship` (user1ID, user2ID) VALUES (:user1, :user2) "); @@ -159,7 +165,7 @@ function requestFriendship($userID) { } function removeFriendship($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" DELETE FROM `friendship` WHERE `user1ID` = :user1 AND @@ -175,7 +181,7 @@ function removeFriendship($userID) { } function acceptFriendship($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `friendship` SET `status`='confirmed' WHERE @@ -190,7 +196,7 @@ function acceptFriendship($userID) { } function setLastVisited($friend) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `friendship` SET `friendship`.chatLastVisted1=( @@ -220,7 +226,7 @@ function setLastVisited($friend) { } function searchSomeFriends($n, $m, $search) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username`, diff --git a/website/queries/group_member.php b/website/queries/group_member.php index cba339f..cea4dde 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -5,7 +5,7 @@ function selectAllGroupsFromUser($userID) { } function selectLimitedGroupsFromUser($userID, $limit) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `group_page`.`name`, `group_page`.`picture` @@ -28,7 +28,7 @@ function selectLimitedGroupsFromUser($userID, $limit) { } function searchSomeOwnGroups($n, $m, $search) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `group_page`.`name`, `group_page`.`picture` diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 5652e37..b3e454c 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -1,10 +1,11 @@ prepare(" + $stmt = prepareQuery(" SELECT + `group_page`.`groupID`, `group_page`.`groupID`, `name`, `description`, @@ -29,7 +30,7 @@ function selectGroupByName($name) { } function selectGroupMembers(int $groupID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `username`, `fname`, @@ -54,7 +55,7 @@ function selectGroupMembers(int $groupID) { } function selectGroupById($groupID) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `group_page`.`name`, `group_page`.`picture`, @@ -73,7 +74,7 @@ function selectGroupById($groupID) { } function select20GroupsFromN($n) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `group_page`.`groupID`, `group_page`.`name`, @@ -95,7 +96,7 @@ function select20GroupsFromN($n) { } function select20GroupsByStatusFromN($n, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `group_page`.`groupID`, `group_page`.`name`, @@ -120,7 +121,7 @@ function select20GroupsByStatusFromN($n, $status) { } function search20GroupsFromNByStatus($n, $keyword, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `groupID`, `name`, @@ -147,7 +148,7 @@ function search20GroupsFromNByStatus($n, $keyword, $status) { } function searchSomeGroupsByStatus($n, $m, $keyword, $status) { - $q = $GLOBALS['db']->prepare(" + $q = prepareQuery(" SELECT `groupID`, `name`, @@ -175,7 +176,7 @@ function searchSomeGroupsByStatus($n, $m, $keyword, $status) { } function countSomeGroupsByStatus($keyword, $status) { - $q = $GLOBALS['db']->prepare(" + $q = prepareQuery(" SELECT COUNT(*) FROM @@ -196,7 +197,7 @@ function countSomeGroupsByStatus($keyword, $status) { } function changeGroupStatusByID($id, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" UPDATE `group_page` SET @@ -212,7 +213,7 @@ function changeGroupStatusByID($id, $status) { } function changeMultipleGroupStatusByID($ids, $status) { - $q = $GLOBALS['db']->prepare(" + $q = prepareQuery(" UPDATE `group_page` SET @@ -229,7 +230,7 @@ function changeMultipleGroupStatusByID($ids, $status) { } function searchSomeGroups($n, $m, $search) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `name`, `picture` @@ -252,7 +253,7 @@ function searchSomeGroups($n, $m, $search) { } function countSomeGroups($search) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT COUNT(*) FROM @@ -267,5 +268,4 @@ function countSomeGroups($search) { $stmt->bindParam(':keyword', $search); $stmt->execute(); return $stmt; -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/website/queries/header.php b/website/queries/header.php index b0dd42c..7410d17 100644 --- a/website/queries/header.php +++ b/website/queries/header.php @@ -1,6 +1,6 @@ prepare(" + $stmt = prepareQuery(" SELECT `fname`, `lname`, diff --git a/website/queries/login.php b/website/queries/login.php index 384a3d5..c7e8383 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -1,7 +1,7 @@ prepare(" + $stmt = prepareQuery(" SELECT `password`, `userID`, @@ -61,5 +61,4 @@ class loginException extends Exception parent::__construct($message, $code, $previous); } } -?> diff --git a/website/queries/nicetime.php b/website/queries/nicetime.php index 4db6cbd..e2e509e 100644 --- a/website/queries/nicetime.php +++ b/website/queries/nicetime.php @@ -1,39 +1,39 @@ $unix_date) { -$difference = $now - $unix_date; -$tense = "geleden"; -} else { -$difference = $unix_date - $now; -$tense = "vanaf nu"; -} + if($now > $unix_date) { + $difference = $now - $unix_date; + $tense = "geleden"; + } else { + $difference = $unix_date - $now; + $tense = "vanaf nu"; + } -for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) { -$difference /= $lengths[$i]; -} + for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) { + $difference /= $lengths[$i]; + } -$difference = round($difference); + $difference = round($difference); -if($difference != 1) { -$period = $multiple_periods[$i]; -} else { -$period = $single_periods[$i]; -} + if($difference != 1) { + $period = $multiple_periods[$i]; + } else { + $period = $single_periods[$i]; + } -return "$difference $period $tense"; + return "$difference $period $tense"; } \ No newline at end of file diff --git a/website/queries/post.php b/website/queries/post.php index df1e227..a175cda 100644 --- a/website/queries/post.php +++ b/website/queries/post.php @@ -1,7 +1,53 @@ = 150 AND `post`.`content` NOT LIKE 'bindParam(':userID', $userID, PDO::PARAM_INT); + $stmt->bindParam(':groupID', $groupID , PDO::PARAM_INT); + if(!$stmt->execute()) { + return False; + } + return $stmt; + +} + function selectPostById($postID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `user`.`fname`, `user`.`lname`, @@ -26,7 +72,7 @@ function selectPostById($postID) { } function selectCommentsByPostId($postID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `comment`.`commentID`, `comment`.`postID`, @@ -52,7 +98,7 @@ function selectCommentsByPostId($postID) { } function makePost($userID, $groupID, $title, $content) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" INSERT INTO `post` ( `author`, @@ -76,7 +122,7 @@ function makePost($userID, $groupID, $title, $content) { } function makeComment($postID, $userID, $content) : int { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" INSERT INTO `comment` ( `postID`, @@ -106,7 +152,7 @@ function makeNietSlecht(int $postID, int $userID) : int { } function checkNietSlecht(int $postID, int $userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT * FROM @@ -122,7 +168,7 @@ function checkNietSlecht(int $postID, int $userID) { } function addNietSlecht(int $postID, int $userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" INSERT INTO `niet_slecht` (`userID`, `postID`) VALUES (:userID, :postID) @@ -134,7 +180,7 @@ function addNietSlecht(int $postID, int $userID) { } function deleteNietSlecht(int $postID, int $userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" DELETE FROM `niet_slecht` WHERE diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 4d48d3a..430fddb 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -4,7 +4,7 @@ function getOldChatMessages($user2ID) { require_once ("friendship.php"); $user1ID = $_SESSION["userID"]; if (getFriendshipStatus($user2ID) == 1) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT * FROM @@ -15,7 +15,7 @@ function getOldChatMessages($user2ID) { `origin` = :user2 AND `destination` = :user1 ORDER BY - `messageID` ASC + `creationdate` ASC "); $stmt->bindParam(":user1", $user1ID); @@ -32,7 +32,7 @@ function getOldChatMessages($user2ID) { function sendMessage($destination, $content) { require_once("friendship.php"); if (getFriendshipStatus($destination) == 1) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" INSERT INTO `private_message` ( @@ -61,7 +61,7 @@ function sendMessage($destination, $content) { function getNewChatMessages($lastID, $destination) { require_once("friendship.php"); if (getFriendshipStatus($destination) == 1) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT * FROM @@ -74,7 +74,7 @@ function getNewChatMessages($lastID, $destination) { `destination` = :user1) AND `messageID` > :lastID ORDER BY - `messageID` ASC + `creationdate` ASC "); $stmt->bindParam(':user1', $_SESSION["userID"]); @@ -91,7 +91,7 @@ function getNewChatMessages($lastID, $destination) { function selectAllUnreadChat() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`, `user`.`userID`, diff --git a/website/queries/register.php b/website/queries/register.php index bc44acf..1aed0ef 100644 --- a/website/queries/register.php +++ b/website/queries/register.php @@ -1,7 +1,7 @@ prepare(" + $stmt = prepareQuery(" SELECT `username` FROM @@ -17,7 +17,7 @@ function getExistingUsername() { } function getExistingEmail() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `email` FROM @@ -33,7 +33,7 @@ function getExistingEmail() { } function getResetEmail() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `email` FROM @@ -49,7 +49,7 @@ function getResetEmail() { } function registerAccount() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" INSERT INTO `user`(fname, lname, diff --git a/website/queries/requestpassword.php b/website/queries/requestpassword.php index bae825a..a54bd7d 100644 --- a/website/queries/requestpassword.php +++ b/website/queries/requestpassword.php @@ -3,7 +3,7 @@ include_once "../queries/connect.php"; function sendPasswordRecovery(string $email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username` @@ -39,7 +39,7 @@ function doSendPasswordRecovery(int $userID, string $email, string $username, st } function setHashToDatabase(int $userID, string $hash) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `user` SET diff --git a/website/queries/settings.php b/website/queries/settings.php index 05e7fbf..f4c5403 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -50,7 +50,7 @@ class AngryAlert extends AlertMessage { * @return mixed Setting as an array. */ function getSettings() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `fname`, `lname`, @@ -77,7 +77,7 @@ function getSettings() { * @return mixed passwordhash */ function getPasswordHash() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `password`, `username` @@ -96,7 +96,7 @@ function getPasswordHash() { * @throws HappyAlert */ function updateSettings() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `user` SET @@ -146,7 +146,7 @@ function changePassword() { * @throws HappyAlert */ function doChangePassword() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `user` SET @@ -184,7 +184,7 @@ function changeEmail() { } function emailIsAvailableInDatabase($email) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `email` FROM @@ -201,7 +201,7 @@ function emailIsAvailableInDatabase($email) { } function doChangeEmail($email) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `user` SET @@ -245,7 +245,7 @@ function updateAvatar() { } function removeOldAvatar() { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `profilepicture` FROM @@ -262,7 +262,7 @@ function removeOldAvatar() { } function setAvatarToDatabase(string $url) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" UPDATE `user` SET diff --git a/website/queries/user.php b/website/queries/user.php index 1d075ef..6d93793 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -1,9 +1,9 @@ prepare(" + $stmt = prepareQuery(" SELECT `userID` FROM @@ -18,7 +18,7 @@ function getUserID($username) { } function getUsername($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `username` FROM @@ -33,7 +33,7 @@ function getUsername($userID) { } function selectUser($me, $other) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username`, @@ -46,6 +46,7 @@ function selectUser($me, $other) { `bio`, `user`.`creationdate`, `onlinestatus`, + `role`, `fname`, `lname`, CASE `status` IS NULL @@ -81,7 +82,7 @@ function selectUser($me, $other) { } function selectAllUserGroups($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `group_page`.`groupID`, `name`, @@ -103,50 +104,50 @@ function selectAllUserGroups($userID) { return $stmt; } -function selectAllUserPosts($userID) { - $stmt = $GLOBALS["db"]->prepare(" - 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 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 = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `userID`, `username`, @@ -167,7 +168,7 @@ function select20UsersFromN($n) { } function search20UsersFromN($n, $keyword) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `userID`, `username`, @@ -191,7 +192,7 @@ function search20UsersFromN($n, $keyword) { } function search20UsersFromNByStatus($n, $keyword, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `userID`, `username`, @@ -219,7 +220,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) { } function searchSomeUsersByStatus($n, $m, $keyword, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT `userID`, `username`, @@ -248,7 +249,7 @@ function searchSomeUsersByStatus($n, $m, $keyword, $status) { } function countSomeUsersByStatus($keyword, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT COUNT(*) FROM @@ -271,7 +272,7 @@ function countSomeUsersByStatus($keyword, $status) { function changeUserStatusByID($id, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" UPDATE `user` SET @@ -287,7 +288,7 @@ function changeUserStatusByID($id, $status) { } function changeMultipleUserStatusByID($ids, $status) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" UPDATE `user` SET @@ -304,7 +305,7 @@ function changeMultipleUserStatusByID($ids, $status) { } function selectRandomNotFriendUser($userID) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `user`.`username` FROM @@ -332,7 +333,7 @@ function selectRandomNotFriendUser($userID) { } function searchSomeUsers($n, $m, $search) { - $stmt = $GLOBALS["db"]->prepare(" + $stmt = prepareQuery(" SELECT `userID`, `username`, @@ -367,7 +368,7 @@ function searchSomeUsers($n, $m, $search) { } function countSomeUsers($search) { - $q = $GLOBALS["db"]->prepare(" + $q = prepareQuery(" SELECT COUNT(*) FROM @@ -389,7 +390,7 @@ function countSomeUsers($search) { } function getRoleByID($userID) { - $stmt = $GLOBALS['db']->prepare(" + $stmt = prepareQuery(" SELECT `role` FROM diff --git a/website/views/group.php b/website/views/group.php index b2098c7..24cf9d5 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -13,88 +13,24 @@

\"""; + echo "\"""; } ?>

-
-

Lorem

-

Lorem ipsum dolor sit amet, consectetur.

-

Enkele minuten geleden geplaatst

-
-
-

Image

- Olympic Mountains, Washington -

Gisteren geplaatst

-
-
-

Ipsum

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem nihil alias amet dolores fuga totam sequi a cupiditate ipsa voluptas id facilis nobis.

-

Maandag geplaatst

-
-
-

Dolor

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

-

4 Januari geplaatst

-
-
-

Sit

-

Lorem ipsum dolor sit.

-

4 Januari geplaatst

-
-
-

Image

- Nunobiki Falls, Kobe Japan -

4 Januari geplaatst

-
-
-

Amet

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima asperiores eveniet vero velit eligendi aliquid in.

-

4 Januari geplaatst

-
-
-

Consectetur

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error aliquid reprehenderit expedita odio beatae est.

-

4 Januari geplaatst

-
-
-

Adipisicing

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat architecto quis tenetur fugiat veniam iste molestiae fuga labore!

-

4 Januari geplaatst

-
-
-

Elit

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem ut debitis dolorum earum expedita eveniet voluptatem quibusdam facere eos numquam commodi ad iusto laboriosam rerum aliquam.

-

4 Januari geplaatst

-
-
-

Geen error

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloribus dolorem maxime minima animi cum.

-

4 Januari geplaatst

-
-
-

Image

- Oregon cliffs are no joke. -

4 Januari geplaatst

-
-
-

Aliquid

-

Lorem ipsum dolor sit amet, consectetur.

-

4 Januari geplaatst

-
-
-

Odit

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit accusamus tempore at porro officia rerum est impedit ea ipsa tenetur. Labore libero hic error sunt laborum expedita.

-

4 Januari geplaatst

-
-
-

Accusamus

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis quaerat suscipit ad.

-

4 Januari geplaatst

-
+
+ \ No newline at end of file diff --git a/website/views/head.php b/website/views/head.php index b6c2f21..eb86d56 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -5,7 +5,6 @@ -
- +
$content
diff --git a/website/views/notification-center.php b/website/views/notification-center.php index ee5622e..7630b75 100644 --- a/website/views/notification-center.php +++ b/website/views/notification-center.php @@ -1,9 +1,20 @@