80 Commits

Author SHA1 Message Date
Hendrik
f566c6eec4 comments 2017-02-03 12:43:24 +01:00
Hendrik
f3aebddfea commentses 2017-02-03 12:21:37 +01:00
Hendrik
b07d0712aa Merge branch 'marijn-groups' into hendrik-testing 2017-02-03 12:08:42 +01:00
Marijn Jansen
6d5de98c1d comments 2017-02-03 11:31:18 +01:00
Hendrik
771567660c removed session id lol 2017-02-03 11:19:06 +01:00
Hendrik
a0ef234b79 Merge branch 'master' into hendrik-testing 2017-02-03 11:15:01 +01:00
Hendrik
da061de226 validated adminpanel, added shown friends limit in profile. 2017-02-03 11:14:03 +01:00
Marijn Jansen
f18088d8d2 Merge branch 'marijn-groups' into 'master'
Comments

See merge request !203
2017-02-03 11:13:46 +01:00
Marijn Jansen
ac2ce3d07b Merge branch 'master' into marijn-groups 2017-02-03 11:13:20 +01:00
Marijn Jansen
c69b5d8ed3 Comments 2017-02-03 11:12:02 +01:00
Marijn Jansen
5de3a84683 Merge branch 'marijn-groups' into 'master'
Marijn groups

See merge request !201
2017-02-03 10:59:35 +01:00
Marijn Jansen
b8d6136a9d Added deadmin! 2017-02-03 10:59:10 +01:00
Lars van Hijfte
1862369013 Merge branch 'joey-testing' into 'master'
Joey testing

See merge request !200
2017-02-03 10:54:47 +01:00
Joey Lai
8d70804155 Merge branch 'joey-testing' of ssh://gitlab-fnwi.uva.nl:1337/11166932/WebDB into joey-testing 2017-02-03 10:52:35 +01:00
Joey Lai
0ac12f5110 Merge branch 'master' into joey-testing 2017-02-03 10:48:14 +01:00
Lars van Hijfte
5e8fa6791f Merge branch 'joey-testing' into 'master'
Fixed url

See merge request !198
2017-02-03 10:45:33 +01:00
Marijn Jansen
28e9269b52 Delete groups 2017-02-03 10:44:50 +01:00
Hendrik
bb352c7a7a merge 2017-02-03 10:41:29 +01:00
Lars van Hijfte
fe190975d5 Merge branch 'master' into 'joey-testing'
# Conflicts:
#   website/views/homeLoginRegister.php
2017-02-03 10:41:05 +01:00
Hendrik
0f202088a1 Merge branch 'master' into hendrik-testing 2017-02-03 10:40:44 +01:00
Lars van Hijfte
87b0ab5892 Merge branch 'lars' into 'master'
Lars

See merge request !199
2017-02-03 10:40:16 +01:00
Joey Lai
c8dbdfe70e Fixed url 2017-02-03 10:34:44 +01:00
Lars van Hijfte
8949d14a5e Merge branch 'revert-50e94fb8' into 'master'
Revert "Merge branch 'joey-testing' into 'master'"

See merge request !197
2017-02-03 10:34:39 +01:00
Lars van Hijfte
ecd24ef442 Revert "Merge branch 'joey-testing' into 'master'"
This reverts merge request !196
2017-02-03 10:34:07 +01:00
Lars van Hijfte
50e94fb8ed Merge branch 'joey-testing' into 'master'
Fixed url

See merge request !196
2017-02-03 10:33:47 +01:00
Hendrik
fde736b8c5 misc 2017-02-03 10:33:44 +01:00
Joey Lai
127162b938 Fixed url 2017-02-03 10:32:54 +01:00
Lars van Hijfte
02349dbe28 Changed description 2017-02-03 10:30:44 +01:00
Lars van Hijfte
da01729b61 Merge branch 'master' into lars 2017-02-03 10:15:10 +01:00
Lars van Hijfte
820ffb4a62 Merge branch 'joey-testing' into 'master'
Fixed W3Validation and url GETs

See merge request !195
2017-02-03 10:13:43 +01:00
Joey Lai
1a3efe9669 Fixed W3Validation and url GETs 2017-02-03 10:12:37 +01:00
Lars van Hijfte
6d739a4480 Chat is now only loading the last 100 messages 2017-02-03 00:24:38 +01:00
Lars van Hijfte
ab21226925 Merge branch 'master' into lars 2017-02-03 00:14:03 +01:00
Lars van Hijfte
7e4107ac8b Added fancy buttons in profile 2017-02-03 00:13:23 +01:00
Marijn Jansen
de96ae8263 Merge branch 'marijn-groups' into 'master'
Add mods/admin to a group.

See merge request !194
2017-02-02 21:14:59 +01:00
Marijn Jansen
74e91ed7cb Add mods/admin to a group. 2017-02-02 21:14:25 +01:00
Lars van Hijfte
e9468b0ec8 Merge branch 'master' into lars 2017-02-02 21:04:32 +01:00
Lars van Hijfte
839fb247b4 Merge branch 'joey-testing' into 'master'
Added url get

See merge request !193
2017-02-02 21:03:03 +01:00
Marijn Jansen
bf298f4b43 Merge branch 'marijn-groups' into 'master'
Marijn groups

See merge request !192
2017-02-02 19:44:28 +01:00
Marijn Jansen
74145d5d1c Updated buttons on groups 2017-02-02 19:43:57 +01:00
Joey Lai
1486e71207 Added url get 2017-02-02 19:34:58 +01:00
Lars van Hijfte
b206d243b9 Validator fixes
Changes chat, profile and settings pages so it is compatible with the validator of w3
2017-02-02 18:17:58 +01:00
Lars van Hijfte
4f731e12fe Merge branch 'master' into lars 2017-02-02 17:45:10 +01:00
Lars van Hijfte
f8c9454b85 empty SessionID sends the user to login page
If the session is empty, it now sends you to the login page with a safed url so it can revert you back to the right page after login
2017-02-02 17:43:32 +01:00
Lars van Hijfte
93b908fb13 Merge branch 'kevin-prototype' into 'master'
Redirect to 404 from profile and group

See merge request !190
2017-02-02 16:47:06 +01:00
Marijn Jansen
6fd5401c86 Merge branch 'marijn-groups' into 'master'
Marijn groups

See merge request !191
2017-02-02 16:19:03 +01:00
Marijn Jansen
9165f8fa1b Check if file had been uploaded. 2017-02-02 16:18:15 +01:00
Marijn Jansen
380d8fa83a Group Shit 2017-02-02 16:01:45 +01:00
Hendrik
afb45d6709 add closing of modal on escape key and clicking outside 2017-02-02 15:51:27 +01:00
K. Nobel
1c53eab2fa Fixed user group list on profile page. 2017-02-02 15:50:12 +01:00
K. Nobel
28254d98e4 Merge branch 'master' into kevin-prototype 2017-02-02 15:38:39 +01:00
K. Nobel
8a3cfebf55 Redirect to 404 from profile and group 2017-02-02 15:34:45 +01:00
Lars van Hijfte
b1941f0191 Merge branch 'hendrik-testing' into 'master'
add name field check in settings

See merge request !188
2017-02-02 15:27:39 +01:00
Lars van Hijfte
a27a4881c3 Merge branch 'lars' into 'master'
Lars

See merge request !189
2017-02-02 15:27:27 +01:00
Hendrik
cfa7c870f0 fix profile error color 2017-02-02 15:13:35 +01:00
Hendrik
e60578dc43 add unvalidated option and fixed text 2017-02-02 15:11:41 +01:00
Hendrik
9426f4d6ac add name field check in settings 2017-02-02 15:00:01 +01:00
Lars van Hijfte
7f48cae019 Added uderline in link posts 2017-02-02 14:57:50 +01:00
Lars van Hijfte
33399639b1 Added support for iframe "niet slecht" 2017-02-02 14:51:37 +01:00
Lars van Hijfte
52e40242e6 Added "add group" under group menu 2017-02-02 14:50:51 +01:00
Lars van Hijfte
8a6acbc52a Merge branch 'lars' into 'master'
Lars

See merge request !187
2017-02-02 14:27:49 +01:00
Lars van Hijfte
6fc2f71517 Added meta data in the login page 2017-02-02 14:27:23 +01:00
Lars van Hijfte
1672ce6086 Changed offline status to 5 minutes after inactive 2017-02-02 14:23:36 +01:00
Lars van Hijfte
188741ddf5 BUG FIX: link in fancy text now opens in new tab 2017-02-02 14:22:13 +01:00
K. Nobel
4a7a91ecd9 Fixed bug (not showing profile when on own profile) 2017-02-02 14:20:17 +01:00
Lars van Hijfte
1c1283243c Merge branch 'lars' into 'master'
Lars

See merge request !186
2017-02-02 14:16:56 +01:00
Lars van Hijfte
417124a1fe BUG FIX: added 0 in chat time if needed 2017-02-02 14:13:20 +01:00
Lars van Hijfte
d24ed89096 BUG FIX: mobile support fix 2017-02-02 14:04:59 +01:00
Lars van Hijfte
a92b0fe892 Merge branch 'hendrik-post' into 'master'
Hendrik post

See merge request !185
2017-02-02 13:58:17 +01:00
Lars van Hijfte
5c1b2d1b21 Merge branch 'kevin-prototype' into 'master'
FIXED VISIBILITY ON PROFILE

See merge request !183
2017-02-02 13:57:44 +01:00
Lars van Hijfte
3abaeba52c Merge branch 'joey-testing' into 'master'
Joey testing

See merge request !182
2017-02-02 13:57:25 +01:00
Joey Lai
044ed6a9d3 Added noscript 2017-02-02 13:19:39 +01:00
K. Nobel
328ce69144 Merge branch 'master' into kevin-prototype 2017-02-02 13:15:29 +01:00
K. Nobel
9d675dd897 Fixed default image for group members. 2017-02-02 13:11:05 +01:00
K. Nobel
86b02973e4 Fixed visibility on profiles 2017-02-02 13:02:00 +01:00
Joey Lai
67eb7b991e Merge branch 'master' into joey-testing 2017-02-02 10:44:18 +01:00
Joey Lai
90ac38acdd Fixed restrictions with registering 2017-02-02 10:43:34 +01:00
K. Nobel
6c43cae1cb Added noposts div to group. 2017-02-01 14:31:18 +01:00
K. Nobel
3af38cd088 Merge branch 'master' into kevin-prototype 2017-02-01 14:28:39 +01:00
K. Nobel
cfe2928f7b Fixed member list 2017-02-01 14:28:03 +01:00
64 changed files with 1342 additions and 616 deletions

View File

