Merge branch 'master' into hendrik-search

This commit is contained in:
Hendrik
2017-02-02 10:27:21 +01:00
142 changed files with 12403 additions and 630 deletions

View File

@@ -3,18 +3,29 @@ session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
require_once ("../../queries/user.php");
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
} else if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
} else if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
} else if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
}
if (isset($_SESSION["userID"]) &&
(getRoleByID($_SESSION["userID"]) == 'admin' ||
getRoleByID($_SESSION["userID"]) == 'owner')) {
$userinfo = getRoleByID($_SESSION['userID']);
//header("location: ../admin.php");
print_r($_POST);
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
} else if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
} else if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
if ($userinfo == 'owner') {
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
} else {
changeMultipleUserStatusByIDAdmin($_POST["checkbox-user"], $_POST["batchactions"]);
}
} else if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
} else if (isset($_POST['bancommentuserID']) && isset($_POST['bancommenttext'])) {
editBanCommentByID($_POST['bancommentuserID'], $_POST['bancommenttext']);
}
} else {
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -5,24 +5,40 @@ session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
if (isset($_SESSION["userID"]) &&
(getRoleByID($_SESSION["userID"]) == 'admin' ||
getRoleByID($_SESSION["userID"]) == 'owner')) {
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
$pagetype = "user";
if (isset($_POST['pagetype'])) {
$pagetype = test_input($_POST['pagetype']);
}
$pagetype = "user";
if (isset($_POST['pagetype'])) {
$pagetype = test_input($_POST['pagetype']);
}
$status = array();
if (isset($_POST['status'])) {
$status = $_POST["status"];
}
$status = array();
if (isset($_POST['status'])) {
$status = $_POST["status"];
}
$groupstatus = array();
if (isset($_POST['groupstatus'])) {
$groupstatus = $_POST["groupstatus"];
}
$entries = 20;
$currentpage = 1;
if (isset($_POST['currentpage'])) {
$currentpage = (int) test_input($_POST["currentpage"]);
}
$offset = (int) $currentpage * $entries - $entries;
if ($pagetype == "user") {
include ("../../views/adminpanel-page.php");
} else {
echo "Pagenumber failed!";
}
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -7,38 +7,44 @@ require_once ("../../queries/checkInput.php");
require_once ("../../queries/user.php");
require_once ("../../queries/group_page.php");
$offset = 0;
if (isset($_POST["n"])) {
$offset = (int) test_input($_POST["n"]);
}
$entries = 20;
if (isset($_POST["m"])) {
$entries = (int) test_input($_POST["m"]);
}
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
if (isset($_SESSION["userID"]) &&
(getRoleByID($_SESSION["userID"]) == 'admin' ||
getRoleByID($_SESSION["userID"]) == 'owner')) {
$offset = 0;
$entries = 20;
if (isset($_POST["currentpage"])) {
$offset = (int)test_input($_POST["currentpage"]) * $entries - $entries;
}
$pagetype = "user";
if (isset($_POST['pagetype'])) {
$pagetype = test_input($_POST['pagetype']);
}
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
$status = array();
if (isset($_POST['status'])) {
$status = $_POST["status"];
}
$pagetype = "user";
if (isset($_POST['pagetype'])) {
$pagetype = test_input($_POST['pagetype']);
}
$groupstatus = array();
if (isset($_POST['groupstatus'])) {
$groupstatus = $_POST["groupstatus"];
}
$status = array();
if (isset($_POST['status'])) {
$status = $_POST["status"];
}
if ($pagetype == "user") {
include ("../../views/adminpanel-table.php");
} else if ($pagetype == "group") {
include ("../../views/adminpanel-grouptable.php");
$groupstatus = array();
if (isset($_POST['groupstatus'])) {
$groupstatus = $_POST["groupstatus"];
}
$userinfo = getRoleByID($_SESSION['userID']);
if ($pagetype == "user") {
include("../../views/adminpanel-table.php");
} else if ($pagetype == "group") {
include("../../views/adminpanel-grouptable.php");
} else {
echo "Search failed!";
}
} else {
echo "Search failed!";
}
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -0,0 +1,20 @@
<?php
session_start();
require_once "../../queries/post.php";
require_once "../../queries/user.php";
if (isset($_SESSION["userID"]) and
getRoleByID($_SESSION["userID"]) != 'frozen' and
getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_POST["postID"]) or empty($_SESSION["userID"])) {
header('HTTP/1.1 500 Non enough arguments');
}
deletePost($_POST["postID"], $_SESSION["userID"]);
return;
} else {
echo "frozen";
}

View File

@@ -3,25 +3,32 @@
session_start();
require_once ("../../queries/friendship.php");
require_once("../../queries/user.php");
if(empty($_POST["usr"]) OR empty($_POST["action"]) OR !in_array($_POST["action"], array("request", "accept", "delete"))) {
header('HTTP/1.1 500 Non enough arguments');
}
$friendship_status = getFriendshipStatus($_POST["usr"]);
if($_POST["action"] == "request" AND $friendship_status == 0) {
if (!requestFriendship($_POST["usr"])) {
header('HTTP/1.1 500 Query (request) failed');
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_POST["usr"]) OR empty($_POST["action"]) OR !in_array($_POST["action"], array("request", "accept", "delete"))) {
header('HTTP/1.1 500 Non enough arguments');
}
} else if($_POST["action"] == "delete" AND in_array($friendship_status, array(1, 2, 3))) {
if (!removeFriendship($_POST["usr"])) {
header('HTTP/1.1 500 Query (delete) failed');
}
} else if ($_POST["action"] == "accept" AND $friendship_status == 3) {
if (!acceptFriendship($_POST["usr"])) {
header('HTTP/1.1 500 Query (accept) failed');
$friendship_status = getFriendshipStatus($_POST["usr"]);
if ($_POST["action"] == "request" AND $friendship_status == 0) {
if (!requestFriendship($_POST["usr"])) {
header('HTTP/1.1 500 Query (request) failed');
}
} else if ($_POST["action"] == "delete" AND in_array($friendship_status, array(1, 2, 3))) {
if (!removeFriendship($_POST["usr"])) {
header('HTTP/1.1 500 Query (delete) failed');
}
} else if ($_POST["action"] == "accept" AND $friendship_status == 3) {
if (!acceptFriendship($_POST["usr"])) {
header('HTTP/1.1 500 Query (accept) failed');
}
} else {
header('HTTP/1.1 500 Not the right friendship status');
}
} else {
header('HTTP/1.1 500 Not the right friendship status');
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -0,0 +1,40 @@
<?php
session_start();
if(empty($_POST["grp"]) or empty($_POST["role"])) {
header('HTTP/1.1 500 Non enough arguments');
}
if(in_array($_POST["role"], array('request', 'member', 'banned', 'mod', 'admin'))) {
header('HTTP/1.1 500 Wrong argument given for role');
}
require_once ("../../queries/group_member.php");
require_once ("../../queries/group_page.php");
require_once ("../../queries/group_member.php");
$currentRole = selectGroupRole($_POST["grp"]);
$groupStatus = selectGroupStatus($_POST["grp"]);
echo "role: $currentRole status: $groupStatus ";
if($_POST["role"] == 'request' and $currentRole == 'none') {
if($groupStatus = 'public') {
// Add member to public group
addMember($_POST["grp"], $_SESSION["userID"], 'member');
echo "ADDED";
} else if($groupStatus = 'membersonly') {
// Send request to members only group
addMember($_POST["grp"], $_SESSION["userID"], 'request');
} else {
// Can't invite yourself to hidden groups
header('HTTP/1.1 500 This group is hidden');
}
header('HTTP/1.1 200');
} else if($_POST["role"] == 'none' and $currentRole != 'none') {
// Remove yourself from a group
deleteMember($_POST["grp"], $_SESSION["userID"]);
} else {
echo "failure";
header('HTTP/1.1 500 Wrong argument given for role');
}

View File

@@ -10,15 +10,21 @@
session_start();
require_once ("../../queries/friendship.php");
require_once("../../queries/user.php");
if(empty($_POST["usr"])) {
header('HTTP/1.1 500 Non enough arguments');
}
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_POST["usr"])) {
header('HTTP/1.1 500 Non enough arguments');
}
$friendship_status = getFriendshipStatus($_POST["usr"]);
$friendship_status = getFriendshipStatus($_POST["usr"]);
if($friendship_status == -2) {
header('HTTP/1.1 500 Query failed');
}
if ($friendship_status == -2) {
header('HTTP/1.1 500 Query failed');
}
echo $friendship_status;
echo $friendship_status;
} else {
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -0,0 +1,12 @@
<?php
session_start();
if(empty($_POST["grp"])) {
header('HTTP/1.1 500 Non enough arguments');
}
require_once("../../queries/group_page.php");
echo selectGroupRole($_POST["grp"]);

View File

@@ -1,26 +1,37 @@
<?php
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
header('HTTP/1.1 500 Non enough arguments');
if(!isset($_POST["offset"]) or !isset($_POST["limit"])) {
header('HTTP/1.1 500 Not enough arguments');
}
if(!isset($_POST["usr"]) and !isset($_POST["grp"])) {
header('HTTP/1.1 500 Not enough arguments');
}
session_start();
require_once ("../../queries/post.php");
require_once ("../../queries/nicetime.php");
require_once("../../queries/user.php");
if(empty($_POST["usr"])) {
$posts = selectAllPosts(0, $_POST["grp"]);
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if(empty($_POST["usr"])) {
$posts = selectSomePosts(0, $_POST["grp"], $_POST["offset"], $_POST["limit"]);
} else {
$posts = selectSomePosts($_POST["usr"], 0, $_POST["offset"], $_POST["limit"]);
}
if(!$posts) {
echo false;
} else {
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
for($i = 0; $i < sizeof($results); $i++) {
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
}
echo json_encode($results);
}
} else {
$posts = selectAllPosts($_POST["usr"], 0);
header('HTTP/1.0 403 Forbidden');
}
if(!$posts) {
header('HTTP/1.1 500 Query failed');
}
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
for($i = 0; $i < sizeof($results); $i++) {
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
}
echo json_encode($results);

View File

@@ -4,5 +4,11 @@ session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/private_message.php");
require_once("../../queries/user.php");
echo selectAllUnreadChat();
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
echo selectAllUnreadChat();
} else {
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -4,5 +4,12 @@ session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/friendship.php");
require_once ("../../queries/user.php");
echo selectAllFriendRequests();
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
echo selectAllFriendRequests();
} else {
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -5,12 +5,22 @@ session_start();
require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/friendship.php");
require_once("../../queries/user.php");
if (isset($_POST["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int) test_input($_POST["limit"]));
} else if (isset($_GET["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int) test_input($_GET["limit"]));
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (isset($_SESSION["userID"])) {
if (isset($_POST["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"]));
} else if (isset($_GET["limit"])) {
echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_GET["limit"]));
} else {
echo selectFriends($_SESSION["userID"]);
}
} else {
echo "[]";
}
} else {
echo selectFriends($_SESSION["userID"]);
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -6,9 +6,15 @@ require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/group_member.php");
if (isset($_POST["limit"])) {
echo selectLimitedGroupsFromUser($_SESSION["userID"], (int) test_input($_POST["limit"]));
} else {
echo selectAllGroupsFromUser($_SESSION["userID"]);
}
require_once("../../queries/user.php");
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (isset($_POST["limit"])) {
echo selectLimitedGroupsFromUser($_SESSION["userID"], (int)test_input($_POST["limit"]));
} else {
echo selectAllGroupsFromUser($_SESSION["userID"]);
}
} else {
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -6,11 +6,17 @@ require_once("../../queries/connect.php");
require_once("../../queries/private_message.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/friendship.php");
require_once("../../queries/user.php");
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
setLastVisited(test_input($_POST["destination"]));
echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"]));
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
setLastVisited(test_input($_POST["destination"]));
echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"]));
} else {
setLastVisited(test_input($_POST["destination"]));
echo getOldChatMessages(test_input($_POST["destination"]));
}
} else {
setLastVisited(test_input($_POST["destination"]));
echo getOldChatMessages(test_input($_POST["destination"]));
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -1,12 +1,21 @@
<?php
session_start();
require_once("../../queries/connect.php");
require_once("../../queries/post.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/nicetime.php");
if(isset($_GET['postID'])) {
include("../../views/post-view.php");
require_once("../../queries/user.php");
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (isset($_GET['postID'])) {
include("../../views/post-view.php");
} else {
echo "Kan de post niet laden";
}
} else {
echo "Failed to load";
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -1,41 +0,0 @@
<?php
session_start();
require_once ("../queries/connect.php");
require_once ("../queries/checkInput.php");
function getNietSlechtCountForPost(int $postID) : int {
$stmt = prepareQuery("
SELECT
`userID`
FROM
`niet_slecht`
WHERE
`postID` = :postID
");
$stmt->bindParam(":postID", $postID);
$stmt->execute();
return $stmt->rowCount();
}
function getNietSlechtUsersForPost(int $postID) {
$stmt = prepareQuery("
SELECT
`fname`,
`lname`,
CONCAT(`user`.`fname`, ' ', `user`.`lname`) as `fullname`
FROM
`user`
INNER JOIN
`niet_slecht`
WHERE
`user`.`userID` = `niet_slecht`.`userID` AND
`niet_slecht`.`postID` = :postID
");
$stmt->bindParam(":postID", $postID);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
print($row["fullname"]);
}
}

View File

@@ -2,28 +2,36 @@
session_start();
require("../../queries/post.php");
require_once("../../queries/post.php");
require_once("../../queries/connect.php");
require("../../queries/checkInput.php");
print_r($_POST);
if ($_POST['button'] == 'reaction') {
if (empty($_POST['newcomment-content'])) {
echo 0;
} else {
if (makeComment($_POST['postID'],
$_SESSION['userID'],
test_input($_POST['newcomment-content']))) {
require_once("../../queries/checkInput.php");
require_once("../../queries/user.php");
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if ($_POST['button'] == 'reaction') {
if (empty($_POST['newcomment-content'])) {
echo 0;
} else {
if (makeComment($_POST['postID'],
$_SESSION['userID'],
test_input($_POST['newcomment-content']))) {
echo 1;
} else {
echo 0;
}
}
} else if ($_POST['button'] == 'nietslecht') {
if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) {
echo 1;
} else {
echo 0;
}
}
} else if ($_POST['button'] == 'nietslecht') {
if (makeNietSlecht($_POST["postID"], $_SESSION["userID"])) {
echo 1;
} else {
echo 0;
}
} else {
echo 0;
echo "frozen";
}

View File

@@ -6,49 +6,43 @@ require_once("../../queries/post.php");
require_once("../../queries/group_page.php");
require_once("../../queries/connect.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/user.php");
if (empty($_POST["title"]) or
empty($_POST["content"]) or
empty($_SESSION["userID"])) {
header('HTTP/1.1 500 Non enough arguments');
}
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (empty($_POST["group"])) {
// User Post
makePost(
$_SESSION["userID"],
null,
test_input($_POST["title"]),
test_input($_POST["content"])
);
} else {
// Group Post
// Check if the user is an admin or mod of the group.
if(!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
header('HTTP/1.1 500 Non enough rights');
return;
if (empty($_POST["title"]) or
empty($_POST["content"]) or
empty($_SESSION["userID"])
) {
header('HTTP/1.1 500 Non enough arguments');
}
makePost(
$_SESSION["userID"],
$_POST["group"],
test_input($_POST["title"]),
test_input($_POST["content"])
);
}
if (empty($_POST["group"])) {
// User Post
makePost(
$_SESSION["userID"],
null,
test_input($_POST["title"]),
test_input($_POST["content"])
);
} else {
// Group Post
// Check if the user is an admin or mod of the group.
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
header('HTTP/1.1 500 Non enough rights');
return;
}
//if (empty($_POST['newpost-title'])) {
//} else {
// makePost($_SESSION['userID'],
// null,
// test_input($_POST['newpost-title']),
// test_input($_POST['newpost-content']));
//}
//
//header("Location: ../profile.php");
makePost(
$_SESSION["userID"],
$_POST["group"],
test_input($_POST["title"]),
test_input($_POST["content"])
);
}
} else {
echo "frozen";
}

View File

@@ -7,22 +7,29 @@ require_once ("../../queries/connect.php");
require_once ("../../queries/checkInput.php");
require_once ("../../queries/group_member.php");
require_once ("../../queries/group_page.php");
require_once ("../../queries/user.php");
$n = 0;
if (isset($_POST["n"])) {
$n = (int) test_input($_POST["n"]);
}
$m = 20;
if (isset($_POST["m"])) {
$m = (int) test_input($_POST["m"]);
}
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (isset($_POST["filter"]) && $_POST["filter"] == "personal") {
echo searchSomeOwnGroups($n, $m, $search);
$n = 0;
if (isset($_POST["n"])) {
$n = (int)test_input($_POST["n"]);
}
$m = 20;
if (isset($_POST["m"])) {
$m = (int)test_input($_POST["m"]);
}
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
if (isset($_POST["filter"]) && $_POST["filter"] == "personal") {
echo searchSomeOwnGroups($n, $m, $search);
} else {
echo searchSomeGroups($n, $m, $search);
}
} else {
echo searchSomeGroups($n, $m, $search);
}
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -9,41 +9,45 @@ require_once ("../../queries/group_page.php");
require_once ("../../queries/friendship.php");
require_once ("../../queries/group_member.php");
$user_perpage = $group_perpage = 20;
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {$user_perpage = $group_perpage = 20;
$user_currentpage = $group_currentpage = 1;
if (isset($_POST['user-pageselect'])) {
$user_currentpage = test_input($_POST['user-pageselect']);
}
if (isset($_POST['group-pageselect'])) {
$group_currentpage = test_input($_POST['group-pageselect']);
}
$user_currentpage = $group_currentpage = 1;
if (isset($_POST['user-pageselect'])) {
$user_currentpage = test_input($_POST['user-pageselect']);
}
if (isset($_POST['group-pageselect'])) {
$group_currentpage = test_input($_POST['group-pageselect']);
}
$user_n = $user_currentpage * $user_perpage - $user_perpage;
$group_n = $group_currentpage * $group_perpage - $group_perpage;
$user_n = $user_currentpage * $user_perpage - $user_perpage;
$group_n = $group_currentpage * $group_perpage - $group_perpage;
$search = "";
if (isset($_POST['search'])) {
$search = test_input($_POST['search']);
}
$search = "";
if (isset($_POST['search'])) {
$search = test_input($_POST['search']);
}
$filter = "all";
if (isset($_POST['filter'])) {
$filter = test_input($_POST['filter']);
}
$filter = "all";
if (isset($_POST['filter'])) {
$filter = test_input($_POST['filter']);
}
if ($filter == "all") {
$user_count = countSomeUsers($search)->fetchColumn();
$group_count = countSomeGroups($search)->fetchColumn();
if ($filter == "all") {
$user_count = countSomeUsers($search)->fetchColumn();
$group_count = countSomeGroups($search)->fetchColumn();
} else {
$user_count = countSomeFriends($search);
$group_count = countSomeOwnGroups($search);
}
$option = "user";
if (isset($_POST['option'])) {
$option = test_input($_POST['option']);
}
include ("../../views/searchPageNumber.php");
} else {
$user_count = countSomeFriends($search);
$group_count = countSomeOwnGroups($search);
header('HTTP/1.0 403 Forbidden');
}
$option = "user";
if (isset($_POST['option'])) {
$option = test_input($_POST['option']);
}
include ("../../views/searchPageNumber.php");

View File

@@ -7,23 +7,29 @@ require_once ("../../queries/checkInput.php");
require_once ("../../queries/friendship.php");
require_once ("../../queries/user.php");
$n = 0;
$m = 20;
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'banned') {
$page = 1;
if (isset($_POST["user-pageselect"])) {
$page = (int) test_input($_POST['user-pageselect']);
}
$n = 0;
$m = 20;
$n = ($page - 1) * $m;
$page = 1;
if (isset($_POST["user-pageselect"])) {
$page = (int)test_input($_POST['user-pageselect']);
}
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
$n = ($page - 1) * $m;
if (isset($_POST["filter"]) && $_POST["filter"] == "personal") {
echo searchSomeFriends($n, $m, $search);
$search = "";
if (isset($_POST["search"])) {
$search = test_input($_POST["search"]);
}
if (isset($_POST["filter"]) && $_POST["filter"] == "personal") {
echo searchSomeFriends($n, $m, $search);
} else {
echo searchSomeUsers($n, $m, $search);
}
} else {
echo searchSomeUsers($n, $m, $search);
}
header('HTTP/1.0 403 Forbidden');
}

View File

@@ -4,14 +4,22 @@ session_start();
require_once("../../queries/connect.php");
require_once("../../queries/private_message.php");
require_once("../../queries/checkInput.php");
require_once("../../queries/user.php");
if (!empty(test_input($_POST["destination"])) &&
!empty(test_input($_POST["content"]))) {
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
echo 1;
if (isset($_SESSION["userID"]) &&
getRoleByID($_SESSION["userID"]) != 'frozen' &&
getRoleByID($_SESSION["userID"]) != 'banned') {
if (!empty(test_input($_POST["destination"])) &&
!empty(test_input($_POST["content"]))
) {
if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) {
echo 1;
} else {
echo 0;
}
} else {
echo 0;
}
} else {
echo 0;
echo "frozen";
}

View File

@@ -8,7 +8,7 @@
<style>
@import url("styles/adminpanel.css");
</style>
<script src="js/admin.js" charset="utf-8"></script>
<script src="js/admin.js" charset="utf-8"></script>
</head>
<body>
<?php
@@ -19,9 +19,9 @@
include_once ("../queries/user.php");
// auth
$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC);
$role = getRoleByID($_SESSION['userID']);
if ($userinfo['role'] != 'admin' AND $userinfo['role'] != 'owner') {
if ($role != 'admin' AND $role != 'owner') {
header("location:profile.php");
}

View File

@@ -33,7 +33,7 @@ foreach($friends as $i => $friend) {
}
?>'>
<div class='friend'>
<img alt='PF' class='profile-picture' src='<?= $friend->profilepicture ?>'/>
<img alt='PF' class='profile-picture <?= $friend->onlinestatus ?>' src='<?= $friend->profilepicture ?>'/>
<div class='friend-name'>
<?= $friend->fullname ?><br/>
<span style='color: #666'><?php

View File

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

View File

@@ -0,0 +1,68 @@
<?php
try{
$fbUsername = str_replace(' ', '', test_input(($_POST["fbUsername"])));
checkInputChoice($fbUsername, "fbUsername");
} catch(usernameException $e){
$fbCorrect = false;
$fbUsernameErr = $e->getMessage();
}
try{
$fbPassword = str_replace(' ', '', test_input(($_POST["fbPassword"])));
checkInputChoice($fbPassword, "longerEight");
matchfbPassword();
} catch(passwordException $e){
$fbCorrect = false;
$fbPasswordErr = $e->getMessage();
} catch(fbConfirmPasswordException $e){
$fbCorrect = false;
$fbConfirmpasswordErr = $e->getMessage();
}
try{
$fbName = test_input(($_POST["fbName"]));
checkInputChoice($fbName, "lettersAndSpaces");
} catch(lettersAndSpacesException $e){
$fbCorrect = false;
}
try {
$fbSurname = test_input(($_POST["fbSurname"]));
checkInputChoice($fbSurname, "lettersAndSpaces");
}
catch(lettersAndSpacesException $e){
$fbCorrect = false;
}
try {
$fbDay_date = test_input(($_POST["fbDay_date"]));
$fbMonth_date = test_input(($_POST["fbMonth_date"]));
$fbYear_date = test_input(($_POST["fbYear_date"]));
$fbBday = $fbYear_date . "-" . $fbMonth_date . "-" . $fbDay_date;
checkInputChoice($fbBday, "bday");
} catch (bdayException $e) {
$fbBdayErr = $e->getMessage();
$fbCorrect = false;
}
try{
$fbEmail = test_input(($_POST["fbEmail"]));
checkInputChoice($fbEmail, "fbEmail");
} catch(emailException $e){
$fbCorrect = false;
$fbEmailErr = $e->getMessage();
}
$fbUserID = test_input(($_POST["fbUserID"]));
try {
fbRegisterCheck($fbCorrect);
} catch(registerException $e){
echo "<script>
window.onload = function() {
$('#fbModal').show();
}
</script>";
$fbRegisterErr = $e->getMessage();
}

View File

@@ -11,7 +11,7 @@
<body>
<?php
include("../queries/group_page.php");
include_once("../queries/group_page.php");
$group = selectGroupByName($_GET["groupname"]);
$members = selectGroupMembers(2);
@@ -40,12 +40,15 @@ if ($group["role"] == "mod" OR $group["role"] == "admin") {
?>
<script src="js/masonry.js"></script>
<script src="js/groupButtons.js"></script>
<script src="js/post.js"></script>
<script>
$(document).ready(function() {
userID = 0;
groupID = <?= $group["groupID"] ?>;
placeGroupButtons();
masonry(<?= $masonry_mode ?>);
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1,42 +1,46 @@
$(window).on("load", function () {
changeFilter();
searchFromOne();
$(".admin-searchinput").keyup(function(){
adminSearch();
searchFromOne();
});
// all inputs and labels directly under admin filter and groupfilter
$("#admin-filter, #admin-groupfilter > input, label").click(function(){
adminSearch();
$("#admin-filter, #admin-groupfilter > input, label").change(function(){
searchFromOne();
});
$("#pagetype").change(function(){
adminSearch();
searchFromOne();
});
adminSearch();
/* Update hidden input to be equal to submit pressed,
because serialize doesn't take submit values. */
$('#admin-batchform > button').click(function () {
$('#batchinput').prop('value', $(this).prop('value'));
});
$('#admin-groupbatchform > button').click(function () {
$('#groupbatchinput').prop('value', $(this).prop('value'));
});
});
function checkAll(allbox) {
var checkboxes = document.getElementsByClassName('checkbox-list');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = allbox.checked;
}
}
function checkAll() {
$('.checkbox-list').each(function () {
$(this).prop('checked', $('#checkall').prop('checked'));
});
}
function checkCheckAll(allbox) {
var checkboxes = document.getElementsByClassName('checkbox-list');
function checkCheckAll() {
var checked = true;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
if (checkboxes[i].checked == false) {
checked = false;
break;
}
$('.checkbox-list').each(function () {
if ($(this).prop('checked') == false) {
checked = false;
return;
}
}
allbox.checked = checked;
});
$('#checkall').prop('checked', checked);
}
function changeFilter() {
@@ -55,12 +59,27 @@ function changeFilter() {
}
}
function searchFromOne() {
$('#currentpage').prop('value', 1);
adminSearch();
}
function adminSearch() {
$.post(
"API/adminSearchUsers.php",
$("#admin-searchform").serialize()
).done(function (data) {
$("#usertable").html(data);
updatePageN();
})
}
function adminUpdate(form) {
$.post(
"API/adminChangeUser.php",
$(form).serialize()
).done(function () {
adminSearch();
})
}
@@ -71,4 +90,18 @@ function updatePageN() {
).done(function (data) {
$("#admin-pageinfo").html(data);
})
}
function toggleBancomment(button) {
$(button).siblings("div").toggle();
$(button).toggle();
}
function editComment(form) {
$.post(
"API/adminChangeUser.php",
$(form).serialize()
).done(function (data) {
adminSearch();
});
}

View File

@@ -33,7 +33,11 @@ function sendMessage() {
$.post(
"API/sendMessage.php",
$("#sendMessageForm").serialize()
);
).done(function(response) {
if (response == "frozen") {
alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is.");
}
});
$("#newContent").val("");
loadMessages();
@@ -43,7 +47,7 @@ function addMessages(messages) {
var messagesText = "";
for(var i in messages) {
// Initialize message variables
var thisDate = new Date(messages[i].creationdate);
var thisDate = new Date(messages[i].creationdate.replace(/ /,"T"));
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
var type;
thisDate.setHours(0,0,0,0);
@@ -54,17 +58,15 @@ function addMessages(messages) {
type = "chat-message-other";
}
if (i == 0) {
if (thisDate > previousDate) {
previousDate = thisDate;
messagesText += '\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>';
}
previousDate = thisDate;
messagesText += '\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>';
messagesText += '<div class="chat-message"><div class="' + type + '">';
} else if (type != previousType || thisTime != previousTime || thisDate > previousDate) {
} else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) {
messagesText += '<div class="chat-time">\
' + thisTime + '\
</div></div></div>';

View File

@@ -0,0 +1,34 @@
function placeGroupButtons() {
$.post("API/getGrouprole.php", { grp: groupID })
.done(function(data) {
var $buttonContainer = $("div.group-button-container");
if(data == 'none') {
$buttonContainer.append(
"<button class='green group-button' value='request'>" +
"<i class='fa fa-plus'></i> Voeg toe" +
"</button>");
} else if(data == 'request') {
$buttonContainer.append(
"<button class='red group-button' value='none'>" +
"<i class='fa fa-times'></i> Trek verzoek in" +
"</button>");
} else {
$buttonContainer.append(
"<button class='red group-button' value='none'>" +
"<i class='fa fa-times'></i> Verlaat groep" +
"</button>");
}
$buttonContainer.children().click(function() {
$.post("API/editMembership.php", { grp: groupID, role: this.value })
.done(function() {
$buttonContainer.children().remove();
placeGroupButtons();
updateMenus();
}).fail(function() {
});
});
});
}

View File

@@ -1,40 +1,55 @@
$(document).ready(function() {
// Toggle menu
$("#own-profile-picture, #open-notifications").click(function() {
if ($("#notification-center").css('display') == "none") {
// Make the menu visible and move the content to the left.
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
$("#notification-center").css("display", "block");
$("#contact-menu").css("display", "block");
if ($("#notification-center").css('display') == "none") {
// Make the menu visible and move the content to the left.
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
$("#notification-center").css("display", "block");
$("#contact-menu").css("display", "block");
// Add cookie so the menu stays open on other pages
if (window.innerWidth > 1080) {
$("#chat-history").width("calc(100% - 587px)");
document.cookie = "menu=open; path=/";
} else {
document.cookie = "menu=closed; path=/";
}
// Add cookie so the menu stays open on other pages
if (window.innerWidth > 1080) {
$("#chat-history").css("margin-right", "266px");
$("#chat-history").css("width", "calc(100% - 512px - 75px)");
document.cookie = "menu=open; path=/";
} else {
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("display", "none");
if (window.innerWidth > 1080) {
$("#chat-history").width("calc(100% - 331px)");
} else {
// Make the menu invisible and move the content to the right.
$("#contact-menu").css("display", "none");
}
// Change menu cookie to close
document.cookie = "menu=closed; path=/";
}
} else {
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("display", "none");
if (window.innerWidth > 1080) {
$("#chat-history").css("margin-right", "10px");
$("#chat-history").css("width", "calc(100% - 256px - 85px)");
} else {
// Make the menu invisible and move the content to the right.
$("#contact-menu").css("display", "none");
}
// Change menu cookie to close
document.cookie = "menu=closed; path=/";
}
});
if (getCookie("menu") == "open") {
$("#own-profile-picture").click();
// Make the menu visible and move the content to the left.
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
$("#notification-center").css("display", "block");
$("#contact-menu").css("display", "block");
// Add cookie so the menu stays open on other pages
if (window.innerWidth > 1080) {
$("#chat-history").css("margin-right", "266px");
$("#chat-history").width("calc(100% - 587px)");
document.cookie = "menu=open; path=/";
} else {
document.cookie = "menu=closed; path=/";
}
}
});

View File

@@ -3,7 +3,7 @@ var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "a
function fancyText(text) {
// Add links, images, gifs and (youtube) video's.
var regex = /(https?:\/\/.[^ ]*)/ig;
var regex = /(https?:\/\/.[^ <>"]*)/ig;
text = text.replace(regex, function(link) {
// Add images
if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
@@ -53,6 +53,7 @@ function editFriendship(userID, value) {
$.post("API/editFriendship.php", { usr: userID, action: value })
.done(function() {
placeFriendButtons();
updateMenus();
});
}

View File

@@ -19,7 +19,7 @@ function requestPost(postID) {
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
scrollbarMargin(scrollBarWidth, 'hidden');
$('#modal-response').show();
$('#modal-response').html(data);
$('#modal-response').html(fancyText(data));
});
}
@@ -45,24 +45,49 @@ function postPost() {
}
$(window).on("load", function() {
$(".modal-close").click(function () {
$(".modal").hide();
scrollbarMargin(0, 'auto');
$('#modal-response').hide();
$('.modal-default').show();
});
var masonryMode = 0;
var windowWidth;
var columnCount;
var columns;
var postLimit;
var postAmount = 0;
var noposts = false;
$(document).ready(function () {
windowWidth = $(window).width();
columnCount = Math.floor($(".posts").width() / 250);
columns = new Array(columnCount);
postLimit = columnCount * 7;
});
var masonryMode = 0;
var windowWidth = $(window).width();
$(window).on("load", function() {
$(".modal-close").click(function (){closeModal()});
// http://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom
window.onscroll = function(ev) {
if($(window).scrollTop() + $(window).height() == $(document).height() ) {
loadMorePosts(userID, groupID, postAmount, postLimit);
}
};
});
function closeModal() {
$(".modal").hide();
scrollbarMargin(0, 'auto');
$('#modal-response').hide();
$('.modal-default').show();
}
$(window).resize(function() {
clearTimeout(window.resizedFinished);
window.resizeFinished = setTimeout(function() {
if ($(window).width() != windowWidth) {
windowWidth = $(window).width();
masonry(masonryMode);
if (columnCount != Math.floor($(".posts").width() / 250)) {
columnCount = Math.floor($(".posts").width() / 250);
masonry(masonryMode);
}
}
}, 250);
});
@@ -72,13 +97,11 @@ var $container = $(".posts");
function masonry(mode) {
masonryMode = mode;
$container.children().remove();
columnCount = Math.floor($(".posts").width() / 250);
/*
* Initialise columns.
*/
var columns = new Array(columnCount);
var $columns = new Array(columnCount);
for (i = 0; i < columnCount; i++) {
$column = $("<div class=\"column\">");
$column.width(100/columnCount + "%");
@@ -96,7 +119,7 @@ function masonry(mode) {
}
$form.append($("<input class=\"newpost\" name=\"title\" placeholder=\"Titel\" type=\"text\">"));
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\">"));
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\" maxlength='1000'></textarea><span></span>"));
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
columns[0][1].append($postInput);
@@ -106,38 +129,61 @@ function masonry(mode) {
/*
* Function will find the column with the shortest height.
*/
function getShortestColumn(columns) {
column = columns[0];
for (i = 1; i < columnCount; i++) {
if (column[0] > columns[i][0]) {
column = columns[i];
}
}
return column;
}
/*
* Get the posts from the server.
*/
$.post("API/getPosts.php", { usr : userID, grp : groupID })
.done(function(data) {
posts = JSON.parse(data);
/*
* Rearange the objects.
*/
$.each(posts, function() {
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
$post.append($("<h2>").html(this["title"]));
$post.append($("<p>").html(this["content"]));
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
$post.append($("<p class=\"subscript\">").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
});
});
loadMorePosts(userID, groupID, 0, postLimit);
}
function getShortestColumn(columns) {
column = columns[0];
for (i = 1; i < columnCount; i++) {
if (column[0] > columns[i][0]) {
column = columns[i];
}
}
return column;
}
function loadMorePosts(uID, gID, offset, limit) {
if (noposts) {
return;
}
console.log(uID, gID, offset, limit);
$.post("API/getPosts.php", { usr : uID,
grp : gID,
offset : offset,
limit : limit})
.done(function(data) {
if (!data) {
$('.noposts').show();
noposts = true;
return;
}
posts = JSON.parse(data);
/*
* Rearange the objects.
*/
$.each(posts, function() {
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
$post.append($("<h2>").html(this["title"]));
$post.append($("<p>").html(fancyText(this["content"])));
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
$post.append($("<p class=\"subscript\">").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
});
});
postAmount += limit;
}

View File

@@ -2,92 +2,125 @@ var menuFriendsData;
var menuGroupsData;
var notificationMessagesData;
var notificationRequestsData;
var updatingMenus = 0;
// On document load, load menus and loops loading menus every 10 seconds.
$(document).ready(function() {
loadMenuFriends(5);
loadNotificationFriends();
loadUnreadMessages();
loadMenuGroups();
setInterval(updateMenus, 3000);
updateMenus();
setInterval(updateMenus, 10000);
});
// Update the menu and notification items.
function updateMenus() {
loadMenuFriends(5);
loadNotificationFriends();
loadUnreadMessages();
loadMenuGroups();
if (updatingMenus <= 0) {
loadMenuFriends(5);
loadNotificationFriends();
loadUnreadMessages();
loadMenuGroups();
}
}
// Get, every 3 seconds, the friends and insert them in the menu.
// Get the friends and insert them in the menu.
function loadMenuFriends(limit) {
updatingMenus ++;
$.post(
"API/loadFriends.php",
{
limit: 5
}
).done(function(data) {
if (data == "" || data == "[]") {
$("#friends-menu-section").hide();
} else {
$("#friends-menu-section").show();
}
if (menuFriendsData != data) {
menuFriendsData = data;
if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
$("#friends-menu-section").show();
} else {
if (!showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
$("#friends-menu-section").hide();
}
}
}).fail(function() {
$("#friends-menu-section").hide();
}).always(function() {
updatingMenus --;
});
}
// Get, every 3 seconds, the groups and insert them in the menu.
// Get the groups and insert them in the menu.
function loadMenuGroups() {
updatingMenus ++;
$.post(
"API/loadGroups.php",
{
limit: 5
}
).done(function(data) {
if (data == "" || data == "[]") {
$("#groups-menu-section").hide();
} else {
$("#groups-menu-section").show();
}
if (menuGroupsData != data) {
menuGroupsData = data;
if (showGroups(data, "#menu-groups-list")) {
$("#groups-menu-section").show();
} else {
if (!showGroups(data, "#menu-groups-list")) {
$("#groups-menu-section").hide();
}
}
}).fail(function() {
$("#groups-menu-section").hide();
}).always(function() {
updatingMenus --;
});
}
// Get, every 3 seconds, the friends requests and insert them in the notification center.
// Get the friends requests and insert them in the notification center.
function loadNotificationFriends() {
updatingMenus ++;
$.post(
"API/loadFriendRequest.php"
).done(function(data) {
if (data == "" || data == "[]") {
$("#friend-request-section").hide();
} else {
$("#friend-request-section").show();
}
if (notificationRequestsData != data) {
notificationRequestsData = data;
if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
$("#friend-request-section").show();
} else {
if (!showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
$("#friend-request-section").hide();
}
}
}).fail(function() {
$("#friend-request-section").hide();
}).always(function() {
updatingMenus --;
});
}
// Get, every 3 seconds, the unread messages and insert them in the notification center.
// Get the unread messages and insert them in the notification center.
function loadUnreadMessages() {
updatingMenus ++;
$.post(
"API/loadChatNotifications.php"
).done(function(data) {
if (data == "" || data == "[]") {
$("#unread-messages-section").hide();
} else {
$("#unread-messages-section").show();
}
if (notificationMessagesData != data) {
notificationMessagesData = data;
if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
$("#unread-messages-section").show();
} else {
if (!showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
$("#unread-messages-section").hide();
}
}
}).fail(function() {
$("#unread-messages-section").hide();
}).always(function() {
updatingMenus --;
});
}

View File

@@ -1,11 +1,14 @@
function postComment(buttonValue) {
formData = $("#newcommentform").serializeArray();
formData.push({name: "button", value: buttonValue});
$.post(
"API/postComment.php",
formData
).done(function(data) {
console.log(data);
).done(function (response) {
if (response == "frozen") {
alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is.");
}
});
$("#newcomment").val("");
@@ -15,6 +18,22 @@ function postComment(buttonValue) {
"API/loadPost.php",
$("#newcommentform").serialize()
).done(function (data) {
$('#modal-response').html(data);
$('#modal-response').html(fancyText(data));
});
}
function deletePost(postID) {
var formData = [{name: "postID", value: postID}];
$.post(
"API/deletePost.php",
formData
).done(function (response) {
if (response == "frozen") {
alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is.");
}
});
closeModal();
masonry(masonryMode);
}

View File

@@ -1,15 +1,23 @@
function checkLoggedIn() {
if (confirm("U bent al ingelogd!!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
if (confirm("U bent al ingelogd!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
window.location.href = "logout.php";
} else {
window.location.href = "profile.php";
}
}
function emailAlert(){
alert("Bevestigingsemail is gestuurd!\n");
}
function bannedAlert(){
alert("Uw account is geband!");
}
function frozenAlert(){
alert("Uw account is bevroren!\n");
}
function emailNotConfirmed(){
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
}

View File

@@ -8,56 +8,21 @@
include_once("../queries/emailconfirm.php");
include_once("../queries/requestpassword.php");
include_once("../queries/register.php");
require_once("../queries/Facebook/autoload.php");
?>
<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");
// 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";
// Define variables and set to empty values
$user = $psw = $remember ="";
$loginErr = $resetErr ="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
switch ($_POST["submit"]) {
case "login":
try {
$user = ($_POST["user"]);
validateLogin($_POST["user"], $_POST["psw"]);
} catch(loginException $e) {
$loginErr = $e->getMessage();
}
break;
case "reset":
try {
resetEmail($_POST["forgotEmail"]);
sendPasswordRecovery($_POST["forgotEmail"]);
} catch (emailException $e){
$resetErr = $e->getMessage();
echo "<script>
window.onload = function() {
$('#myModal').show();
}
</script>";
}
break;
case "register":
include("register.php");
}
}
/* This view adds login view */
include("../views/login-view.php");
?>

View File

@@ -13,10 +13,11 @@
</head>
<body>
<?php
include("../queries/user.php");
include("../queries/friendship.php");
include("../queries/nicetime.php");
include("../queries/post.php");
include_once("../queries/user.php");
include_once("../queries/friendship.php");
include_once("../queries/nicetime.php");
include_once("../queries/post.php");
include_once("../queries/calcAge.php");
if(empty($_GET["username"])) {
$userID = $_SESSION["userID"];

View File

@@ -50,7 +50,7 @@
try{
$location = test_input(($_POST["location"]));
checkInputChoice($location, "lettersAndSpaces");
checkInputChoice($location, "");
} catch(lettersAndSpacesException $e){
$correct = false;
$locationErr = $e->getMessage();
@@ -80,12 +80,12 @@
try {
getIp();
registerCheck($correct);
sendConfirmEmailUsername($username);
sendConfirmEmail(getUserID()["userID"]);
} catch(registerException $e){
echo "<script>
window.onload = function() {
$('#registerModal').show();
}
</script>";
window.onload = function() {
$('#registerModal').show();
}
</script>";
$genericErr = $e->getMessage();
}

View File

@@ -4,7 +4,7 @@
.admin-panel input[type="radio"], input[type="checkbox"] {
vertical-align: middle;
height: auto;
height: 28px;
margin: 2px;
}
@@ -34,7 +34,6 @@
width: 100%;
}
.usertable .table-checkbox {width: 20px}
.usertable .table-username {width: 150px}
.usertable .table-status {width: 100px}
.usertable .table-action {width: 200px}
@@ -44,10 +43,18 @@
padding: 3px;
}
.usertable tr {
.usertable th, tr {
text-align: left;
}
.usertable tr:hover {
background-color: #f5f5f5;
}
.bancommentedit {
display: none;
}
.bancommentform input[type="text"] {
width: 80%;
}

View File

@@ -22,6 +22,7 @@ body {
height: calc(100% - 100px);
display: inline-block;
float: left;
overflow-y: auto;
}
@@ -31,12 +32,14 @@ body {
overflow-y: auto;
overflow-x: hidden;
width: calc(100% - 256px - 75px);
width: calc(100% - 256px - 85px);
height: calc(100% - 80px);
margin-right: 10px;
padding: 10px;
display: inline-block;
float: right;
word-wrap: break-word;
}

View File

@@ -49,7 +49,7 @@ header div {
}
#open-notifications {
padding: 5px 20px 5px 0px;
padding: 20px 20px 20px 0px;
}
@media only screen and (max-width: 1080px) {

View File

@@ -10,6 +10,19 @@ a.button {
}
a.fbButton {
background-color: #3B5998;
border-radius: 5px;
color: black;
cursor: pointer;
padding: 8px 20px;
font-family: Arial;
font-size: 22px;
color: white;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
/* Body */
body {
height: 100%;
@@ -28,7 +41,7 @@ body {
form {
/*background-color: #a87a87;*/
border-radius: 12px;
height: 85%;
height: 80%;
margin: auto;
width: 600px;
overflow-y: auto;
@@ -154,7 +167,7 @@ ul {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 30px; /* Location of the box */
padding-top: 75px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
@@ -216,6 +229,7 @@ ul {
}
.modal-footer {
padding: 2px 8px;
background-color: #FBC02D;
color: black;
}

View File

@@ -92,8 +92,17 @@ p {
border-radius: 50%;
}
.online {
border: #4CAF50 solid 3px;
}
.offline {
border: #666666 solid 3px;
}
.group-picture {
border-radius: 5px;
border: none;
}
.item-box, .item-box-full-width {
@@ -299,8 +308,16 @@ div[data-title]:hover:after {
body {
font-size: 28px!important;
}
button {
button, input, select {
font-size: 28px;
height: 42px;
}
textarea {
font-size: 28px;
}
input[type="checkbox"], input[type="radio"] {
width: 28px;
height: 28px;
}
}

View File

@@ -14,7 +14,7 @@
/* Modal Content/Box */
.modal-content {
margin: 5% auto;
margin: 50px auto;
width: 70%; /* Could be more or less, depending on screen size */
overflow-y: auto;
}
@@ -83,4 +83,21 @@
vertical-align: middle;
height: 24px;
width: 24px;
}
.deleteButton {
background-color: firebrick;
}
.deleteButton i {
display: inline-block;
}
.deleteButton:hover span {
display: inline-block;
}
.deleteButton span {
display: none;
}

View File

@@ -18,7 +18,7 @@
display: inline-block;
}
.friend-button-container button, .status-buttons-container button {
.friend-button-container button, .status-buttons-container button, .group-button-container button {
display: block;
margin: 7px 0;
@@ -27,6 +27,10 @@
font-size: 18px;
}
.group-button-container button {
float: right;
}
.empty-button {
background: none;
cursor: auto;
@@ -45,14 +49,24 @@
.main-picture {
position: relative;
border: #4CAF50 solid 5px;
border-width: 5px;
display: inline-block;
width: 150px;
height: 150px;
margin-bottom: -45px;
object-fit: cover;
vertical-align: middle;
}
.group-picture {
border: none;
margin-bottom: 0;
margin-right: 15px;
}
/* Old */
.profile-box h1.profile-username {
@@ -109,6 +123,11 @@ div.posts .post form textarea.newpost {
font-size: 0.8em;
}
.noposts {
display: none;
text-align: center;
}
@media only screen and (max-width: 1500px) {
.post-box {
width: calc(50% - 68px);
@@ -120,4 +139,8 @@ div.posts .post form textarea.newpost {
.post-box {
width: calc(100% - 65px);
}
.modal {
left: 0!important;
width: 100%!important;
}
}