1 Commits

Author SHA1 Message Date
Hendrik
f566c6eec4 comments 2017-02-03 12:43:24 +01:00
15 changed files with 32 additions and 225 deletions

View File

@@ -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();

View File

@@ -51,7 +51,6 @@ function sendMessage() {
});
$("#newContent").val("");
$("#newContent").focus();
}
// Add messages to the chat.

View File

@@ -1,4 +1,9 @@
/**
* Posts a comment or "Niet slecht." on a post.
* Button specifies between comment and "Niet slecht.".
* Alerts or redirects if frozen or not logged in.
*/
function postComment(buttonValue) {
formData = $("#newcommentform").serializeArray();
formData.push({name: "button", value: buttonValue});
@@ -24,6 +29,10 @@ function postComment(buttonValue) {
});
}
/**
* Deletes a post given by postID, closes modal and reloads posts.
* @param postID
*/
function deletePost(postID) {
var formData = [{name: "postID", value: postID}];
$.post(

View File

View File

@@ -1,3 +1,4 @@
// Checks if user is logged in and offers to logout.
function checkLoggedIn() {
if (confirm("U bent al ingelogd!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
window.location.href = "logout.php";
@@ -6,18 +7,22 @@ function checkLoggedIn() {
}
}
// Alert for validation mail.
function emailAlert(){
alert("Bevestigingsemail is gestuurd!\n");
}
// Alert for banned account.
function bannedAlert(){
alert("Uw account is geband!");
}
// Alert for frozen account.
function frozenAlert(){
alert("Uw account is bevroren!\n");
}
// Alert for unconfirmed email.
function emailNotConfirmed(){
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
}

View 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();

View File

@@ -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 {
@@ -44,7 +42,6 @@
.usertable th, td {
border-bottom: 1px solid #ddd;
padding: 3px;
word-wrap: break-word;
}
.usertable th, tr {

View File

@@ -52,7 +52,7 @@ function updateGroupSettings(int $groupID)
}
/**
* Checks if a user is an admin for a page.
* Checks if an user is an admin for a page.
* @param int $groupID
* @param int $userID
* @return bool

View File

@@ -38,7 +38,8 @@ function getUserID() {
}
function validateLogin($username, $password, $url){
// Empty username or password field
echo $url;
// Empty username or password field
if (empty($username) || empty($password)) {
throw new loginException("Inloggegevens zijn niet ingevuld");
}

View File

@@ -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];
}

View File

@@ -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
@@ -354,10 +282,10 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
}
/**
* Returns role of a user.
* Returns role of an user.
* @param int $userID
* @param int $groupID
* @return mixed role of a user.
* @return mixed role of an user.
*/
function getRoleInGroup(int $userID, int $groupID) {
$stmt = prepareQuery("

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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();