diff --git a/.gitignore b/.gitignore
index b1a2ad1..49adb33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -117,7 +117,7 @@ Temporary Items
# *.pdf
## Generated if empty string is given at "Please type another file name for output:"
-projectplan.pdf
+projectplan/projectplan.pdf
## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
new file mode 100644
index 0000000..af0e43a
--- /dev/null
+++ b/.idea/sqldialects.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projectplan/projectplan.pdf b/projectplan/projectplan.pdf
deleted file mode 100644
index e41b19d..0000000
Binary files a/projectplan/projectplan.pdf and /dev/null differ
diff --git a/projectplan/projectplan.tex b/projectplan/projectplan.tex
index 42c6475..bcd0fce 100644
--- a/projectplan/projectplan.tex
+++ b/projectplan/projectplan.tex
@@ -14,6 +14,9 @@
\documentclass{uva-inf-article}
\usepackage[dutch]{babel}
\usepackage{enumitem}
+\usepackage{pgfgantt}
+\usepackage{pdflscape}
+\usepackage{geometry}
%-------------------------------------------------------------------------------
% GEGEVENS VOOR IN DE TITEL
@@ -173,6 +176,83 @@ Voor deze opdracht hebben we met 5 mensen 4 weken de tijd.
%Zet de planning indien gewenst in een apart document
%\input{planning}
+\newgeometry{top=20mm, bottom=20mm, left=10mm, right=10mm}
+\begin{landscape}
+\section{Planning}
+\begin{ganttchart}[
+ vgrid,
+ hgrid,
+ x unit=1cm,
+ y unit title=.6cm,
+ y unit chart=.7cm,
+ group left peak width=.2,
+ group right peak width=.2
+ ]{1}{21}
+ \gantttitle{MyHyvesBook+}{21} \ganttnewline
+ \gantttitle{Week 1}{5}
+ \gantttitle{Week 2}{5}
+ \gantttitle{Week 3}{5}
+ \gantttitle{Week 4}{5} \ganttnewline
+ \gantttitlelist{9,...,13}{1}
+ \gantttitlelist{16,...,20}{1}
+ \gantttitlelist{23,...,27}{1}
+ \gantttitlelist{30,31,1,2,3}{1} \ganttnewline
+
+ \ganttbar{Inleiden}{1}{1} \ganttnewline
+
+ \ganttlinkedgroup{Frontend}{2}{5} \ganttnewline
+
+ \ganttbar{html/views}{2}{5} \ganttnewline
+ \ganttbar{css/styles}{2}{5} \ganttnewline
+ \ganttbar{javascript}{2}{5} \ganttnewline
+ \ganttmilestone{Week 1}{5} \ganttnewline
+
+ \ganttlink[link mid=.833]{elem2}{elem5}
+ \ganttlink[link mid=.75]{elem3}{elem5}
+ \ganttlink[link mid=.5]{elem4}{elem5}
+
+ \ganttlinkedgroup{Backend}{6}{10} \ganttnewline
+
+ \ganttbar{Database/PhpMyAdmin}{6}{6} \ganttnewline
+ \ganttbar{SQL-queries/MySql}{7}{10} \ganttnewline
+ \ganttbar{Forms/php}{6}{10} \ganttnewline
+ \ganttbar{Livechat/AJAX, PHP}{6}{10} \ganttnewline
+ \ganttmilestone{Week 2}{10} \ganttnewline
+
+ \ganttlink[link mid=.5]{elem7}{elem8}
+ \ganttlink[link mid=.833]{elem8}{elem11}
+ \ganttlink[link mid=.75]{elem9}{elem11}
+ \ganttlink[link mid=.5]{elem10}{elem11}
+
+ \ganttbar{Beveiliging/testen}{6}{15} \ganttnewline
+
+ \ganttgroup{Gebruiksvriendleijk}{11}{15} \ganttnewline
+ \ganttbar{Mobileformaat}{11}{15} \ganttnewline
+ \ganttbar{Restyle}{11}{15} \ganttnewline
+ \ganttbar{Extra's}{11}{15} \ganttnewline
+ \ganttbar{Code opschonen}{14}{15} \ganttnewline
+
+ \ganttmilestone{Week 3}{15} \ganttnewline
+ \ganttlink[link mid=.75]{elem11}{elem13}
+ \ganttlink[link mid=.917]{elem12}{elem18}
+ \ganttlink[link mid=.875]{elem14}{elem18}
+ \ganttlink[link mid=.833]{elem15}{elem18}
+ \ganttlink[link mid=.75]{elem16}{elem18}
+ \ganttlink[link mid=.5]{elem17}{elem18}
+
+ \ganttlinkedgroup{Afronding}{16}{20} \ganttnewline
+ \ganttbar{Rapport}{16}{20} \ganttnewline
+ \ganttbar{Documentatie}{16}{20} \ganttnewline
+ \ganttbar{Demo}{18}{20} \ganttnewline
+
+ \ganttmilestone{Finshed!}{20}
+ \ganttlink[link mid=.833]{elem20}{elem23}
+ \ganttlink[link mid=.75]{elem21}{elem23}
+ \ganttlink[link mid=.5]{elem22}{elem23}
+
+\end{ganttchart}
+\end{landscape}
+
%-------------------------------------------------------------------------------
% BIJLAGEN EN EINDE
diff --git a/website/public/chat.php b/website/public/chat.php
index f077a4d..09be336 100644
--- a/website/public/chat.php
+++ b/website/public/chat.php
@@ -5,6 +5,7 @@
+
\
+ \
+ ' + messages[i].content + '\
+
\
+ \
+ ');
+ }
+}
+
+function switchUser(userID) {
+ $(".destinationID").val(userID);
+ $("#chat-history").html("");
+ $("#lastID").val("");
+}
\ No newline at end of file
diff --git a/website/public/js/menu.js b/website/public/js/menu.js
index 56eab9b..32b048a 100644
--- a/website/public/js/menu.js
+++ b/website/public/js/menu.js
@@ -1,11 +1,12 @@
$(document).ready(function() {
$(".extra-menu-items").hide();
+ $("#menu-back").hide();
// Show more friends
$("#more-friends-click").click(function() {
// Show only friends
$("#groups-menu-section").slideUp();
- $("#friends-menu-section a").show();
+ $("#friends-menu-section li").show();
// Change buttons
$("#more-friends-click").hide();
@@ -16,7 +17,7 @@ $(document).ready(function() {
$("#more-groups-click").click(function() {
// Show only groups
$("#friends-menu-section").slideUp();
- $("#groups-menu-section a").show();
+ $("#groups-menu-section li").show();
// Change buttons
$("#more-groups-click").hide();
diff --git a/website/public/login.php b/website/public/login.php
index 0018067..09dce8c 100644
--- a/website/public/login.php
+++ b/website/public/login.php
@@ -1,13 +1,44 @@
diff --git a/website/public/register.php b/website/public/register.php
new file mode 100644
index 0000000..2299cf0
--- /dev/null
+++ b/website/public/register.php
@@ -0,0 +1,165 @@
+
+
+
+
+
+
+
diff --git a/website/public/sendMessage.php b/website/public/sendMessage.php
new file mode 100644
index 0000000..e555e2a
--- /dev/null
+++ b/website/public/sendMessage.php
@@ -0,0 +1,16 @@
+
-
+
"settings-message-angry",
+ "message" => "Deze functie werkt nog niet :("
+ );
+ break;
+ case "picture":
+ $result = array (
+ "type" => "settings-message-angry",
+ "message" => "Deze functie werkt nog niet :("
+ );
+ break;
+ }
+}
+
include("../views/settings-view.php");
-/* This adds the footer. */
include("../views/footer.php");
+
?>
diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css
index e761592..d5b740e 100644
--- a/website/public/styles/adminpanel.css
+++ b/website/public/styles/adminpanel.css
@@ -32,17 +32,36 @@
margin-bottom: 10px;
}
-.admin-filter {
+.admin-filter, .admin-filtertype, .admin-groupfilter {
display: inline-block;
margin: 10px;
vertical-align: top;
- margin-right: 100px;
+ margin-right: 50px;
+ margin-left: 50px;
+}
+
+.admin-filter, .admin-groupfilter {
+ width: 120px;
+}
+
+.admin-groupfilter {
+ display: none;
}
.admin-users {
margin: 10px;
}
+.admin-userpage {
+ width: 170px;
+ margin-bottom: 20px;
+ float: right;
+}
+
+.usertitle {
+ width: 150px;
+}
+
.usertable {
width: 100%;
}
diff --git a/website/public/styles/index.css b/website/public/styles/index.css
index b4daae7..c7d482f 100644
--- a/website/public/styles/index.css
+++ b/website/public/styles/index.css
@@ -1,98 +1,118 @@
::selection {
- background: #845663;
- color: white;
+ background: #845663;
+ color: white;
}
::-moz-selection {
- background: #845663;
- color: white;
+ background: #845663;
+ color: white;
}
a, a:link, a:visited, a:hover, a:active {
- color: inherit;
- text-decoration: none;
+ color: inherit;
+ text-decoration: none;
}
+a.button {
+ background-color: #845663;
+ border: 2px solid black;
+ border-radius: 12px;
+ color: white;
+ cursor: pointer;
+ height: 50%;
+ margin: 8px 0;
+ padding: 14px 20px;
+ width: 25%;
+ font-family: Arial;
+ font-size: 16px;
+}
a[data-title]:hover:after, img[data-title]:hover:after, span[data-title]:hover:after,
div[data-title]:hover:after{
- content: attr(data-title);
- padding: 4px 4px;
- color: #FFFFFF;
- position: absolute;
- left: 0;
- top: 100%;
- z-index: 20;
- white-space: nowrap;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- border-radius: 5px;
- -moz-box-shadow: 0px 0px 4px #222;
- -webkit-box-shadow: 0px 0px 4px #222;
- box-shadow: 0px 0px 4px #222;
- background-color: #333;
- font-size: 15px;
- line-height: normal;
- font-family: Arial, sans-serif;
+ content: attr(data-title);
+ padding: 4px 4px;
+ color: #FFFFFF;
+ position: absolute;
+ left: 0;
+ top: 100%;
+ z-index: 20;
+ white-space: nowrap;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ -moz-box-shadow: 0px 0px 4px #222;
+ -webkit-box-shadow: 0px 0px 4px #222;
+ box-shadow: 0px 0px 4px #222;
+ background-color: #333;
+ font-size: 15px;
+ line-height: normal;
+ font-family: Arial, sans-serif;
}
/* Add Zoom Animation */
.animate {
- animation: animatezoom 0.6s
- -webkit-animation: animatezoom 0.6s;
+ animation: animatezoom 0.6s
+ -webkit-animation: animatezoom 0.6s;
}
/* Body */
body {
- height: 100%;
+ height: 900px;
- background-color: #B78996;
- color: #333;
+ background-image: url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTEnqKdVtLbxjKuNsCSCxFRhTOpp3Gm0gsU8bMgA_MeUYyzrUFy);
+ background-size: cover;
+ background-repeat: repeat-x;
+ background-attachment: fixed;
- font-family: Arial, sans-serif;
+ /*background-color: #B78996;*/
+ color: #333;
+
+ font-family: Arial, sans-serif;
}
/* stijl voor alle buttons */
button {
- background-color: #845663;
- border: 2px solid black;
- border-radius: 12px;
- color: white;
- cursor: pointer;
- height: 50%;
- margin: 8px 0;
- padding: 14px 20px;
- width: 25%;
- font-family: Arial;
- font-size: 16px;
+ background-color: #845663;
+ border: 2px solid black;
+ border-radius: 12px;
+ color: white;
+ cursor: pointer;
+ height: 50%;
+ margin: 8px 0;
+ padding: 14px 20px;
+ width: 25%;
+ font-family: Arial;
+ font-size: 16px;
}
/* The Close Button */
.close {
/* Position it in the top right corner outside of the modal */
- color: white;
- font-size: 100px;
- font-weight: bold;
- position: absolute;
- right: 25px;
- top: 0;
+ color: white;
+ font-size: 100px;
+ font-weight: bold;
+ position: absolute;
+ right: 25px;
+ top: 0;
}
/* Close button on hover */
.close:hover,
.close:focus {
- color: red;
- cursor: pointer;
+ color: red;
+ cursor: pointer;
}
/* inlogform */
form {
- background-color: #a87a87;
+ /*background-color: #a87a87;*/
border: 5px solid #325da3;
+ background-color: #a87a87;
border-radius: 12px;
- height: 50%;
- margin: auto;
- width: 55%;
+ height: 55%;
+ margin: 35px auto;
+ width: 45%;
+ overflow-y:auto;
}
/* inlog titel */
@@ -115,14 +135,14 @@ input[type=text], input[type=password], input[type=email], input[type="date"] {
box-sizing: border-box;
display: inline-block;
height: 50%;
- padding: 12px 20px;
- margin: 8px 0;
+ padding: 8px 20px;
+ margin: 4px 0;
width: 50%;
font-family: Arial;
font-size: 16px;
}
-input[type=submit] {
+button[type=submit] {
background-color: #845663;
border: 2px solid black;
border-radius: 12px;
@@ -142,14 +162,21 @@ label {
/* padding voor registreer container */
.login_containerregister {
- padding: 16px;
- text-align: left;
+ padding: 16px;
+ text-align: left;
}
/* padding voor login_containers */
.login_containerlogin {
- padding: 16px;
- text-align: center;
+ padding: 16px;
+ text-align: center;
+}
+
+/* padding voor foutmelding login */
+.login_containerfault {
+ padding: 16px;
+ text-align: center;
+ color: red;
}
/* The Modal (background) */
@@ -175,12 +202,13 @@ label {
margin: 5px auto; /* 15% from the top and centered */
overflow-y: auto;
width: 40%; /* Could be more or less, depending on screen size */
- height: 80%;
+ height: 60%;
+
}
@keyframes animatezoom {
- from {transform: scale(0)}
- to {transform: scale(1)}
+ from {transform: scale(0)}
+ to {transform: scale(1)}
}
/* datepicker */
@@ -203,6 +231,6 @@ select {
}
ul {
- font-family: Arial;
- font-size: 16px;
+ font-family: Arial;
+ font-size: 16px;
}
diff --git a/website/public/styles/menu.css b/website/public/styles/menu.css
index 7778545..45163de 100644
--- a/website/public/styles/menu.css
+++ b/website/public/styles/menu.css
@@ -25,3 +25,16 @@
font-size: 14px;
cursor: pointer;
}
+
+.friend-item {
+ cursor: pointer;
+}
+
+.menu button {
+ background: none;
+ color: #333;
+ width: 100%;
+ height: 100%;
+ padding: 0;
+ text-align: left;
+}
\ No newline at end of file
diff --git a/website/public/styles/settings.css b/website/public/styles/settings.css
index da55ec4..933e7fd 100644
--- a/website/public/styles/settings.css
+++ b/website/public/styles/settings.css
@@ -5,6 +5,17 @@
.settings-password {
margin-right: 15px;
}
+.settings-message {
+ color: white;
+}
+.settings-message-angry {
+ background-color: firebrick;
+}
+
+.settings-message-happy {
+ background-color: forestgreen;
+
+}
.settings li {
@@ -21,6 +32,10 @@
text-align: right;
}
+.settings-password label, .settings-email label {
+ text-align: left;
+}
+
/* All the fields for typing things. */
.settings input[type="password"],
.settings input[type="text"],
diff --git a/website/public/template_sql.php b/website/public/template_sql.php
index 3ef5b97..b918f6a 100644
--- a/website/public/template_sql.php
+++ b/website/public/template_sql.php
@@ -4,7 +4,6 @@
mysql_host;dbname=$dbconf->mysql_database;charset=utf8",
+ $GLOBALS["db"] = new PDO("mysql:host=$dbconf->mysql_host;dbname=$dbconf->mysql_database;charset=utf8",
"$dbconf->mysql_username", "$dbconf->mysql_password")
or die('Error connecting to mysql server');
-}
-
-?>
+}
\ No newline at end of file
diff --git a/website/queries/friendship.php b/website/queries/friendship.php
index 94cd123..14fa6ee 100644
--- a/website/queries/friendship.php
+++ b/website/queries/friendship.php
@@ -27,4 +27,4 @@ function selectAllFriends($db, $userID) {
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt;
-}
+}
\ No newline at end of file
diff --git a/website/queries/group_member.php b/website/queries/group_member.php
new file mode 100644
index 0000000..824a33b
--- /dev/null
+++ b/website/queries/group_member.php
@@ -0,0 +1,21 @@
+query("
+ SELECT
+ `group_page`.`name`,
+ `group_page`.`picture`
+ FROM
+ `group_page`
+ INNER JOIN
+ `group_member`
+ WHERE
+ `group_member`.`userID` = $userID AND
+ `group_member`.`groupID` = `group_page`.`groupID` AND
+ `group_page`.`status` != 0
+ ");
+}
+
+
+
+?>
\ No newline at end of file
diff --git a/website/queries/group_page.php b/website/queries/group_page.php
new file mode 100644
index 0000000..c6db01b
--- /dev/null
+++ b/website/queries/group_page.php
@@ -0,0 +1,99 @@
+query("
+ SELECT
+ `group_page`.`name`,
+ `group_page`.`picture`,
+ `group_page`.`description`,
+ `group_page`.`status`,
+ `group_page`.`creationdate`
+ FROM
+ `group_page`
+ WHERE
+ `group_page`.`groupID` = $groupID
+ ");
+}
+
+function select20GroupsFromN($db, $n) {
+ return $db->query("
+ SELECT
+ `group_page`.`groupID`,
+ `group_page`.`name`,
+ `group_page`.`picture`,
+ `group_page`.`description`,
+ `group_page`.`status`,
+ `group_page`.`creationdate`
+ FROM
+ `group_page`
+ ORDER BY
+ `group_page`.`name` ASC
+ LIMIT
+ $n, 20
+ ");
+}
+
+function select20GroupsByStatusFromN($db, $n, $status) {
+ return $db->query("
+ SELECT
+ `group_page`.`groupID`,
+ `group_page`.`name`,
+ `group_page`.`picture`,
+ `group_page`.`description`,
+ `group_page`.`status`,
+ `group_page`.`creationdate`
+ FROM
+ `group_page`
+ WHERE
+ `group_page`.`status` = $status
+ ORDER BY
+ `group_page`.`name` ASC
+ LIMIT
+ $n, 20
+ ");
+}
+
+function search20GroupsFromNByStatus($db, $n, $keyword, $status) {
+ $q = $db->prepare("
+ SELECT
+ `groupID`,
+ `name`,
+ `status`,
+ `description`
+ FROM
+ `group_page`
+ WHERE
+ `name` LIKE :keyword AND
+ FIND_IN_SET (`status`, :statuses)
+ ORDER BY
+ `name`
+ LIMIT
+ :n, 20
+ ");
+
+ $keyword = "%$keyword%";
+ $q->bindParam(':keyword', $keyword);
+ $q->bindParam(':n', $n, PDO::PARAM_INT);
+ $statuses = implode(',', $status);
+ $q->bindParam(':statuses', $statuses);
+ $q->execute();
+ return $q;
+}
+
+function changeGroupStatusByID($db, $id, $status) {
+ $q = $db->query("
+ UPDATE
+ `group_page`
+ SET
+ `status` = $status
+ WHERE
+ `groupID` = $id
+ ");
+
+ return $q;
+}
+
+
+
+
+?>
diff --git a/website/queries/login.php b/website/queries/login.php
new file mode 100644
index 0000000..c710833
--- /dev/null
+++ b/website/queries/login.php
@@ -0,0 +1,19 @@
+prepare("
+ SELECT
+ `password`,
+ `userID`
+ FROM
+ `user`
+ WHERE
+ `username` LIKE :username
+ ");
+
+ $stmt->bindParam(":username", $_POST["uname"]);
+ $stmt->execute();
+ return $stmt->fetch(PDO::FETCH_ASSOC);
+}
+
+?>
diff --git a/website/queries/private_message.php b/website/queries/private_message.php
new file mode 100644
index 0000000..2d953c5
--- /dev/null
+++ b/website/queries/private_message.php
@@ -0,0 +1,85 @@
+prepare("
+ SELECT
+ *
+ FROM
+ `private_message`
+ WHERE
+ `origin` = :user1 AND
+ `destination` = :user2 OR
+ `origin` = :user2 AND
+ `destination` = :user1
+ ORDER BY
+ `messageID` ASC
+ ");
+
+ $stmt->bindParam(":user1", $user1ID);
+ $stmt->bindParam(":user2", $user2ID);
+
+ $stmt->execute();
+
+ return json_encode($stmt->fetchAll());
+}
+
+function sendMessage($destination, $content) {
+ $db = $GLOBALS["db"];
+ $stmt = $db->prepare("
+ INSERT INTO
+ `private_message`
+ (
+ `origin`,
+ `destination`,
+ `content`
+ )
+ VALUES
+ (
+ :origin,
+ :destination,
+ :content
+ )
+ ");
+
+ return $stmt->execute(array(
+ "origin" => $_SESSION["userID"],
+ "destination" => $destination,
+ "content" => $content
+ ));
+}
+
+function getNewChatMessages($lastID, $destination) {
+ $db = $GLOBALS["db"];
+ $origin = $_SESSION["userID"];
+
+ $stmt = $db->prepare("
+ SELECT
+ *
+ FROM
+ `private_message`
+ WHERE
+ (
+ `origin` = :user1 AND
+ `destination` = :user2 OR
+ `origin` = :user2 AND
+ `destination` = :user1) AND
+ `messageID` > :lastID
+ ORDER BY
+ `messageID` ASC
+ ");
+
+ $stmt->bindParam(':user1', $origin);
+ $stmt->bindParam(':user2', $destination);
+ $stmt->bindParam(':lastID', $lastID);
+
+ $stmt->execute();
+
+ return json_encode($stmt->fetchAll());
+}
\ No newline at end of file
diff --git a/website/queries/register.php b/website/queries/register.php
new file mode 100644
index 0000000..893bb3a
--- /dev/null
+++ b/website/queries/register.php
@@ -0,0 +1,68 @@
+prepare("
+ SELECT
+ `username`
+ FROM
+ `user`
+ WHERE
+ `username` LIKE :username
+ ");
+
+ $stmt->bindParam(":username", $_POST["username"]);
+ $stmt->execute();
+ return $stmt->rowCount();
+
+}
+
+function getExistingEmail() {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `email`
+ FROM
+ `user`
+ WHERE
+ `email` LIKE :email
+ ");
+
+ $stmt->bindParam(":email", $_POST["email"]);
+ $stmt->execute();
+ return $stmt->rowCount();
+
+}
+
+function registerAccount() {
+ $stmt = $GLOBALS["db"]->prepare("
+ INSERT INTO
+ `user`(fname,
+ lname,
+ birthdate,
+ username,
+ password,
+ location,
+ email)
+ VALUES(
+ :fname,
+ :lname,
+ :bday,
+ :username,
+ :password,
+ :location,
+ :email
+ )");
+
+ $hash=password_hash($_POST["password"].(strtolower($_POST["username"])), 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->execute();
+ $stmt->rowCount();
+}
+?>
diff --git a/website/queries/settings.php b/website/queries/settings.php
new file mode 100644
index 0000000..c59ff7f
--- /dev/null
+++ b/website/queries/settings.php
@@ -0,0 +1,109 @@
+prepare("
+ SELECT
+ `fname`,
+ `lname`,
+ `email`,
+ `location`,
+ `birthdate`,
+ `bio`,
+ `profilepicture`
+ FROM
+ `user`
+ WHERE
+ `userID` = :userID
+ ");
+
+ $stmt->bindParam(":userID", $_SESSION["userID"]);
+ $stmt->execute();
+ return $stmt->fetch();
+}
+
+function getPasswordHash() {
+ $stmt = $GLOBALS["db"]->prepare("
+ SELECT
+ `password`,
+ `username`
+ FROM
+ `user`
+ WHERE
+ `userID` = :userID
+ ");
+ $stmt->bindParam(":userID", $_SESSION["userID"]);
+ $stmt->execute();
+ return $stmt->fetch();
+}
+
+function updateSettings() {
+ $stmt = $GLOBALS["db"]->prepare("
+ UPDATE
+ `user`
+ SET
+ `fname` = :fname,
+ `lname` = :lname,
+ `location` = :location,
+ `birthdate` = :bday,
+ `bio` = :bio
+ WHERE
+ `userID` = :userID
+ ");
+
+ $stmt->bindParam(":fname", $_POST["fname"]);
+ $stmt->bindParam(":lname", $_POST["lname"]);
+ $stmt->bindParam(":location", $_POST["location"]);
+ $stmt->bindParam(":bday", $_POST["bday"]);
+ $stmt->bindParam(":bio", $_POST["bio"]);
+ $stmt->bindParam(":userID", $_SESSION["userID"]);
+
+ $stmt->execute();
+
+ return array (
+ "type" => "settings-message-happy",
+ "message" => "Instellingen zijn opgeslagen."
+ );
+}
+
+function updatePassword() {
+ $user = getPasswordHash();
+ if (password_verify($_POST["password-old"].strtolower($user["username"]), $user["password"])) {
+ if ($_POST["password-new"] == $_POST["password-confirm"] && (strlen($_POST["password-new"]) >= 8)) {
+ if (changePassword($user)) {
+ return array ("type" => "settings-message-happy",
+ "message" => "Wachtwoord gewijzigd.");
+ } else {
+ return array (
+ "type" => "settings-message-angry",
+ "message" => "Er is iets mis gegaan.");
+ }
+ } else {
+ return array (
+ "type" => "settings-message-angry",
+ "message" => "Wachtwoorden komen niet oveeen."
+ );
+ }
+ } else {
+ return array(
+ "type" => "settings-message-angry",
+ "message" => "Oud wachtwoord niet correct."
+ );
+ }
+}
+
+function changePassword($user) {
+ $stmt =$GLOBALS["db"]->prepare("
+ UPDATE
+ `user`
+ SET
+ `password` = :new_password
+ WHERE
+ `userID` = :userID
+ ");
+
+ $hashed_password = password_hash($_POST["password-new"].strtolower($user["username"]), PASSWORD_DEFAULT);
+ $stmt->bindParam(":new_password", $hashed_password);
+ $stmt->bindParam(":userID", $_SESSION["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 fee8fe8..659e0d6 100644
--- a/website/queries/user.php
+++ b/website/queries/user.php
@@ -84,4 +84,89 @@ function selectAllUserPosts($db, $userID) {
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt;
-}
\ No newline at end of file
+}
+
+function select20UsersFromN($db, $n) {
+ return $db->query("
+ SELECT
+ `userID`,
+ `username`,
+ `role`,
+ `bancomment`
+ FROM
+ `user`
+ ORDER BY
+ `role`,
+ `username`
+ LIMIT
+ $n, 20
+ ");
+}
+
+function search20UsersFromN($db, $n, $keyword) {
+ $q = $db->prepare("
+ SELECT
+ `userID`,
+ `username`,
+ `role`,
+ `bancomment`
+ FROM
+ `user`
+ WHERE
+ `username` LIKE :keyword
+ ORDER BY
+ `username`
+ LIMIT
+ :n, 20
+ ");
+
+ $keyword = "%$keyword%";
+ $q->bindParam(':keyword', $keyword);
+ $q->bindParam(':n', $n, PDO::PARAM_INT);
+ $q->execute();
+ return $q;
+}
+
+function search20UsersFromNByStatus($db, $n, $keyword, $status) {
+ $q = $db->prepare("
+ SELECT
+ `userID`,
+ `username`,
+ `role`,
+ `bancomment`
+ FROM
+ `user`
+ WHERE
+ `username` LIKE :keyword AND
+ FIND_IN_SET (`role`, :statuses)
+ ORDER BY
+ `role`,
+ `username`
+ LIMIT
+ :n, 20
+ ");
+
+ $keyword = "%$keyword%";
+ $q->bindParam(':keyword', $keyword);
+ $q->bindParam(':n', $n, PDO::PARAM_INT);
+ $statuses = implode(',', $status);
+ $q->bindParam(':statuses', $statuses);
+ $q->execute();
+ return $q;
+}
+
+function changeUserStatusByID($db, $id, $status) {
+ $q = $db->query("
+ UPDATE
+ `user`
+ SET
+ `role` = $status
+ WHERE
+ `userID` = $id
+ ");
+
+ return $q;
+}
+
+
+?>
diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php
index b789aad..5a3ba97 100644
--- a/website/views/adminpanel.php
+++ b/website/views/adminpanel.php
@@ -1,98 +1,266 @@
-
-
- Admin Panel
-
-
-
-
-
+
diff --git a/website/views/chat-view.php b/website/views/chat-view.php
index a23a1c5..a3acd4c 100644
--- a/website/views/chat-view.php
+++ b/website/views/chat-view.php
@@ -1,52 +1,83 @@
-