Merge branch 'master' into hendrik-testing

This commit is contained in:
Hendrik
2017-01-30 16:34:40 +01:00
42 changed files with 583 additions and 376 deletions

View File

@@ -1,7 +1,7 @@
Options +FollowSymLinks Options +FollowSymLinks
RewriteEngine On RewriteEngine On
ErrorDocument 404 /error404.jpg ErrorDocument 404 /error/404.php
RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-f

View File

@@ -1,13 +1,17 @@
<?php <?php
if(empty($_POST["usr"])) { if(empty($_POST["usr"]) and empty($_POST["grp"])) {
header('HTTP/1.1 500 Non enough arguments'); header('HTTP/1.1 500 Non enough arguments');
} }
require_once ("../../queries/user.php"); require_once ("../../queries/post.php");
require_once ("../../queries/nicetime.php"); require_once ("../../queries/nicetime.php");
$posts = selectAllUserPosts($_POST["usr"]); if(empty($_POST["usr"])) {
$posts = selectAllPosts(0, $_POST["grp"]);
} else {
$posts = selectAllPosts($_POST["usr"], 0);
}
if(!$posts) { if(!$posts) {
header('HTTP/1.1 500 Query failed'); header('HTTP/1.1 500 Query failed');
@@ -19,6 +23,4 @@ for($i = 0; $i < sizeof($results); $i++) {
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]); $results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
} }
//$results[0]["niceTime"] = nicetime($results[0]["creationdate"]);
echo json_encode($results); echo json_encode($results);

View File

