Compare commits
3 Commits
marijn-gro
...
joey-testi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4643dfcddb | ||
|
|
05d6bf8aa6 | ||
|
|
ba6f86e70e |
@@ -21,8 +21,6 @@ require_once "../queries/alerts.php";
|
|||||||
include("../views/main.php");
|
include("../views/main.php");
|
||||||
$alertClass;
|
$alertClass;
|
||||||
$alertMessage;
|
$alertMessage;
|
||||||
|
|
||||||
// Select which button has been pressed.
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
try {
|
try {
|
||||||
switch ($_POST["form"]) {
|
switch ($_POST["form"]) {
|
||||||
@@ -46,15 +44,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
}
|
}
|
||||||
upgradeUser($_POST["groupID"], $_POST["userID"], "admin");
|
upgradeUser($_POST["groupID"], $_POST["userID"], "admin");
|
||||||
break;
|
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) {
|
} catch (AlertMessage $w) {
|
||||||
$alertClass = $w->getClass();
|
$alertClass = $w->getClass();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ var facebookModal = document.getElementById("fbModal");
|
|||||||
// Get the button that opens the modal
|
// Get the button that opens the modal
|
||||||
var registerBtn = document.getElementById("registerBtn");
|
var registerBtn = document.getElementById("registerBtn");
|
||||||
var btn = document.getElementById("myBtn");
|
var btn = document.getElementById("myBtn");
|
||||||
|
var fbBtn = document.getElementById("fbBtn");
|
||||||
|
|
||||||
// Get the <span> element that closes the modal
|
// Get the <span> element that closes the modal
|
||||||
var span = document.getElementsByClassName("close")[0];
|
var span = document.getElementsByClassName("close")[0];
|
||||||
@@ -24,6 +24,9 @@ btn.onclick = function () {
|
|||||||
registerBtn.onclick = function () {
|
registerBtn.onclick = function () {
|
||||||
registerModal.style.display = "block";
|
registerModal.style.display = "block";
|
||||||
}
|
}
|
||||||
|
fbBtn.onclick = function () {
|
||||||
|
facebookModal.style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WHen the user clicks on (X), close the modal
|
* WHen the user clicks on (X), close the modal
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$alertClass;
|
$alertClass;
|
||||||
$alertMessage;
|
$alertMessage;
|
||||||
|
|
||||||
// Select which button has been pressed.
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
try {
|
try {
|
||||||
switch ($_POST["form"]) {
|
switch ($_POST["form"]) {
|
||||||
@@ -31,6 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
case "picture":
|
case "picture":
|
||||||
updateAvatar();
|
updateAvatar();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (AlertMessage $w) {
|
} catch (AlertMessage $w) {
|
||||||
$alertClass = $w->getClass();
|
$alertClass = $w->getClass();
|
||||||
|
|||||||
@@ -41,11 +41,7 @@ function checkInputChoice($variable, $option){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* Checks for only letters and spaces. */
|
||||||
* Checks for only letters and spaces.
|
|
||||||
* @param $variable
|
|
||||||
* @throws lettersAndSpacesException
|
|
||||||
*/
|
|
||||||
function checkName($variable){
|
function checkName($variable){
|
||||||
if (empty($variable)) {
|
if (empty($variable)) {
|
||||||
throw new lettersAndSpacesException("Verplicht!");
|
throw new lettersAndSpacesException("Verplicht!");
|
||||||
@@ -56,11 +52,7 @@ function checkName($variable){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* Checks for bday */
|
||||||
* Checks for bday
|
|
||||||
* @param $variable
|
|
||||||
* @throws bdayException
|
|
||||||
*/
|
|
||||||
function validateBday($variable){
|
function validateBday($variable){
|
||||||
if (empty($variable)) {
|
if (empty($variable)) {
|
||||||
throw new bdayException("Verplicht!");
|
throw new bdayException("Verplicht!");
|
||||||
@@ -227,9 +219,6 @@ function test_input($data) {
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class lettersAndSpacesException
|
|
||||||
*/
|
|
||||||
class lettersAndSpacesException extends Exception
|
class lettersAndSpacesException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -238,9 +227,7 @@ class lettersAndSpacesException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class bdayException
|
|
||||||
*/
|
|
||||||
class bdayException extends Exception
|
class bdayException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -249,9 +236,6 @@ class bdayException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class usernameException
|
|
||||||
*/
|
|
||||||
class usernameException extends Exception
|
class usernameException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -260,9 +244,6 @@ class usernameException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class passwordException
|
|
||||||
*/
|
|
||||||
class passwordException extends Exception
|
class passwordException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -271,9 +252,6 @@ class passwordException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class confirmPasswordException
|
|
||||||
*/
|
|
||||||
class confirmPasswordException extends Exception
|
class confirmPasswordException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -282,9 +260,6 @@ class confirmPasswordException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class fbConfirmPasswordException
|
|
||||||
*/
|
|
||||||
class fbConfirmPasswordException extends Exception
|
class fbConfirmPasswordException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -293,9 +268,6 @@ class fbConfirmPasswordException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class emailException
|
|
||||||
*/
|
|
||||||
class emailException extends Exception
|
class emailException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -304,9 +276,6 @@ class emailException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class confirmEmailException
|
|
||||||
*/
|
|
||||||
class confirmEmailException extends Exception
|
class confirmEmailException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -315,9 +284,6 @@ class confirmEmailException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class captchaException
|
|
||||||
*/
|
|
||||||
class captchaException extends Exception
|
class captchaException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
@@ -326,9 +292,6 @@ class captchaException extends Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class registerException
|
|
||||||
*/
|
|
||||||
class registerException extends Exception
|
class registerException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ else {
|
|||||||
or die('Error connecting to mysql server');
|
or die('Error connecting to mysql server');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helperfunction to create a database query.
|
|
||||||
* @param string $query
|
|
||||||
* @return PDOStatement
|
|
||||||
*/
|
|
||||||
function prepareQuery(string $query) : PDOStatement {
|
function prepareQuery(string $query) : PDOStatement {
|
||||||
return $GLOBALS["db"]->prepare($query);
|
return $GLOBALS["db"]->prepare($query);
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,8 @@
|
|||||||
require_once "../queries/checkInput.php";
|
require_once "../queries/checkInput.php";
|
||||||
require_once "../queries/picture.php";
|
require_once "../queries/picture.php";
|
||||||
require_once "../queries/alerts.php";
|
require_once "../queries/alerts.php";
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a group.
|
|
||||||
*/
|
|
||||||
function createGroup()
|
function createGroup()
|
||||||
{
|
{
|
||||||
// Creates the group.
|
|
||||||
$createGroup = prepareQuery("
|
$createGroup = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`group_page` (`name`, `description`)
|
`group_page` (`name`, `description`)
|
||||||
@@ -18,7 +13,6 @@ function createGroup()
|
|||||||
$createGroup->bindValue(':description', test_input($_POST["bio"]));
|
$createGroup->bindValue(':description', test_input($_POST["bio"]));
|
||||||
$createGroup->execute();
|
$createGroup->execute();
|
||||||
|
|
||||||
// Gets the groupID just created.
|
|
||||||
$getGroupID = prepareQuery("
|
$getGroupID = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`groupID`
|
`groupID`
|
||||||
@@ -30,7 +24,6 @@ function createGroup()
|
|||||||
$getGroupID->execute();
|
$getGroupID->execute();
|
||||||
$groupID = $getGroupID->fetch()["groupID"];
|
$groupID = $getGroupID->fetch()["groupID"];
|
||||||
|
|
||||||
// Adds the user as an admin.
|
|
||||||
$makeUserAdmin = prepareQuery("
|
$makeUserAdmin = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`group_member` (userID, groupID, role)
|
`group_member` (userID, groupID, role)
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Sends a confirm email if you know the username.
|
|
||||||
* @param string $username
|
|
||||||
*/
|
|
||||||
function sendConfirmEmailUsername(string $username) {
|
function sendConfirmEmailUsername(string $username) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -18,10 +15,6 @@ function sendConfirmEmailUsername(string $username) {
|
|||||||
sendConfirmEmail($userID);
|
sendConfirmEmail($userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a confirm email if you know the userID.
|
|
||||||
* @param int $userID
|
|
||||||
*/
|
|
||||||
function sendConfirmEmail(int $userID) {
|
function sendConfirmEmail(int $userID) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Gets the current settings for a group.
|
|
||||||
* @param int $groupID
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
function getGroupSettings(int $groupID) {
|
function getGroupSettings(int $groupID) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -20,12 +15,6 @@ function getGroupSettings(int $groupID) {
|
|||||||
return $stmt->fetch();
|
return $stmt->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the settings for a group.
|
|
||||||
* @param int $groupID
|
|
||||||
* @throws AngryAlert
|
|
||||||
* @throws HappyAlert
|
|
||||||
*/
|
|
||||||
function updateGroupSettings(int $groupID)
|
function updateGroupSettings(int $groupID)
|
||||||
{
|
{
|
||||||
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
||||||
@@ -51,12 +40,6 @@ function updateGroupSettings(int $groupID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if an user is an admin for a page.
|
|
||||||
* @param int $groupID
|
|
||||||
* @param int $userID
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function checkGroupAdmin(int $groupID, int $userID) : bool {
|
function checkGroupAdmin(int $groupID, int $userID) : bool {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -77,40 +60,7 @@ function checkGroupAdmin(int $groupID, int $userID) : bool {
|
|||||||
return ($role == "admin");
|
return ($role == "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function getAllGroupMembers(int $groupID) {
|
||||||
* 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("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`username`,
|
`username`,
|
||||||
@@ -124,25 +74,16 @@ function getAllGroupMembers(int $groupID, string $role) {
|
|||||||
ON
|
ON
|
||||||
`group_member`.`userID` = `user`.`userID`
|
`group_member`.`userID` = `user`.`userID`
|
||||||
WHERE
|
WHERE
|
||||||
`groupID` = :groupID AND `group_member`.`role` = :role
|
`groupID` = :groupID AND `group_member`.`role` = 'member'
|
||||||
");
|
");
|
||||||
|
|
||||||
$stmt->bindParam(':groupID', $groupID);
|
$stmt->bindParam(':groupID', $groupID);
|
||||||
$stmt->bindParam(":role", $role);
|
|
||||||
if (!$stmt->execute()) {
|
if (!$stmt->execute()) {
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
return $stmt->fetchAll();
|
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) {
|
function upgradeUser(int $groupID, int $userID, string $role) {
|
||||||
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
||||||
throw new AngryAlert("Geen toestemming om te wijzigen");
|
throw new AngryAlert("Geen toestemming om te wijzigen");
|
||||||
@@ -165,28 +106,4 @@ function upgradeUser(int $groupID, int $userID, string $role) {
|
|||||||
} else {
|
} else {
|
||||||
throw new AngryAlert("Er is iets mis gegaan");
|
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,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
//Find matching password with the inputted username/emailadress.
|
||||||
* Find matching password with the inputted username/emailadress.
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
function getUser() {
|
function getUser() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -38,8 +35,7 @@ function getUserID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateLogin($username, $password, $url){
|
function validateLogin($username, $password, $url){
|
||||||
echo $url;
|
// Empty username or password field
|
||||||
// Empty username or password field
|
|
||||||
if (empty($username) || empty($password)) {
|
if (empty($username) || empty($password)) {
|
||||||
throw new loginException("Inloggegevens zijn niet ingevuld");
|
throw new loginException("Inloggegevens zijn niet ingevuld");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,12 +281,6 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns role of an user.
|
|
||||||
* @param int $userID
|
|
||||||
* @param int $groupID
|
|
||||||
* @return mixed role of an user.
|
|
||||||
*/
|
|
||||||
function getRoleInGroup(int $userID, int $groupID) {
|
function getRoleInGroup(int $userID, int $groupID) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an username exists with the filled in username.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingUsername() {
|
function getExistingUsername() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -16,6 +20,10 @@ function getExistingUsername() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an username exists with facebooklogin
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingFBUsername() {
|
function getExistingFBUsername() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -32,6 +40,10 @@ function getExistingFBUsername() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an email exists with the filled in email.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingEmail() {
|
function getExistingEmail() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -48,6 +60,10 @@ function getExistingEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an email exists with facebook register
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingFBEmail() {
|
function getExistingFBEmail() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -65,6 +81,10 @@ function getExistingFBEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an email exists with the forgot email input
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getResetEmail() {
|
function getResetEmail() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -81,6 +101,9 @@ function getResetEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a new account in the database
|
||||||
|
*/
|
||||||
function registerAccount() {
|
function registerAccount() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
@@ -119,6 +142,9 @@ function registerAccount() {
|
|||||||
$stmt->rowCount();
|
$stmt->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a new account with facebook register
|
||||||
|
*/
|
||||||
function fbRegisterAccount() {
|
function fbRegisterAccount() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
@@ -158,6 +184,11 @@ function fbRegisterAccount() {
|
|||||||
return $stmt->execute();
|
return $stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks which dates need to be selected when there is an invalid registration.
|
||||||
|
* @param $date
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
function submitselect($date, $value){
|
function submitselect($date, $value){
|
||||||
if ($date == $value){
|
if ($date == $value){
|
||||||
echo "selected";
|
echo "selected";
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../queries/connect.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) {
|
function sendPasswordRecovery(string $email) {
|
||||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
@@ -24,11 +28,16 @@ function sendPasswordRecovery(string $email) {
|
|||||||
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
|
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
|
||||||
setHashToDatabase($userID, $hash);
|
setHashToDatabase($userID, $hash);
|
||||||
doSendPasswordRecovery($userID, $email, $username, $hashedHash);
|
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) {
|
function doSendPasswordRecovery(int $userID, string $email, string $username, string $hash) {
|
||||||
$resetLink = "https://myhyvesbookplus.nl/resetpassword.php?u=$userID&h=$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);
|
mail($email, $subject, $body, $header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the previous password invalid.
|
||||||
|
* @param int $userID
|
||||||
|
* @param string $hash
|
||||||
|
*/
|
||||||
function setHashToDatabase(int $userID, string $hash) {
|
function setHashToDatabase(int $userID, string $hash) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
UPDATE
|
UPDATE
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ function getSettings() {
|
|||||||
`location`,
|
`location`,
|
||||||
`birthdate`,
|
`birthdate`,
|
||||||
`bio`,
|
`bio`,
|
||||||
IFNULL(
|
`profilepicture`,
|
||||||
`profilepicture`,
|
|
||||||
'../img/avatar-standard.png'
|
|
||||||
) AS profilepicture,
|
|
||||||
`showBday`,
|
`showBday`,
|
||||||
`showEmail`,
|
`showEmail`,
|
||||||
`showProfile`
|
`showProfile`
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
if(isset($acces_token)) {
|
||||||
|
echo '<button id="fbBtn" class="button">Facebook registreer</button>';
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!-- The Modal -->
|
<!-- The Modal -->
|
||||||
<div id="fbModal" class="modal">
|
<div id="fbModal" class="modal">
|
||||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
|||||||
<li>
|
<li>
|
||||||
<label></label>
|
<label></label>
|
||||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>">
|
<a href="group.php?groupname=<?=$groupinfo["name"]?>">
|
||||||
<button><i class="fa fa-chevron-left"></i> Terug naar de groep</button>
|
<button class="fa fa-chevron-left"> Terug naar de groep</button>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -51,7 +51,8 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
|||||||
<button type="submit"
|
<button type="submit"
|
||||||
name="form"
|
name="form"
|
||||||
value="group"
|
value="group"
|
||||||
><i class="fa fa-save"></i> Opslaan</button>
|
class="fa fa-save"
|
||||||
|
> Opslaan</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</form>
|
</form>
|
||||||
@@ -79,7 +80,8 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
|||||||
<button type="submit"
|
<button type="submit"
|
||||||
name="form"
|
name="form"
|
||||||
value="picture"
|
value="picture"
|
||||||
><i class="fa fa-picture-o"></i> Verander profielfoto</button>
|
class="fa fa-picture-o"
|
||||||
|
> Verander profielfoto</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</form>
|
</form>
|
||||||
@@ -92,7 +94,7 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
|||||||
<select name="userID">
|
<select name="userID">
|
||||||
<option disabled selected>Geen gebruiker geselecteerd:</option>
|
<option disabled selected>Geen gebruiker geselecteerd:</option>
|
||||||
<?php
|
<?php
|
||||||
$groupMembers = getAllGroupUsers($_GET["groupID"]);
|
$groupMembers = getAllGroupMembers($_GET["groupID"]);
|
||||||
foreach ($groupMembers as $groupMember) {?>
|
foreach ($groupMembers as $groupMember) {?>
|
||||||
<option value="<?=$groupMember["userID"]?>">
|
<option value="<?=$groupMember["userID"]?>">
|
||||||
<?=$groupMember["fullname"]?> (<?=$groupMember["username"]?>)
|
<?=$groupMember["fullname"]?> (<?=$groupMember["username"]?>)
|
||||||
@@ -112,55 +114,11 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
|||||||
</il>
|
</il>
|
||||||
</ul>
|
</ul>
|
||||||
</form>
|
</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">
|
<div class="platform">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<label></label>
|
<label></label>
|
||||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button><i class="fa fa-chevron-left"></i> Terug naar de groep</button></a>
|
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button class="fa fa-chevron-left"> Terug naar de groep</button></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user