@@ -3,9 +3,9 @@ session_start();
require_once "../../queries/post.php"; require_once "../../queries/post.php";
require_once "../../queries/user.php"; require_once "../../queries/user.php";
if (!isset($_SESSION["userID"])) {
if (isset($_SESSION["userID"]) and echo "logged out";
getRoleByID($_SESSION["userID"]) != 'frozen' and } else if (getRoleByID($_SESSION["userID"]) != 'frozen' and
getRoleByID($_SESSION["userID"]) != 'banned') { getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_POST["postID"]) or empty($_SESSION["userID"])) { if (empty($_POST["postID"]) or empty($_SESSION["userID"])) {

View File

@@ -7,9 +7,9 @@ require_once("../../queries/connect.php");
require_once("../../queries/checkInput.php"); require_once("../../queries/checkInput.php");
require_once("../../queries/user.php"); require_once("../../queries/user.php");
if (!isset($_SESSION["userID"])) {
if (isset($_SESSION["userID"]) && echo "logged out";
getRoleByID($_SESSION["userID"]) != 'frozen' && } else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') { getRoleByID($_SESSION["userID"]) != 'banned') {
if ($_POST['button'] == 'reaction') { if ($_POST['button'] == 'reaction') {
if (empty($_POST['newcomment-content'])) { if (empty($_POST['newcomment-content'])) {

View File

@@ -8,8 +8,9 @@ require_once("../../queries/connect.php");
require_once("../../queries/checkInput.php"); require_once("../../queries/checkInput.php");
require_once("../../queries/user.php"); require_once("../../queries/user.php");
if (isset($_SESSION["userID"]) && if (!isset($_SESSION["userID"])) {
getRoleByID($_SESSION["userID"]) != 'frozen' && echo "logged out";
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') { getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_SESSION["userID"])) { if (empty($_SESSION["userID"])) {

View File

@@ -7,8 +7,9 @@ require_once("../../queries/checkInput.php");
require_once("../../queries/user.php"); require_once("../../queries/user.php");
// Check if the user is allowed to send a message. // Check if the user is allowed to send a message.
if (isset($_SESSION["userID"]) && if (!isset($_SESSION["userID"])) {
getRoleByID($_SESSION["userID"]) != 'frozen' && echo "logged out";
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') { getRoleByID($_SESSION["userID"]) != 'banned') {
if (!empty(test_input($_POST["destination"])) && if (!empty(test_input($_POST["destination"])) &&
!empty(test_input($_POST["content"])) !empty(test_input($_POST["content"]))

View File

@@ -0,0 +1,8 @@
<?php
if (isset($_GET["groupname"])) {
$url = "https://myhyvesbookplus.nl/~lars/group.php?groupname=" . $_GET["groupname"];
} else {
$url = "https://myhyvesbookplus.nl/";
}
?>
<a href="<?= $url ?>" target='_blank'><img style="width: 100%; height: auto;" src="../external/nietslecht_button.png" alt='\"Niet slecht\" ons op MyHyvesbook+' /></a>

View File

@@ -0,0 +1,36 @@
<?php
require_once "../queries/createGroup.php";
require_once "../queries/connect.php";
require_once "../queries/alerts.php"?>
<!DOCTYPE html>
<html>
<head>
<?php include("../views/head.php"); ?>
<style>
@import url("styles/settings.css");
</style>
</head>
<body>
<?php
/*
* This view adds the main layout over the screen.
* Header and menu.
*/
include("../views/main.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
createGroup();
} catch (AlertMessage $e) {
}
$groupname = $_POST["groupName"];
header("location: group.php?groupname=$groupname");
}
/* Add your view files here. */
include("../views/createGroup.php");
/* This adds the footer. */
include("../views/footer.php");
?>
</body>
</html>

View File

@@ -1,71 +0,0 @@
<?php
$fb = new Facebook\Facebook([
'app_id' => $appID, // Replace {app-id} with your app id
'app_secret' => $appSecret,
'default_graph_version' => 'v2.2',
]);
$helper = $fb->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
if (! isset($accessToken)) {
if ($helper->getError()) {
header('HTTP/1.0 401 Unauthorized');
echo "Error: " . $helper->getError() . "\n";
echo "Error Code: " . $helper->getErrorCode() . "\n";
echo "Error Reason: " . $helper->getErrorReason() . "\n";
echo "Error Description: " . $helper->getErrorDescription() . "\n";
} else {
header('HTTP/1.0 400 Bad Request');
echo 'Bad request';
}
exit;
}
// Logged in
echo '<h3>Access Token</h3>';
var_dump($accessToken->getValue());
// The OAuth 2.0 client handler helps us manage access tokens
$oAuth2Client = $fb->getOAuth2Client();
// Get the access token metadata from /debug_token
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
echo '<h3>Metadata</h3>';
var_dump($tokenMetadata);
// Validation (these will throw FacebookSDKException's when they fail)
$tokenMetadata->validateAppId($appID); // Replace {app-id} with your app id
// If you know the user ID this access token belongs to, you can validate it here
//$tokenMetadata->validateUserId('123');
$tokenMetadata->validateExpiration();
if (! $accessToken->isLongLived()) {
// Exchanges a short-lived access token for a long-lived one
try {
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
} catch (Facebook\Exceptions\FacebookSDKException $e) {
echo "<p>Error getting long-lived access token: " . $helper->getMessage() . "</p>\n\n";
exit;
}
echo '<h3>Long-lived</h3>';
var_dump($accessToken->getValue());
}
$_SESSION['fb_access_token'] = (string) $accessToken;
// User is logged in with a long-lived access token.
// You can redirect them to a members-only page.
//header('Location: https://example.com/members.php');

View File

@@ -13,13 +13,15 @@
include_once("../queries/group_page.php"); include_once("../queries/group_page.php");
$group = selectGroupByName($_GET["groupname"]); if(!$group = selectGroupByName($_GET["groupname"])) {
$members = selectGroupMembers(2); header("HTTP/1.0 404 Not Found");
header("Location: error/404.php");
die();
}
$members = selectGroupMembers($group["groupID"]);
?>
<script>alert("<?= $members[0] ?>");</script>
<script>alert("<?= $members[1] ?>");</script>
<?php
/* /*
* This view adds the main layout over the screen. * This view adds the main layout over the screen.

View File

@@ -0,0 +1,72 @@
<?php
require_once "../queries/picture.php";
require_once "../queries/groupAdmin.php";
require_once "../queries/alerts.php";
?>
<!DOCTYPE html>
<html>
<head>
<?php include("../views/head.php"); ?>
<style>
/*Insert own stylesheet here ;)*/
@import url("styles/settings.css");
</style>
</head>
<body>
<?php
/*
* This view adds the main layout over the screen.
* Header and menu.
*/
include("../views/main.php");
$alertClass;
$alertMessage;
// Select which button has been pressed.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
switch ($_POST["form"]) {
case "group":
updateGroupSettings($_POST["groupID"]);
break;
case "picture":
if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) {
updateAvatar($_POST["groupID"]);
}
break;
case "mod":
if (!array_key_exists("userID", $_POST)) {
throw new AngryAlert("Geen gebruiker geselecteerd.");
}
upgradeUser($_POST["groupID"], $_POST["userID"], "mod");
break;
case "admin":
if (!array_key_exists("userID", $_POST)) {
throw new AngryAlert("Geen gebruiker geselecteerd.");
}
upgradeUser($_POST["groupID"], $_POST["userID"], "admin");
break;
case "deadmin":
if (!array_key_exists("userID", $_POST)) {
throw new AngryAlert("Geen gebruiker geselecteerd.");
}
upgradeUser($_POST["groupID"], $_POST["userID"], "member");
break;
case "delete":
deleteGroup();
break;
}
} catch (AlertMessage $w) {
$alertClass = $w->getClass();
$alertMessage = $w->getMessage();
}
}
/* Add your view files here. */
include("../views/groupAdmin.php");
/* This adds the footer. */
include("../views/footer.php");
?>
</body>
</html>

View File

@@ -24,12 +24,14 @@ $(window).on("load", function () {
}); });
}); });
// Toggles all checkboxes based on one.
function checkAll() { function checkAll() {
$('.checkbox-list').each(function () { $('.checkbox-list').each(function () {
$(this).prop('checked', $('#checkall').prop('checked')); $(this).prop('checked', $('#checkall').prop('checked'));
}); });
} }
// Simple function that checks if checkall should stay checked.
function checkCheckAll() { function checkCheckAll() {
var checked = true; var checked = true;
@@ -43,6 +45,7 @@ function checkCheckAll() {
$('#checkall').prop('checked', checked); $('#checkall').prop('checked', checked);
} }
// Toggle of filter options.
function changeFilter() { function changeFilter() {
if ($('#pagetype').find(":selected").val() == "group") { if ($('#pagetype').find(":selected").val() == "group") {
document.getElementById('admin-filter').style.display = 'none'; document.getElementById('admin-filter').style.display = 'none';
@@ -59,11 +62,13 @@ function changeFilter() {
} }
} }
// Sets the search page to one, relevant when changing filter or search.
function searchFromOne() { function searchFromOne() {
$('#currentpage').prop('value', 1); $('#currentpage').prop('value', 1);
adminSearch(); adminSearch();
} }
// AJAX live search.
function adminSearch() { function adminSearch() {
$.post( $.post(
"API/adminSearchUsers.php", "API/adminSearchUsers.php",
@@ -74,6 +79,7 @@ function adminSearch() {
}) })
} }
// AJAX live update.
function adminUpdate(form) { function adminUpdate(form) {
$.post( $.post(
"API/adminChangeUser.php", "API/adminChangeUser.php",
@@ -83,6 +89,7 @@ function adminUpdate(form) {
}) })
} }
// AJAX pagenumber functionality.
function updatePageN() { function updatePageN() {
$.post( $.post(
"API/adminPageNumber.php", "API/adminPageNumber.php",
@@ -92,11 +99,13 @@ function updatePageN() {
}) })
} }
// Intended for the edit button to show a form.
function toggleBancomment(button) { function toggleBancomment(button) {
$(button).siblings("div").toggle(); $(button).siblings("div").toggle();
$(button).toggle(); $(button).toggle();
} }
// AJAX value editing.
function editComment(form) { function editComment(form) {
$.post( $.post(
"API/adminChangeUser.php", "API/adminChangeUser.php",

View File

@@ -25,6 +25,9 @@ function loadMessages() {
addMessages(messages); addMessages(messages);
$("#lastID").val(messages[messages.length - 1].messageID); $("#lastID").val(messages[messages.length - 1].messageID);
} }
loadUnreadMessages();
gettingMessages = false; gettingMessages = false;
}); });
} else { } else {
@@ -40,6 +43,8 @@ function sendMessage() {
).done(function(response) { ).done(function(response) {
if (response == "frozen") { 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."); alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is.");
} else if (response == "logged out") {
window.location.href = "login.php?url=" + window.location.pathname;
} }
// Load messages if the message has been send, so it shows in the chat. // Load messages if the message has been send, so it shows in the chat.
loadMessages(); loadMessages();
@@ -56,7 +61,7 @@ function addMessages(messages) {
for(var i in messages) { for(var i in messages) {
// Initialize message variables. // Initialize message variables.
var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); var thisDate = new Date(messages[i].creationdate.replace(/ /,"T"));
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); var thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2);
var type; var type;
thisDate.setHours(0,0,0,0); thisDate.setHours(0,0,0,0);
@@ -78,6 +83,8 @@ function addMessages(messages) {
</div>'; </div>';
} }
previousDate = thisDate; previousDate = thisDate;
previousTime = thisTime;
previousType = type;
messagesText += '<div class="chat-message"><div class="' + type + '">'; messagesText += '<div class="chat-message"><div class="' + type + '">';
// If it is not the first message, and has a different date/time/type then the previous message, // If it is not the first message, and has a different date/time/type then the previous message,
} else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) { } else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) {

View File

@@ -1,123 +0,0 @@
/**
* jQuery DOB Picker
* Website: https://github.com/tyea/dobpicker
* Version: 1.0
* Author: Tom Yeadon
* License: BSD 3-Clause
*/
jQuery.extend({
dobPicker: function(params) {
// set the defaults
if (typeof(params.dayDefault)==='undefined') params.dayDefault = 'Day';
if (typeof(params.monthDefault)==='undefined') params.monthDefault = 'Month';
if (typeof(params.yearDefault)==='undefined') params.yearDefault = 'Year';
if (typeof(params.minimumAge)==='undefined') params.minimumAge = 12;
if (typeof(params.maximumAge)==='undefined') params.maximumAge = 80;
// set the default messages
$(params.daySelector).append('<option value="">' + params.dayDefault + '</option>');
$(params.monthSelector).append('<option value="">' + params.monthDefault + '</option>');
$(params.yearSelector).append('<option value="">' + params.yearDefault + '</option>');
// populate the day select
for (i = 1; i <= 31; i++) {
if (i <= 9) {
var val = '0' + i;
} else {
var val = i;
}
$(params.daySelector).append('<option value="' + val + '">' + i + '</option>');
}
// populate the month select
var months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
for (i = 1; i <= 12; i++) {
if (i <= 9) {
var val = '0' + i;
} else {
var val = i;
}
$(params.monthSelector).append('<option value="' + val + '">' + months[i - 1] + '</option>');
}
// populate the year select
var date = new Date();
var year = date.getFullYear();
var start = year - params.minimumAge;
var count = start - params.maximumAge;
for (i = start; i >= count; i--) {
$(params.yearSelector).append('<option value="' + i + '">' + i + '</option>');
}
// do the logic for the day select
$(params.daySelector).change(function() {
$(params.monthSelector)[0].selectedIndex = 0;
$(params.yearSelector)[0].selectedIndex = 0;
$(params.yearSelector + ' option').removeAttr('disabled');
if ($(params.daySelector).val() >= 1 && $(params.daySelector).val() <= 29) {
$(params.monthSelector + ' option').removeAttr('disabled');
} else if ($(params.daySelector).val() == 30) {
$(params.monthSelector + ' option').removeAttr('disabled');
$(params.monthSelector + ' option[value="02"]').attr('disabled', 'disabled');
} else if($(params.daySelector).val() == 31) {
$(params.monthSelector + ' option').removeAttr('disabled');
$(params.monthSelector + ' option[value="02"]').attr('disabled', 'disabled');
$(params.monthSelector + ' option[value="04"]').attr('disabled', 'disabled');
$(params.monthSelector + ' option[value="06"]').attr('disabled', 'disabled');
$(params.monthSelector + ' option[value="09"]').attr('disabled', 'disabled');
$(params.monthSelector + ' option[value="11"]').attr('disabled', 'disabled');
}
});
// do the logic for the month select
$(params.monthSelector).change(function() {
$(params.yearSelector)[0].selectedIndex = 0;
$(params.yearSelector + ' option').removeAttr('disabled');
if ($(params.daySelector).val() == 29 && $(params.monthSelector).val() == '02') {
$(params.yearSelector + ' option').each(function(index) {
if (index !== 0) {
var year = $(this).attr('value');
var leap = !((year % 4) || (!(year % 100) && (year % 400)));
if (leap === false) {
$(this).attr('disabled', 'disabled');
}
}
});
}
});
}
});

View File

@@ -1 +0,0 @@
jQuery.extend({dobPicker:function(a){for("undefined"==typeof a.dayDefault&&(a.dayDefault="Day"),"undefined"==typeof a.monthDefault&&(a.monthDefault="Month"),"undefined"==typeof a.yearDefault&&(a.yearDefault="Year"),"undefined"==typeof a.minimumAge&&(a.minimumAge=12),"undefined"==typeof a.maximumAge&&(a.maximumAge=80),$(a.daySelector).append('<option value="">'+a.dayDefault+"</option>"),$(a.monthSelector).append('<option value="">'+a.monthDefault+"</option>"),$(a.yearSelector).append('<option value="">'+a.yearDefault+"</option>"),i=1;i<=31;i++){if(i<=9)var b="0"+i;else var b=i;$(a.daySelector).append('<option value="'+b+'">'+i+"</option>")}var c=["January","February","March","April","May","June","July","August","September","October","November","December"];for(i=1;i<=12;i++){if(i<=9)var b="0"+i;else var b=i;$(a.monthSelector).append('<option value="'+b+'">'+c[i-1]+"</option>")}var d=new Date,e=d.getFullYear(),f=e-a.minimumAge,g=f-a.maximumAge;for(i=f;i>=g;i--)$(a.yearSelector).append('<option value="'+i+'">'+i+"</option>");$(a.daySelector).change(function(){$(a.monthSelector)[0].selectedIndex=0,$(a.yearSelector)[0].selectedIndex=0,$(a.yearSelector+" option").removeAttr("disabled"),$(a.daySelector).val()>=1&&$(a.daySelector).val()<=29?$(a.monthSelector+" option").removeAttr("disabled"):30==$(a.daySelector).val()?($(a.monthSelector+" option").removeAttr("disabled"),$(a.monthSelector+' option[value="02"]').attr("disabled","disabled")):31==$(a.daySelector).val()&&($(a.monthSelector+" option").removeAttr("disabled"),$(a.monthSelector+' option[value="02"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="04"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="06"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="09"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="11"]').attr("disabled","disabled"))}),$(a.monthSelector).change(function(){$(a.yearSelector)[0].selectedIndex=0,$(a.yearSelector+" option").removeAttr("disabled"),29==$(a.daySelector).val()&&"02"==$(a.monthSelector).val()&&$(a.yearSelector+" option").each(function(a){if(0!==a){var b=$(this).attr("value"),c=!(b%4||!(b%100)&&b%400);c===!1&&$(this).attr("disabled","disabled")}})})}});

View File

@@ -19,24 +19,24 @@ function placeFriendButtons() {
case "0": case "0":
value1 = "request"; value1 = "request";
class1 = "green"; class1 = "green";
text1 = "Bevriend"; text1 = "Word vrienden";
icon1 = "fa-handshake-o"; icon1 = "fa-user-plus";
break; break;
case "1": case "1":
value1 = userID; value1 = userID;
class1 = "green"; class1 = "green";
text1 = "Chat"; text1 = "Chat";
icon1 = "fa-comment-o"; icon1 = "fa-comment";
value2 = "delete"; value2 = "delete";
class2 = "red"; class2 = "red";
text2 = "Verwijder"; text2 = "Ontvriend";
icon2 = "fa-times"; icon2 = "fa-user-times";
break; break;
case "2": case "2":
value1 = "delete"; value1 = "delete";
class1 = "red"; class1 = "red";
text1 = "Trek verzoek in"; text1 = "Trek verzoek in";
icon1 = "fa-cross"; icon1 = "fa-times";
break; break;
case "3": case "3":
value1 = "accept"; value1 = "accept";
@@ -51,16 +51,18 @@ function placeFriendButtons() {
} }
$buttonContainer.append( $buttonContainer.append(
"<button class='"+ class1 +" friend-button' value='"+ value1 +"'>" + "<div><button class='"+ class1 +" fancy-button friend-button' value='"+ value1 +"'>" +
"<i class='fa "+ icon1 +"'></i> " + text1 + "<span>"+ text1 +"</span>" +
"</button>"); "<i class='fa fa-fw "+ icon1 +"'></i> " +
"</button></div>");
$buttonContainer.append( $buttonContainer.append(
"<button class='"+ class2 +" friend-button' value='"+ value2 +"'>" + "<div><button class='"+ class2 +" fancy-button friend-button' value='"+ value2 +"'>" +
"<i class='fa "+ icon2 +"'></i> " + text2 + "<span>"+ text2 +"</span>" +
"</button>"); "<i class='fa fa-fw "+ icon2 +"'></i> " +
"</button></div>");
$buttonContainer.children().click(function() { $buttonContainer.find("button").click(function() {
if (isNaN(this.value)) if (isNaN(this.value))
editFriendship(userID, this.value); editFriendship(userID, this.value);
else if (this.value != "") else if (this.value != "")

View File

@@ -5,22 +5,31 @@ function placeGroupButtons() {
if (data == 'none') { if (data == 'none') {
$buttonContainer.append( $buttonContainer.append(
"<button class='green group-button' value='request'>" + "<button class='green group-button fancy-button' value='request'>" +
"<i class='fa fa-plus'></i> Voeg toe" + "<span>Treed toe</span><i class='fa fa-plus'></i>" +
"</button>"); "</button>");
} else if (data == 'request') { } else if (data == 'request') {
$buttonContainer.append( $buttonContainer.append(
"<button class='red group-button' value='none'>" + "<button class='red group-button fancy-button' value='none'>" +
"<i class='fa fa-times'></i> Trek verzoek in" + "<span>Trek verzoek in</span><i class='fa fa-times'></i>" +
"</button>"); "</button>");
} else if (data == 'admin') {
$buttonContainer.append(
"<button class='group-button fancy-button' value='admin'>" +
"<span>Instellingen</span><i class='fa fa-cogs'></i>" +
"</button>"
);
} else { } else {
$buttonContainer.append( $buttonContainer.append(
"<button class='red group-button' value='none'>" + "<button class='red group-button fancy-button' value='none'>" +
"<i class='fa fa-times'></i> Verlaat groep" + "<span>Verlaat groep</span><i class='fa fa-sign-out'></i>" +
"</button>"); "</button>");
} }
$buttonContainer.children().click(function() { $buttonContainer.children().click(function() {
if (this.value == 'admin') {
window.location.href='groupAdmin.php?groupID=' + groupID;
} else {
$.post("API/editMembership.php", {grp: groupID, role: this.value}) $.post("API/editMembership.php", {grp: groupID, role: this.value})
.done(function () { .done(function () {
$buttonContainer.children().remove(); $buttonContainer.children().remove();
@@ -28,6 +37,7 @@ function placeGroupButtons() {
updateMenus(); updateMenus();
}).fail(function () { }).fail(function () {
}); });
}
}); });
}); });

View File

@@ -0,0 +1,68 @@
// Get the modal
var modal = document.getElementById('myModal');
var registerModal = document.getElementById('registerModal');
var facebookModal = document.getElementById("fbModal");
// Get the button that opens the modal
var registerBtn = document.getElementById("registerBtn");
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
var registerSpan = document.getElementsByClassName("close")[1];
var facebookCLose = document.getElementsByClassName("close")[2];
/**
* When the user clicks the button, open the modal
*/
btn.onclick = function () {
modal.style.display = "block";
}
registerBtn.onclick = function () {
registerModal.style.display = "block";
}
/**
* WHen the user clicks on (X), close the modal
*/
span.onclick = function () {
modal.style.display = "none";
}
registerSpan.onclick = function () {
registerModal.style.display = "none";
}
facebookCLose.onclick = function () {
facebookModal.style.display = "none";
}
/**
* 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";
}
if (event.target == facebookModal) {
facebookModal.style.display = "none";
}
}
/**
* When ESC is pressed, close modal
*/
document.addEventListener('keyup', function(e) {
if (e.keyCode == 27) {
modal.style.display = "none";
registerModal.style.display = "none";
}
});
/**
* Created by joey on 2-2-17.
*/

View File

@@ -3,8 +3,7 @@ var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "a
function fancyText(text) { function fancyText(text) {
// Add links, images, gifs and (youtube) video's. // Add links, images, gifs and (youtube) video's.
var regex = /(https?:\/\/.[^ <>"]*)/ig; text = text.replace(/(https?:\/\/.[^ \n<>"]*)/ig, function(link) {
text = text.replace(regex, function(link) {
// Add images // Add images
if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) { if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
return "<img alt='" + link + "' src='" + link + "' />"; return "<img alt='" + link + "' src='" + link + "' />";
@@ -31,7 +30,7 @@ function fancyText(text) {
} }
// Add links // Add links
else { else {
return "<a href='" + link + "'>" + link + "</a>"; return "<a href='" + link + "' target='_blank'>" + link + "</a>";
} }
}); });
@@ -39,7 +38,7 @@ function fancyText(text) {
} }
// This function gets the value of a cookie when given a key. // This function gets the value of a cookie when given a key.
// If didn´t find any compatible cookie, it returns false. // If it didn´t find any compatible cookie, it returns false.
function getCookie(key) { function getCookie(key) {
cookies = document.cookie.split("; "); cookies = document.cookie.split("; ");
for (var i in cookies) { for (var i in cookies) {

View File

@@ -26,7 +26,7 @@ function requestPost(postID) {
function postPost() { function postPost() {
title = $("input.newpost[name='title']").val(); title = $("input.newpost[name='title']").val();
content = $("textarea.newpost[name='content']").val(); content = $("textarea.newpost[name='content']").val();
console.log(masonryMode);
if (masonryMode == 2) { if (masonryMode == 2) {
$.post("API/postPost.php", { title: title, $.post("API/postPost.php", { title: title,
content : content, content : content,
@@ -36,6 +36,10 @@ function postPost() {
$('#alertbox').show(); $('#alertbox').show();
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
window.scrollTo(0,0); window.scrollTo(0,0);
} else if (data == "logged out") {
window.location.href = "login.php?url=" + window.location.pathname;
} else if (data == "frozen") {
alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is.");
} else { } else {
$('#alertbox').hide(); $('#alertbox').hide();
masonry(masonryMode); masonry(masonryMode);
@@ -49,6 +53,10 @@ function postPost() {
$('#alertbox').show(); $('#alertbox').show();
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
window.scrollTo(0,0); window.scrollTo(0,0);
} else if (data == "logged out") {
window.location.href = "login.php?url=" + window.location.pathname;
} else if (data == "frozen") {
alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is.");
} else { } else {
$('#alertbox').hide(); $('#alertbox').hide();
masonry(masonryMode); masonry(masonryMode);
@@ -83,6 +91,21 @@ $(window).on("load", function() {
loadMorePosts(userID, groupID, postAmount, postLimit); loadMorePosts(userID, groupID, postAmount, postLimit);
} }
}; };
$(document).keyup(function(e) {
if (e.keyCode == 27) {
closeModal();
}
});
$('.modal').click(function() {
closeModal();
});
$('.modal-content').click(function(event){
event.stopPropagation();
});
}); });
function closeModal() { function closeModal() {

View File

@@ -1,4 +1,9 @@
/**
* Posts a comment or "Niet slecht." on a post.
* Button specifies between comment and "Niet slecht.".
* Alerts or redirects if frozen or not logged in.
*/
function postComment(buttonValue) { function postComment(buttonValue) {
formData = $("#newcommentform").serializeArray(); formData = $("#newcommentform").serializeArray();
formData.push({name: "button", value: buttonValue}); formData.push({name: "button", value: buttonValue});
@@ -8,6 +13,8 @@ function postComment(buttonValue) {
).done(function (response) { ).done(function (response) {
if (response == "frozen") { 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."); alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is.");
} else if (response == "logged out") {
window.location.href = "login.php?url=" + window.location.pathname;
} }
}); });
@@ -22,6 +29,10 @@ function postComment(buttonValue) {
}); });
} }
/**
* Deletes a post given by postID, closes modal and reloads posts.
* @param postID
*/
function deletePost(postID) { function deletePost(postID) {
var formData = [{name: "postID", value: postID}]; var formData = [{name: "postID", value: postID}];
$.post( $.post(
@@ -30,6 +41,8 @@ function deletePost(postID) {
).done(function (response) { ).done(function (response) {
if (response == "frozen") { if (response == "frozen") {
alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is."); alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is.");
} else if (response == "logged out") {
window.location.href = "login.php?url=" + window.location.pathname;
} }
}); });
closeModal(); closeModal();

View File

@@ -1,3 +1,4 @@
// Checks if user is logged in and offers to logout.
function checkLoggedIn() { function checkLoggedIn() {
if (confirm("U bent al ingelogd!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) { if (confirm("U bent al ingelogd!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
window.location.href = "logout.php"; window.location.href = "logout.php";
@@ -6,18 +7,22 @@ function checkLoggedIn() {
} }
} }
// Alert for validation mail.
function emailAlert(){ function emailAlert(){
alert("Bevestigingsemail is gestuurd!\n"); alert("Bevestigingsemail is gestuurd!\n");
} }
// Alert for banned account.
function bannedAlert(){ function bannedAlert(){
alert("Uw account is geband!"); alert("Uw account is geband!");
} }
// Alert for frozen account.
function frozenAlert(){ function frozenAlert(){
alert("Uw account is bevroren!\n"); alert("Uw account is bevroren!\n");
} }
// Alert for unconfirmed email.
function emailNotConfirmed(){ function emailNotConfirmed(){
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen"); alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
} }

View File

@@ -13,18 +13,12 @@
?> ?>
<body> <body>
<?php <?php
session_start();
// Checks if there's an user already logged in
if(isset($_SESSION["userID"])){
echo "<script>
window.onload=checkLoggedIn();
</script>";
}
include("../views/homeLoginRegister.php"); include("../views/homeLoginRegister.php");
/* This view adds login view */ /* This view adds login view */
include("../views/login-view.php"); include("../views/login-view.php");
?> ?>
<script src="js/loginRegisterModals.js"></script>;
</body> </body>
</html> </html>

View File

@@ -25,9 +25,15 @@ if(empty($_GET["username"])) {
$userID = getUserID($_GET["username"]); $userID = getUserID($_GET["username"]);
} }
$user = selectUser($_SESSION["userID"], $userID); if(!$user = selectUser($_SESSION["userID"], $userID)) {
header("HTTP/1.0 404 Not Found");
header("Location: error/404.php");
die();
}
$profile_friends = selectAllFriends($userID); $profile_friends = selectAllFriends($userID);
$profile_groups = selectAllUserGroups($userID); $profile_groups = selectAllUserGroups($userID);
$showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID;
if ($userID == $_SESSION["userID"]) { if ($userID == $_SESSION["userID"]) {

View File

@@ -1,116 +0,0 @@
<!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

@@ -14,11 +14,13 @@
<?php <?php
$alertClass; $alertClass;
$alertMessage; $alertMessage;
// Select which button has been pressed.
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
try { try {
switch ($_POST["form"]) { switch ($_POST["form"]) {
case "profile": case "profile":
updateSettings(); checkUpdateSettings();
break; break;
case "password": case "password":
changePassword(); changePassword();
@@ -29,7 +31,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
case "picture": case "picture":
updateAvatar(); updateAvatar();
break; break;
} }
} catch (AlertMessage $w) { } catch (AlertMessage $w) {
$alertClass = $w->getClass(); $alertClass = $w->getClass();

View File

@@ -34,9 +34,10 @@
width: 100%; width: 100%;
} }
.usertable .table-username {width: 150px} .table-checkbox {width: 20px}
.usertable .table-status {width: 100px} .table-username {width: 150px}
.usertable .table-action {width: 200px} .table-status {width: 100px}
.table-action {width: 200px}
.usertable th, td { .usertable th, td {
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
@@ -51,6 +52,10 @@
background-color: #f5f5f5; background-color: #f5f5f5;
} }
.bancomment {
width: 80%;
}
.bancommentedit { .bancommentedit {
display: none; display: none;
} }

View File

@@ -133,6 +133,12 @@ label {
color: red; color: red;
} }
.login_containerNoscript {
padding: 4px;
text-align: center;
color: red;
}
@keyframes animatezoom { @keyframes animatezoom {
from {transform: scale(0)} from {transform: scale(0)}
to {transform: scale(1)} to {transform: scale(1)}
@@ -150,7 +156,7 @@ label {
margin: 16px auto; margin: 16px auto;
overflow-y: auto; overflow-y: auto;
padding: 20px; padding: 20px;
width: 600px; width: 650px;
} }
select{ select{
@@ -192,12 +198,6 @@ ul {
animation-duration: 0.4s animation-duration: 0.4s
} }
/* Add Animation */
@-webkit-keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
@keyframes animatetop { @keyframes animatetop {
from {top:-300px; opacity:0} from {top:-300px; opacity:0}
to {top:0; opacity:1} to {top:0; opacity:1}

View File

@@ -256,8 +256,6 @@ div[data-title]:hover:after {
top: 150%; top: 150%;
z-index: 200; z-index: 200;
white-space: nowrap; white-space: nowrap;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22); box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
background-color: #333; background-color: #333;

View File

@@ -48,6 +48,10 @@
width: 90%; width: 90%;
} }
.post-content a {
text-decoration: underline;
}
.commentfield { .commentfield {
margin-bottom: 20px; margin-bottom: 20px;
} }
@@ -87,17 +91,5 @@
.deleteButton { .deleteButton {
background-color: firebrick; background-color: firebrick;
float: right;
}
.deleteButton i {
display: inline-block;
}
.deleteButton:hover span {
display: inline-block;
}
.deleteButton span {
display: none;
} }

View File

@@ -5,6 +5,10 @@
background-color: firebrick; background-color: firebrick;
} }
.alerttext {
color: white;
}
.user-box { .user-box {
text-align: center; text-align: center;
} }
@@ -23,14 +27,22 @@
display: inline-block; display: inline-block;
} }
.friend-button-container div, .status-buttons-container div {
width: 200px;
display: inline-block;
}
.friend-button-container button, .status-buttons-container button, .group-button-container button { .friend-button-container button, .status-buttons-container button, .group-button-container button {
display: block; display: block;
float: right;
margin: 7px 0; margin: 7px 0;
width: 200px;
font-size: 18px; font-size: 18px;
} }
.status-buttons-container button {
float: left;
}
.group-button-container button { .group-button-container button {
float: right; float: right;
@@ -67,9 +79,24 @@
.group-picture { .group-picture {
border: none; border: none;
margin-right: 15px;
} }
.fancy-button span {
display: none;
}
.fancy-button:hover {
text-align: right;
}
.fancy-button i {
display: inline-block;
}
.fancy-button:hover span {
display: inline-block;
margin-right: 5px;
}
/* Old */ /* Old */
@@ -94,6 +121,10 @@ div.posts div.post {
word-wrap: break-word; word-wrap: break-word;
} }
div.posts div.post a {
text-decoration: underline;
}
div.posts div.post:hover { div.posts div.post:hover {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
} }

View File

@@ -41,16 +41,26 @@ function checkInputChoice($variable, $option){
} }
} }
/* Checks for only letters and spaces. */ /**
* Checks for only letters and spaces.
* @param $variable
* @throws lettersAndSpacesException
*/
function checkName($variable){ function checkName($variable){
if (empty($variable)) { if (empty($variable)) {
throw new lettersAndSpacesException("Verplicht!"); throw new lettersAndSpacesException("Verplicht!");
} else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) { } 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!");
} else if (strlen($variable) > 63){
throw new lettersAndSpacesException(("Mag maximaal 63 karakters hebben!"));
} }
} }
/* Checks for bday */ /**
* Checks for bday
* @param $variable
* @throws bdayException
*/
function validateBday($variable){ function validateBday($variable){
if (empty($variable)) { if (empty($variable)) {
throw new bdayException("Verplicht!"); throw new bdayException("Verplicht!");
@@ -66,7 +76,7 @@ function validateBday($variable){
} }
} }
// Checks for date /* Checks for date */
function validateDate($date, $format) function validateDate($date, $format)
{ {
$d = DateTime::createFromFormat($format, $date); $d = DateTime::createFromFormat($format, $date);
@@ -81,6 +91,8 @@ function username($variable){
throw new usernameException("Moet minstens 6 karakters bevatten"); throw new usernameException("Moet minstens 6 karakters bevatten");
} else if (getExistingUsername() == 1) { } else if (getExistingUsername() == 1) {
throw new usernameException("Gebruikersnaam bestaal al"); throw new usernameException("Gebruikersnaam bestaal al");
} else if (strlen($variable) > 50) {
throw new usernameException("Mag maximaal 50 karakters!");
} }
} }
@@ -92,6 +104,8 @@ function fbUsername($variable){
throw new usernameException("Moet minstens 6 karakters bevatten"); throw new usernameException("Moet minstens 6 karakters bevatten");
} else if (getExistingFBUsername() == 1) { } else if (getExistingFBUsername() == 1) {
throw new usernameException("Gebruikersnaam bestaal al"); throw new usernameException("Gebruikersnaam bestaal al");
} else if (strlen($variable) > 50) {
throw new usernameException("Mag maximaal 50 karakters!");
} }
} }
@@ -101,6 +115,8 @@ function longerEight($variable){
throw new passwordException("Verplicht!"); throw new passwordException("Verplicht!");
} else if (strlen($variable) < 8) { } else if (strlen($variable) < 8) {
throw new passwordException("Moet minstens 8 karakters bevatten"); throw new passwordException("Moet minstens 8 karakters bevatten");
} else if (strlen($variable) > 50) {
throw new usernameException("Mag maximaal 50 karakters!");
} }
} }
@@ -112,6 +128,8 @@ function validateEmail($variable){
throw new emailException("Geldige email invullen"); throw new emailException("Geldige email invullen");
} else if (getExistingEmail() == 1){ } else if (getExistingEmail() == 1){
throw new emailException("Email bestaal al!"); throw new emailException("Email bestaal al!");
} else if (strlen($variable) > 255) {
throw new emailException("Mag maximaal 50 karakters!");
} }
} }
@@ -122,10 +140,13 @@ function validateFBEmail($variable){
} else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) { } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) {
throw new emailException("Geldige email invullen"); throw new emailException("Geldige email invullen");
} else if (getExistingFBEmail() == 1){ } else if (getExistingFBEmail() == 1){
throw new emailException("Email bestaal al!"); throw new emailException("Uw email wordt al gebruikt voor een ander account!");
} else if (strlen($variable) > 255) {
throw new emailException("Mag maximaal 50 karakters!");
} }
} }
/* checks if email is the same */
function matchEmail(){ function matchEmail(){
if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){ if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){
throw new confirmEmailException("Emails matchen niet!"); throw new confirmEmailException("Emails matchen niet!");
@@ -141,7 +162,6 @@ function resetEmail($variable){
} }
} }
/* checks if two passwords matches. */ /* checks if two passwords matches. */
function matchPassword(){ function matchPassword(){
if ($_POST["password"] != $_POST["confirmpassword"]) { if ($_POST["password"] != $_POST["confirmpassword"]) {
@@ -204,9 +224,13 @@ function test_input($data) {
$data = trim($data); $data = trim($data);
$data = stripslashes($data); $data = stripslashes($data);
$data = htmlspecialchars($data); $data = htmlspecialchars($data);
$data = trim($data);
return $data; return $data;
} }
/**
* Class lettersAndSpacesException
*/
class lettersAndSpacesException extends Exception class lettersAndSpacesException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -215,7 +239,9 @@ class lettersAndSpacesException extends Exception
} }
} }
/**
* Class bdayException
*/
class bdayException extends Exception class bdayException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -224,6 +250,9 @@ class bdayException extends Exception
} }
} }
/**
* Class usernameException
*/
class usernameException extends Exception class usernameException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -232,6 +261,9 @@ class usernameException extends Exception
} }
} }
/**
* Class passwordException
*/
class passwordException extends Exception class passwordException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -240,6 +272,9 @@ class passwordException extends Exception
} }
} }
/**
* Class confirmPasswordException
*/
class confirmPasswordException extends Exception class confirmPasswordException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -248,6 +283,9 @@ class confirmPasswordException extends Exception
} }
} }
/**
* Class fbConfirmPasswordException
*/
class fbConfirmPasswordException extends Exception class fbConfirmPasswordException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -256,6 +294,9 @@ class fbConfirmPasswordException extends Exception
} }
} }
/**
* Class emailException
*/
class emailException extends Exception class emailException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -264,6 +305,9 @@ class emailException extends Exception
} }
} }
/**
* Class confirmEmailException
*/
class confirmEmailException extends Exception class confirmEmailException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -272,6 +316,9 @@ class confirmEmailException extends Exception
} }
} }
/**
* Class captchaException
*/
class captchaException extends Exception class captchaException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -280,6 +327,9 @@ class captchaException extends Exception
} }
} }
/**
* Class registerException
*/
class registerException extends Exception class registerException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)

