From afb45d6709c6ddf640bac34844ac4e3ac8f38055 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 15:51:27 +0100 Subject: [PATCH 01/31] add closing of modal on escape key and clicking outside --- website/public/js/masonry.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index a628e96..107f710 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -83,6 +83,21 @@ $(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() { From 380d8fa83a7ea8780f09fd8c1a8df7965b8f45b1 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 16:01:45 +0100 Subject: [PATCH 02/31] Group Shit --- website/public/createGroup.php | 36 +++++++++++++++ website/public/groupAdmin.php | 46 ++++++++++++++++++++ website/queries/createGroup.php | 37 ++++++++++++++++ website/queries/groupAdmin.php | 61 ++++++++++++++++++++++++++ website/queries/picture.php | 12 ++--- website/views/createGroup.php | 42 ++++++++++++++++++ website/views/groupAdmin.php | 77 +++++++++++++++++++++++++++++++++ website/views/menu.php | 2 +- 8 files changed, 306 insertions(+), 7 deletions(-) create mode 100644 website/public/createGroup.php create mode 100644 website/public/groupAdmin.php create mode 100644 website/queries/createGroup.php create mode 100644 website/queries/groupAdmin.php create mode 100644 website/views/createGroup.php create mode 100644 website/views/groupAdmin.php diff --git a/website/public/createGroup.php b/website/public/createGroup.php new file mode 100644 index 0000000..ffeb6e3 --- /dev/null +++ b/website/public/createGroup.php @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php new file mode 100644 index 0000000..13ff7e0 --- /dev/null +++ b/website/public/groupAdmin.php @@ -0,0 +1,46 @@ + + + + + + + + +getClass(); + $alertMessage = $w->getMessage(); + } +} + +/* Add your view files here. */ +include("../views/groupAdmin.php"); + +/* This adds the footer. */ +include("../views/footer.php"); +?> + + diff --git a/website/queries/createGroup.php b/website/queries/createGroup.php new file mode 100644 index 0000000..20ee28b --- /dev/null +++ b/website/queries/createGroup.php @@ -0,0 +1,37 @@ +bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $createGroup->bindValue(':description', test_input($_POST["bio"])); + $createGroup->execute(); + + $getGroupID = prepareQuery(" + SELECT + `groupID` + FROM + `group_page` + WHERE + `name` LIKE :name"); + $getGroupID->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $getGroupID->execute(); + $groupID = $getGroupID->fetch()["groupID"]; + + $makeUserAdmin = prepareQuery(" + INSERT INTO + `group_member` (userID, groupID, role) + VALUES (:userID, :groupID, 'admin') + "); + $makeUserAdmin->bindValue(":userID", $_SESSION["userID"]); + $makeUserAdmin->bindValue("groupID", $groupID); + $makeUserAdmin->execute(); + + updateAvatar($groupID); +} \ No newline at end of file diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php new file mode 100644 index 0000000..ae2abd3 --- /dev/null +++ b/website/queries/groupAdmin.php @@ -0,0 +1,61 @@ +bindParam(":groupID", $groupID); + $stmt->execute(); + return $stmt->fetch(); +} + +function updateGroupSettings(int $groupID) +{ + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Je hebt geen rechten in deze groep"); + } + $stmt = prepareQuery(" + UPDATE + `group_page` + SET + `name` = :name, + `description` = :bio + WHERE + `groupID` = :groupID + "); + $stmt->bindValue(":bio", test_input($_POST["bio"])); + $stmt->bindValue(":name", test_input($_POST["name"])); + $stmt->bindValue(":groupID", test_input($_POST["groupID"])); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Groep aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } +} + +function checkGroupAdmin(int $groupID, int $userID) : bool { + $stmt = prepareQuery(" + SELECT + `role` + FROM + `group_member` + WHERE + `groupID` = :groupID AND + `userID` = :userID + "); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":groupID", $groupID); + $stmt->execute(); + if (!$stmt->rowCount()) { + return false; + } + $role = $stmt->fetch()["role"]; + return ($role == "admin"); +} \ No newline at end of file diff --git a/website/queries/picture.php b/website/queries/picture.php index 8e99d9a..ba27f72 100644 --- a/website/queries/picture.php +++ b/website/queries/picture.php @@ -6,7 +6,7 @@ * @throws AngryAlert * @throws HappyAlert */ -function updateAvatar(bool $group = false) { +function updateAvatar(int $group = 0) { $publicDir = "/var/www/html/public/"; $tmpImg = $_FILES["pp"]["tmp_name"]; $avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/"; @@ -16,17 +16,17 @@ function updateAvatar(bool $group = false) { if ($_FILES["pp"]["size"] > 4000000) { throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); } - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif"; - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif"; + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); move_uploaded_file($tmpImg, $publicDir . $relativePath); } else { - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png"; + $relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png"; $scaledImg = scaleAvatar($tmpImg); - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); imagepng($scaledImg, $publicDir . $relativePath); } - $group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath); + $group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath); throw new HappyAlert("Profielfoto veranderd."); } diff --git a/website/views/createGroup.php b/website/views/createGroup.php new file mode 100644 index 0000000..736fc45 --- /dev/null +++ b/website/views/createGroup.php @@ -0,0 +1,42 @@ + + +
+
+
+
Maak een groep!
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+
diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php new file mode 100644 index 0000000..66b38f5 --- /dev/null +++ b/website/views/groupAdmin.php @@ -0,0 +1,77 @@ + +
+
+ +
+ +
+ +
+
Groep Instellingen
+ "> +
    +
  • + + " + > +
  • +
  • + + + +
  • +
  • + + +
  • +
