\

\
diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js
index 0452d15..ef49e83 100644
--- a/website/public/js/registerAndLogin.js
+++ b/website/public/js/registerAndLogin.js
@@ -4,5 +4,12 @@ function checkLoggedIn() {
} else {
window.location.href = "profile.php";
}
- document.getElementById("demo").innerHTML = x;
}
+
+function bannedAlert(){
+ alert("Your account is banned");
+}
+
+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 0d07413..de4ecab 100644
--- a/website/public/login.php
+++ b/website/public/login.php
@@ -5,6 +5,7 @@
require_once("../queries/connect.php");
include_once("../queries/login.php");
include_once("../queries/checkInput.php");
+ include_once("../queries/emailconfirm.php");
?>
getMessage();
}
}
diff --git a/website/public/logout.php b/website/public/logout.php
index 6a2ba5d..de4d7c2 100644
--- a/website/public/logout.php
+++ b/website/public/logout.php
@@ -1,15 +1,4 @@
-
-
-
-
-
-
+session_start();
+session_destroy();
+header("Location: login.php");
\ No newline at end of file
diff --git a/website/public/profile.php b/website/public/profile.php
index 4707dc1..aeea68b 100644
--- a/website/public/profile.php
+++ b/website/public/profile.php
@@ -15,7 +15,6 @@ include("../queries/nicetime.php");
if(empty($_GET["username"])) {
$userID = $_SESSION["userID"];
- echo "USERNAME NOT GIVEN";
} else {
$userID = getUserID($_GET["username"]);
}
diff --git a/website/public/register.php b/website/public/register.php
index 99af6c0..1ce4817 100644
--- a/website/public/register.php
+++ b/website/public/register.php
@@ -5,6 +5,7 @@
require_once("../queries/connect.php");
include_once("../queries/register.php");
include_once("../queries/checkInput.php");
+ include_once("../queries/emailconfirm.php");
?>
getMessage();
}
diff --git a/website/public/styles/index.css b/website/public/styles/index.css
index 8482cea..fc9d3d6 100644
--- a/website/public/styles/index.css
+++ b/website/public/styles/index.css
@@ -1,6 +1,6 @@
a.button {
background-color: #C8CABD;
- border-radius: 10px;
+ border-radius: 5px;
color: black;
cursor: pointer;
height: 50%;
diff --git a/website/public/styles/menu.css b/website/public/styles/menu.css
index ce294da..204acd0 100644
--- a/website/public/styles/menu.css
+++ b/website/public/styles/menu.css
@@ -63,4 +63,32 @@
#quick-links i:hover {
color: #FBC02D;
+}
+
+.notification-options {
+ display: none;
+ width: 100%;
+}
+
+.notification-options form {
+ width: 100%;
+ text-align: center;
+}
+
+.notification-options button {
+ display: inline-block;
+ padding: 5px 20px;
+ width: auto;
+}
+
+.accept-notification:hover {
+ color: #4CAF50;
+}
+
+.deny-notification:hover {
+ color: firebrick;
+}
+
+.friend-item:hover .notification-options {
+ display: inline-block;
}
\ No newline at end of file
diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php
index cc32626..5f72f10 100644
--- a/website/queries/checkInput.php
+++ b/website/queries/checkInput.php
@@ -38,7 +38,8 @@ 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!");
}
}
diff --git a/website/queries/emailconfirm.php b/website/queries/emailconfirm.php
new file mode 100644
index 0000000..0b3224f
--- /dev/null
+++ b/website/queries/emailconfirm.php
@@ -0,0 +1,42 @@
+prepare("
+ SELECT
+ `userID`
+ FROM
+ `user`
+ WHERE
+ `username` = :username
+ ");
+ $stmt->bindParam(":username", $username);
+ $stmt->execute();
+ $userID = $stmt->fetch()["username"];
+ sendConfirmEmail($userID);
+}
+
+function sendConfirmEmail(int $userID) {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `email`,
+ `fname`
+ FROM
+ `user`
+ WHERE
+ `userID` = :userID
+ ");
+
+ $stmt->bindParam(":userID", $userID);
+ $stmt->execute();
+ $user = $stmt->fetch();
+
+ $email = $user["email"];
+ $fname = $user["fname"];
+ $hash = password_hash($email, PASSWORD_DEFAULT);
+ $confirmLink = "https://myhyvesbookplus.nl/emailconfirm.php?u=$userID&h=$hash";
+
+ $subject = "Bevestig uw emailadres";
+ $body = "Hallo $fname,\r\n\r\nKlik op de onderstaande link om uw emailadres te bevestigen.\r\n\r\n$confirmLink\r\n\r\nGroeten MyHyvesbook+";
+ $header = "From: MyHyvesbook+
";
+ mail($email, $subject, $body, $header);
+}
\ No newline at end of file
diff --git a/website/queries/friendship.php b/website/queries/friendship.php
index f69522e..2f43415 100644
--- a/website/queries/friendship.php
+++ b/website/queries/friendship.php
@@ -39,6 +39,21 @@ 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`,
IFNULL(
`profilepicture`,
diff --git a/website/queries/login.php b/website/queries/login.php
index 180b431..2af255a 100644
--- a/website/queries/login.php
+++ b/website/queries/login.php
@@ -4,7 +4,8 @@ function getUser() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`password`,
- `userID`
+ `userID`,
+ `role`
FROM
`user`
WHERE
@@ -15,3 +16,46 @@ function getUser() {
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
+
+function validateLogin($username, $password){
+ // Empty username or password field
+ if (empty($username) || empty($password)) {
+ throw new loginException("Gebruikersnaam of wachtwoord is niet ingevuld");
+ }
+ else {
+ $psw = test_input($password);
+ $hash = getUser()["password"];
+ $userID = getUser()["userID"];
+ $role = getUser()["role"];
+
+ // If there's an account, go to the profile page
+ if(password_verify($psw, $hash)) {
+ if ($role == "banned"){
+ echo "";
+ } else if ($role == "unconfirmed"){
+ sendConfirmEmail(getUser()["userID"]);
+ echo "";
+ } else {
+ $_SESSION["userID"] = $userID;
+ header("location: profile.php");
+ }
+ } else {
+ throw new loginException("Inloggevens zijn niet correct");
+ }
+
+ }
+}
+
+class loginException extends Exception
+{
+ public function __construct($message = "", $code = 0, Exception $previous = null)
+ {
+ parent::__construct($message, $code, $previous);
+ }
+}
+?>
+
diff --git a/website/queries/private_message.php b/website/queries/private_message.php
index 4fbb55d..d40ee88 100644
--- a/website/queries/private_message.php
+++ b/website/queries/private_message.php
@@ -80,6 +80,7 @@ function selectAllUnreadChat() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `name`,
+ `user`.`userID`,
IFNULL(
`profilepicture`,
'../img/notbad.jpg'
diff --git a/website/queries/settings.php b/website/queries/settings.php
index d3985c7..0bf8791 100644
--- a/website/queries/settings.php
+++ b/website/queries/settings.php
@@ -1,4 +1,6 @@
bindParam(":email", $email);
$stmt->bindParam(":userID", $_SESSION["userID"]);
$stmt->execute();
-// return $stmt->rowCount();
if ($stmt->rowCount()) {
+ sendConfirmEmail($_SESSION["userID"]);
+ session_destroy();
throw new HappyAlert("Emailadres is veranderd.");
} else {
throw new AngryAlert();
diff --git a/website/views/chat-view.php b/website/views/chat-view.php
index 598b3ee..797e457 100644
--- a/website/views/chat-view.php
+++ b/website/views/chat-view.php
@@ -35,7 +35,12 @@