From ac83bb750bbe3359904f8d3b0e90788c0064c304 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 23 Jan 2017 16:05:22 +0100 Subject: [PATCH 001/201] fix status for enums, fix pages --- website/views/adminpanel.php | 64 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index e53d679..834f54f 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -85,37 +85,37 @@ $listm = $currentpage * $perpage;

Show:

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

Show:

- > + >
- > + >
- > + >
@@ -138,11 +138,11 @@ $listm = $currentpage * $perpage; id="admin-batchform" action="" method="post"> - +
- +
- +

@@ -154,11 +154,11 @@ $listm = $currentpage * $perpage; id="admin-groupbatchform" action="" method="post"> - +
- +
- +

@@ -225,7 +225,7 @@ $listm = $currentpage * $perpage; $listm = $currentpage * $perpage; if ($pagetype == 'user') { - $q = searchSomeUsersByStatus($listn, $listm, $search, $status); + $q = searchSomeUsersByStatus($listn, $perpage, $search, $status); while($user = $q->fetch(PDO::FETCH_ASSOC)) { $userID = $user['userID']; @@ -252,9 +252,9 @@ $listm = $currentpage * $perpage; action='$thispage' method='post'> @@ -264,7 +264,7 @@ $listm = $currentpage * $perpage; "); } } else { - $q = searchSomeGroupsByStatus($listn, $listm, $search, $groupstatus); + $q = searchSomeGroupsByStatus($listn, $perpage, $search, $groupstatus); while ($group = $q->fetch(PDO::FETCH_ASSOC)) { $groupID = $group['groupID']; @@ -291,9 +291,9 @@ $listm = $currentpage * $perpage; action='$thispage' method='post'> -- 2.49.1 From 119c82e110733468f1ff965b0777279b11c36c48 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 23 Jan 2017 16:27:54 +0100 Subject: [PATCH 002/201] minor color and text fixes --- website/public/styles/search.css | 2 +- website/queries/user.php | 5 ++++- website/views/search-view.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/website/public/styles/search.css b/website/public/styles/search.css index 86fd41d..565723e 100644 --- a/website/public/styles/search.css +++ b/website/public/styles/search.css @@ -25,5 +25,5 @@ } li.search-item:hover{ - background-color: #EEE; + background-color: #FBC02D; } \ No newline at end of file diff --git a/website/queries/user.php b/website/queries/user.php index 0af5262..649d976 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -278,7 +278,10 @@ function searchSomeUsers($n, $m, $search) $stmt = $GLOBALS["db"]->prepare(" SELECT `username`, - `profilepicture`, + IFNULL( + `profilepicture`, + '../img/notbad.jpg' + ) AS profilepicture, `fname`, `lname` FROM diff --git a/website/views/search-view.php b/website/views/search-view.php index ad93659..83d5bc0 100644 --- a/website/views/search-view.php +++ b/website/views/search-view.php @@ -38,7 +38,7 @@ $group_count = countSomeGroups($search)->fetchColumn(); > > - @@ -79,22 +83,9 @@ $group_count = countSomeGroups($search)->fetchColumn(); @@ -122,42 +113,9 @@ $group_count = countSomeGroups($search)->fetchColumn(); -- 2.49.1 From b66c108f4ec105ed990c804581197b03beb2ac52 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 26 Jan 2017 14:31:45 +0100 Subject: [PATCH 046/201] Fixed post titles for htmlchars. --- website/public/js/masonry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 0b31443..6b91e4b 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -100,7 +100,7 @@ function masonry(mode) { */ jQuery.each(posts, function() { $post = $("
"); - $post.append($("

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

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

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

").text(this["nicetime"])); -- 2.49.1 From 96f70e1a113ee487e65af9e0ab3adebf3d5a29e7 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Thu, 26 Jan 2017 14:50:41 +0100 Subject: [PATCH 047/201] Fixed date and other extras --- website/public/login.php | 6 +-- website/public/register.php | 17 ++++++-- website/public/styles/index.css | 7 ++- website/queries/checkInput.php | 23 +++++++--- website/queries/login.php | 6 +-- website/queries/register.php | 26 ++++++----- website/views/login-view.php | 77 +++++++++++++++++---------------- website/views/register-view.php | 66 ++++++++++++++++++++++++---- 8 files changed, 156 insertions(+), 72 deletions(-) diff --git a/website/public/login.php b/website/public/login.php index 0515793..d4dd991 100644 --- a/website/public/login.php +++ b/website/public/login.php @@ -20,15 +20,15 @@ } // Define variables and set to empty values - $uname = $psw =""; + $user = $psw =""; $loginErr = $resetErr =""; if ($_SERVER["REQUEST_METHOD"] == "POST") { switch ($_POST["submit"]) { case "login": try { - $uname = ($_POST["uname"]); - validateLogin($_POST["uname"], $_POST["psw"]); + $user = ($_POST["user"]); + validateLogin($_POST["user"], $_POST["psw"]); } catch(loginException $e) { $loginErr = $e->getMessage(); } diff --git a/website/public/register.php b/website/public/register.php index 1ce4817..0077e62 100644 --- a/website/public/register.php +++ b/website/public/register.php @@ -14,9 +14,12 @@ header("location: login.php"); } // define variables and set to empty values - $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $captcha = $ip = ""; - $genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $captchaErr = ""; + $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = ""; + $genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = ""; $correct = true; + $day_date = "dag"; + $month_date = "maand"; + $year_date = "jaar"; // Trying to register an account if ($_SERVER["REQUEST_METHOD"] == "POST") { @@ -38,7 +41,10 @@ } try{ - $bday = test_input(($_POST["bday"])); + $day_date = test_input(($_POST["day_date"])); + $month_date = test_input(($_POST["month_date"])); + $year_date = test_input(($_POST["year_date"])); + $bday = $year_date . "-" . $month_date . "-" . $day_date; checkInputChoice($bday, "bday"); } catch(bdayException $e){ $correct = false; @@ -76,9 +82,14 @@ try{ $email = test_input(($_POST["email"])); checkInputChoice($email, "email"); + $confirmEmail = test_input(($_POST["confirmEmail"])); + matchEmail(); } catch(emailException $e){ $correct = false; $emailErr = $e->getMessage(); + } catch(confirmEmailException $e){ + $correct = false; + $confirmEmailErr = $e->getMessage(); } try{ diff --git a/website/public/styles/index.css b/website/public/styles/index.css index 97d6f63..9829688 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -133,6 +133,10 @@ label { width: 45%; } +select{ + width: 18%; +} + ul { font-family: Arial; font-size: 16px; @@ -203,7 +207,6 @@ ul { .modal-body {padding: 2px 16px;} .modal-footer { - padding: 2px 16px; background-color: #FBC02D; color: black; -} \ No newline at end of file +} diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 9b91833..fbf64a7 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -38,8 +38,7 @@ function checkName($variable){ if (empty($variable)) { throw new lettersAndSpacesException("Verplicht!"); } else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) { - - throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!"); + throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!"); } } @@ -48,12 +47,12 @@ function validateBday($variable){ if (empty($variable)) { throw new bdayException("Verplicht!"); } else { - if (!(validateDate($variable, "Y/m/d"))) { + if (!(validateDate($variable, "Y-m-d"))) { throw new bdayException("Geen geldige datum"); } else { - $dateNow = date("Y/m/d"); + $dateNow = date("Y-m-d"); if ($dateNow < $variable) { - throw new bdayException("Geen geldige datum"); + throw new bdayException("Geen geldige datum!"); } } } @@ -97,6 +96,12 @@ function validateEmail($variable){ } } +function matchEmail(){ + if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){ + throw new confirmEmailException("Emails matchen niet!"); + } +} + /* checks if an input is a valid email. */ function resetEmail($variable){ if (empty($variable)) { @@ -206,6 +211,14 @@ class emailException extends Exception } } +class confirmEmailException extends Exception +{ + public function __construct($message = "", $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } +} + class captchaException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) diff --git a/website/queries/login.php b/website/queries/login.php index 2af255a..15a5de1 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -9,10 +9,10 @@ function getUser() { FROM `user` WHERE - `username` LIKE :username + `username` LIKE :username OR + `email` LIKE :username "); - $stmt->bindParam(":username", $_POST["uname"]); $stmt->execute(); return $stmt->fetch(PDO::FETCH_ASSOC); } @@ -20,7 +20,7 @@ function getUser() { function validateLogin($username, $password){ // Empty username or password field if (empty($username) || empty($password)) { - throw new loginException("Gebruikersnaam of wachtwoord is niet ingevuld"); + throw new loginException("Inloggegevens zijn niet ingevuld"); } else { $psw = test_input($password); diff --git a/website/queries/register.php b/website/queries/register.php index 738ef43..be9d415 100644 --- a/website/queries/register.php +++ b/website/queries/register.php @@ -10,7 +10,7 @@ function getExistingUsername() { `username` LIKE :username "); - $stmt->bindParam(":username", $_POST["username"]); + $stmt->bindParam(":username", test_input($_POST["username"])); $stmt->execute(); return $stmt->rowCount(); @@ -26,7 +26,7 @@ function getExistingEmail() { `email` LIKE :email "); - $stmt->bindParam(":email", $_POST["email"]); + $stmt->bindParam(":email", test_input($_POST["email"])); $stmt->execute(); return $stmt->rowCount(); @@ -42,7 +42,7 @@ function getResetEmail() { `email` LIKE :email "); - $stmt->bindParam(":email", $_POST["forgotEmail"]); + $stmt->bindParam(":email", test_input($_POST["forgotEmail"])); $stmt->execute(); return $stmt->rowCount(); @@ -70,15 +70,21 @@ function registerAccount() { $hash=password_hash($_POST["password"], PASSWORD_DEFAULT); - $stmt->bindParam(":fname", $_POST["name"]); - $stmt->bindParam(":lname", $_POST["surname"]); - $stmt->bindParam(":bday", $_POST["bday"]); - $stmt->bindParam(":username", $_POST["username"]); - $stmt->bindParam(":password", $hash); - $stmt->bindParam(":location", $_POST["location"]); - $stmt->bindParam(":email", (strtolower($_POST["email"]))); + $stmt->bindParam(":fname", test_input($_POST["name"])); + $stmt->bindParam(":lname", test_input($_POST["surname"])); + $stmt->bindParam(":bday", test_input($_POST["bday"])); + $stmt->bindParam(":username", test_input($_POST["username"])); + $stmt->bindParam(":password", test_input($hash)); + $stmt->bindParam(":location", test_input($_POST["location"])); + $stmt->bindParam(":email", test_input(strtolower($_POST["email"]))); $stmt->execute(); $stmt->rowCount(); } + +function submitselect($date, $value){ + if ($date == $value){ + echo "selected"; + } +} ?> diff --git a/website/views/login-view.php b/website/views/login-view.php index de4c48b..c64590e 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -13,11 +13,11 @@

@@ -47,46 +47,47 @@

- - -- 2.49.1 From 7073995534742cc2d479f182774d13e2e439b7cf Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 26 Jan 2017 17:03:11 +0100 Subject: [PATCH 053/201] Stop before Genius Bar visit --- website/public/API/postComment.php | 22 ++++++++--- website/public/styles/post-popup.css | 5 +++ website/queries/post.php | 55 +++++++++++++++++++++++++++- website/views/post-view.php | 4 +- 4 files changed, 77 insertions(+), 9 deletions(-) diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index b840e0b..bbe39b1 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -5,14 +5,24 @@ session_start(); require("../../queries/post.php"); require("../../queries/connect.php"); require("../../queries/checkInput.php"); -if (empty($_POST['newcomment-content'])) { - echo 0; -} else { - if(makeComment($_POST['postID'], - $_SESSION['userID'], - test_input($_POST['newcomment-content']))) { +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; + } + } +} elseif ($_POST["button"] == "nietslecht") { + if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) { echo 1; } else { echo 0; } +} else { + echo 0; } \ No newline at end of file diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 11fe03b..5522743 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -69,4 +69,9 @@ .commentcontent { margin: 5px auto; width: 95%; +} + +.nietslecht { + font-family: Impact, sans-serif; + text-shadow: -1.5px 0 1px black, 0 1.5px 1px black, 1px 0 1.5px black, 0 -1.5px 1px black; } \ No newline at end of file diff --git a/website/queries/post.php b/website/queries/post.php index 5940267..59e7a91 100644 --- a/website/queries/post.php +++ b/website/queries/post.php @@ -75,7 +75,7 @@ function makePost($userID, $groupID, $title, $content) { $stmt->execute(); } -function makeComment($postID, $userID, $content) { +function makeComment($postID, $userID, $content) : int { $stmt = $GLOBALS["db"]->prepare(" INSERT INTO `comment` ( @@ -94,4 +94,55 @@ function makeComment($postID, $userID, $content) { $stmt->bindParam(':userID', $userID); $stmt->bindParam(':content', $content); $stmt->execute(); -} \ No newline at end of file + return $stmt->rowCount(); +} + +function makeNietSlecht(int $postID, int $userID) : int { + if (checkNietSlecht($postID, $userID)) { + return deleteNietSlecht(postID, $userID); + } else { + return addNietSlecht($postID, $userID); + } +} + +function checkNietSlecht(int $postID, int $userID) { + $stmt = $GLOBALS["db"]->prepare(" + SELECT + * + FROM + `niet_slecht` + WHERE + `userID` = :userID AND + `postID` = :postID + "); + $stmt->bindParam(":userID", $userID); + $stmt->bindParam(":postID", $postID); + $stmt->execute(); + return $stmt->rowCount(); +} + +function addNietSlecht(int $postID, int $userID) { + $stmt = $GLOBALS["db"]->prepare(" + INSERT INTO + `niet_slecht` (`userID`, `postID`) + VALUES (:userID, :postID) + "); + $stmt->bindParam(":userID", $userID); + $stmt->bindParam(":postID", $postID); + $stmt->execute(); + return $stmt->rowCount(); +} + +function deleteNietSlecht(int $postID, int $userID) { + $stmt = $GLOBALS["db"]->prepare(" + DELETE FROM + `niet_slecht` + WHERE + `userID` = :userID AND + `postID` = :postID + "); + $stmt->bindParam(":userID", $userID); + $stmt->bindParam(":postID", $postID); + $stmt->execute(); + return $stmt->rowCount(); +} diff --git a/website/views/post-view.php b/website/views/post-view.php index 61e0e05..37e64b5 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -24,7 +24,9 @@ echo("

- + + +
-- 2.49.1 From 032e25b044c11d0018dfb506de4a9d3d21496f05 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 21:50:47 +0100 Subject: [PATCH 054/201] You can now only chat with friends --- website/public/API/sendMessage.php | 1 + website/queries/private_message.php | 2 +- website/views/chat-view.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/website/public/API/sendMessage.php b/website/public/API/sendMessage.php index c5d47d1..f84cb11 100644 --- a/website/public/API/sendMessage.php +++ b/website/public/API/sendMessage.php @@ -3,6 +3,7 @@ session_start(); require_once("../../queries/connect.php"); require_once("../../queries/private_message.php"); +require_once("../../queries/friendship.php"); require_once("../../queries/checkInput.php"); if (!empty(test_input($_POST["destination"])) && diff --git a/website/queries/private_message.php b/website/queries/private_message.php index d2b1537..369ee40 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -58,7 +58,7 @@ function sendMessage($destination, $content) { } function getNewChatMessages($lastID, $destination) { - if (getFriendshipStatus($user2ID) == 1) { + if (getFriendshipStatus($destination) == 1) { $stmt = $GLOBALS["db"]->prepare(" SELECT * diff --git a/website/views/chat-view.php b/website/views/chat-view.php index 0d90149..974b441 100644 --- a/website/views/chat-view.php +++ b/website/views/chat-view.php @@ -74,6 +74,7 @@ name="content" id="newContent" placeholder="Schrijf een bericht..." + autocomplete="off" autofocus required /> -- 2.49.1 From d89e672990325f96c060f3cbb74854eed4519289 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 21:54:47 +0100 Subject: [PATCH 055/201] Also fixed unread chat --- website/public/API/sendMessage.php | 1 - website/queries/private_message.php | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/website/public/API/sendMessage.php b/website/public/API/sendMessage.php index f84cb11..c5d47d1 100644 --- a/website/public/API/sendMessage.php +++ b/website/public/API/sendMessage.php @@ -3,7 +3,6 @@ session_start(); require_once("../../queries/connect.php"); require_once("../../queries/private_message.php"); -require_once("../../queries/friendship.php"); require_once("../../queries/checkInput.php"); if (!empty(test_input($_POST["destination"])) && diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 369ee40..4d48d3a 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -30,6 +30,7 @@ function getOldChatMessages($user2ID) { } function sendMessage($destination, $content) { + require_once("friendship.php"); if (getFriendshipStatus($destination) == 1) { $stmt = $GLOBALS["db"]->prepare(" INSERT INTO @@ -58,6 +59,7 @@ function sendMessage($destination, $content) { } function getNewChatMessages($lastID, $destination) { + require_once("friendship.php"); if (getFriendshipStatus($destination) == 1) { $stmt = $GLOBALS["db"]->prepare(" SELECT @@ -91,13 +93,13 @@ function getNewChatMessages($lastID, $destination) { function selectAllUnreadChat() { $stmt = $GLOBALS["db"]->prepare(" SELECT - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`, `user`.`userID`, IFNULL( `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - LEFT(`private_message`.`content`, 15) as `content` + LEFT(`private_message`.`content`, 15) AS `content` FROM `private_message`, `friendship`, -- 2.49.1 From f1bfc89e6afafc61456c4652fade6f197ebd6a26 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 22:33:32 +0100 Subject: [PATCH 056/201] Custom scrollbar --- website/public/styles/main.css | 13 +++++++++++++ website/public/styles/profile.css | 1 + 2 files changed, 14 insertions(+) diff --git a/website/public/styles/main.css b/website/public/styles/main.css index abda8be..0c37afa 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -275,3 +275,16 @@ div[data-title]:hover:after { display: inline-block; 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; +} \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 85b2db5..becbeca 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -30,6 +30,7 @@ div.posts div.post { width: calc(100% - 40px); cursor: pointer; transition-duration: 250ms; + word-wrap: break-word; } div.posts div.post:hover { -- 2.49.1 From cbff973b631126093c0b8dad90dcb3513eca38ba Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 27 Jan 2017 11:15:33 +0100 Subject: [PATCH 057/201] Save manu state with cookie --- website/public/js/header.js | 11 ++++++++++- website/public/js/main.js | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/website/public/js/header.js b/website/public/js/header.js index 9889bdb..bdf5fe3 100644 --- a/website/public/js/header.js +++ b/website/public/js/header.js @@ -1,5 +1,4 @@ $(document).ready(function() { - // Toggle menu $("#own-profile-picture, #open-notifications").click(function() { if ($("#notification-center").css('right') == "-256px") { @@ -8,12 +7,22 @@ $(document).ready(function() { $(".modal").width("calc(100% - 512px)"); $(".content").css("margin-right", "256px"); $("#notification-center").css("right", "0px"); + + // Add cookie so the menu stays open on other pages + document.cookie = "menu=open; path=/"; } else { // Make the menu invisible and move the content to the right. $("#chat-history").width("calc(100% - 331px)"); $(".modal").width("calc(100% - 256px)"); $(".content").css("margin-right", "0px"); $("#notification-center").css("right", "-256px"); + + // Change menu cookie to close + document.cookie = "menu=closed; path=/"; } }); + + if (getCookie("menu") == "open") { + $("#own-profile-picture").click(); + } }); diff --git a/website/public/js/main.js b/website/public/js/main.js index 8a52797..5622827 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -1,3 +1,14 @@ +function getCookie(key) { + cookies = document.cookie.split("; "); + for (var i in cookies) { + cookie = cookies[i].split("="); + if (cookie[0] == key) { + return cookie[1]; + } + } + return false; +} + function editFriendship(userID, value) { $.post("API/editFriendship.php", { usr: userID, action: value }) .done(function() { -- 2.49.1 From 3b542e08789c15641248b1e315755e6134f4e38b Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 27 Jan 2017 12:20:50 +0100 Subject: [PATCH 058/201] "Niet slecht."-button! --- website/public/API/postComment.php | 5 +++-- website/public/js/post.js | 10 +++++----- website/public/profile.php | 1 + website/public/styles/post-popup.css | 2 +- website/queries/post.php | 2 +- website/views/post-view.php | 15 ++++++++++++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index bbe39b1..30c02eb 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -5,7 +5,8 @@ session_start(); require("../../queries/post.php"); require("../../queries/connect.php"); require("../../queries/checkInput.php"); -if ($_POST["button"] == "reaction") { +print_r($_POST); +if ($_POST['button'] == 'reaction') { if (empty($_POST['newcomment-content'])) { echo 0; } else { @@ -17,7 +18,7 @@ if ($_POST["button"] == "reaction") { echo 0; } } -} elseif ($_POST["button"] == "nietslecht") { +} else if ($_POST['button'] == 'nietslecht') { if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) { echo 1; } else { diff --git a/website/public/js/post.js b/website/public/js/post.js index 62ace68..1906428 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -1,7 +1,9 @@ -function postComment() { +function postComment(buttonValue) { + formData = $("#newcommentform").serializeArray(); + formData.push({name: "button", value: buttonValue}); $.post( "API/postComment.php", - $("#newcommentform").serialize() + formData ); $("#newcomment").val(""); @@ -13,6 +15,4 @@ function postComment() { ).done(function (data) { $('#modal-response').html(data); }); -} - - +} \ No newline at end of file diff --git a/website/public/profile.php b/website/public/profile.php index a79ad4c..95c5b86 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -8,6 +8,7 @@ diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 5522743..c6e96c1 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -72,6 +72,6 @@ } .nietslecht { - font-family: Impact, sans-serif; + 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; } \ No newline at end of file diff --git a/website/queries/post.php b/website/queries/post.php index 59e7a91..df1e227 100644 --- a/website/queries/post.php +++ b/website/queries/post.php @@ -99,7 +99,7 @@ function makeComment($postID, $userID, $content) : int { function makeNietSlecht(int $postID, int $userID) : int { if (checkNietSlecht($postID, $userID)) { - return deleteNietSlecht(postID, $userID); + return deleteNietSlecht($postID, $userID); } else { return addNietSlecht($postID, $userID); } diff --git a/website/views/post-view.php b/website/views/post-view.php index 37e64b5..4e0ddb1 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -2,6 +2,7 @@ $postID = $_GET['postID']; $post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC); $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")"; +session_start(); echo("
@@ -21,12 +22,20 @@ echo("
-
+
- + - +
-- 2.49.1 From f27b9ec6b41f85f519c50961e53eb516e3ec842a Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 27 Jan 2017 12:22:26 +0100 Subject: [PATCH 059/201] Chat messages split per day --- website/public/js/chat.js | 18 ++++++++++++++++-- website/public/js/main.js | 3 +++ website/public/js/search.js | 2 -- website/public/styles/chat.css | 21 +++++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 06f85df..2b2fe34 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -1,3 +1,5 @@ +var previousDate = new Date("1970-01-01 00:00:00"); + $(document).ready(function() { loadMessages(); sayEmpty(); @@ -31,13 +33,25 @@ function sendMessage() { } function addMessages(messages) { - for(i in messages) { + for(var i in messages) { + thisDate = new Date(messages[i].creationdate); + thisDate.setHours(0,0,0,0); if (messages[i].destination == $(".destinationID").val()) { type = "chat-message-self"; } else { type = "chat-message-other"; } - + if (thisDate > previousDate) { + console.log(previousDate); + previousDate = thisDate; + $("#chat-history").append('\ +
\ +
\ + ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ +
\ +
\ + '); + } $("#chat-history").append('\
\
\ diff --git a/website/public/js/main.js b/website/public/js/main.js index 5622827..587f020 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -1,3 +1,6 @@ +var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"]; +var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"] + function getCookie(key) { cookies = document.cookie.split("; "); for (var i in cookies) { diff --git a/website/public/js/search.js b/website/public/js/search.js index b3c322a..c026b64 100644 --- a/website/public/js/search.js +++ b/website/public/js/search.js @@ -8,7 +8,6 @@ function searchUsers(n, m) { filter: $("#search-filter").val() } ).done(function(data) { - console.log(data); if (!showFriends(data, "#search-users-list", 0, "profile.php", "GET")) { $("#search-users-list").text("Niemand gevonden"); } @@ -25,7 +24,6 @@ function searchGroups(n, m) { filter: $("#search-filter").val() } ).done(function(data) { - console.log(data); if (!showGroups(data, "#search-groups-list")) { $("#search-groups-list").text("Geen groepen gevonden"); } diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css index 6822d21..600bb41 100644 --- a/website/public/styles/chat.css +++ b/website/public/styles/chat.css @@ -1,3 +1,8 @@ + +body { + overflow: hidden; +} + /* Overall chat-screen */ .chat { position: fixed; @@ -37,6 +42,22 @@ } /* Chat-message takes the whole width of the chat area */ +.day-message { + width: 100%; + min-height: 40px; + padding: 10px 0; + clear: both; + text-align: center; +} + +.day-message-content { + width: auto; + padding: 10px; + + background-color: #F8F8F8; + color: #666; +} + .chat-message { width: 100%; min-height: 40px; -- 2.49.1 From 609f350cd344812617a94a18847aa2590fd94044 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 27 Jan 2017 12:27:40 +0100 Subject: [PATCH 060/201] Made different files for login and register --- website/public/login.php | 102 +-------- website/public/register(stash).php | 115 +++++++++++ website/public/register.php | 187 ++++++++--------- website/public/styles/index.css | 31 +-- website/queries/login.php | 5 +- website/views/bdayInput.php | 37 ++++ website/views/forgotPasswordModal.php | 35 ++++ website/views/login-view.php | 286 ++++---------------------- website/views/register-view.php | 8 - website/views/registerModal.php | 155 ++++++++++++++ 10 files changed, 482 insertions(+), 479 deletions(-) create mode 100644 website/public/register(stash).php create mode 100644 website/views/bdayInput.php create mode 100644 website/views/forgotPasswordModal.php create mode 100644 website/views/registerModal.php diff --git a/website/public/login.php b/website/public/login.php index 81fee57..9fd7fb0 100644 --- a/website/public/login.php +++ b/website/public/login.php @@ -28,7 +28,7 @@ $year_date = "jaar"; // Define variables and set to empty values - $user = $psw =""; + $user = $psw = $remember =""; $loginErr = $resetErr =""; if ($_SERVER["REQUEST_METHOD"] == "POST") { @@ -55,107 +55,9 @@ } break; case "register": - try { - $name = test_input(($_POST["name"])); - checkInputChoice($name, "lettersAndSpaces"); - } catch(lettersAndSpacesException $e){ - $correct = false; - $nameErr = $e->getMessage(); - } - - try { - $surname = test_input(($_POST["surname"])); - checkInputChoice($surname, "lettersAndSpaces"); - } - catch(lettersAndSpacesException $e){ - $correct = false; - $surnameErr = $e->getMessage(); - } - - try{ - $day_date = test_input(($_POST["day_date"])); - $month_date = test_input(($_POST["month_date"])); - $year_date = test_input(($_POST["year_date"])); - $bday = $year_date . "-" . $month_date . "-" . $day_date; - checkInputChoice($bday, "bday"); - } catch(bdayException $e){ - $correct = false; - $bdayErr = $e->getMessage(); - } - - try{ - $username = str_replace(' ', '', test_input(($_POST["username"]))); - checkInputChoice($username, "username"); - } catch(usernameException $e){ - $correct = false; - $usernameErr = $e->getMessage(); - } - - try{ - $password = str_replace(' ', '', test_input(($_POST["password"]))); - checkInputChoice($password, "longerEight"); - matchPassword(); - } catch(passwordException $e){ - $correct = false; - $passwordErr = $e->getMessage(); - } catch(confirmPasswordException $e){ - $correct = false; - $confirmPasswordErr = $e->getMessage(); - } - - try{ - $location = test_input(($_POST["location"])); - checkInputChoice($location, "lettersAndSpaces"); - } catch(lettersAndSpacesException $e){ - $correct = false; - $locationErr = $e->getMessage(); - } - - try{ - $email = test_input(($_POST["email"])); - checkInputChoice($email, "email"); - $confirmEmail = test_input(($_POST["confirmEmail"])); - matchEmail(); - } catch(emailException $e){ - $correct = false; - $emailErr = $e->getMessage(); - } catch(confirmEmailException $e){ - $correct = false; - $confirmEmailErr = $e->getMessage(); - } - - try{ - $captcha = $_POST['g-recaptcha-response']; - checkCaptcha($captcha); - } catch(captchaException $e){ - $correct = false; - $captchaErr = $e->getMessage(); - } - - try { - getIp(); - registerCheck($correct); - sendConfirmEmailUsername($username); - } catch(registerException $e){ - echo ""; - $genericErr = $e->getMessage(); - } + include("register.php"); } } -// // Trying to login -// if ($_SERVER["REQUEST_METHOD"] == "POST") { -// try{ -// $uname = ($_POST["uname"]); -// validateLogin($_POST["uname"], $_POST["psw"]); -// } catch(loginException $e) { -// $loginErr = $e->getMessage(); -// } -// } - /* This view adds login view */ include("../views/login-view.php"); ?> diff --git a/website/public/register(stash).php b/website/public/register(stash).php new file mode 100644 index 0000000..0077e62 --- /dev/null +++ b/website/public/register(stash).php @@ -0,0 +1,115 @@ + + + + +getMessage(); + } + + try { + $surname = test_input(($_POST["surname"])); + checkInputChoice($surname, "lettersAndSpaces"); + } + catch(lettersAndSpacesException $e){ + $correct = false; + $surnameErr = $e->getMessage(); + } + + try{ + $day_date = test_input(($_POST["day_date"])); + $month_date = test_input(($_POST["month_date"])); + $year_date = test_input(($_POST["year_date"])); + $bday = $year_date . "-" . $month_date . "-" . $day_date; + checkInputChoice($bday, "bday"); + } catch(bdayException $e){ + $correct = false; + $bdayErr = $e->getMessage(); + } + + try{ + $username = str_replace(' ', '', test_input(($_POST["username"]))); + checkInputChoice($username, "username"); + } catch(usernameException $e){ + $correct = false; + $usernameErr = $e->getMessage(); + } + + try{ + $password = str_replace(' ', '', test_input(($_POST["password"]))); + checkInputChoice($password, "longerEight"); + matchPassword(); + } catch(passwordException $e){ + $correct = false; + $passwordErr = $e->getMessage(); + } catch(confirmPasswordException $e){ + $correct = false; + $confirmPasswordErr = $e->getMessage(); + } + + try{ + $location = test_input(($_POST["location"])); + checkInputChoice($location, "lettersAndSpaces"); + } catch(lettersAndSpacesException $e){ + $correct = false; + $locationErr = $e->getMessage(); + } + + try{ + $email = test_input(($_POST["email"])); + checkInputChoice($email, "email"); + $confirmEmail = test_input(($_POST["confirmEmail"])); + matchEmail(); + } catch(emailException $e){ + $correct = false; + $emailErr = $e->getMessage(); + } catch(confirmEmailException $e){ + $correct = false; + $confirmEmailErr = $e->getMessage(); + } + + try{ + $captcha = $_POST['g-recaptcha-response']; + checkCaptcha($captcha); + } catch(captchaException $e){ + $correct = false; + $captchaErr = $e->getMessage(); + } + + try { + getIp(); + registerCheck($correct); + sendConfirmEmailUsername($username); + } catch(registerException $e){ + $genericErr = $e->getMessage(); + } + } +/* This view adds register view */ +include("../views/register-view.php"); +?> + + diff --git a/website/public/register.php b/website/public/register.php index 0077e62..ee19930 100644 --- a/website/public/register.php +++ b/website/public/register.php @@ -1,115 +1,90 @@ - - - -getMessage(); +} - // Trying to register an account - if ($_SERVER["REQUEST_METHOD"] == "POST") { - try { - $name = test_input(($_POST["name"])); - checkInputChoice($name, "lettersAndSpaces"); - } catch(lettersAndSpacesException $e){ - $correct = false; - $nameErr = $e->getMessage(); - } +try { + $surname = test_input(($_POST["surname"])); + checkInputChoice($surname, "lettersAndSpaces"); +} +catch(lettersAndSpacesException $e){ + $correct = false; + $surnameErr = $e->getMessage(); +} - try { - $surname = test_input(($_POST["surname"])); - checkInputChoice($surname, "lettersAndSpaces"); - } - catch(lettersAndSpacesException $e){ - $correct = false; - $surnameErr = $e->getMessage(); - } +try{ + $day_date = test_input(($_POST["day_date"])); + $month_date = test_input(($_POST["month_date"])); + $year_date = test_input(($_POST["year_date"])); + $bday = $year_date . "-" . $month_date . "-" . $day_date; + checkInputChoice($bday, "bday"); +} catch(bdayException $e){ + $correct = false; + $bdayErr = $e->getMessage(); +} - try{ - $day_date = test_input(($_POST["day_date"])); - $month_date = test_input(($_POST["month_date"])); - $year_date = test_input(($_POST["year_date"])); - $bday = $year_date . "-" . $month_date . "-" . $day_date; - checkInputChoice($bday, "bday"); - } catch(bdayException $e){ - $correct = false; - $bdayErr = $e->getMessage(); - } +try{ + $username = str_replace(' ', '', test_input(($_POST["username"]))); + checkInputChoice($username, "username"); +} catch(usernameException $e){ + $correct = false; + $usernameErr = $e->getMessage(); +} - try{ - $username = str_replace(' ', '', test_input(($_POST["username"]))); - checkInputChoice($username, "username"); - } catch(usernameException $e){ - $correct = false; - $usernameErr = $e->getMessage(); - } +try{ + $password = str_replace(' ', '', test_input(($_POST["password"]))); + checkInputChoice($password, "longerEight"); + matchPassword(); +} catch(passwordException $e){ + $correct = false; + $passwordErr = $e->getMessage(); +} catch(confirmPasswordException $e){ + $correct = false; + $confirmPasswordErr = $e->getMessage(); +} - try{ - $password = str_replace(' ', '', test_input(($_POST["password"]))); - checkInputChoice($password, "longerEight"); - matchPassword(); - } catch(passwordException $e){ - $correct = false; - $passwordErr = $e->getMessage(); - } catch(confirmPasswordException $e){ - $correct = false; - $confirmPasswordErr = $e->getMessage(); - } +try{ + $location = test_input(($_POST["location"])); + checkInputChoice($location, "lettersAndSpaces"); +} catch(lettersAndSpacesException $e){ + $correct = false; + $locationErr = $e->getMessage(); +} - try{ - $location = test_input(($_POST["location"])); - checkInputChoice($location, "lettersAndSpaces"); - } catch(lettersAndSpacesException $e){ - $correct = false; - $locationErr = $e->getMessage(); - } +try{ + $email = test_input(($_POST["email"])); + checkInputChoice($email, "email"); + $confirmEmail = test_input(($_POST["confirmEmail"])); + matchEmail(); +} catch(emailException $e){ + $correct = false; + $emailErr = $e->getMessage(); +} catch(confirmEmailException $e){ + $correct = false; + $confirmEmailErr = $e->getMessage(); +} - try{ - $email = test_input(($_POST["email"])); - checkInputChoice($email, "email"); - $confirmEmail = test_input(($_POST["confirmEmail"])); - matchEmail(); - } catch(emailException $e){ - $correct = false; - $emailErr = $e->getMessage(); - } catch(confirmEmailException $e){ - $correct = false; - $confirmEmailErr = $e->getMessage(); - } +try{ + $captcha = $_POST['g-recaptcha-response']; + checkCaptcha($captcha); +} catch(captchaException $e){ + $correct = false; + $captchaErr = $e->getMessage(); +} - try{ - $captcha = $_POST['g-recaptcha-response']; - checkCaptcha($captcha); - } catch(captchaException $e){ - $correct = false; - $captchaErr = $e->getMessage(); - } - - try { - getIp(); - registerCheck($correct); - sendConfirmEmailUsername($username); - } catch(registerException $e){ - $genericErr = $e->getMessage(); - } - } -/* This view adds register view */ -include("../views/register-view.php"); -?> - - +try { + getIp(); + registerCheck($correct); + sendConfirmEmailUsername($username); +} catch(registerException $e){ + echo ""; + $genericErr = $e->getMessage(); +} \ No newline at end of file diff --git a/website/public/styles/index.css b/website/public/styles/index.css index 85cc670..f5d40a7 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -28,10 +28,10 @@ body { form { /*background-color: #a87a87;*/ border-radius: 12px; - height: 80%; + height: 85%; margin: auto; width: 600px; - overflow-y:auto; + overflow-y: auto; overflow-x: hidden; } @@ -46,13 +46,13 @@ h1 { /* registreer titel*/ h2 { - padding: 16px; + padding: 8px; text-align: left; font-size: 2.0em; } h3 { - padding: 16px; + padding: 8px; text-align: center; font-size: 1.5em; } @@ -63,7 +63,7 @@ input[type=text], input[type=password], input[type=email], input[type="date"] { display: inline-block; height: 60%; font-size: 16px; - padding: 8px 20px; + padding: 8px 10px; margin: 4px 0; width: 55%; } @@ -79,7 +79,7 @@ button { cursor: pointer; height: 50%; padding: 8px 20px; - margin: 10px; + margin: 5px; font-family: Arial; font-size: 22px; box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); @@ -90,6 +90,7 @@ button { font-family: Arial; font-size: 15px; color: red; + text-align: left; } label { @@ -98,19 +99,19 @@ label { /* padding voor registreer container */ .login_containerregister { - padding: 16px; + padding: 8px; text-align: left; } /* padding voor login_containers */ .login_containerlogin { - padding:16px; + padding:8px; text-align: center; } /* padding voor foutmelding login */ .login_containerfault { - padding: 16px; + padding: 4px; text-align: center; color: red; } @@ -129,7 +130,7 @@ label { background-attachment: fixed;*/ box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); height: 400px; - margin: 34px auto; + margin: 16px auto; overflow-y: auto; padding: 20px; width: 600px; @@ -149,12 +150,12 @@ ul { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1; /* Sit on top */ - padding-top: 100px; /* Location of the box */ + padding-top: 30px; /* Location of the box */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ - overflow: auto; /* Enable scroll if needed */ + overflow: hidden; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ } @@ -166,7 +167,7 @@ ul { margin: auto; padding: 0; border: 1px solid #888; - width: 589px; + width: 600px; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); -webkit-animation-name: animatetop; -webkit-animation-duration: 0.4s; @@ -189,7 +190,7 @@ ul { .close { color: white; float: right; - font-size: 28px; + font-size: 36px; font-weight: bold; } @@ -201,7 +202,7 @@ ul { } .modal-header { - padding: 2px 16px; + padding: 4px 16px; background-color: #FBC02D; color: black; } diff --git a/website/queries/login.php b/website/queries/login.php index 6af9e1e..b686659 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -13,7 +13,7 @@ function getUser() { `email` LIKE :username "); - $stmt->bindParam(":username", test_input($_POST["user"])); + $stmt->bindValue(":username", test_input($_POST["user"])); $stmt->execute(); return $stmt->fetch(PDO::FETCH_ASSOC); } @@ -42,6 +42,9 @@ function validateLogin($username, $password){ "; } else { $_SESSION["userID"] = $userID; + if($_POST[rememberMe] == 1){ + ini_set("session.gc_maxlifetime", "10"); + } header("location: profile.php"); } } else { diff --git a/website/views/bdayInput.php b/website/views/bdayInput.php new file mode 100644 index 0000000..f3ddecc --- /dev/null +++ b/website/views/bdayInput.php @@ -0,0 +1,37 @@ + + + diff --git a/website/views/forgotPasswordModal.php b/website/views/forgotPasswordModal.php new file mode 100644 index 0000000..a84ae68 --- /dev/null +++ b/website/views/forgotPasswordModal.php @@ -0,0 +1,35 @@ + + + + + \ No newline at end of file diff --git a/website/views/login-view.php b/website/views/login-view.php index b9052b3..fa7f8fd 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -32,6 +32,11 @@ >
+ + @@ -49,269 +54,52 @@ + +// When the user clicks anywhere outside of the modal, close it + window.onclick = function (event) { + if (event.target == modal) { + modal.style.display = "none"; + } + if (event.target == registerModal) { + registerModal.style.display = "none"; + } + } + \ No newline at end of file diff --git a/website/views/register-view.php b/website/views/register-view.php index 9577216..acb5f4b 100644 --- a/website/views/register-view.php +++ b/website/views/register-view.php @@ -41,14 +41,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
\ No newline at end of file -- 2.49.1 From ce6a75163047b4209846129d748f620565a1cbbb Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 27 Jan 2017 12:30:28 +0100 Subject: [PATCH 061/201] Niet slecht inverted --- website/views/post-view.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/views/post-view.php b/website/views/post-view.php index 4e0ddb1..e3ceb9b 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -30,9 +30,9 @@ echo(" -- 2.49.1 From 5e9629eddd5ccdf983c384602951a25f468b3081 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 27 Jan 2017 14:03:11 +0100 Subject: [PATCH 062/201] Fixed bugs --- website/public/js/registerAndLogin.js | 6 +- website/public/register.php | 155 +++++++++++++------------- website/public/styles/index.css | 4 + website/queries/checkInput.php | 4 +- website/queries/login.php | 6 +- website/queries/register.php | 20 ++-- website/views/bdayInput.php | 24 ++-- website/views/forgotPasswordModal.php | 1 + website/views/login-view.php | 15 ++- website/views/registerModal.php | 5 +- 10 files changed, 127 insertions(+), 113 deletions(-) diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js index b2fda05..87522cf 100644 --- a/website/public/js/registerAndLogin.js +++ b/website/public/js/registerAndLogin.js @@ -1,5 +1,5 @@ function checkLoggedIn() { - if (confirm("You are already logged in!\nDo you want to logout?\nPress ok to logout.") == true) { + if (confirm("U bent al ingelogd!!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) { window.location.href = "logout.php"; } else { window.location.href = "profile.php"; @@ -7,9 +7,9 @@ function checkLoggedIn() { } function bannedAlert(){ - alert("Your account is banned"); + alert("Uw account is geband!"); } function emailNotConfirmed(){ - alert("Your account has not been verified yet!\nAnother email has been sent to you") + alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen"); } diff --git a/website/public/register.php b/website/public/register.php index ee19930..6bebd7e 100644 --- a/website/public/register.php +++ b/website/public/register.php @@ -1,90 +1,91 @@ getMessage(); -} -try { - $surname = test_input(($_POST["surname"])); - checkInputChoice($surname, "lettersAndSpaces"); -} -catch(lettersAndSpacesException $e){ - $correct = false; - $surnameErr = $e->getMessage(); -} + try { + $name = test_input(($_POST["name"])); + checkInputChoice($name, "lettersAndSpaces"); + } catch(lettersAndSpacesException $e){ + $correct = false; + $nameErr = $e->getMessage(); + } -try{ - $day_date = test_input(($_POST["day_date"])); - $month_date = test_input(($_POST["month_date"])); - $year_date = test_input(($_POST["year_date"])); - $bday = $year_date . "-" . $month_date . "-" . $day_date; - checkInputChoice($bday, "bday"); -} catch(bdayException $e){ - $correct = false; - $bdayErr = $e->getMessage(); -} + try { + $surname = test_input(($_POST["surname"])); + checkInputChoice($surname, "lettersAndSpaces"); + } + catch(lettersAndSpacesException $e){ + $correct = false; + $surnameErr = $e->getMessage(); + } -try{ - $username = str_replace(' ', '', test_input(($_POST["username"]))); - checkInputChoice($username, "username"); -} catch(usernameException $e){ - $correct = false; - $usernameErr = $e->getMessage(); -} + try{ + $day_date = test_input(($_POST["day_date"])); + $month_date = test_input(($_POST["month_date"])); + $year_date = test_input(($_POST["year_date"])); + $bday = $year_date . "-" . $month_date . "-" . $day_date; + checkInputChoice($bday, "bday"); + } catch(bdayException $e){ + $correct = false; + $bdayErr = $e->getMessage(); + } -try{ - $password = str_replace(' ', '', test_input(($_POST["password"]))); - checkInputChoice($password, "longerEight"); - matchPassword(); -} catch(passwordException $e){ - $correct = false; - $passwordErr = $e->getMessage(); -} catch(confirmPasswordException $e){ - $correct = false; - $confirmPasswordErr = $e->getMessage(); -} + try{ + $username = str_replace(' ', '', test_input(($_POST["username"]))); + checkInputChoice($username, "username"); + } catch(usernameException $e){ + $correct = false; + $usernameErr = $e->getMessage(); + } -try{ - $location = test_input(($_POST["location"])); - checkInputChoice($location, "lettersAndSpaces"); -} catch(lettersAndSpacesException $e){ - $correct = false; - $locationErr = $e->getMessage(); -} + try{ + $password = str_replace(' ', '', test_input(($_POST["password"]))); + checkInputChoice($password, "longerEight"); + matchPassword(); + } catch(passwordException $e){ + $correct = false; + $passwordErr = $e->getMessage(); + } catch(confirmPasswordException $e){ + $correct = false; + $confirmPasswordErr = $e->getMessage(); + } -try{ - $email = test_input(($_POST["email"])); - checkInputChoice($email, "email"); - $confirmEmail = test_input(($_POST["confirmEmail"])); - matchEmail(); -} catch(emailException $e){ - $correct = false; - $emailErr = $e->getMessage(); -} catch(confirmEmailException $e){ - $correct = false; - $confirmEmailErr = $e->getMessage(); -} + try{ + $location = test_input(($_POST["location"])); + checkInputChoice($location, "lettersAndSpaces"); + } catch(lettersAndSpacesException $e){ + $correct = false; + $locationErr = $e->getMessage(); + } -try{ - $captcha = $_POST['g-recaptcha-response']; - checkCaptcha($captcha); -} catch(captchaException $e){ - $correct = false; - $captchaErr = $e->getMessage(); -} + try{ + $email = test_input(($_POST["email"])); + checkInputChoice($email, "email"); + $confirmEmail = test_input(($_POST["confirmEmail"])); + matchEmail(); + } catch(emailException $e){ + $correct = false; + $emailErr = $e->getMessage(); + } catch(confirmEmailException $e){ + $correct = false; + $confirmEmailErr = $e->getMessage(); + } -try { - getIp(); - registerCheck($correct); - sendConfirmEmailUsername($username); -} catch(registerException $e){ - echo ""; - $genericErr = $e->getMessage(); -} \ No newline at end of file + $genericErr = $e->getMessage(); + } diff --git a/website/public/styles/index.css b/website/public/styles/index.css index f5d40a7..6f7caf0 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -68,6 +68,10 @@ input[type=text], input[type=password], input[type=email], input[type="date"] { width: 55%; } +.middle{ + text-align: center; +} + .center{ text-align: center; } diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index fbf64a7..52b830f 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -124,11 +124,11 @@ function matchPassword(){ /* Checks if captcha is correctly filled in */ function checkCaptcha($captcha){ if(!$captcha){ - throw new captchaException("Captcha needs to be filled in!"); + throw new captchaException("Captcha moet ingevuld worde!"); } else { $response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Lc72xIUAAAAAPizuF3nUbklCPljVCVzgYespz8o&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR'])); if($response->success==false) { - throw new captchaException("You are a spammer!"); + throw new captchaException("Je bent een spammer!"); } } } diff --git a/website/queries/login.php b/website/queries/login.php index b686659..384a3d5 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -42,9 +42,9 @@ function validateLogin($username, $password){ "; } else { $_SESSION["userID"] = $userID; - if($_POST[rememberMe] == 1){ - ini_set("session.gc_maxlifetime", "10"); - } +// if($_POST[rememberMe] == 1){ +// ini_set("session.gc_maxlifetime", "10"); +// } header("location: profile.php"); } } else { diff --git a/website/queries/register.php b/website/queries/register.php index be9d415..bc44acf 100644 --- a/website/queries/register.php +++ b/website/queries/register.php @@ -10,7 +10,7 @@ function getExistingUsername() { `username` LIKE :username "); - $stmt->bindParam(":username", test_input($_POST["username"])); + $stmt->bindValue(":username", test_input($_POST["username"])); $stmt->execute(); return $stmt->rowCount(); @@ -26,7 +26,7 @@ function getExistingEmail() { `email` LIKE :email "); - $stmt->bindParam(":email", test_input($_POST["email"])); + $stmt->bindValue(":email", test_input($_POST["email"])); $stmt->execute(); return $stmt->rowCount(); @@ -42,7 +42,7 @@ function getResetEmail() { `email` LIKE :email "); - $stmt->bindParam(":email", test_input($_POST["forgotEmail"])); + $stmt->bindValue(":email", test_input($_POST["forgotEmail"])); $stmt->execute(); return $stmt->rowCount(); @@ -70,13 +70,13 @@ function registerAccount() { $hash=password_hash($_POST["password"], PASSWORD_DEFAULT); - $stmt->bindParam(":fname", test_input($_POST["name"])); - $stmt->bindParam(":lname", test_input($_POST["surname"])); - $stmt->bindParam(":bday", test_input($_POST["bday"])); - $stmt->bindParam(":username", test_input($_POST["username"])); - $stmt->bindParam(":password", test_input($hash)); - $stmt->bindParam(":location", test_input($_POST["location"])); - $stmt->bindParam(":email", test_input(strtolower($_POST["email"]))); + $stmt->bindValue(":fname", test_input($_POST["name"])); + $stmt->bindValue(":lname", test_input($_POST["surname"])); + $stmt->bindValue(":bday", test_input($_POST["bday"])); + $stmt->bindValue(":username", test_input($_POST["username"])); + $stmt->bindValue(":password", test_input($hash)); + $stmt->bindValue(":location", test_input($_POST["location"])); + $stmt->bindValue(":email", test_input(strtolower($_POST["email"]))); $stmt->execute(); $stmt->rowCount(); diff --git a/website/views/bdayInput.php b/website/views/bdayInput.php index f3ddecc..f4e440f 100644 --- a/website/views/bdayInput.php +++ b/website/views/bdayInput.php @@ -11,18 +11,18 @@ diff --git a/website/views/login-view.php b/website/views/login-view.php index fa7f8fd..8edc777 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -15,6 +15,7 @@ - - @@ -49,6 +46,11 @@ Inloggen + + @@ -78,7 +80,10 @@ var registerSpan = document.getElementsByClassName("close")[1]; // When the user clicks the button, open the modal btn.onclick = function () { +// modal.style.display = "block"; modal.style.display = "block"; + window.onload=emailSent(); + } registerBtn.onclick = function () { diff --git a/website/views/registerModal.php b/website/views/registerModal.php index f55c33a..b430ab8 100644 --- a/website/views/registerModal.php +++ b/website/views/registerModal.php @@ -19,6 +19,8 @@ return= $correct method="post"> + + @@ -135,7 +137,8 @@ -- 2.49.1 From e9eeeaf11045b6c98a7f52929c4cb906cf125db9 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 27 Jan 2017 14:17:56 +0100 Subject: [PATCH 063/201] fixed idk --- website/queries/requestpassword.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/queries/requestpassword.php b/website/queries/requestpassword.php index c0ff462..bae825a 100644 --- a/website/queries/requestpassword.php +++ b/website/queries/requestpassword.php @@ -50,5 +50,5 @@ function setHashToDatabase(int $userID, string $hash) { $stmt->bindParam(":hash", $hash); $stmt->bindParam(":userID", $userID); $stmt->execute(); - return $stmt->rowCount(); + $stmt->rowCount(); } \ No newline at end of file -- 2.49.1 From 7e2c20e2447a10fd449bc718e4b735bf5b589559 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 27 Jan 2017 15:40:07 +0100 Subject: [PATCH 064/201] Added showEmail and showBday to the settings page --- website/queries/settings.php | 49 ++++++++++++++++++++++++++++----- website/views/settings-view.php | 26 +++++++++++++++++ 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/website/queries/settings.php b/website/queries/settings.php index 0bf8791..05e7fbf 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -1,6 +1,10 @@ fetch(); } +/** + * Gets the passwordHas form the database + * @return mixed passwordhash + */ function getPasswordHash() { $stmt = $GLOBALS["db"]->prepare(" SELECT @@ -73,6 +91,10 @@ function getPasswordHash() { return $stmt->fetch(); } +/** + * Changes the setting from post. + * @throws HappyAlert + */ function updateSettings() { $stmt = $GLOBALS["db"]->prepare(" UPDATE @@ -82,7 +104,9 @@ function updateSettings() { `lname` = :lname, `location` = :location, `birthdate` = :bday, - `bio` = :bio + `bio` = :bio, + `showEmail` = :showEmail, + `showBday` = :showBday WHERE `userID` = :userID "); @@ -92,15 +116,22 @@ function updateSettings() { $stmt->bindValue(":location", test_input($_POST["location"])); $stmt->bindValue(":bday", test_input($_POST["bday"])); $stmt->bindValue(":bio", test_input($_POST["bio"])); + $stmt->bindValue(":showEmail", test_input($_POST["showEmail"])); + $stmt->bindValue(":showBday", test_input($_POST["showBday"])); + $stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->execute(); throw new HappyAlert("Instellingen zijn opgeslagen."); } +/** + * Change + * @throws AngryAlert + */ function changePassword() { $user = getPasswordHash(); - if (password_verify($_POST["password-old"], $user["password"])) { - if ($_POST["password-new"] == $_POST["password-confirm"] && (strlen($_POST["password-new"]) >= 8)) { + if (password_verify($_POST["password-old"], test_input($user["password"]))) { + if (test_input($_POST["password-new"]) == test_input($_POST["password-confirm"]) && (strlen(test_input($_POST["password-new"])) >= 8)) { doChangePassword(); } else { throw new AngryAlert("Wachtwoorden komen niet overeen."); @@ -110,6 +141,10 @@ function changePassword() { } } +/** + * @throws AngryAlert + * @throws HappyAlert + */ function doChangePassword() { $stmt = $GLOBALS["db"]->prepare(" UPDATE @@ -134,8 +169,8 @@ function doChangePassword() { function changeEmail() { - if ($_POST["email"] == $_POST["email-confirm"]) { - $email = strtolower($_POST["email"]); + if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) { + $email = strtolower(test_input($_POST["email"])); if (filter_var($email, FILTER_VALIDATE_EMAIL)) { //check if email exists emailIsAvailableInDatabase($email); @@ -193,7 +228,6 @@ function updateAvatar() { $tmpImg = $_FILES["pp"]["tmp_name"]; checkAvatarSize($tmpImg); - removeOldAvatar(); if (getimagesize($tmpImg)["mime"] == "image/gif") { if ($_FILES["pp"]["size"] > 4000000) { throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); @@ -205,6 +239,7 @@ function updateAvatar() { $scaledImg = scaleAvatar($tmpImg); imagepng($scaledImg, $profilePictureDir . $relativePath); } + removeOldAvatar(); setAvatarToDatabase("../" . $relativePath); throw new HappyAlert("Profielfoto veranderd."); } diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 66513fc..b6a3b4c 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -51,6 +51,32 @@ $settings = getSettings(); value="" > +
  • + + + > Ja + + > Nee +
  • +
  • + + + > Ja + + > Nee +

  • - - -- 2.49.1 From 9a36dea59219f037eb266412fd090d1b950a1f1b Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 13:22:44 +0100 Subject: [PATCH 077/201] Removed a comma --- website/views/post-view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/views/post-view.php b/website/views/post-view.php index 81aca46..264d67c 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -50,7 +50,7 @@ echo("
    $commentauthor - + $commentnicetime
    -- 2.49.1 From 54ddb784531c5dc8ae57cba6bf8cc6cf2416bc4f Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Mon, 30 Jan 2017 13:59:02 +0100 Subject: [PATCH 078/201] Chat receive messages is now better --- website/public/js/chat.js | 36 +++++++++++++++++++------------ website/public/styles/main.css | 1 - website/public/styles/profile.css | 3 --- website/queries/friendship.php | 6 ++++++ website/views/menu.php | 2 +- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 773a819..0f32fa6 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -1,25 +1,30 @@ var previousDate = new Date("1970-01-01 00:00:00"); +var gettingMessages = false; + $(document).ready(function() { - loadMessages(); + setInterval(loadMessages, 2000); 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,6 +35,7 @@ function sendMessage() { ); $("#newContent").val(""); + loadMessages(); } function addMessages(messages) { @@ -59,6 +65,8 @@ function addMessages(messages) {
    \ '); } + + $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight); } function switchUser(userID) { diff --git a/website/public/styles/main.css b/website/public/styles/main.css index be2f4f7..3eb0bb3 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -97,7 +97,6 @@ p { } .item-box, .item-box-full-width { - margin: 20px 0 0 0; padding: 25px; background-color: #FFFFFF; } diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 2fe819a..03ab19f 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -2,7 +2,6 @@ .user-box { text-align: center; - margin-bottom: 50px; } .status-buttons-container { @@ -64,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; diff --git a/website/queries/friendship.php b/website/queries/friendship.php index a1a23d8..01e3d8a 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -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 "); diff --git a/website/views/menu.php b/website/views/menu.php index 0444384..f3f3cde 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -1,7 +1,7 @@
  • - " - > + + + +
  • + > Ja + > Nee
  • + > Ja + > Nee
  • @@ -189,4 +220,4 @@ $settings = getSettings(); - \ No newline at end of file + -- 2.49.1 From ce53b6e9e4e592b55a4f1918862e01ba50bbc4c5 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 22:42:47 +0100 Subject: [PATCH 093/201] Checkbox for showBday and showEmail --- website/queries/settings.php | 7 ++-- website/views/settings-view.php | 58 +++++++++++++-------------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/website/queries/settings.php b/website/queries/settings.php index 6c52fc4..bdc9d38 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -110,7 +110,8 @@ function updateSettings() { WHERE `userID` = :userID "); - $bday = new DateTime(test_input($_POST["year"] . $_POST["month"] . $_POST["day"])); + $bday = new DateTime(); + $bday->setDate(test_input($_POST["year"]), test_input($_POST["month"]), test_input($_POST["day"])); checkBday($bday); $stmt->bindValue(":fname", test_input($_POST["fname"])); @@ -118,8 +119,8 @@ function updateSettings() { $stmt->bindValue(":location", test_input($_POST["location"])); $stmt->bindValue(":bday", $bday->format("Ymd")); $stmt->bindValue(":bio", test_input($_POST["bio"])); - $stmt->bindValue(":showEmail", test_input($_POST["showEmail"])); - $stmt->bindValue(":showBday",test_input($_POST["showBday"])); + $stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0")); + $stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0")); $stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->execute(); diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 1079c91..6271a45 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -45,30 +45,30 @@ $settings = getSettings();
  • - + "; - + + + - format("Y"); for ($year = $now; $year >= 1900; $year--): ?> @@ -80,33 +80,19 @@ $settings = getSettings();
  • - - > Ja - - > Nee + >
  • - - > Ja - - > Nee + >
  • @@ -220,4 +206,4 @@ $settings = getSettings(); - + \ No newline at end of file -- 2.49.1 From 8dfa31696c8c53ceac1214c862261bd8ba875d06 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 22:49:43 +0100 Subject: [PATCH 094/201] autocomplete suggestions at password --- website/views/settings-view.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 6271a45..c5c58c2 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -141,24 +141,30 @@ $settings = getSettings();
    Verander Wachtwoord
    • - +
    • - +
    • - +
    • -- 2.49.1 From 6983aa06a2c97646ff2f5fce9ebe4b03c18c8a33 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 23:03:50 +0100 Subject: [PATCH 095/201] Finishing touches --- website/views/settings-view.php | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index c5c58c2..029a32b 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -21,7 +21,7 @@ $settings = getSettings(); id="fname" placeholder="Voornaam" title="Voornaam" - value="" + value="" >
    • @@ -30,7 +30,7 @@ $settings = getSettings(); name="lname" id="lname" placeholder="Achternaam" - value="" + value="" >
    • @@ -39,18 +39,19 @@ $settings = getSettings(); name="location" id="location" placeholder="Locatie" - value="" + value="" >
    • - + - -
    • @@ -83,7 +84,7 @@ $settings = getSettings(); + >
    • @@ -91,7 +92,7 @@ $settings = getSettings(); + >
    • @@ -100,7 +101,7 @@ $settings = getSettings(); rows="5" title="bio" id="bio" - > + >
    • @@ -116,7 +117,7 @@ $settings = getSettings();
      • - " + " class="profile-picture" >
      • @@ -183,7 +184,7 @@ $settings = getSettings(); " + value="" disabled > -- 2.49.1 From a6b6d6d747ca2a02e53f8bab68dcafda38ea5387 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Tue, 31 Jan 2017 10:23:47 +0100 Subject: [PATCH 096/201] Style changes --- website/views/settings-view.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 029a32b..b7f554a 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -4,13 +4,11 @@ $settings = getSettings();
        - - $alertMessage -
        "; - } - ?> + +
        + +
        +
        Profiel Instellingen
          @@ -43,10 +41,10 @@ $settings = getSettings(); >
        • - + +
        • -- 2.49.1 From 4dc3b4f651d353b266973acebaad5f517cb97826 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 10:31:57 +0100 Subject: [PATCH 097/201] Mobile friendly --- website/public/js/admin.js | 1 - website/public/js/friendButtons.js | 3 -- website/public/js/header.js | 46 ++++++++++++++--------- website/public/styles/chat.css | 14 ++++++- website/public/styles/header.css | 9 ++++- website/public/styles/main.css | 10 +++++ website/public/styles/menu.css | 14 +++++++ website/public/styles/mobilefriendly.css | 47 ++++++++++++++++++++++++ website/public/styles/profile.css | 2 +- website/views/head.php | 2 + website/views/menu.php | 2 +- 11 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 website/public/styles/mobilefriendly.css diff --git a/website/public/js/admin.js b/website/public/js/admin.js index 140c99a..36347c2 100644 --- a/website/public/js/admin.js +++ b/website/public/js/admin.js @@ -60,7 +60,6 @@ function adminSearch() { "API/adminSearchUsers.php", $("#admin-searchform").serialize() ).done(function (data) { - console.log(data); $("#usertable").html(data); }) } diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index d62e919..47c476a 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -48,9 +48,6 @@ function placeFriendButtons() { text2 = "Weiger"; icon2 = "fa-times"; break; - default: - console.log(friendshipStatus); - break; } $buttonContainer.append( diff --git a/website/public/js/header.js b/website/public/js/header.js index bdf5fe3..13e3e12 100644 --- a/website/public/js/header.js +++ b/website/public/js/header.js @@ -1,25 +1,37 @@ $(document).ready(function() { // Toggle menu $("#own-profile-picture, #open-notifications").click(function() { - if ($("#notification-center").css('right') == "-256px") { - // Make the menu visible and move the content to the left. - $("#chat-history").width("calc(100% - 587px)"); - $(".modal").width("calc(100% - 512px)"); - $(".content").css("margin-right", "256px"); - $("#notification-center").css("right", "0px"); + if ($("#notification-center").css('display') == "none") { + // Make the menu visible and move the content to the left. + $(".modal").width("calc(100% - 512px)"); + $(".content").css("margin-right", "256px"); + $("#notification-center").css("right", "0px"); + $("#notification-center").css("display", "block"); + $("#contact-menu").css("display", "block"); - // Add cookie so the menu stays open on other pages - document.cookie = "menu=open; path=/"; - } else { - // Make the menu invisible and move the content to the right. - $("#chat-history").width("calc(100% - 331px)"); - $(".modal").width("calc(100% - 256px)"); - $(".content").css("margin-right", "0px"); - $("#notification-center").css("right", "-256px"); + // Add cookie so the menu stays open on other pages + if (window.innerWidth > 1080) { + $("#chat-history").width("calc(100% - 587px)"); + document.cookie = "menu=open; path=/"; + } else { + document.cookie = "menu=closed; path=/"; + } + } else { + $(".modal").width("calc(100% - 256px)"); + $(".content").css("margin-right", "0px"); + $("#notification-center").css("display", "none"); - // Change menu cookie to close - document.cookie = "menu=closed; path=/"; - } + if (window.innerWidth > 1080) { + $("#chat-history").width("calc(100% - 331px)"); + } else { + // Make the menu invisible and move the content to the right. + $("#contact-menu").css("display", "none"); + } + + // Change menu cookie to close + document.cookie = "menu=closed; path=/"; + + } }); if (getCookie("menu") == "open") { diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css index 85eb219..cb0f19f 100644 --- a/website/public/styles/chat.css +++ b/website/public/styles/chat.css @@ -146,8 +146,20 @@ body { text-align: right; } -@media only screen and (max-width: 1200px) { +@media only screen and (max-width: 1080px) { .chat-message-self, .chat-message-other { max-width: 75%; } + .chat { + left: 0; + width: 100%; + } + #chat-recent-panel { + left: 0; + width: 320px; + } + #chat-history { + left: 50%; + width: calc(100% - 390px); + } } \ No newline at end of file diff --git a/website/public/styles/header.css b/website/public/styles/header.css index 70e8c80..61727eb 100644 --- a/website/public/styles/header.css +++ b/website/public/styles/header.css @@ -26,7 +26,8 @@ header { } #header-search { - padding-left: 42px; + margin: 24px 0 24px 32px; + vertical-align: middle; } @@ -49,4 +50,10 @@ header div { #open-notifications { padding: 5px 20px 5px 0px; +} + +@media only screen and (max-width: 1080px) { + #header-logo { + display: none; + } } \ No newline at end of file diff --git a/website/public/styles/main.css b/website/public/styles/main.css index abb1604..baff345 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -293,4 +293,14 @@ div[data-title]:hover:after { -webkit-border-radius: 20px; border-radius: 20px; background: #4CAF50; +} + +@media only screen and (max-width: 1080px) { + body { + font-size: 28px!important; + } + button { + font-size: 28px; + } + } \ No newline at end of file diff --git a/website/public/styles/menu.css b/website/public/styles/menu.css index 303b9bc..a862d12 100644 --- a/website/public/styles/menu.css +++ b/website/public/styles/menu.css @@ -86,4 +86,18 @@ height: 100%; padding: 0; text-align: left; +} + +@media only screen and (max-width: 1080px) { + #contact-menu, #notification-center { + display: none; + background: rgba(0, 0, 0, 0.4); + width: calc(50% - 20px); + } + .content { + margin-left: 0; + } + #quick-links i { + font-size: 48px!important; + } } \ No newline at end of file diff --git a/website/public/styles/mobilefriendly.css b/website/public/styles/mobilefriendly.css new file mode 100644 index 0000000..86ffab8 --- /dev/null +++ b/website/public/styles/mobilefriendly.css @@ -0,0 +1,47 @@ +/* MAIN */ +body { + font-size: 28px!important; +} +button { + font-size: 28px; +} + +/* HEADER */ +#header-logo { + display: none; +} + +/* PROFILE */ +.post-box { + width: calc(100% - 65px); +} + +/* MENU */ +#contact-menu, #notification-center { + display: none; + background: rgba(0, 0, 0, 0.4); + width: calc(50% - 20px); +} +.content { + margin-left: 0; +} +#quick-links i { + font-size: 48px!important; +} + +/* CHAT */ +.chat-message-self, .chat-message-other { + max-width: 75%; +} +.chat { + left: 0; + width: 100%; +} +#chat-recent-panel { + left: 0; + width: 320px; +} +#chat-history { + left: 50%; + width: calc(100% - 390px); +} \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 03ab19f..37aaaa1 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -116,7 +116,7 @@ div.posts .post form textarea.newpost { } /* mobile */ -@media only screen and (max-width: 1000px) { +@media only screen and (max-width: 1080px) { .post-box { width: calc(100% - 65px); } diff --git a/website/views/head.php b/website/views/head.php index eb86d56..6e8ca0a 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -12,6 +12,8 @@ @import url("styles/header.css"); @import url("styles/menu.css"); @import url("styles/footer.css"); + + @import url("styles/mobilefriendly.css") screen and (orientation: portrait); +
        -- 2.49.1 From f26097f55fab9a19fa2fc59b087aa4c813f84b5f Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 12:25:28 +0100 Subject: [PATCH 100/201] Fixed online status --- website/public/bits/friend-item.php | 2 +- website/public/group.php | 2 +- website/public/profile.php | 8 ++++---- website/public/styles/main.css | 10 +++++++++- website/public/styles/profile.css | 2 +- website/queries/friendship.php | 11 ++++++----- website/queries/user.php | 13 +++++++++++++ website/views/head.php | 5 ++++- website/views/profile.php | 4 ++-- 9 files changed, 41 insertions(+), 16 deletions(-) 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 ?>
        = 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/user.php b/website/queries/user.php index 0900d9f..b1bb93c 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 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/profile.php b/website/views/profile.php index 90a368d..8cf555f 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -1,10 +1,10 @@
        - ">
        + " src="">
        -- 2.49.1 From f67dd019c46c67ca604423d00ac04b7c956a8ac7 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 12:47:24 +0100 Subject: [PATCH 101/201] Inputs are now mobile friendly --- website/public/styles/main.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 7909687..f2d7535 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -192,7 +192,7 @@ button.green { } button.gray{ - background-color: inherit; + background-color: #FFF; color: #333; } @@ -307,8 +307,9 @@ div[data-title]:hover:after { body { font-size: 28px!important; } - button { + button, input { font-size: 28px; + height: 42px; } } \ No newline at end of file -- 2.49.1 From c14a2770bd092b41a343a2a99f0606c444c75b3d Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 31 Jan 2017 12:52:50 +0100 Subject: [PATCH 102/201] Fixed posting functions for groups. --- website/public/API/postPost.php | 57 +++++++++++++++++++++++++++------ website/queries/group_page.php | 31 +++++++++++++++++- 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b52e96b..40c18e1 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/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 -- 2.49.1 From 6b13db9c4fbfeb99ce903b8072c36ad2e60f7cc9 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 31 Jan 2017 12:53:45 +0100 Subject: [PATCH 103/201] Fixed posting on group pages. --- website/public/API/postPost.php | 2 +- website/public/group.php | 3 +++ website/public/js/masonry.js | 34 +++++++++++++++++++++++++++++---- website/views/group.php | 2 +- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index 40c18e1..7a33857 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -29,7 +29,7 @@ if (empty($_POST["group"])) { header('HTTP/1.1 500 Non enough rights'); return; } - + makePost( $_SESSION["userID"], $_POST["group"], diff --git a/website/public/group.php b/website/public/group.php index 2ef3493..5d9459e 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -34,6 +34,9 @@ include("../views/group.php"); include("../views/footer.php"); $masonry_mode = 0; +if ($group["role"] == "mod" OR $group["role"] == "admin") { + $masonry_mode = 2; +} ?> diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index cb82089..d73c33c 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -23,6 +23,28 @@ function requestPost(postID) { }); } +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(); @@ -64,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); 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("
        -
        +
        +
        +
        + + + + + + + + + + + +
        \ No newline at end of file diff --git a/website/views/fbBdayInput.php b/website/views/fbBdayInput.php new file mode 100644 index 0000000..c08b192 --- /dev/null +++ b/website/views/fbBdayInput.php @@ -0,0 +1,40 @@ + + + + + + diff --git a/website/views/login-view.php b/website/views/login-view.php index 0219797..8e82fdf 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -20,7 +20,7 @@ name="user" value="" title="Moet een geldige gebruiker zijn" - > + required>
        @@ -31,7 +31,7 @@ placeholder="Voer uw wachtwoord in" name="psw" title="Moet minstens 8 karakters lang zijn" - > + required>
        @@ -47,73 +47,68 @@
        -
        - + + +login with Facebook!
        '; + } +?> \ No newline at end of file diff --git a/website/views/registerModal.php b/website/views/registerModal.php index b430ab8..9ad48dc 100644 --- a/website/views/registerModal.php +++ b/website/views/registerModal.php @@ -32,7 +32,8 @@ name="name" value="" title="Mag alleen letters bevatten" - > + required + autocomplete="given-name"> * @@ -44,7 +45,8 @@ name="surname" value="" title="Mag alleen letters bevatten" - > + required + autocomplete="family-name"> * @@ -65,7 +67,7 @@ name="username" value="" title="Moet minimaal 6 karakters bevatten" - > + required> *
        • Minstens 6 karakters
        • @@ -81,7 +83,7 @@ name="password" value="" id="password" - > + required> *
          • Minstens 8 karakters
          • @@ -96,7 +98,7 @@ value="" id="confirmpassword" title="Herhaal wachtwoord" - > + required> * @@ -109,7 +111,6 @@ value="" pattern="[A-Za-z]{1,}" title="Mag alleen letters bevatten"> - * @@ -120,7 +121,8 @@ name="email" value="" id="email" - title="Voer een geldige email in"> + title="Voer een geldige email in" + required> * @@ -132,10 +134,12 @@ name="confirmEmail" value="" id="email" - title="Herhaal uw email"> + title="Herhaal uw email" + required> * + + +
            -- 2.49.1 From c0a64e9ffd4af652b488ac18a39f31831de13523 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Tue, 31 Jan 2017 16:19:15 +0100 Subject: [PATCH 117/201] 1337 bday --- website/views/settings-view.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index b7f554a..b03133e 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -75,6 +75,9 @@ $settings = getSettings(); +
          • -- 2.49.1 From 52a4822477432218965aff2bf0b9b15018f4112e Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 31 Jan 2017 16:20:02 +0100 Subject: [PATCH 118/201] post-merge fix --- website/public/API/adminSearchUsers.php | 2 +- website/views/adminpanel-table.php | 2 +- website/views/adminpanel.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/public/API/adminSearchUsers.php b/website/public/API/adminSearchUsers.php index 58b170a..5f7944b 100644 --- a/website/public/API/adminSearchUsers.php +++ b/website/public/API/adminSearchUsers.php @@ -33,7 +33,7 @@ if (isset($_POST['groupstatus'])) { $groupstatus = $_POST["groupstatus"]; } -$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC); +$userinfo = getRoleByID($_SESSION['userID']); if ($pagetype == "user") { include ("../../views/adminpanel-table.php"); diff --git a/website/views/adminpanel-table.php b/website/views/adminpanel-table.php index 9e6b9bc..3ae5da4 100644 --- a/website/views/adminpanel-table.php +++ b/website/views/adminpanel-table.php @@ -50,7 +50,7 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) { - + name="fbUserID" + value=""> + diff --git a/website/views/forgotPasswordModal.php b/website/views/forgotPasswordModal.php index d3f12f9..2ebdbb9 100644 --- a/website/views/forgotPasswordModal.php +++ b/website/views/forgotPasswordModal.php @@ -19,7 +19,8 @@ class="middle" placeholder="Voer uw email in" name="forgotEmail" - title="Voer een email in"> + title="Voer een email in" + required>
          • + value="email"> + Verander Email +
          -- 2.49.1 From d027333bd7dfa3170505566a0f93c6b5ef55d6d9 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 01:06:31 +0100 Subject: [PATCH 141/201] fix filter and pagenumber interaction in search --- website/public/API/searchPageNumber.php | 14 ++++++++--- website/queries/friendship.php | 31 +++++++++++++++++++++++++ website/queries/group_member.php | 23 ++++++++++++++++++ website/views/search-view.php | 7 +++++- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/website/public/API/searchPageNumber.php b/website/public/API/searchPageNumber.php index 4a76516..9a12d79 100644 --- a/website/public/API/searchPageNumber.php +++ b/website/public/API/searchPageNumber.php @@ -6,6 +6,8 @@ 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"); $user_perpage = $group_perpage = 20; @@ -25,14 +27,20 @@ if (isset($_POST['search'])) { $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']); diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 450fd20..49d8047 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -274,4 +274,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/group_member.php b/website/queries/group_member.php index cea4dde..8b6bf75 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -54,3 +54,26 @@ 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(); +} \ 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; - -- 2.49.1 From e299ef59e8e5e46d87fde39c1b152b34aa92807a Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 10:28:12 +0100 Subject: [PATCH 142/201] Added show profile into settings --- website/public/js/post.js | 2 -- website/queries/settings.php | 7 +++++-- website/views/settings-view.php | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/website/public/js/post.js b/website/public/js/post.js index f176950..4009023 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -34,6 +34,4 @@ function deletePost(postID) { }); closeModal(); masonry(masonryMode); - - } \ No newline at end of file diff --git a/website/queries/settings.php b/website/queries/settings.php index 03f794f..dfd65a0 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -18,7 +18,8 @@ function getSettings() { `bio`, `profilepicture`, `showBday`, - `showEmail` + `showEmail`, + `showProfile` FROM `user` WHERE @@ -64,7 +65,8 @@ function updateSettings() { `birthdate` = :bday, `bio` = :bio, `showEmail` = :showEmail, - `showBday` = :showBday + `showBday` = :showBday, + `showProfile` = :showProfile WHERE `userID` = :userID "); @@ -79,6 +81,7 @@ function updateSettings() { $stmt->bindValue(":bio", test_input($_POST["bio"])); $stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0")); $stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0")); + $stmt->bindValue(":showProfile", (array_key_exists("showProfile", $_POST) ? "1" : "0")); $stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->execute(); diff --git a/website/views/settings-view.php b/website/views/settings-view.php index e3cfd36..f72e243 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -96,6 +96,14 @@ $settings = getSettings(); > +
        • + + + > +
        • ")); - $form.append($("")); + $form.append($("")); columns[0][1].append($postInput); columns[0][0] = $postInput.height() + margin; diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 1bacafa..2370da8 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -108,7 +108,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/views/post-view.php b/website/views/post-view.php index da1c86f..f8fe902 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -30,7 +30,7 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "

          - + "; + ""; } // 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)) { diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 226a96d..650a30f 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -116,7 +116,7 @@ p { @media only screen and (max-width: 1400px) { .item-box { - width: calc(100% - 50px); + width: calc(100% - 50px)!important; } } 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/views/head.php b/website/views/head.php index 284abb4..c4d13a5 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,4 +1,8 @@ - + + + + + MyHyvesbook+ -- 2.49.1 From 327a6a8f5cb5f8ca04508548dd3f6d3062e5264d Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 12:52:03 +0100 Subject: [PATCH 147/201] BUG FIX: username doesn't cut off in link --- website/public/bits/friend-item.php | 2 +- website/queries/friendship.php | 13 ++++++++----- website/queries/user.php | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/website/public/bits/friend-item.php b/website/public/bits/friend-item.php index 181f9b6..6a0c868 100644 --- a/website/public/bits/friend-item.php +++ b/website/public/bits/friend-item.php @@ -41,7 +41,7 @@ foreach($friends as $i => $friend) { fullname ?>
          username)) { - echo $friend->username; + echo $friend->usernameshort; } else if (isset($friend->content)) { echo $friend->content; } diff --git a/website/queries/friendship.php b/website/queries/friendship.php index e1a8c53..6ea6313 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -10,7 +10,8 @@ function selectLimitedFriends($userID, $limit) { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, @@ -50,7 +51,8 @@ function selectAllFriends($userID) { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, @@ -85,7 +87,8 @@ function selectAllFriendRequests() { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, @@ -235,8 +238,8 @@ function searchSomeFriends($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, - - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, diff --git a/website/queries/user.php b/website/queries/user.php index 72205ba..1e54763 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -349,7 +349,8 @@ function searchSomeUsers($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, IFNULL( `profilepicture`, '../img/avatar-standard.png' -- 2.49.1 From 86b02973e4887022619cff121379f9fd5da50998 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 13:02:00 +0100 Subject: [PATCH 148/201] Fixed visibility on profiles --- website/public/profile.php | 6 ++++++ website/queries/user.php | 4 ++++ website/views/profile.php | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/website/public/profile.php b/website/public/profile.php index 05c661d..d9a317c 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -21,13 +21,19 @@ include_once("../queries/calcAge.php"); if(empty($_GET["username"])) { $userID = $_SESSION["userID"]; + $showProfile = True; } else { $userID = getUserID($_GET["username"]); + $showProfile = False; } $user = selectUser($_SESSION["userID"], $userID); $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); +$showProfile = $showProfile || $user["showProfile"] || ($user["status"] == 'confirmed'); +echo " friendship status: " . $user["status"]; +echo " showprofile: $showProfile"; +echo " userID: " . $user["userID"]; if ($userID == $_SESSION["userID"]) { diff --git a/website/queries/user.php b/website/queries/user.php index 33a85a1..74b0aa1 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -65,6 +65,10 @@ function selectUser($me, $other) { `role`, `fname`, `lname`, + `showBday`, + `showEmail`, + `showProfile`, + `status`, CASE `status` IS NULL WHEN TRUE THEN 0 WHEN FALSE THEN diff --git a/website/views/profile.php b/website/views/profile.php index 2bb117f..1e88af8 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -15,16 +15,18 @@

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

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

          Bio:

          " . $user["bio"] . "

          "; } ?> +

          Informatie

          @@ -85,4 +87,5 @@

          + \ No newline at end of file -- 2.49.1 From 9d675dd897b01d2a5e4e13a124ab9944b2b63a46 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 13:11:05 +0100 Subject: [PATCH 149/201] Fixed default image for group members. --- website/queries/group_page.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 511ff4d..b66ca54 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -81,7 +81,10 @@ function selectGroupMembers(int $groupID) { `username`, `fname`, `lname`, - `profilepicture` + IFNULL( + `profilepicture`, + '../img/avatar-standard.png' + ) AS profilepicture FROM `group_member` LEFT JOIN -- 2.49.1 From 044ed6a9d34345e54778ef1795611a51402521c1 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Thu, 2 Feb 2017 13:19:39 +0100 Subject: [PATCH 150/201] Added noscript --- website/public/styles/index.css | 8 +++++++- website/queries/checkInput.php | 2 +- website/views/facebookRegisterModal.php | 3 +-- website/views/login-view.php | 7 +++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/website/public/styles/index.css b/website/public/styles/index.css index 196485e..c7a0aa8 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -133,6 +133,12 @@ label { color: red; } +.login_containerNoscript { + padding: 4px; + text-align: center; + color: red; +} + @keyframes animatezoom { from {transform: scale(0)} to {transform: scale(1)} @@ -150,7 +156,7 @@ label { margin: 16px auto; overflow-y: auto; padding: 20px; - width: 600px; + width: 650px; } select{ diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 8722418..69274ce 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -132,7 +132,7 @@ function validateFBEmail($variable){ } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) { throw new emailException("Geldige email invullen"); } else if (getExistingFBEmail() == 1){ - throw new emailException("Email bestaal al!"); + throw new emailException("Uw email wordt al gebruikt voor een ander account!"); } else if (strlen($variable) > 255) { throw new emailException("Mag maximaal 50 karakters!"); } diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index 7db44b0..7271d63 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -55,7 +55,6 @@ * - + * - diff --git a/website/views/login-view.php b/website/views/login-view.php index 4f85b0a..98ce71c 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -1,3 +1,9 @@ +
          -- 2.49.1 From 417124a1fed22f85cd86615e83df488455baeb30 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:13:20 +0100 Subject: [PATCH 155/201] BUG FIX: added 0 in chat time if needed --- website/public/js/chat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 1141334..a3ff430 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -59,7 +59,7 @@ function addMessages(messages) { for(var i in messages) { // Initialize message variables. var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); - var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); + var thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2); var type; thisDate.setHours(0,0,0,0); @@ -81,6 +81,8 @@ function addMessages(messages) {
          '; } previousDate = thisDate; + previousTime = thisTime; + previousType = type; messagesText += '
          '; // If it is not the first message, and has a different date/time/type then the previous message, } else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) { -- 2.49.1 From 4a7a91ecd964f1cb0827765078314d04ac6534dc Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 14:20:17 +0100 Subject: [PATCH 156/201] Fixed bug (not showing profile when on own profile) --- website/public/profile.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/website/public/profile.php b/website/public/profile.php index d9a317c..aa4cf7c 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -21,19 +21,14 @@ include_once("../queries/calcAge.php"); if(empty($_GET["username"])) { $userID = $_SESSION["userID"]; - $showProfile = True; } else { $userID = getUserID($_GET["username"]); - $showProfile = False; } $user = selectUser($_SESSION["userID"], $userID); $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); -$showProfile = $showProfile || $user["showProfile"] || ($user["status"] == 'confirmed'); -echo " friendship status: " . $user["status"]; -echo " showprofile: $showProfile"; -echo " userID: " . $user["userID"]; +$showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID; if ($userID == $_SESSION["userID"]) { -- 2.49.1 From 188741ddf5ded574767a0115f06af8bd2a97487b Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:22:13 +0100 Subject: [PATCH 157/201] BUG FIX: link in fancy text now opens in new tab --- website/public/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/main.js b/website/public/js/main.js index b6ab703..30cd3ed 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -31,7 +31,7 @@ function fancyText(text) { } // Add links else { - return "" + link + ""; + return "" + link + ""; } }); -- 2.49.1 From 1672ce6086deed96f1325a3044e9fe9c632adaf6 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:23:36 +0100 Subject: [PATCH 158/201] Changed offline status to 5 minutes after inactive --- website/queries/friendship.php | 8 ++++---- website/queries/user.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 7edada9..3dcd53b 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -17,7 +17,7 @@ function selectLimitedFriends($userID, $limit) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -58,7 +58,7 @@ function selectAllFriends($userID) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -94,7 +94,7 @@ function selectAllFriendRequests() { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -245,7 +245,7 @@ function searchSomeFriends($n, $m, $search) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, diff --git a/website/queries/user.php b/website/queries/user.php index e8bda13..7b8ef3f 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -62,7 +62,7 @@ function selectUser($me, $other) { ) AS profilepicture, `bio`, `user`.`creationdate`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -131,7 +131,7 @@ function select20UsersFromN($n) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -156,7 +156,7 @@ function search20UsersFromN($n, $keyword) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -184,7 +184,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -218,7 +218,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -362,7 +362,7 @@ function searchSomeUsers($n, $m, $search) { '../img/avatar-standard.png' ) AS profilepicture, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` -- 2.49.1 From 6fc2f715176a34529d129a0f1a79d4d57f9ae659 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:27:23 +0100 Subject: [PATCH 159/201] Added meta data in the login page --- website/views/login_head.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/views/login_head.php b/website/views/login_head.php index e319a9d..bb7d7cf 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,5 +1,8 @@ - + + + + MyHyvesbook+ Date: Thu, 2 Feb 2017 14:50:51 +0100 Subject: [PATCH 160/201] Added "add group" under group menu --- website/views/menu.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..1c1cf01 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -12,6 +12,8 @@ + +
          @@ -122,6 +122,7 @@ if (isset($_GET["groupstatus"])) { + Maak Owner"; + value=\"owner\">Maak Eigenaar"; } ?> @@ -139,9 +140,9 @@ if (isset($_GET["groupstatus"])) { onsubmit="adminUpdate(this); return false;"> - - - + + +
          -- 2.49.1 From cfa7c870f08417b80d5d7c285207deb0e94db228 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 15:13:35 +0100 Subject: [PATCH 165/201] fix profile error color --- website/public/styles/profile.css | 4 ++++ website/views/profile.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index dbb3d24..46906d2 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -5,6 +5,10 @@ background-color: firebrick; } +.alerttext { + color: white; +} + .user-box { text-align: center; } diff --git a/website/views/profile.php b/website/views/profile.php index 7348642..4139099 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -1,6 +1,6 @@
          - +
          -- 2.49.1 From 8a3cfebf55bbc8380034c25741f52682beb2b9aa Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 15:34:45 +0100 Subject: [PATCH 166/201] Redirect to 404 from profile and group --- website/public/group.php | 9 ++++++++- website/public/profile.php | 7 ++++++- website/queries/group_page.php | 7 ++++++- website/queries/user.php | 4 +++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/website/public/group.php b/website/public/group.php index bb393e3..84726fa 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -13,9 +13,16 @@ include_once("../queries/group_page.php"); -$group = selectGroupByName($_GET["groupname"]); +if(!$group = selectGroupByName($_GET["groupname"])) { + header("HTTP/1.0 404 Not Found"); + header("Location: error/404.php"); + die(); +} + + $members = selectGroupMembers($group["groupID"]); + /* * This view adds the main layout over the screen. * Header, menu, footer. diff --git a/website/public/profile.php b/website/public/profile.php index aa4cf7c..126c87f 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -25,7 +25,12 @@ if(empty($_GET["username"])) { $userID = getUserID($_GET["username"]); } -$user = selectUser($_SESSION["userID"], $userID); +if(!$user = selectUser($_SESSION["userID"], $userID)) { + header("HTTP/1.0 404 Not Found"); + header("Location: error/404.php"); + die(); +} + $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); $showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID; diff --git a/website/queries/group_page.php b/website/queries/group_page.php index f2f028f..a6676c4 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -33,7 +33,12 @@ function selectGroupByName($name) { if (!$stmt->execute()) { return False; } - return $stmt->fetch(); + $row = $stmt->fetch(); + if($row["groupID"] == null) { + return False; + } + + return $row; } function selectGroupRole(int $groupID) { diff --git a/website/queries/user.php b/website/queries/user.php index 972937d..836c956 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -101,7 +101,9 @@ function selectUser($me, $other) { $stmt->bindParam(':me', $me, PDO::PARAM_INT); $stmt->bindParam(':other', $other, PDO::PARAM_INT); - $stmt->execute(); + if(!$stmt->execute() || $stmt->rowCount() == 0) { + return False; + } return $stmt->fetch(); } -- 2.49.1 From 1c53eab2fa77c02aaeb7340a38b053d38c0cf335 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 15:50:12 +0100 Subject: [PATCH 167/201] Fixed user group list on profile page. --- website/queries/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/queries/user.php b/website/queries/user.php index 06487be..422edc4 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -122,7 +122,7 @@ function selectAllUserGroups($userID) { `group_page`.`groupID` = `group_member`.`groupID` WHERE `userID` = :userID AND - `role` = 'member' + `role` IN ('member', 'mod', 'admin') "); $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); -- 2.49.1 From afb45d6709c6ddf640bac34844ac4e3ac8f38055 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 15:51:27 +0100 Subject: [PATCH 168/201] add closing of modal on escape key and clicking outside --- website/public/js/masonry.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index a628e96..107f710 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -83,6 +83,21 @@ $(window).on("load", function() { loadMorePosts(userID, groupID, postAmount, postLimit); } }; + + $(document).keyup(function(e) { + if (e.keyCode == 27) { + closeModal(); + } + }); + + $('.modal').click(function() { + closeModal(); + }); + + $('.modal-content').click(function(event){ + event.stopPropagation(); + }); + }); function closeModal() { -- 2.49.1 From 380d8fa83a7ea8780f09fd8c1a8df7965b8f45b1 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 16:01:45 +0100 Subject: [PATCH 169/201] Group Shit --- website/public/createGroup.php | 36 +++++++++++++++ website/public/groupAdmin.php | 46 ++++++++++++++++++++ website/queries/createGroup.php | 37 ++++++++++++++++ website/queries/groupAdmin.php | 61 ++++++++++++++++++++++++++ website/queries/picture.php | 12 ++--- website/views/createGroup.php | 42 ++++++++++++++++++ website/views/groupAdmin.php | 77 +++++++++++++++++++++++++++++++++ website/views/menu.php | 2 +- 8 files changed, 306 insertions(+), 7 deletions(-) create mode 100644 website/public/createGroup.php create mode 100644 website/public/groupAdmin.php create mode 100644 website/queries/createGroup.php create mode 100644 website/queries/groupAdmin.php create mode 100644 website/views/createGroup.php create mode 100644 website/views/groupAdmin.php diff --git a/website/public/createGroup.php b/website/public/createGroup.php new file mode 100644 index 0000000..ffeb6e3 --- /dev/null +++ b/website/public/createGroup.php @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php new file mode 100644 index 0000000..13ff7e0 --- /dev/null +++ b/website/public/groupAdmin.php @@ -0,0 +1,46 @@ + + + + + + + + +getClass(); + $alertMessage = $w->getMessage(); + } +} + +/* Add your view files here. */ +include("../views/groupAdmin.php"); + +/* This adds the footer. */ +include("../views/footer.php"); +?> + + diff --git a/website/queries/createGroup.php b/website/queries/createGroup.php new file mode 100644 index 0000000..20ee28b --- /dev/null +++ b/website/queries/createGroup.php @@ -0,0 +1,37 @@ +bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $createGroup->bindValue(':description', test_input($_POST["bio"])); + $createGroup->execute(); + + $getGroupID = prepareQuery(" + SELECT + `groupID` + FROM + `group_page` + WHERE + `name` LIKE :name"); + $getGroupID->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $getGroupID->execute(); + $groupID = $getGroupID->fetch()["groupID"]; + + $makeUserAdmin = prepareQuery(" + INSERT INTO + `group_member` (userID, groupID, role) + VALUES (:userID, :groupID, 'admin') + "); + $makeUserAdmin->bindValue(":userID", $_SESSION["userID"]); + $makeUserAdmin->bindValue("groupID", $groupID); + $makeUserAdmin->execute(); + + updateAvatar($groupID); +} \ No newline at end of file diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php new file mode 100644 index 0000000..ae2abd3 --- /dev/null +++ b/website/queries/groupAdmin.php @@ -0,0 +1,61 @@ +bindParam(":groupID", $groupID); + $stmt->execute(); + return $stmt->fetch(); +} + +function updateGroupSettings(int $groupID) +{ + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Je hebt geen rechten in deze groep"); + } + $stmt = prepareQuery(" + UPDATE + `group_page` + SET + `name` = :name, + `description` = :bio + WHERE + `groupID` = :groupID + "); + $stmt->bindValue(":bio", test_input($_POST["bio"])); + $stmt->bindValue(":name", test_input($_POST["name"])); + $stmt->bindValue(":groupID", test_input($_POST["groupID"])); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Groep aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } +} + +function checkGroupAdmin(int $groupID, int $userID) : bool { + $stmt = prepareQuery(" + SELECT + `role` + FROM + `group_member` + WHERE + `groupID` = :groupID AND + `userID` = :userID + "); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":groupID", $groupID); + $stmt->execute(); + if (!$stmt->rowCount()) { + return false; + } + $role = $stmt->fetch()["role"]; + return ($role == "admin"); +} \ No newline at end of file diff --git a/website/queries/picture.php b/website/queries/picture.php index 8e99d9a..ba27f72 100644 --- a/website/queries/picture.php +++ b/website/queries/picture.php @@ -6,7 +6,7 @@ * @throws AngryAlert * @throws HappyAlert */ -function updateAvatar(bool $group = false) { +function updateAvatar(int $group = 0) { $publicDir = "/var/www/html/public/"; $tmpImg = $_FILES["pp"]["tmp_name"]; $avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/"; @@ -16,17 +16,17 @@ function updateAvatar(bool $group = false) { if ($_FILES["pp"]["size"] > 4000000) { throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); } - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif"; - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif"; + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); move_uploaded_file($tmpImg, $publicDir . $relativePath); } else { - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png"; + $relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png"; $scaledImg = scaleAvatar($tmpImg); - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); imagepng($scaledImg, $publicDir . $relativePath); } - $group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath); + $group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath); throw new HappyAlert("Profielfoto veranderd."); } diff --git a/website/views/createGroup.php b/website/views/createGroup.php new file mode 100644 index 0000000..736fc45 --- /dev/null +++ b/website/views/createGroup.php @@ -0,0 +1,42 @@ + + +
          +
          +
          +
          Maak een groep!
          +
            +
          • + + +
          • +
          • + + +
          • +
          • + + +
          • +
          • + + +
          • +
          +
          +
          +
          diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php new file mode 100644 index 0000000..66b38f5 --- /dev/null +++ b/website/views/groupAdmin.php @@ -0,0 +1,77 @@ + +
          +
          + +
          + +
          + +
          +
          Groep Instellingen
          + "> +
            +
          • + + " + > +
          • +
          • + + + +
          • +
          • + + +
          • +
          +
          +
          +
          Verander groepsafbeelding.
          + "> +
            +
          • + + " + class="group-picture" + > +
          • +
          • + + +
          • +
          • + + +
          • +
          +
          +
          +
          \ No newline at end of file diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..03e0f56 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -14,7 +14,7 @@
        +
        + +
        \ No newline at end of file -- 2.49.1 From 74e91ed7cb18acebaabd5b6356f87aec25830977 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 21:14:25 +0100 Subject: [PATCH 175/201] Add mods/admin to a group. --- website/public/groupAdmin.php | 27 ++++++++++++++----- website/queries/groupAdmin.php | 48 ++++++++++++++++++++++++++++++++++ website/queries/settings.php | 15 +++++++++++ website/views/groupAdmin.php | 29 ++++++++++++++++++++ 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php index 13ff7e0..6095149 100644 --- a/website/public/groupAdmin.php +++ b/website/public/groupAdmin.php @@ -23,12 +23,27 @@ $alertClass; $alertMessage; if ($_SERVER["REQUEST_METHOD"] == "POST") { try { - if ($_POST["form"] == "group") { - updateGroupSettings($_POST["groupID"]); - } else if ($_POST["form"] == "picture") { - if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { - updateAvatar($_POST["groupID"]); - } + switch ($_POST["form"]) { + case "group": + updateGroupSettings($_POST["groupID"]); + break; + case "picture": + if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { + updateAvatar($_POST["groupID"]); + } + break; + case "mod": + if (!array_key_exists("userID", $_POST)) { + throw new AngryAlert("Geen gebruiker geselecteerd."); + } + upgradeUser($_POST["groupID"], $_POST["userID"], "mod"); + break; + case "admin": + if (!array_key_exists("userID", $_POST)) { + throw new AngryAlert("Geen gebruiker geselecteerd."); + } + upgradeUser($_POST["groupID"], $_POST["userID"], "admin"); + break; } } catch (AlertMessage $w) { $alertClass = $w->getClass(); diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php index ae2abd3..e3580b6 100644 --- a/website/queries/groupAdmin.php +++ b/website/queries/groupAdmin.php @@ -58,4 +58,52 @@ function checkGroupAdmin(int $groupID, int $userID) : bool { } $role = $stmt->fetch()["role"]; return ($role == "admin"); +} + +function getAllGroupMembers(int $groupID) { + $stmt = prepareQuery(" + SELECT + `username`, + `user`.`userID`, + CONCAT(`fname`, ' ', `lname`) AS `fullname`, + `group_member`.`role` + FROM + `group_member` + LEFT JOIN + `user` + ON + `group_member`.`userID` = `user`.`userID` + WHERE + `groupID` = :groupID AND `group_member`.`role` = 'member' + "); + + $stmt->bindParam(':groupID', $groupID); + if (!$stmt->execute()) { + return False; + } + return $stmt->fetchAll(); +} + +function upgradeUser(int $groupID, int $userID, string $role) { + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Geen toestemming om te wijzigen"); + } + + $stmt = prepareQuery(" + UPDATE + `group_member` + SET + `role` = :role + WHERE + `userID` = :userID AND `groupID` = :groupID + "); + $stmt->bindValue(":groupID", $groupID); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":role", $role); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Permissie aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } } \ No newline at end of file diff --git a/website/queries/settings.php b/website/queries/settings.php index 9b17d17..26237ec 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -148,6 +148,10 @@ function doChangePassword() { } } +/** + * Changes the users email if it is valid. + * @throws AngryAlert + */ function changeEmail() { if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) { @@ -164,6 +168,11 @@ function changeEmail() { } } +/** + * Checks if an emailadres is available in the database. + * @param $email + * @throws AngryAlert + */ function emailIsAvailableInDatabase($email) { $stmt = prepareQuery(" SELECT @@ -181,6 +190,12 @@ function emailIsAvailableInDatabase($email) { } } +/** + * Does the actual changing of an email-adress. + * @param $email + * @throws AngryAlert + * @throws HappyAlert + */ function doChangeEmail($email) { $stmt = prepareQuery(" UPDATE diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php index a28553e..54fbee8 100644 --- a/website/views/groupAdmin.php +++ b/website/views/groupAdmin.php @@ -85,6 +85,35 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
      +
      +
      Voeg een admin/mod toe
      +
        + + " type="hidden"> + + + + + +
      +
      • -- 2.49.1 From 7e4107ac8b357bc1335c9657293182a5ce18720c Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:13:23 +0100 Subject: [PATCH 176/201] Added fancy buttons in profile --- website/public/js/friendButtons.js | 28 +++++++++++++++------------- website/public/js/groupButtons.js | 12 ++++++------ website/public/styles/post-popup.css | 12 ------------ website/public/styles/profile.css | 19 ++++++++++++------- website/views/post-view.php | 4 ++-- website/views/profile.php | 14 ++++++++++---- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 47c476a..303ccf9 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -19,24 +19,24 @@ function placeFriendButtons() { case "0": value1 = "request"; class1 = "green"; - text1 = "Bevriend"; - icon1 = "fa-handshake-o"; + text1 = "Word vrienden"; + icon1 = "fa-user-plus"; break; case "1": value1 = userID; class1 = "green"; text1 = "Chat"; - icon1 = "fa-comment-o"; + icon1 = "fa-comment"; value2 = "delete"; class2 = "red"; - text2 = "Verwijder"; - icon2 = "fa-times"; + text2 = "Ontvriend"; + icon2 = "fa-user-times"; break; case "2": value1 = "delete"; class1 = "red"; text1 = "Trek verzoek in"; - icon1 = "fa-cross"; + icon1 = "fa-times"; break; case "3": value1 = "accept"; @@ -51,16 +51,18 @@ function placeFriendButtons() { } $buttonContainer.append( - ""); + "
        "); $buttonContainer.append( - ""); + "
        "); - $buttonContainer.children().click(function() { + $buttonContainer.find("button").click(function() { if (isNaN(this.value)) editFriendship(userID, this.value); else if (this.value != "") diff --git a/website/public/js/groupButtons.js b/website/public/js/groupButtons.js index 549277d..caf3ab8 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -5,23 +5,23 @@ function placeGroupButtons() { if (data == 'none') { $buttonContainer.append( - ""); } else if (data == 'request') { $buttonContainer.append( - ""); } else if (data == 'admin') { $buttonContainer.append( - "" ); } else { $buttonContainer.append( - ""); } diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 9493b83..e82129b 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -92,16 +92,4 @@ .deleteButton { background-color: firebrick; float: right; -} - -.deleteButton i { - display: inline-block; -} - -.deleteButton:hover span { - display: inline-block; -} - -.deleteButton span { - display: none; } \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 18e105e..8a93d12 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -27,16 +27,21 @@ display: inline-block; } +.friend-button-container div, .status-buttons-container div { + width: 200px; + display: inline-block; +} + .friend-button-container button, .status-buttons-container button, .group-button-container button { display: block; + float: right; margin: 7px 0; font-size: 18px; } - -.friend-button-container button, .status-buttons-container button, .group-button-fixed { - width: 200px; +.status-buttons-container button { + float: left; } .group-button-container button { @@ -76,19 +81,19 @@ border: none; } -.group-button-fancy span { +.fancy-button span { display: none; } -.group-button-fancy:hover { +.fancy-button:hover { text-align: right; } -.group-button-fancy i { +.fancy-button i { display: inline-block; } -.group-button-fancy:hover span { +.fancy-button:hover span { display: inline-block; margin-right: 5px; } diff --git a/website/views/post-view.php b/website/views/post-view.php index 717e6a8..fadc791 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -13,11 +13,11 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
      -
      diff --git a/website/views/profile.php b/website/views/profile.php index 62157f4..0cb5cc2 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -7,10 +7,16 @@ <?= $user[" class="profile-picture main-picture " src="">
      - - +
      + +
      +
      + +

      :)

      -- 2.49.1 From 6d739a4480019709d6abe9addea37ade0ebbc34d Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:24:38 +0100 Subject: [PATCH 177/201] Chat is now only loading the last 100 messages --- website/queries/private_message.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 3b88563..f2df887 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -6,18 +6,23 @@ function getOldChatMessages($user2ID) { if (getFriendshipStatus($user2ID) == 1) { $stmt = prepareQuery(" SELECT - * + * FROM - `private_message` - WHERE - `origin` = :user1 AND - `destination` = :user2 OR - `origin` = :user2 AND - `destination` = :user1 + (SELECT + * + FROM + `private_message` + WHERE + `origin` = :user1 AND + `destination` = :user2 OR + `origin` = :user2 AND + `destination` = :user1 + ORDER BY + `messageID` DESC + LIMIT + 100) sub ORDER BY - `creationdate` ASC - LIMIT - 100 + `messageID` ASC "); $stmt->bindParam(":user1", $user1ID); @@ -76,7 +81,7 @@ function getNewChatMessages($lastID, $destination) { `destination` = :user1) AND `messageID` > :lastID ORDER BY - `creationdate` ASC + `messageID` ASC "); $stmt->bindParam(':user1', $_SESSION["userID"]); -- 2.49.1 From 1a3efe9669089acffc404151616d26b1d3f9d984 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 3 Feb 2017 10:12:37 +0100 Subject: [PATCH 178/201] Fixed W3Validation and url GETs --- website/public/fb-callback.php | 71 -------------- website/public/register(stash).php | 116 ----------------------- website/public/styles/index.css | 6 -- website/queries/checkInput.php | 6 +- website/queries/login.php | 7 +- website/views/facebookRegisterModal.php | 8 +- website/{public => views}/fbRegister.php | 0 website/views/forgotPasswordModal.php | 4 +- website/views/homeLoginRegister.php | 38 ++++---- website/views/login-view.php | 13 ++- website/{public => views}/register.php | 0 website/views/registerModal.php | 13 +-- 12 files changed, 43 insertions(+), 239 deletions(-) delete mode 100644 website/public/fb-callback.php delete mode 100644 website/public/register(stash).php rename website/{public => views}/fbRegister.php (100%) rename website/{public => views}/register.php (100%) diff --git a/website/public/fb-callback.php b/website/public/fb-callback.php deleted file mode 100644 index 0ed0369..0000000 --- a/website/public/fb-callback.php +++ /dev/null @@ -1,71 +0,0 @@ - $appID, // Replace {app-id} with your app id - 'app_secret' => $appSecret, - 'default_graph_version' => 'v2.2', -]); - -$helper = $fb->getRedirectLoginHelper(); - -try { - $accessToken = $helper->getAccessToken(); -} catch(Facebook\Exceptions\FacebookResponseException $e) { - // When Graph returns an error - echo 'Graph returned an error: ' . $e->getMessage(); - exit; -} catch(Facebook\Exceptions\FacebookSDKException $e) { - // When validation fails or other local issues - echo 'Facebook SDK returned an error: ' . $e->getMessage(); - exit; -} - -if (! isset($accessToken)) { - if ($helper->getError()) { - header('HTTP/1.0 401 Unauthorized'); - echo "Error: " . $helper->getError() . "\n"; - echo "Error Code: " . $helper->getErrorCode() . "\n"; - echo "Error Reason: " . $helper->getErrorReason() . "\n"; - echo "Error Description: " . $helper->getErrorDescription() . "\n"; - } else { - header('HTTP/1.0 400 Bad Request'); - echo 'Bad request'; - } - exit; -} - -// Logged in -echo '

      Access Token

      '; -var_dump($accessToken->getValue()); - -// The OAuth 2.0 client handler helps us manage access tokens -$oAuth2Client = $fb->getOAuth2Client(); - -// Get the access token metadata from /debug_token -$tokenMetadata = $oAuth2Client->debugToken($accessToken); -echo '

      Metadata

      '; -var_dump($tokenMetadata); - -// Validation (these will throw FacebookSDKException's when they fail) -$tokenMetadata->validateAppId($appID); // Replace {app-id} with your app id -// If you know the user ID this access token belongs to, you can validate it here -//$tokenMetadata->validateUserId('123'); -$tokenMetadata->validateExpiration(); - -if (! $accessToken->isLongLived()) { - // Exchanges a short-lived access token for a long-lived one - try { - $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken); - } catch (Facebook\Exceptions\FacebookSDKException $e) { - echo "

      Error getting long-lived access token: " . $helper->getMessage() . "

      \n\n"; - exit; - } - - echo '

      Long-lived

      '; - var_dump($accessToken->getValue()); -} - -$_SESSION['fb_access_token'] = (string) $accessToken; - -// User is logged in with a long-lived access token. -// You can redirect them to a members-only page. -//header('Location: https://example.com/members.php'); \ No newline at end of file diff --git a/website/public/register(stash).php b/website/public/register(stash).php deleted file mode 100644 index 99ebc02..0000000 --- a/website/public/register(stash).php +++ /dev/null @@ -1,116 +0,0 @@ - - - - -getMessage(); - } - - try { - $surname = test_input(($_POST["surname"])); - checkInputChoice($surname, "lettersAndSpaces"); - } - catch(lettersAndSpacesException $e){ - $correct = false; - $surnameErr = $e->getMessage(); - } - - try{ - $day_date = test_input(($_POST["day_date"])); - $month_date = test_input(($_POST["month_date"])); - $year_date = test_input(($_POST["year_date"])); - $bday = $year_date . "-" . $month_date . "-" . $day_date; - checkInputChoice($bday, "bday"); - } catch(bdayException $e){ - $correct = false; - $bdayErr = $e->getMessage(); - } - - try{ - $username = str_replace(' ', '', test_input(($_POST["username"]))); - checkInputChoice($username, "username"); - } catch(usernameException $e){ - $correct = false; - $usernameErr = $e->getMessage(); - } - - try{ - $password = str_replace(' ', '', test_input(($_POST["password"]))); - checkInputChoice($password, "longerEight"); - matchPassword(); - } catch(passwordException $e){ - $correct = false; - $passwordErr = $e->getMessage(); - } catch(confirmPasswordException $e){ - $correct = false; - $confirmPasswordErr = $e->getMessage(); - } - - try{ - $location = test_input(($_POST["location"])); - checkInputChoice($location, "lettersAndSpaces"); - } catch(lettersAndSpacesException $e){ - $correct = false; - $locationErr = $e->getMessage(); - } - - try{ - $email = test_input(($_POST["email"])); - checkInputChoice($email, "email"); - $confirmEmail = test_input(($_POST["confirmEmail"])); - matchEmail(); - } catch(emailException $e){ - $correct = false; - $emailErr = $e->getMessage(); - } catch(confirmEmailException $e){ - $correct = false; - $confirmEmailErr = $e->getMessage(); - } - - try{ - $captcha = $_POST['g-recaptcha-response']; - checkCaptcha($captcha); - } catch(captchaException $e){ - $correct = false; - $captchaErr = $e->getMessage(); - } - - try { - getIp(); - registerCheck($correct); - sendConfirmEmailUsername($username); - } catch(registerException $e){ - $genericErr = $e->getMessage(); - } - } -/* This view adds register view */ -include("../views/register-view.php"); -?> - - diff --git a/website/public/styles/index.css b/website/public/styles/index.css index c7a0aa8..68191ad 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -198,12 +198,6 @@ ul { animation-duration: 0.4s } -/* Add Animation */ -@-webkit-keyframes animatetop { - from {top:-300px; opacity:0} - to {top:0; opacity:1} -} - @keyframes animatetop { from {top:-300px; opacity:0} to {top:0; opacity:1} diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 69274ce..247050b 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -68,7 +68,7 @@ function validateBday($variable){ } } -// Checks for date +/* Checks for date */ function validateDate($date, $format) { $d = DateTime::createFromFormat($format, $date); @@ -124,7 +124,7 @@ function validateEmail($variable){ throw new emailException("Mag maximaal 50 karakters!"); } } -//255 + /* checks if an input is a valid email. */ function validateFBEmail($variable){ if (empty($variable)) { @@ -138,6 +138,7 @@ function validateFBEmail($variable){ } } +/* checks if email is the same */ function matchEmail(){ if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){ throw new confirmEmailException("Emails matchen niet!"); @@ -153,7 +154,6 @@ function resetEmail($variable){ } } - /* checks if two passwords matches. */ function matchPassword(){ if ($_POST["password"] != $_POST["confirmpassword"]) { diff --git a/website/queries/login.php b/website/queries/login.php index 27c1f3b..3480991 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -1,5 +1,6 @@ @@ -75,8 +77,9 @@ function validateLogin($username, $password, $url){ $_SESSION["userID"] = $userID; if(!isset($url) or $url == "") { header("location: profile.php"); + echo "succes"; } else{ - header("location: $url"); + header("location: ".$url); } } diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index 7271d63..a38a3a3 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -1,7 +1,6 @@
      - * +
      - + diff --git a/website/public/fbRegister.php b/website/views/fbRegister.php similarity index 100% rename from website/public/fbRegister.php rename to website/views/fbRegister.php diff --git a/website/views/forgotPasswordModal.php b/website/views/forgotPasswordModal.php index 2ebdbb9..ebb9d64 100644 --- a/website/views/forgotPasswordModal.php +++ b/website/views/forgotPasswordModal.php @@ -4,7 +4,6 @@ diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index 55277e7..ad7be40 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -11,16 +11,16 @@ if(isset($_SESSION["userID"])){ // Facebook variables $appID = "353857824997532"; $appSecret = "db47e91ffbfd355fdd11b4b65eade851"; -$fbUsername = $fbPassword = $fbConfirmpassword = ""; +$fbUsername = $fbPassword = $fbConfirmpassword = $fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = ""; $fbUsernameErr = $fbPasswordErr = $fbConfirmpasswordErr = $fbEmailErr = $fbBdayErr = ""; $fbCorrect = true; -$fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = ""; // Register variables $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = ""; $genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = ""; $correct = true; +// Bday dates $day_date = $month_date = $year_date = ""; $fbDay_date = $fbMonth_date = $fbYear_date = ""; @@ -28,22 +28,14 @@ $fbDay_date = $fbMonth_date = $fbYear_date = ""; $user = $psw = $remember =""; $loginErr = $resetErr = $fbRegisterErr =""; -//if ($_SERVER["REQUEST_METHOD"] == "GET") { -// try { -// $user = ($_POST["user"]); -// validateLogin($_POST["user"], $_POST["psw"], "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); -// } catch(loginException $e) { -// $loginErr = $e->getMessage(); -// } -//} - if ($_SERVER["REQUEST_METHOD"] == "POST") { + $url = $_POST["url"]; // Checks for which button is pressed switch ($_POST["submit"]) { case "login": try { $user = ($_POST["user"]); - validateLogin($_POST["user"], $_POST["psw"], $_POST["url"]); + validateLogin($_POST["user"], $_POST["psw"], $url); } catch(loginException $e) { $loginErr = $e->getMessage(); } @@ -62,18 +54,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } break; case "register": - include("register.php"); + include("../views/register.php"); break; case "fbRegister": - include("fbRegister.php"); + include("../views/fbRegister.php"); break; } } + +// Get facebook information with facebook PHP SDK. $fb = new Facebook\Facebook([ 'app_id' => $appID, 'app_secret' => $appSecret, 'default_graph_version' => 'v2.2', ]); + +// Redirect back to login.php after logging/canceling with facebook. $redirect = "https://myhyvesbookplus.nl/login.php"; $helper = $fb->getRedirectLoginHelper(); @@ -88,6 +84,7 @@ try { exit; } +// If theres no facebook account logged in, ask for permission. if(!isset($acces_token)){ $permission=["email", "user_birthday"]; $loginurl=$helper->getLoginUrl($redirect,$permission); @@ -96,13 +93,14 @@ if(!isset($acces_token)){ $response = $fb->get('/me?fields=email,name,birthday'); $usernode = $response->getGraphUser(); + // Get facebook information $nameSplit = explode(" ", $usernode->getName()); $fbName = $nameSplit[0]; $fbSurname = $nameSplit[1]; $fbUserID = $usernode->getID(); $fbEmail = $usernode->getProperty("email"); -// $image = 'https://graph.facebook.com/' . $usernode->getId() . '/picture?width=200'; + // If there is an account, check if the account is banned or frozen. if (fbLogin($fbUserID) == 1) { $fbID = getfbUserID($fbUserID)["userID"]; $fbRole = getfbUserID($fbUserID)["role"]; @@ -110,16 +108,20 @@ if(!isset($acces_token)){ echo ""; + } else if($fbRole == "frozen"){ $_SESSION["userID"] = $fbID; echo ""; + window.onload=frozenAlert(); + window.location.href= 'profile.php'; + "; + } else { $_SESSION["userID"] = $fbID; header("location: profile.php"); + } + // Registration with faceobook if theres no account. } else { echo " diff --git a/website/views/login_head.php b/website/views/login_head.php index 9e580df..e8e3a84 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -3,6 +3,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyHyvesbook+ Date: Fri, 3 Feb 2017 11:47:16 +0100 Subject: [PATCH 195/201] Added fbModal button --- website/public/js/loginRegisterModals.js | 5 ++++- website/views/facebookRegisterModal.php | 6 ++++++ website/views/homeLoginRegister.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/website/public/js/loginRegisterModals.js b/website/public/js/loginRegisterModals.js index 373fb7e..104dd02 100644 --- a/website/public/js/loginRegisterModals.js +++ b/website/public/js/loginRegisterModals.js @@ -7,7 +7,7 @@ var facebookModal = document.getElementById("fbModal"); // Get the button that opens the modal var registerBtn = document.getElementById("registerBtn"); var btn = document.getElementById("myBtn"); - +var fbBtn = document.getElementById("fbBtn"); // Get the element that closes the modal var span = document.getElementsByClassName("close")[0]; @@ -24,6 +24,9 @@ btn.onclick = function () { registerBtn.onclick = function () { registerModal.style.display = "block"; } +fbBtn.onclick = function () { + facebookModal.style.display = "block"; +} /** * WHen the user clicks on (X), close the modal diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index a38a3a3..17ce7ef 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -1,3 +1,9 @@ +Facebook registreer'; + +} +?> -- 2.49.1 From fb5f76c4993cab6d41ab7be8c246452a2f49a207 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 12:32:57 +0100 Subject: [PATCH 198/201] ? --- website/public/js/profile.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 website/public/js/profile.js diff --git a/website/public/js/profile.js b/website/public/js/profile.js deleted file mode 100644 index e69de29..0000000 -- 2.49.1 From 1ac6a7da87e1637e195e596f111df74c8742d8af Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 12:40:33 +0100 Subject: [PATCH 199/201] Changed admin checkbox buttons --- website/public/styles/adminpanel.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index 888b4ca..d04d8fa 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -1,9 +1,9 @@ .admin-panel input[type="radio"], input[type="checkbox"] { vertical-align: middle; - height: 28px; - width: 28px; - margin: 2px; + height: 14px; + width: 14px; + margin: 7px; } .table-checkbox { -- 2.49.1 From 4643dfcddb4f8ef314168cb0851c811d559d57bd Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 3 Feb 2017 12:42:30 +0100 Subject: [PATCH 200/201] Fixed comments and links --- website/queries/register.php | 31 +++++++++++++++++++++++++++++ website/queries/requestpassword.php | 18 +++++++++++++++-- website/views/homeLoginRegister.php | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/website/queries/register.php b/website/queries/register.php index 3dcbed4..7f91dfa 100644 --- a/website/queries/register.php +++ b/website/queries/register.php @@ -1,5 +1,9 @@ rowCount(); } +/** + * Registers a new account with facebook register + */ function fbRegisterAccount() { $stmt = prepareQuery(" INSERT INTO @@ -158,6 +184,11 @@ function fbRegisterAccount() { return $stmt->execute(); } +/** + * Checks which dates need to be selected when there is an invalid registration. + * @param $date + * @param $value + */ function submitselect($date, $value){ if ($date == $value){ echo "selected"; diff --git a/website/queries/requestpassword.php b/website/queries/requestpassword.php index a54bd7d..daad355 100644 --- a/website/queries/requestpassword.php +++ b/website/queries/requestpassword.php @@ -1,6 +1,10 @@ getRedirectLoginHelper(); try { -- 2.49.1 From 7cc6450e6afde743509fcc83b3e8dadf0415509e Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Fri, 3 Feb 2017 13:19:00 +0100 Subject: [PATCH 201/201] Added comments to javascript code. --- website/public/js/friendButtons.js | 8 +++++- website/public/js/groupButtons.js | 5 ++++ website/public/js/masonry.js | 44 +++++++++++++++++++----------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 47c476a..440dfe5 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -1,6 +1,8 @@ +// Show the right friendship buttonsto the user. function placeFriendButtons() { $.post("API/getFriendshipStatus.php", { usr: userID }) .done(function(data) { + //save the friendship status var friendshipStatus = data; var $buttonContainer = $("div.friend-button-container"); $("#start-profile-chat").hide(); @@ -22,6 +24,7 @@ function placeFriendButtons() { text1 = "Bevriend"; icon1 = "fa-handshake-o"; break; + // Users are friends. case "1": value1 = userID; class1 = "green"; @@ -32,12 +35,14 @@ function placeFriendButtons() { text2 = "Verwijder"; icon2 = "fa-times"; break; + // This user sent request. case "2": value1 = "delete"; class1 = "red"; text1 = "Trek verzoek in"; icon1 = "fa-cross"; break; + // Other user sent request. case "3": value1 = "accept"; class1 = "green"; @@ -50,6 +55,7 @@ function placeFriendButtons() { break; } + // Append buttons to the container. $buttonContainer.append( ""); - + // Gets triggered when a friend button is triggered. $buttonContainer.children().click(function() { if (isNaN(this.value)) editFriendship(userID, this.value); diff --git a/website/public/js/groupButtons.js b/website/public/js/groupButtons.js index e6ada67..ab86e8c 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -3,16 +3,20 @@ function placeGroupButtons() { .done(function(data) { var $buttonContainer = $("div.group-button-container"); + // Append the right group button to the button container. + // When user is not a member if(data == 'none') { $buttonContainer.append( ""); + // when user sent a request to become a member. } else if(data == 'request') { $buttonContainer.append( ""); + // When user is a member of the group. } else { $buttonContainer.append( ""); } + // Gets triggered when a group button is clicked. $buttonContainer.children().click(function() { $.post("API/editMembership.php", { grp: groupID, role: this.value }) .done(function() { diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index a628e96..eeb5cf7 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -1,3 +1,4 @@ +// Vertical margin between two posts. margin = 20; // scrolling modal taken from http://stackoverflow.com/questions/10476632/how-to-scroll-the-page-when-a-modal-dialog-is-longer-than-the-screen @@ -11,9 +12,12 @@ function scrollbarMargin(width, overflow) { }); } +// Get post from the server. function requestPost(postID) { + // Make the modal view visible. $(".modal").show(); + // Send get request to the server to load the post. $.get("API/loadPost.php", { postID : postID }).done(function(data) { $('.modal-default').hide(); var scrollBarWidth = window.innerWidth - document.body.offsetWidth; @@ -23,11 +27,14 @@ function requestPost(postID) { }); } +// Create a new post. function postPost() { title = $("input.newpost[name='title']").val(); content = $("textarea.newpost[name='content']").val(); + // Masonrymode 2: when on group page and user is an admin. if (masonryMode == 2) { + // Create the new group post. $.post("API/postPost.php", { title: title, content : content, group : groupID }) @@ -42,6 +49,7 @@ function postPost() { } }); } else { + // Create the new user post. $.post("API/postPost.php", { title: title, content : content }) .done(function(data) { @@ -68,6 +76,7 @@ var postAmount = 0; var noposts = false; $(document).ready(function () { + // Initialise variables for masonry. windowWidth = $(window).width(); columnCount = Math.floor($(".posts").width() / 250); columns = new Array(columnCount); @@ -78,6 +87,7 @@ $(window).on("load", function() { $(".modal-close").click(function (){closeModal()}); // http://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom + // Infinite scroll. window.onscroll = function(ev) { if($(window).scrollTop() + $(window).height() == $(document).height() ) { loadMorePosts(userID, groupID, postAmount, postLimit); @@ -85,6 +95,7 @@ $(window).on("load", function() { }; }); +// Hide modal view from the screen. function closeModal() { $(".modal").hide(); scrollbarMargin(0, 'auto'); @@ -92,23 +103,30 @@ function closeModal() { $('.modal-default').show(); } +// Will fire when user resizes the window. $(window).resize(function() { clearTimeout(window.resizedFinished); window.resizeFinished = setTimeout(function() { + // Check if the width of the screen changed. if ($(window).width() != windowWidth) { + // Save width. windowWidth = $(window).width(); - + // Check if there fit more or less columns in the new width. if (columnCount != Math.floor($(".posts").width() / 250)) { columnCount = Math.floor($(".posts").width() / 250); + // Respawn the masonry grid. masonry(masonryMode); } } }, 250); }); +// Select the container for masonry. var $container = $(".posts"); +// Spawn the masonry grid. function masonry(mode) { + // save the masonry mode. masonryMode = mode; $container.children().remove(); @@ -116,10 +134,7 @@ function masonry(mode) { noposts = false; postAmount = 0; - /* - * Initialise columns. - */ - + // Initialise columns. for (i = 0; i < columnCount; i++) { $column = $("
      "); $column.width(100/columnCount + "%"); @@ -127,11 +142,13 @@ function masonry(mode) { columns[i] = [0, $column]; } + // Place the form for new posts. if(mode > 0) { $postInput = $("
      "); $form = $(""); $postInput.append($form); + //Add extra input for group posts. if(mode == 2) { $form.append($("")); } @@ -144,17 +161,11 @@ function masonry(mode) { columns[0][0] = $postInput.height() + margin; } - /* - * Function will find the column with the shortest height. - */ - - - /* - * Get the posts from the server. - */ + // Get the posts from the server. loadMorePosts(userID, groupID, 0, postLimit); } +// Find the column with the shortest hight. function getShortestColumn(columns) { column = columns[0]; @@ -166,17 +177,20 @@ function getShortestColumn(columns) { return column; } +// Load certain range of posts. function loadMorePosts(uID, gID, offset, limit) { if (noposts) { return; } + // Get a list of posts from the server. $.post("API/getPosts.php", { usr : uID, grp : gID, offset : offset, limit : limit}) .done(function(data) { if (!data) { + // No posts were found, show noposts bar to user. $('.noposts').show(); noposts = true; return; @@ -184,9 +198,7 @@ function loadMorePosts(uID, gID, offset, limit) { posts = JSON.parse(data); - /* - * Rearange the objects. - */ + // Rearange the objects. $.each(posts, function() { $post = $("
      "); $post.append($("

      ").html(this["title"])); -- 2.49.1