diff --git a/website/public/API/nietSlecht.php b/website/public/API/nietSlecht.php
new file mode 100644
index 0000000..e37c8e0
--- /dev/null
+++ b/website/public/API/nietSlecht.php
@@ -0,0 +1,41 @@
+prepare("
+ SELECT
+ `userID`
+ FROM
+ `niet_slecht`
+ WHERE
+ `postID` = :postID
+ ");
+ $stmt->bindParam(":postID", $postID);
+ $stmt->execute();
+ return $stmt->rowCount();
+}
+
+function getNietSlechtUsersForPost(int $postID) {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `fname`,
+ `lname`,
+ CONCAT(`user`.`fname`, ' ', `user`.`lname`) as `fullname`
+ FROM
+ `user`
+ INNER JOIN
+ `niet_slecht`
+ WHERE
+ `user`.`userID` = `niet_slecht`.`userID` AND
+ `niet_slecht`.`postID` = :postID
+ ");
+ $stmt->bindParam(":postID", $postID);
+ $stmt->execute();
+ $rows = $stmt->fetchAll();
+ foreach ($rows as $row) {
+ print($row["fullname"]);
+ }
+}
\ No newline at end of file
diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php
index b840e0b..30c02eb 100644
--- a/website/public/API/postComment.php
+++ b/website/public/API/postComment.php
@@ -5,14 +5,25 @@ 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']))) {
+print_r($_POST);
+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;
+ }
+ }
+} else if ($_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/group.php b/website/public/group.php
index ee20feb..fa45090 100644
--- a/website/public/group.php
+++ b/website/public/group.php
@@ -8,6 +8,17 @@
+
+
+ previousDate) {
+ previousDate = thisDate;
+ $("#chat-history").append('\
+ ");
- $post.append($("
").text(this["title"]));
+ $post.append($("").html(this["title"]));
$post.append($(" ").html(this["content"]));
$post.append($("
").text(this["nicetime"]));
+ $post.append($("
").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);
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/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/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/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/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/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..6bebd7e 100644
--- a/website/public/register.php
+++ b/website/public/register.php
@@ -1,115 +1,91 @@
-
-
-
-getMessage();
}
- // define variables and set to empty values
- $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") {
- 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){
- $genericErr = $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();
}
-/* This view adds register view */
-include("../views/register-view.php");
-?>
-
-
diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css
index 6822d21..0ba5af4 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;
@@ -105,4 +126,8 @@
.active-friend-chat {
background: #4CAF50;
color: white;
+}
+
+.chat-message img {
+ max-width: 100%;
}
\ No newline at end of file
diff --git a/website/public/styles/index.css b/website/public/styles/index.css
index 85cc670..6f7caf0 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,11 +63,15 @@ 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%;
}
+.middle{
+ text-align: center;
+}
+
.center{
text-align: center;
}
@@ -79,7 +83,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 +94,7 @@ button {
font-family: Arial;
font-size: 15px;
color: red;
+ text-align: left;
}
label {
@@ -98,19 +103,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 +134,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 +154,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 +171,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 +194,7 @@ ul {
.close {
color: white;
float: right;
- font-size: 28px;
+ font-size: 36px;
font-weight: bold;
}
@@ -201,7 +206,7 @@ ul {
}
.modal-header {
- padding: 2px 16px;
+ padding: 4px 16px;
background-color: #FBC02D;
color: black;
}
diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css
index 11fe03b..c6e96c1 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, 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/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/group_page.php b/website/queries/group_page.php
index cdef6ae..5652e37 100644
--- a/website/queries/group_page.php
+++ b/website/queries/group_page.php
@@ -1,5 +1,58 @@
prepare("
+ SELECT
+ `group_page`.`groupID`,
+ `name`,
+ `description`,
+ `picture`,
+ `status`,
+ COUNT(`group_member`.`groupID`) as `members`
+ FROM
+ `group_page`
+ LEFT JOIN
+ `group_member`
+ ON
+ `group_page`.`groupID` = `group_member`.`groupID`
+ WHERE
+ name LIKE :name
+ ");
+
+ $stmt->bindParam(':name', $name);
+ if (!$stmt->execute()) {
+ return False;
+ }
+ return $stmt->fetch();
+}
+
+function selectGroupMembers(int $groupID) {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `username`,
+ `fname`,
+ `lname`,
+ `profilepicture`
+ FROM
+ `group_member`
+ LEFT JOIN
+ `user`
+ ON
+ `group_member`.`userID` = `user`.`userID`
+ WHERE
+ `groupID` = :groupID
+ LIMIT 20
+ ");
+
+ $stmt->bindParam(':groupID', $groupID);
+ if (!$stmt->execute()) {
+ return False;
+ }
+ return $stmt->fetchAll();
+}
+
function selectGroupById($groupID) {
$q = $GLOBALS["db"]->prepare("
SELECT
diff --git a/website/queries/login.php b/website/queries/login.php
index 6af9e1e..384a3d5 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/queries/post.php b/website/queries/post.php
index 5940267..df1e227 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/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/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
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/queries/user.php b/website/queries/user.php
index 9c41435..1d075ef 100644
--- a/website/queries/user.php
+++ b/website/queries/user.php
@@ -106,24 +106,36 @@ function selectAllUserGroups($userID) {
function selectAllUserPosts($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
- `postID`,
- `author`,
+ `post`.`postID`,
+ `post`.`author`,
`title`,
- CASE LENGTH(`content`) >= 150 AND `content` NOT LIKE '
= 150 AND `post`.`content` NOT LIKE '
bindParam(':userID', $userID, PDO::PARAM_INT);
diff --git a/website/views/bdayInput.php b/website/views/bdayInput.php
new file mode 100644
index 0000000..f4e440f
--- /dev/null
+++ b/website/views/bdayInput.php
@@ -0,0 +1,37 @@
+
+ dag
+
+ >= $i ?>
+
+
+
+ Maand
+ >januari
+ >februari
+ >maart
+ >april
+ >mei
+ >juni
+ >juli
+ >augustus
+ >september
+ >oktober
+ >november
+ >december
+
+
+ Jaar
+ format("Y");
+ for($i=$year; $i > $year - 100; $i--) {
+ ?>
+ >= $i ?>
+
+
diff --git a/website/views/forgotPasswordModal.php b/website/views/forgotPasswordModal.php
new file mode 100644
index 0000000..d3f12f9
--- /dev/null
+++ b/website/views/forgotPasswordModal.php
@@ -0,0 +1,36 @@
+
+
Wachtwoord vergeten
+
+
+
\ No newline at end of file
diff --git a/website/views/group.php b/website/views/group.php
index c8ed118..b2098c7 100644
--- a/website/views/group.php
+++ b/website/views/group.php
@@ -1,43 +1,21 @@
+
+// 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/post-view.php b/website/views/post-view.php
index 61e0e05..e3ceb9b 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("
- + + +