Compare commits
2 Commits
lars
...
joey-testi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4643dfcddb | ||
|
|
05d6bf8aa6 |
@@ -13,7 +13,7 @@
|
||||
|
||||
include_once("../queries/group_page.php");
|
||||
|
||||
if(isset($_SESSION["userID"]) and !$group = selectGroupByName($_GET["groupname"])) {
|
||||
if(!$group = selectGroupByName($_GET["groupname"])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header("Location: error/404.php");
|
||||
die();
|
||||
|
||||
@@ -21,8 +21,6 @@ require_once "../queries/alerts.php";
|
||||
include("../views/main.php");
|
||||
$alertClass;
|
||||
$alertMessage;
|
||||
|
||||
// Select which button has been pressed.
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
@@ -46,15 +44,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
}
|
||||
upgradeUser($_POST["groupID"], $_POST["userID"], "admin");
|
||||
break;
|
||||
case "deadmin":
|
||||
if (!array_key_exists("userID", $_POST)) {
|
||||
throw new AngryAlert("Geen gebruiker geselecteerd.");
|
||||
}
|
||||
upgradeUser($_POST["groupID"], $_POST["userID"], "member");
|
||||
break;
|
||||
case "delete":
|
||||
deleteGroup();
|
||||
break;
|
||||
}
|
||||
} catch (AlertMessage $w) {
|
||||
$alertClass = $w->getClass();
|
||||
|
||||
@@ -24,14 +24,12 @@ $(window).on("load", function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Toggles all checkboxes based on one.
|
||||
function checkAll() {
|
||||
$('.checkbox-list').each(function () {
|
||||
$(this).prop('checked', $('#checkall').prop('checked'));
|
||||
});
|
||||
}
|
||||
|
||||
// Simple function that checks if checkall should stay checked.
|
||||
function checkCheckAll() {
|
||||
var checked = true;
|
||||
|
||||
@@ -45,7 +43,6 @@ function checkCheckAll() {
|
||||
$('#checkall').prop('checked', checked);
|
||||
}
|
||||
|
||||
// Toggle of filter options.
|
||||
function changeFilter() {
|
||||
if ($('#pagetype').find(":selected").val() == "group") {
|
||||
document.getElementById('admin-filter').style.display = 'none';
|
||||
@@ -62,13 +59,11 @@ function changeFilter() {
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the search page to one, relevant when changing filter or search.
|
||||
function searchFromOne() {
|
||||
$('#currentpage').prop('value', 1);
|
||||
adminSearch();
|
||||
}
|
||||
|
||||
// AJAX live search.
|
||||
function adminSearch() {
|
||||
$.post(
|
||||
"API/adminSearchUsers.php",
|
||||
@@ -79,7 +74,6 @@ function adminSearch() {
|
||||
})
|
||||
}
|
||||
|
||||
// AJAX live update.
|
||||
function adminUpdate(form) {
|
||||
$.post(
|
||||
"API/adminChangeUser.php",
|
||||
@@ -89,7 +83,6 @@ function adminUpdate(form) {
|
||||
})
|
||||
}
|
||||
|
||||
// AJAX pagenumber functionality.
|
||||
function updatePageN() {
|
||||
$.post(
|
||||
"API/adminPageNumber.php",
|
||||
@@ -99,13 +92,11 @@ function updatePageN() {
|
||||
})
|
||||
}
|
||||
|
||||
// Intended for the edit button to show a form.
|
||||
function toggleBancomment(button) {
|
||||
$(button).siblings("div").toggle();
|
||||
$(button).toggle();
|
||||
}
|
||||
|
||||
// AJAX value editing.
|
||||
function editComment(form) {
|
||||
$.post(
|
||||
"API/adminChangeUser.php",
|
||||
|
||||
@@ -51,7 +51,6 @@ function sendMessage() {
|
||||
});
|
||||
|
||||
$("#newContent").val("");
|
||||
$("#newContent").focus();
|
||||
}
|
||||
|
||||
// Add messages to the chat.
|
||||
|
||||
@@ -7,7 +7,7 @@ var facebookModal = document.getElementById("fbModal");
|
||||
// Get the button that opens the modal
|
||||
var registerBtn = document.getElementById("registerBtn");
|
||||
var btn = document.getElementById("myBtn");
|
||||
|
||||
var fbBtn = document.getElementById("fbBtn");
|
||||
|
||||
// Get the <span> element that closes the modal
|
||||
var span = document.getElementsByClassName("close")[0];
|
||||
@@ -24,6 +24,9 @@ btn.onclick = function () {
|
||||
registerBtn.onclick = function () {
|
||||
registerModal.style.display = "block";
|
||||
}
|
||||
fbBtn.onclick = function () {
|
||||
facebookModal.style.display = "block";
|
||||
}
|
||||
|
||||
/**
|
||||
* WHen the user clicks on (X), close the modal
|
||||
|
||||
@@ -91,21 +91,6 @@ $(window).on("load", function() {
|
||||
loadMorePosts(userID, groupID, postAmount, postLimit);
|
||||
}
|
||||
};
|
||||
|
||||
$(document).keyup(function(e) {
|
||||
if (e.keyCode == 27) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
$('.modal').click(function() {
|
||||
closeModal();
|
||||
});
|
||||
|
||||
$('.modal-content').click(function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function closeModal() {
|
||||
|
||||
0
website/public/js/profile.js
Normal file
0
website/public/js/profile.js
Normal file
@@ -25,8 +25,7 @@ if(empty($_GET["username"])) {
|
||||
$userID = getUserID($_GET["username"]);
|
||||
}
|
||||
|
||||
|
||||
if (isset($_SESSION["userID"]) and !$user = selectUser($_SESSION["userID"], $userID)) {
|
||||
if(!$user = selectUser($_SESSION["userID"], $userID)) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header("Location: error/404.php");
|
||||
die();
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
<?php
|
||||
$alertClass;
|
||||
$alertMessage;
|
||||
|
||||
// Select which button has been pressed.
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
@@ -31,6 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
case "picture":
|
||||
updateAvatar();
|
||||
break;
|
||||
|
||||
}
|
||||
} catch (AlertMessage $w) {
|
||||
$alertClass = $w->getClass();
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
.admin-panel {
|
||||
min-width: 800px;
|
||||
}
|
||||
|
||||
.admin-panel input[type="radio"], input[type="checkbox"] {
|
||||
vertical-align: middle;
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
margin: 7px;
|
||||
}
|
||||
|
||||
.table-checkbox {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.admin-searchform {
|
||||
@@ -36,15 +34,13 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-checkbox {width: 20px}
|
||||
.table-username {width: 150px}
|
||||
.table-status {width: 100px}
|
||||
.table-action {width: 200px}
|
||||
.usertable .table-username {width: 150px}
|
||||
.usertable .table-status {width: 100px}
|
||||
.usertable .table-action {width: 200px}
|
||||
|
||||
.usertable th, td {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 3px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.usertable th, tr {
|
||||
@@ -55,10 +51,6 @@
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.bancomment {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.bancommentedit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,7 @@ function checkInputChoice($variable, $option){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for only letters and spaces.
|
||||
* @param $variable
|
||||
* @throws lettersAndSpacesException
|
||||
*/
|
||||
/* Checks for only letters and spaces. */
|
||||
function checkName($variable){
|
||||
if (empty($variable)) {
|
||||
throw new lettersAndSpacesException("Verplicht!");
|
||||
@@ -56,11 +52,7 @@ function checkName($variable){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for bday
|
||||
* @param $variable
|
||||
* @throws bdayException
|
||||
*/
|
||||
/* Checks for bday */
|
||||
function validateBday($variable){
|
||||
if (empty($variable)) {
|
||||
throw new bdayException("Verplicht!");
|
||||
@@ -224,13 +216,9 @@ function test_input($data) {
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
$data = htmlspecialchars($data);
|
||||
$data = trim($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class lettersAndSpacesException
|
||||
*/
|
||||
class lettersAndSpacesException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -239,9 +227,7 @@ class lettersAndSpacesException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class bdayException
|
||||
*/
|
||||
|
||||
class bdayException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -250,9 +236,6 @@ class bdayException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class usernameException
|
||||
*/
|
||||
class usernameException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -261,9 +244,6 @@ class usernameException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class passwordException
|
||||
*/
|
||||
class passwordException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -272,9 +252,6 @@ class passwordException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class confirmPasswordException
|
||||
*/
|
||||
class confirmPasswordException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -283,9 +260,6 @@ class confirmPasswordException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class fbConfirmPasswordException
|
||||
*/
|
||||
class fbConfirmPasswordException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -294,9 +268,6 @@ class fbConfirmPasswordException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class emailException
|
||||
*/
|
||||
class emailException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -305,9 +276,6 @@ class emailException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class confirmEmailException
|
||||
*/
|
||||
class confirmEmailException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -316,9 +284,6 @@ class confirmEmailException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class captchaException
|
||||
*/
|
||||
class captchaException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
@@ -327,9 +292,6 @@ class captchaException extends Exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class registerException
|
||||
*/
|
||||
class registerException extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||
|
||||
@@ -10,11 +10,6 @@ else {
|
||||
or die('Error connecting to mysql server');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helperfunction to create a database query.
|
||||
* @param string $query
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function prepareQuery(string $query) : PDOStatement {
|
||||
return $GLOBALS["db"]->prepare($query);
|
||||
}
|
||||
@@ -2,13 +2,8 @@
|
||||
require_once "../queries/checkInput.php";
|
||||
require_once "../queries/picture.php";
|
||||
require_once "../queries/alerts.php";
|
||||
|
||||
/**
|
||||
* Creates a group.
|
||||
*/
|
||||
function createGroup()
|
||||
{
|
||||
// Creates the group.
|
||||
$createGroup = prepareQuery("
|
||||
INSERT INTO
|
||||
`group_page` (`name`, `description`)
|
||||
@@ -18,7 +13,6 @@ function createGroup()
|
||||
$createGroup->bindValue(':description', test_input($_POST["bio"]));
|
||||
$createGroup->execute();
|
||||
|
||||
// Gets the groupID just created.
|
||||
$getGroupID = prepareQuery("
|
||||
SELECT
|
||||
`groupID`
|
||||
@@ -30,7 +24,6 @@ function createGroup()
|
||||
$getGroupID->execute();
|
||||
$groupID = $getGroupID->fetch()["groupID"];
|
||||
|
||||
// Adds the user as an admin.
|
||||
$makeUserAdmin = prepareQuery("
|
||||
INSERT INTO
|
||||
`group_member` (userID, groupID, role)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* Sends a confirm email if you know the username.
|
||||
* @param string $username
|
||||
*/
|
||||
|
||||
function sendConfirmEmailUsername(string $username) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -18,10 +15,6 @@ function sendConfirmEmailUsername(string $username) {
|
||||
sendConfirmEmail($userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a confirm email if you know the userID.
|
||||
* @param int $userID
|
||||
*/
|
||||
function sendConfirmEmail(int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -2,21 +2,10 @@
|
||||
|
||||
require_once ("connect.php");
|
||||
|
||||
/**
|
||||
* Selects all friends of a user.
|
||||
* @param $userID
|
||||
* @return string
|
||||
*/
|
||||
function selectFriends($userID) {
|
||||
return selectLimitedFriends($userID, 9999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a limited amount of friends of a user.
|
||||
* @param $userID
|
||||
* @param $limit
|
||||
* @return string
|
||||
*/
|
||||
function selectLimitedFriends($userID, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -57,11 +46,7 @@ function selectLimitedFriends($userID, $limit) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects all friends of a user.
|
||||
* @param $userID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
|
||||
function selectAllFriends($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -98,10 +83,6 @@ function selectAllFriends($userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all friend requests of the current user.
|
||||
* @return string
|
||||
*/
|
||||
function selectAllFriendRequests() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -138,11 +119,6 @@ function selectAllFriendRequests() {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the friendship status from current user and userID.
|
||||
* @param $userID
|
||||
* @return int
|
||||
*/
|
||||
function getFriendshipStatus($userID) {
|
||||
# -2: Query failed.
|
||||
# -1: user1 and 2 are the same user
|
||||
@@ -186,11 +162,6 @@ function getFriendshipStatus($userID) {
|
||||
return intval($stmt->fetch()["friend_state"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request friendship from current user to target user.
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function requestFriendship($userID) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO `friendship` (user1ID, user2ID)
|
||||
@@ -202,11 +173,6 @@ function requestFriendship($userID) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes friendship between current and target user.
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function removeFriendship($userID) {
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM `friendship`
|
||||
@@ -223,11 +189,6 @@ function removeFriendship($userID) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the friendship between current and target user to accepted.
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function acceptFriendship($userID) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE `friendship`
|
||||
@@ -243,11 +204,6 @@ function acceptFriendship($userID) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last time the user visited the chat with specified friend.
|
||||
* @param $friend
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function setLastVisited($friend) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
@@ -278,13 +234,6 @@ function setLastVisited($friend) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches m friends from n filtered by search.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeFriends($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -332,11 +281,6 @@ function searchSomeFriends($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all friends of current user filtered by search.
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function countSomeFriends($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Gets the current settings for a group.
|
||||
* @param int $groupID
|
||||
* @return mixed
|
||||
*/
|
||||
function getGroupSettings(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -20,12 +15,6 @@ function getGroupSettings(int $groupID) {
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the settings for a group.
|
||||
* @param int $groupID
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function updateGroupSettings(int $groupID)
|
||||
{
|
||||
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
||||
@@ -51,12 +40,6 @@ function updateGroupSettings(int $groupID)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user is an admin for a page.
|
||||
* @param int $groupID
|
||||
* @param int $userID
|
||||
* @return bool
|
||||
*/
|
||||
function checkGroupAdmin(int $groupID, int $userID) : bool {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -77,40 +60,7 @@ function checkGroupAdmin(int $groupID, int $userID) : bool {
|
||||
return ($role == "admin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all normal members for a group.
|
||||
* @param int $groupID
|
||||
* @return array|bool
|
||||
*/
|
||||
function getAllGroupUsers(int $groupID) {
|
||||
return getAllGroupMembers($groupID, 'member');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all admin for a group.
|
||||
* @param int $groupID
|
||||
* @return array|bool
|
||||
*/
|
||||
function getAllGroupAdmins(int $groupID) {
|
||||
return getAllGroupMembers($groupID, 'admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all Moderators for a group.
|
||||
* @param int $groupID
|
||||
* @return array|bool
|
||||
*/
|
||||
function getAllGroupMods(int $groupID) {
|
||||
return getAllGroupMembers($groupID, 'mod');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all members for a group specified by a string.
|
||||
* @param int $groupID
|
||||
* @param string $role
|
||||
* @return array|bool
|
||||
*/
|
||||
function getAllGroupMembers(int $groupID, string $role) {
|
||||
function getAllGroupMembers(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`username`,
|
||||
@@ -124,25 +74,16 @@ function getAllGroupMembers(int $groupID, string $role) {
|
||||
ON
|
||||
`group_member`.`userID` = `user`.`userID`
|
||||
WHERE
|
||||
`groupID` = :groupID AND `group_member`.`role` = :role
|
||||
`groupID` = :groupID AND `group_member`.`role` = 'member'
|
||||
");
|
||||
|
||||
$stmt->bindParam(':groupID', $groupID);
|
||||
$stmt->bindParam(":role", $role);
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrades or downgrades a groupmember to a different role.
|
||||
* @param int $groupID
|
||||
* @param int $userID
|
||||
* @param string $role
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function upgradeUser(int $groupID, int $userID, string $role) {
|
||||
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
||||
throw new AngryAlert("Geen toestemming om te wijzigen");
|
||||
@@ -165,28 +106,4 @@ function upgradeUser(int $groupID, int $userID, string $role) {
|
||||
} else {
|
||||
throw new AngryAlert("Er is iets mis gegaan");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a group form the database.
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function deleteGroup() {
|
||||
if (!checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) {
|
||||
throw new AngryAlert("Geen toestemming om de groep te verwijderen!");
|
||||
}
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM
|
||||
`group_page`
|
||||
WHERE
|
||||
`groupID` = :groupID
|
||||
");
|
||||
$stmt->bindValue(":groupID", $_POST["groupID"]);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
throw new HappyAlert("Group verwijderd!");
|
||||
} else {
|
||||
throw new AngryAlert("Er is iets mis gegaan");
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns all groups a user is member of.
|
||||
* @param $userID
|
||||
* @return string
|
||||
*/
|
||||
function selectAllGroupsFromUser($userID) {
|
||||
return selectLimitedGroupsFromUser($userID, 9999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects number of groups that a user is member of.
|
||||
* @param $userID
|
||||
* @param $limit
|
||||
* @return string
|
||||
*/
|
||||
function selectLimitedGroupsFromUser($userID, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -38,13 +27,6 @@ function selectLimitedGroupsFromUser($userID, $limit) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns m groups offset by n filtered by search that the current user is part of.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeOwnGroups($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -73,11 +55,6 @@ function searchSomeOwnGroups($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all groups filtered by search that the current user is member of.
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function countSomeOwnGroups($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -101,13 +78,6 @@ function countSomeOwnGroups($search) {
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a user by userID to a group by groupID with a specified role.
|
||||
* @param $groupID
|
||||
* @param $userID
|
||||
* @param $role
|
||||
* @return bool
|
||||
*/
|
||||
function addMember($groupID, $userID, $role) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -122,13 +92,6 @@ function addMember($groupID, $userID, $role) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes te role of a user within a group to the specified one.
|
||||
* @param $groupID
|
||||
* @param $userID
|
||||
* @param $role
|
||||
* @return bool
|
||||
*/
|
||||
function changeMember($groupID, $userID, $role) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
@@ -146,12 +109,6 @@ function changeMember($groupID, $userID, $role) {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a user from a group.
|
||||
* @param $groupID
|
||||
* @param $userID
|
||||
* @return bool
|
||||
*/
|
||||
function deleteMember($groupID, $userID) {
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
require_once("connect.php");
|
||||
|
||||
/**
|
||||
* Selects some info from a group by name.
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function selectGroupByName($name) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -45,11 +41,6 @@ function selectGroupByName($name) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the current user's role within a group by the group's ID.
|
||||
* @param int $groupID
|
||||
* @return bool|string
|
||||
*/
|
||||
function selectGroupRole(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -72,11 +63,6 @@ function selectGroupRole(int $groupID) {
|
||||
return $stmt->fetch()["role"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of a group by it's ID.
|
||||
* @param int $groupID
|
||||
* @return bool
|
||||
*/
|
||||
function selectGroupStatus(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -94,11 +80,6 @@ function selectGroupStatus(int $groupID) {
|
||||
return $stmt->fetch()["status"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns some info of all group members.
|
||||
* @param int $groupID
|
||||
* @return bool|PDOStatement
|
||||
*/
|
||||
function selectGroupMembers(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -124,14 +105,9 @@ function selectGroupMembers(int $groupID) {
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt;
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns group info by it's ID.
|
||||
* @param $groupID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectGroupById($groupID) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -151,11 +127,6 @@ function selectGroupById($groupID) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns some info of 20 groups offset by n.
|
||||
* @param $n
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function select20GroupsFromN($n) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -178,12 +149,6 @@ function select20GroupsFromN($n) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns info of 20 groups offset by n, filtered by status.
|
||||
* @param $n
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function select20GroupsByStatusFromN($n, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -209,13 +174,6 @@ function select20GroupsByStatusFromN($n, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns info of 20 groups offset by n, filtered by status, filtered by search.
|
||||
* @param $n
|
||||
* @param $keyword
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function search20GroupsFromNByStatus($n, $keyword, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -243,14 +201,6 @@ function search20GroupsFromNByStatus($n, $keyword, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns info of n groups offset by m, filtered by status and search.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function searchSomeGroupsByStatus($n, $m, $search, $status) {
|
||||
// parentheses not needed in where clause, for clarity as
|
||||
// role search should override status filter.
|
||||
@@ -283,12 +233,6 @@ function searchSomeGroupsByStatus($n, $m, $search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count all groups filtered by status and search.
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeGroupsByStatus($search, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -312,12 +256,6 @@ function countSomeGroupsByStatus($search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the status of a group with the given ID.
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeGroupStatusByID($id, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -334,12 +272,6 @@ function changeGroupStatusByID($id, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the status of multiple groups to 1 status by an array of IDs.
|
||||
* @param $ids
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeMultipleGroupStatusByID($ids, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -357,13 +289,6 @@ function changeMultipleGroupStatusByID($ids, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns m groups offset by n, filtered by search.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeGroups($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -387,11 +312,6 @@ function searchSomeGroups($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all group filtered by search.
|
||||
* @param $search
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeGroups($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Find matching password with the inputted username/emailadress.
|
||||
* @return mixed
|
||||
*/
|
||||
//Find matching password with the inputted username/emailadress.
|
||||
function getUser() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Return a relative dutch and readable text when given a datetime.
|
||||
* @param $date
|
||||
* @return string
|
||||
*/
|
||||
function nicetime($date) {
|
||||
if(empty($date)) {
|
||||
return "No date provided";
|
||||
}
|
||||
|
||||
// Create dutch arrays so it has dutch words.
|
||||
$single_periods = array("seconde", "minuut", "uur", "dag", "week", "maand", "jaar", "decennium");
|
||||
$multiple_periods = array("seconden", "minuten", "uur", "dagen", "weken", "maanden", "jaar", "decennia");
|
||||
$lengths = array("60", "60", "24", "7", "4.35", "12", "10", "0");
|
||||
@@ -22,8 +15,7 @@ function nicetime($date) {
|
||||
return "Bad date";
|
||||
}
|
||||
|
||||
// Check if it is in the future or not.
|
||||
if($now >= $unix_date) {
|
||||
if($now > $unix_date) {
|
||||
$difference = $now - $unix_date;
|
||||
$tense = "geleden";
|
||||
} else {
|
||||
@@ -31,7 +23,6 @@ function nicetime($date) {
|
||||
$tense = "vanaf nu";
|
||||
}
|
||||
|
||||
// Get the nice time.
|
||||
for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) {
|
||||
$difference /= $lengths[$i];
|
||||
}
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
|
||||
require_once("connect.php");
|
||||
|
||||
/**
|
||||
* Select all posts on a user.
|
||||
* @param $userID
|
||||
* @param $groupID
|
||||
* @return bool|PDOStatement
|
||||
*/
|
||||
function selectAllPosts($userID, $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -52,14 +46,6 @@ function selectAllPosts($userID, $groupID) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Select $limit posts from $offset from a user or group.
|
||||
* @param $userID
|
||||
* @param $groupID
|
||||
* @param $offset
|
||||
* @param $limit
|
||||
* @return bool|PDOStatement
|
||||
*/
|
||||
function selectSomePosts($userID, $groupID, $offset, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -108,13 +94,9 @@ function selectSomePosts($userID, $groupID, $offset, $limit) {
|
||||
return False;
|
||||
}
|
||||
return $stmt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the post information from an postID.
|
||||
* @param $postID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectPostById($postID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -140,11 +122,6 @@ function selectPostById($postID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the comments from a post.
|
||||
* @param $postID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectCommentsByPostId($postID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -171,13 +148,6 @@ function selectCommentsByPostId($postID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a post to a group or user
|
||||
* @param $userID
|
||||
* @param $groupID
|
||||
* @param $title
|
||||
* @param $content
|
||||
*/
|
||||
function makePost($userID, $groupID, $title, $content) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -202,13 +172,6 @@ function makePost($userID, $groupID, $title, $content) {
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a comment by a post.
|
||||
* @param $postID
|
||||
* @param $userID
|
||||
* @param $content
|
||||
* @return int
|
||||
*/
|
||||
function makeComment($postID, $userID, $content) : int {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -231,12 +194,6 @@ function makeComment($postID, $userID, $content) : int {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* If a post already is niet slechted.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function makeNietSlecht(int $postID, int $userID) : int {
|
||||
if (checkNietSlecht($postID, $userID)) {
|
||||
return deleteNietSlecht($postID, $userID);
|
||||
@@ -245,12 +202,6 @@ function makeNietSlecht(int $postID, int $userID) : int {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a niet slecht of a post.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function checkNietSlecht(int $postID, int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -267,12 +218,6 @@ function checkNietSlecht(int $postID, int $userID) {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a niet slecht to a post.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function addNietSlecht(int $postID, int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -285,12 +230,6 @@ function addNietSlecht(int $postID, int $userID) {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a niet slecht.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return int
|
||||
*/
|
||||
function deleteNietSlecht(int $postID, int $userID) {
|
||||
$stmt = prepareQuery("
|
||||
DELETE FROM
|
||||
@@ -305,11 +244,6 @@ function deleteNietSlecht(int $postID, int $userID) {
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a post
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
*/
|
||||
function deletePost(int $postID, int $userID) {
|
||||
if (checkPermissionOnPost($postID, $userID)) {
|
||||
$stmt = prepareQuery("
|
||||
@@ -323,12 +257,6 @@ function deletePost(int $postID, int $userID) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user has premissions to delete a post.
|
||||
* @param int $postID
|
||||
* @param int $userID
|
||||
* @return bool
|
||||
*/
|
||||
function checkPermissionOnPost(int $postID, int $userID) : bool {
|
||||
$getGroupID = prepareQuery("
|
||||
SELECT
|
||||
@@ -353,12 +281,6 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns role of a user.
|
||||
* @param int $userID
|
||||
* @param int $groupID
|
||||
* @return mixed role of a user.
|
||||
*/
|
||||
function getRoleInGroup(int $userID, int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Get the the last 100 chat messages.
|
||||
* @param $user2ID
|
||||
* @return string
|
||||
*/
|
||||
function getOldChatMessages($user2ID) {
|
||||
require_once ("friendship.php");
|
||||
$user1ID = $_SESSION["userID"];
|
||||
@@ -41,12 +36,6 @@ function getOldChatMessages($user2ID) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a chat message.
|
||||
* @param $destination
|
||||
* @param $content
|
||||
* @return bool
|
||||
*/
|
||||
function sendMessage($destination, $content) {
|
||||
require_once("friendship.php");
|
||||
if (getFriendshipStatus($destination) == 1) {
|
||||
@@ -76,12 +65,6 @@ function sendMessage($destination, $content) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the chat messages after an messageID ($lastID).
|
||||
* @param $lastID
|
||||
* @param $destination
|
||||
* @return string
|
||||
*/
|
||||
function getNewChatMessages($lastID, $destination) {
|
||||
require_once("friendship.php");
|
||||
if (getFriendshipStatus($destination) == 1) {
|
||||
@@ -113,10 +96,7 @@ function getNewChatMessages($lastID, $destination) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get of every friend the first unread chat message.
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function selectAllUnreadChat() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Returns 1 if an username exists with the filled in username.
|
||||
* @return int
|
||||
*/
|
||||
function getExistingUsername() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -16,6 +20,10 @@ function getExistingUsername() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an username exists with facebooklogin
|
||||
* @return int
|
||||
*/
|
||||
function getExistingFBUsername() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -32,6 +40,10 @@ function getExistingFBUsername() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an email exists with the filled in email.
|
||||
* @return int
|
||||
*/
|
||||
function getExistingEmail() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -48,6 +60,10 @@ function getExistingEmail() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an email exists with facebook register
|
||||
* @return int
|
||||
*/
|
||||
function getExistingFBEmail() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -65,6 +81,10 @@ function getExistingFBEmail() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if an email exists with the forgot email input
|
||||
* @return int
|
||||
*/
|
||||
function getResetEmail() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -81,6 +101,9 @@ function getResetEmail() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new account in the database
|
||||
*/
|
||||
function registerAccount() {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -119,6 +142,9 @@ function registerAccount() {
|
||||
$stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new account with facebook register
|
||||
*/
|
||||
function fbRegisterAccount() {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
@@ -158,6 +184,11 @@ function fbRegisterAccount() {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks which dates need to be selected when there is an invalid registration.
|
||||
* @param $date
|
||||
* @param $value
|
||||
*/
|
||||
function submitselect($date, $value){
|
||||
if ($date == $value){
|
||||
echo "selected";
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
include_once "../queries/connect.php";
|
||||
|
||||
/**
|
||||
* Sends a link to an email to change the password of an account
|
||||
* @param string $email
|
||||
*/
|
||||
function sendPasswordRecovery(string $email) {
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$stmt = prepareQuery("
|
||||
@@ -24,11 +28,16 @@ function sendPasswordRecovery(string $email) {
|
||||
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
|
||||
setHashToDatabase($userID, $hash);
|
||||
doSendPasswordRecovery($userID, $email, $username, $hashedHash);
|
||||
} else {
|
||||
// TODO: Be angry!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message in the email to reset a password of an account.
|
||||
* @param int $userID
|
||||
* @param string $email
|
||||
* @param string $username
|
||||
* @param string $hash
|
||||
*/
|
||||
function doSendPasswordRecovery(int $userID, string $email, string $username, string $hash) {
|
||||
$resetLink = "https://myhyvesbookplus.nl/resetpassword.php?u=$userID&h=$hash";
|
||||
|
||||
@@ -38,6 +47,11 @@ function doSendPasswordRecovery(int $userID, string $email, string $username, st
|
||||
mail($email, $subject, $body, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the previous password invalid.
|
||||
* @param int $userID
|
||||
* @param string $hash
|
||||
*/
|
||||
function setHashToDatabase(int $userID, string $hash) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -16,10 +16,7 @@ function getSettings() {
|
||||
`location`,
|
||||
`birthdate`,
|
||||
`bio`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`profilepicture`,
|
||||
`showBday`,
|
||||
`showEmail`,
|
||||
`showProfile`
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
require_once ("connect.php");
|
||||
|
||||
/**
|
||||
* This sets the last activity of the session user to now.
|
||||
* @return bool, true is it ran correctly
|
||||
*/
|
||||
function updateLastActivity() {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
@@ -19,11 +15,6 @@ function updateLastActivity() {
|
||||
return $stmt->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the userID from a username
|
||||
* @param $username
|
||||
* @return mixed
|
||||
*/
|
||||
function getUserID($username) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -39,11 +30,6 @@ function getUserID($username) {
|
||||
return $stmt->fetch()["userID"];
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the username from a userID
|
||||
* @param $userID
|
||||
* @return mixed
|
||||
*/
|
||||
function getUsername($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -59,12 +45,6 @@ function getUsername($userID) {
|
||||
return $stmt->fetch()["username"];
|
||||
}
|
||||
|
||||
/**
|
||||
* This selects the information about the other user and the connection between the two.
|
||||
* @param $me
|
||||
* @param $other
|
||||
* @return bool|mixed
|
||||
*/
|
||||
function selectUser($me, $other) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -127,11 +107,6 @@ function selectUser($me, $other) {
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the users from a group.
|
||||
* @param $userID
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function selectAllUserGroups($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -155,11 +130,6 @@ function selectAllUserGroups($userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects 20 users from a given point in the table, ordered by role and name
|
||||
* @param $n
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function select20UsersFromN($n) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -185,12 +155,6 @@ function select20UsersFromN($n) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search 20 users from a given point in the table, ordered by role and name
|
||||
* @param $n
|
||||
* @param $keyword
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function search20UsersFromN($n, $keyword) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -219,13 +183,6 @@ function search20UsersFromN($n, $keyword) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search 20 users from a given point in the database where the status @param $status
|
||||
* @param $n
|
||||
* @param $keyword
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -258,14 +215,6 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users from a given point in the database where the status @param $status
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function searchSomeUsersByStatus($n, $m, $search, $status) {
|
||||
// parentheses not needed in where clause, for clarity as
|
||||
// role search should override status filter.
|
||||
@@ -303,12 +252,6 @@ function searchSomeUsersByStatus($n, $m, $search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the users with a name like $search and a $status
|
||||
* @param $search
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeUsersByStatus($search, $status) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -333,12 +276,7 @@ function countSomeUsersByStatus($search, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the user status
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
|
||||
function changeUserStatusByID($id, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -355,12 +293,6 @@ function changeUserStatusByID($id, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change multiple user statuses by an id array.
|
||||
* @param $ids
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeMultipleUserStatusByID($ids, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -378,13 +310,6 @@ function changeMultipleUserStatusByID($ids, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change multiple user statuses by an id array.
|
||||
* This excludes that admins and owners statuses can be changed.
|
||||
* @param $ids
|
||||
* @param $status
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function changeMultipleUserStatusByIDAdmin($ids, $status) {
|
||||
$q = prepareQuery("
|
||||
UPDATE
|
||||
@@ -404,11 +329,6 @@ function changeMultipleUserStatusByIDAdmin($ids, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a random user that is nog your friend.
|
||||
* @param $userID
|
||||
* @return mixed
|
||||
*/
|
||||
function selectRandomNotFriendUser($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -437,13 +357,6 @@ function selectRandomNotFriendUser($userID) {
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users.
|
||||
* @param $n
|
||||
* @param $m
|
||||
* @param $search
|
||||
* @return string
|
||||
*/
|
||||
function searchSomeUsers($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -484,11 +397,6 @@ function searchSomeUsers($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the users that you get searching for a user with a keyword.
|
||||
* @param $search
|
||||
* @return PDOStatement
|
||||
*/
|
||||
function countSomeUsers($search) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
@@ -512,11 +420,6 @@ function countSomeUsers($search) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the role of a user by userID.
|
||||
* @param $userID
|
||||
* @return mixed
|
||||
*/
|
||||
function getRoleByID($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -532,11 +435,6 @@ function getRoleByID($userID) {
|
||||
return $stmt->fetch()["role"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the ban comment.
|
||||
* @param $userID
|
||||
* @param $comment
|
||||
*/
|
||||
function editBanCommentByID($userID, $comment) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<th class="table-username">Groepsnaam</th>
|
||||
<th class="table-status">Status</th>
|
||||
<th class="table-comment">Beschrijving</th>
|
||||
<th class="table-action">Zichtbaarheid</th>
|
||||
<th class="table-action">Actie</th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -13,7 +13,6 @@ Pagina:
|
||||
id="currentpage"
|
||||
form="admin-searchform"
|
||||
onchange="adminSearch();">
|
||||
<!-- Construct the options. -->
|
||||
<?php
|
||||
for ($i=1; $i <= ceil($countresults / $entries); $i++) {
|
||||
if ($currentpage == $i) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<tr>
|
||||
<th class="table-checkbox"><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
|
||||
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
|
||||
<th class="table-username">Gebruikersnaam</th>
|
||||
<th class="table-status">Status</th>
|
||||
<th class="table-comment">Aantekening</th>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<!-- Form value holding. -->
|
||||
|
||||
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
|
||||
<?php
|
||||
$search = "";
|
||||
$status = array("user", "frozen", "banned", "unconfirmed", "admin", "owner");
|
||||
@@ -126,11 +127,11 @@ if (isset($_GET["groupstatus"])) {
|
||||
if ($userinfo == 'owner') {
|
||||
echo "<button type=\"submit\"
|
||||
name=\"batchactions\"
|
||||
id=\"batch-admin\"
|
||||
id=\"admin\"
|
||||
value=\"admin\">Maak Admin</button>
|
||||
<button type=\"submit\"
|
||||
name=\"batchactions\"
|
||||
id=\"batch-owner\"
|
||||
id=\"owner\"
|
||||
value=\"owner\">Maak Eigenaar</button>";
|
||||
}
|
||||
?>
|
||||
@@ -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="batch-hide" value="hidden">Verborgen</button>
|
||||
<button type="submit" name="batchactions" id="batch-public" value="public">Publiek</button>
|
||||
<button type="submit" name="batchactions" id="batch-members" value="membersonly">Alleen Leden</button>
|
||||
<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>
|
||||
|
||||
@@ -151,3 +152,5 @@ if (isset($_GET["groupstatus"])) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +1,9 @@
|
||||
<?php
|
||||
if(isset($acces_token)) {
|
||||
echo '<button id="fbBtn" class="button">Facebook registreer</button>';
|
||||
|
||||
}
|
||||
?>
|
||||
<!-- The Modal -->
|
||||
<div id="fbModal" class="modal">
|
||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||
|
||||
@@ -16,18 +16,9 @@
|
||||
<h2>Leden (<?= $group['members'] ?>)</h2>
|
||||
<p>
|
||||
<?php
|
||||
$membercount = $members->rowCount();
|
||||
$memberdif = $membercount - 7;
|
||||
|
||||
for ($i = 0; $i < min($membercount, 7); $i += 1) {
|
||||
$member = $members->fetch();
|
||||
foreach($members as $member) {
|
||||
echo "<a href=\"profile.php?username=" . $member["username"] . "\" data-title=\"" . $member["username"] . "\"><img class=\"profile-picture\" src=\"" . $member["profilepicture"] . "\" alt=\"" . $member["username"] . "'s profielfoto\"></a>";
|
||||
}
|
||||
|
||||
if ($memberdif > 0) {
|
||||
echo $memberdif === 1 ? "en nog 1 andere." : "...en nog $memberdif anderen.";
|
||||
}
|
||||
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
||||
<li>
|
||||
<label></label>
|
||||
<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>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -51,7 +51,8 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
||||
<button type="submit"
|
||||
name="form"
|
||||
value="group"
|
||||
><i class="fa fa-save"></i> Opslaan</button>
|
||||
class="fa fa-save"
|
||||
> Opslaan</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
@@ -79,7 +80,8 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
||||
<button type="submit"
|
||||
name="form"
|
||||
value="picture"
|
||||
><i class="fa fa-picture-o"></i> Verander profielfoto</button>
|
||||
class="fa fa-picture-o"
|
||||
> Verander profielfoto</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
@@ -92,7 +94,7 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
||||
<select name="userID">
|
||||
<option disabled selected>Geen gebruiker geselecteerd:</option>
|
||||
<?php
|
||||
$groupMembers = getAllGroupUsers($_GET["groupID"]);
|
||||
$groupMembers = getAllGroupMembers($_GET["groupID"]);
|
||||
foreach ($groupMembers as $groupMember) {?>
|
||||
<option value="<?=$groupMember["userID"]?>">
|
||||
<?=$groupMember["fullname"]?> (<?=$groupMember["username"]?>)
|
||||
@@ -112,55 +114,11 @@ $groupinfo = getGroupSettings($_GET["groupID"]);
|
||||
</il>
|
||||
</ul>
|
||||
</form>
|
||||
<form class="platform" method="post">
|
||||
<h5>Verwijder een admin/mod</h5>
|
||||
<ul>
|
||||
<il>
|
||||
<input name="groupID" value="<?=$_GET["groupID"]?>" type="hidden">
|
||||
<label>Selecteer gebruiker</label>
|
||||
<select name="userID">
|
||||
<option disabled selected>Geen gebruiker geselecteerd:</option>
|
||||
<?php
|
||||
$groupAdmins = getAllGroupAdmins($_GET["groupID"]);
|
||||
foreach ($groupAdmins as $groupAdmin) {?>
|
||||
<option value="<?=$groupAdmin["userID"]?>">
|
||||
<?=$groupAdmin["fullname"]?> (<?=$groupAdmin["username"]?>) (<?=$groupAdmin["role"]?>)
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php
|
||||
$groupMods = getAllGroupMods($_GET["groupID"]);
|
||||
foreach ($groupMods as $groupMod) {?>
|
||||
<option value="<?=$groupMod["userID"]?>">
|
||||
<?=$groupMod["fullname"]?> (<?=$groupMod["username"]?>) (<?=$groupMod["role"]?>)
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<button name="form"
|
||||
value="deadmin"
|
||||
>
|
||||
Verwijder
|
||||
</button>
|
||||
</il>
|
||||
</ul>
|
||||
</form>
|
||||
<form class="platform" method="post">
|
||||
<ul>
|
||||
<h5>Verwijder groep</h5>
|
||||
<li>
|
||||
<label></label>
|
||||
<input name="groupID" value="<?=$_GET["groupID"]?>" type="hidden">
|
||||
<button class="red"
|
||||
name="form"
|
||||
value="delete"
|
||||
><i class="fa fa-trash"></i> Verwijder groep</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<div class="platform">
|
||||
<ul>
|
||||
<li>
|
||||
<label></label>
|
||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button><i class="fa fa-chevron-left"></i> Terug naar de groep</button></a>
|
||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button class="fa fa-chevron-left"> Terug naar de groep</button></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Checks if there's a user already logged in
|
||||
// Checks if there's an user already logged in
|
||||
if(isset($_SESSION["userID"])){
|
||||
echo "<script>
|
||||
window.onload=checkLoggedIn();
|
||||
|
||||
@@ -55,17 +55,10 @@
|
||||
<h3>Vrienden</h3>
|
||||
<p>
|
||||
<?php
|
||||
$friendcount = $profile_friends->rowCount();
|
||||
$frienddif = $friendcount - 7;
|
||||
|
||||
for ($i = 0; $i < min($friendcount, 7); $i += 1) {
|
||||
$friend = $profile_friends->fetch();
|
||||
while($friend = $profile_friends->fetch()) {
|
||||
echo "<a href='profile.php?username=${friend["username"]}' data-title='${friend["username"]}'><img class='profile-picture' height='42' width='42' src='${friend["profilepicture"]}' alt='${friend["username"]}' /></a>";
|
||||
}
|
||||
|
||||
if ($frienddif > 0) {
|
||||
echo $frienddif === 1 ? "en nog 1 andere." : "...en nog $frienddif anderen.";
|
||||
}
|
||||
|
||||
if($profile_friends->rowCount() === 0) {
|
||||
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
|
||||
@@ -78,18 +71,10 @@
|
||||
<h3>Groepen</h3>
|
||||
<p>
|
||||
<?php
|
||||
$groupcount = $profile_groups->rowCount();
|
||||
$groupdif = $groupcount - 7;
|
||||
|
||||
for ($i = 0; $i < min($groupcount, 7); $i += 1) {
|
||||
$group = $profile_groups->fetch();
|
||||
while($group = $profile_groups->fetch()) {
|
||||
echo "<a href='group.php?groupname=${group['name']}' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
||||
}
|
||||
|
||||
if ($groupdif > 0) {
|
||||
echo $groupdif === 1 ? "en nog 1 andere." : "...en nog $groupdif anderen.";
|
||||
}
|
||||
|
||||
if($profile_groups->rowCount() === 0) {
|
||||
echo "<p>Deze gebruiker is nog geen lid van een groep.</p>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user