Compare commits
116 Commits
hendrik-se
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
490d39ba47 | ||
|
|
1193078e8f | ||
|
|
bcb01e3296 | ||
|
|
7cc6450e6a | ||
|
|
4643dfcddb | ||
|
|
833bfd3292 | ||
|
|
1ac6a7da87 | ||
|
|
52ce787241 | ||
|
|
fb5f76c499 | ||
|
|
f3aebddfea | ||
|
|
3aae884bb5 | ||
|
|
b07d0712aa | ||
|
|
05d6bf8aa6 | ||
|
|
1e60941a3f | ||
|
|
e3f4fa0b3c | ||
|
|
1fd984cc02 | ||
|
|
6d5de98c1d | ||
|
|
16f83d93ce | ||
|
|
306fd3090f | ||
|
|
771567660c | ||
|
|
4eae09dfc7 | ||
|
|
53e1d7fef3 | ||
|
|
c29be662bc | ||
|
|
000d1f4072 | ||
|
|
d260bf04bc | ||
|
|
a0ef234b79 | ||
|
|
da061de226 | ||
|
|
f18088d8d2 | ||
|
|
ac2ce3d07b | ||
|
|
ba6f86e70e | ||
|
|
c69b5d8ed3 | ||
|
|
5de3a84683 | ||
|
|
b8d6136a9d | ||
|
|
1862369013 | ||
|
|
8d70804155 | ||
|
|
0ac12f5110 | ||
|
|
5e8fa6791f | ||
|
|
28e9269b52 | ||
|
|
bb352c7a7a | ||
|
|
fe190975d5 | ||
|
|
0f202088a1 | ||
|
|
87b0ab5892 | ||
|
|
c8dbdfe70e | ||
|
|
8949d14a5e | ||
|
|
ecd24ef442 | ||
|
|
50e94fb8ed | ||
|
|
fde736b8c5 | ||
|
|
127162b938 | ||
|
|
02349dbe28 | ||
|
|
da01729b61 | ||
|
|
820ffb4a62 | ||
|
|
1a3efe9669 | ||
|
|
6d739a4480 | ||
|
|
ab21226925 | ||
|
|
7e4107ac8b | ||
|
|
de96ae8263 | ||
|
|
74e91ed7cb | ||
|
|
e9468b0ec8 | ||
|
|
839fb247b4 | ||
|
|
bf298f4b43 | ||
|
|
74145d5d1c | ||
|
|
1486e71207 | ||
|
|
b206d243b9 | ||
|
|
4f731e12fe | ||
|
|
f8c9454b85 | ||
|
|
93b908fb13 | ||
|
|
6fd5401c86 | ||
|
|
9165f8fa1b | ||
|
|
380d8fa83a | ||
|
|
afb45d6709 | ||
|
|
1c53eab2fa | ||
|
|
28254d98e4 | ||
|
|
8a3cfebf55 | ||
|
|
b1941f0191 | ||
|
|
a27a4881c3 | ||
|
|
cfa7c870f0 | ||
|
|
e60578dc43 | ||
|
|
9426f4d6ac | ||
|
|
7f48cae019 | ||
|
|
33399639b1 | ||
|
|
52e40242e6 | ||
|
|
8a6acbc52a | ||
|
|
6fc2f71517 | ||
|
|
1672ce6086 | ||
|
|
188741ddf5 | ||
|
|
4a7a91ecd9 | ||
|
|
1c1283243c | ||
|
|
417124a1fe | ||
|
|
d24ed89096 | ||
|
|
a92b0fe892 | ||
|
|
5c1b2d1b21 | ||
|
|
3abaeba52c | ||
|
|
93e63111de | ||
|
|
feba1d9786 | ||
|
|
6ed19d9060 | ||
|
|
d4d16661df | ||
|
|
044ed6a9d3 | ||
|
|
328ce69144 | ||
|
|
9d675dd897 | ||
|
|
86b02973e4 | ||
|
|
ab5f243281 | ||
|
|
327a6a8f5c | ||
|
|
d03d58ce37 | ||
|
|
487e0a0523 | ||
|
|
1dfc14e6f0 | ||
|
|
cc9866d3dd | ||
|
|
04df02862f | ||
|
|
67eb7b991e | ||
|
|
90ac38acdd | ||
|
|
60b55b3f04 | ||
|
|
70b7e12559 | ||
|
|
e299ef59e8 | ||
|
|
0546b8689d | ||
|
|
6c43cae1cb | ||
|
|
3af38cd088 | ||
|
|
cfe2928f7b |
@@ -3,9 +3,9 @@ session_start();
|
||||
|
||||
require_once "../../queries/post.php";
|
||||
require_once "../../queries/user.php";
|
||||
|
||||
if (isset($_SESSION["userID"]) and
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' and
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' and
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
if (empty($_POST["postID"]) or empty($_SESSION["userID"])) {
|
||||
|
||||
@@ -6,6 +6,7 @@ require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/private_message.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
// Check if the user is allowed to load them.
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
echo selectAllUnreadChat();
|
||||
|
||||
@@ -6,6 +6,7 @@ require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once ("../../queries/user.php");
|
||||
|
||||
// Check if the user is allowed to load them.
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
@@ -7,9 +7,11 @@ require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
// Check if the user is allowed to load them.
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (isset($_SESSION["userID"])) {
|
||||
// Echo the limited or unlimited users.
|
||||
if (isset($_POST["limit"])) {
|
||||
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"]));
|
||||
} else if (isset($_GET["limit"])) {
|
||||
|
||||
@@ -8,8 +8,10 @@ require_once ("../../queries/group_member.php");
|
||||
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
// Check if the user is allowed to load them.
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
// Echo the limited or unlimited groups.
|
||||
if (isset($_POST["limit"])) {
|
||||
echo selectLimitedGroupsFromUser($_SESSION["userID"], (int)test_input($_POST["limit"]));
|
||||
} else {
|
||||
|
||||
@@ -8,8 +8,10 @@ require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/friendship.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
// Check if the user is allowed to get the messages.
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
// Check if the users wants new messages or old ones, and give the right one back.
|
||||
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
|
||||
setLastVisited(test_input($_POST["destination"]));
|
||||
echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"]));
|
||||
|
||||
@@ -7,9 +7,9 @@ require_once("../../queries/connect.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if ($_POST['button'] == 'reaction') {
|
||||
if (empty($_POST['newcomment-content'])) {
|
||||
|
||||
@@ -8,17 +8,20 @@ require_once("../../queries/connect.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
if (empty($_POST["title"]) or
|
||||
empty($_POST["content"]) or
|
||||
empty($_SESSION["userID"])
|
||||
) {
|
||||
if (empty($_SESSION["userID"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
if (empty(test_input($_POST["title"])) or
|
||||
empty(test_input($_POST["content"]))
|
||||
) {
|
||||
echo "empty";
|
||||
} else {
|
||||
if (empty($_POST["group"])) {
|
||||
// User Post
|
||||
makePost(
|
||||
@@ -43,6 +46,7 @@ if (isset($_SESSION["userID"]) &&
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "frozen";
|
||||
}
|
||||
@@ -6,12 +6,16 @@ require_once("../../queries/private_message.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
// Check if the user is allowed to send a message.
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (!empty(test_input($_POST["destination"])) &&
|
||||
!empty(test_input($_POST["content"]))
|
||||
) {
|
||||
// Send the message.
|
||||
// Returns false when it didn't succeed sending the message.
|
||||
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
|
||||
echo 1;
|
||||
} else {
|
||||
|
||||
BIN
website/public/apple-touch-icon-114x114-precomposed.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
website/public/apple-touch-icon-120x120-precomposed.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
website/public/apple-touch-icon-144x144-precomposed.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
website/public/apple-touch-icon-152x152-precomposed.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
website/public/apple-touch-icon-180x180-precomposed.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
website/public/apple-touch-icon-57x57-precomposed.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
website/public/apple-touch-icon-60x60-precomposed.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
website/public/apple-touch-icon-72x72-precomposed.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
website/public/apple-touch-icon-76x76-precomposed.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
website/public/apple-touch-icon-precomposed.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
@@ -4,6 +4,7 @@ session_start();
|
||||
|
||||
include_once ("../../queries/friendship.php");
|
||||
|
||||
// Initialize variables to given or default values.
|
||||
if (isset($_POST["action"])) {
|
||||
$action = $_POST["action"];
|
||||
} else {
|
||||
@@ -18,6 +19,8 @@ if (isset($_POST["actionType"])) {
|
||||
|
||||
$friends = json_decode($_POST["friends"]);
|
||||
|
||||
|
||||
// Foreach friend, return them as list item.
|
||||
foreach($friends as $i => $friend) {
|
||||
$friendshipStatus = getFriendshipStatus($friend->userID);
|
||||
?>
|
||||
@@ -38,7 +41,7 @@ foreach($friends as $i => $friend) {
|
||||
<?= $friend->fullname ?><br/>
|
||||
<span style='color: #666'><?php
|
||||
if (isset($friend->username)) {
|
||||
echo $friend->username;
|
||||
echo $friend->usernameshort;
|
||||
} else if (isset($friend->content)) {
|
||||
echo $friend->content;
|
||||
}
|
||||
@@ -48,6 +51,7 @@ foreach($friends as $i => $friend) {
|
||||
</button>
|
||||
</form>
|
||||
<?php
|
||||
// Add friendship options if possible.
|
||||
if ($friendshipStatus > 1) {
|
||||
if ($friendshipStatus == 2) {
|
||||
$denyName = "Annuleer";
|
||||
|
||||
@@ -6,6 +6,7 @@ include_once ("../../queries/group_member.php");
|
||||
|
||||
$groups = json_decode($_POST["groups"]);
|
||||
|
||||
// Add each group as list item.
|
||||
foreach($groups as $i => $group) {
|
||||
?>
|
||||
<li class='group-item'>
|
||||
|
||||
8
website/public/bits/niet-slecht.php
Normal 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>
|
||||
12
website/public/browserconfig.xml
Executable file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square70x70logo src="tiny.png"/>
|
||||
<square150x150logo src="square.jpg"/>
|
||||
<wide310x150logo src="wide.jpg"/>
|
||||
<square310x310logo src="large.jpg"/>
|
||||
<TileColor>#000000</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
36
website/public/createGroup.php
Normal 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>
|
||||
BIN
website/public/favicon-1.png
Normal file
|
After Width: | Height: | Size: 492 B |
BIN
website/public/favicon-2.png
Normal file
|
After Width: | Height: | Size: 782 B |
BIN
website/public/favicon-3.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
website/public/favicon-4.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
website/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 97 KiB |
@@ -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');
|
||||
@@ -13,13 +13,15 @@
|
||||
|
||||
include_once("../queries/group_page.php");
|
||||
|
||||
$group = selectGroupByName($_GET["groupname"]);
|
||||
$members = selectGroupMembers(2);
|
||||
if(isset($_SESSION["userID"]) and !$group = selectGroupByName($_GET["groupname"])) {
|
||||
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.
|
||||
|
||||
72
website/public/groupAdmin.php
Normal 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>
|
||||
@@ -24,12 +24,14 @@ $(window).on("load", function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Toggles all checkboxes based on one.
|
||||
function checkAll() {
|
||||
$('.checkbox-list').each(function () {
|
||||
$(this).prop('checked', $('#checkall').prop('checked'));
|
||||
});
|
||||
}
|
||||
|
||||
// Simple function that checks if checkall should stay checked.
|
||||
function checkCheckAll() {
|
||||
var checked = true;
|
||||
|
||||
@@ -43,6 +45,7 @@ function checkCheckAll() {
|
||||
$('#checkall').prop('checked', checked);
|
||||
}
|
||||
|
||||
// Toggle of filter options.
|
||||
function changeFilter() {
|
||||
if ($('#pagetype').find(":selected").val() == "group") {
|
||||
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() {
|
||||
$('#currentpage').prop('value', 1);
|
||||
adminSearch();
|
||||
}
|
||||
|
||||
// AJAX live search.
|
||||
function adminSearch() {
|
||||
$.post(
|
||||
"API/adminSearchUsers.php",
|
||||
@@ -74,6 +79,7 @@ function adminSearch() {
|
||||
})
|
||||
}
|
||||
|
||||
// AJAX live update.
|
||||
function adminUpdate(form) {
|
||||
$.post(
|
||||
"API/adminChangeUser.php",
|
||||
@@ -83,6 +89,7 @@ function adminUpdate(form) {
|
||||
})
|
||||
}
|
||||
|
||||
// AJAX pagenumber functionality.
|
||||
function updatePageN() {
|
||||
$.post(
|
||||
"API/adminPageNumber.php",
|
||||
@@ -92,11 +99,13 @@ function updatePageN() {
|
||||
})
|
||||
}
|
||||
|
||||
// Intended for the edit button to show a form.
|
||||
function toggleBancomment(button) {
|
||||
$(button).siblings("div").toggle();
|
||||
$(button).toggle();
|
||||
}
|
||||
|
||||
// AJAX value editing.
|
||||
function editComment(form) {
|
||||
$.post(
|
||||
"API/adminChangeUser.php",
|
||||
|
||||
@@ -9,18 +9,25 @@ $(document).ready(function() {
|
||||
$(".chat-field").hide();
|
||||
});
|
||||
|
||||
// This function loads the new messages and runs the addMessages function to show them.
|
||||
function loadMessages() {
|
||||
// If the function is not running elsewhere, run it here.
|
||||
if (!gettingMessages) {
|
||||
gettingMessages = true;
|
||||
// Get the messages.
|
||||
$.post(
|
||||
"API/loadMessages.php",
|
||||
$("#lastIDForm").serialize()
|
||||
).done(function (data) {
|
||||
// Post the messages in the chat.
|
||||
if (data && data != "[]") {
|
||||
messages = JSON.parse(data);
|
||||
addMessages(messages);
|
||||
$("#lastID").val(messages[messages.length - 1].messageID);
|
||||
}
|
||||
|
||||
loadUnreadMessages();
|
||||
|
||||
gettingMessages = false;
|
||||
});
|
||||
} else {
|
||||
@@ -28,7 +35,7 @@ function loadMessages() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send a message to a friend of the user.
|
||||
function sendMessage() {
|
||||
$.post(
|
||||
"API/sendMessage.php",
|
||||
@@ -36,43 +43,60 @@ function sendMessage() {
|
||||
).done(function(response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
} 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.
|
||||
loadMessages();
|
||||
});
|
||||
|
||||
$("#newContent").val("");
|
||||
loadMessages();
|
||||
$("#newContent").focus();
|
||||
}
|
||||
|
||||
// Add messages to the chat.
|
||||
function addMessages(messages) {
|
||||
var messagesText = "";
|
||||
|
||||
// Loop over all the messages.
|
||||
for(var i in messages) {
|
||||
// Initialize message variables
|
||||
// Initialize message variables.
|
||||
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;
|
||||
thisDate.setHours(0,0,0,0);
|
||||
|
||||
// See where the message has been send from, so it shows on the right side.
|
||||
if (messages[i].destination == $(".destinationID").val()) {
|
||||
type = "chat-message-self";
|
||||
} else {
|
||||
type = "chat-message-other";
|
||||
}
|
||||
|
||||
// If it is the first message, open the message box and maybe add a year.
|
||||
if (i == 0) {
|
||||
previousDate = thisDate;
|
||||
if (thisDate.getTime() > previousDate.getTime()) {
|
||||
messagesText += '\
|
||||
<div class="day-message"> \
|
||||
<div class="day-message-content">\
|
||||
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
|
||||
</div> \
|
||||
</div>';
|
||||
}
|
||||
previousDate = thisDate;
|
||||
previousTime = thisTime;
|
||||
previousType = 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,
|
||||
} else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) {
|
||||
// Close the previous message.
|
||||
messagesText += '<div class="chat-time">\
|
||||
' + thisTime + '\
|
||||
</div></div></div>';
|
||||
|
||||
previousTime = thisTime;
|
||||
previousType = type;
|
||||
// If the date is different, add a new date.
|
||||
if (thisDate > previousDate) {
|
||||
previousDate = thisDate;
|
||||
messagesText += '\
|
||||
@@ -83,8 +107,11 @@ function addMessages(messages) {
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Open the new message.
|
||||
messagesText += '<div class="chat-message"><div class="' + type + '">';
|
||||
}
|
||||
|
||||
// Add the content of the message in the new box.
|
||||
messagesText += fancyText(messages[i].content) + "<br />";
|
||||
}
|
||||
|
||||
@@ -93,11 +120,14 @@ function addMessages(messages) {
|
||||
' + thisTime + '\
|
||||
</div></div></div>';
|
||||
|
||||
// Add all the new created messaged to the chat.
|
||||
$("#chat-history").append(messagesText);
|
||||
|
||||
// Scroll down, so the user can see the new messages.
|
||||
$("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight);
|
||||
}
|
||||
|
||||
// Switch to a different user.
|
||||
function switchUser(userID) {
|
||||
previousDate = new Date("1970-01-01 00:00:00");
|
||||
$(".chat-field").show();
|
||||
@@ -108,6 +138,7 @@ function switchUser(userID) {
|
||||
$("#friend-item-" + userID).addClass("active-friend-chat");
|
||||
}
|
||||
|
||||
// Insert a message in the chat, this is used when it is empty.
|
||||
function sayEmpty() {
|
||||
$("#chat-history").html("Probeer ook eens foto's en video's te sturen");
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
1
website/public/js/dobPicker.min.js
vendored
@@ -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")}})})}});
|
||||
@@ -1,6 +1,8 @@
|
||||
// Show the right friendship buttonsto the user.
|
||||
function placeFriendButtons() {
|
||||
$.post("API/getFriendshipStatus.php", { usr: userID })
|
||||
.done(function(data) {
|
||||
//save the friendship status
|
||||
var friendshipStatus = data;
|
||||
var $buttonContainer = $("div.friend-button-container");
|
||||
$("#start-profile-chat").hide();
|
||||
@@ -19,25 +21,28 @@ function placeFriendButtons() {
|
||||
case "0":
|
||||
value1 = "request";
|
||||
class1 = "green";
|
||||
text1 = "Bevriend";
|
||||
icon1 = "fa-handshake-o";
|
||||
text1 = "Word vrienden";
|
||||
icon1 = "fa-user-plus";
|
||||
break;
|
||||
// Users are friends.
|
||||
case "1":
|
||||
value1 = userID;
|
||||
class1 = "green";
|
||||
text1 = "Chat";
|
||||
icon1 = "fa-comment-o";
|
||||
icon1 = "fa-comment";
|
||||
value2 = "delete";
|
||||
class2 = "red";
|
||||
text2 = "Verwijder";
|
||||
icon2 = "fa-times";
|
||||
text2 = "Ontvriend";
|
||||
icon2 = "fa-user-times";
|
||||
break;
|
||||
// This user sent request.
|
||||
case "2":
|
||||
value1 = "delete";
|
||||
class1 = "red";
|
||||
text1 = "Trek verzoek in";
|
||||
icon1 = "fa-cross";
|
||||
icon1 = "fa-times";
|
||||
break;
|
||||
// Other user sent request.
|
||||
case "3":
|
||||
value1 = "accept";
|
||||
class1 = "green";
|
||||
@@ -50,17 +55,20 @@ function placeFriendButtons() {
|
||||
break;
|
||||
}
|
||||
|
||||
// Append buttons to the container.
|
||||
$buttonContainer.append(
|
||||
"<button class='"+ class1 +" friend-button' value='"+ value1 +"'>" +
|
||||
"<i class='fa "+ icon1 +"'></i> " + text1 +
|
||||
"</button>");
|
||||
"<div><button class='"+ class1 +" fancy-button friend-button' value='"+ value1 +"'>" +
|
||||
"<span>"+ text1 +"</span>" +
|
||||
"<i class='fa fa-fw "+ icon1 +"'></i> " +
|
||||
"</button></div>");
|
||||
$buttonContainer.append(
|
||||
"<button class='"+ class2 +" friend-button' value='"+ value2 +"'>" +
|
||||
"<i class='fa "+ icon2 +"'></i> " + text2 +
|
||||
"</button>");
|
||||
"<div><button class='"+ class2 +" fancy-button friend-button' value='"+ value2 +"'>" +
|
||||
"<span>"+ text2 +"</span>" +
|
||||
"<i class='fa fa-fw "+ icon2 +"'></i> " +
|
||||
"</button></div>");
|
||||
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
// Gets triggered when a friend button is triggered.
|
||||
$buttonContainer.find("button").click(function() {
|
||||
if (isNaN(this.value))
|
||||
editFriendship(userID, this.value);
|
||||
else if (this.value != "")
|
||||
|
||||
@@ -3,24 +3,40 @@ function placeGroupButtons() {
|
||||
.done(function(data) {
|
||||
var $buttonContainer = $("div.group-button-container");
|
||||
|
||||
// Append the right group button to the button container.
|
||||
// When user is not a member
|
||||
if(data == 'none') {
|
||||
$buttonContainer.append(
|
||||
"<button class='green group-button' value='request'>" +
|
||||
"<i class='fa fa-plus'></i> Voeg toe" +
|
||||
"<button class='green group-button fancy-button' value='request'>" +
|
||||
"<span>Treed toe</span><i class='fa fa-plus'></i>" +
|
||||
"</button>");
|
||||
|
||||
// when user sent a request to become a member.
|
||||
} else if(data == 'request') {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Trek verzoek in" +
|
||||
"<button class='red group-button fancy-button' value='none'>" +
|
||||
"<span>Trek verzoek in</span><i class='fa fa-times'></i>" +
|
||||
"</button>");
|
||||
// When user is a member of the group.
|
||||
} 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 {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Verlaat groep" +
|
||||
"<button class='red group-button fancy-button' value='none'>" +
|
||||
"<span>Verlaat groep</span><i class='fa fa-sign-out'></i>" +
|
||||
"</button>");
|
||||
}
|
||||
|
||||
// Gets triggered when a group button is clicked.
|
||||
$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})
|
||||
.done(function () {
|
||||
$buttonContainer.children().remove();
|
||||
@@ -28,6 +44,7 @@ function placeGroupButtons() {
|
||||
updateMenus();
|
||||
}).fail(function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
71
website/public/js/loginRegisterModals.js
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
// 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");
|
||||
var fbBtn = document.getElementById("fbBtn");
|
||||
|
||||
// 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";
|
||||
}
|
||||
fbBtn.onclick = function () {
|
||||
facebookModal.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.
|
||||
*/
|
||||
@@ -3,8 +3,7 @@ var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "a
|
||||
|
||||
function fancyText(text) {
|
||||
// Add links, images, gifs and (youtube) video's.
|
||||
var regex = /(https?:\/\/.[^ <>"]*)/ig;
|
||||
text = text.replace(regex, function(link) {
|
||||
text = text.replace(/(https?:\/\/.[^ \n<>"]*)/ig, function(link) {
|
||||
// Add images
|
||||
if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
|
||||
return "<img alt='" + link + "' src='" + link + "' />";
|
||||
@@ -14,14 +13,14 @@ function fancyText(text) {
|
||||
return "<video width='100%'>" +
|
||||
"<source src='"+ link +"' type='video/mp4'>" +
|
||||
"<b>Je browser ondersteund geen video</b>" +
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'>Speel af</button>";
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'><i class='fa fa-play'></i></button>";
|
||||
}
|
||||
// Add ogg video's
|
||||
else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) {
|
||||
return "<video width='100%'>" +
|
||||
"<source src='"+ link +"' type='video/ogg'>" +
|
||||
"<b>Je browser ondersteund geen video</b>" +
|
||||
"</video><button onclick='$(this).prev().get(0).play();'>Speel af</button>";
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'><i class='fa fa-play'></i></button>";
|
||||
}
|
||||
// Add youtube video's
|
||||
else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) {
|
||||
@@ -31,13 +30,15 @@ function fancyText(text) {
|
||||
}
|
||||
// Add links
|
||||
else {
|
||||
return "<a href='" + link + "'>" + link + "</a>";
|
||||
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
|
||||
}
|
||||
});
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
// This function gets the value of a cookie when given a key.
|
||||
// If it didn´t find any compatible cookie, it returns false.
|
||||
function getCookie(key) {
|
||||
cookies = document.cookie.split("; ");
|
||||
for (var i in cookies) {
|
||||
@@ -49,6 +50,7 @@ function getCookie(key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Edit the friendship status of two users.
|
||||
function editFriendship(userID, value) {
|
||||
$.post("API/editFriendship.php", { usr: userID, action: value })
|
||||
.done(function() {
|
||||
@@ -57,6 +59,8 @@ function editFriendship(userID, value) {
|
||||
});
|
||||
}
|
||||
|
||||
// Show the given friends in the given list.
|
||||
// The friends are giving in JSON, and the list is giving with a hashtag.
|
||||
function showFriends(friends, list) {
|
||||
if(friends && friends != "[]") {
|
||||
$(list).load("bits/friend-item.php", {
|
||||
@@ -69,6 +73,8 @@ function showFriends(friends, list) {
|
||||
}
|
||||
}
|
||||
|
||||
// Show the given friends in the given list.
|
||||
// This function supports more options given as parameters. This adds extra functionality.
|
||||
function showFriendsPlus(friends, list, limit, action, actionType) {
|
||||
if(friends && friends != "[]") {
|
||||
$(list).load("bits/friend-item.php", {
|
||||
@@ -84,6 +90,7 @@ function showFriendsPlus(friends, list, limit, action, actionType) {
|
||||
}
|
||||
}
|
||||
|
||||
// Show the given groups in the given list.
|
||||
function showGroups(groups, list) {
|
||||
if(groups && groups != "[]") {
|
||||
$(list).load("bits/group-item.php", {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Vertical margin between two posts.
|
||||
margin = 20;
|
||||
|
||||
// scrolling modal taken from http://stackoverflow.com/questions/10476632/how-to-scroll-the-page-when-a-modal-dialog-is-longer-than-the-screen
|
||||
@@ -11,9 +12,12 @@ function scrollbarMargin(width, overflow) {
|
||||
});
|
||||
}
|
||||
|
||||
// Get post from the server.
|
||||
function requestPost(postID) {
|
||||
// Make the modal view visible.
|
||||
$(".modal").show();
|
||||
|
||||
// Send get request to the server to load the post.
|
||||
$.get("API/loadPost.php", { postID : postID }).done(function(data) {
|
||||
$('.modal-default').hide();
|
||||
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
|
||||
@@ -23,22 +27,48 @@ function requestPost(postID) {
|
||||
});
|
||||
}
|
||||
|
||||
// Create a new post.
|
||||
function postPost() {
|
||||
title = $("input.newpost[name='title']").val();
|
||||
content = $("textarea.newpost[name='content']").val();
|
||||
|
||||
// Masonrymode 2: when on group page and user is an admin.
|
||||
if (masonryMode == 2) {
|
||||
// Create the new group post.
|
||||
$.post("API/postPost.php", { title: title,
|
||||
content : content,
|
||||
group : groupID })
|
||||
.done(function() {
|
||||
.done(function(data) {
|
||||
if (data == "empty") {
|
||||
$('#alertbox').show();
|
||||
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
|
||||
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 {
|
||||
$('#alertbox').hide();
|
||||
masonry(masonryMode);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Create the new user post.
|
||||
$.post("API/postPost.php", { title: title,
|
||||
content : content })
|
||||
.done(function() {
|
||||
.done(function(data) {
|
||||
if (data == "empty") {
|
||||
$('#alertbox').show();
|
||||
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
|
||||
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 {
|
||||
$('#alertbox').hide();
|
||||
masonry(masonryMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,6 +84,7 @@ var postAmount = 0;
|
||||
var noposts = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
// Initialise variables for masonry.
|
||||
windowWidth = $(window).width();
|
||||
columnCount = Math.floor($(".posts").width() / 250);
|
||||
columns = new Array(columnCount);
|
||||
@@ -64,13 +95,30 @@ $(window).on("load", function() {
|
||||
$(".modal-close").click(function (){closeModal()});
|
||||
|
||||
// http://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom
|
||||
// Infinite scroll.
|
||||
window.onscroll = function(ev) {
|
||||
if($(window).scrollTop() + $(window).height() == $(document).height() ) {
|
||||
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();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Hide modal view from the screen.
|
||||
function closeModal() {
|
||||
$(".modal").hide();
|
||||
scrollbarMargin(0, 'auto');
|
||||
@@ -78,30 +126,38 @@ function closeModal() {
|
||||
$('.modal-default').show();
|
||||
}
|
||||
|
||||
// Will fire when user resizes the window.
|
||||
$(window).resize(function() {
|
||||
clearTimeout(window.resizedFinished);
|
||||
window.resizeFinished = setTimeout(function() {
|
||||
// Check if the width of the screen changed.
|
||||
if ($(window).width() != windowWidth) {
|
||||
// Save width.
|
||||
windowWidth = $(window).width();
|
||||
|
||||
// Check if there fit more or less columns in the new width.
|
||||
if (columnCount != Math.floor($(".posts").width() / 250)) {
|
||||
columnCount = Math.floor($(".posts").width() / 250);
|
||||
// Respawn the masonry grid.
|
||||
masonry(masonryMode);
|
||||
}
|
||||
}
|
||||
}, 250);
|
||||
});
|
||||
|
||||
// Select the container for masonry.
|
||||
var $container = $(".posts");
|
||||
|
||||
// Spawn the masonry grid.
|
||||
function masonry(mode) {
|
||||
// save the masonry mode.
|
||||
masonryMode = mode;
|
||||
$container.children().remove();
|
||||
|
||||
/*
|
||||
* Initialise columns.
|
||||
*/
|
||||
// reinit posts
|
||||
noposts = false;
|
||||
postAmount = 0;
|
||||
|
||||
// Initialise columns.
|
||||
for (i = 0; i < columnCount; i++) {
|
||||
$column = $("<div class=\"column\">");
|
||||
$column.width(100/columnCount + "%");
|
||||
@@ -109,34 +165,30 @@ function masonry(mode) {
|
||||
columns[i] = [0, $column];
|
||||
}
|
||||
|
||||
// Place the form for new posts.
|
||||
if(mode > 0) {
|
||||
$postInput = $("<div class=\"post platform\">");
|
||||
$form = $("<form class=\"newpost\" action=\"API/postPost.php\" method=\"post\" onsubmit=\"postPost(); return false;\">");
|
||||
$postInput.append($form);
|
||||
|
||||
//Add extra input for group posts.
|
||||
if(mode == 2) {
|
||||
$form.append($("<input class=\"newpost\" type=\"hidden\" name=\"group\" value=\"" + groupID + "\">"));
|
||||
}
|
||||
|
||||
$form.append($("<input class=\"newpost\" name=\"title\" placeholder=\"Titel\" type=\"text\">"));
|
||||
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\" maxlength='1000'></textarea><span></span>"));
|
||||
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
|
||||
$form.append($("<button type=\"submit\"><i class='fa fa-sticky-note-o'></i> Plaats!</button>"));
|
||||
columns[0][1].append($postInput);
|
||||
|
||||
columns[0][0] = $postInput.height() + margin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function will find the column with the shortest height.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Get the posts from the server.
|
||||
*/
|
||||
// Get the posts from the server.
|
||||
loadMorePosts(userID, groupID, 0, postLimit);
|
||||
}
|
||||
|
||||
// Find the column with the shortest hight.
|
||||
function getShortestColumn(columns) {
|
||||
column = columns[0];
|
||||
|
||||
@@ -148,20 +200,20 @@ function getShortestColumn(columns) {
|
||||
return column;
|
||||
}
|
||||
|
||||
// Load certain range of posts.
|
||||
function loadMorePosts(uID, gID, offset, limit) {
|
||||
if (noposts) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(uID, gID, offset, limit);
|
||||
|
||||
|
||||
// Get a list of posts from the server.
|
||||
$.post("API/getPosts.php", { usr : uID,
|
||||
grp : gID,
|
||||
offset : offset,
|
||||
limit : limit})
|
||||
.done(function(data) {
|
||||
if (!data) {
|
||||
// No posts were found, show noposts bar to user.
|
||||
$('.noposts').show();
|
||||
noposts = true;
|
||||
return;
|
||||
@@ -169,9 +221,7 @@ function loadMorePosts(uID, gID, offset, limit) {
|
||||
|
||||
posts = JSON.parse(data);
|
||||
|
||||
/*
|
||||
* Rearange the objects.
|
||||
*/
|
||||
// Rearange the objects.
|
||||
$.each(posts, function() {
|
||||
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
|
||||
$post.append($("<h2>").html(this["title"]));
|
||||
|
||||
@@ -8,6 +8,8 @@ function postComment(buttonValue) {
|
||||
).done(function (response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
} else if (response == "logged out") {
|
||||
window.location.href = "login.php?url=" + window.location.pathname;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,10 +32,10 @@ function deletePost(postID) {
|
||||
).done(function (response) {
|
||||
if (response == "frozen") {
|
||||
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();
|
||||
masonry(masonryMode);
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ $(window).on('load', function () {
|
||||
pageNumber();
|
||||
});
|
||||
|
||||
// Search for the users and put them in the user list.
|
||||
function searchUsers() {
|
||||
$.post(
|
||||
"API/searchUsers.php",
|
||||
@@ -13,6 +14,7 @@ function searchUsers() {
|
||||
});
|
||||
}
|
||||
|
||||
// Search for the groups and put them in the group list.
|
||||
function searchGroups() {
|
||||
$.post(
|
||||
"API/searchGroups.php",
|
||||
@@ -24,6 +26,7 @@ function searchGroups() {
|
||||
});
|
||||
}
|
||||
|
||||
// Get the page numbers and return them in the select.
|
||||
function pageNumber() {
|
||||
var input = input2 = $('#search-form').serialize();
|
||||
$.post(
|
||||
|
||||
BIN
website/public/large.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
website/public/launcher-icon-0-75x.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
website/public/launcher-icon-1-5x.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
website/public/launcher-icon-1x.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
website/public/launcher-icon-2x.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
website/public/launcher-icon-3x.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
website/public/launcher-icon-4x.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
@@ -13,18 +13,12 @@
|
||||
?>
|
||||
<body>
|
||||
<?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");
|
||||
|
||||
/* This view adds login view */
|
||||
include("../views/login-view.php");
|
||||
?>
|
||||
<script src="js/loginRegisterModals.js"></script>;
|
||||
</body>
|
||||
</html>
|
||||
|
||||
44
website/public/manifest.json
Executable file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "Web Application Manifest Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "launcher-icon-0-75x.png",
|
||||
"sizes": "36x36",
|
||||
"type": "image/png",
|
||||
"density": "0.75"
|
||||
},
|
||||
{
|
||||
"src": "launcher-icon-1x.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image/png",
|
||||
"density": "1.0"
|
||||
},
|
||||
{
|
||||
"src": "launcher-icon-1-5x.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"density": "1.5"
|
||||
},
|
||||
{
|
||||
"src": "launcher-icon-2x.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"density": "2.0"
|
||||
},
|
||||
{
|
||||
"src": "launcher-icon-3x.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"density": "3.0"
|
||||
},
|
||||
{
|
||||
"src": "launcher-icon-4x.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"density": "4.0"
|
||||
}
|
||||
],
|
||||
"start_url": "index.html",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait"
|
||||
}
|
||||
@@ -25,9 +25,16 @@ if(empty($_GET["username"])) {
|
||||
$userID = getUserID($_GET["username"]);
|
||||
}
|
||||
|
||||
$user = selectUser($_SESSION["userID"], $userID);
|
||||
|
||||
if (isset($_SESSION["userID"]) and !$user = selectUser($_SESSION["userID"], $userID)) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header("Location: error/404.php");
|
||||
die();
|
||||
}
|
||||
|
||||
$profile_friends = selectAllFriends($userID);
|
||||
$profile_groups = selectAllUserGroups($userID);
|
||||
$showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID;
|
||||
|
||||
|
||||
if ($userID == $_SESSION["userID"]) {
|
||||
|
||||
@@ -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>
|
||||
@@ -14,11 +14,13 @@
|
||||
<?php
|
||||
$alertClass;
|
||||
$alertMessage;
|
||||
|
||||
// Select which button has been pressed.
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
case "profile":
|
||||
updateSettings();
|
||||
checkUpdateSettings();
|
||||
break;
|
||||
case "password":
|
||||
changePassword();
|
||||
@@ -29,7 +31,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
case "picture":
|
||||
updateAvatar();
|
||||
break;
|
||||
|
||||
}
|
||||
} catch (AlertMessage $w) {
|
||||
$alertClass = $w->getClass();
|
||||
|
||||
BIN
website/public/square.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
@@ -1,11 +1,13 @@
|
||||
.admin-panel {
|
||||
min-width: 800px;
|
||||
}
|
||||
|
||||
.admin-panel input[type="radio"], input[type="checkbox"] {
|
||||
vertical-align: middle;
|
||||
height: 28px;
|
||||
margin: 2px;
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
margin: 7px;
|
||||
}
|
||||
|
||||
.table-checkbox {
|
||||
width: 28px;
|
||||
}
|
||||
|
||||
.admin-searchform {
|
||||
@@ -34,13 +36,15 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.usertable .table-username {width: 150px}
|
||||
.usertable .table-status {width: 100px}
|
||||
.usertable .table-action {width: 200px}
|
||||
.table-checkbox {width: 20px}
|
||||
.table-username {width: 150px}
|
||||
.table-status {width: 100px}
|
||||
.table-action {width: 200px}
|
||||
|
||||
.usertable th, td {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 3px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.usertable th, tr {
|
||||
@@ -51,6 +55,10 @@
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.bancomment {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.bancommentedit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,12 @@ label {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.login_containerNoscript {
|
||||
padding: 4px;
|
||||
text-align: center;
|
||||
color: red;
|
||||
}
|
||||
|
||||
@keyframes animatezoom {
|
||||
from {transform: scale(0)}
|
||||
to {transform: scale(1)}
|
||||
@@ -150,7 +156,7 @@ label {
|
||||
margin: 16px auto;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
width: 600px;
|
||||
width: 650px;
|
||||
}
|
||||
|
||||
select{
|
||||
@@ -192,12 +198,6 @@ ul {
|
||||
animation-duration: 0.4s
|
||||
}
|
||||
|
||||
/* Add Animation */
|
||||
@-webkit-keyframes animatetop {
|
||||
from {top:-300px; opacity:0}
|
||||
to {top:0; opacity:1}
|
||||
}
|
||||
|
||||
@keyframes animatetop {
|
||||
from {top:-300px; opacity:0}
|
||||
to {top:0; opacity:1}
|
||||
|
||||
@@ -102,7 +102,6 @@ p {
|
||||
|
||||
.group-picture {
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.item-box, .item-box-full-width {
|
||||
@@ -117,7 +116,7 @@ p {
|
||||
|
||||
@media only screen and (max-width: 1400px) {
|
||||
.item-box {
|
||||
width: calc(100% - 50px);
|
||||
width: calc(100% - 50px)!important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,8 +256,6 @@ div[data-title]:hover:after {
|
||||
top: 150%;
|
||||
z-index: 200;
|
||||
white-space: nowrap;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-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);
|
||||
background-color: #333;
|
||||
@@ -291,19 +288,6 @@ div[data-title]:hover:after {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: none;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
-webkit-border-radius: 20px;
|
||||
border-radius: 20px;
|
||||
background: #4CAF50;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1080px) {
|
||||
body {
|
||||
font-size: 28px!important;
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.post-content a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.commentfield {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -87,17 +91,5 @@
|
||||
|
||||
.deleteButton {
|
||||
background-color: firebrick;
|
||||
|
||||
}
|
||||
|
||||
.deleteButton i {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deleteButton:hover span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deleteButton span {
|
||||
display: none;
|
||||
float: right;
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
/* New */
|
||||
|
||||
.alertbox {
|
||||
display: none;
|
||||
background-color: firebrick;
|
||||
}
|
||||
|
||||
.alerttext {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.user-box {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -11,21 +20,29 @@
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.friend-button-container {
|
||||
.friend-button-container, .group-button-container {
|
||||
position: relative;
|
||||
float: right;
|
||||
width: 200px;
|
||||
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 {
|
||||
display: block;
|
||||
float: right;
|
||||
|
||||
margin: 7px 0;
|
||||
width: 200px;
|
||||
|
||||
font-size: 18px;
|
||||
}
|
||||
.status-buttons-container button {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.group-button-container button {
|
||||
float: right;
|
||||
@@ -62,10 +79,24 @@
|
||||
|
||||
.group-picture {
|
||||
border: none;
|
||||
margin-bottom: 0;
|
||||
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 */
|
||||
|
||||
@@ -90,6 +121,10 @@ div.posts div.post {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
div.posts div.post a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -108,7 +143,7 @@ div.posts .post form input, div.posts .post form textarea {
|
||||
width: calc(100% - 15px);
|
||||
}
|
||||
|
||||
div.posts .post form input[type="submit"] {
|
||||
div.posts .post form input[type="submit"], .post button{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.settings-password, .settings-email {
|
||||
width: calc(50% - 60px);
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.settings-password label, .settings-email label {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
BIN
website/public/tiny.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
website/public/wide.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
@@ -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){
|
||||
if (empty($variable)) {
|
||||
throw new lettersAndSpacesException("Verplicht!");
|
||||
} else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) {
|
||||
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){
|
||||
if (empty($variable)) {
|
||||
throw new bdayException("Verplicht!");
|
||||
@@ -66,7 +76,7 @@ function validateBday($variable){
|
||||
}
|
||||
}
|
||||
|
||||
// Checks for date
|
||||
/* Checks for date */
|
||||
function validateDate($date, $format)
|
||||
{
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
@@ -81,6 +91,8 @@ function username($variable){
|
||||
throw new usernameException("Moet minstens 6 karakters bevatten");
|
||||
} else if (getExistingUsername() == 1) {
|
||||
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");
|
||||
} else if (getExistingFBUsername() == 1) {
|
||||
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!");
|
||||
} else if (strlen($variable) < 8) {
|
||||
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");
|
||||
} else if (getExistingEmail() == 1){
|
||||
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)) {
|
||||
throw new emailException("Geldige email invullen");
|
||||
} 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(){
|
||||
if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){
|
||||
throw new confirmEmailException("Emails matchen niet!");
|
||||
@@ -141,7 +162,6 @@ function resetEmail($variable){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* checks if two passwords matches. */
|
||||
function matchPassword(){
|
||||
if ($_POST["password"] != $_POST["confirmpassword"]) {
|
||||
@@ -204,9 +224,13 @@ function test_input($data) {
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
$data = htmlspecialchars($data);
|
||||
$data = trim($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class lettersAndSpacesException
|
||||
*/
|
||||
class lettersAndSpacesException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -215,7 +239,9 @@ class lettersAndSpacesException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class bdayException
|
||||
*/
|
||||
class bdayException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -224,6 +250,9 @@ class bdayException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class usernameException
|
||||
*/
|
||||
class usernameException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -232,6 +261,9 @@ class usernameException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class passwordException
|
||||
*/
|
||||
class passwordException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -240,6 +272,9 @@ class passwordException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class confirmPasswordException
|
||||
*/
|
||||
class confirmPasswordException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -248,6 +283,9 @@ class confirmPasswordException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class fbConfirmPasswordException
|
||||
*/
|
||||
class fbConfirmPasswordException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -256,6 +294,9 @@ class fbConfirmPasswordException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class emailException
|
||||
*/
|
||||
class emailException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -264,6 +305,9 @@ class emailException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class confirmEmailException
|
||||
*/
|
||||
class confirmEmailException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -272,6 +316,9 @@ class confirmEmailException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class captchaException
|
||||
*/
|
||||
class captchaException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -280,6 +327,9 @@ class captchaException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class registerException
|
||||
*/
|
||||
class registerException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
|
||||
@@ -10,6 +10,11 @@ else {
|
||||
or die('Error connecting to mysql server');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helperfunction to create a database query.
|
||||
* @param string $query
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function prepareQuery(string $query) : PDOStatement {
|
||||
return $GLOBALS["db"]->prepare($query);
|
||||
}
|
||||
44
website/queries/createGroup.php
Normal 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);
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Sends a confirm email if you know the username.
|
||||
* @param string $username
|
||||
*/
|
||||
function sendConfirmEmailUsername(string $username) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -15,6 +18,10 @@ function sendConfirmEmailUsername(string $username) {
|
||||
sendConfirmEmail($userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a confirm email if you know the userID.
|
||||
* @param int $userID
|
||||
*/
|
||||
function sendConfirmEmail(int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -2,21 +2,33 @@
|
||||
|
||||
require_once ("connect.php");
|
||||
|
||||
/**
|
||||
* Selects all friends of a user.
|
||||
* @param $userID
|
||||
* @return string
|
||||
*/
|
||||
function selectFriends($userID) {
|
||||
return selectLimitedFriends($userID, 9999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a limited amount of friends of a user.
|
||||
* @param $userID
|
||||
* @param $limit
|
||||
* @return string
|
||||
*/
|
||||
function selectLimitedFriends($userID, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -45,18 +57,23 @@ function selectLimitedFriends($userID, $limit) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects all friends of a user.
|
||||
* @param $userID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectAllFriends($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -81,17 +98,22 @@ function selectAllFriends($userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all friend requests of the current user.
|
||||
* @return string
|
||||
*/
|
||||
function selectAllFriendRequests() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -116,6 +138,11 @@ function selectAllFriendRequests() {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the friendship status from current user and userID.
|
||||
* @param $userID
|
||||
* @return int
|
||||
*/
|
||||
function getFriendshipStatus($userID) {
|
||||
# -2: Query failed.
|
||||
# -1: user1 and 2 are the same user
|
||||
@@ -159,6 +186,11 @@ function getFriendshipStatus($userID) {
|
||||
return intval($stmt->fetch()["friend_state"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request friendship from current user to target user.
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function requestFriendship($userID) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO `friendship` (user1ID, user2ID)
|
||||
@@ -170,6 +202,11 @@ function requestFriendship($userID) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes friendship between current and target user.
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function removeFriendship($userID) {
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM `friendship`
|
||||
@@ -186,6 +223,11 @@ function removeFriendship($userID) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the friendship between current and target user to accepted.
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function acceptFriendship($userID) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE `friendship`
|
||||
@@ -201,6 +243,11 @@ function acceptFriendship($userID) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last time the user visited the chat with specified friend.
|
||||
* @param $friend
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function setLastVisited($friend) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
@@ -231,17 +278,25 @@ function setLastVisited($friend) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches m friends from n filtered by search.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeFriends($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -277,6 +332,11 @@ function searchSomeFriends($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all friends of current user filtered by search.
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function countSomeFriends($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
192
website/queries/groupAdmin.php
Normal 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 a 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");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns all groups a user is member of.
|
||||
* @param $userID
|
||||
* @return string
|
||||
*/
|
||||
function selectAllGroupsFromUser($userID) {
|
||||
return selectLimitedGroupsFromUser($userID, 9999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects number of groups that a user is member of.
|
||||
* @param $userID
|
||||
* @param $limit
|
||||
* @return string
|
||||
*/
|
||||
function selectLimitedGroupsFromUser($userID, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -27,6 +38,13 @@ function selectLimitedGroupsFromUser($userID, $limit) {
|
||||
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) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -55,6 +73,11 @@ function searchSomeOwnGroups($n, $m, $search) {
|
||||
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) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -78,6 +101,13 @@ function countSomeOwnGroups($search) {
|
||||
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) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -92,6 +122,13 @@ function addMember($groupID, $userID, $role) {
|
||||
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) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
@@ -109,6 +146,12 @@ function changeMember($groupID, $userID, $role) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a user from a group.
|
||||
* @param $groupID
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function deleteMember($groupID, $userID) {
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
require_once("connect.php");
|
||||
|
||||
/**
|
||||
* Selects some info from a group by name.
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function selectGroupByName($name) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -33,9 +37,19 @@ function selectGroupByName($name) {
|
||||
if (!$stmt->execute()) {
|
||||
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) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -58,6 +72,11 @@ function selectGroupRole(int $groupID) {
|
||||
return $stmt->fetch()["role"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of a group by it's ID.
|
||||
* @param int $groupID
|
||||
* @return bool
|
||||
*/
|
||||
function selectGroupStatus(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -75,13 +94,21 @@ function selectGroupStatus(int $groupID) {
|
||||
return $stmt->fetch()["status"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns some info of all group members.
|
||||
* @param int $groupID
|
||||
* @return bool|PDOStatement
|
||||
*/
|
||||
function selectGroupMembers(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`username`,
|
||||
`fname`,
|
||||
`lname`,
|
||||
`profilepicture`
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture
|
||||
FROM
|
||||
`group_member`
|
||||
LEFT JOIN
|
||||
@@ -97,9 +124,14 @@ function selectGroupMembers(int $groupID) {
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetchAll();
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns group info by it's ID.
|
||||
* @param $groupID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectGroupById($groupID) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -119,6 +151,11 @@ function selectGroupById($groupID) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns some info of 20 groups offset by n.
|
||||
* @param $n
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function select20GroupsFromN($n) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -141,6 +178,12 @@ function select20GroupsFromN($n) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns info of 20 groups offset by n, filtered by status.
|
||||
* @param $n
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function select20GroupsByStatusFromN($n, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -166,6 +209,13 @@ function select20GroupsByStatusFromN($n, $status) {
|
||||
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) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -193,6 +243,14 @@ function search20GroupsFromNByStatus($n, $keyword, $status) {
|
||||
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) {
|
||||
// parentheses not needed in where clause, for clarity as
|
||||
// role search should override status filter.
|
||||
@@ -225,6 +283,12 @@ function searchSomeGroupsByStatus($n, $m, $search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all groups filtered by status and search.
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeGroupsByStatus($search, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -248,6 +312,12 @@ function countSomeGroupsByStatus($search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the status of a group with the given ID.
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeGroupStatusByID($id, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -264,6 +334,12 @@ function changeGroupStatusByID($id, $status) {
|
||||
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) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -281,6 +357,13 @@ function changeMultipleGroupStatusByID($ids, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns m groups offset by n, filtered by search.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeGroups($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -304,6 +387,11 @@ function searchSomeGroups($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all group filtered by search.
|
||||
* @param $search
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeGroups($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Find matching password with the inputted username/emailadress.
|
||||
* @return mixed
|
||||
*/
|
||||
function getUser() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -33,7 +37,7 @@ function getUserID() {
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function validateLogin($username, $password){
|
||||
function validateLogin($username, $password, $url){
|
||||
// Empty username or password field
|
||||
if (empty($username) || empty($password)) {
|
||||
throw new loginException("Inloggegevens zijn niet ingevuld");
|
||||
@@ -44,26 +48,42 @@ function validateLogin($username, $password){
|
||||
$userID = getUser()["userID"];
|
||||
$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 ($role == "banned"){
|
||||
echo "<script>
|
||||
window.onload=bannedAlert();
|
||||
</script>";
|
||||
|
||||
} else if ($role == "frozen") {
|
||||
$_SESSION["userID"] = $userID;
|
||||
if (!isset($url) or $url = "") {
|
||||
echo "<script>
|
||||
window.onload=frozenAlert();
|
||||
window.location.href= 'profile.php';
|
||||
</script>";
|
||||
} else {
|
||||
echo "<script>
|
||||
window.onload=frozenAlert();
|
||||
window.location.href= $url;
|
||||
</script>";
|
||||
}
|
||||
|
||||
} else if ($role == "unconfirmed"){
|
||||
sendConfirmEmail(getUser()["userID"]);
|
||||
echo "<script>
|
||||
window.onload=emailNotConfirmed();
|
||||
</script>";
|
||||
|
||||
} else {
|
||||
$_SESSION["userID"] = $userID;
|
||||
if(!isset($url) or $url == "") {
|
||||
header("location: profile.php");
|
||||
echo "succes";
|
||||
} else{
|
||||
header("location: ".$url);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
throw new loginException("Inloggevens zijn niet correct");
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Return a relative dutch and readable text when given a datetime.
|
||||
* @param $date
|
||||
* @return string
|
||||
*/
|
||||
function nicetime($date) {
|
||||
if(empty($date)) {
|
||||
return "No date provided";
|
||||
}
|
||||
|
||||
// Create dutch arrays so it has dutch words.
|
||||
$single_periods = array("seconde", "minuut", "uur", "dag", "week", "maand", "jaar", "decennium");
|
||||
$multiple_periods = array("seconden", "minuten", "uur", "dagen", "weken", "maanden", "jaar", "decennia");
|
||||
$lengths = array("60", "60", "24", "7", "4.35", "12", "10", "0");
|
||||
@@ -15,7 +22,8 @@ function nicetime($date) {
|
||||
return "Bad date";
|
||||
}
|
||||
|
||||
if($now > $unix_date) {
|
||||
// Check if it is in the future or not.
|
||||
if($now >= $unix_date) {
|
||||
$difference = $now - $unix_date;
|
||||
$tense = "geleden";
|
||||
} else {
|
||||
@@ -23,6 +31,7 @@ function nicetime($date) {
|
||||
$tense = "vanaf nu";
|
||||
}
|
||||
|
||||
// Get the nice time.
|
||||
for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) {
|
||||
$difference /= $lengths[$i];
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
* @throws AngryAlert
|
||||
* @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/";
|
||||
$tmpImg = $_FILES["pp"]["tmp_name"];
|
||||
$avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/";
|
||||
@@ -16,17 +19,17 @@ function updateAvatar(bool $group = false) {
|
||||
if ($_FILES["pp"]["size"] > 4000000) {
|
||||
throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan.");
|
||||
}
|
||||
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif";
|
||||
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar();
|
||||
$relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif";
|
||||
$group ? removeOldGroupAvatar($group) : removeOldUserAvatar();
|
||||
move_uploaded_file($tmpImg, $publicDir . $relativePath);
|
||||
} else {
|
||||
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png";
|
||||
$relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png";
|
||||
$scaledImg = scaleAvatar($tmpImg);
|
||||
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar();
|
||||
$group ? removeOldGroupAvatar($group) : removeOldUserAvatar();
|
||||
imagepng($scaledImg, $publicDir . $relativePath);
|
||||
}
|
||||
|
||||
$group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath);
|
||||
$group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath);
|
||||
throw new HappyAlert("Profielfoto veranderd.");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
require_once("connect.php");
|
||||
|
||||
/**
|
||||
* Select all posts on a user.
|
||||
* @param $userID
|
||||
* @param $groupID
|
||||
* @return bool|PDOStatement
|
||||
*/
|
||||
function selectAllPosts($userID, $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -46,6 +52,14 @@ function selectAllPosts($userID, $groupID) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Select $limit posts from $offset from a user or group.
|
||||
* @param $userID
|
||||
* @param $groupID
|
||||
* @param $offset
|
||||
* @param $limit
|
||||
* @return bool|PDOStatement
|
||||
*/
|
||||
function selectSomePosts($userID, $groupID, $offset, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -94,9 +108,13 @@ function selectSomePosts($userID, $groupID, $offset, $limit) {
|
||||
return False;
|
||||
}
|
||||
return $stmt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the post information from an postID.
|
||||
* @param $postID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectPostById($postID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -122,6 +140,11 @@ function selectPostById($postID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the comments from a post.
|
||||
* @param $postID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectCommentsByPostId($postID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -148,6 +171,13 @@ function selectCommentsByPostId($postID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a post to a group or user
|
||||
* @param $userID
|
||||
* @param $groupID
|
||||
* @param $title
|
||||
* @param $content
|
||||
*/
|
||||
function makePost($userID, $groupID, $title, $content) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -172,6 +202,13 @@ function makePost($userID, $groupID, $title, $content) {
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a comment by a post.
|
||||
* @param $postID
|
||||
* @param $userID
|
||||
* @param $content
|
||||
* @return int
|
||||
*/
|
||||
function makeComment($postID, $userID, $content) : int {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -194,6 +231,12 @@ function makeComment($postID, $userID, $content) : int {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* If a post already is niet slechted.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function makeNietSlecht(int $postID, int $userID) : int {
|
||||
if (checkNietSlecht($postID, $userID)) {
|
||||
return deleteNietSlecht($postID, $userID);
|
||||
@@ -202,6 +245,12 @@ function makeNietSlecht(int $postID, int $userID) : int {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a niet slecht of a post.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function checkNietSlecht(int $postID, int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -218,6 +267,12 @@ function checkNietSlecht(int $postID, int $userID) {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a niet slecht to a post.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function addNietSlecht(int $postID, int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -230,6 +285,12 @@ function addNietSlecht(int $postID, int $userID) {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a niet slecht.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function deleteNietSlecht(int $postID, int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM
|
||||
@@ -244,6 +305,11 @@ function deleteNietSlecht(int $postID, int $userID) {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a post
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
*/
|
||||
function deletePost(int $postID, int $userID) {
|
||||
if (checkPermissionOnPost($postID, $userID)) {
|
||||
$stmt = prepareQuery("
|
||||
@@ -257,6 +323,12 @@ function deletePost(int $postID, int $userID) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user has premissions to delete a post.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return bool
|
||||
*/
|
||||
function checkPermissionOnPost(int $postID, int $userID) : bool {
|
||||
$getGroupID = prepareQuery("
|
||||
SELECT
|
||||
@@ -281,6 +353,12 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns role of a user.
|
||||
* @param int $userID
|
||||
* @param int $groupID
|
||||
* @return mixed role of a user.
|
||||
*/
|
||||
function getRoleInGroup(int $userID, int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Get the the last 100 chat messages.
|
||||
* @param $user2ID
|
||||
* @return string
|
||||
*/
|
||||
function getOldChatMessages($user2ID) {
|
||||
require_once ("friendship.php");
|
||||
$user1ID = $_SESSION["userID"];
|
||||
@@ -7,6 +12,9 @@ function getOldChatMessages($user2ID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(SELECT
|
||||
*
|
||||
FROM
|
||||
`private_message`
|
||||
WHERE
|
||||
@@ -15,9 +23,11 @@ function getOldChatMessages($user2ID) {
|
||||
`origin` = :user2 AND
|
||||
`destination` = :user1
|
||||
ORDER BY
|
||||
`creationdate` ASC
|
||||
`messageID` DESC
|
||||
LIMIT
|
||||
100
|
||||
100) sub
|
||||
ORDER BY
|
||||
`messageID` ASC
|
||||
");
|
||||
|
||||
$stmt->bindParam(":user1", $user1ID);
|
||||
@@ -31,6 +41,12 @@ function getOldChatMessages($user2ID) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a chat message.
|
||||
* @param $destination
|
||||
* @param $content
|
||||
* @return bool
|
||||
*/
|
||||
function sendMessage($destination, $content) {
|
||||
require_once("friendship.php");
|
||||
if (getFriendshipStatus($destination) == 1) {
|
||||
@@ -60,6 +76,12 @@ function sendMessage($destination, $content) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the chat messages after an messageID ($lastID).
|
||||
* @param $lastID
|
||||
* @param $destination
|
||||
* @return string
|
||||
*/
|
||||
function getNewChatMessages($lastID, $destination) {
|
||||
require_once("friendship.php");
|
||||
if (getFriendshipStatus($destination) == 1) {
|
||||
@@ -76,7 +98,7 @@ function getNewChatMessages($lastID, $destination) {
|
||||
`destination` = :user1) AND
|
||||
`messageID` > :lastID
|
||||
ORDER BY
|
||||
`creationdate` ASC
|
||||
`messageID` ASC
|
||||
");
|
||||
|
||||
$stmt->bindParam(':user1', $_SESSION["userID"]);
|
||||
@@ -91,11 +113,14 @@ function getNewChatMessages($lastID, $destination) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get of every friend the first unread chat message.
|
||||
* @return string
|
||||
*/
|
||||
function selectAllUnreadChat() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
`user`.`userID`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns 1 if an username exists with the filled in username.
|
||||
* @return int
|
||||
*/
|
||||
function getExistingUsername() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -16,6 +20,10 @@ function getExistingUsername() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an username exists with facebooklogin
|
||||
* @return int
|
||||
*/
|
||||
function getExistingFBUsername() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -32,6 +40,10 @@ function getExistingFBUsername() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an email exists with the filled in email.
|
||||
* @return int
|
||||
*/
|
||||
function getExistingEmail() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -48,6 +60,10 @@ function getExistingEmail() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an email exists with facebook register
|
||||
* @return int
|
||||
*/
|
||||
function getExistingFBEmail() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -65,6 +81,10 @@ function getExistingFBEmail() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an email exists with the forgot email input
|
||||
* @return int
|
||||
*/
|
||||
function getResetEmail() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -81,6 +101,9 @@ function getResetEmail() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new account in the database
|
||||
*/
|
||||
function registerAccount() {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -119,6 +142,9 @@ function registerAccount() {
|
||||
$stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new account with facebook register
|
||||
*/
|
||||
function fbRegisterAccount() {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -158,6 +184,11 @@ function fbRegisterAccount() {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks which dates need to be selected when there is an invalid registration.
|
||||
* @param $date
|
||||
* @param $value
|
||||
*/
|
||||
function submitselect($date, $value){
|
||||
if ($date == $value){
|
||||
echo "selected";
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
include_once "../queries/connect.php";
|
||||
|
||||
/**
|
||||
* Sends a link to an email to change the password of an account
|
||||
* @param string $email
|
||||
*/
|
||||
function sendPasswordRecovery(string $email) {
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$stmt = prepareQuery("
|
||||
@@ -24,11 +28,16 @@ function sendPasswordRecovery(string $email) {
|
||||
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
|
||||
setHashToDatabase($userID, $hash);
|
||||
doSendPasswordRecovery($userID, $email, $username, $hashedHash);
|
||||
} else {
|
||||
// TODO: Be angry!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message in the email to reset a password of an account.
|
||||
* @param int $userID
|
||||
* @param string $email
|
||||
* @param string $username
|
||||
* @param string $hash
|
||||
*/
|
||||
function doSendPasswordRecovery(int $userID, string $email, string $username, string $hash) {
|
||||
$resetLink = "https://myhyvesbookplus.nl/resetpassword.php?u=$userID&h=$hash";
|
||||
|
||||
@@ -38,6 +47,11 @@ function doSendPasswordRecovery(int $userID, string $email, string $username, st
|
||||
mail($email, $subject, $body, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the previous password invalid.
|
||||
* @param int $userID
|
||||
* @param string $hash
|
||||
*/
|
||||
function setHashToDatabase(int $userID, string $hash) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -16,9 +16,13 @@ function getSettings() {
|
||||
`location`,
|
||||
`birthdate`,
|
||||
`bio`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`showBday`,
|
||||
`showEmail`
|
||||
`showEmail`,
|
||||
`showProfile`
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
@@ -49,6 +53,15 @@ function getPasswordHash() {
|
||||
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.
|
||||
* @throws HappyAlert
|
||||
@@ -64,7 +77,8 @@ function updateSettings() {
|
||||
`birthdate` = :bday,
|
||||
`bio` = :bio,
|
||||
`showEmail` = :showEmail,
|
||||
`showBday` = :showBday
|
||||
`showBday` = :showBday,
|
||||
`showProfile` = :showProfile
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
@@ -79,6 +93,7 @@ function updateSettings() {
|
||||
$stmt->bindValue(":bio", test_input($_POST["bio"]));
|
||||
$stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0"));
|
||||
$stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0"));
|
||||
$stmt->bindValue(":showProfile", (array_key_exists("showProfile", $_POST) ? "1" : "0"));
|
||||
|
||||
$stmt->bindValue(":userID", $_SESSION["userID"]);
|
||||
$stmt->execute();
|
||||
@@ -136,6 +151,10 @@ function doChangePassword() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the users email if it is valid.
|
||||
* @throws AngryAlert
|
||||
*/
|
||||
function changeEmail() {
|
||||
|
||||
if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) {
|
||||
@@ -152,6 +171,11 @@ function changeEmail() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an emailadres is available in the database.
|
||||
* @param $email
|
||||
* @throws AngryAlert
|
||||
*/
|
||||
function emailIsAvailableInDatabase($email) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -169,6 +193,12 @@ function emailIsAvailableInDatabase($email) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual changing of an email-adress.
|
||||
* @param $email
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function doChangeEmail($email) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
require_once ("connect.php");
|
||||
|
||||
/**
|
||||
* This sets the last activity of the session user to now.
|
||||
* @return bool, true is it ran correctly
|
||||
*/
|
||||
function updateLastActivity() {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
@@ -15,6 +19,11 @@ function updateLastActivity() {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the userID from a username
|
||||
* @param $username
|
||||
* @return mixed
|
||||
*/
|
||||
function getUserID($username) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -30,6 +39,11 @@ function getUserID($username) {
|
||||
return $stmt->fetch()["userID"];
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the username from a userID
|
||||
* @param $userID
|
||||
* @return mixed
|
||||
*/
|
||||
function getUsername($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -45,6 +59,12 @@ function getUsername($userID) {
|
||||
return $stmt->fetch()["username"];
|
||||
}
|
||||
|
||||
/**
|
||||
* This selects the information about the other user and the connection between the two.
|
||||
* @param $me
|
||||
* @param $other
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function selectUser($me, $other) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -52,19 +72,27 @@ function selectUser($me, $other) {
|
||||
`username`,
|
||||
`birthdate`,
|
||||
`location`,
|
||||
`showBday`,
|
||||
`showEmail`,
|
||||
`showProfile`,
|
||||
`email`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`bio`,
|
||||
`user`.`creationdate`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
`role`,
|
||||
`fname`,
|
||||
`lname`,
|
||||
`showBday`,
|
||||
`showEmail`,
|
||||
`showProfile`,
|
||||
`status`,
|
||||
CASE `status` IS NULL
|
||||
WHEN TRUE THEN 0
|
||||
WHEN FALSE THEN
|
||||
@@ -93,10 +121,17 @@ function selectUser($me, $other) {
|
||||
|
||||
$stmt->bindParam(':me', $me, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':other', $other, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
if(!$stmt->execute() || $stmt->rowCount() == 0) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the users from a group.
|
||||
* @param $userID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectAllUserGroups($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -112,7 +147,7 @@ function selectAllUserGroups($userID) {
|
||||
`group_page`.`groupID` = `group_member`.`groupID`
|
||||
WHERE
|
||||
`userID` = :userID AND
|
||||
`role` = 'member'
|
||||
`role` IN ('member', 'mod', 'admin')
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
@@ -120,6 +155,11 @@ function selectAllUserGroups($userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects 20 users from a given point in the table, ordered by role and name
|
||||
* @param $n
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function select20UsersFromN($n) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -127,7 +167,7 @@ function select20UsersFromN($n) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -145,6 +185,12 @@ function select20UsersFromN($n) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search 20 users from a given point in the table, ordered by role and name
|
||||
* @param $n
|
||||
* @param $keyword
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function search20UsersFromN($n, $keyword) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -152,7 +198,7 @@ function search20UsersFromN($n, $keyword) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -173,6 +219,13 @@ function search20UsersFromN($n, $keyword) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search 20 users from a given point in the database where the status @param $status
|
||||
* @param $n
|
||||
* @param $keyword
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -180,7 +233,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -205,6 +258,14 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users from a given point in the database where the status @param $status
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function searchSomeUsersByStatus($n, $m, $search, $status) {
|
||||
// parentheses not needed in where clause, for clarity as
|
||||
// role search should override status filter.
|
||||
@@ -214,7 +275,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -242,6 +303,12 @@ function searchSomeUsersByStatus($n, $m, $search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the users with a name like $search and a $status
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeUsersByStatus($search, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -266,7 +333,12 @@ function countSomeUsersByStatus($search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the user status
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeUserStatusByID($id, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -283,6 +355,12 @@ function changeUserStatusByID($id, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change multiple user statuses by an id array.
|
||||
* @param $ids
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeMultipleUserStatusByID($ids, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -300,6 +378,13 @@ function changeMultipleUserStatusByID($ids, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change multiple user statuses by an id array.
|
||||
* This excludes that admins and owners statuses can be changed.
|
||||
* @param $ids
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeMultipleUserStatusByIDAdmin($ids, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -319,6 +404,11 @@ function changeMultipleUserStatusByIDAdmin($ids, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a random user that is nog your friend.
|
||||
* @param $userID
|
||||
* @return mixed
|
||||
*/
|
||||
function selectRandomNotFriendUser($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -347,17 +437,25 @@ function selectRandomNotFriendUser($userID) {
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeUsers($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -386,6 +484,11 @@ function searchSomeUsers($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the users that you get searching for a user with a keyword.
|
||||
* @param $search
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeUsers($search) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -409,6 +512,11 @@ function countSomeUsers($search) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the role of a user by userID.
|
||||
* @param $userID
|
||||
* @return mixed
|
||||
*/
|
||||
function getRoleByID($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -424,6 +532,11 @@ function getRoleByID($userID) {
|
||||
return $stmt->fetch()["role"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the ban comment.
|
||||
* @param $userID
|
||||
* @param $comment
|
||||
*/
|
||||
function editBanCommentByID($userID, $comment) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<tr>
|
||||
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)"></th>
|
||||
<th class="table-username">Gebruikersnaam</th>
|
||||
<th class="table-username">Groepsnaam</th>
|
||||
<th class="table-status">Status</th>
|
||||
<th class="table-comment">Aantekening</th>
|
||||
<th class="table-action">Actie</th>
|
||||
<th class="table-comment">Beschrijving</th>
|
||||
<th class="table-action">Zichtbaarheid</th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
@@ -33,9 +33,9 @@ while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
<form class='admin-groupaction'
|
||||
onsubmit=\"adminUpdate(this); return false;\">
|
||||
<select class='action' name='actions'>
|
||||
<option value='hidden'>Hidden</option>
|
||||
<option value='public'>Public</option>
|
||||
<option value='membersonly'>Members</option>
|
||||
<option value='hidden'>Verborgen</option>
|
||||
<option value='public'>Publiek</option>
|
||||
<option value='membersonly'>Alleen Leden</option>
|
||||
</select>
|
||||
<input type='hidden' name='groupID' value='$groupID'>
|
||||
<input type='submit' value='Confirm'>
|
||||
|
||||
@@ -13,6 +13,7 @@ Pagina:
|
||||
id="currentpage"
|
||||
form="admin-searchform"
|
||||
onchange="adminSearch();">
|
||||
<!-- Construct the options. -->
|
||||
<?php
|
||||
for ($i=1; $i <= ceil($countresults / $entries); $i++) {
|
||||
if ($currentpage == $i) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<tr>
|
||||
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
|
||||
<th class="table-checkbox"><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
|
||||
<th class="table-username">Gebruikersnaam</th>
|
||||
<th class="table-status">Status</th>
|
||||
<th class="table-comment">Aantekening</th>
|
||||
@@ -55,7 +55,8 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
OR $user['role'] == 'owner'))) {
|
||||
echo "<option value='frozen'>Bevries</option>
|
||||
<option value='banned'>Ban</option>
|
||||
<option value='user'>Activeer</option>";
|
||||
<option value='user'>Activeer</option>
|
||||
<option value='unconfirmed'>Ongevalideerd</option>";
|
||||
|
||||
if ($userinfo == 'owner') {
|
||||
echo "<option value='admin'>Admin</option>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
|
||||
<!-- Form value holding. -->
|
||||
<?php
|
||||
$search = "";
|
||||
$status = array("user", "frozen", "banned", "unconfirmed", "admin", "owner");
|
||||
@@ -67,13 +66,13 @@ if (isset($_GET["groupstatus"])) {
|
||||
id="frozen"
|
||||
value="frozen"
|
||||
<?php if (in_array("frozen", $status)) echo "checked";?>>
|
||||
<label for="frozen">Gefrozen</label><br>
|
||||
<label for="frozen">Bevroren</label><br>
|
||||
<input type="checkbox"
|
||||
name="status[]"
|
||||
id="banned"
|
||||
value="banned"
|
||||
<?php if (in_array("banned", $status)) echo "checked";?>>
|
||||
<label for="banned">Gebant</label><br>
|
||||
<label for="banned">Verbannen</label><br>
|
||||
<input type="checkbox"
|
||||
name="status[]"
|
||||
id="admin"
|
||||
@@ -91,7 +90,7 @@ if (isset($_GET["groupstatus"])) {
|
||||
id="owner"
|
||||
value="owner"
|
||||
<?php if (in_array("owner", $status)) echo "checked";?>>
|
||||
<label for="owner">Owner</label>
|
||||
<label for="owner">Eigenaar</label>
|
||||
</div>
|
||||
|
||||
<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="ban" value="banned">Ban</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
|
||||
if ($userinfo == 'owner') {
|
||||
echo "<button type=\"submit\"
|
||||
name=\"batchactions\"
|
||||
id=\"admin\"
|
||||
id=\"batch-admin\"
|
||||
value=\"admin\">Maak Admin</button>
|
||||
<button type=\"submit\"
|
||||
name=\"batchactions\"
|
||||
id=\"owner\"
|
||||
value=\"owner\">Maak Owner</button>";
|
||||
id=\"batch-owner\"
|
||||
value=\"owner\">Maak Eigenaar</button>";
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
@@ -139,9 +139,9 @@ if (isset($_GET["groupstatus"])) {
|
||||
onsubmit="adminUpdate(this); return false;">
|
||||
|
||||
<input type="hidden" name="groupbatchactions" id="groupbatchinput">
|
||||
<button type="submit" name="batchactions" id="hide" value="hidden">Hide</button>
|
||||
<button type="submit" name="batchactions" id="ban" value="public">Public</button>
|
||||
<button type="submit" name="batchactions" id="members" value="membersonly">Members</button>
|
||||
<button type="submit" name="batchactions" id="batch-hide" value="hidden">Verborgen</button>
|
||||
<button type="submit" name="batchactions" id="batch-public" value="public">Publiek</button>
|
||||
<button type="submit" name="batchactions" id="batch-members" value="membersonly">Alleen Leden</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -151,5 +151,3 @@ if (isset($_GET["groupstatus"])) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
42
website/views/createGroup.php
Normal 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>
|
||||
@@ -1,7 +1,12 @@
|
||||
<?php
|
||||
if(isset($acces_token)) {
|
||||
echo '<button id="fbBtn" class="button">Facebook registreer</button>';
|
||||
|
||||
}
|
||||
?>
|
||||
<!-- The Modal -->
|
||||
<div id="fbModal" class="modal">
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
return= $correct
|
||||
method="post"
|
||||
name="fbModal">
|
||||
|
||||
@@ -55,7 +60,6 @@
|
||||
*<span class="error"> <?php echo $fbConfirmpasswordErr;?></span>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if(empty($userBday)) { ?>
|
||||
<!-- Register birthday -->
|
||||
<div class="login_containerregister">
|
||||
@@ -67,17 +71,16 @@
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<span class="error"> <?php echo $fbEmailErr;?></span>
|
||||
<div class="modal-footer">
|
||||
<button type="submit"
|
||||
value="fbRegister"
|
||||
name="submit"
|
||||
id="frm1_submit">
|
||||
name="submit">
|
||||
Registreer account
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Facebook information-->
|
||||
<input type="hidden"
|
||||
name="fbName"
|
||||
value="<?php echo $fbName ?>">
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<!-- The Modal -->
|
||||
<div id="myModal" class="modal">
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
return= $correct
|
||||
method="post"
|
||||
name="forgotPassword">
|
||||
|
||||
@@ -26,8 +25,7 @@
|
||||
<div class="login_containerfault"><span><?php echo $resetErr; ?></span></div>
|
||||
<button type="submit"
|
||||
value="reset"
|
||||
name="submit"
|
||||
id="frm1_submit">
|
||||
name="submit">
|
||||
Reset password
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
<div class="content">
|
||||
<div class="profile-box platform">
|
||||
<img class="left main-picture group-picture" src="<?= $group['picture'] ?>">
|
||||
<div class="group-button-container"></div>
|
||||
<h1 class="profile-username"><?= $group['name'] ?></h1>
|
||||
<p><?= $group['description'] ?></p>
|
||||
|
||||
<div class="user-box">
|
||||
<img alt="<?= $group["name"] ?>" class="group-picture main-picture" src="<?= $group["picture"] ?>"><br />
|
||||
<div class="platform">
|
||||
<div class="status-buttons-container">
|
||||
<button disabled class="gray"><?= $group["status"] ?></button>
|
||||
</div>
|
||||
<div class="group-button-container"></div>
|
||||
<div class="profile-info">
|
||||
<h2><?= $group["name"]?></h2>
|
||||
<?= $group["description"] ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-box-full-width platform">
|
||||
<h2>Leden (<?= $group['members'] ?>)</h2>
|
||||
<p>
|
||||
<?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>";
|
||||
}
|
||||
|
||||
if ($memberdif > 0) {
|
||||
echo $memberdif === 1 ? "en nog 1 andere." : "...en nog $memberdif anderen.";
|
||||
}
|
||||
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
@@ -22,6 +36,10 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="noposts platform">
|
||||
<p>Geen posts meer!</p>
|
||||
</div>
|
||||
|
||||
<div class="modal">
|
||||
<div class="modal-content platform">
|
||||
<div class="modal-close">
|
||||
|
||||
168
website/views/groupAdmin.php
Normal 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>
|
||||
@@ -1,4 +1,41 @@
|
||||
<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">
|
||||
<!--Favicon-->
|
||||
<!-- Desktop Browsers -->
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
|
||||
<!-- Android: Chrome M39 and up-->
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<!-- Android: Chrome M31 and up, ignored if manifest is present-->
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="icon" sizes="192x192" href="icon-192x192.png">
|
||||
<!-- iOS -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-title" content="My Awesome Web App">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon-180x180-precomposed.png">
|
||||
<link href="apple-touch-icon-152x152-precomposed.png" sizes="152x152" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-144x144-precomposed.png" sizes="144x144" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-120x120-precomposed.png" sizes="120x120" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-114x114-precomposed.png" sizes="114x114" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-76x76-precomposed.png" sizes="76x76" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-72x72-precomposed.png" sizes="72x72" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-60x60-precomposed.png" sizes="60x60" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-57x57-precomposed.png" sizes="57x57" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-precomposed.png" rel="apple-touch-icon">
|
||||
|
||||
<!-- Windows 8 and IE 11 -->
|
||||
<meta name="msapplication-config" content="browserconfig.xml" />
|
||||
|
||||
<!-- Windows -->
|
||||
<meta name="application-name" content="My Awesome Web App" />
|
||||
<meta name="msapplication-tooltip" content="Get the latest updates!" />
|
||||
<meta name="msapplication-window" content="width=1024;height=768" />
|
||||
<meta name="msapplication-navbutton-color" content="#FF3300" />
|
||||
<meta name="msapplication-starturl" content="./" />
|
||||
|
||||
<title>MyHyvesbook+</title>
|
||||
<!-- Add your javascript files here. -->
|
||||
<script src="js/jquery.js"></script>
|
||||
@@ -24,7 +61,7 @@ require_once ("../queries/user.php");
|
||||
session_start();
|
||||
|
||||
if(!isset($_SESSION["userID"])) {
|
||||
header("location:login.php");
|
||||
header("location:login.php?url=" . "$_SERVER[REQUEST_URI]");
|
||||
} else {
|
||||
updateLastActivity();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ $userinfo = getHeaderInfo();
|
||||
</div>
|
||||
<?= $userinfo["fname"] ?>
|
||||
</div>
|
||||
<img id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/><i id="open-notifications" class="fa fa-bars"></i>
|
||||
<img alt="<?= $userinfo["lname"] ?>" id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/><i id="open-notifications" class="fa fa-bars"></i>
|
||||
</div>
|
||||
</header>
|
||||
<?php include("notification-center.php"); ?>
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Checks if there's a user already logged in
|
||||
if(isset($_SESSION["userID"])){
|
||||
echo "<script>
|
||||
window.onload=checkLoggedIn();
|
||||
</script>";
|
||||
}
|
||||
|
||||
// Facebook variables
|
||||
$appID = "353857824997532";
|
||||
$appSecret = "db47e91ffbfd355fdd11b4b65eade851";
|
||||
$fbUsername = $fbPassword = $fbConfirmpassword = "";
|
||||
$fbUsername = $fbPassword = $fbConfirmpassword = $fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = "";
|
||||
$fbUsernameErr = $fbPasswordErr = $fbConfirmpasswordErr = $fbEmailErr = $fbBdayErr = "";
|
||||
$fbCorrect = true;
|
||||
$fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = "";
|
||||
$bdayExist = false;
|
||||
|
||||
// Register variables
|
||||
$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;
|
||||
|
||||
// Bday dates
|
||||
$day_date = $month_date = $year_date = "";
|
||||
$fbDay_date = $fbMonth_date = $fbYear_date = "";
|
||||
|
||||
@@ -27,7 +34,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
case "login":
|
||||
try {
|
||||
$user = ($_POST["user"]);
|
||||
validateLogin($_POST["user"], $_POST["psw"]);
|
||||
validateLogin($_POST["user"], $_POST["psw"], $_POST["url"]);
|
||||
} catch(loginException $e) {
|
||||
$loginErr = $e->getMessage();
|
||||
}
|
||||
@@ -46,18 +53,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
}
|
||||
break;
|
||||
case "register":
|
||||
include("register.php");
|
||||
include("../views/register.php");
|
||||
break;
|
||||
case "fbRegister":
|
||||
include("fbRegister.php");
|
||||
include("../views/fbRegister.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get facebook information with facebook PHP SDK.
|
||||
$fb = new Facebook\Facebook([
|
||||
'app_id' => $appID,
|
||||
'app_secret' => $appSecret,
|
||||
'default_graph_version' => 'v2.2',
|
||||
]);
|
||||
|
||||
// Redirect back to login.php after logging/canceling with facebook.
|
||||
$redirect = "https://myhyvesbookplus.nl/login.php";
|
||||
$helper = $fb->getRedirectLoginHelper();
|
||||
|
||||
@@ -72,6 +83,7 @@ try {
|
||||
exit;
|
||||
}
|
||||
|
||||
// If theres no facebook account logged in, ask for permission.
|
||||
if(!isset($acces_token)){
|
||||
$permission=["email", "user_birthday"];
|
||||
$loginurl=$helper->getLoginUrl($redirect,$permission);
|
||||
@@ -80,13 +92,14 @@ if(!isset($acces_token)){
|
||||
$response = $fb->get('/me?fields=email,name,birthday');
|
||||
$usernode = $response->getGraphUser();
|
||||
|
||||
// Get facebook information
|
||||
$nameSplit = explode(" ", $usernode->getName());
|
||||
$fbName = $nameSplit[0];
|
||||
$fbSurname = $nameSplit[1];
|
||||
$fbUserID = $usernode->getID();
|
||||
$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) {
|
||||
$fbID = getfbUserID($fbUserID)["userID"];
|
||||
$fbRole = getfbUserID($fbUserID)["role"];
|
||||
@@ -94,16 +107,20 @@ if(!isset($acces_token)){
|
||||
echo "<script>
|
||||
window.onload=bannedAlert();
|
||||
</script>";
|
||||
|
||||
} else if($fbRole == "frozen"){
|
||||
$_SESSION["userID"] = $fbID;
|
||||
echo "<script>
|
||||
window.onload=frozenAlert();
|
||||
window.location.href= 'profile.php';
|
||||
</script>";
|
||||
|
||||
} else {
|
||||
$_SESSION["userID"] = $fbID;
|
||||
header("location: profile.php");
|
||||
|
||||
}
|
||||
// Registration with faceobook if theres no account.
|
||||
} else {
|
||||
echo "<script>
|
||||
window.onload = function() {
|
||||
|
||||
@@ -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>
|
||||
<img style="width:50%;margin-left:25%"
|
||||
src="/img/top-logo.png"
|
||||
@@ -7,10 +13,17 @@
|
||||
<h1>Welkom bij MyHyvesbook+</h1>
|
||||
<!-- Login content -->
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
return=$correct
|
||||
method="post"
|
||||
name="login">
|
||||
|
||||
<!-- Url parameter -->
|
||||
<input type="hidden"
|
||||
name="url"
|
||||
value="<?php
|
||||
if(isset($_GET["url"])) {
|
||||
echo $_GET["url"];
|
||||
} ?>"/>
|
||||
|
||||
<!-- Login name -->
|
||||
<div class="login_containerlogin">
|
||||
<label><b>Gebruikersnaam/Email</b></label>
|
||||
@@ -41,8 +54,7 @@
|
||||
<div class="login_containerlogin">
|
||||
<button type="submit"
|
||||
value="login"
|
||||
name="submit"
|
||||
id="frm1_submit">
|
||||
name="submit">
|
||||
Inloggen
|
||||
</button>
|
||||
</div>
|
||||
@@ -62,74 +74,8 @@
|
||||
<!--Login with facebook button-->
|
||||
<?php
|
||||
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>
|
||||
@@ -1,5 +1,42 @@
|
||||
<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">
|
||||
<!-- Favicon-->
|
||||
<!-- Desktop Browsers -->
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
|
||||
<!-- Android: Chrome M39 and up-->
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<!-- Android: Chrome M31 and up, ignored if manifest is present-->
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="icon" sizes="192x192" href="icon-192x192.png">
|
||||
<!-- iOS -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-title" content="My Awesome Web App">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon-180x180-precomposed.png">
|
||||
<link href="apple-touch-icon-152x152-precomposed.png" sizes="152x152" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-144x144-precomposed.png" sizes="144x144" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-120x120-precomposed.png" sizes="120x120" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-114x114-precomposed.png" sizes="114x114" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-76x76-precomposed.png" sizes="76x76" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-72x72-precomposed.png" sizes="72x72" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-60x60-precomposed.png" sizes="60x60" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-57x57-precomposed.png" sizes="57x57" rel="apple-touch-icon">
|
||||
<link href="apple-touch-icon-precomposed.png" rel="apple-touch-icon">
|
||||
|
||||
<!-- Windows 8 and IE 11 -->
|
||||
<meta name="msapplication-config" content="browserconfig.xml" />
|
||||
|
||||
<!-- Windows -->
|
||||
<meta name="application-name" content="My Awesome Web App" />
|
||||
<meta name="msapplication-tooltip" content="Get the latest updates!" />
|
||||
<meta name="msapplication-window" content="width=1024;height=768" />
|
||||
<meta name="msapplication-navbutton-color" content="#FF3300" />
|
||||
<meta name="msapplication-starturl" content="./" />
|
||||
|
||||
<title>MyHyvesbook+</title>
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
@@ -7,7 +44,11 @@
|
||||
<link rel="stylesheet"
|
||||
type="text/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/registerAndLogin.js"></script>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
|
||||
</head>
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
</h4>
|
||||
<ul id="menu-groups-list" class="nav-list">
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<ul class="nav-list">
|
||||
<li>
|
||||
<a href="#">
|
||||
<a href="createGroup.php">
|
||||
Maak een groep aan
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
echo "<style>@import url('styles/adminbutton.css'); </style>";
|
||||
}
|
||||
?>
|
||||
<a href="logout.php" data-title="Admin"><i class="fa fa-sign-out"></i></a>
|
||||
<a href="logout.php" data-title="Uitloggen"><i class="fa fa-sign-out"></i></a>
|
||||
</section>
|
||||
<section id="friend-request-section">
|
||||
<h4>
|
||||
|
||||
@@ -5,14 +5,6 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
|
||||
?>
|
||||
<div class='post-header header'>
|
||||
<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'>
|
||||
gepost door <?=$fullname?>,
|
||||
<span class='posttime' title='<?=$post['creationdate']?>'>
|
||||
@@ -20,7 +12,14 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
|
||||
</span>
|
||||
</span>
|
||||
</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'>
|
||||
<p><?=$post['content']?></p>
|
||||
</div>
|
||||
@@ -30,7 +29,7 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
|
||||
<form id="newcommentform" onsubmit="return false;">
|
||||
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
|
||||
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..." maxlength="1000"></textarea><span></span> <br>
|
||||
<button onclick="postComment('reaction')" name="button" value="reaction">Reageer!</button>
|
||||
<button onclick="postComment('reaction')" name="button" value="reaction" class="green"><i class="fa fa-comment"></i> Reageer!</button>
|
||||
<button onclick="postComment('nietslecht')" name="button" value="nietslecht" class="nietslecht">
|
||||
<?php
|
||||
if (checkNietSlecht($postID, $_SESSION["userID"])) {
|
||||
|
||||