Compare commits
46 Commits
hendrik-po
...
revert-50e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecd24ef442 | ||
|
|
50e94fb8ed | ||
|
|
127162b938 | ||
|
|
820ffb4a62 | ||
|
|
1a3efe9669 | ||
|
|
de96ae8263 | ||
|
|
74e91ed7cb | ||
|
|
839fb247b4 | ||
|
|
bf298f4b43 | ||
|
|
74145d5d1c | ||
|
|
1486e71207 | ||
|
|
93b908fb13 | ||
|
|
6fd5401c86 | ||
|
|
9165f8fa1b | ||
|
|
380d8fa83a | ||
|
|
1c53eab2fa | ||
|
|
28254d98e4 | ||
|
|
8a3cfebf55 | ||
|
|
b1941f0191 | ||
|
|
a27a4881c3 | ||
|
|
cfa7c870f0 | ||
|
|
e60578dc43 | ||
|
|
9426f4d6ac | ||
|
|
7f48cae019 | ||
|
|
33399639b1 | ||
|
|
52e40242e6 | ||
|
|
8a6acbc52a | ||
|
|
6fc2f71517 | ||
|
|
1672ce6086 | ||
|
|
188741ddf5 | ||
|
|
4a7a91ecd9 | ||
|
|
1c1283243c | ||
|
|
417124a1fe | ||
|
|
d24ed89096 | ||
|
|
a92b0fe892 | ||
|
|
5c1b2d1b21 | ||
|
|
3abaeba52c | ||
|
|
044ed6a9d3 | ||
|
|
328ce69144 | ||
|
|
9d675dd897 | ||
|
|
86b02973e4 | ||
|
|
67eb7b991e | ||
|
|
90ac38acdd | ||
|
|
6c43cae1cb | ||
|
|
3af38cd088 | ||
|
|
cfe2928f7b |
8
website/public/bits/niet-slecht.php
Normal file
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>
|
||||
36
website/public/createGroup.php
Normal file
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>
|
||||
@@ -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(!$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.
|
||||
|
||||
61
website/public/groupAdmin.php
Normal file
61
website/public/groupAdmin.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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;
|
||||
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;
|
||||
}
|
||||
} 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>
|
||||
@@ -25,6 +25,9 @@ function loadMessages() {
|
||||
addMessages(messages);
|
||||
$("#lastID").val(messages[messages.length - 1].messageID);
|
||||
}
|
||||
|
||||
loadUnreadMessages();
|
||||
|
||||
gettingMessages = false;
|
||||
});
|
||||
} else {
|
||||
@@ -56,7 +59,7 @@ function addMessages(messages) {
|
||||
for(var i in messages) {
|
||||
// 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);
|
||||
|
||||
@@ -78,6 +81,8 @@ function addMessages(messages) {
|
||||
</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()) {
|
||||
|
||||
@@ -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
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")}})})}});
|
||||
@@ -3,31 +3,41 @@ function placeGroupButtons() {
|
||||
.done(function(data) {
|
||||
var $buttonContainer = $("div.group-button-container");
|
||||
|
||||
if(data == 'none') {
|
||||
if (data == 'none') {
|
||||
$buttonContainer.append(
|
||||
"<button class='green group-button' value='request'>" +
|
||||
"<button class='green group-button group-button-fixed' value='request'>" +
|
||||
"<i class='fa fa-plus'></i> Voeg toe" +
|
||||
"</button>");
|
||||
} else if(data == 'request') {
|
||||
} else if (data == 'request') {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<button class='red group-button group-button-fixed' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Trek verzoek in" +
|
||||
"</button>");
|
||||
} else if (data == 'admin') {
|
||||
$buttonContainer.append(
|
||||
"<button class='group-button group-button-fancy' 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 group-button-fancy' value='none'>" +
|
||||
"<span>Verlaat groep</span><i class='fa fa-sign-out'></i>" +
|
||||
"</button>");
|
||||
}
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
$.post("API/editMembership.php", { grp: groupID, role: this.value })
|
||||
.done(function() {
|
||||
$buttonContainer.children().remove();
|
||||
placeGroupButtons();
|
||||
updateMenus();
|
||||
}).fail(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();
|
||||
placeGroupButtons();
|
||||
updateMenus();
|
||||
}).fail(function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
68
website/public/js/loginRegisterModals.js
Normal file
68
website/public/js/loginRegisterModals.js
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
// Get the modal
|
||||
var modal = document.getElementById('myModal');
|
||||
var registerModal = document.getElementById('registerModal');
|
||||
var facebookModal = document.getElementById("fbModal");
|
||||
|
||||
// Get the button that opens the modal
|
||||
var registerBtn = document.getElementById("registerBtn");
|
||||
var btn = document.getElementById("myBtn");
|
||||
|
||||
|
||||
// Get the <span> element that closes the modal
|
||||
var span = document.getElementsByClassName("close")[0];
|
||||
var registerSpan = document.getElementsByClassName("close")[1];
|
||||
var facebookCLose = document.getElementsByClassName("close")[2];
|
||||
|
||||
/**
|
||||
* When the user clicks the button, open the modal
|
||||
*/
|
||||
btn.onclick = function () {
|
||||
modal.style.display = "block";
|
||||
|
||||
}
|
||||
registerBtn.onclick = function () {
|
||||
registerModal.style.display = "block";
|
||||
}
|
||||
|
||||
/**
|
||||
* WHen the user clicks on (X), close the modal
|
||||
*/
|
||||
span.onclick = function () {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
registerSpan.onclick = function () {
|
||||
registerModal.style.display = "none";
|
||||
}
|
||||
facebookCLose.onclick = function () {
|
||||
facebookModal.style.display = "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* When the user clicks anywhere outside of the modal, close it
|
||||
*/
|
||||
window.onclick = function (event) {
|
||||
if (event.target == modal) {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
if (event.target == registerModal) {
|
||||
registerModal.style.display = "none";
|
||||
}
|
||||
if (event.target == facebookModal) {
|
||||
facebookModal.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When ESC is pressed, close modal
|
||||
*/
|
||||
document.addEventListener('keyup', function(e) {
|
||||
if (e.keyCode == 27) {
|
||||
modal.style.display = "none";
|
||||
registerModal.style.display = "none";
|
||||
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Created by joey on 2-2-17.
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ function fancyText(text) {
|
||||
}
|
||||
// Add links
|
||||
else {
|
||||
return "<a href='" + link + "'>" + link + "</a>";
|
||||
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -25,9 +25,15 @@ if(empty($_GET["username"])) {
|
||||
$userID = getUserID($_GET["username"]);
|
||||
}
|
||||
|
||||
$user = selectUser($_SESSION["userID"], $userID);
|
||||
if(!$user = selectUser($_SESSION["userID"], $userID)) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header("Location: error/404.php");
|
||||
die();
|
||||
}
|
||||
|
||||
$profile_friends = selectAllFriends($userID);
|
||||
$profile_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>
|
||||
@@ -18,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
case "profile":
|
||||
updateSettings();
|
||||
checkUpdateSettings();
|
||||
break;
|
||||
case "password":
|
||||
changePassword();
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.post-content a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.commentfield {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -87,7 +91,6 @@
|
||||
|
||||
.deleteButton {
|
||||
background-color: firebrick;
|
||||
|
||||
}
|
||||
|
||||
.deleteButton i {
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
background-color: firebrick;
|
||||
}
|
||||
|
||||
.alerttext {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.user-box {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -27,11 +31,14 @@
|
||||
display: block;
|
||||
|
||||
margin: 7px 0;
|
||||
width: 200px;
|
||||
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.friend-button-container button, .status-buttons-container button, .group-button-fixed {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.group-button-container button {
|
||||
float: right;
|
||||
}
|
||||
@@ -70,6 +77,22 @@
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.group-button-fancy span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.group-button-fancy:hover {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.group-button-fancy i {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.group-button-fancy:hover span {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* Old */
|
||||
|
||||
@@ -94,6 +117,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);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ function checkName($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!"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +68,7 @@ function validateBday($variable){
|
||||
}
|
||||
}
|
||||
|
||||
// Checks for date
|
||||
/* Checks for date */
|
||||
function validateDate($date, $format)
|
||||
{
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
@@ -81,6 +83,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 +96,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 +107,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 +120,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 +132,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 +154,6 @@ function resetEmail($variable){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* checks if two passwords matches. */
|
||||
function matchPassword(){
|
||||
if ($_POST["password"] != $_POST["confirmpassword"]) {
|
||||
|
||||
37
website/queries/createGroup.php
Normal file
37
website/queries/createGroup.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
require_once "../queries/checkInput.php";
|
||||
require_once "../queries/picture.php";
|
||||
require_once "../queries/alerts.php";
|
||||
function createGroup()
|
||||
{
|
||||
$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();
|
||||
|
||||
$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"];
|
||||
|
||||
$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);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ function selectLimitedFriends($userID, $limit) {
|
||||
`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`,
|
||||
@@ -58,7 +58,7 @@ function selectAllFriends($userID) {
|
||||
`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`,
|
||||
@@ -94,7 +94,7 @@ function selectAllFriendRequests() {
|
||||
`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`,
|
||||
@@ -245,7 +245,7 @@ function searchSomeFriends($n, $m, $search) {
|
||||
`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`,
|
||||
|
||||
109
website/queries/groupAdmin.php
Normal file
109
website/queries/groupAdmin.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
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();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
function getAllGroupMembers(int $groupID) {
|
||||
$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` = 'member'
|
||||
");
|
||||
|
||||
$stmt->bindParam(':groupID', $groupID);
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,12 @@ function selectGroupByName($name) {
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetch();
|
||||
$row = $stmt->fetch();
|
||||
if($row["groupID"] == null) {
|
||||
return False;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function selectGroupRole(int $groupID) {
|
||||
@@ -81,7 +86,10 @@ function selectGroupMembers(int $groupID) {
|
||||
`username`,
|
||||
`fname`,
|
||||
`lname`,
|
||||
`profilepicture`
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture
|
||||
FROM
|
||||
`group_member`
|
||||
LEFT JOIN
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
//Find matching password with the inputted username/emailadress.
|
||||
function getUser() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -33,7 +34,8 @@ function getUserID() {
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function validateLogin($username, $password){
|
||||
function validateLogin($username, $password, $url){
|
||||
echo $url;
|
||||
// Empty username or password field
|
||||
if (empty($username) || empty($password)) {
|
||||
throw new loginException("Inloggegevens zijn niet ingevuld");
|
||||
@@ -44,26 +46,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"){
|
||||
|
||||
} 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;
|
||||
header("location: profile.php");
|
||||
if(!isset($url) or $url == "") {
|
||||
header("location: profile.php");
|
||||
echo "succes";
|
||||
} else{
|
||||
header("location: ".$url);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
throw new loginException("Inloggevens zijn niet correct");
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,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
|
||||
@@ -139,6 +148,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"])) {
|
||||
@@ -155,6 +168,11 @@ function changeEmail() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an emailadres is available in the database.
|
||||
* @param $email
|
||||
* @throws AngryAlert
|
||||
*/
|
||||
function emailIsAvailableInDatabase($email) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -172,6 +190,12 @@ function emailIsAvailableInDatabase($email) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual changing of an email-adress.
|
||||
* @param $email
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function doChangeEmail($email) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -62,13 +62,17 @@ function selectUser($me, $other) {
|
||||
) 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
|
||||
@@ -97,7 +101,9 @@ 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();
|
||||
}
|
||||
|
||||
@@ -116,7 +122,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);
|
||||
@@ -131,7 +137,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`
|
||||
@@ -156,7 +162,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`
|
||||
@@ -184,7 +190,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`
|
||||
@@ -218,7 +224,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`
|
||||
@@ -362,7 +368,7 @@ function searchSomeUsers($n, $m, $search) {
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<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-comment">Beschrijving</th>
|
||||
<th class="table-action">Actie</th>
|
||||
</tr>
|
||||
|
||||
@@ -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'>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -67,13 +67,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 +91,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,6 +122,7 @@ 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\"
|
||||
@@ -131,7 +132,7 @@ if (isset($_GET["groupstatus"])) {
|
||||
<button type=\"submit\"
|
||||
name=\"batchactions\"
|
||||
id=\"owner\"
|
||||
value=\"owner\">Maak Owner</button>";
|
||||
value=\"owner\">Maak Eigenaar</button>";
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
@@ -139,9 +140,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="hide" value="hidden">Verborgen</button>
|
||||
<button type="submit" name="batchactions" id="ban" value="public">Publiek</button>
|
||||
<button type="submit" name="batchactions" id="members" value="membersonly">Alleen Leden</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
42
website/views/createGroup.php
Normal file
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,6 @@
|
||||
<!-- The Modal -->
|
||||
<div id="fbModal" class="modal">
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
return= $correct
|
||||
method="post"
|
||||
name="fbModal">
|
||||
|
||||
@@ -55,7 +54,6 @@
|
||||
*<span class="error"> <?php echo $fbConfirmpasswordErr;?></span>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if(empty($userBday)) { ?>
|
||||
<!-- Register birthday -->
|
||||
<div class="login_containerregister">
|
||||
@@ -67,17 +65,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>
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="noposts platform">
|
||||
<p>Geen posts meer!</p>
|
||||
</div>
|
||||
|
||||
<div class="modal">
|
||||
<div class="modal-content platform">
|
||||
<div class="modal-close">
|
||||
|
||||
126
website/views/groupAdmin.php
Normal file
126
website/views/groupAdmin.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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 class="fa fa-chevron-left"> 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"
|
||||
class="fa fa-save"
|
||||
> 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"
|
||||
class="fa fa-picture-o"
|
||||
> 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 = getAllGroupMembers($_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>
|
||||
<div class="platform">
|
||||
<ul>
|
||||
<li>
|
||||
<label></label>
|
||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button class="fa fa-chevron-left"> Terug naar de groep</button></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,7 +2,6 @@
|
||||
<meta name="description" content="MyHyvesbook+ is het sociaal media voor alle coole mensen.">
|
||||
<meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media">
|
||||
<meta name="author" content="MyHyvesbookplus corporation">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MyHyvesbook+</title>
|
||||
<!-- Add your javascript files here. -->
|
||||
<script src="js/jquery.js"></script>
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Checks if there's an 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 = "";
|
||||
|
||||
@@ -22,12 +29,13 @@ $user = $psw = $remember ="";
|
||||
$loginErr = $resetErr = $fbRegisterErr ="";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$url = $_POST["url"];
|
||||
// Checks for which button is pressed
|
||||
switch ($_POST["submit"]) {
|
||||
case "login":
|
||||
try {
|
||||
$user = ($_POST["user"]);
|
||||
validateLogin($_POST["user"], $_POST["psw"]);
|
||||
validateLogin($_POST["user"], $_POST["psw"], $url);
|
||||
} catch(loginException $e) {
|
||||
$loginErr = $e->getMessage();
|
||||
}
|
||||
@@ -46,18 +54,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 +84,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 +93,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 +108,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>";
|
||||
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,8 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="MyHyvesbook+ is het sociaal media voor alle coole mensen.">
|
||||
<meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media">
|
||||
<meta name="author" content="MyHyvesbookplus corporation">
|
||||
<title>MyHyvesbook+</title>
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
@@ -7,7 +10,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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="content">
|
||||
<div class='platform alertbox' id="alertbox">
|
||||
<span id="alerttext"></span>
|
||||
<span class="alerttext" id="alerttext"></span>
|
||||
</div>
|
||||
|
||||
<div class="user-box">
|
||||
@@ -19,16 +19,18 @@
|
||||
<div class="profile-info">
|
||||
<h2><?= $user["fname"]?> <?=$user["lname"]?></h2>
|
||||
<h5><?=$user["username"]?></h5>
|
||||
<?php if (strlen($user["bio"]) <= 50) {
|
||||
<?php
|
||||
if (strlen($user["bio"]) <= 50 and $showProfile) {
|
||||
echo "<p>" . $user["bio"] . "</p>";
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (strlen($user["bio"]) > 50) {
|
||||
<?php if (strlen($user["bio"]) > 50 and $showProfile) {
|
||||
echo "<div class='platform'><h3>Bio:</h3><p>" . $user["bio"] . "</p></div>";
|
||||
} ?>
|
||||
|
||||
<?php if($showProfile) { ?>
|
||||
<div class="item-box platform">
|
||||
<h3>Informatie</h3>
|
||||
<p>
|
||||
@@ -94,4 +96,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@@ -4,7 +4,6 @@
|
||||
<!-- The Modal -->
|
||||
<div id="registerModal" class="modal">
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
return= $correct
|
||||
method="post"
|
||||
name="forgotPassword">
|
||||
|
||||
@@ -15,14 +14,11 @@
|
||||
<h3>Registreer uw account</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
return= $correct
|
||||
method="post">
|
||||
|
||||
<div class="login_containerregister"><label>U krijgt een bevestigingsemail na het registreren</label></div>
|
||||
|
||||
<!-- Error message -->
|
||||
<div class="login_containerfault"><?php echo $genericErr;?></span></div>
|
||||
<div class="login_containerfault"><span><?php echo $genericErr;?></span></div>
|
||||
|
||||
<!-- Register name -->
|
||||
<div class="login_containerregister">
|
||||
@@ -82,7 +78,6 @@
|
||||
placeholder="Voer uw wachtwoord in"
|
||||
name="password"
|
||||
value="<?php echo $password ?>"
|
||||
id="password"
|
||||
required>
|
||||
*<span class="error"> <?php echo $passwordErr;?></span>
|
||||
<ul>
|
||||
@@ -96,7 +91,6 @@
|
||||
placeholder="Herhaal wachtwoord"
|
||||
name="confirmpassword"
|
||||
value="<?php echo $confirmpassword ?>"
|
||||
id="confirmpassword"
|
||||
title="Herhaal wachtwoord"
|
||||
required>
|
||||
*<span class="error"> <?php echo $confirmpasswordErr;?></span>
|
||||
@@ -120,7 +114,6 @@
|
||||
placeholder="Voer uw email in"
|
||||
name="email"
|
||||
value="<?php echo $email ?>"
|
||||
id="email"
|
||||
title="Voer een geldige email in"
|
||||
required>
|
||||
*<span class="error"> <?php echo $emailErr;?></span>
|
||||
@@ -133,7 +126,6 @@
|
||||
placeholder="Herhaal uw email"
|
||||
name="confirmEmail"
|
||||
value="<?php echo $confirmEmail ?>"
|
||||
id="email"
|
||||
title="Herhaal uw email"
|
||||
required>
|
||||
*<span class="error"> <?php echo $confirmEmailErr;?></span>
|
||||
@@ -152,8 +144,7 @@
|
||||
<!-- Register button -->
|
||||
<button type="submit"
|
||||
value="register"
|
||||
name="submit"
|
||||
id="frm1_submit">
|
||||
name="submit">
|
||||
Registreer
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user