From ac83bb750bbe3359904f8d3b0e90788c0064c304 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 23 Jan 2017 16:05:22 +0100 Subject: [PATCH 001/170] fix status for enums, fix pages --- website/views/adminpanel.php | 64 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index e53d679..834f54f 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -85,37 +85,37 @@ $listm = $currentpage * $perpage;

Show:

- > + >
- > + >
- > + >
- > + >
- > + >
- > + >

Show:

- > + >
- > + >
- > + >
@@ -138,11 +138,11 @@ $listm = $currentpage * $perpage; id="admin-batchform" action="" method="post"> - +
- +
- +

@@ -154,11 +154,11 @@ $listm = $currentpage * $perpage; id="admin-groupbatchform" action="" method="post"> - +
- +
- +

@@ -225,7 +225,7 @@ $listm = $currentpage * $perpage; $listm = $currentpage * $perpage; if ($pagetype == 'user') { - $q = searchSomeUsersByStatus($listn, $listm, $search, $status); + $q = searchSomeUsersByStatus($listn, $perpage, $search, $status); while($user = $q->fetch(PDO::FETCH_ASSOC)) { $userID = $user['userID']; @@ -252,9 +252,9 @@ $listm = $currentpage * $perpage; action='$thispage' method='post'> @@ -264,7 +264,7 @@ $listm = $currentpage * $perpage; "); } } else { - $q = searchSomeGroupsByStatus($listn, $listm, $search, $groupstatus); + $q = searchSomeGroupsByStatus($listn, $perpage, $search, $groupstatus); while ($group = $q->fetch(PDO::FETCH_ASSOC)) { $groupID = $group['groupID']; @@ -291,9 +291,9 @@ $listm = $currentpage * $perpage; action='$thispage' method='post'> -- 2.49.1 From 4ebdd378a65be9fe671f9a5157863c8d20f241d4 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Wed, 25 Jan 2017 16:21:17 +0100 Subject: [PATCH 002/170] Password change --- website/public/resetpassword.php | 10 +++++++--- website/queries/requestpassword.php | 9 ++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/website/public/resetpassword.php b/website/public/resetpassword.php index c2f9221..54b706b 100644 --- a/website/public/resetpassword.php +++ b/website/public/resetpassword.php @@ -8,16 +8,19 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") { echo "Ongeldige link."; } } else { - echo "Ongeldige link"; + echo "Ongeldige link."; } } elseif ($_SERVER["REQUEST_METHOD"] == "POST") { if (verifyLink($_POST["u"], $_POST["h"])) { if ($_POST["password"] == $_POST["password-confirm"]) { changePassword(); + echo "Wachtwoord is veranderd"; + } else { + echo "Wachtwoorden zijn niet hetzelfde"; } } } else { - echo "Ongeldige link"; + echo "Ongeldige link."; } function changePassword() { @@ -29,7 +32,7 @@ function changePassword() { WHERE `userID` = :userID "); - $stmt->bindParam(":password", $_POST["password"]); + $stmt->bindValue(":password", password_hash($_POST["password"], PASSWORD_DEFAULT)); $stmt->bindParam(":userID", $_POST["u"]); $stmt->execute(); } @@ -44,6 +47,7 @@ function verifyLink(int $userID, string $hash) { `userID` = :userID "); $stmt->bindParam(":userID", $userID); + $stmt->execute(); $password = $stmt->fetch()["password"]; return password_verify($password, $hash); } \ No newline at end of file diff --git a/website/queries/requestpassword.php b/website/queries/requestpassword.php index abf87c7..c0ff462 100644 --- a/website/queries/requestpassword.php +++ b/website/queries/requestpassword.php @@ -15,7 +15,6 @@ function sendPasswordRecovery(string $email) { $stmt->bindParam(":email", $email); $stmt->execute(); if (!$stmt->rowCount()) { - // TODO: Just stop. return; } $result = $stmt->fetch(); @@ -25,8 +24,6 @@ function sendPasswordRecovery(string $email) { $hashedHash = password_hash($hash, PASSWORD_DEFAULT); setHashToDatabase($userID, $hash); doSendPasswordRecovery($userID, $email, $username, $hashedHash); - - } else { // TODO: Be angry! } @@ -46,10 +43,12 @@ function setHashToDatabase(int $userID, string $hash) { UPDATE `user` SET - `password` = $hash + `password` = :hash WHERE - `userID` = $userID + `userID` = :userID "); + $stmt->bindParam(":hash", $hash); + $stmt->bindParam(":userID", $userID); $stmt->execute(); return $stmt->rowCount(); } \ No newline at end of file -- 2.49.1 From 95ee91748fe86d4130e13d91faa3b28c7c38ac79 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 10:26:40 +0100 Subject: [PATCH 003/170] Chat messages and groups are now live. --- website/public/API/loadGroups.php | 14 +++++ website/public/bits/friend-item.php | 44 ++++++++++------ website/public/bits/group-item.php | 38 ++++++++++++++ website/public/index.php | 14 +++-- website/public/js/friendButtons.js | 5 +- website/public/js/main.js | 21 +++++++- website/public/js/menu.js | 39 ++++++++++++-- website/public/js/notifications.js | 80 ++++++++++++++--------------- website/queries/group_member.php | 9 +++- website/queries/private_message.php | 15 +++--- website/views/chat-view.php | 6 +-- website/views/menu.php | 61 ++-------------------- 12 files changed, 209 insertions(+), 137 deletions(-) create mode 100644 website/public/API/loadGroups.php create mode 100644 website/public/bits/group-item.php diff --git a/website/public/API/loadGroups.php b/website/public/API/loadGroups.php new file mode 100644 index 0000000..546b9d7 --- /dev/null +++ b/website/public/API/loadGroups.php @@ -0,0 +1,14 @@ + $friend) {
@@ -50,27 +62,25 @@ foreach($friends as $i => $friend) { if ($friendshipStatus > 1) { ?>
- - - + + - + -
$group) { + ?> +
  • + + +
  • + + +
  • +
    + + + +
    +
  • diff --git a/website/public/index.php b/website/public/index.php index 914192b..7ad8b59 100644 --- a/website/public/index.php +++ b/website/public/index.php @@ -1,5 +1,9 @@ - - - - - \ No newline at end of file + 0) { + if(friends && friends != "[]") { $(list).load("bits/friend-item.php", { "friends": friends, "limit": limit, @@ -19,6 +26,18 @@ function showFriendsPlus(friends, list, limit, action, actionType) { "actionType": actionType }); + return true; + } else { + return false; + } +} + +function showGroups(groups, list) { + if(groups && groups != "[]") { + $(list).load("bits/group-item.php", { + "groups": groups + }); + return true; } else { return false; diff --git a/website/public/js/menu.js b/website/public/js/menu.js index 7bd6922..8329cde 100644 --- a/website/public/js/menu.js +++ b/website/public/js/menu.js @@ -39,6 +39,8 @@ $(document).ready(function() { loadMenuFriends(5); loadNotificationFriends(); + loadUnreadMessages(); + loadMenuGroups(); }); @@ -56,20 +58,51 @@ function loadMenuFriends(limit) { } }); - setTimeout(loadMenuFriends, 3000, limit); } +function loadMenuGroups() { + $.post( + "API/loadGroups.php", + { + limit: 5 + } + ).done(function(data) { + if (showGroups(data, "#menu-groups-list")) { + $("#groups-menu-section").show(); + } else { + $("#groups-menu-section").hide(); + } + }); + + setTimeout(loadMenuGroups, 3000); +} + function loadNotificationFriends() { $.post( "API/loadFriendRequest.php" ).done(function(data) { - if (showFriendsPlus(data, "#friend-requests-list", 5, "API/edit_friendship", "POST")) { + if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) { $("#friend-request-section").show(); } else { $("#friend-request-section").hide(); } }); - setTimeout(loadNotificationFriends, 30000); + setTimeout(loadNotificationFriends, 3000); +} + +function loadUnreadMessages() { + $.post( + "API/loadChatNotifications.php" + ).done(function(data) { + if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) { + console.log(data); + $("#unread-messages-section").show(); + } else { + $("#unread-messages-section").hide(); + } + }); + + setTimeout(loadUnreadMessages, 3000); } \ No newline at end of file diff --git a/website/public/js/notifications.js b/website/public/js/notifications.js index a875418..d78d167 100644 --- a/website/public/js/notifications.js +++ b/website/public/js/notifications.js @@ -1,43 +1,43 @@ -function showChatNotifications(notifications) { - $("#unreadChatlist").html(""); - for (i in notifications) { - $("#unreadChatlist").append(" \ -
  • \ -
    \ - \ -
    \ -
  • \ - "); - } -} - -function loadNotifications() { - $.post( - "API/loadChatNotifications.php" - ).done(function(data) { - if (data && data != "[]") { - $("#unread-messages-section").show(); - showChatNotifications(JSON.parse(data)); - } else { - $("#unread-messages-section").hide(); - } - }); - - setTimeout(loadNotifications, 10000); -} -$(document).ready(function() { - loadNotifications(); -}); +// function showChatNotifications(notifications) { +// $("#unreadChatlist").html(""); +// for (i in notifications) { +// $("#unreadChatlist").append(" \ +//
  • \ +//
    \ +// \ +//
    \ +//
  • \ +// "); +// } +// } +// +// function loadNotifications() { +// $.post( +// "API/loadChatNotifications.php" +// ).done(function(data) { +// if (data && data != "[]") { +// $("#unread-messages-section").show(); +// showChatNotifications(JSON.parse(data)); +// } else { +// $("#unread-messages-section").hide(); +// } +// }); +// +// setTimeout(loadNotifications, 10000); +// } +// $(document).ready(function() { +// loadNotifications(); +// }); diff --git a/website/queries/group_member.php b/website/queries/group_member.php index 59d4dce..a188494 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -1,6 +1,10 @@ prepare(" SELECT `group_page`.`name`, @@ -13,10 +17,13 @@ function selectAllGroupsFromUser($userID) { `group_member`.`userID` = :userID AND `group_member`.`groupID` = `group_page`.`groupID` AND `group_page`.`status` != 'hidden' + LIMIT :limitCount "); $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); + $stmt->bindParam(':limitCount', $limit, PDO::PARAM_INT); $stmt->execute(); - return $stmt; + return json_encode($stmt->fetchAll()); } + diff --git a/website/queries/private_message.php b/website/queries/private_message.php index d40ee88..e708541 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -79,11 +79,11 @@ function getNewChatMessages($lastID, $destination) { function selectAllUnreadChat() { $stmt = $GLOBALS["db"]->prepare(" SELECT - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `name`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, `user`.`userID`, IFNULL( - `profilepicture`, - '../img/notbad.jpg' + `profilepicture`, + '../img/notbad.jpg' ) AS profilepicture, LEFT(`private_message`.`content`, 15) as `content` FROM @@ -93,15 +93,18 @@ function selectAllUnreadChat() { WHERE (`friendship`.user2ID = `private_message`.`origin` AND `friendship`.user1ID = `private_message`.`destination` AND - `friendship`.chatLastVisted1 < `private_message`.`creationdate` OR + (`friendship`.chatLastVisted1 < `private_message`.`creationdate` OR + `friendship`.chatLastVisted1 IS NULL) OR `friendship`.user1ID = `private_message`.`origin` AND - `friendship`.user2ID = `private_message`.`destination` AND - `friendship`.chatLastVisted2 < `private_message`.`creationdate`) AND + `friendship`.user2ID = `private_message`.`destination` AND + (`friendship`.chatLastVisted2 < `private_message`.`creationdate` OR + `friendship`.chatLastVisted2 IS NULL)) AND `private_message`.`origin` = `user`.`userID` AND `private_message`.`destination` = :userID AND `user`.`role` != 'banned' GROUP BY `user`.`userID` + "); $stmt->bindParam(':userID', $_SESSION["userID"]); diff --git a/website/views/chat-view.php b/website/views/chat-view.php index c3fdde4..0d90149 100644 --- a/website/views/chat-view.php +++ b/website/views/chat-view.php @@ -16,7 +16,7 @@ // Set default values of a friend. $username = $friend["username"]; - $name = $friend["name"]; + $name = $friend["fullname"]; $userID = $friend["userID"]; $pf = "img/avatar-standard.png"; @@ -37,8 +37,8 @@ "; } - if (isset($_GET["chatID"]) && $_GET["chatID"] != "") { - $chatID = $_GET["chatID"]; + if (isset($_GET["username"]) && $_GET["username"] != "") { + $chatID = $_GET["username"]; echo ""; } ?> diff --git a/website/views/menu.php b/website/views/menu.php index 6564366..4d15d94 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -16,63 +16,10 @@
    - 0) { - echo " -

    - Groepen -

    -
      - "; - - foreach ($groups as $i => $group) { - // Set default values of a friend. - $name = $group["name"]; - $extraItem = ""; - $picture = $group["picture"]; - - // Change values if needed. - if ($i > 3) - $extraItem = "extra-menu-items"; - - echo " -
    • -
      - -
      -
    • - "; - } - - if (sizeof($groups) > 3) { - echo " -
    • - Meer groepen.. -
    • - "; - } - } - ?> -
    -
    -
      - +

      + Groepen +

      +
    \ No newline at end of file -- 2.49.1 From 8fb8df075f002583a17729d24eadaba9fcc82ef0 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 26 Jan 2017 11:31:15 +0100 Subject: [PATCH 004/170] Added comments --- website/public/API/edit_friendship.php | 31 ------- website/public/js/header.js | 32 +++----- website/public/js/menu.js | 109 +++++++++++-------------- website/public/js/notifications.js | 43 ---------- website/views/notification-center.php | 2 +- 5 files changed, 61 insertions(+), 156 deletions(-) delete mode 100644 website/public/API/edit_friendship.php delete mode 100644 website/public/js/notifications.js diff --git a/website/public/API/edit_friendship.php b/website/public/API/edit_friendship.php deleted file mode 100644 index 52aacf5..0000000 --- a/website/public/API/edit_friendship.php +++ /dev/null @@ -1,31 +0,0 @@ - \ -//
    \ -// \ -//
    \ -// \ -// "); -// } -// } -// -// function loadNotifications() { -// $.post( -// "API/loadChatNotifications.php" -// ).done(function(data) { -// if (data && data != "[]") { -// $("#unread-messages-section").show(); -// showChatNotifications(JSON.parse(data)); -// } else { -// $("#unread-messages-section").hide(); -// } -// }); -// -// setTimeout(loadNotifications, 10000); -// } -// $(document).ready(function() { -// loadNotifications(); -// }); - - - diff --git a/website/views/notification-center.php b/website/views/notification-center.php index 8c01217..ee5622e 100644 --- a/website/views/notification-center.php +++ b/website/views/notification-center.php @@ -7,7 +7,7 @@

    - Vriendchapsverzoeken + Verzoeken

    - \ No newline at end of file + -- 2.49.1 From ce53b6e9e4e592b55a4f1918862e01ba50bbc4c5 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 22:42:47 +0100 Subject: [PATCH 062/170] Checkbox for showBday and showEmail --- website/queries/settings.php | 7 ++-- website/views/settings-view.php | 58 +++++++++++++-------------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/website/queries/settings.php b/website/queries/settings.php index 6c52fc4..bdc9d38 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -110,7 +110,8 @@ function updateSettings() { WHERE `userID` = :userID "); - $bday = new DateTime(test_input($_POST["year"] . $_POST["month"] . $_POST["day"])); + $bday = new DateTime(); + $bday->setDate(test_input($_POST["year"]), test_input($_POST["month"]), test_input($_POST["day"])); checkBday($bday); $stmt->bindValue(":fname", test_input($_POST["fname"])); @@ -118,8 +119,8 @@ function updateSettings() { $stmt->bindValue(":location", test_input($_POST["location"])); $stmt->bindValue(":bday", $bday->format("Ymd")); $stmt->bindValue(":bio", test_input($_POST["bio"])); - $stmt->bindValue(":showEmail", test_input($_POST["showEmail"])); - $stmt->bindValue(":showBday",test_input($_POST["showBday"])); + $stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0")); + $stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0")); $stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->execute(); diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 1079c91..6271a45 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -45,30 +45,30 @@ $settings = getSettings();
  • - + "; - + + + - format("Y"); for ($year = $now; $year >= 1900; $year--): ?> @@ -80,33 +80,19 @@ $settings = getSettings();
  • - - > Ja - - > Nee + >
  • - - > Ja - - > Nee + >
  • @@ -220,4 +206,4 @@ $settings = getSettings(); - + \ No newline at end of file -- 2.49.1 From 8dfa31696c8c53ceac1214c862261bd8ba875d06 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 22:49:43 +0100 Subject: [PATCH 063/170] autocomplete suggestions at password --- website/views/settings-view.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 6271a45..c5c58c2 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -141,24 +141,30 @@ $settings = getSettings();
    Verander Wachtwoord
    • - +
    • - +
    • - +
    • -- 2.49.1 From 6983aa06a2c97646ff2f5fce9ebe4b03c18c8a33 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Mon, 30 Jan 2017 23:03:50 +0100 Subject: [PATCH 064/170] Finishing touches --- website/views/settings-view.php | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index c5c58c2..029a32b 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -21,7 +21,7 @@ $settings = getSettings(); id="fname" placeholder="Voornaam" title="Voornaam" - value="" + value="" >
    • @@ -30,7 +30,7 @@ $settings = getSettings(); name="lname" id="lname" placeholder="Achternaam" - value="" + value="" >
    • @@ -39,18 +39,19 @@ $settings = getSettings(); name="location" id="location" placeholder="Locatie" - value="" + value="" >
    • - + - -
    • @@ -83,7 +84,7 @@ $settings = getSettings(); + >
    • @@ -91,7 +92,7 @@ $settings = getSettings(); + >
    • @@ -100,7 +101,7 @@ $settings = getSettings(); rows="5" title="bio" id="bio" - > + >
    • @@ -116,7 +117,7 @@ $settings = getSettings();
      • - " + " class="profile-picture" >
      • @@ -183,7 +184,7 @@ $settings = getSettings(); " + value="" disabled > -- 2.49.1 From a6b6d6d747ca2a02e53f8bab68dcafda38ea5387 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Tue, 31 Jan 2017 10:23:47 +0100 Subject: [PATCH 065/170] Style changes --- website/views/settings-view.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 029a32b..b7f554a 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -4,13 +4,11 @@ $settings = getSettings();
        - - $alertMessage -
        "; - } - ?> + +
        + +
        +
        Profiel Instellingen
          @@ -43,10 +41,10 @@ $settings = getSettings(); >
        • - + +
        • -- 2.49.1 From 4dc3b4f651d353b266973acebaad5f517cb97826 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 10:31:57 +0100 Subject: [PATCH 066/170] Mobile friendly --- website/public/js/admin.js | 1 - website/public/js/friendButtons.js | 3 -- website/public/js/header.js | 46 ++++++++++++++--------- website/public/styles/chat.css | 14 ++++++- website/public/styles/header.css | 9 ++++- website/public/styles/main.css | 10 +++++ website/public/styles/menu.css | 14 +++++++ website/public/styles/mobilefriendly.css | 47 ++++++++++++++++++++++++ website/public/styles/profile.css | 2 +- website/views/head.php | 2 + website/views/menu.php | 2 +- 11 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 website/public/styles/mobilefriendly.css diff --git a/website/public/js/admin.js b/website/public/js/admin.js index 140c99a..36347c2 100644 --- a/website/public/js/admin.js +++ b/website/public/js/admin.js @@ -60,7 +60,6 @@ function adminSearch() { "API/adminSearchUsers.php", $("#admin-searchform").serialize() ).done(function (data) { - console.log(data); $("#usertable").html(data); }) } diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index d62e919..47c476a 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -48,9 +48,6 @@ function placeFriendButtons() { text2 = "Weiger"; icon2 = "fa-times"; break; - default: - console.log(friendshipStatus); - break; } $buttonContainer.append( diff --git a/website/public/js/header.js b/website/public/js/header.js index bdf5fe3..13e3e12 100644 --- a/website/public/js/header.js +++ b/website/public/js/header.js @@ -1,25 +1,37 @@ $(document).ready(function() { // Toggle menu $("#own-profile-picture, #open-notifications").click(function() { - if ($("#notification-center").css('right') == "-256px") { - // Make the menu visible and move the content to the left. - $("#chat-history").width("calc(100% - 587px)"); - $(".modal").width("calc(100% - 512px)"); - $(".content").css("margin-right", "256px"); - $("#notification-center").css("right", "0px"); + 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 - document.cookie = "menu=open; path=/"; - } else { - // Make the menu invisible and move the content to the right. - $("#chat-history").width("calc(100% - 331px)"); - $(".modal").width("calc(100% - 256px)"); - $(".content").css("margin-right", "0px"); - $("#notification-center").css("right", "-256px"); + // 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=/"; + } + } else { + $(".modal").width("calc(100% - 256px)"); + $(".content").css("margin-right", "0px"); + $("#notification-center").css("display", "none"); - // Change menu cookie to close - document.cookie = "menu=closed; path=/"; - } + 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=/"; + + } }); if (getCookie("menu") == "open") { diff --git a/website/public/styles/chat.css b/website/public/styles/chat.css index 85eb219..cb0f19f 100644 --- a/website/public/styles/chat.css +++ b/website/public/styles/chat.css @@ -146,8 +146,20 @@ body { text-align: right; } -@media only screen and (max-width: 1200px) { +@media only screen and (max-width: 1080px) { .chat-message-self, .chat-message-other { max-width: 75%; } + .chat { + left: 0; + width: 100%; + } + #chat-recent-panel { + left: 0; + width: 320px; + } + #chat-history { + left: 50%; + width: calc(100% - 390px); + } } \ No newline at end of file diff --git a/website/public/styles/header.css b/website/public/styles/header.css index 70e8c80..61727eb 100644 --- a/website/public/styles/header.css +++ b/website/public/styles/header.css @@ -26,7 +26,8 @@ header { } #header-search { - padding-left: 42px; + margin: 24px 0 24px 32px; + vertical-align: middle; } @@ -49,4 +50,10 @@ header div { #open-notifications { padding: 5px 20px 5px 0px; +} + +@media only screen and (max-width: 1080px) { + #header-logo { + display: none; + } } \ No newline at end of file diff --git a/website/public/styles/main.css b/website/public/styles/main.css index abb1604..baff345 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -293,4 +293,14 @@ div[data-title]:hover:after { -webkit-border-radius: 20px; border-radius: 20px; background: #4CAF50; +} + +@media only screen and (max-width: 1080px) { + body { + font-size: 28px!important; + } + button { + font-size: 28px; + } + } \ No newline at end of file diff --git a/website/public/styles/menu.css b/website/public/styles/menu.css index 303b9bc..a862d12 100644 --- a/website/public/styles/menu.css +++ b/website/public/styles/menu.css @@ -86,4 +86,18 @@ height: 100%; padding: 0; text-align: left; +} + +@media only screen and (max-width: 1080px) { + #contact-menu, #notification-center { + display: none; + background: rgba(0, 0, 0, 0.4); + width: calc(50% - 20px); + } + .content { + margin-left: 0; + } + #quick-links i { + font-size: 48px!important; + } } \ No newline at end of file diff --git a/website/public/styles/mobilefriendly.css b/website/public/styles/mobilefriendly.css new file mode 100644 index 0000000..86ffab8 --- /dev/null +++ b/website/public/styles/mobilefriendly.css @@ -0,0 +1,47 @@ +/* MAIN */ +body { + font-size: 28px!important; +} +button { + font-size: 28px; +} + +/* HEADER */ +#header-logo { + display: none; +} + +/* PROFILE */ +.post-box { + width: calc(100% - 65px); +} + +/* MENU */ +#contact-menu, #notification-center { + display: none; + background: rgba(0, 0, 0, 0.4); + width: calc(50% - 20px); +} +.content { + margin-left: 0; +} +#quick-links i { + font-size: 48px!important; +} + +/* CHAT */ +.chat-message-self, .chat-message-other { + max-width: 75%; +} +.chat { + left: 0; + width: 100%; +} +#chat-recent-panel { + left: 0; + width: 320px; +} +#chat-history { + left: 50%; + width: calc(100% - 390px); +} \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 03ab19f..37aaaa1 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -116,7 +116,7 @@ div.posts .post form textarea.newpost { } /* mobile */ -@media only screen and (max-width: 1000px) { +@media only screen and (max-width: 1080px) { .post-box { width: calc(100% - 65px); } diff --git a/website/views/head.php b/website/views/head.php index eb86d56..6e8ca0a 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -12,6 +12,8 @@ @import url("styles/header.css"); @import url("styles/menu.css"); @import url("styles/footer.css"); + + @import url("styles/mobilefriendly.css") screen and (orientation: portrait); +
        -- 2.49.1 From f26097f55fab9a19fa2fc59b087aa4c813f84b5f Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 12:25:28 +0100 Subject: [PATCH 069/170] Fixed online status --- website/public/bits/friend-item.php | 2 +- website/public/group.php | 2 +- website/public/profile.php | 8 ++++---- website/public/styles/main.css | 10 +++++++++- website/public/styles/profile.css | 2 +- website/queries/friendship.php | 11 ++++++----- website/queries/user.php | 13 +++++++++++++ website/views/head.php | 5 ++++- website/views/profile.php | 4 ++-- 9 files changed, 41 insertions(+), 16 deletions(-) diff --git a/website/public/bits/friend-item.php b/website/public/bits/friend-item.php index a69d12a..40bc8a8 100644 --- a/website/public/bits/friend-item.php +++ b/website/public/bits/friend-item.php @@ -33,7 +33,7 @@ foreach($friends as $i => $friend) { } ?>'>
        - PF + PF
        fullname ?>
        = DATE_SUB(NOW(),INTERVAL 15 MINUTE) + WHEN TRUE THEN 'online' + WHEN FALSE THEN 'offline' + END AS `onlinestatus`, `role` FROM `user` @@ -28,11 +32,8 @@ function selectLimitedFriends($userID, $limit) { `friendship`.`user1ID` = `user`.`userID`) AND `user`.`role` != 'banned' AND `friendship`.`status` = 'confirmed' - ORDER BY - CASE - WHEN `friendship`.`user2ID` = `user`.`userID` THEN `friendship`.`chatLastVisted1` - WHEN `friendship`.`user1ID` = `user`.`userID` THEN `friendship`.`chatLastVisted2` - END + ORDER BY + `user`.`lastactivity` DESC LIMIT :limitCount "); diff --git a/website/queries/user.php b/website/queries/user.php index 0900d9f..b1bb93c 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -2,6 +2,19 @@ require_once ("connect.php"); +function updateLastActivity() { + $stmt = prepareQuery(" + UPDATE + `user` + SET + `lastactivity` = NOW() + WHERE + `userID` = :userID + "); + $stmt->bindParam(":userID", $_SESSION["userID"]); + return $stmt->execute(); +} + function getUserID($username) { $stmt = prepareQuery(" SELECT diff --git a/website/views/head.php b/website/views/head.php index 6e8ca0a..284abb4 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -19,9 +19,12 @@ require_once ("../queries/checkInput.php"); require_once ("../queries/connect.php"); +require_once ("../queries/user.php"); session_start(); if(!isset($_SESSION["userID"])){ header("location:login.php"); -} \ No newline at end of file +} else { + updateLastActivity(); +} diff --git a/website/views/profile.php b/website/views/profile.php index 90a368d..8cf555f 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -1,10 +1,10 @@
        - ">
        + " src="">
        -- 2.49.1 From f67dd019c46c67ca604423d00ac04b7c956a8ac7 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Tue, 31 Jan 2017 12:47:24 +0100 Subject: [PATCH 070/170] Inputs are now mobile friendly --- website/public/styles/main.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 7909687..f2d7535 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -192,7 +192,7 @@ button.green { } button.gray{ - background-color: inherit; + background-color: #FFF; color: #333; } @@ -307,8 +307,9 @@ div[data-title]:hover:after { body { font-size: 28px!important; } - button { + button, input { font-size: 28px; + height: 42px; } } \ No newline at end of file -- 2.49.1 From c14a2770bd092b41a343a2a99f0606c444c75b3d Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 31 Jan 2017 12:52:50 +0100 Subject: [PATCH 071/170] Fixed posting functions for groups. --- website/public/API/postPost.php | 57 +++++++++++++++++++++++++++------ website/queries/group_page.php | 31 +++++++++++++++++- 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b52e96b..40c18e1 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -2,16 +2,53 @@ session_start(); -require("../../queries/post.php"); -require("../../queries/connect.php"); -require("../../queries/checkInput.php"); +require_once("../../queries/post.php"); +require_once("../../queries/group_page.php"); +require_once("../../queries/connect.php"); +require_once("../../queries/checkInput.php"); -if (empty($_POST['newpost-title'])) { -} else { - makePost($_SESSION['userID'], - null, - test_input($_POST['newpost-title']), - test_input($_POST['newpost-content'])); +if (empty($_POST["title"]) or + empty($_POST["content"]) or + empty($_SESSION["userID"])) { + header('HTTP/1.1 500 Non enough arguments'); } -header("Location: ../profile.php"); \ No newline at end of file +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; + } + + makePost( + $_SESSION["userID"], + $_POST["group"], + test_input($_POST["title"]), + test_input($_POST["content"]) + ); +} + + + + + + +//if (empty($_POST['newpost-title'])) { +//} else { +// makePost($_SESSION['userID'], +// null, +// test_input($_POST['newpost-title']), +// test_input($_POST['newpost-content'])); +//} +// +//header("Location: ../profile.php"); \ No newline at end of file diff --git a/website/queries/group_page.php b/website/queries/group_page.php index b3e454c..83911f8 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -11,6 +11,12 @@ function selectGroupByName($name) { `description`, `picture`, `status`, + ( + SELECT `role` + FROM `group_member` + WHERE `group_member`.`groupID` = `group_page`.`groupID` AND + `userID` = :userID + ) AS `role`, COUNT(`group_member`.`groupID`) as `members` FROM `group_page` @@ -22,13 +28,36 @@ function selectGroupByName($name) { name LIKE :name "); - $stmt->bindParam(':name', $name); + $stmt->bindParam(':name', $name, PDO::PARAM_STR); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); if (!$stmt->execute()) { return False; } return $stmt->fetch(); } +function selectGroupRole(int $groupID) { + $stmt = prepareQuery(" + SELECT + `role` + FROM + `group_member` + WHERE + `groupID` = :groupID AND + `userID` = :userID + "); + + $stmt->bindParam(':groupID', $groupID, PDO::PARAM_INT); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); + if(!$stmt->execute()) { + return False; + } + if($stmt->rowCount() == 0) { + return "none"; + } + return $stmt->fetch()["role"]; +} + function selectGroupMembers(int $groupID) { $stmt = prepareQuery(" SELECT -- 2.49.1 From 6b13db9c4fbfeb99ce903b8072c36ad2e60f7cc9 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Tue, 31 Jan 2017 12:53:45 +0100 Subject: [PATCH 072/170] Fixed posting on group pages. --- website/public/API/postPost.php | 2 +- website/public/group.php | 3 +++ website/public/js/masonry.js | 34 +++++++++++++++++++++++++++++---- website/views/group.php | 2 +- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index 40c18e1..7a33857 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -29,7 +29,7 @@ if (empty($_POST["group"])) { header('HTTP/1.1 500 Non enough rights'); return; } - + makePost( $_SESSION["userID"], $_POST["group"], diff --git a/website/public/group.php b/website/public/group.php index 2ef3493..5d9459e 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -34,6 +34,9 @@ include("../views/group.php"); include("../views/footer.php"); $masonry_mode = 0; +if ($group["role"] == "mod" OR $group["role"] == "admin") { + $masonry_mode = 2; +} ?> diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index cb82089..d73c33c 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -23,6 +23,28 @@ function requestPost(postID) { }); } +function postPost() { + title = $("input.newpost[name='title']").val(); + content = $("textarea.newpost[name='content']").val(); + + if (masonryMode == 2) { + $.post("API/postPost.php", { title: title, + content : content, + group : groupID }) + .done(function() { + masonry(masonryMode); + }); + } else { + $.post("API/postPost.php", { title: title, + content : content }) + .done(function() { + masonry(masonryMode); + }); + } + + +} + $(window).on("load", function() { $(".modal-close").click(function () { $(".modal").hide(); @@ -64,13 +86,17 @@ function masonry(mode) { columns[i] = [0, $column]; } - if(mode == 1) { + if(mode > 0) { $postInput = $("
        "); - $form = $(""); + $form = $(""); $postInput.append($form); - $form.append($("")); - $form.append($("")); $form.append($("")); columns[0][1].append($postInput); diff --git a/website/views/post-view.php b/website/views/post-view.php index 264d67c..d961334 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -24,7 +24,7 @@ echo("
        -
        +
        +
        +
        + + + + + + + + + + + +
        \ No newline at end of file diff --git a/website/views/fbBdayInput.php b/website/views/fbBdayInput.php new file mode 100644 index 0000000..c08b192 --- /dev/null +++ b/website/views/fbBdayInput.php @@ -0,0 +1,40 @@ + + + + + + diff --git a/website/views/login-view.php b/website/views/login-view.php index 0219797..8e82fdf 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -20,7 +20,7 @@ name="user" value="" title="Moet een geldige gebruiker zijn" - > + required>
        @@ -31,7 +31,7 @@ placeholder="Voer uw wachtwoord in" name="psw" title="Moet minstens 8 karakters lang zijn" - > + required>
        @@ -47,73 +47,68 @@
        -
        - + + +login with Facebook!
        '; + } +?> \ No newline at end of file diff --git a/website/views/registerModal.php b/website/views/registerModal.php index b430ab8..9ad48dc 100644 --- a/website/views/registerModal.php +++ b/website/views/registerModal.php @@ -32,7 +32,8 @@ name="name" value="" title="Mag alleen letters bevatten" - > + required + autocomplete="given-name"> * @@ -44,7 +45,8 @@ name="surname" value="" title="Mag alleen letters bevatten" - > + required + autocomplete="family-name"> * @@ -65,7 +67,7 @@ name="username" value="" title="Moet minimaal 6 karakters bevatten" - > + required> *
        • Minstens 6 karakters
        • @@ -81,7 +83,7 @@ name="password" value="" id="password" - > + required> *
          • Minstens 8 karakters
          • @@ -96,7 +98,7 @@ value="" id="confirmpassword" title="Herhaal wachtwoord" - > + required> * @@ -109,7 +111,6 @@ value="" pattern="[A-Za-z]{1,}" title="Mag alleen letters bevatten"> - * @@ -120,7 +121,8 @@ name="email" value="" id="email" - title="Voer een geldige email in"> + title="Voer een geldige email in" + required> * @@ -132,10 +134,12 @@ name="confirmEmail" value="" id="email" - title="Herhaal uw email"> + title="Herhaal uw email" + required> * + + +
            -- 2.49.1 From c0a64e9ffd4af652b488ac18a39f31831de13523 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Tue, 31 Jan 2017 16:19:15 +0100 Subject: [PATCH 086/170] 1337 bday --- website/views/settings-view.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/views/settings-view.php b/website/views/settings-view.php index b7f554a..b03133e 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -75,6 +75,9 @@ $settings = getSettings(); +
          • -- 2.49.1 From 52a4822477432218965aff2bf0b9b15018f4112e Mon Sep 17 00:00:00 2001 From: Hendrik Date: Tue, 31 Jan 2017 16:20:02 +0100 Subject: [PATCH 087/170] post-merge fix --- website/public/API/adminSearchUsers.php | 2 +- website/views/adminpanel-table.php | 2 +- website/views/adminpanel.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/public/API/adminSearchUsers.php b/website/public/API/adminSearchUsers.php index 58b170a..5f7944b 100644 --- a/website/public/API/adminSearchUsers.php +++ b/website/public/API/adminSearchUsers.php @@ -33,7 +33,7 @@ if (isset($_POST['groupstatus'])) { $groupstatus = $_POST["groupstatus"]; } -$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC); +$userinfo = getRoleByID($_SESSION['userID']); if ($pagetype == "user") { include ("../../views/adminpanel-table.php"); diff --git a/website/views/adminpanel-table.php b/website/views/adminpanel-table.php index 9e6b9bc..3ae5da4 100644 --- a/website/views/adminpanel-table.php +++ b/website/views/adminpanel-table.php @@ -50,7 +50,7 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) { - + name="fbUserID" + value=""> + diff --git a/website/views/forgotPasswordModal.php b/website/views/forgotPasswordModal.php index d3f12f9..2ebdbb9 100644 --- a/website/views/forgotPasswordModal.php +++ b/website/views/forgotPasswordModal.php @@ -19,7 +19,8 @@ class="middle" placeholder="Voer uw email in" name="forgotEmail" - title="Voer een email in"> + title="Voer een email in" + required>
          • + value="email"> + Verander Email +
          -- 2.49.1 From d027333bd7dfa3170505566a0f93c6b5ef55d6d9 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 2 Feb 2017 01:06:31 +0100 Subject: [PATCH 110/170] fix filter and pagenumber interaction in search --- website/public/API/searchPageNumber.php | 14 ++++++++--- website/queries/friendship.php | 31 +++++++++++++++++++++++++ website/queries/group_member.php | 23 ++++++++++++++++++ website/views/search-view.php | 7 +++++- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/website/public/API/searchPageNumber.php b/website/public/API/searchPageNumber.php index 4a76516..9a12d79 100644 --- a/website/public/API/searchPageNumber.php +++ b/website/public/API/searchPageNumber.php @@ -6,6 +6,8 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/checkInput.php"); require_once ("../../queries/user.php"); require_once ("../../queries/group_page.php"); +require_once ("../../queries/friendship.php"); +require_once ("../../queries/group_member.php"); $user_perpage = $group_perpage = 20; @@ -25,14 +27,20 @@ if (isset($_POST['search'])) { $search = test_input($_POST['search']); } -$user_count = countSomeUsers($search)->fetchColumn(); -$group_count = countSomeGroups($search)->fetchColumn(); - $filter = "all"; if (isset($_POST['filter'])) { $filter = test_input($_POST['filter']); } +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']); diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 450fd20..49d8047 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -274,4 +274,35 @@ function searchSomeFriends($n, $m, $search) { $stmt->bindParam(':m', $m, PDO::PARAM_INT); $stmt->execute(); return json_encode($stmt->fetchAll()); +} + +function countSomeFriends($search) { + $stmt = prepareQuery(" + SELECT + COUNT(*) + FROM + `user` + INNER JOIN + `friendship` + WHERE + ((`friendship`.`user1ID` = :userID AND + `friendship`.`user2ID` = `user`.`userID` OR + `friendship`.`user2ID` = :userID AND + `friendship`.`user1ID` = `user`.`userID`) AND + `user`.`role` != 'banned' AND + `friendship`.`status` = 'confirmed') AND + (`username` LIKE :keyword OR + `fname` LIKE :keyword OR + `lname` LIKE :keyword) + ORDER BY + `fname`, + `lname`, + `username` + "); + + $search = "%$search%"; + $stmt->bindParam(':keyword', $search); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetchColumn(); } \ No newline at end of file diff --git a/website/queries/group_member.php b/website/queries/group_member.php index cea4dde..8b6bf75 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -54,3 +54,26 @@ function searchSomeOwnGroups($n, $m, $search) { return json_encode($stmt->fetchAll()); } + +function countSomeOwnGroups($search) { + $stmt = prepareQuery(" + SELECT + COUNT(*) + FROM + `group_page` + INNER JOIN + `group_member` + WHERE + `group_member`.`userID` = :userID AND + `group_member`.`groupID` = `group_page`.`groupID` AND + `group_page`.`status` != 'hidden' AND + `name` LIKE :keyword + "); + + $search = "%$search%"; + $stmt->bindParam(':keyword', $search); + $stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT); + $stmt->execute(); + + return $stmt->fetchColumn(); +} \ No newline at end of file diff --git a/website/views/search-view.php b/website/views/search-view.php index e42f985..f00fd3c 100644 --- a/website/views/search-view.php +++ b/website/views/search-view.php @@ -48,7 +48,12 @@ $group_n = ($group_currentpage - 1) * $group_perpage; - -- 2.49.1 From e299ef59e8e5e46d87fde39c1b152b34aa92807a Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 10:28:12 +0100 Subject: [PATCH 111/170] Added show profile into settings --- website/public/js/post.js | 2 -- website/queries/settings.php | 7 +++++-- website/views/settings-view.php | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/website/public/js/post.js b/website/public/js/post.js index f176950..4009023 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -34,6 +34,4 @@ function deletePost(postID) { }); closeModal(); masonry(masonryMode); - - } \ No newline at end of file diff --git a/website/queries/settings.php b/website/queries/settings.php index 03f794f..dfd65a0 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -18,7 +18,8 @@ function getSettings() { `bio`, `profilepicture`, `showBday`, - `showEmail` + `showEmail`, + `showProfile` FROM `user` WHERE @@ -64,7 +65,8 @@ function updateSettings() { `birthdate` = :bday, `bio` = :bio, `showEmail` = :showEmail, - `showBday` = :showBday + `showBday` = :showBday, + `showProfile` = :showProfile WHERE `userID` = :userID "); @@ -79,6 +81,7 @@ function updateSettings() { $stmt->bindValue(":bio", test_input($_POST["bio"])); $stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0")); $stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0")); + $stmt->bindValue(":showProfile", (array_key_exists("showProfile", $_POST) ? "1" : "0")); $stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->execute(); diff --git a/website/views/settings-view.php b/website/views/settings-view.php index e3cfd36..f72e243 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -96,6 +96,14 @@ $settings = getSettings(); > +
        • + + + > +
        • ")); - $form.append($("")); + $form.append($("")); columns[0][1].append($postInput); columns[0][0] = $postInput.height() + margin; diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 1bacafa..2370da8 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -108,7 +108,7 @@ div.posts .post form input, div.posts .post form textarea { width: calc(100% - 15px); } -div.posts .post form input[type="submit"] { +div.posts .post form input[type="submit"], .post button{ width: 100%; } diff --git a/website/views/post-view.php b/website/views/post-view.php index da1c86f..f8fe902 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -30,7 +30,7 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "

          - + "; + ""; } // Add ogg video's else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) { return ""; + ""; } // Add youtube video's else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) { diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 226a96d..650a30f 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -116,7 +116,7 @@ p { @media only screen and (max-width: 1400px) { .item-box { - width: calc(100% - 50px); + width: calc(100% - 50px)!important; } } diff --git a/website/public/styles/settings.css b/website/public/styles/settings.css index 933e7fd..6a2c2f2 100644 --- a/website/public/styles/settings.css +++ b/website/public/styles/settings.css @@ -32,6 +32,11 @@ text-align: right; } +.settings-password, .settings-email { + width: calc(50% - 60px); + display: inline-flex; +} + .settings-password label, .settings-email label { text-align: left; } diff --git a/website/views/head.php b/website/views/head.php index 284abb4..c4d13a5 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,4 +1,8 @@ - + + + + + MyHyvesbook+ -- 2.49.1 From 327a6a8f5cb5f8ca04508548dd3f6d3062e5264d Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 12:52:03 +0100 Subject: [PATCH 116/170] BUG FIX: username doesn't cut off in link --- website/public/bits/friend-item.php | 2 +- website/queries/friendship.php | 13 ++++++++----- website/queries/user.php | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/website/public/bits/friend-item.php b/website/public/bits/friend-item.php index 181f9b6..6a0c868 100644 --- a/website/public/bits/friend-item.php +++ b/website/public/bits/friend-item.php @@ -41,7 +41,7 @@ foreach($friends as $i => $friend) { fullname ?>
          username)) { - echo $friend->username; + echo $friend->usernameshort; } else if (isset($friend->content)) { echo $friend->content; } diff --git a/website/queries/friendship.php b/website/queries/friendship.php index e1a8c53..6ea6313 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -10,7 +10,8 @@ function selectLimitedFriends($userID, $limit) { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, @@ -50,7 +51,8 @@ function selectAllFriends($userID) { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, @@ -85,7 +87,8 @@ function selectAllFriendRequests() { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, @@ -235,8 +238,8 @@ function searchSomeFriends($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, - - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, diff --git a/website/queries/user.php b/website/queries/user.php index 72205ba..1e54763 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -349,7 +349,8 @@ function searchSomeUsers($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, - LEFT(`username`, 12) as `username`, + LEFT(`username`, 12) as `usernameshort`, + `username`, IFNULL( `profilepicture`, '../img/avatar-standard.png' -- 2.49.1 From 86b02973e4887022619cff121379f9fd5da50998 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 13:02:00 +0100 Subject: [PATCH 117/170] Fixed visibility on profiles --- website/public/profile.php | 6 ++++++ website/queries/user.php | 4 ++++ website/views/profile.php | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/website/public/profile.php b/website/public/profile.php index 05c661d..d9a317c 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -21,13 +21,19 @@ include_once("../queries/calcAge.php"); if(empty($_GET["username"])) { $userID = $_SESSION["userID"]; + $showProfile = True; } else { $userID = getUserID($_GET["username"]); + $showProfile = False; } $user = selectUser($_SESSION["userID"], $userID); $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); +$showProfile = $showProfile || $user["showProfile"] || ($user["status"] == 'confirmed'); +echo " friendship status: " . $user["status"]; +echo " showprofile: $showProfile"; +echo " userID: " . $user["userID"]; if ($userID == $_SESSION["userID"]) { diff --git a/website/queries/user.php b/website/queries/user.php index 33a85a1..74b0aa1 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -65,6 +65,10 @@ function selectUser($me, $other) { `role`, `fname`, `lname`, + `showBday`, + `showEmail`, + `showProfile`, + `status`, CASE `status` IS NULL WHEN TRUE THEN 0 WHEN FALSE THEN diff --git a/website/views/profile.php b/website/views/profile.php index 2bb117f..1e88af8 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -15,16 +15,18 @@

          - " . $user["bio"] . "

          "; } ?>
          - 50) { + 50 and $showProfile) { echo "

          Bio:

          " . $user["bio"] . "

          "; } ?> +

          Informatie

          @@ -85,4 +87,5 @@

          + \ No newline at end of file -- 2.49.1 From 9d675dd897b01d2a5e4e13a124ab9944b2b63a46 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 13:11:05 +0100 Subject: [PATCH 118/170] Fixed default image for group members. --- website/queries/group_page.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 511ff4d..b66ca54 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -81,7 +81,10 @@ function selectGroupMembers(int $groupID) { `username`, `fname`, `lname`, - `profilepicture` + IFNULL( + `profilepicture`, + '../img/avatar-standard.png' + ) AS profilepicture FROM `group_member` LEFT JOIN -- 2.49.1 From 044ed6a9d34345e54778ef1795611a51402521c1 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Thu, 2 Feb 2017 13:19:39 +0100 Subject: [PATCH 119/170] Added noscript --- website/public/styles/index.css | 8 +++++++- website/queries/checkInput.php | 2 +- website/views/facebookRegisterModal.php | 3 +-- website/views/login-view.php | 7 +++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/website/public/styles/index.css b/website/public/styles/index.css index 196485e..c7a0aa8 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -133,6 +133,12 @@ label { color: red; } +.login_containerNoscript { + padding: 4px; + text-align: center; + color: red; +} + @keyframes animatezoom { from {transform: scale(0)} to {transform: scale(1)} @@ -150,7 +156,7 @@ label { margin: 16px auto; overflow-y: auto; padding: 20px; - width: 600px; + width: 650px; } select{ diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 8722418..69274ce 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -132,7 +132,7 @@ function validateFBEmail($variable){ } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) { throw new emailException("Geldige email invullen"); } else if (getExistingFBEmail() == 1){ - throw new emailException("Email bestaal al!"); + throw new emailException("Uw email wordt al gebruikt voor een ander account!"); } else if (strlen($variable) > 255) { throw new emailException("Mag maximaal 50 karakters!"); } diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index 7db44b0..7271d63 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -55,7 +55,6 @@ * - + * - diff --git a/website/views/login-view.php b/website/views/login-view.php index 4f85b0a..98ce71c 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -1,3 +1,9 @@ +
          -- 2.49.1 From 417124a1fed22f85cd86615e83df488455baeb30 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:13:20 +0100 Subject: [PATCH 124/170] BUG FIX: added 0 in chat time if needed --- website/public/js/chat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 1141334..a3ff430 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -59,7 +59,7 @@ function addMessages(messages) { for(var i in messages) { // Initialize message variables. var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); - var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); + var thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2); var type; thisDate.setHours(0,0,0,0); @@ -81,6 +81,8 @@ function addMessages(messages) {
          '; } previousDate = thisDate; + previousTime = thisTime; + previousType = type; messagesText += '
          '; // If it is not the first message, and has a different date/time/type then the previous message, } else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) { -- 2.49.1 From 4a7a91ecd964f1cb0827765078314d04ac6534dc Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 2 Feb 2017 14:20:17 +0100 Subject: [PATCH 125/170] Fixed bug (not showing profile when on own profile) --- website/public/profile.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/website/public/profile.php b/website/public/profile.php index d9a317c..aa4cf7c 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -21,19 +21,14 @@ include_once("../queries/calcAge.php"); if(empty($_GET["username"])) { $userID = $_SESSION["userID"]; - $showProfile = True; } else { $userID = getUserID($_GET["username"]); - $showProfile = False; } $user = selectUser($_SESSION["userID"], $userID); $profile_friends = selectAllFriends($userID); $profile_groups = selectAllUserGroups($userID); -$showProfile = $showProfile || $user["showProfile"] || ($user["status"] == 'confirmed'); -echo " friendship status: " . $user["status"]; -echo " showprofile: $showProfile"; -echo " userID: " . $user["userID"]; +$showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID; if ($userID == $_SESSION["userID"]) { -- 2.49.1 From 188741ddf5ded574767a0115f06af8bd2a97487b Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:22:13 +0100 Subject: [PATCH 126/170] BUG FIX: link in fancy text now opens in new tab --- website/public/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/main.js b/website/public/js/main.js index b6ab703..30cd3ed 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -31,7 +31,7 @@ function fancyText(text) { } // Add links else { - return "" + link + ""; + return "" + link + ""; } }); -- 2.49.1 From 1672ce6086deed96f1325a3044e9fe9c632adaf6 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:23:36 +0100 Subject: [PATCH 127/170] Changed offline status to 5 minutes after inactive --- website/queries/friendship.php | 8 ++++---- website/queries/user.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 7edada9..3dcd53b 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -17,7 +17,7 @@ function selectLimitedFriends($userID, $limit) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -58,7 +58,7 @@ function selectAllFriends($userID) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -94,7 +94,7 @@ function selectAllFriendRequests() { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -245,7 +245,7 @@ function searchSomeFriends($n, $m, $search) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, diff --git a/website/queries/user.php b/website/queries/user.php index e8bda13..7b8ef3f 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -62,7 +62,7 @@ function selectUser($me, $other) { ) AS profilepicture, `bio`, `user`.`creationdate`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -131,7 +131,7 @@ function select20UsersFromN($n) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -156,7 +156,7 @@ function search20UsersFromN($n, $keyword) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -184,7 +184,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -218,7 +218,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -362,7 +362,7 @@ function searchSomeUsers($n, $m, $search) { '../img/avatar-standard.png' ) AS profilepicture, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` -- 2.49.1 From 6fc2f715176a34529d129a0f1a79d4d57f9ae659 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Thu, 2 Feb 2017 14:27:23 +0100 Subject: [PATCH 128/170] Added meta data in the login page --- website/views/login_head.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/views/login_head.php b/website/views/login_head.php index e319a9d..bb7d7cf 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,5 +1,8 @@ - + + + + MyHyvesbook+ Date: Thu, 2 Feb 2017 14:50:51 +0100 Subject: [PATCH 129/170] Added "add group" under group menu --- website/views/menu.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..1c1cf01 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -12,6 +12,8 @@ +
  • +
    +
    + +
    \ No newline at end of file -- 2.49.1 From 74e91ed7cb18acebaabd5b6356f87aec25830977 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 2 Feb 2017 21:14:25 +0100 Subject: [PATCH 144/170] 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"> + + + + + +
    +
    • -- 2.49.1 From 7e4107ac8b357bc1335c9657293182a5ce18720c Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:13:23 +0100 Subject: [PATCH 145/170] 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="">
    - - +
    + +
    +
    + +

    :)

    -- 2.49.1 From 6d739a4480019709d6abe9addea37ade0ebbc34d Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 00:24:38 +0100 Subject: [PATCH 146/170] 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"]); -- 2.49.1 From 1a3efe9669089acffc404151616d26b1d3f9d984 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 3 Feb 2017 10:12:37 +0100 Subject: [PATCH 147/170] 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 11:47:16 +0100 Subject: [PATCH 164/170] Added fbModal button --- website/public/js/loginRegisterModals.js | 5 ++++- website/views/facebookRegisterModal.php | 6 ++++++ website/views/homeLoginRegister.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/website/public/js/loginRegisterModals.js b/website/public/js/loginRegisterModals.js index 373fb7e..104dd02 100644 --- a/website/public/js/loginRegisterModals.js +++ b/website/public/js/loginRegisterModals.js @@ -7,7 +7,7 @@ var facebookModal = document.getElementById("fbModal"); // Get the button that opens the modal var registerBtn = document.getElementById("registerBtn"); var btn = document.getElementById("myBtn"); - +var fbBtn = document.getElementById("fbBtn"); // Get the element that closes the modal var span = document.getElementsByClassName("close")[0]; @@ -24,6 +24,9 @@ btn.onclick = function () { registerBtn.onclick = function () { registerModal.style.display = "block"; } +fbBtn.onclick = function () { + facebookModal.style.display = "block"; +} /** * WHen the user clicks on (X), close the modal diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index a38a3a3..17ce7ef 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -1,3 +1,9 @@ +Facebook registreer'; + +} +?> -- 2.49.1 From fb5f76c4993cab6d41ab7be8c246452a2f49a207 Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 12:32:57 +0100 Subject: [PATCH 167/170] ? --- 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 -- 2.49.1 From 1ac6a7da87e1637e195e596f111df74c8742d8af Mon Sep 17 00:00:00 2001 From: Lars van Hijfte Date: Fri, 3 Feb 2017 12:40:33 +0100 Subject: [PATCH 168/170] 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 { -- 2.49.1 From 4643dfcddb4f8ef314168cb0851c811d559d57bd Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Fri, 3 Feb 2017 12:42:30 +0100 Subject: [PATCH 169/170] Fixed comments and links --- website/queries/register.php | 31 +++++++++++++++++++++++++++++ website/queries/requestpassword.php | 18 +++++++++++++++-- website/views/homeLoginRegister.php | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/website/queries/register.php b/website/queries/register.php index 3dcbed4..7f91dfa 100644 --- a/website/queries/register.php +++ b/website/queries/register.php @@ -1,5 +1,9 @@ rowCount(); } +/** + * Registers a new account with facebook register + */ function fbRegisterAccount() { $stmt = prepareQuery(" INSERT INTO @@ -158,6 +184,11 @@ function fbRegisterAccount() { return $stmt->execute(); } +/** + * Checks which dates need to be selected when there is an invalid registration. + * @param $date + * @param $value + */ function submitselect($date, $value){ if ($date == $value){ echo "selected"; diff --git a/website/queries/requestpassword.php b/website/queries/requestpassword.php index a54bd7d..daad355 100644 --- a/website/queries/requestpassword.php +++ b/website/queries/requestpassword.php @@ -1,6 +1,10 @@ getRedirectLoginHelper(); try { -- 2.49.1 From 7cc6450e6afde743509fcc83b3e8dadf0415509e Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Fri, 3 Feb 2017 13:19:00 +0100 Subject: [PATCH 170/170] Added comments to javascript code. --- website/public/js/friendButtons.js | 8 +++++- website/public/js/groupButtons.js | 5 ++++ website/public/js/masonry.js | 44 +++++++++++++++++++----------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 47c476a..440dfe5 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -1,6 +1,8 @@ +// Show the right friendship buttonsto the user. function placeFriendButtons() { $.post("API/getFriendshipStatus.php", { usr: userID }) .done(function(data) { + //save the friendship status var friendshipStatus = data; var $buttonContainer = $("div.friend-button-container"); $("#start-profile-chat").hide(); @@ -22,6 +24,7 @@ function placeFriendButtons() { text1 = "Bevriend"; icon1 = "fa-handshake-o"; break; + // Users are friends. case "1": value1 = userID; class1 = "green"; @@ -32,12 +35,14 @@ function placeFriendButtons() { text2 = "Verwijder"; icon2 = "fa-times"; break; + // This user sent request. case "2": value1 = "delete"; class1 = "red"; text1 = "Trek verzoek in"; icon1 = "fa-cross"; break; + // Other user sent request. case "3": value1 = "accept"; class1 = "green"; @@ -50,6 +55,7 @@ function placeFriendButtons() { break; } + // Append buttons to the container. $buttonContainer.append( ""); - + // Gets triggered when a friend button is triggered. $buttonContainer.children().click(function() { if (isNaN(this.value)) editFriendship(userID, this.value); diff --git a/website/public/js/groupButtons.js b/website/public/js/groupButtons.js index e6ada67..ab86e8c 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -3,16 +3,20 @@ function placeGroupButtons() { .done(function(data) { var $buttonContainer = $("div.group-button-container"); + // Append the right group button to the button container. + // When user is not a member if(data == 'none') { $buttonContainer.append( ""); + // when user sent a request to become a member. } else if(data == 'request') { $buttonContainer.append( ""); + // When user is a member of the group. } else { $buttonContainer.append( ""); } + // Gets triggered when a group button is clicked. $buttonContainer.children().click(function() { $.post("API/editMembership.php", { grp: groupID, role: this.value }) .done(function() { diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index a628e96..eeb5cf7 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -1,3 +1,4 @@ +// Vertical margin between two posts. margin = 20; // scrolling modal taken from http://stackoverflow.com/questions/10476632/how-to-scroll-the-page-when-a-modal-dialog-is-longer-than-the-screen @@ -11,9 +12,12 @@ function scrollbarMargin(width, overflow) { }); } +// Get post from the server. function requestPost(postID) { + // Make the modal view visible. $(".modal").show(); + // Send get request to the server to load the post. $.get("API/loadPost.php", { postID : postID }).done(function(data) { $('.modal-default').hide(); var scrollBarWidth = window.innerWidth - document.body.offsetWidth; @@ -23,11 +27,14 @@ function requestPost(postID) { }); } +// Create a new post. function postPost() { title = $("input.newpost[name='title']").val(); content = $("textarea.newpost[name='content']").val(); + // Masonrymode 2: when on group page and user is an admin. if (masonryMode == 2) { + // Create the new group post. $.post("API/postPost.php", { title: title, content : content, group : groupID }) @@ -42,6 +49,7 @@ function postPost() { } }); } else { + // Create the new user post. $.post("API/postPost.php", { title: title, content : content }) .done(function(data) { @@ -68,6 +76,7 @@ var postAmount = 0; var noposts = false; $(document).ready(function () { + // Initialise variables for masonry. windowWidth = $(window).width(); columnCount = Math.floor($(".posts").width() / 250); columns = new Array(columnCount); @@ -78,6 +87,7 @@ $(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 + // Infinite scroll. window.onscroll = function(ev) { if($(window).scrollTop() + $(window).height() == $(document).height() ) { loadMorePosts(userID, groupID, postAmount, postLimit); @@ -85,6 +95,7 @@ $(window).on("load", function() { }; }); +// Hide modal view from the screen. function closeModal() { $(".modal").hide(); scrollbarMargin(0, 'auto'); @@ -92,23 +103,30 @@ function closeModal() { $('.modal-default').show(); } +// Will fire when user resizes the window. $(window).resize(function() { clearTimeout(window.resizedFinished); window.resizeFinished = setTimeout(function() { + // Check if the width of the screen changed. if ($(window).width() != windowWidth) { + // Save width. windowWidth = $(window).width(); - + // Check if there fit more or less columns in the new width. if (columnCount != Math.floor($(".posts").width() / 250)) { columnCount = Math.floor($(".posts").width() / 250); + // Respawn the masonry grid. masonry(masonryMode); } } }, 250); }); +// Select the container for masonry. var $container = $(".posts"); +// Spawn the masonry grid. function masonry(mode) { + // save the masonry mode. masonryMode = mode; $container.children().remove(); @@ -116,10 +134,7 @@ function masonry(mode) { noposts = false; postAmount = 0; - /* - * Initialise columns. - */ - + // Initialise columns. for (i = 0; i < columnCount; i++) { $column = $("
    "); $column.width(100/columnCount + "%"); @@ -127,11 +142,13 @@ function masonry(mode) { columns[i] = [0, $column]; } + // Place the form for new posts. if(mode > 0) { $postInput = $("
    "); $form = $(""); $postInput.append($form); + //Add extra input for group posts. if(mode == 2) { $form.append($("")); } @@ -144,17 +161,11 @@ function masonry(mode) { columns[0][0] = $postInput.height() + margin; } - /* - * Function will find the column with the shortest height. - */ - - - /* - * Get the posts from the server. - */ + // Get the posts from the server. loadMorePosts(userID, groupID, 0, postLimit); } +// Find the column with the shortest hight. function getShortestColumn(columns) { column = columns[0]; @@ -166,17 +177,20 @@ function getShortestColumn(columns) { return column; } +// Load certain range of posts. function loadMorePosts(uID, gID, offset, limit) { if (noposts) { return; } + // Get a list of posts from the server. $.post("API/getPosts.php", { usr : uID, grp : gID, offset : offset, limit : limit}) .done(function(data) { if (!data) { + // No posts were found, show noposts bar to user. $('.noposts').show(); noposts = true; return; @@ -184,9 +198,7 @@ function loadMorePosts(uID, gID, offset, limit) { posts = JSON.parse(data); - /* - * Rearange the objects. - */ + // Rearange the objects. $.each(posts, function() { $post = $("
    "); $post.append($("

    ").html(this["title"])); -- 2.49.1