View File

@@ -10,6 +10,11 @@ else {
or die('Error connecting to mysql server'); or die('Error connecting to mysql server');
} }
/**
* Helperfunction to create a database query.
* @param string $query
* @return PDOStatement
*/
function prepareQuery(string $query) : PDOStatement { function prepareQuery(string $query) : PDOStatement {
return $GLOBALS["db"]->prepare($query); return $GLOBALS["db"]->prepare($query);
} }

View File

@@ -0,0 +1,44 @@
<?php
require_once "../queries/checkInput.php";
require_once "../queries/picture.php";
require_once "../queries/alerts.php";
/**
* Creates a group.
*/
function createGroup()
{
// Creates the group.
$createGroup = prepareQuery("
INSERT INTO
`group_page` (`name`, `description`)
VALUES (:name, :description);
");
$createGroup->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR);
$createGroup->bindValue(':description', test_input($_POST["bio"]));
$createGroup->execute();
// Gets the groupID just created.
$getGroupID = prepareQuery("
SELECT
`groupID`
FROM
`group_page`
WHERE
`name` LIKE :name");
$getGroupID->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR);
$getGroupID->execute();
$groupID = $getGroupID->fetch()["groupID"];
// Adds the user as an admin.
$makeUserAdmin = prepareQuery("
INSERT INTO
`group_member` (userID, groupID, role)
VALUES (:userID, :groupID, 'admin')
");
$makeUserAdmin->bindValue(":userID", $_SESSION["userID"]);
$makeUserAdmin->bindValue("groupID", $groupID);
$makeUserAdmin->execute();
updateAvatar($groupID);
}

View File

@@ -1,5 +1,8 @@
<?php <?php
/**
* Sends a confirm email if you know the username.
* @param string $username
*/
function sendConfirmEmailUsername(string $username) { function sendConfirmEmailUsername(string $username) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -15,6 +18,10 @@ function sendConfirmEmailUsername(string $username) {
sendConfirmEmail($userID); sendConfirmEmail($userID);
} }
/**
* Sends a confirm email if you know the userID.
* @param int $userID
*/
function sendConfirmEmail(int $userID) { function sendConfirmEmail(int $userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT

View File

@@ -2,10 +2,21 @@
require_once ("connect.php"); require_once ("connect.php");
/**
* Selects all friends of a user.
* @param $userID
* @return string
*/
function selectFriends($userID) { function selectFriends($userID) {
return selectLimitedFriends($userID, 9999); return selectLimitedFriends($userID, 9999);
} }
/**
* Returns a limited amount of friends of a user.
* @param $userID
* @param $limit
* @return string
*/
function selectLimitedFriends($userID, $limit) { function selectLimitedFriends($userID, $limit) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -17,7 +28,7 @@ function selectLimitedFriends($userID, $limit) {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus`, END AS `onlinestatus`,
@@ -46,7 +57,11 @@ function selectLimitedFriends($userID, $limit) {
return json_encode($stmt->fetchAll()); return json_encode($stmt->fetchAll());
} }
/**
* Selects all friends of a user.
* @param $userID
* @return PDOStatement
*/
function selectAllFriends($userID) { function selectAllFriends($userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -58,7 +73,7 @@ function selectAllFriends($userID) {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus`, END AS `onlinestatus`,
@@ -83,6 +98,10 @@ function selectAllFriends($userID) {
return $stmt; return $stmt;
} }
/**
* Returns all friend requests of the current user.
* @return string
*/
function selectAllFriendRequests() { function selectAllFriendRequests() {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -94,7 +113,7 @@ function selectAllFriendRequests() {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus`, END AS `onlinestatus`,
@@ -119,6 +138,11 @@ function selectAllFriendRequests() {
return json_encode($stmt->fetchAll()); return json_encode($stmt->fetchAll());
} }
/**
* Gets the friendship status from current user and userID.
* @param $userID
* @return int
*/
function getFriendshipStatus($userID) { function getFriendshipStatus($userID) {
# -2: Query failed. # -2: Query failed.
# -1: user1 and 2 are the same user # -1: user1 and 2 are the same user
@@ -162,6 +186,11 @@ function getFriendshipStatus($userID) {
return intval($stmt->fetch()["friend_state"]); return intval($stmt->fetch()["friend_state"]);
} }
/**
* Request friendship from current user to target user.
* @param $userID
* @return bool
*/
function requestFriendship($userID) { function requestFriendship($userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
INSERT INTO `friendship` (user1ID, user2ID) INSERT INTO `friendship` (user1ID, user2ID)
@@ -173,6 +202,11 @@ function requestFriendship($userID) {
return $stmt->execute(); return $stmt->execute();
} }
/**
* Removes friendship between current and target user.
* @param $userID
* @return bool
*/
function removeFriendship($userID) { function removeFriendship($userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
DELETE FROM `friendship` DELETE FROM `friendship`
@@ -189,6 +223,11 @@ function removeFriendship($userID) {
return $stmt->execute(); return $stmt->execute();
} }
/**
* Sets the friendship between current and target user to accepted.
* @param $userID
* @return bool
*/
function acceptFriendship($userID) { function acceptFriendship($userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
UPDATE `friendship` UPDATE `friendship`
@@ -204,6 +243,11 @@ function acceptFriendship($userID) {
return $stmt->execute(); return $stmt->execute();
} }
/**
* Sets the last time the user visited the chat with specified friend.
* @param $friend
* @return PDOStatement
*/
function setLastVisited($friend) { function setLastVisited($friend) {
$stmt = prepareQuery(" $stmt = prepareQuery("
UPDATE UPDATE
@@ -234,6 +278,13 @@ function setLastVisited($friend) {
return $stmt; return $stmt;
} }
/**
* Searches m friends from n filtered by search.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeFriends($n, $m, $search) { function searchSomeFriends($n, $m, $search) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -245,7 +296,7 @@ function searchSomeFriends($n, $m, $search) {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus`, END AS `onlinestatus`,
@@ -281,6 +332,11 @@ function searchSomeFriends($n, $m, $search) {
return json_encode($stmt->fetchAll()); return json_encode($stmt->fetchAll());
} }
/**
* Counts all friends of current user filtered by search.
* @param $search
* @return string
*/
function countSomeFriends($search) { function countSomeFriends($search) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT

View File

@@ -0,0 +1,192 @@
<?php
/**
* Gets the current settings for a group.
* @param int $groupID
* @return mixed
*/
function getGroupSettings(int $groupID) {
$stmt = prepareQuery("
SELECT
`name`,
`picture`,
`description`
FROM
`group_page`
WHERE
`groupID` = :groupID
");
$stmt->bindParam(":groupID", $groupID);
$stmt->execute();
return $stmt->fetch();
}
/**
* Updates the settings for a group.
* @param int $groupID
* @throws AngryAlert
* @throws HappyAlert
*/
function updateGroupSettings(int $groupID)
{
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
throw new AngryAlert("Je hebt geen rechten in deze groep");
}
$stmt = prepareQuery("
UPDATE
`group_page`
SET
`name` = :name,
`description` = :bio
WHERE
`groupID` = :groupID
");
$stmt->bindValue(":bio", test_input($_POST["bio"]));
$stmt->bindValue(":name", test_input($_POST["name"]));
$stmt->bindValue(":groupID", test_input($_POST["groupID"]));
$stmt->execute();
if ($stmt->rowCount()) {
throw new HappyAlert("Groep aangepast!");
} else {
throw new AngryAlert("Er is iets mis gegaan");
}
}
/**
* Checks if an user is an admin for a page.
* @param int $groupID
* @param int $userID
* @return bool
*/
function checkGroupAdmin(int $groupID, int $userID) : bool {
$stmt = prepareQuery("
SELECT
`role`
FROM
`group_member`
WHERE
`groupID` = :groupID AND
`userID` = :userID
");
$stmt->bindValue(":userID", $userID);
$stmt->bindValue(":groupID", $groupID);
$stmt->execute();
if (!$stmt->rowCount()) {
return false;
}
$role = $stmt->fetch()["role"];
return ($role == "admin");
}
/**
* Returns all normal members for a group.
* @param int $groupID
* @return array|bool
*/
function getAllGroupUsers(int $groupID) {
return getAllGroupMembers($groupID, 'member');
}
/**
* Returns all admin for a group.
* @param int $groupID
* @return array|bool
*/
function getAllGroupAdmins(int $groupID) {
return getAllGroupMembers($groupID, 'admin');
}
/**
* Returns all Moderators for a group.
* @param int $groupID
* @return array|bool
*/
function getAllGroupMods(int $groupID) {
return getAllGroupMembers($groupID, 'mod');
}
/**
* Returns all members for a group specified by a string.
* @param int $groupID
* @param string $role
* @return array|bool
*/
function getAllGroupMembers(int $groupID, string $role) {
$stmt = prepareQuery("
SELECT
`username`,
`user`.`userID`,
CONCAT(`fname`, ' ', `lname`) AS `fullname`,
`group_member`.`role`
FROM
`group_member`
LEFT JOIN
`user`
ON
`group_member`.`userID` = `user`.`userID`
WHERE
`groupID` = :groupID AND `group_member`.`role` = :role
");
$stmt->bindParam(':groupID', $groupID);
$stmt->bindParam(":role", $role);
if (!$stmt->execute()) {
return False;
}
return $stmt->fetchAll();
}
/**
* Upgrades or downgrades a groupmember to a different role.
* @param int $groupID
* @param int $userID
* @param string $role
* @throws AngryAlert
* @throws HappyAlert
*/
function upgradeUser(int $groupID, int $userID, string $role) {
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
throw new AngryAlert("Geen toestemming om te wijzigen");
}
$stmt = prepareQuery("
UPDATE
`group_member`
SET
`role` = :role
WHERE
`userID` = :userID AND `groupID` = :groupID
");
$stmt->bindValue(":groupID", $groupID);
$stmt->bindValue(":userID", $userID);
$stmt->bindValue(":role", $role);
$stmt->execute();
if ($stmt->rowCount()) {
throw new HappyAlert("Permissie aangepast!");
} else {
throw new AngryAlert("Er is iets mis gegaan");
}
}
/**
* Removes a group form the database.
* @throws AngryAlert
* @throws HappyAlert
*/
function deleteGroup() {
if (!checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) {
throw new AngryAlert("Geen toestemming om de groep te verwijderen!");
}
$stmt = prepareQuery("
DELETE FROM
`group_page`
WHERE
`groupID` = :groupID
");
$stmt->bindValue(":groupID", $_POST["groupID"]);
$stmt->execute();
if ($stmt->rowCount()) {
throw new HappyAlert("Group verwijderd!");
} else {
throw new AngryAlert("Er is iets mis gegaan");
}
}

View File

@@ -1,9 +1,20 @@
<?php <?php
/**
* Returns all groups a user is member of.
* @param $userID
* @return string
*/
function selectAllGroupsFromUser($userID) { function selectAllGroupsFromUser($userID) {
return selectLimitedGroupsFromUser($userID, 9999); return selectLimitedGroupsFromUser($userID, 9999);
} }
/**
* Selects number of groups that a user is member of.
* @param $userID
* @param $limit
* @return string
*/
function selectLimitedGroupsFromUser($userID, $limit) { function selectLimitedGroupsFromUser($userID, $limit) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -27,6 +38,13 @@ function selectLimitedGroupsFromUser($userID, $limit) {
return json_encode($stmt->fetchAll()); return json_encode($stmt->fetchAll());
} }
/**
* Returns m groups offset by n filtered by search that the current user is part of.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeOwnGroups($n, $m, $search) { function searchSomeOwnGroups($n, $m, $search) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -55,6 +73,11 @@ function searchSomeOwnGroups($n, $m, $search) {
return json_encode($stmt->fetchAll()); return json_encode($stmt->fetchAll());
} }
/**
* Counts all groups filtered by search that the current user is member of.
* @param $search
* @return string
*/
function countSomeOwnGroups($search) { function countSomeOwnGroups($search) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -78,6 +101,13 @@ function countSomeOwnGroups($search) {
return $stmt->fetchColumn(); return $stmt->fetchColumn();
} }
/**
* Adds a user by userID to a group by groupID with a specified role.
* @param $groupID
* @param $userID
* @param $role
* @return bool
*/
function addMember($groupID, $userID, $role) { function addMember($groupID, $userID, $role) {
$stmt = prepareQuery(" $stmt = prepareQuery("
INSERT INTO INSERT INTO
@@ -92,6 +122,13 @@ function addMember($groupID, $userID, $role) {
return $stmt->execute(); return $stmt->execute();
} }
/**
* Changes te role of a user within a group to the specified one.
* @param $groupID
* @param $userID
* @param $role
* @return bool
*/
function changeMember($groupID, $userID, $role) { function changeMember($groupID, $userID, $role) {
$stmt = prepareQuery(" $stmt = prepareQuery("
UPDATE UPDATE
@@ -109,6 +146,12 @@ function changeMember($groupID, $userID, $role) {
return $stmt->execute(); return $stmt->execute();
} }
/**
* Removes a user from a group.
* @param $groupID
* @param $userID
* @return bool
*/
function deleteMember($groupID, $userID) { function deleteMember($groupID, $userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
DELETE FROM DELETE FROM

View File

@@ -2,6 +2,10 @@
require_once("connect.php"); require_once("connect.php");
/**
* Selects some info from a group by name.
* @return bool|mixed
*/
function selectGroupByName($name) { function selectGroupByName($name) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -33,9 +37,19 @@ function selectGroupByName($name) {
if (!$stmt->execute()) { if (!$stmt->execute()) {
return False; return False;
} }
return $stmt->fetch(); $row = $stmt->fetch();
if($row["groupID"] == null) {
return False;
} }
return $row;
}
/**
* Selects the current user's role within a group by the group's ID.
* @param int $groupID
* @return bool|string
*/
function selectGroupRole(int $groupID) { function selectGroupRole(int $groupID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -58,6 +72,11 @@ function selectGroupRole(int $groupID) {
return $stmt->fetch()["role"]; return $stmt->fetch()["role"];
} }
/**
* Returns the status of a group by it's ID.
* @param int $groupID
* @return bool
*/
function selectGroupStatus(int $groupID) { function selectGroupStatus(int $groupID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -75,13 +94,21 @@ function selectGroupStatus(int $groupID) {
return $stmt->fetch()["status"]; return $stmt->fetch()["status"];
} }
/**
* Returns some info of all group members.
* @param int $groupID
* @return bool|PDOStatement
*/
function selectGroupMembers(int $groupID) { function selectGroupMembers(int $groupID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
`username`, `username`,
`fname`, `fname`,
`lname`, `lname`,
`profilepicture` IFNULL(
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture
FROM FROM
`group_member` `group_member`
LEFT JOIN LEFT JOIN
@@ -97,9 +124,14 @@ function selectGroupMembers(int $groupID) {
if (!$stmt->execute()) { if (!$stmt->execute()) {
return False; return False;
} }
return $stmt->fetchAll(); return $stmt;
} }
/**
* Returns group info by it's ID.
* @param $groupID
* @return PDOStatement
*/
function selectGroupById($groupID) { function selectGroupById($groupID) {
$q = prepareQuery(" $q = prepareQuery("
SELECT SELECT
@@ -119,6 +151,11 @@ function selectGroupById($groupID) {
return $q; return $q;
} }
/**
* Returns some info of 20 groups offset by n.
* @param $n
* @return PDOStatement
*/
function select20GroupsFromN($n) { function select20GroupsFromN($n) {
$q = prepareQuery(" $q = prepareQuery("
SELECT SELECT
@@ -141,6 +178,12 @@ function select20GroupsFromN($n) {
return $q; return $q;
} }
/**
* Returns info of 20 groups offset by n, filtered by status.
* @param $n
* @param $status
* @return PDOStatement
*/
function select20GroupsByStatusFromN($n, $status) { function select20GroupsByStatusFromN($n, $status) {
$q = prepareQuery(" $q = prepareQuery("
SELECT SELECT
@@ -166,6 +209,13 @@ function select20GroupsByStatusFromN($n, $status) {
return $q; return $q;
} }
/**
* Returns info of 20 groups offset by n, filtered by status, filtered by search.
* @param $n
* @param $keyword
* @param $status
* @return PDOStatement
*/
function search20GroupsFromNByStatus($n, $keyword, $status) { function search20GroupsFromNByStatus($n, $keyword, $status) {
$q = prepareQuery(" $q = prepareQuery("
SELECT SELECT
@@ -193,6 +243,14 @@ function search20GroupsFromNByStatus($n, $keyword, $status) {
return $q; return $q;
} }
/**
* Returns info of n groups offset by m, filtered by status and search.
* @param $n
* @param $m
* @param $search
* @param $status
* @return PDOStatement
*/
function searchSomeGroupsByStatus($n, $m, $search, $status) { function searchSomeGroupsByStatus($n, $m, $search, $status) {
// parentheses not needed in where clause, for clarity as // parentheses not needed in where clause, for clarity as
// role search should override status filter. // role search should override status filter.
@@ -225,6 +283,12 @@ function searchSomeGroupsByStatus($n, $m, $search, $status) {
return $q; return $q;
} }
/**
* Count all groups filtered by status and search.
* @param $search
* @param $status
* @return PDOStatement
*/
function countSomeGroupsByStatus($search, $status) { function countSomeGroupsByStatus($search, $status) {
$q = prepareQuery(" $q = prepareQuery("
SELECT SELECT
@@ -248,6 +312,12 @@ function countSomeGroupsByStatus($search, $status) {
return $q; return $q;
} }
/**
* Changes the status of a group with the given ID.
* @param $id
* @param $status
* @return PDOStatement
*/
function changeGroupStatusByID($id, $status) { function changeGroupStatusByID($id, $status) {
$q = prepareQuery(" $q = prepareQuery("
UPDATE UPDATE
@@ -264,6 +334,12 @@ function changeGroupStatusByID($id, $status) {
return $q; return $q;
} }
/**
* Changes the status of multiple groups to 1 status by an array of IDs.
* @param $ids
* @param $status
* @return PDOStatement
*/
function changeMultipleGroupStatusByID($ids, $status) { function changeMultipleGroupStatusByID($ids, $status) {
$q = prepareQuery(" $q = prepareQuery("
UPDATE UPDATE
@@ -281,6 +357,13 @@ function changeMultipleGroupStatusByID($ids, $status) {
return $q; return $q;
} }
/**
* Returns m groups offset by n, filtered by search.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeGroups($n, $m, $search) { function searchSomeGroups($n, $m, $search) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -304,6 +387,11 @@ function searchSomeGroups($n, $m, $search) {
return json_encode($stmt->fetchAll()); return json_encode($stmt->fetchAll());
} }
/**
* Counts all group filtered by search.
* @param $search
* @return PDOStatement
*/
function countSomeGroups($search) { function countSomeGroups($search) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT

View File

@@ -1,5 +1,9 @@
<?php <?php
/**
* Find matching password with the inputted username/emailadress.
* @return mixed
*/
function getUser() { function getUser() {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -33,7 +37,8 @@ function getUserID() {
return $stmt->fetch(PDO::FETCH_ASSOC); return $stmt->fetch(PDO::FETCH_ASSOC);
} }
function validateLogin($username, $password){ function validateLogin($username, $password, $url){
echo $url;
// Empty username or password field // Empty username or password field
if (empty($username) || empty($password)) { if (empty($username) || empty($password)) {
throw new loginException("Inloggegevens zijn niet ingevuld"); throw new loginException("Inloggegevens zijn niet ingevuld");
@@ -44,26 +49,42 @@ function validateLogin($username, $password){
$userID = getUser()["userID"]; $userID = getUser()["userID"];
$role = getUser()["role"]; $role = getUser()["role"];
// If there's an account, go to the profile page // If there's an account, check if the account is banned, frozen or unconfirmed.
if(password_verify($psw, $hash)) { if(password_verify($psw, $hash)) {
if ($role == "banned"){ if ($role == "banned"){
echo "<script> echo "<script>
window.onload=bannedAlert(); window.onload=bannedAlert();
</script>"; </script>";
} else if ($role == "frozen") { } else if ($role == "frozen") {
$_SESSION["userID"] = $userID; $_SESSION["userID"] = $userID;
if (!isset($url) or $url = "") {
echo "<script> echo "<script>
window.onload=frozenAlert(); window.onload=frozenAlert();
window.location.href= 'profile.php'; window.location.href= 'profile.php';
</script>"; </script>";
} else {
echo "<script>
window.onload=frozenAlert();
window.location.href= $url;
</script>";
}
} else if ($role == "unconfirmed"){ } else if ($role == "unconfirmed"){
sendConfirmEmail(getUser()["userID"]); sendConfirmEmail(getUser()["userID"]);
echo "<script> echo "<script>
window.onload=emailNotConfirmed(); window.onload=emailNotConfirmed();
</script>"; </script>";
} else { } else {
$_SESSION["userID"] = $userID; $_SESSION["userID"] = $userID;
if(!isset($url) or $url == "") {
header("location: profile.php"); header("location: profile.php");
echo "succes";
} else{
header("location: ".$url);
}
} }
} else { } else {
throw new loginException("Inloggevens zijn niet correct"); throw new loginException("Inloggevens zijn niet correct");

View File

@@ -6,7 +6,10 @@
* @throws AngryAlert * @throws AngryAlert
* @throws HappyAlert * @throws HappyAlert
*/ */
function updateAvatar(bool $group = false) { function updateAvatar(int $group = 0) {
if (!array_key_exists("pp", $_FILES)) {
throw new AngryAlert("Geen afbeelding meegegeven!");
}
$publicDir = "/var/www/html/public/"; $publicDir = "/var/www/html/public/";
$tmpImg = $_FILES["pp"]["tmp_name"]; $tmpImg = $_FILES["pp"]["tmp_name"];
$avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/"; $avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/";
@@ -16,17 +19,17 @@ function updateAvatar(bool $group = false) {
if ($_FILES["pp"]["size"] > 4000000) { if ($_FILES["pp"]["size"] > 4000000) {
throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan.");
} }
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif"; $relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif";
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); $group ? removeOldGroupAvatar($group) : removeOldUserAvatar();
move_uploaded_file($tmpImg, $publicDir . $relativePath); move_uploaded_file($tmpImg, $publicDir . $relativePath);
} else { } else {
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png"; $relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png";
$scaledImg = scaleAvatar($tmpImg); $scaledImg = scaleAvatar($tmpImg);
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); $group ? removeOldGroupAvatar($group) : removeOldUserAvatar();
imagepng($scaledImg, $publicDir . $relativePath); imagepng($scaledImg, $publicDir . $relativePath);
} }
$group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath); $group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath);
throw new HappyAlert("Profielfoto veranderd."); throw new HappyAlert("Profielfoto veranderd.");
} }

View File

@@ -281,6 +281,12 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
} }
} }
/**
* Returns role of an user.
* @param int $userID
* @param int $groupID
* @return mixed role of an user.
*/
function getRoleInGroup(int $userID, int $groupID) { function getRoleInGroup(int $userID, int $groupID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT

View File

@@ -7,6 +7,9 @@ function getOldChatMessages($user2ID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
* *
FROM
(SELECT
*
FROM FROM
`private_message` `private_message`
WHERE WHERE
@@ -15,9 +18,11 @@ function getOldChatMessages($user2ID) {
`origin` = :user2 AND `origin` = :user2 AND
`destination` = :user1 `destination` = :user1
ORDER BY ORDER BY
`creationdate` ASC `messageID` DESC
LIMIT LIMIT
100 100) sub
ORDER BY
`messageID` ASC
"); ");
$stmt->bindParam(":user1", $user1ID); $stmt->bindParam(":user1", $user1ID);
@@ -76,7 +81,7 @@ function getNewChatMessages($lastID, $destination) {
`destination` = :user1) AND `destination` = :user1) AND
`messageID` > :lastID `messageID` > :lastID
ORDER BY ORDER BY
`creationdate` ASC `messageID` ASC
"); ");
$stmt->bindParam(':user1', $_SESSION["userID"]); $stmt->bindParam(':user1', $_SESSION["userID"]);

View File

@@ -16,7 +16,10 @@ function getSettings() {
`location`, `location`,
`birthdate`, `birthdate`,
`bio`, `bio`,
IFNULL(
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
`showBday`, `showBday`,
`showEmail`, `showEmail`,
`showProfile` `showProfile`
@@ -50,6 +53,15 @@ function getPasswordHash() {
return $stmt->fetch(); return $stmt->fetch();
} }
function checkUpdateSettings() {
if (empty(test_input($_POST['fname'])) || empty(test_input($_POST['lname']))) {
throw new AngryAlert("Geen voornaam of achternaam.");
return;
}
updateSettings();
}
/** /**
* Changes the setting from post. * Changes the setting from post.
* @throws HappyAlert * @throws HappyAlert
@@ -139,6 +151,10 @@ function doChangePassword() {
} }
} }
/**
* Changes the users email if it is valid.
* @throws AngryAlert
*/
function changeEmail() { function changeEmail() {
if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) { if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) {
@@ -155,6 +171,11 @@ function changeEmail() {
} }
} }
/**
* Checks if an emailadres is available in the database.
* @param $email
* @throws AngryAlert
*/
function emailIsAvailableInDatabase($email) { function emailIsAvailableInDatabase($email) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -172,6 +193,12 @@ function emailIsAvailableInDatabase($email) {
} }
} }
/**
* Does the actual changing of an email-adress.
* @param $email
* @throws AngryAlert
* @throws HappyAlert
*/
function doChangeEmail($email) { function doChangeEmail($email) {
$stmt = prepareQuery(" $stmt = prepareQuery("
UPDATE UPDATE

View File

@@ -62,13 +62,17 @@ function selectUser($me, $other) {
) AS profilepicture, ) AS profilepicture,
`bio`, `bio`,
`user`.`creationdate`, `user`.`creationdate`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus`, END AS `onlinestatus`,
`role`, `role`,
`fname`, `fname`,
`lname`, `lname`,
`showBday`,
`showEmail`,
`showProfile`,
`status`,
CASE `status` IS NULL CASE `status` IS NULL
WHEN TRUE THEN 0 WHEN TRUE THEN 0
WHEN FALSE THEN WHEN FALSE THEN
@@ -97,7 +101,9 @@ function selectUser($me, $other) {
$stmt->bindParam(':me', $me, PDO::PARAM_INT); $stmt->bindParam(':me', $me, PDO::PARAM_INT);
$stmt->bindParam(':other', $other, PDO::PARAM_INT); $stmt->bindParam(':other', $other, PDO::PARAM_INT);
$stmt->execute(); if(!$stmt->execute() || $stmt->rowCount() == 0) {
return False;
}
return $stmt->fetch(); return $stmt->fetch();
} }
@@ -116,7 +122,7 @@ function selectAllUserGroups($userID) {
`group_page`.`groupID` = `group_member`.`groupID` `group_page`.`groupID` = `group_member`.`groupID`
WHERE WHERE
`userID` = :userID AND `userID` = :userID AND
`role` = 'member' `role` IN ('member', 'mod', 'admin')
"); ");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT); $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
@@ -131,7 +137,7 @@ function select20UsersFromN($n) {
`username`, `username`,
`role`, `role`,
`bancomment`, `bancomment`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus` END AS `onlinestatus`
@@ -156,7 +162,7 @@ function search20UsersFromN($n, $keyword) {
`username`, `username`,
`role`, `role`,
`bancomment`, `bancomment`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus` END AS `onlinestatus`
@@ -184,7 +190,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
`username`, `username`,
`role`, `role`,
`bancomment`, `bancomment`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus` END AS `onlinestatus`
@@ -218,7 +224,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) {
`username`, `username`,
`role`, `role`,
`bancomment`, `bancomment`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus` END AS `onlinestatus`
@@ -362,7 +368,7 @@ function searchSomeUsers($n, $m, $search) {
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
WHEN TRUE THEN 'online' WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline' WHEN FALSE THEN 'offline'
END AS `onlinestatus` END AS `onlinestatus`

View File

@@ -1,9 +1,9 @@
<tr> <tr>
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)"></th> <th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)"></th>
<th class="table-username">Gebruikersnaam</th> <th class="table-username">Groepsnaam</th>
<th class="table-status">Status</th> <th class="table-status">Status</th>
<th class="table-comment">Aantekening</th> <th class="table-comment">Beschrijving</th>
<th class="table-action">Actie</th> <th class="table-action">Zichtbaarheid</th>
</tr> </tr>
<?php <?php
@@ -33,9 +33,9 @@ while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
<form class='admin-groupaction' <form class='admin-groupaction'
onsubmit=\"adminUpdate(this); return false;\"> onsubmit=\"adminUpdate(this); return false;\">
<select class='action' name='actions'> <select class='action' name='actions'>
<option value='hidden'>Hidden</option> <option value='hidden'>Verborgen</option>
<option value='public'>Public</option> <option value='public'>Publiek</option>
<option value='membersonly'>Members</option> <option value='membersonly'>Alleen Leden</option>
</select> </select>
<input type='hidden' name='groupID' value='$groupID'> <input type='hidden' name='groupID' value='$groupID'>
<input type='submit' value='Confirm'> <input type='submit' value='Confirm'>

View File

@@ -13,6 +13,7 @@ Pagina:
id="currentpage" id="currentpage"
form="admin-searchform" form="admin-searchform"
onchange="adminSearch();"> onchange="adminSearch();">
<!-- Construct the options. -->
<?php <?php
for ($i=1; $i <= ceil($countresults / $entries); $i++) { for ($i=1; $i <= ceil($countresults / $entries); $i++) {
if ($currentpage == $i) { if ($currentpage == $i) {

View File

@@ -55,7 +55,8 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) {
OR $user['role'] == 'owner'))) { OR $user['role'] == 'owner'))) {
echo "<option value='frozen'>Bevries</option> echo "<option value='frozen'>Bevries</option>
<option value='banned'>Ban</option> <option value='banned'>Ban</option>
<option value='user'>Activeer</option>"; <option value='user'>Activeer</option>
<option value='unconfirmed'>Ongevalideerd</option>";
if ($userinfo == 'owner') { if ($userinfo == 'owner') {
echo "<option value='admin'>Admin</option> echo "<option value='admin'>Admin</option>

View File

@@ -1,5 +1,4 @@
<!-- Form value holding. -->
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
<?php <?php
$search = ""; $search = "";
$status = array("user", "frozen", "banned", "unconfirmed", "admin", "owner"); $status = array("user", "frozen", "banned", "unconfirmed", "admin", "owner");
@@ -67,13 +66,13 @@ if (isset($_GET["groupstatus"])) {
id="frozen" id="frozen"
value="frozen" value="frozen"
<?php if (in_array("frozen", $status)) echo "checked";?>> <?php if (in_array("frozen", $status)) echo "checked";?>>
<label for="frozen">Gefrozen</label><br> <label for="frozen">Bevroren</label><br>
<input type="checkbox" <input type="checkbox"
name="status[]" name="status[]"
id="banned" id="banned"
value="banned" value="banned"
<?php if (in_array("banned", $status)) echo "checked";?>> <?php if (in_array("banned", $status)) echo "checked";?>>
<label for="banned">Gebant</label><br> <label for="banned">Verbannen</label><br>
<input type="checkbox" <input type="checkbox"
name="status[]" name="status[]"
id="admin" id="admin"
@@ -91,7 +90,7 @@ if (isset($_GET["groupstatus"])) {
id="owner" id="owner"
value="owner" value="owner"
<?php if (in_array("owner", $status)) echo "checked";?>> <?php if (in_array("owner", $status)) echo "checked";?>>
<label for="owner">Owner</label> <label for="owner">Eigenaar</label>
</div> </div>
<div id="admin-groupfilter"> <div id="admin-groupfilter">
@@ -122,16 +121,17 @@ if (isset($_GET["groupstatus"])) {
<button type="submit" name="batchactions" id="freeze" value="frozen">Bevries</button> <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="ban" value="banned">Ban</button>
<button type="submit" name="batchactions" id="restore" value="user">Activeer</button> <button type="submit" name="batchactions" id="restore" value="user">Activeer</button>
<button type="submit" name="batchactions" id="unconfirm" value="unconfirmed">Maak Ongevalideerd</button>
<?php <?php
if ($userinfo == 'owner') { if ($userinfo == 'owner') {
echo "<button type=\"submit\" echo "<button type=\"submit\"
name=\"batchactions\" name=\"batchactions\"
id=\"admin\" id=\"batch-admin\"
value=\"admin\">Maak Admin</button> value=\"admin\">Maak Admin</button>
<button type=\"submit\" <button type=\"submit\"
name=\"batchactions\" name=\"batchactions\"
id=\"owner\" id=\"batch-owner\"
value=\"owner\">Maak Owner</button>"; value=\"owner\">Maak Eigenaar</button>";
} }
?> ?>
</form> </form>
@@ -139,9 +139,9 @@ if (isset($_GET["groupstatus"])) {
onsubmit="adminUpdate(this); return false;"> onsubmit="adminUpdate(this); return false;">
<input type="hidden" name="groupbatchactions" id="groupbatchinput"> <input type="hidden" name="groupbatchactions" id="groupbatchinput">
<button type="submit" name="batchactions" id="hide" value="hidden">Hide</button> <button type="submit" name="batchactions" id="batch-hide" value="hidden">Verborgen</button>
<button type="submit" name="batchactions" id="ban" value="public">Public</button> <button type="submit" name="batchactions" id="batch-public" value="public">Publiek</button>
<button type="submit" name="batchactions" id="members" value="membersonly">Members</button> <button type="submit" name="batchactions" id="batch-members" value="membersonly">Alleen Leden</button>
</form> </form>
</div> </div>
@@ -151,5 +151,3 @@ if (isset($_GET["groupstatus"])) {
</div> </div>
</div> </div>
</div> </div>
</body>
</html>

View File

@@ -0,0 +1,42 @@
<?php
?>
<div class="content">
<div class="createGroup">
<form class="platform settings" method="post" action="createGroup.php" enctype="multipart/form-data">
<h5>Maak een groep!</h5>
<ul>
<li>
<label for="groupName">Groepsnaam</label>
<input type="text"
name="groupName"
id="groupName"
maxlength="63"
placeholder="Groepsnaam"
>
</li>
<li>
<label for="bio">Bio</label>
<textarea name="bio"
rows="5"
title="bio"
id="bio"
maxlength="1000"
></textarea>
</li>
<li>
<label>Selecteer foto</label>
<input type="file"
name="pp"
accept="image/*"
size="4000000"
>
</li>
<li>
<label></label>
<button type="submit">Maak Groep</button>
</li>
</ul>
</form>
</div>
</div>

View File

@@ -1,7 +1,6 @@
<!-- The Modal --> <!-- The Modal -->
<div id="fbModal" class="modal"> <div id="fbModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post" method="post"
name="fbModal"> name="fbModal">
@@ -55,7 +54,6 @@
*<span class="error"> <?php echo $fbConfirmpasswordErr;?></span> *<span class="error"> <?php echo $fbConfirmpasswordErr;?></span>
</div> </div>
<?php if(empty($userBday)) { ?> <?php if(empty($userBday)) { ?>
<!-- Register birthday --> <!-- Register birthday -->
<div class="login_containerregister"> <div class="login_containerregister">
@@ -67,17 +65,16 @@
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
<span class="error"> <?php echo $fbEmailErr;?></span>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" <button type="submit"
value="fbRegister" value="fbRegister"
name="submit" name="submit">
id="frm1_submit">
Registreer account Registreer account
</button> </button>
</div> </div>
</div> </div>
<!-- Facebook information-->
<input type="hidden" <input type="hidden"
name="fbName" name="fbName"
value="<?php echo $fbName ?>"> value="<?php echo $fbName ?>">

View File

@@ -4,7 +4,6 @@
<!-- The Modal --> <!-- The Modal -->
<div id="myModal" class="modal"> <div id="myModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post" method="post"
name="forgotPassword"> name="forgotPassword">
@@ -26,8 +25,7 @@
<div class="login_containerfault"><span><?php echo $resetErr; ?></span></div> <div class="login_containerfault"><span><?php echo $resetErr; ?></span></div>
<button type="submit" <button type="submit"
value="reset" value="reset"
name="submit" name="submit">
id="frm1_submit">
Reset password Reset password
</button> </button>
</div> </div>

View File

@@ -1,6 +1,6 @@
<div class="content"> <div class="content">
<div class="user-box"> <div class="user-box">
<img class="group-picture main-picture" src="<?= $group["picture"] ?>"><br /> <img alt="<?= $group["name"] ?>" class="group-picture main-picture" src="<?= $group["picture"] ?>"><br />
<div class="platform"> <div class="platform">
<div class="status-buttons-container"> <div class="status-buttons-container">
<button disabled class="gray"><?= $group["status"] ?></button> <button disabled class="gray"><?= $group["status"] ?></button>
@@ -16,9 +16,18 @@
<h2>Leden (<?= $group['members'] ?>)</h2> <h2>Leden (<?= $group['members'] ?>)</h2>
<p> <p>
<?php <?php
foreach($members as $member) { $membercount = $members->rowCount();
$memberdif = $membercount - 7;
for ($i = 0; $i < min($membercount, 7); $i += 1) {
$member = $members->fetch();
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>"; 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>";
} }
if ($memberdif > 0) {
echo $memberdif === 1 ? "en nog 1 andere." : "...en nog $memberdif anderen.";
}
?> ?>
</p> </p>
</div> </div>
@@ -27,6 +36,10 @@
</div> </div>
<div class="noposts platform">
<p>Geen posts meer!</p>
</div>
<div class="modal"> <div class="modal">
<div class="modal-content platform"> <div class="modal-content platform">
<div class="modal-close"> <div class="modal-close">

View File

@@ -0,0 +1,168 @@
<?php
require_once "../queries/connect.php";
require_once "../queries/groupAdmin.php";
require_once "../queries/checkInput.php";
$groupinfo = getGroupSettings($_GET["groupID"]);
?>
<div class="content">
<div class="settings">
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
<div class='platform settings-message <?=$alertClass?>'>
<?=$alertMessage?>
</div>
<?php endif; ?>
<div class="platform">
<ul>
<li>
<label></label>
<a href="group.php?groupname=<?=$groupinfo["name"]?>">
<button><i class="fa fa-chevron-left"></i> Terug naar de groep</button>
</a>
</li>
</ul>
</div>
<form class="platform" method="post">
<h5>Groep Instellingen</h5>
<input type="hidden" name="groupID" value="<?=$_GET["groupID"]?>">
<ul>
<li>
<label for="name">Groepsnaam</label>
<input type="text"
name="name"
id="name"
maxlength="63"
placeholder="Groepsnaam"
title="Groepsnaam"
value="<?=$groupinfo["name"]?>"
>
</li>
<li>
<label for="bio">Bio</label>
<textarea name="bio"
rows="5"
title="bio"
id="bio"
maxlength="1000"
><?=$groupinfo["description"]?></textarea>
<label></label>
</li>
<li>
<label></label>
<button type="submit"
name="form"
value="group"
><i class="fa fa-save"></i> Opslaan</button>
</li>
</ul>
</form>
<form class="platform" method="post" enctype="multipart/form-data">
<h5>Verander groepsafbeelding.</h5>
<input type="hidden" name="groupID" value="<?=$_GET["groupID"]?>">
<ul>
<li>
<label>Huidige profielfoto</label>
<img src="<?=$groupinfo["picture"]?>"
class="group-picture"
>
</li>
<li>
<label>Selecteer foto</label>
<input type="file"
name="pp"
accept="image/*"
size="4000000"
required
>
</li>
<li>
<label></label>
<button type="submit"
name="form"
value="picture"
><i class="fa fa-picture-o"></i> Verander profielfoto</button>
</li>
</ul>
</form>
<form class="platform" method="post">
<h5>Voeg een admin/mod toe</h5>
<ul>
<il>
<input name="groupID" value="<?=$_GET["groupID"]?>" type="hidden">
<label>Selecteer gebruiker</label>
<select name="userID">
<option disabled selected>Geen gebruiker geselecteerd:</option>
<?php
$groupMembers = getAllGroupUsers($_GET["groupID"]);
foreach ($groupMembers as $groupMember) {?>
<option value="<?=$groupMember["userID"]?>">
<?=$groupMember["fullname"]?> (<?=$groupMember["username"]?>)
</option>
<?php } ?>
</select>
<button name="form"
value="admin"
>
Maak Admin
</button>
<button name="form"
value="mod"
>
Maak Moderator
</button>
</il>
</ul>
</form>
<form class="platform" method="post">
<h5>Verwijder een admin/mod</h5>
<ul>
<il>
<input name="groupID" value="<?=$_GET["groupID"]?>" type="hidden">
<label>Selecteer gebruiker</label>
<select name="userID">
<option disabled selected>Geen gebruiker geselecteerd:</option>
<?php
$groupAdmins = getAllGroupAdmins($_GET["groupID"]);
foreach ($groupAdmins as $groupAdmin) {?>
<option value="<?=$groupAdmin["userID"]?>">
<?=$groupAdmin["fullname"]?> (<?=$groupAdmin["username"]?>) (<?=$groupAdmin["role"]?>)
</option>
<?php } ?>
<?php
$groupMods = getAllGroupMods($_GET["groupID"]);
foreach ($groupMods as $groupMod) {?>
<option value="<?=$groupMod["userID"]?>">
<?=$groupMod["fullname"]?> (<?=$groupMod["username"]?>) (<?=$groupMod["role"]?>)
</option>
<?php } ?>
</select>
<button name="form"
value="deadmin"
>
Verwijder
</button>
</il>
</ul>
</form>
<form class="platform" method="post">
<ul>
<h5>Verwijder groep</h5>
<li>
<label></label>
<input name="groupID" value="<?=$_GET["groupID"]?>" type="hidden">
<button class="red"
name="form"
value="delete"
><i class="fa fa-trash"></i> Verwijder groep</button>
</li>
</ul>
</form>
<div class="platform">
<ul>
<li>
<label></label>
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button><i class="fa fa-chevron-left"></i> Terug naar de groep</button></a>
</li>
</ul>
</div>
</div>
</div>

View File

@@ -1,8 +1,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="description" content="MyHyvesbook+ is het sociaal media voor alle coole mensen."> <meta name="description" content="MyHyvesbook+ is het sociaal medium voor alle coole mensen. Stap nu over van facebook op het gloednieuwe en betere sociaal medium.">
<meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media"> <meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media">
<meta name="author" content="MyHyvesbookplus corporation"> <meta name="author" content="MyHyvesbookplus corporation">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MyHyvesbook+</title> <title>MyHyvesbook+</title>
<!-- Add your javascript files here. --> <!-- Add your javascript files here. -->
<script src="js/jquery.js"></script> <script src="js/jquery.js"></script>
@@ -28,7 +27,7 @@ require_once ("../queries/user.php");
session_start(); session_start();
if(!isset($_SESSION["userID"])) { if(!isset($_SESSION["userID"])) {
header("location:login.php"); header("location:login.php?url=" . "$_SERVER[REQUEST_URI]");
} else { } else {
updateLastActivity(); updateLastActivity();
} }

View File

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

View File

@@ -1,19 +1,26 @@
<?php <?php
session_start();
// Checks if there's an user already logged in
if(isset($_SESSION["userID"])){
echo "<script>
window.onload=checkLoggedIn();
</script>";
}
// Facebook variables // Facebook variables
$appID = "353857824997532"; $appID = "353857824997532";
$appSecret = "db47e91ffbfd355fdd11b4b65eade851"; $appSecret = "db47e91ffbfd355fdd11b4b65eade851";
$fbUsername = $fbPassword = $fbConfirmpassword = ""; $fbUsername = $fbPassword = $fbConfirmpassword = $fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = "";
$fbUsernameErr = $fbPasswordErr = $fbConfirmpasswordErr = $fbEmailErr = $fbBdayErr = ""; $fbUsernameErr = $fbPasswordErr = $fbConfirmpasswordErr = $fbEmailErr = $fbBdayErr = "";
$fbCorrect = true; $fbCorrect = true;
$fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = "";
$bdayExist = false;
// Register variables // Register variables
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = ""; $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = "";
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = ""; $genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = "";
$correct = true; $correct = true;
// Bday dates
$day_date = $month_date = $year_date = ""; $day_date = $month_date = $year_date = "";
$fbDay_date = $fbMonth_date = $fbYear_date = ""; $fbDay_date = $fbMonth_date = $fbYear_date = "";
@@ -27,7 +34,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
case "login": case "login":
try { try {
$user = ($_POST["user"]); $user = ($_POST["user"]);
validateLogin($_POST["user"], $_POST["psw"]); validateLogin($_POST["user"], $_POST["psw"], $_POST["url"]);
} catch(loginException $e) { } catch(loginException $e) {
$loginErr = $e->getMessage(); $loginErr = $e->getMessage();
} }
@@ -46,18 +53,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
} }
break; break;
case "register": case "register":
include("register.php"); include("../views/register.php");
break; break;
case "fbRegister": case "fbRegister":
include("fbRegister.php"); include("../views/fbRegister.php");
break; break;
} }
} }
// Get facebook information with facebook PHP SDK.
$fb = new Facebook\Facebook([ $fb = new Facebook\Facebook([
'app_id' => $appID, 'app_id' => $appID,
'app_secret' => $appSecret, 'app_secret' => $appSecret,
'default_graph_version' => 'v2.2', 'default_graph_version' => 'v2.2',
]); ]);
// Redirect back to login.php after logging/canceling with facebook.
$redirect = "https://myhyvesbookplus.nl/login.php"; $redirect = "https://myhyvesbookplus.nl/login.php";
$helper = $fb->getRedirectLoginHelper(); $helper = $fb->getRedirectLoginHelper();
@@ -72,6 +83,7 @@ try {
exit; exit;
} }
// If theres no facebook account logged in, ask for permission.
if(!isset($acces_token)){ if(!isset($acces_token)){
$permission=["email", "user_birthday"]; $permission=["email", "user_birthday"];
$loginurl=$helper->getLoginUrl($redirect,$permission); $loginurl=$helper->getLoginUrl($redirect,$permission);
@@ -80,13 +92,14 @@ if(!isset($acces_token)){
$response = $fb->get('/me?fields=email,name,birthday'); $response = $fb->get('/me?fields=email,name,birthday');
$usernode = $response->getGraphUser(); $usernode = $response->getGraphUser();
// Get facebook information
$nameSplit = explode(" ", $usernode->getName()); $nameSplit = explode(" ", $usernode->getName());
$fbName = $nameSplit[0]; $fbName = $nameSplit[0];
$fbSurname = $nameSplit[1]; $fbSurname = $nameSplit[1];
$fbUserID = $usernode->getID(); $fbUserID = $usernode->getID();
$fbEmail = $usernode->getProperty("email"); $fbEmail = $usernode->getProperty("email");
// $image = 'https://graph.facebook.com/' . $usernode->getId() . '/picture?width=200';
// If there is an account, check if the account is banned or frozen.
if (fbLogin($fbUserID) == 1) { if (fbLogin($fbUserID) == 1) {
$fbID = getfbUserID($fbUserID)["userID"]; $fbID = getfbUserID($fbUserID)["userID"];
$fbRole = getfbUserID($fbUserID)["role"]; $fbRole = getfbUserID($fbUserID)["role"];
@@ -94,16 +107,20 @@ if(!isset($acces_token)){
echo "<script> echo "<script>
window.onload=bannedAlert(); window.onload=bannedAlert();
</script>"; </script>";
} else if($fbRole == "frozen"){ } else if($fbRole == "frozen"){
$_SESSION["userID"] = $fbID; $_SESSION["userID"] = $fbID;
echo "<script> echo "<script>
window.onload=frozenAlert(); window.onload=frozenAlert();
window.location.href= 'profile.php'; window.location.href= 'profile.php';
</script>"; </script>";
} else { } else {
$_SESSION["userID"] = $fbID; $_SESSION["userID"] = $fbID;
header("location: profile.php"); header("location: profile.php");
} }
// Registration with faceobook if theres no account.
} else { } else {
echo "<script> echo "<script>
window.onload = function() { window.onload = function() {

View File

@@ -1,3 +1,9 @@
<div class="login_containerNoscript">
<noscript>
<a href="http://www.enable-javascript.com/nl/" target="_blank">Om deze site te gebruiken is het noodzakelijk om Javascript aan te zetten.
Klikt hier voor de instructies om je Javascript te activeren</a>.
</noscript>
</div>
<div> <div>
<img style="width:50%;margin-left:25%" <img style="width:50%;margin-left:25%"
src="/img/top-logo.png" src="/img/top-logo.png"
@@ -7,10 +13,17 @@
<h1>Welkom bij MyHyvesbook+</h1> <h1>Welkom bij MyHyvesbook+</h1>
<!-- Login content --> <!-- Login content -->
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return=$correct
method="post" method="post"
name="login"> name="login">
<!-- Url parameter -->
<input type="hidden"
name="url"
value="<?php
if(isset($_GET["url"])) {
echo $_GET["url"];
} ?>"/>
<!-- Login name --> <!-- Login name -->
<div class="login_containerlogin"> <div class="login_containerlogin">
<label><b>Gebruikersnaam/Email</b></label> <label><b>Gebruikersnaam/Email</b></label>
@@ -41,8 +54,7 @@
<div class="login_containerlogin"> <div class="login_containerlogin">
<button type="submit" <button type="submit"
value="login" value="login"
name="submit" name="submit">
id="frm1_submit">
Inloggen Inloggen
</button> </button>
</div> </div>
@@ -62,74 +74,8 @@
<!--Login with facebook button--> <!--Login with facebook button-->
<?php <?php
if(!isset($acces_token)) { if(!isset($acces_token)) {
echo '<div class="login_containerlogin"><a class="fbButton" href="' . $loginurl . '">login with Facebook!</a></div>'; echo '<div class="login_containerlogin"><a class="fbButton" href="' . $loginurl . '"><i class="fa fa-facebook-square"></i> login met Facebook!</a></div>';
} else {
echo '<div class="login_containerlogin"><a class="fbButton" href="' . "https://myhyvesbookplus.nl/login.php" . '"><i class="fa fa-facebook-square"></i> loguit Facebook sessie</a></div>';
} }
?> ?>
<script>
// Get the modal
var modal = document.getElementById('myModal');
var registerModal = document.getElementById('registerModal');
var facebookModal = document.getElementById("fbModal");
// Get the button that opens the modal
var registerBtn = document.getElementById("registerBtn");
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
var registerSpan = document.getElementsByClassName("close")[1];
var facebookCLose = document.getElementsByClassName("close")[2];
/**
* When the user clicks the button, open the modal
*/
btn.onclick = function () {
modal.style.display = "block";
}
registerBtn.onclick = function () {
registerModal.style.display = "block";
}
/**
* WHen the user clicks on (X), close the modal
*/
span.onclick = function () {
modal.style.display = "none";
}
registerSpan.onclick = function () {
registerModal.style.display = "none";
}
facebookCLose.onclick = function () {
facebookModal.style.display = "none";
}
/**
* 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";
}
if (event.target == facebookModal) {
facebookModal.style.display = "none";
}
}
/**
* When ESC is pressed, close modal
*/
document.addEventListener('keyup', function(e) {
if (e.keyCode == 27) {
modal.style.display = "none";
registerModal.style.display = "none";
}
});
</script>

View File

@@ -1,5 +1,8 @@
<head> <head>
<meta charset="utf-8"> <meta charset="UTF-8">
<meta name="description" content="MyHyvesbook+ is het sociaal medium voor alle coole mensen. Stap nu over van facebook op het gloednieuwe en betere sociaal medium.">
<meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media">
<meta name="author" content="MyHyvesbookplus corporation">
<title>MyHyvesbook+</title> <title>MyHyvesbook+</title>
<link rel="stylesheet" <link rel="stylesheet"
type="text/css" type="text/css"
@@ -7,7 +10,11 @@
<link rel="stylesheet" <link rel="stylesheet"
type="text/css" type="text/css"
href="styles/index.css"> href="styles/index.css">
<link rel="stylesheet"
type="text/css"
href="styles/font-awesome.css">
<script src="js/jquery.js"></script> <script src="js/jquery.js"></script>
<script src="js/registerAndLogin.js"></script> <script src="js/registerAndLogin.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script> <script src='https://www.google.com/recaptcha/api.js'></script>
</head> </head>

View File

@@ -12,9 +12,11 @@
</h4> </h4>
<ul id="menu-groups-list" class="nav-list"> <ul id="menu-groups-list" class="nav-list">
</ul> </ul>
</section>
<section>
<ul class="nav-list"> <ul class="nav-list">
<li> <li>
<a href="#"> <a href="createGroup.php">
Maak een groep aan Maak een groep aan
</a> </a>
</li> </li>

View File

@@ -5,14 +5,6 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
?> ?>
<div class='post-header header'> <div class='post-header header'>
<h4><?=$post['title']?></h4> <h4><?=$post['title']?></h4>
<?php if (checkPermissionOnPost($postID, $_SESSION["userID"])) {?>
<button class="deleteButton"
onclick="deletePost('<?=$postID?>')"
type="submit">
<i class="fa fa-trash"></i>
<span>Verwijder post</span>
</button><br />
<?php } ?>
<span class='postinfo'> <span class='postinfo'>
gepost door <?=$fullname?>, gepost door <?=$fullname?>,
<span class='posttime' title='<?=$post['creationdate']?>'> <span class='posttime' title='<?=$post['creationdate']?>'>
@@ -20,7 +12,14 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
</span> </span>
</span> </span>
</div> </div>
<?php if (checkPermissionOnPost($postID, $_SESSION["userID"])) {?>
<button class="deleteButton fancy-button"
onclick="deletePost('<?=$postID?>')"
type="submit">
<span>Verwijder post</span>
<i class="fa fa-trash"></i>
</button><br />
<?php } ?>
<div class='post-content'> <div class='post-content'>
<p><?=$post['content']?></p> <p><?=$post['content']?></p>
</div> </div>

View File

@@ -1,16 +1,22 @@
<div class="content"> <div class="content">
<div class='platform alertbox' id="alertbox"> <div class='platform alertbox' id="alertbox">
<span id="alerttext"></span> <span class="alerttext" id="alerttext"></span>
</div> </div>
<div class="user-box"> <div class="user-box">
<img class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br /> <img alt="<?= $user["fname"] ?>" class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br />
<div class="platform"> <div class="platform">
<div class="status-buttons-container"> <div class="status-buttons-container">
<div>
<button disabled class="gray"> <button disabled class="gray">
<?= $user["onlinestatus"] ?> <?= $user["onlinestatus"] ?>
</button> </button>
<button disabled class="gray"><?= $user["role"] ?></button> </div>
<div>
<button disabled class="gray">
<?= $user["role"] ?>
</button>
</div>
</div> </div>
<div class="friend-button-container"> <div class="friend-button-container">
<p>:)</p> <p>:)</p>
@@ -19,19 +25,20 @@
<div class="profile-info"> <div class="profile-info">
<h2><?= $user["fname"]?> <?=$user["lname"]?></h2> <h2><?= $user["fname"]?> <?=$user["lname"]?></h2>
<h5><?=$user["username"]?></h5> <h5><?=$user["username"]?></h5>
<?php if (strlen($user["bio"]) <= 50) { <?php
if (strlen($user["bio"]) <= 50 and $showProfile) {
echo "<p>" . $user["bio"] . "</p>"; echo "<p>" . $user["bio"] . "</p>";
} ?> } ?>
</div> </div>
</div> </div>
</div> </div>
<?php if (strlen($user["bio"]) > 50) { <?php if (strlen($user["bio"]) > 50 and $showProfile) {
echo "<div class='platform'><h3>Bio:</h3><p>" . $user["bio"] . "</p></div>"; echo "<div class='platform'><h3>Bio:</h3><p>" . $user["bio"] . "</p></div>";
} ?> } ?>
<?php if($showProfile) { ?>
<div class="item-box platform"> <div class="item-box platform">
<h3>Informatie</h3> <h3>Informatie</h3>
<p>
<ul> <ul>
<?php if ($user["showBday"]) { ?> <?php if ($user["showBday"]) { ?>
<li>Leeftijd: <?= getAge($user["birthdate"]) ?> jaar</li> <li>Leeftijd: <?= getAge($user["birthdate"]) ?> jaar</li>
@@ -42,17 +49,23 @@
<li>Locatie: <?= $user["location"] ?></li> <li>Locatie: <?= $user["location"] ?></li>
<li>Lid sinds: <?= nicetime($user["creationdate"]) ?></li> <li>Lid sinds: <?= nicetime($user["creationdate"]) ?></li>
</ul> </ul>
</p>
</div> </div>
<div class="item-box platform"> <div class="item-box platform">
<h3>Vrienden</h3> <h3>Vrienden</h3>
<p> <p>
<?php <?php
while($friend = $profile_friends->fetch()) { $friendcount = $profile_friends->rowCount();
echo "<a href='profile.php?username=${friend["username"]}' data-title='${friend["username"]}'><img class='profile-picture' src='${friend["profilepicture"]}' alt='${friend["username"]}'s profielfoto></a>"; $frienddif = $friendcount - 7;
for ($i = 0; $i < min($friendcount, 7); $i += 1) {
$friend = $profile_friends->fetch();
echo "<a href='profile.php?username=${friend["username"]}' data-title='${friend["username"]}'><img class='profile-picture' height='42' width='42' src='${friend["profilepicture"]}' alt='${friend["username"]}' /></a>";
} }
if ($frienddif > 0) {
echo $frienddif === 1 ? "en nog 1 andere." : "...en nog $frienddif anderen.";
}
if($profile_friends->rowCount() === 0) { if($profile_friends->rowCount() === 0) {
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>"; echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
@@ -65,10 +78,18 @@
<h3>Groepen</h3> <h3>Groepen</h3>
<p> <p>
<?php <?php
while($group = $profile_groups->fetch()) { $groupcount = $profile_groups->rowCount();
$groupdif = $groupcount - 7;
for ($i = 0; $i < min($groupcount, 7); $i += 1) {
$group = $profile_groups->fetch();
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>"; 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 ($groupdif > 0) {
echo $groupdif === 1 ? "en nog 1 andere." : "...en nog $groupdif anderen.";
}
if($profile_groups->rowCount() === 0) { if($profile_groups->rowCount() === 0) {
echo "<p>Deze gebruiker is nog geen lid van een groep.</p>"; echo "<p>Deze gebruiker is nog geen lid van een groep.</p>";
} }
@@ -94,4 +115,5 @@
</div> </div>
</div> </div>
</div> </div>
<?php } ?>
</div> </div>

View File

@@ -4,7 +4,6 @@
<!-- The Modal --> <!-- The Modal -->
<div id="registerModal" class="modal"> <div id="registerModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct
method="post" method="post"
name="forgotPassword"> name="forgotPassword">
@@ -15,14 +14,11 @@
<h3>Registreer uw account</h3> <h3>Registreer uw account</h3>
</div> </div>
<div class="modal-body"> <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> <div class="login_containerregister"><label>U krijgt een bevestigingsemail na het registreren</label></div>
<!-- Error message --> <!-- Error message -->
<div class="login_containerfault"><?php echo $genericErr;?></span></div> <div class="login_containerfault"><span><?php echo $genericErr;?></span></div>
<!-- Register name --> <!-- Register name -->
<div class="login_containerregister"> <div class="login_containerregister">
@@ -82,7 +78,6 @@
placeholder="Voer uw wachtwoord in" placeholder="Voer uw wachtwoord in"
name="password" name="password"
value="<?php echo $password ?>" value="<?php echo $password ?>"
id="password"
required> required>
*<span class="error"> <?php echo $passwordErr;?></span> *<span class="error"> <?php echo $passwordErr;?></span>
<ul> <ul>
@@ -96,7 +91,6 @@
placeholder="Herhaal wachtwoord" placeholder="Herhaal wachtwoord"
name="confirmpassword" name="confirmpassword"
value="<?php echo $confirmpassword ?>" value="<?php echo $confirmpassword ?>"
id="confirmpassword"
title="Herhaal wachtwoord" title="Herhaal wachtwoord"
required> required>
*<span class="error"> <?php echo $confirmpasswordErr;?></span> *<span class="error"> <?php echo $confirmpasswordErr;?></span>
@@ -120,7 +114,6 @@
placeholder="Voer uw email in" placeholder="Voer uw email in"
name="email" name="email"
value="<?php echo $email ?>" value="<?php echo $email ?>"
id="email"
title="Voer een geldige email in" title="Voer een geldige email in"
required> required>
*<span class="error"> <?php echo $emailErr;?></span> *<span class="error"> <?php echo $emailErr;?></span>
@@ -133,7 +126,6 @@
placeholder="Herhaal uw email" placeholder="Herhaal uw email"
name="confirmEmail" name="confirmEmail"
value="<?php echo $confirmEmail ?>" value="<?php echo $confirmEmail ?>"
id="email"
title="Herhaal uw email" title="Herhaal uw email"
required> required>
*<span class="error"> <?php echo $confirmEmailErr;?></span> *<span class="error"> <?php echo $confirmEmailErr;?></span>
@@ -152,8 +144,7 @@
<!-- Register button --> <!-- Register button -->
<button type="submit" <button type="submit"
value="register" value="register"
name="submit" name="submit">
id="frm1_submit">
Registreer Registreer
</button> </button>
</div> </div>

View File

@@ -45,8 +45,8 @@ $settings = getSettings();
</li> </li>
<li> <li>
<?php $currentbday = new DateTime($settings["birthdate"]); ?> <?php $currentbday = new DateTime($settings["birthdate"]); ?>
<label for="bday">Geboortedatum</label> <label>Geboortedatum</label>
<select name='day' id="bday"> <select name='day'>
<?php for ($day = 1; $day <= 31; $day++): ?> <?php for ($day = 1; $day <= 31; $day++): ?>
<option value='<?=$day?>' <option value='<?=$day?>'
<?=($day == $currentbday->format("d")) ? "selected" : ""?> <?=($day == $currentbday->format("d")) ? "selected" : ""?>
@@ -55,7 +55,7 @@ $settings = getSettings();
</option> </option>
<?php endfor; ?> <?php endfor; ?>
</select> </select>
<select name='month' id="bday"> <select name='month'>
<?php <?php
$months = array ("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", $months = array ("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus",
"september", "oktober", "november", "december"); "september", "oktober", "november", "december");
@@ -68,7 +68,7 @@ $settings = getSettings();
</option> </option>
<?php endfor; ?> <?php endfor; ?>
</select> </select>
<select name='year' id="bday"> <select name='year'>
<?php <?php
$now = (new DateTime)->format("Y"); $now = (new DateTime)->format("Y");
for ($year = $now; $year >= 1900; $year--): ?> for ($year = $now; $year >= 1900; $year--): ?>