Merge branch 'master' into hendrik-post

This commit is contained in:
Hendrik
2017-02-01 11:49:41 +01:00
83 changed files with 2810 additions and 1142 deletions

View File

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

View File

@@ -0,0 +1,25 @@
<?php
session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
$userinfo = getRoleByID($_SESSION['userID']);
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
} else if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
} else if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
if ($userinfo == 'owner') {
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
} else {
changeMultipleUserStatusByIDAdmin($_POST["checkbox-user"], $_POST["batchactions"]);
}
} else if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
} else if (isset($_POST['bancommentuserID']) && isset($_POST['bancommenttext'])) {
editBanCommentByID($_POST['bancommentuserID'], $_POST['bancommenttext']);
}

View File

@@ -0,0 +1,38 @@
<?php
session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
$pagetype = "user";
if (isset($_POST['pagetype'])) {
$pagetype = test_input($_POST['pagetype']);
}
$status = array();
if (isset($_POST['status'])) {
$status = $_POST["status"];
}
$groupstatus = array();
if (isset($_POST['groupstatus'])) {
$groupstatus = $_POST["groupstatus"];
}
$entries = 20;
$currentpage = 1;
if (isset($_POST['currentpage'])) {
$currentpage = (int) test_input($_POST["currentpage"]);
}
$offset = (int) $currentpage * $entries - $entries;
include ("../../views/adminpanel-page.php");

View File

@@ -0,0 +1,44 @@
<?php
session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
$offset = 0;
$entries = 20;
if (isset($_POST["currentpage"])) {
$offset = (int) test_input($_POST["currentpage"]) * $entries - $entries;
}
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
$pagetype = "user";
if (isset($_POST['pagetype'])) {
$pagetype = test_input($_POST['pagetype']);
}
$status = array();
if (isset($_POST['status'])) {
$status = $_POST["status"];
}
$groupstatus = array();
if (isset($_POST['groupstatus'])) {
$groupstatus = $_POST["groupstatus"];
}
$userinfo = getRoleByID($_SESSION['userID']);
if ($pagetype == "user") {
include ("../../views/adminpanel-table.php");
} else if ($pagetype == "group") {
include ("../../views/adminpanel-grouptable.php");
} else {
echo "Search failed!";
}

View File

@@ -1,13 +1,17 @@
<?php
if(empty($_POST["usr"])) {
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
header('HTTP/1.1 500 Non enough arguments');
}
require_once ("../../queries/user.php");
require_once ("../../queries/post.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) {
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[0]["niceTime"] = nicetime($results[0]["creationdate"]);
echo json_encode($results);

View File

@@ -4,5 +4,12 @@ session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/friendship.php");
require_once ("../../queries/user.php");
echo selectAllFriendRequests();
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
echo selectAllFriendRequests();
} else {
echo "[]";
}

View File