@@ -5,7 +5,7 @@ require_once ("../queries/connect.php");
require_once ("../queries/checkInput.php"); require_once ("../queries/checkInput.php");
function getNietSlechtCountForPost(int $postID) : int { function getNietSlechtCountForPost(int $postID) : int {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID` `userID`
FROM FROM
@@ -19,7 +19,7 @@ function getNietSlechtCountForPost(int $postID) : int {
} }
function getNietSlechtUsersForPost(int $postID) { function getNietSlechtUsersForPost(int $postID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`fname`, `fname`,
`lname`, `lname`,

View File

@@ -3,7 +3,7 @@
session_start(); session_start();
require("../../queries/post.php"); require("../../queries/post.php");
require("../../queries/connect.php"); require_once("../../queries/connect.php");
require("../../queries/checkInput.php"); require("../../queries/checkInput.php");
print_r($_POST); print_r($_POST);
if ($_POST['button'] == 'reaction') { if ($_POST['button'] == 'reaction') {

View File

@@ -2,7 +2,7 @@
include_once("../queries/connect.php"); include_once("../queries/connect.php");
include_once("../views/messagepage.php"); include_once("../views/messagepage.php");
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) { if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
$checkHash = $GLOBALS["db"]->prepare(" $checkHash = prepareQuery("
SELECT SELECT
`email`, `email`,
`role` `role`
@@ -28,7 +28,7 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
function doActivate(string $email) { function doActivate(string $email) {
if (password_verify($email, $_GET["h"])) { if (password_verify($email, $_GET["h"])) {
$confirmUser = $GLOBALS["db"]->prepare(" $confirmUser = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET

View File

@@ -0,0 +1,9 @@
<?php
require_once "../../views/messagepage.php";
messagePage("
<div class='error-page'>
<h1>404</h1>
<h4>Verkeerde link...</h4><br />
<img height='25%' width='25%' src='../img/zelda.png'>
</div>");

View File

@@ -4,6 +4,8 @@
<?php include("../views/head.php"); ?> <?php include("../views/head.php"); ?>
<style> <style>
@import url("styles/profile.css"); @import url("styles/profile.css");
@import url("styles/post-popup.css");
@import url('https://fonts.googleapis.com/css?family=Anton');
</style> </style>
</head> </head>
<body> <body>
@@ -30,6 +32,20 @@ include("../views/group.php");
/* This adds the footer. */ /* This adds the footer. */
include("../views/footer.php"); include("../views/footer.php");
$masonry_mode = 0;
?> ?>
<script src="js/masonry.js"></script>
<script src="js/post.js"></script>
<script>
$(document).ready(function() {
userID = 0;
groupID = <?= $group["groupID"] ?>;
masonry(<?= $masonry_mode ?>);
});
</script>
</body> </body>
</html> </html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -1,12 +1,17 @@
var previousDate = new Date("1970-01-01 00:00:00"); var previousDate = new Date("1970-01-01 00:00:00");
var previousTime = "00:00";
var gettingMessages = false;
var previousType = "robot";
$(document).ready(function() { $(document).ready(function() {
loadMessages(); setInterval(loadMessages, 1000);
sayEmpty(); sayEmpty();
$(".chat-field").hide(); $(".chat-field").hide();
}); });
function loadMessages() { function loadMessages() {
if (!gettingMessages) {
gettingMessages = true;
$.post( $.post(
"API/loadMessages.php", "API/loadMessages.php",
$("#lastIDForm").serialize() $("#lastIDForm").serialize()
@@ -15,11 +20,12 @@ function loadMessages() {
messages = JSON.parse(data); messages = JSON.parse(data);
addMessages(messages); addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID); $("#lastID").val(messages[messages.length - 1].messageID);
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight);
} }
gettingMessages = false;
}); });
} else {
setTimeout(loadMessages, 1000); setTimeout(loadMessages, 500);
}
} }
@@ -30,35 +36,55 @@ function sendMessage() {
); );
$("#newContent").val(""); $("#newContent").val("");
loadMessages();
} }
function addMessages(messages) { function addMessages(messages) {
var messagesText = "";
for(var i in messages) { for(var i in messages) {
thisDate = new Date(messages[i].creationdate); // Initialize message variables
var thisDate = new Date(messages[i].creationdate);
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
var type;
thisDate.setHours(0,0,0,0); thisDate.setHours(0,0,0,0);
if (messages[i].destination == $(".destinationID").val()) { if (messages[i].destination == $(".destinationID").val()) {
type = "chat-message-self"; type = "chat-message-self";
} else { } else {
type = "chat-message-other"; type = "chat-message-other";
} }
if (thisDate > previousDate) { if (i == 0) {
messagesText += '<div class="chat-message"><div class="' + type + '">';
} else if (type != previousType || thisTime != previousTime || thisDate > previousDate) {
messagesText += '<div class="chat-time">\
' + thisTime + '\
</div></div></div>';
previousDate = thisDate; previousDate = thisDate;
$("#chat-history").append('\ previousTime = thisTime;
previousType = type;
if (thisDate > previousDate) {
messagesText += '\
<div class="day-message"> \ <div class="day-message"> \
<div class="day-message-content">\ <div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \ </div> \
</div>\ </div>';
');
} }
$("#chat-history").append('\
<div class="chat-message"> \ messagesText += '<div class="chat-message"><div class="' + type + '">';
<div class="' + type + '">\
' + fancyText(messages[i].content) + '\
</div> \
</div>\
');
} }
messagesText += fancyText(messages[i].content) + "<br />";
}
// Close the last message
messagesText += '<div class="chat-time">\
' + thisTime + '\
</div></div></div>';
$("#chat-history").append(messagesText);
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight);
} }
function switchUser(userID) { function switchUser(userID) {
@@ -72,5 +98,5 @@ function switchUser(userID) {
} }
function sayEmpty() { function sayEmpty() {
$("#chat-history").html("Begin nu met chatten!"); $("#chat-history").html("Probeer ook eens foto's en video's te sturen");
} }

View File

@@ -1,26 +1,73 @@
function placeFriendButtons() { function placeFriendButtons() {
$.post("API/getFriendshipStatus.php", { usr: userID }) $.post("API/getFriendshipStatus.php", { usr: userID })
.done(function(data) { .done(function(data) {
friendshipStatus = data; var friendshipStatus = data;
$buttonContainer = $("div.friend-button-container"); var $buttonContainer = $("div.friend-button-container");
$buttonContainer.children().remove(); $("#start-profile-chat").hide();
$("#start-profile-chat-form").hide(); $buttonContainer.html("");
if (friendshipStatus == -1) { var value1 = "";
return; var class1 = "empty-button";
} else if(friendshipStatus == 0) { var icon1 = "";
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>")); var text1 = "";
} else if(friendshipStatus == 1) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>")); var value2 = "";
$("#start-profile-chat-form").show(); var class2 = "empty-button";
} else if(friendshipStatus == 2) { var icon2 = "";
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>")); var text2 = "";
} else if(friendshipStatus == 3) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Weiger</button>")); switch (friendshipStatus) {
$buttonContainer.append($("<button class=\"green friend-button\" value=\"accept\"><i class=\"fa fa-check\"></i> Accepteer</button>")); case "0":
value1 = "request";
class1 = "green";
text1 = "Bevriend";
icon1 = "fa-handshake-o";
break;
case "1":
value1 = userID;
class1 = "green";
text1 = "Chat";
icon1 = "fa-comment-o";
value2 = "delete";
class2 = "red";
text2 = "Verwijder";
icon2 = "fa-times";
break;
case "2":
value1 = "delete";
class1 = "red";
text1 = "Trek verzoek in";
icon1 = "fa-cross";
break;
case "3":
value1 = "accept";
class1 = "green";
text1 = "Accepteer";
icon1 = "fa-check";
value2 = "delete";
class2 = "red";
text2 = "Weiger";
icon2 = "fa-times";
break;
default:
console.log(friendshipStatus);
break;
} }
$buttonContainer.append(
"<button class='"+ class1 +" friend-button' value='"+ value1 +"'>" +
"<i class='fa "+ icon1 +"'></i> " + text1 +
"</button>");
$buttonContainer.append(
"<button class='"+ class2 +" friend-button' value='"+ value2 +"'>" +
"<i class='fa "+ icon2 +"'></i> " + text2 +
"</button>");
$buttonContainer.children().click(function() { $buttonContainer.children().click(function() {
if (isNaN(this.value))
editFriendship(userID, this.value); editFriendship(userID, this.value);
else if (this.value != "")
window.location.href = "chat.php?username=" + this.value;
}); });
}); });
} }

View File

@@ -2,19 +2,39 @@ var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag",
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"] var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]
function fancyText(text) { function fancyText(text) {
// Add links, images, gifs and (youtube) video's.
// Add images and gifs. var regex = /(https?:\/\/.[^ ]*)/ig;
var regex = /(https:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig; text = text.replace(regex, function(link) {
text = text.replace(regex, function(img) { // Add images
return "<img src='" + img + "' />"; if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
return "<img alt='" + link + "' src='" + link + "' />";
}
// Add mp4 video's
else if (link.match(/(https?:\/\/.[^ ]*\.(?:mp4))/ig)) {
return "<video width='100%'>" +
"<source src='"+ link +"' type='video/mp4'>" +
"<b>Je browser ondersteund geen video</b>" +
"</video><button class='gray' onclick='$(this).prev().get(0).play();'>Speel af</button>";
}
// Add ogg video's
else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) {
return "<video width='100%'>" +
"<source src='"+ link +"' type='video/ogg'>" +
"<b>Je browser ondersteund geen video</b>" +
"</video><button onclick='$(this).prev().get(0).play();'>Speel af</button>";
}
// Add youtube video's
else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) {
return '<iframe width="100%"' +
' src="https://www.youtube.com/embed/' + link.substr(link.length - 11) +
'" frameborder="0" allowfullscreen></iframe>';
}
// Add links
else {
return "<a href='" + link + "'>" + link + "</a>";
}
}); });
// Add links.
// regex = /(https:\/\/.[^ ]*\.(?:net|com|nl))/ig;
// text = text.replace(regex, function(link) {
// return "<a href='" + link + "'>LINK</a>";
// });
return text; return text;
} }

View File

@@ -90,7 +90,7 @@ function masonry(mode) {
/* /*
* Get the posts from the server. * Get the posts from the server.
*/ */
$.post("API/getPosts.php", { usr : userID }) $.post("API/getPosts.php", { usr : userID, grp : groupID })
.done(function(data) { .done(function(data) {
posts = JSON.parse(data); posts = JSON.parse(data);

View File

@@ -4,7 +4,9 @@ function postComment(buttonValue) {
$.post( $.post(
"API/postComment.php", "API/postComment.php",
formData formData
); ).done(function(data) {
console.log(data);
});
$("#newcomment").val(""); $("#newcomment").val("");

View File

@@ -27,7 +27,6 @@ if(empty($_GET["username"])) {
$user = selectUser($_SESSION["userID"], $userID); $user = selectUser($_SESSION["userID"], $userID);
$profile_friends = selectAllFriends($userID); $profile_friends = selectAllFriends($userID);
$profile_groups = selectAllUserGroups($userID); $profile_groups = selectAllUserGroups($userID);
$posts = selectAllUserPosts($userID);
if ($userID == $_SESSION["userID"]) { if ($userID == $_SESSION["userID"]) {
@@ -54,23 +53,12 @@ include("../views/footer.php");
<script src="js/friendButtons.js"></script> <script src="js/friendButtons.js"></script>
<script src="js/masonry.js"></script> <script src="js/masonry.js"></script>
<script> <script>
var posts;
$(document).ready(function() { $(document).ready(function() {
userID = <?= $userID ?>; userID = <?= $userID ?>;
groupID = 0;
placeFriendButtons(); placeFriendButtons();
masonry(<?= $masonry_mode ?>); masonry(<?= $masonry_mode ?>);
// alert("blap");
// $.post("API/getPosts.php", { usr : userID }, "json")
// .done(function(data) {
// posts = JSON.parse(data);
// alert(posts[0]["content"]);
// }).fail(function() {
// alert("failure...");
// });
}); });
</script> </script>
</body> </body>

View File

@@ -28,7 +28,7 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") {
} }
function changePassword() { function changePassword() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET
@@ -42,7 +42,7 @@ function changePassword() {
} }
function verifyLink(int $userID, string $hash) { function verifyLink(int $userID, string $hash) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`password` `password`
FROM FROM

View File

@@ -0,0 +1,3 @@
#quick-links i {
font-size: 32px;
}

View File

@@ -131,3 +131,17 @@ body {
.chat-message img { .chat-message img {
max-width: 100%; max-width: 100%;
} }
.chat-message a {
text-decoration: underline;
}
.chat-time {
color: #666666;
font-size: 12px;
margin-bottom: -3px;
}
.chat-message-other .chat-time {
text-align: right;
}

View File

@@ -97,16 +97,16 @@ p {
} }
.item-box, .item-box-full-width { .item-box, .item-box-full-width {
margin: 20px 0 0 0;
padding: 25px; padding: 25px;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.item-box { .item-box {
width: calc(50% - 60px); width: calc(33% - 50px);
display: inline-table;
} }
@media only screen and (max-width: 900px) { @media only screen and (max-width: 1400px) {
.item-box { .item-box {
width: calc(100% - 50px); width: calc(100% - 50px);
} }
@@ -183,6 +183,10 @@ button.green {
background-color: forestgreen; background-color: forestgreen;
} }
button.gray{
background-color: #FFF;
color: #333;
}
button, button,
input[type="submit"], input[type="submit"],
@@ -224,6 +228,7 @@ td {
/* Custom title box, appears instantaneously */ /* Custom title box, appears instantaneously */
a[data-title]:hover, a[data-title]:hover,
i[data-title]:hover,
img[data-title]:hover, img[data-title]:hover,
span[data-title]:hover, span[data-title]:hover,
div[data-title]:hover { div[data-title]:hover {
@@ -231,6 +236,7 @@ div[data-title]:hover {
} }
a[data-title]:hover:after, a[data-title]:hover:after,
i[data-title]:hover:after,
img[data-title]:hover:after, img[data-title]:hover:after,
span[data-title]:hover:after, span[data-title]:hover:after,
div[data-title]:hover:after { div[data-title]:hover:after {

View File

@@ -1,6 +1,9 @@
body {
background-color: #FBC02D;
}
.password-change { .password-change {
height: 100%; height: 100%;
background-color: #FBC02D;
margin: auto; margin: auto;
} }
@@ -12,6 +15,14 @@
margin: 30px auto auto; margin: 30px auto auto;
display: block; display: block;
} }
.password-change img { .top-logo img {
width: 50%; width: 50%;
} }
.error-page {
text-align: center;
}
.error-page img {
vertical-align: middle;
}

View File

@@ -71,7 +71,16 @@
width: 95%; width: 95%;
} }
.nietslecht { .nietslecht-text {
font-family: Impact, Anton, 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; text-shadow: -1px 0 1px black, 0 1px 1px black, 1px 0 1px black, 0 -1px 1px black;
}
.nietslecht {
}
.nietslecht img {
vertical-align: middle;
height: 24px;
width: 24px;
} }

View File

@@ -1,15 +1,60 @@
.profile-box { /* New */
min-height: 150px;
padding: 25px; .user-box {
background-color: #FFFFFF; text-align: center;
} }
.profile-box .profile-picture, .profile-box .group-picture { .status-buttons-container {
position: relative;
float: left;
width: 200px;
display: inline-block;
}
.friend-button-container {
position: relative;
float: right;
width: 200px;
display: inline-block;
}
.friend-button-container button, .status-buttons-container button {
display: block;
margin: 7px 0;
width: 200px;
font-size: 18px;
}
.empty-button {
background: none;
cursor: auto;
}
.empty-button:active {
box-shadow: none;
}
.profile-info {
display: inline-block;
min-width: 250px;
width: auto;
padding-top: 30px;
}
.main-picture {
position: relative;
border: #4CAF50 solid 5px;
display: inline-block;
width: 150px; width: 150px;
height: 150px; height: 150px;
margin: 0 20px 20px 0; margin-bottom: -45px;
} }
/* Old */
.profile-box h1.profile-username { .profile-box h1.profile-username {
padding-top: 50px; padding-top: 50px;
} }
@@ -18,14 +63,12 @@
} }
div.posts { div.posts {
padding-top: 20px;
width: calc(100% + 20px); width: calc(100% + 20px);
display: inline-flex; display: inline-flex;
} }
div.posts div.post { div.posts div.post {
display: block; display: block;
margin: 20px 0 0 0;
padding: 10px; padding: 10px;
width: calc(100% - 40px); width: calc(100% - 40px);
cursor: pointer; cursor: pointer;
@@ -60,6 +103,12 @@ div.posts .post form textarea.newpost {
height: 100px; height: 100px;
} }
.post .post-date {
float: right;
color: #aaaaaa;
font-size: 0.8em;
}
@media only screen and (max-width: 1500px) { @media only screen and (max-width: 1500px) {
.post-box { .post-box {
width: calc(50% - 68px); width: calc(50% - 68px);
@@ -72,23 +121,3 @@ div.posts .post form textarea.newpost {
width: calc(100% - 65px); width: calc(100% - 65px);
} }
} }
.post .post-date {
float: right;
color: #aaaaaa;
font-size: 0.8em;
}
button.friend-button {
float: right;
height: auto;
padding: 10px;
margin-left: 10px;
border-radius: 5px;
transition-duration: 250ms;
cursor: pointer;
}
button.friend-button:hover {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}

View File

@@ -9,3 +9,7 @@ else {
"$dbconf->mysql_username", "$dbconf->mysql_password") "$dbconf->mysql_username", "$dbconf->mysql_password")
or die('Error connecting to mysql server'); or die('Error connecting to mysql server');
} }
function prepareQuery(string $query) : PDOStatement {
return $GLOBALS["db"]->prepare($query);
}

View File

@@ -1,7 +1,7 @@
<?php <?php
function sendConfirmEmailUsername(string $username) { function sendConfirmEmailUsername(string $username) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID` `userID`
FROM FROM
@@ -16,7 +16,7 @@ function sendConfirmEmailUsername(string $username) {
} }
function sendConfirmEmail(int $userID) { function sendConfirmEmail(int $userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`email`, `email`,
`fname` `fname`

View File

@@ -7,7 +7,7 @@ function selectFriends($userID) {
} }
function selectLimitedFriends($userID, $limit) { function selectLimitedFriends($userID, $limit) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -29,6 +29,12 @@ function selectLimitedFriends($userID, $limit) {
`friendship`.`user1ID` = `user`.`userID`) AND `friendship`.`user1ID` = `user`.`userID`) AND
`user`.`role` != 'banned' AND `user`.`role` != 'banned' AND
`friendship`.`status` = 'confirmed' `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 LIMIT :limitCount
"); ");
@@ -41,7 +47,7 @@ function selectLimitedFriends($userID, $limit) {
function selectAllFriends($userID) { function selectAllFriends($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -73,7 +79,7 @@ function selectAllFriends($userID) {
} }
function selectAllFriendRequests() { function selectAllFriendRequests() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -115,7 +121,7 @@ function getFriendshipStatus($userID) {
return -1; return -1;
} }
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
CASE `status` IS NULL CASE `status` IS NULL
WHEN TRUE THEN 0 WHEN TRUE THEN 0
@@ -148,7 +154,7 @@ function getFriendshipStatus($userID) {
} }
function requestFriendship($userID) { function requestFriendship($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
INSERT INTO `friendship` (user1ID, user2ID) INSERT INTO `friendship` (user1ID, user2ID)
VALUES (:user1, :user2) VALUES (:user1, :user2)
"); ");
@@ -159,7 +165,7 @@ function requestFriendship($userID) {
} }
function removeFriendship($userID) { function removeFriendship($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
DELETE FROM `friendship` DELETE FROM `friendship`
WHERE WHERE
`user1ID` = :user1 AND `user1ID` = :user1 AND
@@ -175,7 +181,7 @@ function removeFriendship($userID) {
} }
function acceptFriendship($userID) { function acceptFriendship($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE `friendship` UPDATE `friendship`
SET `status`='confirmed' SET `status`='confirmed'
WHERE WHERE
@@ -190,7 +196,7 @@ function acceptFriendship($userID) {
} }
function setLastVisited($friend) { function setLastVisited($friend) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`friendship` `friendship`
SET `friendship`.chatLastVisted1=( SET `friendship`.chatLastVisted1=(
@@ -220,7 +226,7 @@ function setLastVisited($friend) {
} }
function searchSomeFriends($n, $m, $search) { function searchSomeFriends($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,

View File

@@ -5,7 +5,7 @@ function selectAllGroupsFromUser($userID) {
} }
function selectLimitedGroupsFromUser($userID, $limit) { function selectLimitedGroupsFromUser($userID, $limit) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`group_page`.`name`, `group_page`.`name`,
`group_page`.`picture` `group_page`.`picture`
@@ -28,7 +28,7 @@ function selectLimitedGroupsFromUser($userID, $limit) {
} }
function searchSomeOwnGroups($n, $m, $search) { function searchSomeOwnGroups($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`group_page`.`name`, `group_page`.`name`,
`group_page`.`picture` `group_page`.`picture`

View File

@@ -1,10 +1,11 @@
<?php <?php
require("connect.php"); require_once("connect.php");
function selectGroupByName($name) { function selectGroupByName($name) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`group_page`.`groupID`,
`group_page`.`groupID`, `group_page`.`groupID`,
`name`, `name`,
`description`, `description`,
@@ -29,7 +30,7 @@ function selectGroupByName($name) {
} }
function selectGroupMembers(int $groupID) { function selectGroupMembers(int $groupID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`username`, `username`,
`fname`, `fname`,
@@ -54,7 +55,7 @@ function selectGroupMembers(int $groupID) {
} }
function selectGroupById($groupID) { function selectGroupById($groupID) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`group_page`.`name`, `group_page`.`name`,
`group_page`.`picture`, `group_page`.`picture`,
@@ -73,7 +74,7 @@ function selectGroupById($groupID) {
} }
function select20GroupsFromN($n) { function select20GroupsFromN($n) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`group_page`.`groupID`, `group_page`.`groupID`,
`group_page`.`name`, `group_page`.`name`,
@@ -95,7 +96,7 @@ function select20GroupsFromN($n) {
} }
function select20GroupsByStatusFromN($n, $status) { function select20GroupsByStatusFromN($n, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`group_page`.`groupID`, `group_page`.`groupID`,
`group_page`.`name`, `group_page`.`name`,
@@ -120,7 +121,7 @@ function select20GroupsByStatusFromN($n, $status) {
} }
function search20GroupsFromNByStatus($n, $keyword, $status) { function search20GroupsFromNByStatus($n, $keyword, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`groupID`, `groupID`,
`name`, `name`,
@@ -147,7 +148,7 @@ function search20GroupsFromNByStatus($n, $keyword, $status) {
} }
function searchSomeGroupsByStatus($n, $m, $keyword, $status) { function searchSomeGroupsByStatus($n, $m, $keyword, $status) {
$q = $GLOBALS['db']->prepare(" $q = prepareQuery("
SELECT SELECT
`groupID`, `groupID`,
`name`, `name`,
@@ -175,7 +176,7 @@ function searchSomeGroupsByStatus($n, $m, $keyword, $status) {
} }
function countSomeGroupsByStatus($keyword, $status) { function countSomeGroupsByStatus($keyword, $status) {
$q = $GLOBALS['db']->prepare(" $q = prepareQuery("
SELECT SELECT
COUNT(*) COUNT(*)
FROM FROM
@@ -196,7 +197,7 @@ function countSomeGroupsByStatus($keyword, $status) {
} }
function changeGroupStatusByID($id, $status) { function changeGroupStatusByID($id, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
UPDATE UPDATE
`group_page` `group_page`
SET SET
@@ -212,7 +213,7 @@ function changeGroupStatusByID($id, $status) {
} }
function changeMultipleGroupStatusByID($ids, $status) { function changeMultipleGroupStatusByID($ids, $status) {
$q = $GLOBALS['db']->prepare(" $q = prepareQuery("
UPDATE UPDATE
`group_page` `group_page`
SET SET
@@ -229,7 +230,7 @@ function changeMultipleGroupStatusByID($ids, $status) {
} }
function searchSomeGroups($n, $m, $search) { function searchSomeGroups($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`name`, `name`,
`picture` `picture`
@@ -252,7 +253,7 @@ function searchSomeGroups($n, $m, $search) {
} }
function countSomeGroups($search) { function countSomeGroups($search) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
COUNT(*) COUNT(*)
FROM FROM
@@ -268,4 +269,3 @@ function countSomeGroups($search) {
$stmt->execute(); $stmt->execute();
return $stmt; return $stmt;
} }
?>

View File

@@ -1,6 +1,6 @@
<?php <?php
function getHeaderInfo() { function getHeaderInfo() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`fname`, `fname`,
`lname`, `lname`,

View File

@@ -1,7 +1,7 @@
<?php <?php
function getUser() { function getUser() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`password`, `password`,
`userID`, `userID`,
@@ -61,5 +61,4 @@ class loginException extends Exception
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }
?>

View File

@@ -1,7 +1,53 @@
<?php <?php
require_once("connect.php");
function selectAllPosts($userID, $groupID) {
$stmt = prepareQuery("
SELECT
`post`.`postID`,
`post`.`author`,
`title`,
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
WHEN TRUE THEN
CONCAT(LEFT(`post`.`content`, 150), '...')
WHEN FALSE THEN
`post`.`content`
END
AS `content`,
`post`.`creationdate`,
COUNT(DISTINCT `commentID`) AS `comments`,
COUNT(DISTINCT `niet_slecht`.`postID`) AS `niet_slechts`
FROM
`post`
LEFT JOIN
`niet_slecht`
ON
`post`.`postID` = `niet_slecht`.`postID`
LEFT JOIN
`comment`
ON
`post`.`postID` = `comment`.`postID`
WHERE
`post`.`author` = :userID AND
`groupID` IS NULL OR
`groupID` = :groupID
GROUP BY
`post`.`postID`
ORDER BY
`post`.`creationdate` DESC
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->bindParam(':groupID', $groupID , PDO::PARAM_INT);
if(!$stmt->execute()) {
return False;
}
return $stmt;
}
function selectPostById($postID) { function selectPostById($postID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`user`.`fname`, `user`.`fname`,
`user`.`lname`, `user`.`lname`,
@@ -26,7 +72,7 @@ function selectPostById($postID) {
} }
function selectCommentsByPostId($postID) { function selectCommentsByPostId($postID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`comment`.`commentID`, `comment`.`commentID`,
`comment`.`postID`, `comment`.`postID`,
@@ -52,7 +98,7 @@ function selectCommentsByPostId($postID) {
} }
function makePost($userID, $groupID, $title, $content) { function makePost($userID, $groupID, $title, $content) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
INSERT INTO INSERT INTO
`post` ( `post` (
`author`, `author`,
@@ -76,7 +122,7 @@ function makePost($userID, $groupID, $title, $content) {
} }
function makeComment($postID, $userID, $content) : int { function makeComment($postID, $userID, $content) : int {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
INSERT INTO INSERT INTO
`comment` ( `comment` (
`postID`, `postID`,
@@ -106,7 +152,7 @@ function makeNietSlecht(int $postID, int $userID) : int {
} }
function checkNietSlecht(int $postID, int $userID) { function checkNietSlecht(int $postID, int $userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
* *
FROM FROM
@@ -122,7 +168,7 @@ function checkNietSlecht(int $postID, int $userID) {
} }
function addNietSlecht(int $postID, int $userID) { function addNietSlecht(int $postID, int $userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
INSERT INTO INSERT INTO
`niet_slecht` (`userID`, `postID`) `niet_slecht` (`userID`, `postID`)
VALUES (:userID, :postID) VALUES (:userID, :postID)
@@ -134,7 +180,7 @@ function addNietSlecht(int $postID, int $userID) {
} }
function deleteNietSlecht(int $postID, int $userID) { function deleteNietSlecht(int $postID, int $userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
DELETE FROM DELETE FROM
`niet_slecht` `niet_slecht`
WHERE WHERE

View File

@@ -4,7 +4,7 @@ function getOldChatMessages($user2ID) {
require_once ("friendship.php"); require_once ("friendship.php");
$user1ID = $_SESSION["userID"]; $user1ID = $_SESSION["userID"];
if (getFriendshipStatus($user2ID) == 1) { if (getFriendshipStatus($user2ID) == 1) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
* *
FROM FROM
@@ -15,7 +15,7 @@ function getOldChatMessages($user2ID) {
`origin` = :user2 AND `origin` = :user2 AND
`destination` = :user1 `destination` = :user1
ORDER BY ORDER BY
`messageID` ASC `creationdate` ASC
"); ");
$stmt->bindParam(":user1", $user1ID); $stmt->bindParam(":user1", $user1ID);
@@ -32,7 +32,7 @@ function getOldChatMessages($user2ID) {
function sendMessage($destination, $content) { function sendMessage($destination, $content) {
require_once("friendship.php"); require_once("friendship.php");
if (getFriendshipStatus($destination) == 1) { if (getFriendshipStatus($destination) == 1) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
INSERT INTO INSERT INTO
`private_message` `private_message`
( (
@@ -61,7 +61,7 @@ function sendMessage($destination, $content) {
function getNewChatMessages($lastID, $destination) { function getNewChatMessages($lastID, $destination) {
require_once("friendship.php"); require_once("friendship.php");
if (getFriendshipStatus($destination) == 1) { if (getFriendshipStatus($destination) == 1) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
* *
FROM FROM
@@ -74,7 +74,7 @@ function getNewChatMessages($lastID, $destination) {
`destination` = :user1) AND `destination` = :user1) AND
`messageID` > :lastID `messageID` > :lastID
ORDER BY ORDER BY
`messageID` ASC `creationdate` ASC
"); ");
$stmt->bindParam(':user1', $_SESSION["userID"]); $stmt->bindParam(':user1', $_SESSION["userID"]);
@@ -91,7 +91,7 @@ function getNewChatMessages($lastID, $destination) {
function selectAllUnreadChat() { function selectAllUnreadChat() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`,
`user`.`userID`, `user`.`userID`,

View File

@@ -1,7 +1,7 @@
<?php <?php
function getExistingUsername() { function getExistingUsername() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`username` `username`
FROM FROM
@@ -17,7 +17,7 @@ function getExistingUsername() {
} }
function getExistingEmail() { function getExistingEmail() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`email` `email`
FROM FROM
@@ -33,7 +33,7 @@ function getExistingEmail() {
} }
function getResetEmail() { function getResetEmail() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`email` `email`
FROM FROM
@@ -49,7 +49,7 @@ function getResetEmail() {
} }
function registerAccount() { function registerAccount() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
INSERT INTO INSERT INTO
`user`(fname, `user`(fname,
lname, lname,

View File

@@ -3,7 +3,7 @@ include_once "../queries/connect.php";
function sendPasswordRecovery(string $email) { function sendPasswordRecovery(string $email) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username` `username`
@@ -39,7 +39,7 @@ function doSendPasswordRecovery(int $userID, string $email, string $username, st
} }
function setHashToDatabase(int $userID, string $hash) { function setHashToDatabase(int $userID, string $hash) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET

View File

@@ -50,7 +50,7 @@ class AngryAlert extends AlertMessage {
* @return mixed Setting as an array. * @return mixed Setting as an array.
*/ */
function getSettings() { function getSettings() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`fname`, `fname`,
`lname`, `lname`,
@@ -77,7 +77,7 @@ function getSettings() {
* @return mixed passwordhash * @return mixed passwordhash
*/ */
function getPasswordHash() { function getPasswordHash() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`password`, `password`,
`username` `username`
@@ -96,7 +96,7 @@ function getPasswordHash() {
* @throws HappyAlert * @throws HappyAlert
*/ */
function updateSettings() { function updateSettings() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET
@@ -146,7 +146,7 @@ function changePassword() {
* @throws HappyAlert * @throws HappyAlert
*/ */
function doChangePassword() { function doChangePassword() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET
@@ -184,7 +184,7 @@ function changeEmail() {
} }
function emailIsAvailableInDatabase($email) { function emailIsAvailableInDatabase($email) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`email` `email`
FROM FROM
@@ -201,7 +201,7 @@ function emailIsAvailableInDatabase($email) {
} }
function doChangeEmail($email) { function doChangeEmail($email) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET
@@ -245,7 +245,7 @@ function updateAvatar() {
} }
function removeOldAvatar() { function removeOldAvatar() {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`profilepicture` `profilepicture`
FROM FROM
@@ -262,7 +262,7 @@ function removeOldAvatar() {
} }
function setAvatarToDatabase(string $url) { function setAvatarToDatabase(string $url) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET

View File

@@ -1,9 +1,9 @@
<?php <?php
require("connect.php"); require_once ("connect.php");
function getUserID($username) { function getUserID($username) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID` `userID`
FROM FROM
@@ -18,7 +18,7 @@ function getUserID($username) {
} }
function getUsername($userID) { function getUsername($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`username` `username`
FROM FROM
@@ -33,7 +33,7 @@ function getUsername($userID) {
} }
function selectUser($me, $other) { function selectUser($me, $other) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -46,6 +46,7 @@ function selectUser($me, $other) {
`bio`, `bio`,
`user`.`creationdate`, `user`.`creationdate`,
`onlinestatus`, `onlinestatus`,
`role`,
`fname`, `fname`,
`lname`, `lname`,
CASE `status` IS NULL CASE `status` IS NULL
@@ -81,7 +82,7 @@ function selectUser($me, $other) {
} }
function selectAllUserGroups($userID) { function selectAllUserGroups($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`group_page`.`groupID`, `group_page`.`groupID`,
`name`, `name`,
@@ -103,50 +104,50 @@ function selectAllUserGroups($userID) {
return $stmt; return $stmt;
} }
function selectAllUserPosts($userID) { //function selectAllUserPosts($userID) {
$stmt = $GLOBALS["db"]->prepare(" // $stmt = prepareQuery("
SELECT // SELECT
`post`.`postID`, // `post`.`postID`,
`post`.`author`, // `post`.`author`,
`title`, // `title`,
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%' // CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
WHEN TRUE THEN // WHEN TRUE THEN
CONCAT(LEFT(`post`.`content`, 150), '...') // CONCAT(LEFT(`post`.`content`, 150), '...')
WHEN FALSE THEN // WHEN FALSE THEN
`post`.`content` // `post`.`content`
END // END
AS `content`, // AS `content`,
`post`.`creationdate`, // `post`.`creationdate`,
COUNT(`commentID`) AS `comments`, // COUNT(`commentID`) AS `comments`,
COUNT(`niet_slecht`.`postID`) AS `niet_slechts` // COUNT(`niet_slecht`.`postID`) AS `niet_slechts`
FROM // FROM
`post` // `post`
LEFT JOIN // LEFT JOIN
`niet_slecht` // `niet_slecht`
ON // ON
`post`.`postID` = `niet_slecht`.`postID` // `post`.`postID` = `niet_slecht`.`postID`
LEFT JOIN // LEFT JOIN
`comment` // `comment`
ON // ON
`post`.`postID` = `comment`.`postID` // `post`.`postID` = `comment`.`postID`
WHERE // WHERE
`post`.`author` = :userID AND // `post`.`author` = :userID AND
`groupID` IS NULL // `groupID` IS NULL
GROUP BY // GROUP BY
`post`.`postID` // `post`.`postID`
ORDER BY // ORDER BY
`post`.`creationdate` DESC // `post`.`creationdate` DESC
"); // ");
//
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT); // $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
if(!$stmt->execute()) { // if(!$stmt->execute()) {
return False; // return False;
} // }
return $stmt; // return $stmt;
} //}
function select20UsersFromN($n) { function select20UsersFromN($n) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -167,7 +168,7 @@ function select20UsersFromN($n) {
} }
function search20UsersFromN($n, $keyword) { function search20UsersFromN($n, $keyword) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -191,7 +192,7 @@ function search20UsersFromN($n, $keyword) {
} }
function search20UsersFromNByStatus($n, $keyword, $status) { function search20UsersFromNByStatus($n, $keyword, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -219,7 +220,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
} }
function searchSomeUsersByStatus($n, $m, $keyword, $status) { function searchSomeUsersByStatus($n, $m, $keyword, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -248,7 +249,7 @@ function searchSomeUsersByStatus($n, $m, $keyword, $status) {
} }
function countSomeUsersByStatus($keyword, $status) { function countSomeUsersByStatus($keyword, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
COUNT(*) COUNT(*)
FROM FROM
@@ -271,7 +272,7 @@ function countSomeUsersByStatus($keyword, $status) {
function changeUserStatusByID($id, $status) { function changeUserStatusByID($id, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET
@@ -287,7 +288,7 @@ function changeUserStatusByID($id, $status) {
} }
function changeMultipleUserStatusByID($ids, $status) { function changeMultipleUserStatusByID($ids, $status) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
UPDATE UPDATE
`user` `user`
SET SET
@@ -304,7 +305,7 @@ function changeMultipleUserStatusByID($ids, $status) {
} }
function selectRandomNotFriendUser($userID) { function selectRandomNotFriendUser($userID) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`user`.`username` `user`.`username`
FROM FROM
@@ -332,7 +333,7 @@ function selectRandomNotFriendUser($userID) {
} }
function searchSomeUsers($n, $m, $search) { function searchSomeUsers($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare(" $stmt = prepareQuery("
SELECT SELECT
`userID`, `userID`,
`username`, `username`,
@@ -367,7 +368,7 @@ function searchSomeUsers($n, $m, $search) {
} }
function countSomeUsers($search) { function countSomeUsers($search) {
$q = $GLOBALS["db"]->prepare(" $q = prepareQuery("
SELECT SELECT
COUNT(*) COUNT(*)
FROM FROM
@@ -389,7 +390,7 @@ function countSomeUsers($search) {
} }
function getRoleByID($userID) { function getRoleByID($userID) {
$stmt = $GLOBALS['db']->prepare(" $stmt = prepareQuery("
SELECT SELECT
`role` `role`
FROM FROM

View File

@@ -13,88 +13,24 @@
<p> <p>
<?php <?php
foreach($members as $member) { foreach($members as $member) {
echo "<a href=\"profile.php?username=" . $member["username"] . "\" data-title=\"" . $member["username"] . "\"><img class=\"profile-picture\" src=\"" . $member["profilepicture"] . "\" alt=\"" . $member["username"] . "'s profielfoto\">"; echo "<a href=\"profile.php?username=" . $member["username"] . "\" data-title=\"" . $member["username"] . "\"><img class=\"profile-picture\" src=\"" . $member["profilepicture"] . "\" alt=\"" . $member["username"] . "'s profielfoto\"></a>";
} }
?> ?>
</p> </p>
</div> </div>
<div class="posts"> <div class="posts">
<div class="post platform">
<h2>Lorem</h2>
<p>Lorem ipsum dolor sit amet, consectetur.</p>
<p class="subscript">Enkele minuten geleden geplaatst</p>
</div>
<div class="post platform">
<h2>Image</h2>
<img src="http://i.imgur.com/ypIQKjE.jpg" alt="Olympic Mountains, Washington">
<p class="subscript">Gisteren geplaatst</p>
</div>
<div class="post platform">
<h2>Ipsum</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem nihil alias amet dolores fuga totam sequi a cupiditate ipsa voluptas id facilis nobis.</p>
<p class="subscript">Maandag geplaatst</p>
</div>
<div class="post platform">
<h2>Dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Sit</h2>
<p>Lorem ipsum dolor sit.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Image</h2>
<img src="https://i.redditmedia.com/EBWWiEojgkRrdn89R7qF7tBZjJszJaIqgkWUH23s11A.jpg?w=576&s=ba4fe1f02485cb2327305924ef869a66" alt="Nunobiki Falls, Kobe Japan">
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima asperiores eveniet vero velit eligendi aliquid in.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Consectetur</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error aliquid reprehenderit expedita odio beatae est.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Adipisicing</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat architecto quis tenetur fugiat veniam iste molestiae fuga labore!</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Elit</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem ut debitis dolorum earum expedita eveniet voluptatem quibusdam facere eos numquam commodi ad iusto laboriosam rerum aliquam.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Geen error</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloribus dolorem maxime minima animi cum.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Image</h2>
<img src="https://i.reddituploads.com/82c1c4dd0cfb4a4aa1cfa16f93f5dbfa?fit=max&h=1536&w=1536&s=dd629d407f3646ee6e3adb4da78c93f2" alt="Oregon cliffs are no joke.">
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Aliquid</h2>
<p>Lorem ipsum dolor sit amet, consectetur.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Odit</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit accusamus tempore at porro officia rerum est impedit ea ipsa tenetur. Labore libero hic error sunt laborum expedita.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
<div class="post platform">
<h2>Accusamus</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis quaerat suscipit ad.</p>
<p class="subscript">4 Januari geplaatst</p>
</div>
</div>
</div> </div>
<div class="modal">
<div class="modal-content platform">
<div class="modal-close">
&times;
</div>
<div class="modal-response" id="modal-response">
<span class="modal-default">Aan het laden...</span>
</div>
</div>
</div>
</div>

View File

@@ -5,7 +5,6 @@
<script src="js/main.js"></script> <script src="js/main.js"></script>
<script src="js/header.js"></script> <script src="js/header.js"></script>
<script src="js/menu.js"></script> <script src="js/menu.js"></script>
<script src="js/notifications.js"></script>
<style> <style>
/* Add your css files here. */ /* Add your css files here. */
@import url("styles/main.css"); @import url("styles/main.css");

View File

@@ -1,7 +1,7 @@
<nav class="menu"> <nav class="menu">
<section id="friends-menu-section"> <section id="friends-menu-section">
<h4> <h4>
Top vrienden Recente vrienden
</h4> </h4>
<ul id="menu-friends-list" class="nav-list"> <ul id="menu-friends-list" class="nav-list">
</ul> </ul>
@@ -12,6 +12,13 @@
</h4> </h4>
<ul id="menu-groups-list" class="nav-list"> <ul id="menu-groups-list" class="nav-list">
</ul> </ul>
<ul class="nav-list">
<li>
<a href="#">
Maak een groep aan
</a>
</li>
</ul>
</section> </section>
<section> <section>
<ul class="nav-list"> <ul class="nav-list">

View File

@@ -5,14 +5,14 @@ function messagePage(string $content) {
<html> <html>
<head> <head>
<style> <style>
@import url(styles/main.css); @import url(../styles/main.css);
@import url(styles/settings.css); @import url(../styles/settings.css);
@import url(styles/resetpassword.css); @import url(../styles/message-page.css);
</style> </style>
</head> </head>
<body> <body>
<div class='password-change'> <div class='password-change'>
<div class='top-logo'><a href='login.php'><img src='img/top-logo.png' alt='MyHyvesbook+'/></a></div> <div class='top-logo'><a href='../index.php'><img src='../img/top-logo.png' alt='MyHyvesbook+'/></a></div>
<div class='item-box platform'>$content</div> <div class='item-box platform'>$content</div>
</div> </div>
</body> </body>

View File

@@ -1,9 +1,20 @@
<nav class="menu" id="notification-center"> <nav class="menu" id="notification-center">
<section id="quick-links"> <section id="quick-links">
<a href="chat.php"><i class="fa fa-comments-o" data-title="Prive chats"></i></a> <a href="chat.php" data-title="Prive chats"><i class="fa fa-comments-o"></i></a>
<a href="settings.php"><i class="fa fa-cog" data-title="Instellingen"></i></a> <a href="settings.php" data-title="Instellingen"><i class="fa fa-cog"></i></a>
<a href="profile.php"><i class="fa fa-user" data-title="Profiel"></i></a> <a href="profile.php" data-title="Profiel"><i class="fa fa-user"></i></a>
<a href="logout.php"><i class="fa fa-sign-out" data-title="Uitloggen"></i></a> <?php
include_once ("../queries/user.php");
// auth
$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC);
if ($userinfo['role'] == 'admin' OR $userinfo['role'] == 'owner') {
echo "<a href=\"admin.php\" data-title=\"Admin\"><i class=\"fa fa-lock\"></i></a>";
echo "<style>@import url('styles/adminbutton.css'); </style>";
}
?>
<a href="logout.php" data-title="Admin"><i class="fa fa-sign-out"></i></a>
</section> </section>
<section id="friend-request-section"> <section id="friend-request-section">
<h4> <h4>

View File

@@ -26,13 +26,12 @@ echo("
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>"> <input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br> <textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
<button onclick="postComment('reaction')" name="button" value="reaction">Reageer!</button> <button onclick="postComment('reaction')" name="button" value="reaction">Reageer!</button>
<!-- TODO: if/else op "niet slecht." button voor like/unlike--> <button onclick="postComment('nietslecht')" name="button" value="nietslecht" class="nietslecht">
<button onclick="postComment('nietslecht')" name="button" value="nietslecht">
<?php <?php
if (checkNietSlecht($postID, $_SESSION["userID"])) { if (checkNietSlecht($postID, $_SESSION["userID"])) {
echo 'Trek <span class="nietslecht">"Niet slecht."</span> terug'; echo 'Trek <span class="nietslecht-text">"Niet slecht."</span> terug';
} else { } else {
echo 'Vind ik <span class="nietslecht">"Niet slecht."</span>'; echo '<img src="img/nietslecht_small.png" /> <span class="nietslecht-text">"Niet slecht."</span>';
} }
?> ?>
</button> </button>
@@ -51,7 +50,7 @@ echo("
<div class='comment'> <div class='comment'>
<div class='commentinfo'> <div class='commentinfo'>
$commentauthor $commentauthor
<span class='commentdate', title='$commentdate'> <span class='commentdate' title='$commentdate'>
$commentnicetime $commentnicetime
</span> </span>
</div> </div>

View File

@@ -1,24 +1,41 @@
<div class="content"> <div class="content">
<div class="profile-box platform"> <div class="user-box">
<img class="left profile-picture" src="<?php echo $user["profilepicture"] ?>"> <img class="profile-picture main-picture" src="<?= $user["profilepicture"] ?>"><br />
<form id="start-profile-chat-form" class="right" action="chat.php" method="get"> <div class="platform">
<button name="username" <div class="status-buttons-container">
class="friend-button green" <button disabled class="gray"><?= $user["onlinestatus"] ?></button>
value="<?php echo $user["userID"] ?>"> <button disabled class="gray"><?= $user["role"] ?></button>
<i class="fa fa-comment-o"></i> Chat </div>
</button>
</form>
<div class="friend-button-container"> <div class="friend-button-container">
<p>:)</p>
<p>Je ziet er goed uit vandaag</p>
</div>
<div class="profile-info">
<h2><?= $user["fname"]?> <?=$user["lname"]?></h2>
<h5><?=$user["username"]?></h5>
<?php if (strlen($user["bio"]) <= 50) {
echo "<p>" . $user["bio"] . "</p>";
} ?>
</div>
</div>
</div>
<?php if (strlen($user["bio"]) > 50) {
echo "<div class='platform'><h3>Bio:</h3><p>" . $user["bio"] . "</p></div>";
} ?>
<div class="item-box platform">
<h3>Informatie</h3>
<p>
<ul>
<li>Geboren op: <?= $user["birthdate"] ?></li>
<li>Locatie: <?= $user["location"] ?></li>
<li>Lid sinds: <?= nicetime($user["creationdate"]) ?></li>
</ul>
</p>
</div> </div>
<h1 class="profile-username"><?= $user["fname"]?> <?=$user["lname"]?></h1> <div class="item-box platform">
<h5 class="profile-username"><?=$user["username"]?></h5> <h3>Vrienden</h3>
<p><?=$user["bio"]?></p>
</div>
<div class="item-box left platform">
<h2>Vrienden</h2>
<p> <p>
<?php <?php
while($friend = $profile_friends->fetch()) { while($friend = $profile_friends->fetch()) {
@@ -33,12 +50,12 @@
</p> </p>
</div> </div>
<div class="item-box right platform"> <div class="item-box platform">
<h2>Groepen</h2> <h3>Groepen</h3>
<p> <p>
<?php <?php
while($group = $profile_groups->fetch()) { while($group = $profile_groups->fetch()) {
echo "<a href='/group/${group["name"]}/' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>"; echo "<a href='group.php?groupname=${group['name']}' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
} }
if($profile_groups->rowCount() === 0) { if($profile_groups->rowCount() === 0) {