From ac83bb750bbe3359904f8d3b0e90788c0064c304 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 23 Jan 2017 16:05:22 +0100 Subject: [PATCH 01/73] 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'> From 1a53d01747efff5f90c995f91e2b226ffea7fe23 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 26 Jan 2017 13:29:56 +0100 Subject: [PATCH 02/73] add authentication --- website/public/admin.php | 8 ++++++++ website/queries/user.php | 15 +++++++++++++++ website/views/adminpanel.php | 1 + 3 files changed, 24 insertions(+) diff --git a/website/public/admin.php b/website/public/admin.php index 5faa096..fcd386a 100644 --- a/website/public/admin.php +++ b/website/public/admin.php @@ -12,6 +12,14 @@ * This view adds the main layout over the screen. * Header and menu. */ +include_once ("../queries/user.php"); + +$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC); + +if ($userinfo['role'] != 'admin' AND $userinfo['role'] != 'owner') { + header("location:profile.php"); +} + include("../views/main.php"); /* Add your view files here. */ diff --git a/website/queries/user.php b/website/queries/user.php index be06197..104d526 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -370,3 +370,18 @@ function countSomeUsers($search) { $q->execute(); return $q; } + +function getRoleByID($userID) { + $stmt = $GLOBALS['db']->prepare(" + SELECT + `role` + FROM + `user` + WHERE + `userID` = :userID + "); + + $stmt->bindParam(':userID', $userID); + $stmt->execute(); + return $stmt; +} \ No newline at end of file diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 86fbb36..fd10d15 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -2,6 +2,7 @@ Date: Thu, 26 Jan 2017 14:31:45 +0100 Subject: [PATCH 03/73] 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"])); From 96f70e1a113ee487e65af9e0ab3adebf3d5a29e7 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Thu, 26 Jan 2017 14:50:41 +0100 Subject: [PATCH 04/73] 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 @@

- - From 7073995534742cc2d479f182774d13e2e439b7cf Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 26 Jan 2017 17:03:11 +0100 Subject: [PATCH 09/73] 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("

- + + +
From 032e25b044c11d0018dfb506de4a9d3d21496f05 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 21:50:47 +0100 Subject: [PATCH 10/73] 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 /> From d89e672990325f96c060f3cbb74854eed4519289 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 21:54:47 +0100 Subject: [PATCH 11/73] 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`, From f1bfc89e6afafc61456c4652fade6f197ebd6a26 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 22:33:32 +0100 Subject: [PATCH 12/73] 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 { From cbff973b631126093c0b8dad90dcb3513eca38ba Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 27 Jan 2017 11:15:33 +0100 Subject: [PATCH 13/73] 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() { From 3b542e08789c15641248b1e315755e6134f4e38b Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 27 Jan 2017 12:20:50 +0100 Subject: [PATCH 14/73] "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("
-
+
- + - +
From f27b9ec6b41f85f519c50961e53eb516e3ec842a Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 27 Jan 2017 12:22:26 +0100 Subject: [PATCH 15/73] 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; From 609f350cd344812617a94a18847aa2590fd94044 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 27 Jan 2017 12:27:40 +0100 Subject: [PATCH 16/73] 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 From ce6a75163047b4209846129d748f620565a1cbbb Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 27 Jan 2017 12:30:28 +0100 Subject: [PATCH 17/73] 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(" From 5e9629eddd5ccdf983c384602951a25f468b3081 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 27 Jan 2017 14:03:11 +0100 Subject: [PATCH 18/73] 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 @@ From e9eeeaf11045b6c98a7f52929c4cb906cf125db9 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 27 Jan 2017 14:17:56 +0100 Subject: [PATCH 19/73] 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 From 7e2c20e2447a10fd449bc718e4b735bf5b589559 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 27 Jan 2017 15:40:07 +0100 Subject: [PATCH 20/73] 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 +

  • - - From 9a36dea59219f037eb266412fd090d1b950a1f1b Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 13:22:44 +0100 Subject: [PATCH 32/73] 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
    From 54ddb784531c5dc8ae57cba6bf8cc6cf2416bc4f Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Mon, 30 Jan 2017 13:59:02 +0100 Subject: [PATCH 33/73] 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 + From ce53b6e9e4e592b55a4f1918862e01ba50bbc4c5 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 22:42:47 +0100 Subject: [PATCH 48/73] 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 From 8dfa31696c8c53ceac1214c862261bd8ba875d06 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 22:49:43 +0100 Subject: [PATCH 49/73] 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
    • - +
    • - +
    • - +
    • From 6983aa06a2c97646ff2f5fce9ebe4b03c18c8a33 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 23:03:50 +0100 Subject: [PATCH 50/73] 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 > From a6b6d6d747ca2a02e53f8bab68dcafda38ea5387 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Tue, 31 Jan 2017 10:23:47 +0100 Subject: [PATCH 51/73] 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(); >
        • - + +
        • From 4dc3b4f651d353b266973acebaad5f517cb97826 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 10:31:57 +0100 Subject: [PATCH 52/73] 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); +
        From f26097f55fab9a19fa2fc59b087aa4c813f84b5f Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 12:25:28 +0100 Subject: [PATCH 55/73] 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="">
        From f67dd019c46c67ca604423d00ac04b7c956a8ac7 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 12:47:24 +0100 Subject: [PATCH 56/73] 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 From c14a2770bd092b41a343a2a99f0606c444c75b3d Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 31 Jan 2017 12:52:50 +0100 Subject: [PATCH 57/73] 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 From 6b13db9c4fbfeb99ce903b8072c36ad2e60f7cc9 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 31 Jan 2017 12:53:45 +0100 Subject: [PATCH 58/73] 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("
        -
        +
        + +
        + +
        From c0a64e9ffd4af652b488ac18a39f31831de13523 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Tue, 31 Jan 2017 16:19:15 +0100 Subject: [PATCH 71/73] 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(); +
      • From 52a4822477432218965aff2bf0b9b15018f4112e Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 31 Jan 2017 16:20:02 +0100 Subject: [PATCH 72/73] 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)) {