+
+
+
Verander groepsafbeelding.
+ "> +
    +
  • + + " + class="group-picture" + > +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+
\ No newline at end of file diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..03e0f56 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -14,7 +14,7 @@ +
+ +
\ No newline at end of file From 74e91ed7cb18acebaabd5b6356f87aec25830977 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 21:14:25 +0100 Subject: [PATCH 08/31] Add mods/admin to a group. --- website/public/groupAdmin.php | 27 ++++++++++++++----- website/queries/groupAdmin.php | 48 ++++++++++++++++++++++++++++++++++ website/queries/settings.php | 15 +++++++++++ website/views/groupAdmin.php | 29 ++++++++++++++++++++ 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php index 13ff7e0..6095149 100644 --- a/website/public/groupAdmin.php +++ b/website/public/groupAdmin.php @@ -23,12 +23,27 @@ $alertClass; $alertMessage; if ($_SERVER["REQUEST_METHOD"] == "POST") { try { - if ($_POST["form"] == "group") { - updateGroupSettings($_POST["groupID"]); - } else if ($_POST["form"] == "picture") { - if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { - updateAvatar($_POST["groupID"]); - } + switch ($_POST["form"]) { + case "group": + updateGroupSettings($_POST["groupID"]); + break; + case "picture": + if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { + updateAvatar($_POST["groupID"]); + } + break; + case "mod": + if (!array_key_exists("userID", $_POST)) { + throw new AngryAlert("Geen gebruiker geselecteerd."); + } + upgradeUser($_POST["groupID"], $_POST["userID"], "mod"); + break; + case "admin": + if (!array_key_exists("userID", $_POST)) { + throw new AngryAlert("Geen gebruiker geselecteerd."); + } + upgradeUser($_POST["groupID"], $_POST["userID"], "admin"); + break; } } catch (AlertMessage $w) { $alertClass = $w->getClass(); diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php index ae2abd3..e3580b6 100644 --- a/website/queries/groupAdmin.php +++ b/website/queries/groupAdmin.php @@ -58,4 +58,52 @@ function checkGroupAdmin(int $groupID, int $userID) : bool { } $role = $stmt->fetch()["role"]; return ($role == "admin"); +} + +function getAllGroupMembers(int $groupID) { + $stmt = prepareQuery(" + SELECT + `username`, + `user`.`userID`, + CONCAT(`fname`, ' ', `lname`) AS `fullname`, + `group_member`.`role` + FROM + `group_member` + LEFT JOIN + `user` + ON + `group_member`.`userID` = `user`.`userID` + WHERE + `groupID` = :groupID AND `group_member`.`role` = 'member' + "); + + $stmt->bindParam(':groupID', $groupID); + if (!$stmt->execute()) { + return False; + } + return $stmt->fetchAll(); +} + +function upgradeUser(int $groupID, int $userID, string $role) { + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Geen toestemming om te wijzigen"); + } + + $stmt = prepareQuery(" + UPDATE + `group_member` + SET + `role` = :role + WHERE + `userID` = :userID AND `groupID` = :groupID + "); + $stmt->bindValue(":groupID", $groupID); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":role", $role); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Permissie aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } } \ No newline at end of file diff --git a/website/queries/settings.php b/website/queries/settings.php index 9b17d17..26237ec 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -148,6 +148,10 @@ function doChangePassword() { } } +/** + * Changes the users email if it is valid. + * @throws AngryAlert + */ function changeEmail() { if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) { @@ -164,6 +168,11 @@ function changeEmail() { } } +/** + * Checks if an emailadres is available in the database. + * @param $email + * @throws AngryAlert + */ function emailIsAvailableInDatabase($email) { $stmt = prepareQuery(" SELECT @@ -181,6 +190,12 @@ function emailIsAvailableInDatabase($email) { } } +/** + * Does the actual changing of an email-adress. + * @param $email + * @throws AngryAlert + * @throws HappyAlert + */ function doChangeEmail($email) { $stmt = prepareQuery(" UPDATE diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php index a28553e..54fbee8 100644 --- a/website/views/groupAdmin.php +++ b/website/views/groupAdmin.php @@ -85,6 +85,35 @@ $groupinfo = getGroupSettings($_GET["groupID"]); +
+
Voeg een admin/mod toe
+
    + + " type="hidden"> + + + + + +
+
  • From 7e4107ac8b357bc1335c9657293182a5ce18720c Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:13:23 +0100 Subject: [PATCH 09/31] Added fancy buttons in profile --- website/public/js/friendButtons.js | 28 +++++++++++++++------------- website/public/js/groupButtons.js | 12 ++++++------ website/public/styles/post-popup.css | 12 ------------ website/public/styles/profile.css | 19 ++++++++++++------- website/views/post-view.php | 4 ++-- website/views/profile.php | 14 ++++++++++---- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 47c476a..303ccf9 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -19,24 +19,24 @@ function placeFriendButtons() { case "0": value1 = "request"; class1 = "green"; - text1 = "Bevriend"; - icon1 = "fa-handshake-o"; + text1 = "Word vrienden"; + icon1 = "fa-user-plus"; break; case "1": value1 = userID; class1 = "green"; text1 = "Chat"; - icon1 = "fa-comment-o"; + icon1 = "fa-comment"; value2 = "delete"; class2 = "red"; - text2 = "Verwijder"; - icon2 = "fa-times"; + text2 = "Ontvriend"; + icon2 = "fa-user-times"; break; case "2": value1 = "delete"; class1 = "red"; text1 = "Trek verzoek in"; - icon1 = "fa-cross"; + icon1 = "fa-times"; break; case "3": value1 = "accept"; @@ -51,16 +51,18 @@ function placeFriendButtons() { } $buttonContainer.append( - ""); + "
    "); $buttonContainer.append( - ""); + "
    "); - $buttonContainer.children().click(function() { + $buttonContainer.find("button").click(function() { if (isNaN(this.value)) editFriendship(userID, this.value); else if (this.value != "") diff --git a/website/public/js/groupButtons.js b/website/public/js/groupButtons.js index 549277d..caf3ab8 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -5,23 +5,23 @@ function placeGroupButtons() { if (data == 'none') { $buttonContainer.append( - ""); } else if (data == 'request') { $buttonContainer.append( - ""); } else if (data == 'admin') { $buttonContainer.append( - "" ); } else { $buttonContainer.append( - ""); } diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 9493b83..e82129b 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -92,16 +92,4 @@ .deleteButton { background-color: firebrick; float: right; -} - -.deleteButton i { - display: inline-block; -} - -.deleteButton:hover span { - display: inline-block; -} - -.deleteButton span { - display: none; } \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 18e105e..8a93d12 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -27,16 +27,21 @@ display: inline-block; } +.friend-button-container div, .status-buttons-container div { + width: 200px; + display: inline-block; +} + .friend-button-container button, .status-buttons-container button, .group-button-container button { display: block; + float: right; margin: 7px 0; font-size: 18px; } - -.friend-button-container button, .status-buttons-container button, .group-button-fixed { - width: 200px; +.status-buttons-container button { + float: left; } .group-button-container button { @@ -76,19 +81,19 @@ border: none; } -.group-button-fancy span { +.fancy-button span { display: none; } -.group-button-fancy:hover { +.fancy-button:hover { text-align: right; } -.group-button-fancy i { +.fancy-button i { display: inline-block; } -.group-button-fancy:hover span { +.fancy-button:hover span { display: inline-block; margin-right: 5px; } diff --git a/website/views/post-view.php b/website/views/post-view.php index 717e6a8..fadc791 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -13,11 +13,11 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
-
diff --git a/website/views/profile.php b/website/views/profile.php index 62157f4..0cb5cc2 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -7,10 +7,16 @@ <?= $user[" class="profile-picture main-picture " src="">
- - +
+ +
+
+ +

:)

From 6d739a4480019709d6abe9addea37ade0ebbc34d Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:24:38 +0100 Subject: [PATCH 10/31] Chat is now only loading the last 100 messages --- website/queries/private_message.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 3b88563..f2df887 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -6,18 +6,23 @@ function getOldChatMessages($user2ID) { if (getFriendshipStatus($user2ID) == 1) { $stmt = prepareQuery(" SELECT - * + * FROM - `private_message` - WHERE - `origin` = :user1 AND - `destination` = :user2 OR - `origin` = :user2 AND - `destination` = :user1 + (SELECT + * + FROM + `private_message` + WHERE + `origin` = :user1 AND + `destination` = :user2 OR + `origin` = :user2 AND + `destination` = :user1 + ORDER BY + `messageID` DESC + LIMIT + 100) sub ORDER BY - `creationdate` ASC - LIMIT - 100 + `messageID` ASC "); $stmt->bindParam(":user1", $user1ID); @@ -76,7 +81,7 @@ function getNewChatMessages($lastID, $destination) { `destination` = :user1) AND `messageID` > :lastID ORDER BY - `creationdate` ASC + `messageID` ASC "); $stmt->bindParam(':user1', $_SESSION["userID"]); From 1a3efe9669089acffc404151616d26b1d3f9d984 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 3 Feb 2017 10:12:37 +0100 Subject: [PATCH 11/31] Fixed W3Validation and url GETs --- website/public/fb-callback.php | 71 -------------- website/public/register(stash).php | 116 ----------------------- website/public/styles/index.css | 6 -- website/queries/checkInput.php | 6 +- website/queries/login.php | 7 +- website/views/facebookRegisterModal.php | 8 +- website/{public => views}/fbRegister.php | 0 website/views/forgotPasswordModal.php | 4 +- website/views/homeLoginRegister.php | 38 ++++---- website/views/login-view.php | 13 ++- website/{public => views}/register.php | 0 website/views/registerModal.php | 13 +-- 12 files changed, 43 insertions(+), 239 deletions(-) delete mode 100644 website/public/fb-callback.php delete mode 100644 website/public/register(stash).php rename website/{public => views}/fbRegister.php (100%) rename website/{public => views}/register.php (100%) diff --git a/website/public/fb-callback.php b/website/public/fb-callback.php deleted file mode 100644 index 0ed0369..0000000 --- a/website/public/fb-callback.php +++ /dev/null @@ -1,71 +0,0 @@ - $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 '

Access Token

'; -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 '

Metadata

'; -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 "

Error getting long-lived access token: " . $helper->getMessage() . "

\n\n"; - exit; - } - - echo '

Long-lived

'; - 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'); \ No newline at end of file diff --git a/website/public/register(stash).php b/website/public/register(stash).php deleted file mode 100644 index 99ebc02..0000000 --- a/website/public/register(stash).php +++ /dev/null @@ -1,116 +0,0 @@ - - - - -getMessage(); - } - - try { - $surname = test_input(($_POST["surname"])); - checkInputChoice($surname, "lettersAndSpaces"); - } - catch(lettersAndSpacesException $e){ - $correct = false; - $surnameErr = $e->getMessage(); - } - - try{ - $day_date = test_input(($_POST["day_date"])); - $month_date = test_input(($_POST["month_date"])); - $year_date = test_input(($_POST["year_date"])); - $bday = $year_date . "-" . $month_date . "-" . $day_date; - checkInputChoice($bday, "bday"); - } catch(bdayException $e){ - $correct = false; - $bdayErr = $e->getMessage(); - } - - try{ - $username = str_replace(' ', '', test_input(($_POST["username"]))); - checkInputChoice($username, "username"); - } catch(usernameException $e){ - $correct = false; - $usernameErr = $e->getMessage(); - } - - try{ - $password = str_replace(' ', '', test_input(($_POST["password"]))); - checkInputChoice($password, "longerEight"); - matchPassword(); - } catch(passwordException $e){ - $correct = false; - $passwordErr = $e->getMessage(); - } catch(confirmPasswordException $e){ - $correct = false; - $confirmPasswordErr = $e->getMessage(); - } - - try{ - $location = test_input(($_POST["location"])); - checkInputChoice($location, "lettersAndSpaces"); - } catch(lettersAndSpacesException $e){ - $correct = false; - $locationErr = $e->getMessage(); - } - - try{ - $email = test_input(($_POST["email"])); - checkInputChoice($email, "email"); - $confirmEmail = test_input(($_POST["confirmEmail"])); - matchEmail(); - } catch(emailException $e){ - $correct = false; - $emailErr = $e->getMessage(); - } catch(confirmEmailException $e){ - $correct = false; - $confirmEmailErr = $e->getMessage(); - } - - try{ - $captcha = $_POST['g-recaptcha-response']; - checkCaptcha($captcha); - } catch(captchaException $e){ - $correct = false; - $captchaErr = $e->getMessage(); - } - - try { - getIp(); - registerCheck($correct); - sendConfirmEmailUsername($username); - } catch(registerException $e){ - $genericErr = $e->getMessage(); - } - } -/* This view adds register view */ -include("../views/register-view.php"); -?> - - diff --git a/website/public/styles/index.css b/website/public/styles/index.css index c7a0aa8..68191ad 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -198,12 +198,6 @@ ul { animation-duration: 0.4s } -/* Add Animation */ -@-webkit-keyframes animatetop { - from {top:-300px; opacity:0} - to {top:0; opacity:1} -} - @keyframes animatetop { from {top:-300px; opacity:0} to {top:0; opacity:1} diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 69274ce..247050b 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -68,7 +68,7 @@ function validateBday($variable){ } } -// Checks for date +/* Checks for date */ function validateDate($date, $format) { $d = DateTime::createFromFormat($format, $date); @@ -124,7 +124,7 @@ function validateEmail($variable){ throw new emailException("Mag maximaal 50 karakters!"); } } -//255 + /* checks if an input is a valid email. */ function validateFBEmail($variable){ if (empty($variable)) { @@ -138,6 +138,7 @@ function validateFBEmail($variable){ } } +/* checks if email is the same */ function matchEmail(){ if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){ throw new confirmEmailException("Emails matchen niet!"); @@ -153,7 +154,6 @@ function resetEmail($variable){ } } - /* checks if two passwords matches. */ function matchPassword(){ if ($_POST["password"] != $_POST["confirmpassword"]) { diff --git a/website/queries/login.php b/website/queries/login.php index 27c1f3b..3480991 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -1,5 +1,6 @@ @@ -75,8 +77,9 @@ function validateLogin($username, $password, $url){ $_SESSION["userID"] = $userID; if(!isset($url) or $url == "") { header("location: profile.php"); + echo "succes"; } else{ - header("location: $url"); + header("location: ".$url); } } diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index 7271d63..a38a3a3 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -1,7 +1,6 @@
- * +
- + diff --git a/website/public/fbRegister.php b/website/views/fbRegister.php similarity index 100% rename from website/public/fbRegister.php rename to website/views/fbRegister.php diff --git a/website/views/forgotPasswordModal.php b/website/views/forgotPasswordModal.php index 2ebdbb9..ebb9d64 100644 --- a/website/views/forgotPasswordModal.php +++ b/website/views/forgotPasswordModal.php @@ -4,7 +4,6 @@ diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index 55277e7..ad7be40 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -11,16 +11,16 @@ if(isset($_SESSION["userID"])){ // Facebook variables $appID = "353857824997532"; $appSecret = "db47e91ffbfd355fdd11b4b65eade851"; -$fbUsername = $fbPassword = $fbConfirmpassword = ""; +$fbUsername = $fbPassword = $fbConfirmpassword = $fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = ""; $fbUsernameErr = $fbPasswordErr = $fbConfirmpasswordErr = $fbEmailErr = $fbBdayErr = ""; $fbCorrect = true; -$fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = ""; // Register variables $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = ""; $genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = ""; $correct = true; +// Bday dates $day_date = $month_date = $year_date = ""; $fbDay_date = $fbMonth_date = $fbYear_date = ""; @@ -28,22 +28,14 @@ $fbDay_date = $fbMonth_date = $fbYear_date = ""; $user = $psw = $remember =""; $loginErr = $resetErr = $fbRegisterErr =""; -//if ($_SERVER["REQUEST_METHOD"] == "GET") { -// try { -// $user = ($_POST["user"]); -// validateLogin($_POST["user"], $_POST["psw"], "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); -// } catch(loginException $e) { -// $loginErr = $e->getMessage(); -// } -//} - if ($_SERVER["REQUEST_METHOD"] == "POST") { + $url = $_POST["url"]; // Checks for which button is pressed switch ($_POST["submit"]) { case "login": try { $user = ($_POST["user"]); - validateLogin($_POST["user"], $_POST["psw"], $_POST["url"]); + validateLogin($_POST["user"], $_POST["psw"], $url); } catch(loginException $e) { $loginErr = $e->getMessage(); } @@ -62,18 +54,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } break; case "register": - include("register.php"); + include("../views/register.php"); break; case "fbRegister": - include("fbRegister.php"); + include("../views/fbRegister.php"); break; } } + +// Get facebook information with facebook PHP SDK. $fb = new Facebook\Facebook([ 'app_id' => $appID, 'app_secret' => $appSecret, 'default_graph_version' => 'v2.2', ]); + +// Redirect back to login.php after logging/canceling with facebook. $redirect = "https://myhyvesbookplus.nl/login.php"; $helper = $fb->getRedirectLoginHelper(); @@ -88,6 +84,7 @@ try { exit; } +// If theres no facebook account logged in, ask for permission. if(!isset($acces_token)){ $permission=["email", "user_birthday"]; $loginurl=$helper->getLoginUrl($redirect,$permission); @@ -96,13 +93,14 @@ if(!isset($acces_token)){ $response = $fb->get('/me?fields=email,name,birthday'); $usernode = $response->getGraphUser(); + // Get facebook information $nameSplit = explode(" ", $usernode->getName()); $fbName = $nameSplit[0]; $fbSurname = $nameSplit[1]; $fbUserID = $usernode->getID(); $fbEmail = $usernode->getProperty("email"); -// $image = 'https://graph.facebook.com/' . $usernode->getId() . '/picture?width=200'; + // If there is an account, check if the account is banned or frozen. if (fbLogin($fbUserID) == 1) { $fbID = getfbUserID($fbUserID)["userID"]; $fbRole = getfbUserID($fbUserID)["role"]; @@ -110,16 +108,20 @@ if(!isset($acces_token)){ echo ""; + } else if($fbRole == "frozen"){ $_SESSION["userID"] = $fbID; echo ""; + window.onload=frozenAlert(); + window.location.href= 'profile.php'; + "; + } else { $_SESSION["userID"] = $fbID; header("location: profile.php"); + } + // Registration with faceobook if theres no account. } else { echo " diff --git a/website/views/login_head.php b/website/views/login_head.php index 9e580df..e8e3a84 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -3,6 +3,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyHyvesbook+ Date: Fri, 3 Feb 2017 12:12:16 +0100 Subject: [PATCH 28/31] Added comments --- website/queries/groupAdmin.php | 2 +- website/queries/nicetime.php | 11 ++- website/queries/post.php | 78 ++++++++++++++++++++- website/queries/private_message.php | 22 +++++- website/queries/user.php | 104 +++++++++++++++++++++++++++- website/views/homeLoginRegister.php | 2 +- 6 files changed, 211 insertions(+), 8 deletions(-) diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php index 8cefb9b..6240009 100644 --- a/website/queries/groupAdmin.php +++ b/website/queries/groupAdmin.php @@ -52,7 +52,7 @@ function updateGroupSettings(int $groupID) } /** - * Checks if an user is an admin for a page. + * Checks if a user is an admin for a page. * @param int $groupID * @param int $userID * @return bool diff --git a/website/queries/nicetime.php b/website/queries/nicetime.php index e2e509e..3881cc7 100644 --- a/website/queries/nicetime.php +++ b/website/queries/nicetime.php @@ -1,9 +1,16 @@ $unix_date) { + // Check if it is in the future or not. + if($now >= $unix_date) { $difference = $now - $unix_date; $tense = "geleden"; } else { @@ -23,6 +31,7 @@ function nicetime($date) { $tense = "vanaf nu"; } + // Get the nice time. for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) { $difference /= $lengths[$i]; } diff --git a/website/queries/post.php b/website/queries/post.php index dc41b49..5cd6354 100644 --- a/website/queries/post.php +++ b/website/queries/post.php @@ -2,6 +2,12 @@ require_once("connect.php"); +/** + * Select all posts on a user. + * @param $userID + * @param $groupID + * @return bool|PDOStatement + */ function selectAllPosts($userID, $groupID) { $stmt = prepareQuery(" SELECT @@ -46,6 +52,14 @@ 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 @@ -94,9 +108,13 @@ 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 @@ -122,6 +140,11 @@ function selectPostById($postID) { return $stmt; } +/** + * Get all the comments from a post. + * @param $postID + * @return PDOStatement + */ function selectCommentsByPostId($postID) { $stmt = prepareQuery(" SELECT @@ -148,6 +171,13 @@ 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 @@ -172,6 +202,13 @@ 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 @@ -194,6 +231,12 @@ 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); @@ -202,6 +245,12 @@ 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 @@ -218,6 +267,12 @@ 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 @@ -230,6 +285,12 @@ 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 @@ -244,6 +305,11 @@ 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(" @@ -257,6 +323,12 @@ 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 @@ -282,10 +354,10 @@ function checkPermissionOnPost(int $postID, int $userID) : bool { } /** - * Returns role of an user. + * Returns role of a user. * @param int $userID * @param int $groupID - * @return mixed role of an user. + * @return mixed role of a user. */ function getRoleInGroup(int $userID, int $groupID) { $stmt = prepareQuery(" diff --git a/website/queries/private_message.php b/website/queries/private_message.php index f2df887..de18144 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -1,5 +1,10 @@ execute(); } +/** + * This gets the userID from a username + * @param $username + * @return mixed + */ function getUserID($username) { $stmt = prepareQuery(" SELECT @@ -30,6 +39,11 @@ function getUserID($username) { return $stmt->fetch()["userID"]; } +/** + * This gets the username from a userID + * @param $userID + * @return mixed + */ function getUsername($userID) { $stmt = prepareQuery(" SELECT @@ -45,6 +59,12 @@ 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 @@ -107,6 +127,11 @@ function selectUser($me, $other) { return $stmt->fetch(); } +/** + * Select all the users from a group. + * @param $userID + * @return PDOStatement + */ function selectAllUserGroups($userID) { $stmt = prepareQuery(" SELECT @@ -130,6 +155,11 @@ 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 @@ -155,6 +185,12 @@ 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 @@ -183,6 +219,13 @@ 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 @@ -215,6 +258,14 @@ 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. @@ -252,6 +303,12 @@ 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 @@ -276,7 +333,12 @@ function countSomeUsersByStatus($search, $status) { return $q; } - +/** + * Change the user status + * @param $id + * @param $status + * @return PDOStatement + */ function changeUserStatusByID($id, $status) { $q = prepareQuery(" UPDATE @@ -293,6 +355,12 @@ 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 @@ -310,6 +378,13 @@ 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 @@ -329,6 +404,11 @@ 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 @@ -357,6 +437,13 @@ function selectRandomNotFriendUser($userID) { return $stmt->fetch(); } +/** + * Search users. + * @param $n + * @param $m + * @param $search + * @return string + */ function searchSomeUsers($n, $m, $search) { $stmt = prepareQuery(" SELECT @@ -397,6 +484,11 @@ 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 @@ -420,6 +512,11 @@ function countSomeUsers($search) { return $q; } +/** + * Get the role of a user by userID. + * @param $userID + * @return mixed + */ function getRoleByID($userID) { $stmt = prepareQuery(" SELECT @@ -435,6 +532,11 @@ function getRoleByID($userID) { return $stmt->fetch()["role"]; } +/** + * Edit the ban comment. + * @param $userID + * @param $comment + */ function editBanCommentByID($userID, $comment) { $stmt = prepareQuery(" UPDATE diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index 2e00905..95b6c53 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -1,7 +1,7 @@ window.onload=checkLoggedIn(); From f3aebddfeaa845bd3d421001d2e45d894336a253 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 3 Feb 2017 12:21:37 +0100 Subject: [PATCH 29/31] commentses --- website/queries/friendship.php | 58 +++++++++++++++++++++- website/queries/group_member.php | 43 ++++++++++++++++ website/queries/group_page.php | 82 ++++++++++++++++++++++++++++++- website/views/adminpanel-page.php | 1 + website/views/group.php | 11 ++++- 5 files changed, 192 insertions(+), 3 deletions(-) diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 3dcd53b..b264c51 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -2,10 +2,21 @@ 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 @@ -46,7 +57,11 @@ 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 @@ -83,6 +98,10 @@ function selectAllFriends($userID) { return $stmt; } +/** + * Returns all friend requests of the current user. + * @return string + */ function selectAllFriendRequests() { $stmt = prepareQuery(" SELECT @@ -119,6 +138,11 @@ 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 @@ -162,6 +186,11 @@ 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) @@ -173,6 +202,11 @@ 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` @@ -189,6 +223,11 @@ 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` @@ -204,6 +243,11 @@ 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 @@ -234,6 +278,13 @@ 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 @@ -281,6 +332,11 @@ 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 diff --git a/website/queries/group_member.php b/website/queries/group_member.php index 7844235..4c23540 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -1,9 +1,20 @@ 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 @@ -55,6 +73,11 @@ 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 @@ -78,6 +101,13 @@ 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 @@ -92,6 +122,13 @@ 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 @@ -109,6 +146,12 @@ 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 diff --git a/website/queries/group_page.php b/website/queries/group_page.php index a6676c4..bf992de 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -2,6 +2,10 @@ require_once("connect.php"); +/** + * Selects some info from a group by name. + * @return bool|mixed + */ function selectGroupByName($name) { $stmt = prepareQuery(" SELECT @@ -41,6 +45,11 @@ 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 @@ -63,6 +72,11 @@ 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 @@ -80,6 +94,11 @@ 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 @@ -105,9 +124,14 @@ function selectGroupMembers(int $groupID) { if (!$stmt->execute()) { return False; } - return $stmt->fetchAll(); + return $stmt; } +/** + * Returns group info by it's ID. + * @param $groupID + * @return PDOStatement + */ function selectGroupById($groupID) { $q = prepareQuery(" SELECT @@ -127,6 +151,11 @@ function selectGroupById($groupID) { return $q; } +/** + * Returns some info of 20 groups offset by n. + * @param $n + * @return PDOStatement + */ function select20GroupsFromN($n) { $q = prepareQuery(" SELECT @@ -149,6 +178,12 @@ 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 @@ -174,6 +209,13 @@ 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 @@ -201,6 +243,14 @@ 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. @@ -233,6 +283,12 @@ 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 @@ -256,6 +312,12 @@ 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 @@ -272,6 +334,12 @@ 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 @@ -289,6 +357,13 @@ 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 @@ -312,6 +387,11 @@ 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 diff --git a/website/views/adminpanel-page.php b/website/views/adminpanel-page.php index cfd73bc..f48d982 100644 --- a/website/views/adminpanel-page.php +++ b/website/views/adminpanel-page.php @@ -13,6 +13,7 @@ Pagina: id="currentpage" form="admin-searchform" onchange="adminSearch();"> + Leden ()

rowCount(); + $memberdif = $membercount - 7; + + for ($i = 0; $i < min($membercount, 7); $i += 1) { + $member = $members->fetch(); echo "\"""; } + + if ($memberdif > 0) { + echo $memberdif === 1 ? "en nog 1 andere." : "...en nog $memberdif anderen."; + } + ?>

From fb5f76c4993cab6d41ab7be8c246452a2f49a207 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 12:32:57 +0100 Subject: [PATCH 30/31] ? --- website/public/js/profile.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 website/public/js/profile.js diff --git a/website/public/js/profile.js b/website/public/js/profile.js deleted file mode 100644 index e69de29..0000000 From 1ac6a7da87e1637e195e596f111df74c8742d8af Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 12:40:33 +0100 Subject: [PATCH 31/31] Changed admin checkbox buttons --- website/public/styles/adminpanel.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index 888b4ca..d04d8fa 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -1,9 +1,9 @@ .admin-panel input[type="radio"], input[type="checkbox"] { vertical-align: middle; - height: 28px; - width: 28px; - margin: 2px; + height: 14px; + width: 14px; + margin: 7px; } .table-checkbox {