@@ -6,11 +6,15 @@ require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/friendship.php");
if (isset($_POST["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int) test_input($_POST["limit"]));
} else if (isset($_GET["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int) test_input($_GET["limit"]));
if (isset($_SESSION["userID"])) {
if (isset($_POST["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"]));
} else if (isset($_GET["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_GET["limit"]));
} else {
echo selectFriends($_SESSION["userID"]);
}
} else {
echo selectFriends($_SESSION["userID"]);
echo "[]";
}

View File

@@ -0,0 +1,41 @@
<?php
session_start();
require_once ("../queries/connect.php");
require_once ("../queries/checkInput.php");
function getNietSlechtCountForPost(int $postID) : int {
$stmt = prepareQuery("
SELECT
`userID`
FROM
`niet_slecht`
WHERE
`postID` = :postID
");
$stmt->bindParam(":postID", $postID);
$stmt->execute();
return $stmt->rowCount();
}
function getNietSlechtUsersForPost(int $postID) {
$stmt = prepareQuery("
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"]);
}
}

View File

@@ -2,17 +2,36 @@
session_start();
require("../../queries/post.php");
require("../../queries/connect.php");
require("../../queries/checkInput.php");
if (empty($_POST['newcomment-content'])) {
echo 0;
} else {
if(makeComment(test_input($_POST['postID']),
$_SESSION['userID'],
test_input($_POST['newcomment-content']))) {
echo 1;
require_once("../../queries/post.php");
require_once("../../queries/connect.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/user.php");
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
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;
}
} else {
echo "frozen";
}

View File

@@ -2,16 +2,53 @@
session_start();
require("../../queries/post.php");
require("../../queries/connect.php");
require("../../queries/checkInput.php");
require_once("../../queries/post.php");
require_once("../../queries/group_page.php");
require_once("../../queries/connect.php");
require_once("../../queries/checkInput.php");
if (empty($_POST['newpost-title'])) {
} else {
makePost($_SESSION['userID'],
null,
test_input($_POST['newpost-title']),
test_input($_POST['newpost-content']));
if (empty($_POST["title"]) or
empty($_POST["content"]) or
empty($_SESSION["userID"])) {
header('HTTP/1.1 500 Non enough arguments');
}
header("Location: ../profile.php");
if (empty($_POST["group"])) {
// User Post
makePost(
$_SESSION["userID"],
null,
test_input($_POST["title"]),
test_input($_POST["content"])
);
} else {
// Group Post
// Check if the user is an admin or mod of the group.
if(!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
header('HTTP/1.1 500 Non enough rights');
return;
}
makePost(
$_SESSION["userID"],
$_POST["group"],
test_input($_POST["title"]),
test_input($_POST["content"])
);
}
//if (empty($_POST['newpost-title'])) {
//} else {
// makePost($_SESSION['userID'],
// null,
// test_input($_POST['newpost-title']),
// test_input($_POST['newpost-content']));
//}
//
//header("Location: ../profile.php");

View File

@@ -0,0 +1,41 @@
<?php
session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
$user_perpage = $group_perpage = 20;
$user_currentpage = $group_currentpage = 1;
if (isset($_POST['user-pageselect'])) {
$user_currentpage = test_input($_POST['user-pageselect']);
}
if (isset($_POST['group-pageselect'])) {
$group_currentpage = test_input($_POST['group-pageselect']);
}
$user_n = $user_currentpage * $user_perpage - $user_perpage;
$group_n = $group_currentpage * $group_perpage - $group_perpage;
$search = "";
if (isset($_POST['search'])) {
$search = test_input($_POST['search']);
}
$user_count = countSomeUsers($search)->fetchColumn();
$group_count = countSomeGroups($search)->fetchColumn();
$filter = "all";
if (isset($_POST['filter'])) {
$filter = test_input($_POST['filter']);
}
$option = "user";
if (isset($_POST['option'])) {
$option = test_input($_POST['option']);
}
include ("../../views/searchPageNumber.php");

View File

@@ -8,13 +8,15 @@ require_once ("../../queries/friendship.php");
require_once ("../../queries/user.php");
$n = 0;
if (isset($_POST["n"])) {
$n = (int) test_input($_POST["n"]);
}
$m = 20;
if (isset($_POST["m"])) {
$m = (int) test_input($_POST["m"]);
$page = 1;
if (isset($_POST["user-pageselect"])) {
$page = (int) test_input($_POST['user-pageselect']);
}
$n = ($page - 1) * $m;
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);

View File

@@ -4,14 +4,22 @@ session_start();
require_once("../../queries/connect.php");
require_once("../../queries/private_message.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/user.php");
if (!empty(test_input($_POST["destination"])) &&
!empty(test_input($_POST["content"]))) {
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
echo 1;
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (!empty(test_input($_POST["destination"])) &&
!empty(test_input($_POST["content"]))
) {
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
echo 1;
} else {
echo 0;
}
} else {
echo 0;
}
} else {
echo 0;
echo "frozen";
}

View File

@@ -1,10 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<?php include("../views/head.php"); ?>
<?php
require_once ("../queries/user.php");
require_once ("../queries/group_page.php");
require_once ("../views/head.php"); ?>
<style>
@import url("styles/adminpanel.css");
</style>
<script src="js/admin.js" charset="utf-8"></script>
</head>
<body>
<?php
@@ -12,6 +16,15 @@
* This view adds the main layout over the screen.
* Header and menu.
*/
include_once ("../queries/user.php");
// auth
$role = getRoleByID($_SESSION['userID']);
if ($role != 'admin' AND $role != 'owner') {
header("location:profile.php");
}
include("../views/main.php");
/* Add your view files here. */

View File

@@ -21,7 +21,7 @@ $friends = json_decode($_POST["friends"]);
foreach($friends as $i => $friend) {
$friendshipStatus = getFriendshipStatus($friend->userID);
?>
<li class='friend-item <?= $extra ?>'>
<li class='friend-item'>
<form action='<?= $action ?>' method='<?= $actionType ?>'>
<button type='submit'
name='username'
@@ -33,7 +33,7 @@ foreach($friends as $i => $friend) {
}
?>'>
<div class='friend'>
<img alt='PF' class='profile-picture' src='<?= $friend->profilepicture ?>'/>
<img alt='PF' class='profile-picture <?= $friend->onlinestatus ?>' src='<?= $friend->profilepicture ?>'/>
<div class='friend-name'>
<?= $friend->fullname ?><br/>
<span style='color: #666'><?php

View File

@@ -2,7 +2,7 @@
include_once("../queries/connect.php");
include_once("../views/messagepage.php");
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
$checkHash = $GLOBALS["db"]->prepare("
$checkHash = prepareQuery("
SELECT
`email`,
`role`
@@ -28,7 +28,7 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
function doActivate(string $email) {
if (password_verify($email, $_GET["h"])) {
$confirmUser = $GLOBALS["db"]->prepare("
$confirmUser = prepareQuery("
UPDATE
`user`
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,10 +4,23 @@
<?php include("../views/head.php"); ?>
<style>
@import url("styles/profile.css");
@import url("styles/post-popup.css");
@import url('https://fonts.googleapis.com/css?family=Anton');
</style>
</head>
<body>
<?php
include_once("../queries/group_page.php");
$group = selectGroupByName($_GET["groupname"]);
$members = selectGroupMembers(2);
?>
<script>alert("<?= $members[0] ?>");</script>
<script>alert("<?= $members[1] ?>");</script>
<?php
/*
* This view adds the main layout over the screen.
* Header, menu, footer.
@@ -19,6 +32,23 @@ include("../views/group.php");
/* This adds the footer. */
include("../views/footer.php");
$masonry_mode = 0;
if ($group["role"] == "mod" OR $group["role"] == "admin") {
$masonry_mode = 2;
}
?>
<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>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -1,30 +1,48 @@
window.onload = function() {
$(window).on("load", function () {
changeFilter();
};
searchFromOne();
function checkAll(allbox) {
var checkboxes = document.getElementsByClassName('checkbox-list');
$(".admin-searchinput").keyup(function(){
searchFromOne();
});
// all inputs and labels directly under admin filter and groupfilter
$("#admin-filter, #admin-groupfilter > input, label").change(function(){
searchFromOne();
});
$("#pagetype").change(function(){
searchFromOne();
});
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = allbox.checked;
}
}
/* Update hidden input to be equal to submit pressed,
because serialize doesn't take submit values. */
$('#admin-batchform > button').click(function () {
$('#batchinput').prop('value', $(this).prop('value'));
console.log($('#batchinput').prop('value'));
});
$('#admin-groupbatchform > button').click(function () {
$('#groupbatchinput').prop('value', $(this).prop('value'));
console.log($('#batchinput').prop('value'));
});
});
function checkAll() {
$('.checkbox-list').each(function () {
$(this).prop('checked', $('#checkall').prop('checked'));
});
}
function checkCheckAll(allbox) {
var checkboxes = document.getElementsByClassName('checkbox-list');
function checkCheckAll() {
var checked = true;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
if (checkboxes[i].checked == false) {
checked = false;
break;
}
$('.checkbox-list').each(function () {
if ($(this).prop('checked') == false) {
checked = false;
return;
}
}
allbox.checked = checked;
});
$('#checkall').prop('checked', checked);
}
function changeFilter() {
@@ -32,13 +50,61 @@ function changeFilter() {
document.getElementById('admin-filter').style.display = 'none';
document.getElementById('admin-groupfilter').style.display = 'inline-block';
document.getElementById('admin-batchactions').style.display = 'none';
document.getElementById('admin-groupbatchactions').style.display = 'inline-block';
document.getElementById('admin-batchform').style.display = 'none';
document.getElementById('admin-groupbatchform').style.display = 'inline-block';
} else {
document.getElementById('admin-filter').style.display = 'inline-block';
document.getElementById('admin-groupfilter').style.display = 'none';
document.getElementById('admin-batchactions').style.display = 'inline-block';
document.getElementById('admin-groupbatchactions').style.display = 'none';
document.getElementById('admin-batchform').style.display = 'inline-block';
document.getElementById('admin-groupbatchform').style.display = 'none';
}
}
function searchFromOne() {
$('#currentpage').prop('value', 1);
adminSearch();
}
function adminSearch() {
console.log($("#admin-searchform").serialize());
$.post(
"API/adminSearchUsers.php",
$("#admin-searchform").serialize()
).done(function (data) {
$("#usertable").html(data);
updatePageN();
})
}
function adminUpdate(form) {
$.post(
"API/adminChangeUser.php",
$(form).serialize()
).done(function () {
adminSearch();
})
}
function updatePageN() {
$.post(
"API/adminPageNumber.php",
$("#admin-searchform").serialize()
).done(function (data) {
$("#admin-pageinfo").html(data);
})
}
function toggleBancomment(button) {
$(button).siblings("div").toggle();
$(button).toggle();
}
function editComment(form) {
$.post(
"API/adminChangeUser.php",
$(form).serialize()
).done(function (data) {
adminSearch();
});
}

View File

@@ -1,23 +1,31 @@
var previousDate = new Date("1970-01-01 00:00:00");
var previousTime = "00:00";
var gettingMessages = false;
var previousType = "robot";
$(document).ready(function() {
loadMessages();
setInterval(loadMessages, 1000);
sayEmpty();
$(".chat-field").hide();
});
function loadMessages() {
$.post(
"API/loadMessages.php",
$("#lastIDForm").serialize()
).done(function(data) {
if (data && data != "[]") {
messages = JSON.parse(data);
addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID);
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight);
}
});
setTimeout(loadMessages, 1000);
if (!gettingMessages) {
gettingMessages = true;
$.post(
"API/loadMessages.php",
$("#lastIDForm").serialize()
).done(function (data) {
if (data && data != "[]") {
messages = JSON.parse(data);
addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID);
}
gettingMessages = false;
});
} else {
setTimeout(loadMessages, 500);
}
}
@@ -25,30 +33,75 @@ function sendMessage() {
$.post(
"API/sendMessage.php",
$("#sendMessageForm").serialize()
);
).done(function(response) {
if (response == "frozen") {
alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is.");
}
});
$("#newContent").val("");
loadMessages();
}
function addMessages(messages) {
for(i in messages) {
var messagesText = "";
for(var i in messages) {
// Initialize message variables
var thisDate = new Date(messages[i].creationdate);
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
var type;
thisDate.setHours(0,0,0,0);
if (messages[i].destination == $(".destinationID").val()) {
type = "chat-message-self";
} else {
type = "chat-message-other";
}
if (i == 0) {
if (thisDate > previousDate) {
previousDate = thisDate;
messagesText += '\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>';
}
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>';
$("#chat-history").append('\
<div class="chat-message"> \
<div class="' + type + '">\
' + messages[i].content + '\
</div> \
</div>\
');
previousTime = thisTime;
previousType = type;
if (thisDate > previousDate) {
previousDate = thisDate;
messagesText += '\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>';
}
messagesText += '<div class="chat-message"><div class="' + type + '">';
}
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) {
previousDate = new Date("1970-01-01 00:00:00");
$(".chat-field").show();
$(".destinationID").val(userID);
$("#chat-history").html("");
@@ -58,5 +111,5 @@ function switchUser(userID) {
}
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,24 +1,70 @@
function placeFriendButtons() {
$.post("API/getFriendshipStatus.php", { usr: userID })
.done(function(data) {
friendshipStatus = data;
$buttonContainer = $("div.friend-button-container");
$buttonContainer.children().remove();
if (friendshipStatus == -1) {
return;
} else if(friendshipStatus == 0) {
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>"));
} else if(friendshipStatus == 1) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>"));
} else if(friendshipStatus == 2) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>"));
} else if(friendshipStatus == 3) {
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Weiger</button>"));
$buttonContainer.append($("<button class=\"green friend-button\" value=\"accept\"><i class=\"fa fa-check\"></i> Accepteer</button>"));
}
var friendshipStatus = data;
var $buttonContainer = $("div.friend-button-container");
$("#start-profile-chat").hide();
$buttonContainer.html("");
var value1 = "";
var class1 = "empty-button";
var icon1 = "";
var text1 = "";
var value2 = "";
var class2 = "empty-button";
var icon2 = "";
var text2 = "";
switch (friendshipStatus) {
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;
}
$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() {
editFriendship(userID, this.value);
if (isNaN(this.value))
editFriendship(userID, this.value);
else if (this.value != "")
window.location.href = "chat.php?username=" + this.value;
});
});
}

View File

@@ -1,19 +1,40 @@
$(document).ready(function() {
// Toggle menu
$("#own-profile-picture, #open-notifications").click(function() {
if ($("#notification-center").css('right') == "-256px") {
// Make the menu visible and move the content to the left.
$("#chat-history").width("calc(100% - 587px)");
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
} else {
// Make the menu invisible and move the content to the right.
$("#chat-history").width("calc(100% - 331px)");
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("right", "-256px");
}
if ($("#notification-center").css('display') == "none") {
// Make the menu visible and move the content to the left.
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
$("#notification-center").css("display", "block");
$("#contact-menu").css("display", "block");
// Add cookie so the menu stays open on other pages
if (window.innerWidth > 1080) {
$("#chat-history").width("calc(100% - 587px)");
document.cookie = "menu=open; path=/";
} else {
document.cookie = "menu=closed; path=/";
}
} else {
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("display", "none");
if (window.innerWidth > 1080) {
$("#chat-history").width("calc(100% - 331px)");
} else {
// Make the menu invisible and move the content to the right.
$("#contact-menu").css("display", "none");
}
// Change menu cookie to close
document.cookie = "menu=closed; path=/";
}
});
if (getCookie("menu") == "open") {
$("#own-profile-picture").click();
}
});

View File

@@ -1,3 +1,54 @@
var days = ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"];
var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]
function fancyText(text) {
// Add links, images, gifs and (youtube) video's.
var regex = /(https?:\/\/.[^ <>"]*)/ig;
text = text.replace(regex, function(link) {
// Add images
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>";
}
});
return text;
}
function getCookie(key) {
cookies = document.cookie.split("; ");
for (var i in cookies) {
cookie = cookies[i].split("=");
if (cookie[0] == key) {
return cookie[1];
}
}
return false;
}
function editFriendship(userID, value) {
$.post("API/editFriendship.php", { usr: userID, action: value })
.done(function() {
@@ -43,3 +94,13 @@ function showGroups(groups, list) {
return false;
}
}
$(document).ready(function() {
$("body").delegate("textarea[maxlength]", "keydown", function() {
if ($(this).val().length / .9 >= $(this).attr("maxlength")) {
$(this).next().text($(this).val().length + "/" + $(this).attr("maxlength"));
} else {
$(this).next().text("");
}
});
});

View File

@@ -19,10 +19,32 @@ function requestPost(postID) {
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
scrollbarMargin(scrollBarWidth, 'hidden');
$('#modal-response').show();
$('#modal-response').html(data);
$('#modal-response').html(fancyText(data));
});
}
function postPost() {
title = $("input.newpost[name='title']").val();
content = $("textarea.newpost[name='content']").val();
if (masonryMode == 2) {
$.post("API/postPost.php", { title: title,
content : content,
group : groupID })
.done(function() {
masonry(masonryMode);
});
} else {
$.post("API/postPost.php", { title: title,
content : content })
.done(function() {
masonry(masonryMode);
});
}
}
$(window).on("load", function() {
$(".modal-close").click(function () {
$(".modal").hide();
@@ -33,11 +55,15 @@ $(window).on("load", function() {
});
var masonryMode = 0;
var windowWidth = $(window).width();
$(window).resize(function() {
clearTimeout(window.resizedFinished);
window.resizeFinished = setTimeout(function() {
masonry(masonryMode);
if ($(window).width() != windowWidth) {
windowWidth = $(window).width();
masonry(masonryMode);
}
}, 250);
});
@@ -52,7 +78,7 @@ function masonry(mode) {
* Initialise columns.
*/
var columns = new Array(columnCount);
var $columns = new Array(columnCount);
for (i = 0; i < columnCount; i++) {
$column = $("<div class=\"column\">");
$column.width(100/columnCount + "%");
@@ -60,19 +86,21 @@ function masonry(mode) {
columns[i] = [0, $column];
}
if(mode == 1) {
if(mode > 0) {
$postInput = $("<div class=\"post platform\">");
$form = $("<form action=\"API/postPost.php\" method=\"post\">");
$form = $("<form class=\"newpost\" action=\"API/postPost.php\" method=\"post\" onsubmit=\"postPost(); return false;\">");
$postInput.append($form);
$form.append($("<input class=\"newpost\" name=\"newpost-title\" placeholder=\"Titel\" type=\"text\">"));
$form.append($("<textarea class=\"newpost\" name=\"newpost-content\" placeholder=\"Schrijf een berichtje...\">"));
if(mode == 2) {
$form.append($("<input class=\"newpost\" type=\"hidden\" name=\"group\" value=\"" + groupID + "\">"));
}
$form.append($("<input class=\"newpost\" name=\"title\" placeholder=\"Titel\" type=\"text\">"));
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\" maxlength='1000'></textarea><span></span>"));
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
columns[0][1].append($postInput);
$postInput.on("load", function() {
columns[0][0] = $postInput.height() + margin;
});
columns[0][0] = $postInput.height() + margin;
}
/*
@@ -92,18 +120,19 @@ function masonry(mode) {
/*
* Get the posts from the server.
*/
$.post("API/getPosts.php", { usr : userID })
$.post("API/getPosts.php", { usr : userID, grp : groupID })
.done(function(data) {
posts = JSON.parse(data);
/*
* Rearange the objects.
*/
jQuery.each(posts, function() {
$.each(posts, function() {
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
$post.append($("<h2>").text(this["title"]));
$post.append($("<p>").html(this["content"]));
$post.append($("<h2>").html(this["title"]));
$post.append($("<p>").html(fancyText(this["content"])));
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
$post.append($("<p class=\"subscript\">").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);

View File

@@ -1,8 +1,14 @@
function postComment() {
function postComment(buttonValue) {
formData = $("#newcommentform").serializeArray();
formData.push({name: "button", value: buttonValue});
$.post(
"API/postComment.php",
$("#newcommentform").serialize()
);
formData
).done(function (response) {
if (response == "frozen") {
alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is.");
}
});
$("#newcomment").val("");
@@ -11,8 +17,6 @@ function postComment() {
"API/loadPost.php",
$("#newcommentform").serialize()
).done(function (data) {
$('#modal-response').html(data);
$('#modal-response').html(fancyText(data));
});
}

View File

@@ -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");
}

View File

@@ -1,33 +1,41 @@
function searchUsers(n, m) {
$(window).on('load', function () {
pageNumber();
});
function searchUsers() {
$.post(
"API/searchUsers.php",
{
n: n,
m: m,
search: $("#search-input").val(),
filter: $("#search-filter").val()
}
$('#search-form').serialize()
).done(function(data) {
console.log(data);
if (!showFriends(data, "#search-users-list", 0, "profile.php", "GET")) {
$("#search-users-list").text("Niemand gevonden");
}
});
}
function searchGroups(n, m) {
function searchGroups() {
$.post(
"API/searchGroups.php",
{
n: n,
m: m,
search: $("#search-input").val(),
filter: $("#search-filter").val()
}
$('#search-form').serialize()
).done(function(data) {
console.log(data);
if (!showGroups(data, "#search-groups-list")) {
$("#search-groups-list").text("Geen groepen gevonden");
}
});
}
function pageNumber() {
var input = input2 = $('#search-form').serialize();
$.post(
"API/searchPageNumber.php",
input + "&option=user"
).done(function (data) {
$('#user-pageselect').html(data);
});
$.post(
"API/searchPageNumber.php",
input2 + "&option=group"
).done(function (data) {
$('#group-pageselect').html(data);
});
}

View File

@@ -19,16 +19,24 @@
</script>";
}
// 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";
// Define variables and set to empty values
$uname = $psw ="";
$user = $psw = $remember ="";
$loginErr = $resetErr ="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
switch ($_POST["submit"]) {
case "login":
try {
$uname = ($_POST["uname"]);
validateLogin($_POST["uname"], $_POST["psw"]);
$user = ($_POST["user"]);
validateLogin($_POST["user"], $_POST["psw"]);
} catch(loginException $e) {
$loginErr = $e->getMessage();
}
@@ -46,19 +54,10 @@
</script>";
}
break;
case "register":
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");
?>

View File

@@ -8,14 +8,16 @@
<style>
@import url("styles/profile.css");
@import url("styles/post-popup.css");
@import url('https://fonts.googleapis.com/css?family=Anton');
</style>
</head>
<body>
<?php
include("../queries/user.php");
include("../queries/friendship.php");
include("../queries/nicetime.php");
include("../queries/post.php");
include_once("../queries/user.php");
include_once("../queries/friendship.php");
include_once("../queries/nicetime.php");
include_once("../queries/post.php");
include_once("../queries/calcAge.php");
if(empty($_GET["username"])) {
$userID = $_SESSION["userID"];
@@ -26,7 +28,6 @@ if(empty($_GET["username"])) {
$user = selectUser($_SESSION["userID"], $userID);
$profile_friends = selectAllFriends($userID);
$profile_groups = selectAllUserGroups($userID);
$posts = selectAllUserPosts($userID);
if ($userID == $_SESSION["userID"]) {
@@ -53,23 +54,12 @@ include("../views/footer.php");
<script src="js/friendButtons.js"></script>
<script src="js/masonry.js"></script>
<script>
var posts;
$(document).ready(function() {
userID = <?= $userID ?>;
groupID = 0;
placeFriendButtons();
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>
</body>

View File

@@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<?php
include("../views/login_head.php");
require_once("../queries/connect.php");
include_once("../queries/register.php");
include_once("../queries/checkInput.php");
include_once("../queries/emailconfirm.php");
?>
<body>
<?php
session_start();
if(isset($_SESSION["userID"])){
header("location: login.php");
}
// 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();
}
}
/* This view adds register view */
include("../views/register-view.php");
?>
</body>
</html>

View File

@@ -1,104 +1,91 @@
<!DOCTYPE html>
<html>
<?php
include("../views/login_head.php");
require_once("../queries/connect.php");
include_once("../queries/register.php");
include_once("../queries/checkInput.php");
include_once("../queries/emailconfirm.php");
?>
<body>
<?php
session_start();
if(isset($_SESSION["userID"])){
header("location: login.php");
try {
$name = test_input(($_POST["name"]));
checkInputChoice($name, "lettersAndSpaces");
} catch(lettersAndSpacesException $e){
$correct = false;
$nameErr = $e->getMessage();
}
// define variables and set to empty values
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $captcha = $ip = "";
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $captchaErr = "";
$correct = true;
// 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{
$bday = test_input(($_POST["bday"]));
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");
} catch(emailException $e){
$correct = false;
$emailErr = $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 "<script>
window.onload = function() {
$('#registerModal').show();
}
</script>";
$genericErr = $e->getMessage();
}
/* This view adds register view */
include("../views/register-view.php");
?>
</body>
</html>

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
.admin-panel input[type="radio"], input[type="checkbox"] {
vertical-align: middle;
height: auto;
height: 28px;
margin: 2px;
}
@@ -34,7 +34,6 @@
width: 100%;
}
.usertable .table-checkbox {width: 20px}
.usertable .table-username {width: 150px}
.usertable .table-status {width: 100px}
.usertable .table-action {width: 200px}
@@ -44,10 +43,18 @@
padding: 3px;
}
.usertable tr {
.usertable th, tr {
text-align: left;
}
.usertable tr:hover {
background-color: #f5f5f5;
}
.bancommentedit {
display: none;
}
.bancommentform input[type="text"] {
width: 100%;
}

View File

@@ -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;
@@ -106,3 +127,39 @@
background: #4CAF50;
color: white;
}
.chat-message img {
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;
}
@media only screen and (max-width: 1080px) {
.chat-message-self, .chat-message-other {
max-width: 75%;
}
.chat {
left: 0;
width: 100%;
}
#chat-recent-panel {
left: 0;
width: 320px;
}
#chat-history {
left: 50%;
width: calc(100% - 390px);
}
}

View File

@@ -26,7 +26,8 @@ header {
}
#header-search {
padding-left: 42px;
margin: 24px 0 24px 32px;
vertical-align: middle;
}
@@ -48,5 +49,11 @@ header div {
}
#open-notifications {
padding: 5px 20px 5px 0px;
padding: 20px 20px 20px 0px;
}
@media only screen and (max-width: 1080px) {
#header-logo {
display: none;
}
}

View File

@@ -30,8 +30,10 @@ form {
border-radius: 12px;
height: 85%;
margin: auto;
width: 80%;
overflow-y:auto;
width: 600px;
overflow-y: auto;
overflow-x: hidden;
}
@@ -44,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;
}
@@ -61,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;
}
@@ -77,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);
@@ -88,6 +94,7 @@ button {
font-family: Arial;
font-size: 15px;
color: red;
text-align: left;
}
label {
@@ -96,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;
}
@@ -127,10 +134,14 @@ 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: 45%;
width: 600px;
}
select{
width: 18%;
}
ul {
@@ -143,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 */
}
@@ -160,7 +171,7 @@ ul {
margin: auto;
padding: 0;
border: 1px solid #888;
width: 500px;
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;
@@ -183,7 +194,7 @@ ul {
.close {
color: white;
float: right;
font-size: 28px;
font-size: 36px;
font-weight: bold;
}
@@ -195,15 +206,16 @@ ul {
}
.modal-header {
padding: 2px 16px;
padding: 4px 16px;
background-color: #FBC02D;
color: black;
}
.modal-body {padding: 2px 16px;}
.modal-body {
padding: 2px 16px;
}
.modal-footer {
padding: 2px 16px;
background-color: #FBC02D;
color: black;
}

View File

@@ -92,21 +92,29 @@ p {
border-radius: 50%;
}
.online {
border: #4CAF50 solid 3px;
}
.offline {
border: #666666 solid 3px;
}
.group-picture {
border-radius: 5px;
}
.item-box, .item-box-full-width {
margin: 20px 0 0 0;
padding: 25px;
background-color: #FFFFFF;
}
.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 {
width: calc(100% - 50px);
}
@@ -183,6 +191,10 @@ button.green {
background-color: forestgreen;
}
button.gray{
background-color: #FFF;
color: #333;
}
button,
input[type="submit"],
@@ -224,6 +236,7 @@ td {
/* Custom title box, appears instantaneously */
a[data-title]:hover,
i[data-title]:hover,
img[data-title]:hover,
span[data-title]:hover,
div[data-title]:hover {
@@ -231,6 +244,7 @@ div[data-title]:hover {
}
a[data-title]:hover:after,
i[data-title]:hover:after,
img[data-title]:hover:after,
span[data-title]:hover:after,
div[data-title]:hover:after {
@@ -275,3 +289,34 @@ div[data-title]:hover:after {
display: inline-block;
vertical-align: middle;
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-track {
background: none;
}
::-webkit-scrollbar-thumb {
-webkit-border-radius: 20px;
border-radius: 20px;
background: #4CAF50;
}
@media only screen and (max-width: 1080px) {
body {
font-size: 28px!important;
}
button, input, select {
font-size: 28px;
height: 42px;
}
textarea {
font-size: 28px;
}
input[type="checkbox"], input[type="radio"] {
width: 28px;
height: 28px;
}
}

View File

@@ -5,7 +5,7 @@
left: 0;
top: 80px;
height: calc(100% - 80px);
height: calc(100% - 120px);
width: 236px;
padding: 20px 10px;
@@ -87,3 +87,17 @@
padding: 0;
text-align: left;
}
@media only screen and (max-width: 1080px) {
#contact-menu, #notification-center {
display: none;
background: rgba(0, 0, 0, 0.4);
width: calc(50% - 20px);
}
.content {
margin-left: 0;
}
#quick-links i {
font-size: 48px!important;
}
}

View File

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

View File

@@ -0,0 +1,47 @@
/* MAIN */
body {
font-size: 28px!important;
}
button {
font-size: 28px;
}
/* HEADER */
#header-logo {
display: none;
}
/* PROFILE */
.post-box {
width: calc(100% - 65px);
}
/* MENU */
#contact-menu, #notification-center {
display: none;
background: rgba(0, 0, 0, 0.4);
width: calc(50% - 20px);
}
.content {
margin-left: 0;
}
#quick-links i {
font-size: 48px!important;
}
/* CHAT */
.chat-message-self, .chat-message-other {
max-width: 75%;
}
.chat {
left: 0;
width: 100%;
}
#chat-recent-panel {
left: 0;
width: 320px;
}
#chat-history {
left: 50%;
width: calc(100% - 390px);
}

View File

@@ -70,3 +70,17 @@
margin: 5px auto;
width: 95%;
}
.nietslecht-text {
font-family: Impact, Anton, sans-serif;
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 {
min-height: 150px;
padding: 25px;
background-color: #FFFFFF;
/* New */
.user-box {
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-width: 5px;
display: inline-block;
width: 150px;
height: 150px;
margin: 0 20px 20px 0;
margin-bottom: -45px;
}
/* Old */
.profile-box h1.profile-username {
padding-top: 50px;
}
@@ -18,18 +63,17 @@
}
div.posts {
padding-top: 20px;
width: calc(100% + 20px);
display: inline-flex;
}
div.posts div.post {
display: block;
margin: 20px 0 0 0;
padding: 10px;
width: calc(100% - 40px);
cursor: pointer;
transition-duration: 250ms;
word-wrap: break-word;
}
div.posts div.post:hover {
@@ -59,6 +103,12 @@ div.posts .post form textarea.newpost {
height: 100px;
}
.post .post-date {
float: right;
color: #aaaaaa;
font-size: 0.8em;
}
@media only screen and (max-width: 1500px) {
.post-box {
width: calc(50% - 68px);
@@ -66,28 +116,12 @@ div.posts .post form textarea.newpost {
}
/* mobile */
@media only screen and (max-width: 1000px) {
@media only screen and (max-width: 1080px) {
.post-box {
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);
.modal {
left: 0!important;
width: 100%!important;
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* Class AlertMessage
* abstract class for alertMessages used in
*/
abstract class AlertMessage extends Exception {
public function __construct($message = "", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
abstract public function getClass();
}
/**
* Class HappyAlert
* class for a happy alert as an exception.
*/
class HappyAlert extends AlertMessage {
public function __construct($message = "Gelukt!", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
public function getClass() {
return "settings-message-happy";
}
}
/**
* Class AngryAlert
* class for an angry alert as as exception.
*/
class AngryAlert extends AlertMessage {
public function __construct($message = "Er is iets fout gegaan.", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
public function getClass() {
return "settings-message-angry";
}
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* calculates the age of a user
* @param string $bdayAsString
* @return int age
*/
function getAge(string $bdayAsString) : int {
$bday = new DateTime($bdayAsString);
$today = new DateTime("now");
$interval = $bday->diff($today);
return $interval->y;
}

View File

@@ -38,8 +38,7 @@ function checkName($variable){
if (empty($variable)) {
throw new lettersAndSpacesException("Verplicht!");
} else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) {
throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!");
throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!");
}
}
@@ -48,12 +47,12 @@ function validateBday($variable){
if (empty($variable)) {
throw new bdayException("Verplicht!");
} else {
if (!(validateDate($variable, "Y/m/d"))) {
if (!(validateDate($variable, "Y-m-d"))) {
throw new bdayException("Geen geldige datum");
} else {
$dateNow = date("Y/m/d");
$dateNow = date("Y-m-d");
if ($dateNow < $variable) {
throw new bdayException("Geen geldige datum");
throw new bdayException("Geen geldige datum!");
}
}
}
@@ -97,6 +96,12 @@ function validateEmail($variable){
}
}
function matchEmail(){
if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){
throw new confirmEmailException("Emails matchen niet!");
}
}
/* checks if an input is a valid email. */
function resetEmail($variable){
if (empty($variable)) {
@@ -119,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!");
}
}
}
@@ -206,6 +211,14 @@ class emailException extends Exception
}
}
class confirmEmailException extends Exception
{
public function __construct($message = "", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
}
class captchaException extends Exception
{
public function __construct($message = "", $code = 0, Exception $previous = null)

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ function selectFriends($userID) {
}
function selectLimitedFriends($userID, $limit) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`,
`username`,
@@ -16,7 +16,10 @@ function selectLimitedFriends($userID, $limit) {
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
`onlinestatus`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role`
FROM
`user`
@@ -29,6 +32,9 @@ function selectLimitedFriends($userID, $limit) {
`friendship`.`user1ID` = `user`.`userID`) AND
`user`.`role` != 'banned' AND
`friendship`.`status` = 'confirmed'
ORDER BY
`user`.`lastactivity`
DESC
LIMIT :limitCount
");
@@ -41,7 +47,7 @@ function selectLimitedFriends($userID, $limit) {
function selectAllFriends($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`,
`username`,
@@ -50,7 +56,10 @@ function selectAllFriends($userID) {
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
`onlinestatus`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role`
FROM
`user`
@@ -73,7 +82,7 @@ function selectAllFriends($userID) {
}
function selectAllFriendRequests() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`,
`username`,
@@ -82,7 +91,10 @@ function selectAllFriendRequests() {
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
`onlinestatus`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role`
FROM
`user`
@@ -115,7 +127,7 @@ function getFriendshipStatus($userID) {
return -1;
}
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
CASE `status` IS NULL
WHEN TRUE THEN 0
@@ -148,7 +160,7 @@ function getFriendshipStatus($userID) {
}
function requestFriendship($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
INSERT INTO `friendship` (user1ID, user2ID)
VALUES (:user1, :user2)
");
@@ -159,7 +171,7 @@ function requestFriendship($userID) {
}
function removeFriendship($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
DELETE FROM `friendship`
WHERE
`user1ID` = :user1 AND
@@ -175,7 +187,7 @@ function removeFriendship($userID) {
}
function acceptFriendship($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
UPDATE `friendship`
SET `status`='confirmed'
WHERE
@@ -190,7 +202,7 @@ function acceptFriendship($userID) {
}
function setLastVisited($friend) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
UPDATE
`friendship`
SET `friendship`.chatLastVisted1=(
@@ -220,7 +232,7 @@ function setLastVisited($friend) {
}
function searchSomeFriends($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`,
`username`,
@@ -229,7 +241,10 @@ function searchSomeFriends($n, $m, $search) {
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
`onlinestatus`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role`
FROM
`user`

View File

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

View File

@@ -1,7 +1,90 @@
<?php
require_once("connect.php");
function selectGroupByName($name) {
$stmt = prepareQuery("
SELECT
`group_page`.`groupID`,
`group_page`.`groupID`,
`name`,
`description`,
`picture`,
`status`,
(
SELECT `role`
FROM `group_member`
WHERE `group_member`.`groupID` = `group_page`.`groupID` AND
`userID` = :userID
) AS `role`,
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, PDO::PARAM_STR);
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
if (!$stmt->execute()) {
return False;
}
return $stmt->fetch();
}
function selectGroupRole(int $groupID) {
$stmt = prepareQuery("
SELECT
`role`
FROM
`group_member`
WHERE
`groupID` = :groupID AND
`userID` = :userID
");
$stmt->bindParam(':groupID', $groupID, PDO::PARAM_INT);
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
if(!$stmt->execute()) {
return False;
}
if($stmt->rowCount() == 0) {
return "none";
}
return $stmt->fetch()["role"];
}
function selectGroupMembers(int $groupID) {
$stmt = prepareQuery("
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("
$q = prepareQuery("
SELECT
`group_page`.`name`,
`group_page`.`picture`,
@@ -20,7 +103,7 @@ function selectGroupById($groupID) {
}
function select20GroupsFromN($n) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`group_page`.`groupID`,
`group_page`.`name`,
@@ -42,7 +125,7 @@ function select20GroupsFromN($n) {
}
function select20GroupsByStatusFromN($n, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`group_page`.`groupID`,
`group_page`.`name`,
@@ -67,7 +150,7 @@ function select20GroupsByStatusFromN($n, $status) {
}
function search20GroupsFromNByStatus($n, $keyword, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`groupID`,
`name`,
@@ -94,7 +177,7 @@ function search20GroupsFromNByStatus($n, $keyword, $status) {
}
function searchSomeGroupsByStatus($n, $m, $keyword, $status) {
$q = $GLOBALS['db']->prepare("
$q = prepareQuery("
SELECT
`groupID`,
`name`,
@@ -122,7 +205,7 @@ function searchSomeGroupsByStatus($n, $m, $keyword, $status) {
}
function countSomeGroupsByStatus($keyword, $status) {
$q = $GLOBALS['db']->prepare("
$q = prepareQuery("
SELECT
COUNT(*)
FROM
@@ -143,20 +226,23 @@ function countSomeGroupsByStatus($keyword, $status) {
}
function changeGroupStatusByID($id, $status) {
$q = $GLOBALS["db"]->query("
$q = prepareQuery("
UPDATE
`group_page`
SET
`status` = $status
`status` = :status
WHERE
`groupID` = $id
`groupID` = :id
");
$q->bindParam(':status', $status);
$q->bindParam(':id', $id);
$q->execute();
return $q;
}
function changeMultipleGroupStatusByID($ids, $status) {
$q = $GLOBALS['db']->prepare("
$q = prepareQuery("
UPDATE
`group_page`
SET
@@ -173,7 +259,7 @@ function changeMultipleGroupStatusByID($ids, $status) {
}
function searchSomeGroups($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`name`,
`picture`
@@ -196,7 +282,7 @@ function searchSomeGroups($n, $m, $search) {
}
function countSomeGroups($search) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
COUNT(*)
FROM
@@ -212,4 +298,3 @@ function countSomeGroups($search) {
$stmt->execute();
return $stmt;
}
?>

View File

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

View File

@@ -1,7 +1,7 @@
<?php
function getUser() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`password`,
`userID`,
@@ -9,10 +9,11 @@ function getUser() {
FROM
`user`
WHERE
`username` LIKE :username
`username` LIKE :username OR
`email` LIKE :username
");
$stmt->bindParam(":username", $_POST["uname"]);
$stmt->bindValue(":username", test_input($_POST["user"]));
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
@@ -20,7 +21,7 @@ function getUser() {
function validateLogin($username, $password){
// Empty username or password field
if (empty($username) || empty($password)) {
throw new loginException("Gebruikersnaam of wachtwoord is niet ingevuld");
throw new loginException("Inloggegevens zijn niet ingevuld");
}
else {
$psw = test_input($password);
@@ -41,6 +42,9 @@ function validateLogin($username, $password){
</script>";
} else {
$_SESSION["userID"] = $userID;
// if($_POST[rememberMe] == 1){
// ini_set("session.gc_maxlifetime", "10");
// }
header("location: profile.php");
}
} else {
@@ -57,5 +61,4 @@ class loginException extends Exception
parent::__construct($message, $code, $previous);
}
}
?>

View File

@@ -1,39 +1,39 @@
<?php
function nicetime($date) {
if(empty($date)) {
return "No date provided";
}
$single_periods = array("seconde", "minuut", "uur", "dag", "week", "maand", "jaar", "decennium");
$multiple_periods = array("seconden", "minuten", "uur", "dagen", "weken", "maanden", "jaar", "decennia");
$lengths = array("60", "60", "24", "7", "4.35", "12", "10", "0");
$now = time();
$unix_date = strtotime($date);
if(empty($unix_date)) {
return "Bad date";
}
if($now > $unix_date) {
$difference = $now - $unix_date;
$tense = "geleden";
} else {
$difference = $unix_date - $now;
$tense = "vanaf nu";
}
for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) {
$difference /= $lengths[$i];
}
$difference = round($difference);
if($difference != 1) {
$period = $multiple_periods[$i];
} else {
$period = $single_periods[$i];
}
return "$difference $period $tense";
if(empty($date)) {
return "No date provided";
}
$single_periods = array("seconde", "minuut", "uur", "dag", "week", "maand", "jaar", "decennium");
$multiple_periods = array("seconden", "minuten", "uur", "dagen", "weken", "maanden", "jaar", "decennia");
$lengths = array("60", "60", "24", "7", "4.35", "12", "10", "0");
$now = time();
$unix_date = strtotime($date);
if(empty($unix_date)) {
return "Bad date";
}
if($now > $unix_date) {
$difference = $now - $unix_date;
$tense = "geleden";
} else {
$difference = $unix_date - $now;
$tense = "vanaf nu";
}
for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) {
$difference /= $lengths[$i];
}
$difference = round($difference);
if($difference != 1) {
$period = $multiple_periods[$i];
} else {
$period = $single_periods[$i];
}
return "$difference $period $tense";
}

138
website/queries/picture.php Normal file
View File

@@ -0,0 +1,138 @@
<?php
/**
* Uploads Avatar, checks it, and removes the old one.
* @param bool $group
* @throws AngryAlert
* @throws HappyAlert
*/
function updateAvatar(bool $group = false) {
$publicDir = "/var/www/html/public/";
$tmpImg = $_FILES["pp"]["tmp_name"];
$avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/";
checkAvatarSize($tmpImg);
if (getimagesize($tmpImg)["mime"] == "image/gif") {
if ($_FILES["pp"]["size"] > 4000000) {
throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan.");
}
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif";
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar();
move_uploaded_file($tmpImg, $publicDir . $relativePath);
} else {
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png";
$scaledImg = scaleAvatar($tmpImg);
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar();
imagepng($scaledImg, $publicDir . $relativePath);
}
$group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath);
throw new HappyAlert("Profielfoto veranderd.");
}
/**
* Removes the old avatar from the uploads folder, for a user.
*/
function removeOldUserAvatar() {
$stmt = prepareQuery("
SELECT
`profilepicture`
FROM
`user`
WHERE
`userID` = :userID
");
$stmt->bindParam(":userID", $_SESSION["userID"]);
$stmt->execute();
$old_avatar = $stmt->fetch()["profilepicture"];
if ($old_avatar != NULL) {
unlink("/var/www/html/public/uploads/" . $old_avatar);
}
}
/**
* Removes the old avatar from the uploads folder, for a group.
* @param int $groupID
*/
function removeOldGroupAvatar(int $groupID) {
$stmt = prepareQuery("
SELECT
`picture`
FROM
`group_page`
WHERE
groupID = :groupID
");
$stmt->bindParam(":groupID", $groupID);
$stmt->execute();
$old_avatar = $stmt->fetch()["picture"];
if ($old_avatar != NULL) {
unlink("/var/www/html/public/uploads/" . $old_avatar);
}
}
/**
* Inserts the the path to the avatar into the database, for Users.
* @param string $url path to the avatar
*/
function setUserAvatarToDatabase(string $url) {
$stmt = prepareQuery("
UPDATE
`user`
SET
`profilepicture` = :avatar
WHERE
`userID` = :userID
");
$stmt->bindParam(":avatar", $url);
$stmt->bindParam(":userID", $_SESSION["userID"]);
$stmt->execute();
}
/**
* Inserts the the path to the avatar into the database, for Groups.
* @param string $url path to the avatar
* @param int $groupID
*/
function setGroupAvatarToDatabase(string $url, int $groupID) {
$stmt = prepareQuery("
UPDATE
`group_page`
SET
`picture` = :avatar
WHERE
`groupID` = :groupID
");
$stmt->bindParam(":avatar", $url);
$stmt->bindParam(":groupID", $groupID);
$stmt->execute();
}
/**
* Checks the resoluton of a picture.
* @param string $img
* @throws AngryAlert
*/
function checkAvatarSize(string $img) {
$minResolution = 200;
$imgSize = getimagesize($img);
if ($imgSize[0] < $minResolution or $imgSize[1] < $minResolution) {
throw new AngryAlert("Afbeelding te klein, minimaal 200x200 pixels.");
}
}
/**
* Scales a picture, standard width is 600px.
* @param string $imgLink Path to a image file
* @param int $newWidth Custom image width.
* @return bool|resource Returns the image as an Resource.
* @throws AngryAlert
*/
function scaleAvatar(string $imgLink, int $newWidth = 600) {
$img = imagecreatefromstring(file_get_contents($imgLink));
if ($img) {
return imagescale($img, $newWidth);
} else {
throw new AngryAlert("Afbeelding wordt niet ondersteund.");
}
}

View File

@@ -1,7 +1,53 @@
<?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) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`user`.`fname`,
`user`.`lname`,
@@ -26,7 +72,7 @@ function selectPostById($postID) {
}
function selectCommentsByPostId($postID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`comment`.`commentID`,
`comment`.`postID`,
@@ -52,7 +98,7 @@ function selectCommentsByPostId($postID) {
}
function makePost($userID, $groupID, $title, $content) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
INSERT INTO
`post` (
`author`,
@@ -75,8 +121,8 @@ function makePost($userID, $groupID, $title, $content) {
$stmt->execute();
}
function makeComment($postID, $userID, $content) {
$stmt = $GLOBALS["db"]->prepare("
function makeComment($postID, $userID, $content) : int {
$stmt = prepareQuery("
INSERT INTO
`comment` (
`postID`,
@@ -94,4 +140,55 @@ function makeComment($postID, $userID, $content) {
$stmt->bindParam(':userID', $userID);
$stmt->bindParam(':content', $content);
$stmt->execute();
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 = prepareQuery("
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 = prepareQuery("
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 = prepareQuery("
DELETE FROM
`niet_slecht`
WHERE
`userID` = :userID AND
`postID` = :postID
");
$stmt->bindParam(":userID", $userID);
$stmt->bindParam(":postID", $postID);
$stmt->execute();
return $stmt->rowCount();
}

View File

@@ -1,91 +1,107 @@
<?php
function getOldChatMessages($user2ID) {
require_once ("friendship.php");
$user1ID = $_SESSION["userID"];
if (getFriendshipStatus($user2ID) == 1) {
$stmt = prepareQuery("
SELECT
*
FROM
`private_message`
WHERE
`origin` = :user1 AND
`destination` = :user2 OR
`origin` = :user2 AND
`destination` = :user1
ORDER BY
`creationdate` ASC
LIMIT
100
");
$stmt = $GLOBALS["db"]->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->bindParam(":user1", $user1ID);
$stmt->bindParam(":user2", $user2ID);
$stmt->execute();
$stmt->execute();
return json_encode($stmt->fetchAll());
return json_encode($stmt->fetchAll());
} else {
return "[]";
}
}
function sendMessage($destination, $content) {
$stmt = $GLOBALS["db"]->prepare("
INSERT INTO
`private_message`
(
`origin`,
`destination`,
`content`
)
VALUES
(
:origin,
:destination,
:content
)
");
require_once("friendship.php");
if (getFriendshipStatus($destination) == 1) {
$stmt = prepareQuery("
INSERT INTO
`private_message`
(
`origin`,
`destination`,
`content`
)
VALUES
(
:origin,
:destination,
:content
)
");
return $stmt->execute(array(
"origin" => $_SESSION["userID"],
"destination" => $destination,
"content" => $content
));
return $stmt->execute(array(
"origin" => $_SESSION["userID"],
"destination" => $destination,
"content" => $content
));
} else {
return false;
}
}
function getNewChatMessages($lastID, $destination) {
$stmt = $GLOBALS["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
");
require_once("friendship.php");
if (getFriendshipStatus($destination) == 1) {
$stmt = prepareQuery("
SELECT
*
FROM
`private_message`
WHERE
(
`origin` = :user1 AND
`destination` = :user2 OR
`origin` = :user2 AND
`destination` = :user1) AND
`messageID` > :lastID
ORDER BY
`creationdate` ASC
");
$stmt->bindParam(':user1', $_SESSION["userID"]);
$stmt->bindParam(':user2', $destination);
$stmt->bindParam(':lastID', $lastID);
$stmt->bindParam(':user1', $_SESSION["userID"]);
$stmt->bindParam(':user2', $destination);
$stmt->bindParam(':lastID', $lastID);
$stmt->execute();
$stmt->execute();
return json_encode($stmt->fetchAll());
return json_encode($stmt->fetchAll());
} else {
return "[]";
}
}
function selectAllUnreadChat() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`,
`user`.`userID`,
IFNULL(
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
LEFT(`private_message`.`content`, 15) as `content`
LEFT(`private_message`.`content`, 15) AS `content`
FROM
`private_message`,
`friendship`,
@@ -101,7 +117,8 @@ function selectAllUnreadChat() {
`friendship`.chatLastVisted2 IS NULL)) AND
`private_message`.`origin` = `user`.`userID` AND
`private_message`.`destination` = :userID AND
`user`.`role` != 'banned'
`user`.`role` != 'banned' AND
`friendship`.`status` = 'confirmed'
GROUP BY `user`.`userID`

View File

@@ -1,7 +1,7 @@
<?php
function getExistingUsername() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`username`
FROM
@@ -10,14 +10,14 @@ function getExistingUsername() {
`username` LIKE :username
");
$stmt->bindParam(":username", $_POST["username"]);
$stmt->bindValue(":username", test_input($_POST["username"]));
$stmt->execute();
return $stmt->rowCount();
}
function getExistingEmail() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`email`
FROM
@@ -26,14 +26,14 @@ function getExistingEmail() {
`email` LIKE :email
");
$stmt->bindParam(":email", $_POST["email"]);
$stmt->bindValue(":email", test_input($_POST["email"]));
$stmt->execute();
return $stmt->rowCount();
}
function getResetEmail() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`email`
FROM
@@ -42,14 +42,14 @@ function getResetEmail() {
`email` LIKE :email
");
$stmt->bindParam(":email", $_POST["forgotEmail"]);
$stmt->bindValue(":email", test_input($_POST["forgotEmail"]));
$stmt->execute();
return $stmt->rowCount();
}
function registerAccount() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
INSERT INTO
`user`(fname,
lname,
@@ -70,15 +70,21 @@ function registerAccount() {
$hash=password_hash($_POST["password"], 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->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();
}
function submitselect($date, $value){
if ($date == $value){
echo "selected";
}
}
?>

View File

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

View File

@@ -1,44 +1,14 @@
<?php
include_once "../queries/emailconfirm.php";
abstract class AlertMessage extends Exception {
public function __construct($message = "", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
abstract public function getClass();
}
class HappyAlert extends AlertMessage {
public function __construct($message = "Gelukt!", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
public function getClass() {
return "settings-message-happy";
}
}
class AngryAlert extends AlertMessage {
public function __construct($message = "Er is iets fout gegaan.", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
public function getClass() {
return "settings-message-angry";
}
}
include_once "../queries/picture.php";
include_once "../queries/alerts.php";
/**
* Gets the settings form the database.
* @return mixed Setting as an array.
*/
function getSettings() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`fname`,
`lname`,
@@ -46,7 +16,9 @@ function getSettings() {
`location`,
`birthdate`,
`bio`,
`profilepicture`
`profilepicture`,
`showBday`,
`showEmail`
FROM
`user`
WHERE
@@ -58,8 +30,12 @@ function getSettings() {
return $stmt->fetch();
}
/**
* Gets the passwordHas form the database
* @return mixed passwordhash
*/
function getPasswordHash() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`password`,
`username`
@@ -73,8 +49,12 @@ function getPasswordHash() {
return $stmt->fetch();
}
/**
* Changes the setting from post.
* @throws HappyAlert
*/
function updateSettings() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
UPDATE
`user`
SET
@@ -82,25 +62,45 @@ function updateSettings() {
`lname` = :lname,
`location` = :location,
`birthdate` = :bday,
`bio` = :bio
`bio` = :bio,
`showEmail` = :showEmail,
`showBday` = :showBday
WHERE
`userID` = :userID
");
$bday = new DateTime();
$bday->setDate(test_input($_POST["year"]), test_input($_POST["month"]), test_input($_POST["day"]));
checkBday($bday);
$stmt->bindValue(":fname", test_input($_POST["fname"]));
$stmt->bindValue(":lname", test_input($_POST["lname"]));
$stmt->bindValue(":location", test_input($_POST["location"]));
$stmt->bindValue(":bday", test_input($_POST["bday"]));
$stmt->bindValue(":bday", $bday->format("Ymd"));
$stmt->bindValue(":bio", test_input($_POST["bio"]));
$stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0"));
$stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0"));
$stmt->bindValue(":userID", $_SESSION["userID"]);
$stmt->execute();
throw new HappyAlert("Instellingen zijn opgeslagen.");
}
function checkBday(DateTime $bday) {
$today = new DateTime();
if ($bday >= $today) {
throw new AngryAlert("Jij bent vast niet in de toekomst geboren toch? ;)");
}
}
/**
* 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,8 +110,12 @@ function changePassword() {
}
}
/**
* @throws AngryAlert
* @throws HappyAlert
*/
function doChangePassword() {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
UPDATE
`user`
SET
@@ -134,8 +138,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);
@@ -149,7 +153,7 @@ function changeEmail() {
}
function emailIsAvailableInDatabase($email) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`email`
FROM
@@ -166,7 +170,7 @@ function emailIsAvailableInDatabase($email) {
}
function doChangeEmail($email) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
UPDATE
`user`
SET
@@ -187,73 +191,3 @@ function doChangeEmail($email) {
throw new AngryAlert();
}
}
function updateAvatar() {
$profilePictureDir = "/var/www/html/public/";
$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.");
}
$relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.gif";
move_uploaded_file($tmpImg, $profilePictureDir . $relativePath);
} else {
$relativePath = "uploads/profilepictures/" . $_SESSION["userID"] . "_avatar.png";
$scaledImg = scaleAvatar($tmpImg);
imagepng($scaledImg, $profilePictureDir . $relativePath);
}
setAvatarToDatabase("../" . $relativePath);
throw new HappyAlert("Profielfoto veranderd.");
}
function removeOldAvatar() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`profilepicture`
FROM
`user`
WHERE
`userID` = :userID
");
$stmt->bindParam(":userID", $_SESSION["userID"]);
$stmt->execute();
$old_avatar = $stmt->fetch()["profilepicture"];
if ($old_avatar != NULL) {
unlink("/var/www/html/public/uploads/" . $old_avatar);
}
}
function setAvatarToDatabase(string $url) {
$stmt = $GLOBALS["db"]->prepare("
UPDATE
`user`
SET
`profilepicture` = :avatar
WHERE
`userID` = :userID
");
$stmt->bindParam(":avatar", $url);
$stmt->bindParam(":userID", $_SESSION["userID"]);
$stmt->execute();
}
function checkAvatarSize(string $img) {
$minResolution = 200;
$imgSize = getimagesize($img);
if ($imgSize[0] < $minResolution or $imgSize[1] < $minResolution) {
throw new AngryAlert("Afbeelding te klein, minimaal 200x200 pixels.");
}
}
function scaleAvatar(string $imgLink, int $newWidth = 600) {
$img = imagecreatefromstring(file_get_contents($imgLink));
if ($img) {
return imagescale($img, $newWidth);
} else {
throw new AngryAlert("Afbeelding wordt niet ondersteund.");
}
}

View File

@@ -1,9 +1,22 @@
<?php
require("connect.php");
require_once ("connect.php");
function updateLastActivity() {
$stmt = prepareQuery("
UPDATE
`user`
SET
`lastactivity` = NOW()
WHERE
`userID` = :userID
");
$stmt->bindParam(":userID", $_SESSION["userID"]);
return $stmt->execute();
}
function getUserID($username) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`
FROM
@@ -18,7 +31,7 @@ function getUserID($username) {
}
function getUsername($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`username`
FROM
@@ -33,8 +46,9 @@ function getUsername($userID) {
}
function selectUser($me, $other) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`,
`username`,
`birthdate`,
`location`,
@@ -44,7 +58,11 @@ function selectUser($me, $other) {
) AS profilepicture,
`bio`,
`user`.`creationdate`,
`onlinestatus`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role`,
`fname`,
`lname`,
CASE `status` IS NULL
@@ -80,7 +98,7 @@ function selectUser($me, $other) {
}
function selectAllUserGroups($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`group_page`.`groupID`,
`name`,
@@ -94,7 +112,7 @@ function selectAllUserGroups($userID) {
`group_page`.`groupID` = `group_member`.`groupID`
WHERE
`userID` = :userID AND
`role` = 1
`role` = 'member'
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
@@ -102,38 +120,8 @@ function selectAllUserGroups($userID) {
return $stmt;
}
function selectAllUserPosts($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`postID`,
`author`,
`title`,
CASE LENGTH(`content`) >= 150 AND `content` NOT LIKE '<img%'
WHEN TRUE THEN
CONCAT(LEFT(`content`, 150), '...')
WHEN FALSE THEN
`content`
END
AS `content`,
`creationdate`
FROM
`post`
WHERE
`author` = :userID AND
`groupID` IS NULL
ORDER BY
`creationdate` DESC
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
if(!$stmt->execute()) {
return False;
}
return $stmt;
}
function select20UsersFromN($n) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`userID`,
`username`,
@@ -154,7 +142,7 @@ function select20UsersFromN($n) {
}
function search20UsersFromN($n, $keyword) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`userID`,
`username`,
@@ -178,7 +166,7 @@ function search20UsersFromN($n, $keyword) {
}
function search20UsersFromNByStatus($n, $keyword, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`userID`,
`username`,
@@ -206,7 +194,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
}
function searchSomeUsersByStatus($n, $m, $keyword, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
`userID`,
`username`,
@@ -235,7 +223,7 @@ function searchSomeUsersByStatus($n, $m, $keyword, $status) {
}
function countSomeUsersByStatus($keyword, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
COUNT(*)
FROM
@@ -258,7 +246,7 @@ function countSomeUsersByStatus($keyword, $status) {
function changeUserStatusByID($id, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
UPDATE
`user`
SET
@@ -274,7 +262,7 @@ function changeUserStatusByID($id, $status) {
}
function changeMultipleUserStatusByID($ids, $status) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
UPDATE
`user`
SET
@@ -290,8 +278,27 @@ function changeMultipleUserStatusByID($ids, $status) {
return $q;
}
function changeMultipleUserStatusByIDAdmin($ids, $status) {
$q = prepareQuery("
UPDATE
`user`
SET
`role` = :status
WHERE
FIND_IN_SET (`userID`, :ids)
AND NOT `role` = 'admin'
AND NOT `role` = 'owner'
");
$ids = implode(',', $ids);
$q->bindParam(':ids', $ids);
$q->bindParam(':status', $status);
$q->execute();
return $q;
}
function selectRandomNotFriendUser($userID) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`user`.`username`
FROM
@@ -319,7 +326,7 @@ function selectRandomNotFriendUser($userID) {
}
function searchSomeUsers($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare("
$stmt = prepareQuery("
SELECT
`userID`,
`username`,
@@ -331,9 +338,10 @@ function searchSomeUsers($n, $m, $search) {
FROM
`user`
WHERE
`username` LIKE :keyword OR
(`username` LIKE :keyword OR
`fname` LIKE :keyword OR
`lname` LIKE :keyword
`lname` LIKE :keyword) AND
`role` != 'banned'
ORDER BY
`fname`,
`lname`,
@@ -353,15 +361,16 @@ function searchSomeUsers($n, $m, $search) {
}
function countSomeUsers($search) {
$q = $GLOBALS["db"]->prepare("
$q = prepareQuery("
SELECT
COUNT(*)
FROM
`user`
WHERE
`username` LIKE :keyword OR
(`username` LIKE :keyword OR
`fname` LIKE :keyword OR
`lname` LIKE :keyword
`lname` LIKE :keyword) AND
`role` != 'banned'
ORDER BY
`fname`,
`lname`,
@@ -373,3 +382,33 @@ function countSomeUsers($search) {
$q->execute();
return $q;
}
function getRoleByID($userID) {
$stmt = prepareQuery("
SELECT
`role`
FROM
`user`
WHERE
`userID` = :userID
");
$stmt->bindParam(':userID', $userID);
$stmt->execute();
return $stmt->fetch()["role"];
}
function editBanCommentByID($userID, $comment) {
$stmt = prepareQuery("
UPDATE
`user`
SET
`bancomment` = :comment
WHERE
`userID` = :userID
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->bindParam(':comment', $comment);
$stmt->execute();
}

View File

@@ -0,0 +1,46 @@
<tr>
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)"></th>
<th class="table-username">Gebruikersnaam</th>
<th class="table-status">Status</th>
<th class="table-comment">Aantekening</th>
<th class="table-action">Actie</th>
</tr>
<?php
print_r($_POST);
$q = searchSomeGroupsByStatus($offset, $entries, $search, $groupstatus);
while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
$groupID = $group['groupID'];
$name = $group['name'];
$role = $group['status'];
$description = $group['description'];
echo("
<tr>
<td><input type='checkbox'
name='checkbox-group[]'
class='checkbox-list'
value='$groupID'
form='admin-groupbatchform'
onchange='checkCheckAll();'>
</td>
<td>$name</td>
<td>$role</td>
<td>$description</td>
<td>
<form class='admin-groupaction'
onsubmit=\"adminUpdate(this); return false;\">
<select class='action' name='actions'>
<option value='hidden'>Hidden</option>
<option value='public'>Public</option>
<option value='membersonly'>Members</option>
</select>
<input type='hidden' name='groupID' value='$groupID'>
<input type='submit' value='Confirm'>
</form>
</td>
</tr>
");
}

View File

@@ -0,0 +1,30 @@
<?php
if ($pagetype == "user") {
$pages = countSomeUsersByStatus($search, $status);
} else {
$pages = countSomeGroupsByStatus($search, $groupstatus);
}
$countresults = $pages->fetchColumn();
?>
Pagina:
<select class="admin-pageselect"
name="currentpage"
id="currentpage"
form="admin-searchform"
onchange="adminSearch();">
<?php
for ($i=1; $i <= ceil($countresults / $entries); $i++) {
if ($currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
?>
</select>
<?php
$n = min($offset + 1, $countresults);
$m = min($offset + $entries, $countresults);
echo " $n tot $m ($countresults totaal)";
?>

View File

@@ -0,0 +1,73 @@
<tr>
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
<th class="table-username">Gebruikersnaam</th>
<th class="table-status">Status</th>
<th class="table-comment">Aantekening</th>
<th class="table-action">Actie</th>
</tr>
<!-- Table construction via php PDO. -->
<?php
$q = searchSomeUsersByStatus($offset, $entries, $search, $status);
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
$userID = $user['userID'];
$username = $user['username'];
$role = $user['role'];
$bancomment = $user['bancomment'];
echo("
<tr>
<td>
<input type='checkbox'
name='checkbox-user[]'
class='checkbox-list'
value='$userID'
form='admin-batchform'
onchange='checkCheckAll();'>
</td>
<td>$username</td>
<td>$role</td>
<td>
<div class='bancomment'>$bancomment</div>
<div class='bancommentedit'>
<form class='bancommentform'
id='bancommentform'
onsubmit='editComment(this);
return false;'>
<input type='text'
name='bancommenttext'
placeholder='Schrijf een aantekening'
value='$bancomment'>
<input type='hidden'
name='bancommentuserID'
value='$userID'>
<button type='submit'>Update</button>
</form>
</div>
<button type='button' onclick='toggleBancomment(this)'>Verander</button>
</td>
<td>
<form class='admin-useraction'
onsubmit=\"adminUpdate(this); return false;\">
<select class='action' name='actions'>");
if (!($userinfo == 'admin'
AND ($user['role'] == 'admin'
OR $user['role'] == 'owner'))) {
echo "<option value='frozen'>Bevries</option>
<option value='banned'>Ban</option>
<option value='user'>Activeer</option>";
if ($userinfo == 'owner') {
echo "<option value='admin'>Admin</option>
<option value='owner'>Owner</option>";
}
}
echo ("</select>
<input type='hidden' name='userID' value='$userID'>
<input type='submit' value='Confirm'>
</form>
</td>
</tr>
");
}

View File

@@ -1,15 +1,11 @@
<script src="js/admin.js" charset="utf-8"></script>
<?php
require_once ("../queries/user.php");
require_once ("../queries/group_page.php");
?>
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
<?php
$search = "";
$currentpage = 1;
$perpage = 20;
$status = $groupstatus = array();
$status = array("user", "frozen", "banned", "unconfirmed", "admin", "owner");
$groupstatus = array("hidden", "public", "membersonly");
$pagetype = "user";
$userinfo = getRoleByID($_SESSION['userID']);
if (isset($_GET["search"])) {
$search = test_input($_GET["search"]);
@@ -27,33 +23,6 @@ if (isset($_GET["groupstatus"])) {
$groupstatus = $_GET["groupstatus"];
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
}
if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
}
if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
}
if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
}
if (isset($_POST["pageselect"])) {
$currentpage = $_POST["pageselect"];
}
}
$listn = ($currentpage-1) * $perpage;
$listm = $currentpage * $perpage;
?>
<div class="content">
@@ -61,19 +30,21 @@ $listm = $currentpage * $perpage;
<h5>Zoek naar gebruikers of groepen:</h5>
<div class="admin-options">
<form class="admin-searchform"
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
id="admin-searchform"
action="javascript:searchFromOne();"
method="get">
<div class="admin-searchbar">
Zoek: <input type="text"
name="search"
class="admin-searchinput"
placeholder="Naam"
value="<?php echo $search;?>">
Op: <select name="pagetype" id="pagetype" onchange="changeFilter()">
name="search"
class="admin-searchinput"
placeholder="Naam"
value="<?php echo $search;?>">
Op: <select name="pagetype" id="pagetype" onchange="changeFilter()">
<option value="user"
<?php if (isset($pagetype) && $pagetype=="user") echo "selected";?>>
Gerbuiker
Gebruiker
</option>
<option value="group"
<?php if (isset($pagetype) && $pagetype=="group") echo "selected";?>>
@@ -82,210 +53,102 @@ $listm = $currentpage * $perpage;
</select>
<button type="submit"><i class="fa fa-search"></i></button>
</div>
<div id="admin-filter">
<h5>Type gebruiker:</h5>
<input type="checkbox"
name="status[]"
id="all"
value="all"
<?php if (in_array("all", $status)) echo "checked";?>>
<label for="normal">Allemaal</label><br>
<input type="checkbox"
name="status[]"
id="normal"
value="user"
<?php if (in_array("user", $status)) echo "checked";?>>
<label for="normal">Normal</label><br>
<?php if (in_array("user", $status)) echo "checked";?>>
<label for="normal">Normaal</label><br>
<input type="checkbox"
name="status[]"
id="frozen"
value="frozen"
<?php if (in_array("frozen", $status)) echo "checked";?>>
<label for="frozen">Frozen</label><br>
<?php if (in_array("frozen", $status)) echo "checked";?>>
<label for="frozen">Gefrozen</label><br>
<input type="checkbox"
name="status[]"
id="banned"
value="banned"
<?php if (in_array("banned", $status)) echo "checked";?>>
<label for="banned">Banned</label><br>
<?php if (in_array("banned", $status)) echo "checked";?>>
<label for="banned">Gebant</label><br>
<input type="checkbox"
name="status[]"
id="admin"
value="admin"
<?php if (in_array("admin", $status)) echo "checked";?>>
<?php if (in_array("admin", $status)) echo "checked";?>>
<label for="admin">Admin</label><br>
<input type="checkbox"
name="status[]"
id="unvalidated"
value="unconfirmed"
<?php if (in_array("unconfirmed", $status)) echo "checked";?>>
<label for="unvalidated">Unvalidated</label><br>
<?php if (in_array("unconfirmed", $status)) echo "checked";?>>
<label for="unvalidated">Ongevalideerd</label><br>
<input type="checkbox"
name="status[]"
id="owner"
value="owner"
<?php if (in_array("owner", $status)) echo "checked";?>>
<?php if (in_array("owner", $status)) echo "checked";?>>
<label for="owner">Owner</label>
</div>
<div id="admin-groupfilter">
<h5>Type groep:</h5>
<input type="checkbox" name="groupstatus[]" id="all" value="all"
<?php if (in_array("all", $groupstatus)) echo "checked";?>>
<label for="hidden">Allemaal</label><br>
<input type="checkbox" name="groupstatus[]" id="hidden" value="0"
<?php if (in_array("0", $groupstatus)) echo "checked";?>>
<label for="hidden">Hidden</label><br>
<input type="checkbox" name="groupstatus[]" id="public" value="1"
<?php if (in_array("1", $groupstatus)) echo "checked";?>>
<label for="public">Public</label><br>
<input type="checkbox" name="groupstatus[]" id="membersonly" value="2"
<?php if (in_array("2", $groupstatus)) echo "checked";?>>
<label for="membersonly">Members-only</label><br>
<input type="checkbox" name="groupstatus[]" id="hidden" value="hidden"
<?php if (in_array("hidden", $groupstatus)) echo "checked";?>>
<label for="hidden">Verborgen</label><br>
<input type="checkbox" name="groupstatus[]" id="public" value="public"
<?php if (in_array("public", $groupstatus)) echo "checked";?>>
<label for="public">Publiek</label><br>
<input type="checkbox" name="groupstatus[]" id="membersonly" value="membersonly"
<?php if (in_array("membersonly", $groupstatus)) echo "checked";?>>
<label for="membersonly">Alleen Leden</label><br>
</div>
</form>
</div>
<div class="admin-users">
<div class="admin-usertitle">
<h4>Resultaat:</h4>
<span style="float: right">
<?php
if ($pagetype == "user") {
$pages = countSomeUsersByStatus($search, $status);
} else {
$pages = countSomeGroupsByStatus($search, $groupstatus);
}
$countresults = $pages->fetchColumn();
$mincount = min($listm, $countresults);
$minlist = min($listn + 1, $countresults);
?>
Pagina: <form class="admin-pageselector"
action="<?php htmlspecialchars(basename($_SERVER['REQUEST_URI'])) ?>"
method="post">
<select class="admin-pageselect"
name="pageselect"
onchange="this.form.submit()"
value="">
<?php
for ($i=1; $i <= ceil($countresults / $perpage); $i++) {
if ($currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
?>
</select>
</form>
<?php
echo "$minlist tot $mincount ($countresults totaal)";
?>
</span>
<form
id="admin-batchform"
action="<?php htmlspecialchars(basename($_SERVER['REQUEST_URI'])) ?>"
method="post">
</div>
<div class="admin-users">
<div class="admin-usertitle">
<h4>Resultaat:</h4>
<div style="float: right" id="admin-pageinfo">
</div>
<form id="admin-batchform"
onsubmit="adminUpdate(this); return false;">
<input type="hidden" name="batchactions" id="batchinput">
<button type="submit" name="batchactions" id="freeze" value="frozen">Bevries</button>
<button type="submit" name="batchactions" id="ban" value="banned">Ban</button>
<button type="submit" name="batchactions" id="restore" value="user">Activeer</button>
</form>
</div>
<table class="usertable">
<tr>
<th><input type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)"></th>
<th class="table-username">Gebruikersnaam</th>
<th class="table-status">Status</th>
<th class="table-comment">Aantekening</th>
<th class="table-action">Actie</th>
</tr>
<!-- Table construction via php PDO. -->
<?php
$listn = ($currentpage-1) * $perpage;
$listm = $currentpage * $perpage;
if ($pagetype == 'user') {
$q = searchSomeUsersByStatus($listn, $listm, $search, $status);
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
$userID = $user['userID'];
$username = $user['username'];
$role = $user['role'];
$bancomment = $user['bancomment'];
$thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI']));
$function = "checkCheckAll(document.getElementById('checkall'))";
echo("
<tr>
<td><input type='checkbox'
name='checkbox-user[]'
class='checkbox-list'
value='$userID'
form='admin-batchform'
onchange=" . "$function" . ">
</td>
<td>$username</td>
<td>$role</td>
<td>$bancomment</td>
<td>
<form class='admin-useraction'
action='$thispage'
method='post'>
<select class='action' name='actions'>
<option value='frozen'>Bevries</option>
<option value='banned'>Ban</option>
<option value='user'>Activeer</option>
</select>
<input type='hidden' name='userID' value='$userID'>
<input type='submit' value='Confirm'>
</form>
</td>
</tr>
");
}
} else {
$q = searchSomeGroupsByStatus($listn, $listm, $search, $groupstatus);
while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
$groupID = $group['groupID'];
$name = $group['name'];
$role = $group['status'];
$description = $group['description'];
$thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI']));
$function = "checkCheckAll(document.getElementById('checkall'))";
echo("
<tr>
<td><input type='checkbox'
name='checkbox-group[]'
class='checkbox-list'
value='$groupID'
form='admin-groupbatchform'
onchange=" . "$function" . ">
</td>
<td>$name</td>
<td>$role</td>
<td>$description</td>
<td>
<form class='admin-groupaction'
action='$thispage'
method='post'>
<select class='action' name='actions'>
<option value='0'>Hide</option>
<option value='1'>Public</option>
<option value='2'>Members</option>
</select>
<input type='hidden' name='groupID' value='$groupID'>
<input type='submit' value='Confirm'>
</form>
</td>
</tr>
");
}
if ($userinfo == 'owner') {
echo "<button type=\"submit\"
name=\"batchactions\"
id=\"admin\"
value=\"admin\">Maak Admin</button>
<button type=\"submit\"
name=\"batchactions\"
id=\"owner\"
value=\"owner\">Maak Owner</button>";
}
?>
</table>
</form>
<form id="admin-groupbatchform"
onsubmit="adminUpdate(this); return false;">
<input type="hidden" name="groupbatchactions" id="groupbatchinput">
<button type="submit" name="batchactions" id="hide" value="hidden">Hide</button>
<button type="submit" name="batchactions" id="ban" value="public">Public</button>
<button type="submit" name="batchactions" id="members" value="membersonly">Members</button>
</form>
</div>
<table class="usertable" id="usertable">
</table>
</div>
</div>
</div>
</body>

View File

@@ -0,0 +1,37 @@
<select name="day_date" >
<option>dag</option>
<?php
for($i=1; $i<32; $i++) {
$i = sprintf("%02d", $i);
?>
<option value="<?= $i ?>" <?php submitselect($day_date, $i)?>><?= $i ?></option>
<?php
}
?>
</select>
<select name="month_date">
<option>Maand</option>
<option value="01" <?php submitselect($month_date, "01")?>>januari</option>
<option value="02" <?php submitselect($month_date, "02")?>>februari</option>
<option value="03" <?php submitselect($month_date, "03")?>>maart</option>
<option value="04" <?php submitselect($month_date, "04")?>>april</option>
<option value="05" <?php submitselect($month_date, "05")?>>mei</option>
<option value="06" <?php submitselect($month_date, "06")?>>juni</option>
<option value="07" <?php submitselect($month_date, "07")?>>juli</option>
<option value="08" <?php submitselect($month_date, "08")?>>augustus</option>
<option value="09" <?php submitselect($month_date, "09")?>>september</option>
<option value="10" <?php submitselect($month_date, "10")?>>oktober</option>
<option value="11" <?php submitselect($month_date, "11")?>>november</option>
<option value="12" <?php submitselect($month_date, "12")?>>december</option>
</select>
<select name="year_date">
<option>Jaar</option>
<?php
$year = (new DateTime)->format("Y");
for($i=$year; $i > $year - 100; $i--) {
?>
<option value="<?= $i ?>" <?php submitselect($year_date, $i)?>><?= $i ?></option>
<?php
}
?>
</select>

View File

@@ -74,6 +74,7 @@
name="content"
id="newContent"
placeholder="Schrijf een bericht..."
autocomplete="off"
autofocus
required
/>

View File

@@ -0,0 +1,36 @@
<!-- Trigger/Open The Modal -->
<button id="myBtn" class="button">Wachtwoord vergeten</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post"
name="forgotPassword">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">&times;</span>
<h3>Voer uw emailadres in</h3>
</div>
<div class="modal-body">
<input type="text"
class="middle"
placeholder="Voer uw email in"
name="forgotEmail"
title="Voer een email in">
</div>
<div class="modal-footer">
<div class="login_containerfault"><span><?php echo $resetErr; ?></span></div>
<button type="submit"
value="reset"
name="submit"
id="frm1_submit">
Reset password
</button>
</div>
</div>
</form>
</div>

View File

@@ -1,122 +1,36 @@
<div class="content">
<div class="profile-box platform">
<img class="left group-picture" src="http://i.imgur.com/afjEUx2.jpg">
<img class="left main-picture" src="<?= $group['picture'] ?>">
<div class="profile-button">
<p><img src="img/leave-group.png"> Groep verlaten</p>
</div>
<h1 class="profile-username">[groepnaam]</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dictum turpis quam, eu ultrices sapien hendrerit tincidunt. Nunc aliquam neque turpis, id porta quam iaculis id. Sed suscipit, nisl a fermentum congue, nunc augue finibus lectus, id varius nunc purus nec dolor. Integer laoreet tellus sit amet sapien auctor congue. Mauris laoreet eu elit vel rhoncus. Nam et tortor arcu. Maecenas sit amet leo quis tellus varius gravida. Sed quis fermentum odio, sed dictum nulla. Donec aliquam rutrum orci cursus tempus. Quisque sit amet ipsum eget velit aliquam facilisis ultricies quis ligula. Nunc nisi lacus, luctus non bibendum quis, sagittis sit amet odio.</p>
<h1 class="profile-username"><?= $group['name'] ?></h1>
<p><?= $group['description'] ?></p>
</div>
<div class="item-box-full-width platform">
<h2>Leden</h2>
<h2>Leden (<?= $group['members'] ?>)</h2>
<p>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#" data-title="[gebruikersnaam]"><img class="profile-picture" src="http://i.imgur.com/afjEUx2.jpg" alt="[gebruikersnaam]'s profielfoto"></a>
<a href="#vrienden">...en nog 25 anderen!</a>
<?php
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\"></a>";
}
?>
</p>
</div>
<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 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/header.js"></script>
<script src="js/menu.js"></script>
<script src="js/notifications.js"></script>
<style>
/* Add your css files here. */
@import url("styles/main.css");
@@ -13,14 +12,19 @@
@import url("styles/header.css");
@import url("styles/menu.css");
@import url("styles/footer.css");
@import url("styles/mobilefriendly.css") screen and (orientation: portrait);
</style>
<?php
require_once ("../queries/checkInput.php");
require_once ("../queries/connect.php");
require_once ("../queries/user.php");
session_start();
if(!isset($_SESSION["userID"])){
header("location:login.php");
} else {
updateLastActivity();
}

View File

@@ -25,8 +25,7 @@ $userinfo = getHeaderInfo();
</div>
<?=$userinfo["fname"]?>
</div>
<img id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/>
<i id="open-notifications" class="fa fa-bars"></i>
<img id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/><i id="open-notifications" class="fa fa-bars"></i>
</div>
</header>
<?php include("notification-center.php"); ?>

View File

@@ -13,12 +13,13 @@
<!-- Login name -->
<div class="login_containerlogin">
<label><b>Gebruikersnaam</b></label>
<label><b>Gebruikersnaam/Email</b></label>
<input type="text"
placeholder="Voer uw gebruikersnaam in"
name="uname"
value="<?php echo $uname ?>"
title="Moet 6 of meer karakters bevatten"
class="middle"
placeholder="Voer uw gebruikersnaam/email in"
name="user"
value="<?php echo $user ?>"
title="Moet een geldige gebruiker zijn"
>
</div>
@@ -26,6 +27,7 @@
<div class="login_containerlogin">
<label><b>Wachtwoord</b></label>
<input type="password"
class="middle"
placeholder="Voer uw wachtwoord in"
name="psw"
title="Moet minstens 8 karakters lang zijn"
@@ -44,73 +46,65 @@
Inloggen
</button>
</div>
<div class="login_containerlogin">
<label><b>Onthoud mij</b></label>
<input type="checkbox" name="rememberMe" value=1><br>
</div>
</form>
</div>
<!-- Button for going to the register screen -->
<div class="login_containerlogin">
<a href="https://myhyvesbookplus.nl/register" class="button">Registreer een account</a>
<!-- Button for going to the register screen -->
<div class="login_containerlogin">
<!-- <a href="https://myhyvesbookplus.nl/register" class="button">Registreer een account</a>-->
<!-- Trigger/Open The Modal -->
<button id="myBtn" class="button">Wachtwoord vergeten</button>
<?php
include("../views/forgotPasswordModal.php");
include("../views/registerModal.php");
?>
<!-- The Modal -->
<div id="myModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post"
name="forgotPassword">
</div>
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">&times;</span>
<h3>Voer uw emailadres in</h3>
</div>
<div class="modal-body">
<input type="text"
placeholder="Voer uw email in"
name="forgotEmail"
title="Voer een email in">
</div>
<div class="modal-footer">
<div class="login_containerfault"><span><?php echo $resetErr; ?></span></div>
<button type="submit"
value="reset"
name="submit"
id="frm1_submit">
Reset password
</button>
</div>
</div>
</form>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the modal
var registerModal = document.getElementById('registerModal');
var registerBtn = document.getElementById("registerBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
var registerSpan = document.getElementsByClassName("close")[1];
// When the user clicks the button, open the modal
btn.onclick = function() {
// When the user clicks the button, open the modal
btn.onclick = function () {
// modal.style.display = "block";
modal.style.display = "block";
window.onload=emailSent();
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
registerBtn.onclick = function () {
registerModal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
}
registerSpan.onclick = function () {
registerModal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
// 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";
}
}
</script>

View File

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

View File

@@ -5,14 +5,14 @@ function messagePage(string $content) {
<html>
<head>
<style>
@import url(styles/main.css);
@import url(styles/settings.css);
@import url(styles/resetpassword.css);
@import url(../styles/main.css);
@import url(../styles/settings.css);
@import url(../styles/message-page.css);
</style>
</head>
<body>
<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>
</body>

View File

@@ -1,9 +1,20 @@
<nav class="menu" id="notification-center">
<section id="quick-links">
<a href="chat.php"><i class="fa fa-comments-o" data-title="Prive chats"></i></a>
<a href="settings.php"><i class="fa fa-cog" data-title="Instellingen"></i></a>
<a href="profile.php"><i class="fa fa-user" data-title="Profiel"></i></a>
<a href="logout.php"><i class="fa fa-sign-out" data-title="Uitloggen"></i></a>
<a href="chat.php" data-title="Prive chats"><i class="fa fa-comments-o"></i></a>
<a href="settings.php" data-title="Instellingen"><i class="fa fa-cog"></i></a>
<a href="profile.php" data-title="Profiel"><i class="fa fa-user"></i></a>
<?php
include_once ("../queries/user.php");
// auth
$role = getRoleByID($_SESSION['userID']);
if ($role == 'admin' OR $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 id="friend-request-section">
<h4>

View File

@@ -2,6 +2,7 @@
$postID = $_GET['postID'];
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
session_start();
echo("
<div class='post-header header'>
@@ -21,10 +22,19 @@ echo("
<div class='post-comments'>
<div class="commentfield">
<form id="newcommentform" action="javascript:postComment();">
<form id="newcommentform" onsubmit="return false;">
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
<input type="submit" value="Reageer!">
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..." maxlength="1000"></textarea><span></span> <br>
<button onclick="postComment('reaction')" name="button" value="reaction">Reageer!</button>
<button onclick="postComment('nietslecht')" name="button" value="nietslecht" class="nietslecht">
<?php
if (checkNietSlecht($postID, $_SESSION["userID"])) {
echo 'Trek <span class="nietslecht-text">"Niet slecht."</span> terug';
} else {
echo '<img src="img/nietslecht_small.png" /> <span class="nietslecht-text">"Niet slecht."</span>';
}
?>
</button>
</form>
</div>
@@ -40,7 +50,7 @@ echo("
<div class='comment'>
<div class='commentinfo'>
$commentauthor
<span class='commentdate', title='$commentdate'>
<span class='commentdate' title='$commentdate'>
$commentnicetime
</span>
</div>

View File

@@ -1,18 +1,43 @@
<div class="content">
<div class="profile-box platform">
<img class="left profile-picture" src="<?php echo $user["profilepicture"] ?>">
<div class="friend-button-container">
<div class="user-box">
<img class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br />
<div class="platform">
<div class="status-buttons-container">
<button disabled class="gray">
<?= $user["onlinestatus"] ?>
</button>
<button disabled class="gray"><?= $user["role"] ?></button>
</div>
<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>";
} ?>
<h1 class="profile-username"><?= $user["fname"]?> <?=$user["lname"]?></h1>
<h5 class="profile-username"><?=$user["username"]?></h5>
<p><?=$user["bio"]?></p>
<div class="item-box platform">
<h3>Informatie</h3>
<p>
<ul>
<li>Leeftijd: <?= getAge($user["birthdate"]) ?> jaar</li>
<li>Locatie: <?= $user["location"] ?></li>
<li>Lid sinds: <?= nicetime($user["creationdate"]) ?></li>
</ul>
</p>
</div>
<div class="item-box left platform">
<h2>Vrienden</h2>
<div class="item-box platform">
<h3>Vrienden</h3>
<p>
<?php
while($friend = $profile_friends->fetch()) {
@@ -27,12 +52,12 @@
</p>
</div>
<div class="item-box right platform">
<h2>Groepen</h2>
<div class="item-box platform">
<h3>Groepen</h3>
<p>
<?php
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) {

View File

@@ -40,14 +40,44 @@
<!-- Register birthday -->
<div class="login_containerregister">
<label><b>Geboortedatum</b></label>
<input type="text"
name="bday"
value="<?php echo $bday ?>"
id="bday"
placeholder="1996/01/01"
data-fv-date-max=""
>
<label><b>Geboortedatum(Dag/Maand/Jaar)</b></label>
<select name="day_date" >
<option>dag</option>
<?php
for($i=1; $i<32; $i++) {
$i = sprintf("%02d", $i);
?>
<option value="<?= $i ?>" <?php submitselect($day_date, $i)?>><?= $i ?></option>
<?php
}
?>
</select>
<select name="month_date">
<option>Maand</option>
<option value="01" <?php submitselect($month_date, "01")?>>Januari</option>
<option value="02" <?php submitselect($month_date, "02")?>>Februari</option>
<option value="03" <?php submitselect($month_date, "03")?>>Maart</option>
<option value="04" <?php submitselect($month_date, "04")?>>April</option>
<option value="05" <?php submitselect($month_date, "05")?>>Mei</option>
<option value="06" <?php submitselect($month_date, "06")?>>Juni</option>
<option value="07" <?php submitselect($month_date, "07")?>>Juli</option>
<option value="08" <?php submitselect($month_date, "08")?>>Augustus</option>
<option value="09" <?php submitselect($month_date, "09")?>>September</option>
<option value="10" <?php submitselect($month_date, "10")?>>Oktober</option>
<option value="11" <?php submitselect($month_date, "11")?>>November</option>
<option value="12" <?php submitselect($month_date, "12")?>>December</option>
</select>
<select name="year_date">
<option>Jaar</option>
<?php
$year = (new DateTime)->format("Y");
for($i=$year; $i > $year - 100; $i--) {
?>
<option value="<?= $i ?>" <?php submitselect($year_date, $i)?>><?= $i ?></option>
<?php
}
?>
</select>
*<span class="error"> <?php echo $bdayErr;?></span>
</div>
@@ -118,6 +148,18 @@
*<span class="error"> <?php echo $emailErr;?></span>
</div>
<!-- Register email -->
<div class="login_containerregister">
<label><b>Herhaal email</b></label>
<input type="text"
placeholder="Herhaal uw email"
name="confirmEmail"
value="<?php echo $confirmEmail ?>"
id="email"
title="Herhaal uw email">
*<span class="error"> <?php echo $confirmEmailErr;?></span>
</div>
<div class="login_containerregister">
<div class="g-recaptcha" data-sitekey="6Lc72xIUAAAAADumlWetgENm7NGd9Npyo0c_tYYQ"></div>
<span class="error"> <?php echo $captchaErr;?></span>

View File

@@ -0,0 +1,158 @@
<!-- Trigger/Open The Modal -->
<button id="registerBtn" class="button">Registreer een account</button>
<!-- The Modal -->
<div id="registerModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post"
name="forgotPassword">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">&times;</span>
<h3>Registreer uw account</h3>
</div>
<div class="modal-body">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post">
<div class="login_containerregister"><label>U krijgt een bevestigingsemail na het registreren</label></div>
<!-- Error message -->
<div class="login_containerfault"><?php echo $genericErr;?></span></div>
<!-- Register name -->
<div class="login_containerregister">
<label><b>Naam</b></label>
<input type="text"
placeholder="Voer uw naam in"
name="name"
value="<?php echo $name ?>"
title="Mag alleen letters bevatten"
>
*<span class="error"><?php echo $nameErr;?></span>
</div>
<!-- Register surname -->
<div class="login_containerregister">
<label><b>Achternaam</b></label>
<input type="text"
placeholder="Voer uw achternaam in"
name="surname"
value="<?php echo $surname ?>"
title="Mag alleen letters bevatten"
>
*<span class="error"> <?php echo $surnameErr;?></span>
</div>
<!-- Register birthday -->
<div class="login_containerregister">
<label><b>Geboortedatum</b></label>
<?php
include("../views/bdayInput.php");
?>
*<span class="error"> <?php echo $bdayErr;?></span>
</div>
<!-- Register username -->
<div class="login_containerregister">
<label><b>Gebruikersnaam</b></label>
<input type="text"
placeholder="Voer uw gebruikersnaam in"
name="username"
value="<?php echo $username ?>"
title="Moet minimaal 6 karakters bevatten"
>
*<span class="error"> <?php echo $usernameErr;?></span>
<ul>
<li>Minstens 6 karakters</li>
</ul>
</div>
<!-- Register password -->
<div class="login_containerregister">
<label><b>Wachtwoord</b></label>
<input type="password"
placeholder="Voer uw wachtwoord in"
name="password"
value="<?php echo $password ?>"
id="password"
>
*<span class="error"> <?php echo $passwordErr;?></span>
<ul>
<li>Minstens 8 karakters</li>
</ul>
</div>
<!-- Repeat password -->
<div class="login_containerregister">
<label><b>Herhaal wachtwoord</b></label>
<input type="password"
placeholder="Herhaal wachtwoord"
name="confirmpassword"
value="<?php echo $confirmpassword ?>"
id="confirmpassword"
title="Herhaal wachtwoord"
>
*<span class="error"> <?php echo $confirmpasswordErr;?></span>
</div>
<!-- Register location -->
<div class="login_containerregister">
<label><b>Locatie</b></label>
<input type="text"
placeholder="Voer uw woonplaats in"
name="location"
value="<?php echo $location ?>"
pattern="[A-Za-z]{1,}"
title="Mag alleen letters bevatten">
*<span class="error"> <?php echo $locationErr;?></span>
</div>
<!-- Register email -->
<div class="login_containerregister">
<label><b>Email</b></label>
<input type="text"
placeholder="Voer uw email in"
name="email"
value="<?php echo $email ?>"
id="email"
title="Voer een geldige email in">
*<span class="error"> <?php echo $emailErr;?></span>
</div>
<!-- Register email -->
<div class="login_containerregister">
<label><b>Herhaal email</b></label>
<input type="text"
placeholder="Herhaal uw email"
name="confirmEmail"
value="<?php echo $confirmEmail ?>"
id="email"
title="Herhaal uw email">
*<span class="error"> <?php echo $confirmEmailErr;?></span>
</div>
<div class="login_containerregister">
<div class="g-recaptcha" data-sitekey="6Lc72xIUAAAAADumlWetgENm7NGd9Npyo0c_tYYQ">
</div>
<span class="error"> <?php echo $captchaErr;?></span>
</div>
</div>
<div class="modal-footer">
<div class="login_containerfault"><span><?php echo $resetErr; ?></span></div>
<button type="submit"
value="register"
name="submit"
id="frm1_submit">
Registreer
</button>
</div>
</div>
</form>
</div>

View File

@@ -21,10 +21,8 @@ if (isset($_GET['filter'])) {
}
$user_n = ($user_currentpage - 1) * $user_perpage;
$user_count = countSomeUsers($search)->fetchColumn();
$group_n = ($group_currentpage - 1) * $group_perpage;
$group_count = countSomeGroups($search)->fetchColumn();
?>
<div class="content">
@@ -40,8 +38,10 @@ $group_count = countSomeGroups($search)->fetchColumn();
id="search-input"
name="search"
onkeyup="
searchUsers(<?= $user_n ?>, <?= $user_perpage ?>);
searchGroups(<?= $group_n ?>, <?= $group_perpage ?>);"
$('#user-pagenumber, #group-pagenumber').prop('value', 1);
searchUsers();
searchGroups();
pageNumber();"
placeholder="Zoek"
value=<?php echo "$search";?>
>
@@ -66,26 +66,12 @@ $group_count = countSomeGroups($search)->fetchColumn();
<div class="platform item-box searchleft" id="search-friends-output">
<h4>Gebruikers</h4>
<select class="user-pageselect"
name="user-pageselect"
id="user-pageselect"
form="search-form"
onchange="this.form.submit()">
<?php
for ($i=1; $i <= ceil($user_count / $user_perpage); $i++) {
if ($user_currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
?>
</select>
<div id="user-pageselect"></div>
<ul id='search-users-list' class='nav-list'>
<script>
$(document).ready(function(){
searchUsers(<?= $user_n ?>, <?= $user_perpage ?>);
searchUsers();
});
</script>
</ul>
@@ -94,26 +80,12 @@ $group_count = countSomeGroups($search)->fetchColumn();
<div class="platform item-box searchright" id="search-group-output">
<h4>Groepen</h4>
<select class="group-pageselect"
name="group-pageselect"
id="group-pageselect"
form="search-form"
onchange="this.form.submit()">
<?php
for ($i=1; $i <= ceil($group_count / $group_perpage); $i++) {
if ($group_currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
?>
</select>
<div id="group-pageselect"></div>
<ul id="search-groups-list" class="nav-list">
<script>
$(document).ready(function(){
searchGroups(<?= $group_n ?>, <?= $group_perpage ?>);
searchGroups();
});
</script>
</ul>

View File

@@ -0,0 +1,36 @@
<?php
if ($option == "user") {
echo "<select class=\"user-pageselect\"
name=\"user-pageselect\"
id='user-pagenumber'
form=\"search-form\"
onchange=\"pageNumber(); searchUsers();\">";
for ($i=1; $i <= ceil($user_count / $user_perpage); $i++) {
if ($user_currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
echo "</select>";
} else {
echo "<select class=\"group-pageselect\"
name=\"group-pageselect\"
id='group-pagenumber'
form=\"search-form\"
onchange=\"pageNumber(); searchGroups();\">";
for ($i=1; $i <= ceil($group_count / $group_perpage); $i++) {
if ($group_currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
echo "</select>";
}
?>

View File

@@ -4,13 +4,11 @@ $settings = getSettings();
<div class="content">
<div class="settings">
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "<div class='platform settings-message $alertClass '>
$alertMessage
</div>";
}
?>
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
<div class='platform settings-message <?=$alertClass?>'>
<?=$alertMessage?>
</div>
<?php endif; ?>
<form class="settings-profile platform" method="post">
<h5>Profiel Instellingen</h5>
<ul>
@@ -21,7 +19,7 @@ $settings = getSettings();
id="fname"
placeholder="Voornaam"
title="Voornaam"
value="<?= $settings["fname"]?>"
value="<?=$settings["fname"]?>"
>
</li>
<li>
@@ -30,7 +28,7 @@ $settings = getSettings();
name="lname"
id="lname"
placeholder="Achternaam"
value="<?= $settings["lname"]?>"
value="<?=$settings["lname"]?>"
>
</li>
<li>
@@ -39,16 +37,63 @@ $settings = getSettings();
name="location"
id="location"
placeholder="Locatie"
value="<?= $settings["location"]?>"
value="<?=$settings["location"]?>"
>
</li>
<li>
<?php $currentbday = new DateTime($settings["birthdate"]); ?>
<label for="bday">Geboortedatum</label>
<input type="date"
name="bday"
id="bday"
placeholder="yyyy-mm-dd"
value="<?= $settings["birthdate"]?>"
<select name='day' id="bday">
<?php for ($day = 1; $day <= 31; $day++): ?>
<option value='<?=$day?>'
<?=($day == $currentbday->format("d")) ? "selected" : ""?>
>
<?=$day?>
</option>
<?php endfor; ?>
</select>
<select name='month' id="bday">
<?php
$months = array ("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus",
"september", "oktober", "november", "december");
for ($month = 1; $month <= 12; $month++):
?>
<option value='<?=$month?>'
<?=($month == $currentbday->format("m")) ? "selected" : ""?>
>
<?=$months[$month - 1]?>
</option>
<?php endfor; ?>
</select>
<select name='year' id="bday">
<?php
$now = (new DateTime)->format("Y");
for ($year = $now; $year >= 1900; $year--): ?>
<option value='<?=$year?>'
<?=($year == $currentbday->format("Y")) ? "selected" : ""?>
>
<?=$year?>
</option>
<?php endfor; ?>
<option value="680" <?=(680 == $currentbday->format("Y")) ? "selected" : ""?>>
680
</option>
</select>
</li>
<li>
<label for="showBday">Toon leeftijd</label>
<input type="checkbox"
name="showBday"
id="showBday"
<?=($settings["showBday"] ? "checked" : "")?>
>
</li>
<li>
<label for="showEmail">Toon Email</label>
<input type="checkbox"
name="showEmail"
id="showEmail"
<?=($settings["showEmail"] ? "checked" : "")?>
>
</li>
<li>
@@ -57,7 +102,8 @@ $settings = getSettings();
rows="5"
title="bio"
id="bio"
><?= $settings["bio"]?></textarea>
maxlength="1000"
><?=$settings["bio"]?></textarea><span></span>
</li>
<li>
<label></label>
@@ -73,7 +119,7 @@ $settings = getSettings();
<ul>
<li>
<label>Huidige profielfoto</label>
<img src="<?= $settings["profilepicture"] ?>"
<img src="<?=$settings["profilepicture"]?>"
class="profile-picture"
>
</li>
@@ -98,24 +144,30 @@ $settings = getSettings();
<h5>Verander Wachtwoord</h5>
<ul>
<li>
<label>Oud wachtwoord</label>
<label for="password-old">Oud wachtwoord</label>
<input type="password"
name="password-old"
id="password-old"
placeholder="Oud wachtwoord"
autocomplete="current-password"
>
</li>
<li>
<label>Nieuw wachtwoord</label>
<label for="password-new">Nieuw wachtwoord</label>
<input type="password"
name="password-new"
id="password-new"
placeholder="Nieuw wachtwoord"
autocomplete="new-password"
>
</li>
<li>
<label>Bevestig wachtwoord</label>
<label for="password-confirm">Bevestig wachtwoord</label>
<input type="password"
name="password-confirm"
id="password-confirm"
placeholder="Bevestig wachtwoord"
autocomplete="new-password"
>
</li>
<li>
@@ -134,7 +186,7 @@ $settings = getSettings();
<label for="email-old">Huidig Email </label>
<input type="email"
id="email-old"
value="<?= $settings["email"]?>"
value="<?=$settings["email"]?>"
disabled
>
</li>