");
$post.append($("
").text(this["title"]));
$post.append($("
").html(this["content"]));
+ $post.append($("
").text(this["nicetime"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);
@@ -60,3 +110,4 @@ function masonry() {
});
});
}
+
diff --git a/website/public/js/menu.js b/website/public/js/menu.js
index 32b048a..8329cde 100644
--- a/website/public/js/menu.js
+++ b/website/public/js/menu.js
@@ -1,39 +1,108 @@
+
$(document).ready(function() {
- $(".extra-menu-items").hide();
- $("#menu-back").hide();
+ // Show more friends/users
// Show more friends
- $("#more-friends-click").click(function() {
- // Show only friends
- $("#groups-menu-section").slideUp();
- $("#friends-menu-section li").show();
+ // $("#more-friends-click").click(function() {
+ // // Show only friends
+ // $("#groups-menu-section").slideUp();
+ // $("#friends-menu-section li").show();
+ //
+ // // Change buttons
+ // $("#more-friends-click").hide();
+ // $("#menu-back").show();
+ // });
+ //
+ // // Show more groups
+ // $("#more-groups-click").click(function() {
+ // // Show only groups
+ // $("#friends-menu-section").slideUp();
+ // $("#groups-menu-section li").show();
+ //
+ // // Change buttons
+ // $("#more-groups-click").hide();
+ // $("#menu-back").show();
+ // });
- // Change buttons
- $("#more-friends-click").hide();
- $("#menu-back").show();
- });
+ // // Go back
+ // $("#menu-back").click(function() {
+ // // Show overview of friends and groups
+ // $("#friends-menu-section").slideDown();
+ // $("#groups-menu-section").slideDown();
+ // $(".extra-menu-items").hide();
+ //
+ // // Change buttons
+ // $("#menu-back").hide();
+ // $("#more-groups-click").show();
+ // $("#more-friends-click").show();
+ // });
- // Show more groups
- $("#more-groups-click").click(function() {
- // Show only groups
- $("#friends-menu-section").slideUp();
- $("#groups-menu-section li").show();
-
- // Change buttons
- $("#more-groups-click").hide();
- $("#menu-back").show();
- });
-
- // Go back
- $("#menu-back").click(function() {
- // Show overview of friends and groups
- $("#friends-menu-section").slideDown();
- $("#groups-menu-section").slideDown();
- $(".extra-menu-items").hide();
-
- // Change buttons
- $("#menu-back").hide();
- $("#more-groups-click").show();
- $("#more-friends-click").show();
- });
+ loadMenuFriends(5);
+ loadNotificationFriends();
+ loadUnreadMessages();
+ loadMenuGroups();
});
+
+
+function loadMenuFriends(limit) {
+ $.post(
+ "API/loadFriends.php",
+ {
+ limit: 5
+ }
+ ).done(function(data) {
+ if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
+ $("#friends-menu-section").show();
+ } else {
+ $("#friends-menu-section").hide();
+ }
+ });
+
+ setTimeout(loadMenuFriends, 3000, limit);
+}
+
+function loadMenuGroups() {
+ $.post(
+ "API/loadGroups.php",
+ {
+ limit: 5
+ }
+ ).done(function(data) {
+ if (showGroups(data, "#menu-groups-list")) {
+ $("#groups-menu-section").show();
+ } else {
+ $("#groups-menu-section").hide();
+ }
+ });
+
+ setTimeout(loadMenuGroups, 3000);
+}
+
+function loadNotificationFriends() {
+ $.post(
+ "API/loadFriendRequest.php"
+ ).done(function(data) {
+ if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
+ $("#friend-request-section").show();
+ } else {
+ $("#friend-request-section").hide();
+ }
+ });
+
+ setTimeout(loadNotificationFriends, 3000);
+}
+
+function loadUnreadMessages() {
+ $.post(
+ "API/loadChatNotifications.php"
+ ).done(function(data) {
+ if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
+ console.log(data);
+ $("#unread-messages-section").show();
+ } else {
+ $("#unread-messages-section").hide();
+ }
+ });
+
+ setTimeout(loadUnreadMessages, 3000);
+}
\ No newline at end of file
diff --git a/website/public/js/notifications.js b/website/public/js/notifications.js
index afcaca0..d78d167 100644
--- a/website/public/js/notifications.js
+++ b/website/public/js/notifications.js
@@ -1,89 +1,43 @@
-function showFriendNotifications(notifications) {
- $("#friendrequestslist").html("");
- for (i in notifications) {
- var outgoing = "";
- if (notifications[i].friend_state == "3") {
- outgoing = "";
- }
-
- $("#friendrequestslist").append(" \
-
\
- \
- \
-
\
- \
- ");
- }
-}
-
-function showChatNotifications(notifications) {
- $("#unreadChatlist").html("");
- for (i in notifications) {
- $("#unreadChatlist").append(" \
-
\
- \
- \
- ");
- }
-}
-
-function loadNotifications() {
- $.post(
- "API/loadFriendRequestNotifications.php"
- ).done(function(data) {
- if (data && data != "[]") {
- showFriendNotifications(JSON.parse(data));
- }
- });
- $.post(
- "API/loadChatNotifications.php"
- ).done(function(data) {
- if (data && data != "[]") {
- showChatNotifications(JSON.parse(data));
- }
- });
-
- setTimeout(loadNotifications, 10000);
-}
-$(document).ready(function() {
- loadNotifications();
-});
+// function showChatNotifications(notifications) {
+// $("#unreadChatlist").html("");
+// for (i in notifications) {
+// $("#unreadChatlist").append(" \
+//
\
+// \
+// \
+// ");
+// }
+// }
+//
+// function loadNotifications() {
+// $.post(
+// "API/loadChatNotifications.php"
+// ).done(function(data) {
+// if (data && data != "[]") {
+// $("#unread-messages-section").show();
+// showChatNotifications(JSON.parse(data));
+// } else {
+// $("#unread-messages-section").hide();
+// }
+// });
+//
+// setTimeout(loadNotifications, 10000);
+// }
+// $(document).ready(function() {
+// loadNotifications();
+// });
diff --git a/website/public/js/profile.js b/website/public/js/profile.js
new file mode 100644
index 0000000..2a47dce
--- /dev/null
+++ b/website/public/js/profile.js
@@ -0,0 +1,8 @@
+function loadPost(postID) {
+ $.get(
+ "API/loadPost.php",
+ $(postID).serialize()
+ ).done(function (data) {
+ $('#modal-response').innerHTML= JSON.parse(data);
+ });
+}
\ No newline at end of file
diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js
index ef49e83..b2fda05 100644
--- a/website/public/js/registerAndLogin.js
+++ b/website/public/js/registerAndLogin.js
@@ -12,4 +12,4 @@ function bannedAlert(){
function emailNotConfirmed(){
alert("Your account has not been verified yet!\nAnother email has been sent to you")
-}
\ No newline at end of file
+}
diff --git a/website/public/login.php b/website/public/login.php
index de4ecab..0515793 100644
--- a/website/public/login.php
+++ b/website/public/login.php
@@ -6,6 +6,8 @@
include_once("../queries/login.php");
include_once("../queries/checkInput.php");
include_once("../queries/emailconfirm.php");
+ include_once("../queries/requestpassword.php");
+ include_once("../queries/register.php");
?>
getMessage();
+ switch ($_POST["submit"]) {
+ case "login":
+ try {
+ $uname = ($_POST["uname"]);
+ validateLogin($_POST["uname"], $_POST["psw"]);
+ } catch(loginException $e) {
+ $loginErr = $e->getMessage();
+ }
+ break;
+ case "reset":
+ try {
+ resetEmail($_POST["forgotEmail"]);
+ sendPasswordRecovery($_POST["forgotEmail"]);
+ } catch (emailException $e){
+ $resetErr = $e->getMessage();
+ echo "";
+ }
+ break;
+
}
}
+// // 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/profile.php b/website/public/profile.php
index 1423483..7cae77d 100644
--- a/website/public/profile.php
+++ b/website/public/profile.php
@@ -2,8 +2,12 @@
+
+
+
@@ -11,6 +15,7 @@
include("../queries/user.php");
include("../queries/friendship.php");
include("../queries/nicetime.php");
+include("../queries/post.php");
if(empty($_GET["username"])) {
$userID = $_SESSION["userID"];
@@ -26,8 +31,10 @@ $posts = selectAllUserPosts($userID);
if ($userID == $_SESSION["userID"]) {
$friendship_status = -1;
+ $masonry_mode = 1;
} else {
$friendship_status = $user["friend_status"];
+ $masonry_mode = 0;
}
/*
@@ -52,7 +59,7 @@ include("../views/footer.php");
userID = = $userID ?>;
placeFriendButtons();
- masonry();
+ masonry(= $masonry_mode ?>);
// alert("blap");
// $.post("API/getPosts.php", { usr : userID }, "json")
// .done(function(data) {
diff --git a/website/public/resetpassword.php b/website/public/resetpassword.php
new file mode 100644
index 0000000..3ca2698
--- /dev/null
+++ b/website/public/resetpassword.php
@@ -0,0 +1,57 @@
+prepare("
+ UPDATE
+ `user`
+ SET
+ `password` = :password
+ WHERE
+ `userID` = :userID
+ ");
+ $stmt->bindValue(":password", password_hash($_POST["password"], PASSWORD_DEFAULT));
+ $stmt->bindParam(":userID", $_POST["u"]);
+ $stmt->execute();
+}
+
+function verifyLink(int $userID, string $hash) {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `password`
+ FROM
+ `user`
+ WHERE
+ `userID` = :userID
+ ");
+ $stmt->bindParam(":userID", $userID);
+ $stmt->execute();
+ $password = $stmt->fetch()["password"];
+ return password_verify($password, $hash);
+}
\ No newline at end of file
diff --git a/website/public/styles/index.css b/website/public/styles/index.css
index fc9d3d6..97d6f63 100644
--- a/website/public/styles/index.css
+++ b/website/public/styles/index.css
@@ -3,11 +3,11 @@ a.button {
border-radius: 5px;
color: black;
cursor: pointer;
- height: 50%;
padding: 8px 20px;
- width: 50%;
font-family: Arial;
- font-size: 20px;
+ font-size: 22px;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
+
}
/* Body */
@@ -28,12 +28,13 @@ body {
form {
/*background-color: #a87a87;*/
border-radius: 12px;
- height: 75%;
+ height: 85%;
margin: auto;
width: 80%;
overflow-y:auto;
}
+
/* inlog titel */
h1 {
padding: 8px;
@@ -48,6 +49,11 @@ h2 {
font-size: 2.0em;
}
+h3 {
+ padding: 16px;
+ text-align: center;
+ font-size: 1.5em;
+}
input[type=text], input[type=password], input[type=email], input[type="date"] {
box-sizing: border-box;
@@ -60,14 +66,22 @@ input[type=text], input[type=password], input[type=email], input[type="date"] {
width: 55%;
}
-button[type=submit] {
+.center{
+ text-align: center;
+}
+
+button {
background-color: #C8CABD;
+ border-radius: 5px;
color: black;
cursor: pointer;
+ height: 50%;
+ padding: 8px 20px;
+ margin: 10px;
font-family: Arial;
font-size: 22px;
- height: 30px;
- width: 120px;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
+
}
.error {
@@ -80,31 +94,6 @@ label {
display: block;
}
-.left-arrow {
- display: inline-block;
- position: relative;
- background-color: #C8CABD;
- height: 25px;
- width: 120px;
- padding: 3px 3px 3px 3px;
- text-align: center;
- border-radius: 0px 5px 5px 0px;
- font-size: 22px;
-
-}
-.left-arrow:after {
- content: '';
- display: block;
- position: absolute;
- right: 100%;
- top: 0;
- bottom: 0;
- border-top: 12px solid transparent;
- border-right: 20px solid #C8CABD;
- border-bottom: 12px solid transparent;
- border-left: 0px solid transparent;
-}
-
/* padding voor registreer container */
.login_containerregister {
padding: 16px;
@@ -137,24 +126,84 @@ label {
background-repeat: repeat-x;
background-attachment: fixed;*/
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
- height: 500px;
+ height: 400px;
margin: 34px auto;
overflow-y: auto;
padding: 20px;
width: 45%;
}
-/*.platform {
- width: 40%;
- margin: 34px auto;
-}*/
-
-@-webkit-keyframes animatezoom {
- from {-webkit-transform: scale(0)}
- to {-webkit-transform: scale(1)}
-}
-
ul {
font-family: Arial;
font-size: 16px;
}
+
+/* The Modal (background) */
+.modal {
+ display: none; /* Hidden by default */
+ position: fixed; /* Stay in place */
+ z-index: 1; /* Sit on top */
+ padding-top: 100px; /* Location of the box */
+ left: 0;
+ top: 0;
+ width: 100%; /* Full width */
+ height: 100%; /* Full height */
+ overflow: auto; /* Enable scroll if needed */
+ background-color: rgb(0,0,0); /* Fallback color */
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
+}
+
+/* Modal Content */
+.modal-content {
+ position: relative;
+ background-color: #FFFFFF;
+ margin: auto;
+ padding: 0;
+ border: 1px solid #888;
+ width: 500px;
+ 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;
+ animation-name: animatetop;
+ 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}
+}
+
+/* The Close Button */
+.close {
+ color: white;
+ float: right;
+ font-size: 28px;
+ font-weight: bold;
+}
+
+.close:hover,
+.close:focus {
+ color: #000;
+ text-decoration: none;
+ cursor: pointer;
+}
+
+.modal-header {
+ padding: 2px 16px;
+ background-color: #FBC02D;
+ color: black;
+}
+
+.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/public/styles/post-popup.css b/website/public/styles/post-popup.css
new file mode 100644
index 0000000..11fe03b
--- /dev/null
+++ b/website/public/styles/post-popup.css
@@ -0,0 +1,72 @@
+/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */
+
+.modal {
+ display: none;
+ position: fixed;
+ top: 80px;
+ left: 256px;
+ width: calc(100% - 256px); /* Full width */
+ height: calc(100% - 80px); /* Full height */
+ background-color: rgb(0,0,0); /* Fallback color */
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
+ overflow-y: auto;
+}
+
+/* Modal Content/Box */
+.modal-content {
+ margin: 5% auto;
+ width: 70%; /* Could be more or less, depending on screen size */
+ overflow-y: auto;
+}
+
+.modal-close {
+ color: #aaa;
+ float: right;
+ font-size: 28px;
+ font-weight: bold;
+ margin: auto;
+}
+
+.modal-close:hover,
+.modal-close:focus {
+ color: black;
+ text-decoration: none;
+ cursor: pointer;
+}
+
+.modal-content img {
+ max-height: 100%;
+ max-width: 100%;
+}
+
+.post-header h4 {
+ font-size: 20pt;
+}
+
+.post-content {
+ margin: 30px auto;
+ width: 90%;
+}
+
+.commentfield {
+ margin-bottom: 20px;
+}
+
+.commentfield textarea {
+ width: 100%;
+}
+
+.comment {
+ padding-top: 10px;
+ padding-bottom: 10px;
+ border-top: 1px solid #4CAF50;
+}
+
+.commentinfo {
+ font-size: 10pt;
+}
+
+.commentcontent {
+ margin: 5px auto;
+ width: 95%;
+}
\ No newline at end of file
diff --git a/website/public/styles/resetpassword.css b/website/public/styles/resetpassword.css
new file mode 100644
index 0000000..a3d7942
--- /dev/null
+++ b/website/public/styles/resetpassword.css
@@ -0,0 +1,17 @@
+.password-change {
+ height: 100%;
+ background-color: #FBC02D;
+ margin: auto;
+}
+
+.top-logo {
+ text-align: center;
+}
+
+.item-box {
+ margin: 30px auto auto;
+ display: block;
+}
+.password-change img {
+ width: 50%;
+}
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/checkInput.php b/website/queries/checkInput.php
index 5f72f10..9b91833 100644
--- a/website/queries/checkInput.php
+++ b/website/queries/checkInput.php
@@ -97,6 +97,18 @@ function validateEmail($variable){
}
}
+/* checks if an input is a valid email. */
+function resetEmail($variable){
+ if (empty($variable)) {
+ throw new emailException("Verplicht!");
+ } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) {
+ throw new emailException("Geldige email invullen");
+ } else if (getResetEmail() == 0){
+ throw new emailException("Email bestaat niet!");
+ }
+}
+
+
/* checks if two passwords matches. */
function matchPassword(){
if ($_POST["password"] != $_POST["confirmpassword"]) {
diff --git a/website/queries/friendship.php b/website/queries/friendship.php
index 2f43415..57dacd8 100644
--- a/website/queries/friendship.php
+++ b/website/queries/friendship.php
@@ -1,13 +1,51 @@
prepare("
+ SELECT
+ `userID`,
+ `username`,
+ LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
+ IFNULL(
+ `profilepicture`,
+ '../img/avatar-standard.png'
+ ) AS profilepicture,
+ `onlinestatus`,
+ `role`
+ 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'
+ LIMIT :limitCount
+ ");
+
+ $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
+ $stmt->bindParam(':limitCount', $limit, PDO::PARAM_INT);
+ $stmt->execute();
+
+ return json_encode($stmt->fetchAll());
+}
+
function selectAllFriends($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`userID`,
`username`,
- LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `name`,
+ LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
IFNULL(
`profilepicture`,
'../img/avatar-standard.png'
@@ -39,22 +77,7 @@ function selectAllFriendRequests() {
SELECT
`userID`,
`username`,
- CASE `status` IS NULL
- WHEN TRUE THEN 0
- WHEN FALSE THEN
- CASE `status` = 'confirmed'
- WHEN TRUE THEN
- 1
- WHEN FALSE THEN
- CASE `user1ID` = :userID
- WHEN TRUE THEN
- 2
- WHEN FALSE THEN
- 3
- END
- END
- END AS `friend_state`,
- LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `name`,
+ LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
IFNULL(
`profilepicture`,
'../img/avatar-standard.png'
diff --git a/website/queries/group_member.php b/website/queries/group_member.php
index 59d4dce..a188494 100644
--- a/website/queries/group_member.php
+++ b/website/queries/group_member.php
@@ -1,6 +1,10 @@
prepare("
SELECT
`group_page`.`name`,
@@ -13,10 +17,13 @@ function selectAllGroupsFromUser($userID) {
`group_member`.`userID` = :userID AND
`group_member`.`groupID` = `group_page`.`groupID` AND
`group_page`.`status` != 'hidden'
+ LIMIT :limitCount
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
+ $stmt->bindParam(':limitCount', $limit, PDO::PARAM_INT);
$stmt->execute();
- return $stmt;
+ return json_encode($stmt->fetchAll());
}
+
diff --git a/website/queries/post.php b/website/queries/post.php
new file mode 100644
index 0000000..0183a5d
--- /dev/null
+++ b/website/queries/post.php
@@ -0,0 +1,97 @@
+prepare("
+ SELECT
+ `user`.`fname`,
+ `user`.`lname`,
+ `user`.`username`,
+ `post`.`groupID`,
+ `post`.`title`,
+ `post`.`content`,
+ `post`.`creationdate`
+ FROM
+ `post`
+ INNER JOIN
+ `user`
+ ON
+ `post`.`author` = `user`. `userID`
+ WHERE
+ `post`.`postID` = :postID
+ ");
+
+ $stmt->bindParam(':postID', $postID);
+ $stmt->execute();
+ return $stmt;
+}
+
+function selectCommentsByPostId($postID) {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `comment`.`commentID`,
+ `comment`.`postID`,
+ `comment`.`author`,
+ `comment`.`content`,
+ `comment`.`creationdate`,
+ `user`.`fname`,
+ `user`.`lname`,
+ `user`.`username`
+ FROM
+ `comment`
+ INNER JOIN
+ `user`
+ ON
+ `comment`.`author` = `user`.`userID`
+ WHERE
+ `comment`.`postID` = :postID
+ ");
+
+ $stmt->bindParam(':postID', $postID);
+ $stmt->execute();
+ return $stmt;
+}
+
+function makePost($userID, $groupID, $title, $content) {
+ $stmt = $GLOBALS["db"]->prepare("
+ INSERT INTO
+ `post` (
+ `author`,
+ `groupID`,
+ `title`,
+ `content`
+ )
+ VALUES (
+ :userID,
+ :groupID,
+ :title,
+ :content
+ )
+ ");
+
+ $stmt->bindParam(':userID', $userID);
+ $stmt->bindParam(':groupID', $groupID);
+ $stmt->bindParam(':title', $title);
+ $stmt->bindParam(':content', $content);
+ $stmt->execute();
+}
+
+function makeComment($postID, $userID, $content) {
+ $stmt = $_GLOBAL["db"]->prepare("
+ INSERT INTO
+ `comment` (
+ `postID`,
+ `author`,
+ `content`
+ )
+ VALUES (
+ :postID,
+ :userID,
+ :content
+ )
+ ");
+
+ $stmt->bindParam(':postID', $postID);
+ $stmt->bindParam(':userID', $userID);
+ $stmt->bindParam(':content', $content);
+ $stmt->execute();
+}
\ No newline at end of file
diff --git a/website/queries/private_message.php b/website/queries/private_message.php
index d40ee88..e708541 100644
--- a/website/queries/private_message.php
+++ b/website/queries/private_message.php
@@ -79,11 +79,11 @@ function getNewChatMessages($lastID, $destination) {
function selectAllUnreadChat() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
- LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `name`,
+ LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
`user`.`userID`,
IFNULL(
- `profilepicture`,
- '../img/notbad.jpg'
+ `profilepicture`,
+ '../img/notbad.jpg'
) AS profilepicture,
LEFT(`private_message`.`content`, 15) as `content`
FROM
@@ -93,15 +93,18 @@ function selectAllUnreadChat() {
WHERE
(`friendship`.user2ID = `private_message`.`origin` AND
`friendship`.user1ID = `private_message`.`destination` AND
- `friendship`.chatLastVisted1 < `private_message`.`creationdate` OR
+ (`friendship`.chatLastVisted1 < `private_message`.`creationdate` OR
+ `friendship`.chatLastVisted1 IS NULL) OR
`friendship`.user1ID = `private_message`.`origin` AND
- `friendship`.user2ID = `private_message`.`destination` AND
- `friendship`.chatLastVisted2 < `private_message`.`creationdate`) AND
+ `friendship`.user2ID = `private_message`.`destination` AND
+ (`friendship`.chatLastVisted2 < `private_message`.`creationdate` OR
+ `friendship`.chatLastVisted2 IS NULL)) AND
`private_message`.`origin` = `user`.`userID` AND
`private_message`.`destination` = :userID AND
`user`.`role` != 'banned'
GROUP BY `user`.`userID`
+
");
$stmt->bindParam(':userID', $_SESSION["userID"]);
diff --git a/website/queries/register.php b/website/queries/register.php
index 4700e72..738ef43 100644
--- a/website/queries/register.php
+++ b/website/queries/register.php
@@ -32,6 +32,22 @@ function getExistingEmail() {
}
+function getResetEmail() {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `email`
+ FROM
+ `user`
+ WHERE
+ `email` LIKE :email
+ ");
+
+ $stmt->bindParam(":email", $_POST["forgotEmail"]);
+ $stmt->execute();
+ return $stmt->rowCount();
+
+}
+
function registerAccount() {
$stmt = $GLOBALS["db"]->prepare("
INSERT INTO
diff --git a/website/queries/requestpassword.php b/website/queries/requestpassword.php
new file mode 100644
index 0000000..c0ff462
--- /dev/null
+++ b/website/queries/requestpassword.php
@@ -0,0 +1,54 @@
+prepare("
+ SELECT
+ `userID`,
+ `username`
+ FROM
+ `user`
+ WHERE
+ `email` = :email
+ ");
+ $stmt->bindParam(":email", $email);
+ $stmt->execute();
+ if (!$stmt->rowCount()) {
+ return;
+ }
+ $result = $stmt->fetch();
+ $userID = $result["userID"];
+ $username = $result["username"];
+ $hash = md5(random_int(0, 1000000));
+ $hashedHash = password_hash($hash, PASSWORD_DEFAULT);
+ setHashToDatabase($userID, $hash);
+ doSendPasswordRecovery($userID, $email, $username, $hashedHash);
+ } else {
+ // TODO: Be angry!
+ }
+}
+
+function doSendPasswordRecovery(int $userID, string $email, string $username, string $hash) {
+ $resetLink = "https://myhyvesbookplus.nl/resetpassword.php?u=$userID&h=$hash";
+
+ $subject = "Reset uw wachtwoord";
+ $body = "Hallo $username,\r\n\r\nKlik op de onderstaande link om uw wachtwoord te resetten.\r\n\r\n$resetLink\r\n\r\nGroeten MyHyvesbook+";
+ $header = "From: MyHyvesbook+
";
+ mail($email, $subject, $body, $header);
+}
+
+function setHashToDatabase(int $userID, string $hash) {
+ $stmt = $GLOBALS["db"]->prepare("
+ UPDATE
+ `user`
+ SET
+ `password` = :hash
+ WHERE
+ `userID` = :userID
+ ");
+ $stmt->bindParam(":hash", $hash);
+ $stmt->bindParam(":userID", $userID);
+ $stmt->execute();
+ return $stmt->rowCount();
+}
\ No newline at end of file
diff --git a/website/queries/user.php b/website/queries/user.php
index 7672746..cb4525d 100644
--- a/website/queries/user.php
+++ b/website/queries/user.php
@@ -323,7 +323,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/chat-view.php b/website/views/chat-view.php
index 797e457..0d90149 100644
--- a/website/views/chat-view.php
+++ b/website/views/chat-view.php
@@ -16,7 +16,7 @@
// Set default values of a friend.
$username = $friend["username"];
- $name = $friend["name"];
+ $name = $friend["fullname"];
$userID = $friend["userID"];
$pf = "img/avatar-standard.png";
@@ -37,9 +37,8 @@
";
}
-
- $chatID = $_GET["chatID"];
- if (isset($chatID) && $chatID != "") {
+ if (isset($_GET["username"]) && $_GET["username"] != "") {
+ $chatID = $_GET["username"];
echo "";
}
?>
diff --git a/website/views/head.php b/website/views/head.php
index 044ac83..b6c2f21 100644
--- a/website/views/head.php
+++ b/website/views/head.php
@@ -2,6 +2,7 @@
MyHyvesbook+
+
diff --git a/website/views/login-view.php b/website/views/login-view.php
index 7a023f0..de4c48b 100644
--- a/website/views/login-view.php
+++ b/website/views/login-view.php
@@ -7,8 +7,9 @@
Welkom bij MyHyvesbook+
+
diff --git a/website/views/login_head.php b/website/views/login_head.php
index e831cd2..e319a9d 100644
--- a/website/views/login_head.php
+++ b/website/views/login_head.php
@@ -7,7 +7,7 @@
-
+
diff --git a/website/views/menu.php b/website/views/menu.php
index d360e77..4d15d94 100644
--- a/website/views/menu.php
+++ b/website/views/menu.php
@@ -1,134 +1,25 @@
\ No newline at end of file
diff --git a/website/views/messagepage.php b/website/views/messagepage.php
new file mode 100644
index 0000000..2dfc871
--- /dev/null
+++ b/website/views/messagepage.php
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+ ");
+
+ echo $webpage;
+ }
\ No newline at end of file
diff --git a/website/views/notification-center.php b/website/views/notification-center.php
index 037b4ae..8c01217 100644
--- a/website/views/notification-center.php
+++ b/website/views/notification-center.php
@@ -5,19 +5,19 @@