diff --git a/website/public/API/deletePost.php b/website/public/API/deletePost.php index fffadf5..37f89a1 100644 --- a/website/public/API/deletePost.php +++ b/website/public/API/deletePost.php @@ -3,10 +3,10 @@ session_start(); require_once "../../queries/post.php"; require_once "../../queries/user.php"; - -if (isset($_SESSION["userID"]) and - getRoleByID($_SESSION["userID"]) != 'frozen' and - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' and + getRoleByID($_SESSION["userID"]) != 'banned') { if (empty($_POST["postID"]) or empty($_SESSION["userID"])) { header('HTTP/1.1 500 Non enough arguments'); diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index 3864cc8..c9f8a53 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -7,10 +7,10 @@ require_once("../../queries/connect.php"); require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); - -if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'frozen' && - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { if ($_POST['button'] == 'reaction') { if (empty($_POST['newcomment-content'])) { echo 0; diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index 241bda6..2d703d3 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -8,9 +8,10 @@ require_once("../../queries/connect.php"); require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); -if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'frozen' && - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { if (empty($_SESSION["userID"])) { header('HTTP/1.1 500 Non enough arguments'); diff --git a/website/public/API/sendMessage.php b/website/public/API/sendMessage.php index c6e3231..a2d411b 100644 --- a/website/public/API/sendMessage.php +++ b/website/public/API/sendMessage.php @@ -7,9 +7,10 @@ require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); // Check if the user is allowed to send a message. -if (isset($_SESSION["userID"]) && - getRoleByID($_SESSION["userID"]) != 'frozen' && - getRoleByID($_SESSION["userID"]) != 'banned') { +if (!isset($_SESSION["userID"])) { + echo "logged out"; +} else if (getRoleByID($_SESSION["userID"]) != 'frozen' && + getRoleByID($_SESSION["userID"]) != 'banned') { if (!empty(test_input($_POST["destination"])) && !empty(test_input($_POST["content"])) ) { diff --git a/website/public/apple-touch-icon-114x114-precomposed.png b/website/public/apple-touch-icon-114x114-precomposed.png new file mode 100644 index 0000000..8ff3015 Binary files /dev/null and b/website/public/apple-touch-icon-114x114-precomposed.png differ diff --git a/website/public/apple-touch-icon-120x120-precomposed.png b/website/public/apple-touch-icon-120x120-precomposed.png new file mode 100644 index 0000000..ef42d75 Binary files /dev/null and b/website/public/apple-touch-icon-120x120-precomposed.png differ diff --git a/website/public/apple-touch-icon-144x144-precomposed.png b/website/public/apple-touch-icon-144x144-precomposed.png new file mode 100644 index 0000000..dd01202 Binary files /dev/null and b/website/public/apple-touch-icon-144x144-precomposed.png differ diff --git a/website/public/apple-touch-icon-152x152-precomposed.png b/website/public/apple-touch-icon-152x152-precomposed.png new file mode 100644 index 0000000..d4a1679 Binary files /dev/null and b/website/public/apple-touch-icon-152x152-precomposed.png differ diff --git a/website/public/apple-touch-icon-180x180-precomposed.png b/website/public/apple-touch-icon-180x180-precomposed.png new file mode 100644 index 0000000..d33355b Binary files /dev/null and b/website/public/apple-touch-icon-180x180-precomposed.png differ diff --git a/website/public/apple-touch-icon-57x57-precomposed.png b/website/public/apple-touch-icon-57x57-precomposed.png new file mode 100644 index 0000000..6b35bb3 Binary files /dev/null and b/website/public/apple-touch-icon-57x57-precomposed.png differ diff --git a/website/public/apple-touch-icon-60x60-precomposed.png b/website/public/apple-touch-icon-60x60-precomposed.png new file mode 100644 index 0000000..ffa2250 Binary files /dev/null and b/website/public/apple-touch-icon-60x60-precomposed.png differ diff --git a/website/public/apple-touch-icon-72x72-precomposed.png b/website/public/apple-touch-icon-72x72-precomposed.png new file mode 100644 index 0000000..ab6b967 Binary files /dev/null and b/website/public/apple-touch-icon-72x72-precomposed.png differ diff --git a/website/public/apple-touch-icon-76x76-precomposed.png b/website/public/apple-touch-icon-76x76-precomposed.png new file mode 100644 index 0000000..691b53c Binary files /dev/null and b/website/public/apple-touch-icon-76x76-precomposed.png differ diff --git a/website/public/apple-touch-icon-precomposed.png b/website/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..c4d8103 Binary files /dev/null and b/website/public/apple-touch-icon-precomposed.png differ diff --git a/website/public/browserconfig.xml b/website/public/browserconfig.xml new file mode 100755 index 0000000..21d8570 --- /dev/null +++ b/website/public/browserconfig.xml @@ -0,0 +1,12 @@ + + + + + + + + + #000000 + + + \ No newline at end of file diff --git a/website/public/createGroup.php b/website/public/createGroup.php new file mode 100644 index 0000000..ffeb6e3 --- /dev/null +++ b/website/public/createGroup.php @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/website/public/favicon-1.png b/website/public/favicon-1.png new file mode 100644 index 0000000..5595296 Binary files /dev/null and b/website/public/favicon-1.png differ diff --git a/website/public/favicon-2.png b/website/public/favicon-2.png new file mode 100644 index 0000000..59929a0 Binary files /dev/null and b/website/public/favicon-2.png differ diff --git a/website/public/favicon-3.png b/website/public/favicon-3.png new file mode 100644 index 0000000..833ff6f Binary files /dev/null and b/website/public/favicon-3.png differ diff --git a/website/public/favicon-4.png b/website/public/favicon-4.png new file mode 100644 index 0000000..fac373a Binary files /dev/null and b/website/public/favicon-4.png differ diff --git a/website/public/favicon.ico b/website/public/favicon.ico new file mode 100644 index 0000000..44ef012 Binary files /dev/null and b/website/public/favicon.ico differ 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/group.php b/website/public/group.php index 84726fa..11a2609 100644 --- a/website/public/group.php +++ b/website/public/group.php @@ -13,7 +13,7 @@ include_once("../queries/group_page.php"); -if(!$group = selectGroupByName($_GET["groupname"])) { +if(isset($_SESSION["userID"]) and !$group = selectGroupByName($_GET["groupname"])) { header("HTTP/1.0 404 Not Found"); header("Location: error/404.php"); die(); diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php new file mode 100644 index 0000000..ec6eee8 --- /dev/null +++ b/website/public/groupAdmin.php @@ -0,0 +1,72 @@ + + + + + + + + +getClass(); + $alertMessage = $w->getMessage(); + } +} + +/* Add your view files here. */ +include("../views/groupAdmin.php"); + +/* This adds the footer. */ +include("../views/footer.php"); +?> + + diff --git a/website/public/js/admin.js b/website/public/js/admin.js index e0dc9f7..76180d9 100644 --- a/website/public/js/admin.js +++ b/website/public/js/admin.js @@ -24,12 +24,14 @@ $(window).on("load", function () { }); }); +// Toggles all checkboxes based on one. function checkAll() { $('.checkbox-list').each(function () { $(this).prop('checked', $('#checkall').prop('checked')); }); } +// Simple function that checks if checkall should stay checked. function checkCheckAll() { var checked = true; @@ -43,6 +45,7 @@ function checkCheckAll() { $('#checkall').prop('checked', checked); } +// Toggle of filter options. function changeFilter() { if ($('#pagetype').find(":selected").val() == "group") { document.getElementById('admin-filter').style.display = 'none'; @@ -59,11 +62,13 @@ function changeFilter() { } } +// Sets the search page to one, relevant when changing filter or search. function searchFromOne() { $('#currentpage').prop('value', 1); adminSearch(); } +// AJAX live search. function adminSearch() { $.post( "API/adminSearchUsers.php", @@ -74,6 +79,7 @@ function adminSearch() { }) } +// AJAX live update. function adminUpdate(form) { $.post( "API/adminChangeUser.php", @@ -83,6 +89,7 @@ function adminUpdate(form) { }) } +// AJAX pagenumber functionality. function updatePageN() { $.post( "API/adminPageNumber.php", @@ -92,11 +99,13 @@ function updatePageN() { }) } +// Intended for the edit button to show a form. function toggleBancomment(button) { $(button).siblings("div").toggle(); $(button).toggle(); } +// AJAX value editing. function editComment(form) { $.post( "API/adminChangeUser.php", diff --git a/website/public/js/chat.js b/website/public/js/chat.js index a3ff430..06dffa4 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -43,12 +43,15 @@ function sendMessage() { ).done(function(response) { if (response == "frozen") { alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is."); + } else if (response == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; } // Load messages if the message has been send, so it shows in the chat. loadMessages(); }); $("#newContent").val(""); + $("#newContent").focus(); } // Add messages to the chat. diff --git a/website/public/js/dobPicker.js b/website/public/js/dobPicker.js deleted file mode 100644 index 9440153..0000000 --- a/website/public/js/dobPicker.js +++ /dev/null @@ -1,123 +0,0 @@ -/** - * jQuery DOB Picker - * Website: https://github.com/tyea/dobpicker - * Version: 1.0 - * Author: Tom Yeadon - * License: BSD 3-Clause - */ - -jQuery.extend({ - - dobPicker: function(params) { - - // set the defaults - if (typeof(params.dayDefault)==='undefined') params.dayDefault = 'Day'; - if (typeof(params.monthDefault)==='undefined') params.monthDefault = 'Month'; - if (typeof(params.yearDefault)==='undefined') params.yearDefault = 'Year'; - if (typeof(params.minimumAge)==='undefined') params.minimumAge = 12; - if (typeof(params.maximumAge)==='undefined') params.maximumAge = 80; - - // set the default messages - $(params.daySelector).append(''); - $(params.monthSelector).append(''); - $(params.yearSelector).append(''); - - // populate the day select - for (i = 1; i <= 31; i++) { - if (i <= 9) { - var val = '0' + i; - } else { - var val = i; - } - $(params.daySelector).append(''); - } - - // populate the month select - var months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - ]; - - for (i = 1; i <= 12; i++) { - if (i <= 9) { - var val = '0' + i; - } else { - var val = i; - } - $(params.monthSelector).append(''); - } - - // populate the year select - var date = new Date(); - var year = date.getFullYear(); - var start = year - params.minimumAge; - var count = start - params.maximumAge; - - for (i = start; i >= count; i--) { - $(params.yearSelector).append(''); - } - - // do the logic for the day select - $(params.daySelector).change(function() { - - $(params.monthSelector)[0].selectedIndex = 0; - $(params.yearSelector)[0].selectedIndex = 0; - $(params.yearSelector + ' option').removeAttr('disabled'); - - if ($(params.daySelector).val() >= 1 && $(params.daySelector).val() <= 29) { - - $(params.monthSelector + ' option').removeAttr('disabled'); - - } else if ($(params.daySelector).val() == 30) { - - $(params.monthSelector + ' option').removeAttr('disabled'); - $(params.monthSelector + ' option[value="02"]').attr('disabled', 'disabled'); - - } else if($(params.daySelector).val() == 31) { - - $(params.monthSelector + ' option').removeAttr('disabled'); - $(params.monthSelector + ' option[value="02"]').attr('disabled', 'disabled'); - $(params.monthSelector + ' option[value="04"]').attr('disabled', 'disabled'); - $(params.monthSelector + ' option[value="06"]').attr('disabled', 'disabled'); - $(params.monthSelector + ' option[value="09"]').attr('disabled', 'disabled'); - $(params.monthSelector + ' option[value="11"]').attr('disabled', 'disabled'); - - } - - }); - - // do the logic for the month select - $(params.monthSelector).change(function() { - - $(params.yearSelector)[0].selectedIndex = 0; - $(params.yearSelector + ' option').removeAttr('disabled'); - - if ($(params.daySelector).val() == 29 && $(params.monthSelector).val() == '02') { - - $(params.yearSelector + ' option').each(function(index) { - if (index !== 0) { - var year = $(this).attr('value'); - var leap = !((year % 4) || (!(year % 100) && (year % 400))); - if (leap === false) { - $(this).attr('disabled', 'disabled'); - } - } - }); - - } - - }); - - } - -}); diff --git a/website/public/js/dobPicker.min.js b/website/public/js/dobPicker.min.js deleted file mode 100644 index b82c3a2..0000000 --- a/website/public/js/dobPicker.min.js +++ /dev/null @@ -1 +0,0 @@ -jQuery.extend({dobPicker:function(a){for("undefined"==typeof a.dayDefault&&(a.dayDefault="Day"),"undefined"==typeof a.monthDefault&&(a.monthDefault="Month"),"undefined"==typeof a.yearDefault&&(a.yearDefault="Year"),"undefined"==typeof a.minimumAge&&(a.minimumAge=12),"undefined"==typeof a.maximumAge&&(a.maximumAge=80),$(a.daySelector).append('"),$(a.monthSelector).append('"),$(a.yearSelector).append('"),i=1;i<=31;i++){if(i<=9)var b="0"+i;else var b=i;$(a.daySelector).append('")}var c=["January","February","March","April","May","June","July","August","September","October","November","December"];for(i=1;i<=12;i++){if(i<=9)var b="0"+i;else var b=i;$(a.monthSelector).append('")}var d=new Date,e=d.getFullYear(),f=e-a.minimumAge,g=f-a.maximumAge;for(i=f;i>=g;i--)$(a.yearSelector).append('");$(a.daySelector).change(function(){$(a.monthSelector)[0].selectedIndex=0,$(a.yearSelector)[0].selectedIndex=0,$(a.yearSelector+" option").removeAttr("disabled"),$(a.daySelector).val()>=1&&$(a.daySelector).val()<=29?$(a.monthSelector+" option").removeAttr("disabled"):30==$(a.daySelector).val()?($(a.monthSelector+" option").removeAttr("disabled"),$(a.monthSelector+' option[value="02"]').attr("disabled","disabled")):31==$(a.daySelector).val()&&($(a.monthSelector+" option").removeAttr("disabled"),$(a.monthSelector+' option[value="02"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="04"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="06"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="09"]').attr("disabled","disabled"),$(a.monthSelector+' option[value="11"]').attr("disabled","disabled"))}),$(a.monthSelector).change(function(){$(a.yearSelector)[0].selectedIndex=0,$(a.yearSelector+" option").removeAttr("disabled"),29==$(a.daySelector).val()&&"02"==$(a.monthSelector).val()&&$(a.yearSelector+" option").each(function(a){if(0!==a){var b=$(this).attr("value"),c=!(b%4||!(b%100)&&b%400);c===!1&&$(this).attr("disabled","disabled")}})})}}); diff --git a/website/public/js/friendButtons.js b/website/public/js/friendButtons.js index 440dfe5..a333916 100644 --- a/website/public/js/friendButtons.js +++ b/website/public/js/friendButtons.js @@ -21,26 +21,26 @@ function placeFriendButtons() { case "0": value1 = "request"; class1 = "green"; - text1 = "Bevriend"; - icon1 = "fa-handshake-o"; + text1 = "Word vrienden"; + icon1 = "fa-user-plus"; break; // Users are friends. 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; // This user sent request. case "2": value1 = "delete"; class1 = "red"; text1 = "Trek verzoek in"; - icon1 = "fa-cross"; + icon1 = "fa-times"; break; // Other user sent request. case "3": @@ -57,16 +57,18 @@ function placeFriendButtons() { // Append buttons to the container. $buttonContainer.append( - ""); + "
"); $buttonContainer.append( - ""); + "
"); // Gets triggered when a friend button is triggered. - $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 ab86e8c..fe82066 100644 --- a/website/public/js/groupButtons.js +++ b/website/public/js/groupButtons.js @@ -7,32 +7,44 @@ function placeGroupButtons() { // 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 if (data == 'admin') { + $buttonContainer.append( + "" + ); + } 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() { - $buttonContainer.children().remove(); - placeGroupButtons(); - updateMenus(); - }).fail(function() { - }); + if (this.value == 'admin') { + window.location.href='groupAdmin.php?groupID=' + groupID; + } else { + $.post("API/editMembership.php", {grp: groupID, role: this.value}) + .done(function () { + $buttonContainer.children().remove(); + placeGroupButtons(); + updateMenus(); + }).fail(function () { + }); + } }); }); diff --git a/website/public/js/loginRegisterModals.js b/website/public/js/loginRegisterModals.js new file mode 100644 index 0000000..373fb7e --- /dev/null +++ b/website/public/js/loginRegisterModals.js @@ -0,0 +1,68 @@ + +// Get the modal +var modal = document.getElementById('myModal'); +var registerModal = document.getElementById('registerModal'); +var facebookModal = document.getElementById("fbModal"); + +// Get the button that opens the modal +var registerBtn = document.getElementById("registerBtn"); +var btn = document.getElementById("myBtn"); + + +// Get the element that closes the modal +var span = document.getElementsByClassName("close")[0]; +var registerSpan = document.getElementsByClassName("close")[1]; +var facebookCLose = document.getElementsByClassName("close")[2]; + +/** + * When the user clicks the button, open the modal + */ +btn.onclick = function () { + modal.style.display = "block"; + +} +registerBtn.onclick = function () { + registerModal.style.display = "block"; +} + +/** + * WHen the user clicks on (X), close the modal + */ +span.onclick = function () { + modal.style.display = "none"; +} +registerSpan.onclick = function () { + registerModal.style.display = "none"; +} +facebookCLose.onclick = function () { + facebookModal.style.display = "none"; +} + +/** + * When the user clicks anywhere outside of the modal, close it + */ +window.onclick = function (event) { + if (event.target == modal) { + modal.style.display = "none"; + } + if (event.target == registerModal) { + registerModal.style.display = "none"; + } + if (event.target == facebookModal) { + facebookModal.style.display = "none"; + } +} + +/** + * When ESC is pressed, close modal + */ +document.addEventListener('keyup', function(e) { + if (e.keyCode == 27) { + modal.style.display = "none"; + registerModal.style.display = "none"; + + } +}); +/** + * Created by joey on 2-2-17. + */ diff --git a/website/public/js/main.js b/website/public/js/main.js index 30cd3ed..2ce58e4 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -3,8 +3,7 @@ var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "a function fancyText(text) { // Add links, images, gifs and (youtube) video's. - var regex = /(https?:\/\/.[^ <>"]*)/ig; - text = text.replace(regex, function(link) { + text = text.replace(/(https?:\/\/.[^ \n<>"]*)/ig, function(link) { // Add images if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) { return "" + link + ""; @@ -39,7 +38,7 @@ function fancyText(text) { } // This function gets the value of a cookie when given a key. -// If didn´t find any compatible cookie, it returns false. +// If it didn´t find any compatible cookie, it returns false. function getCookie(key) { cookies = document.cookie.split("; "); for (var i in cookies) { diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index eeb5cf7..3b7897d 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -43,6 +43,10 @@ function postPost() { $('#alertbox').show(); $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); window.scrollTo(0,0); + } else if (data == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; + } else if (data == "frozen") { + alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is."); } else { $('#alertbox').hide(); masonry(masonryMode); @@ -57,6 +61,10 @@ function postPost() { $('#alertbox').show(); $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); window.scrollTo(0,0); + } else if (data == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; + } else if (data == "frozen") { + alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is."); } else { $('#alertbox').hide(); masonry(masonryMode); @@ -93,6 +101,21 @@ $(window).on("load", function() { loadMorePosts(userID, groupID, postAmount, postLimit); } }; + + $(document).keyup(function(e) { + if (e.keyCode == 27) { + closeModal(); + } + }); + + $('.modal').click(function() { + closeModal(); + }); + + $('.modal-content').click(function(event){ + event.stopPropagation(); + }); + }); // Hide modal view from the screen. diff --git a/website/public/js/post.js b/website/public/js/post.js index 4009023..4f77d4d 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -8,6 +8,8 @@ function postComment(buttonValue) { ).done(function (response) { if (response == "frozen") { alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is."); + } else if (response == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; } }); @@ -30,6 +32,8 @@ function deletePost(postID) { ).done(function (response) { if (response == "frozen") { alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is."); + } else if (response == "logged out") { + window.location.href = "login.php?url=" + window.location.pathname; } }); closeModal(); diff --git a/website/public/js/profile.js b/website/public/js/profile.js deleted file mode 100644 index e69de29..0000000 diff --git a/website/public/large.png b/website/public/large.png new file mode 100644 index 0000000..9cea22c Binary files /dev/null and b/website/public/large.png differ diff --git a/website/public/launcher-icon-0-75x.png b/website/public/launcher-icon-0-75x.png new file mode 100644 index 0000000..edd99ed Binary files /dev/null and b/website/public/launcher-icon-0-75x.png differ diff --git a/website/public/launcher-icon-1-5x.png b/website/public/launcher-icon-1-5x.png new file mode 100644 index 0000000..ab6b967 Binary files /dev/null and b/website/public/launcher-icon-1-5x.png differ diff --git a/website/public/launcher-icon-1x.png b/website/public/launcher-icon-1x.png new file mode 100644 index 0000000..38b5d8a Binary files /dev/null and b/website/public/launcher-icon-1x.png differ diff --git a/website/public/launcher-icon-2x.png b/website/public/launcher-icon-2x.png new file mode 100644 index 0000000..8663ef5 Binary files /dev/null and b/website/public/launcher-icon-2x.png differ diff --git a/website/public/launcher-icon-3x.png b/website/public/launcher-icon-3x.png new file mode 100644 index 0000000..f9e07be Binary files /dev/null and b/website/public/launcher-icon-3x.png differ diff --git a/website/public/launcher-icon-4x.png b/website/public/launcher-icon-4x.png new file mode 100644 index 0000000..fef4035 Binary files /dev/null and b/website/public/launcher-icon-4x.png differ diff --git a/website/public/login.php b/website/public/login.php index 726d530..57e9af7 100644 --- a/website/public/login.php +++ b/website/public/login.php @@ -13,18 +13,12 @@ ?> - window.onload=checkLoggedIn(); - "; - } include("../views/homeLoginRegister.php"); /* This view adds login view */ include("../views/login-view.php"); ?> +; diff --git a/website/public/manifest.json b/website/public/manifest.json new file mode 100755 index 0000000..9fcd94d --- /dev/null +++ b/website/public/manifest.json @@ -0,0 +1,44 @@ +{ + "name": "Web Application Manifest Sample", + "icons": [ + { + "src": "launcher-icon-0-75x.png", + "sizes": "36x36", + "type": "image/png", + "density": "0.75" + }, + { + "src": "launcher-icon-1x.png", + "sizes": "48x48", + "type": "image/png", + "density": "1.0" + }, + { + "src": "launcher-icon-1-5x.png", + "sizes": "72x72", + "type": "image/png", + "density": "1.5" + }, + { + "src": "launcher-icon-2x.png", + "sizes": "96x96", + "type": "image/png", + "density": "2.0" + }, + { + "src": "launcher-icon-3x.png", + "sizes": "144x144", + "type": "image/png", + "density": "3.0" + }, + { + "src": "launcher-icon-4x.png", + "sizes": "192x192", + "type": "image/png", + "density": "4.0" + } + ], + "start_url": "index.html", + "display": "standalone", + "orientation": "portrait" +} \ No newline at end of file diff --git a/website/public/profile.php b/website/public/profile.php index 126c87f..899c9bd 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -25,7 +25,8 @@ if(empty($_GET["username"])) { $userID = getUserID($_GET["username"]); } -if(!$user = selectUser($_SESSION["userID"], $userID)) { + +if (isset($_SESSION["userID"]) and !$user = selectUser($_SESSION["userID"], $userID)) { header("HTTP/1.0 404 Not Found"); header("Location: error/404.php"); die(); 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/settings.php b/website/public/settings.php index 9247d26..7208141 100644 --- a/website/public/settings.php +++ b/website/public/settings.php @@ -14,6 +14,8 @@ getClass(); diff --git a/website/public/square.png b/website/public/square.png new file mode 100644 index 0000000..6ef2732 Binary files /dev/null and b/website/public/square.png differ diff --git a/website/public/styles/adminpanel.css b/website/public/styles/adminpanel.css index 39d823f..d04d8fa 100644 --- a/website/public/styles/adminpanel.css +++ b/website/public/styles/adminpanel.css @@ -1,11 +1,13 @@ -.admin-panel { - min-width: 800px; -} .admin-panel input[type="radio"], input[type="checkbox"] { vertical-align: middle; - height: 28px; - margin: 2px; + height: 14px; + width: 14px; + margin: 7px; +} + +.table-checkbox { + width: 28px; } .admin-searchform { @@ -34,13 +36,15 @@ width: 100%; } -.usertable .table-username {width: 150px} -.usertable .table-status {width: 100px} -.usertable .table-action {width: 200px} +.table-checkbox {width: 20px} +.table-username {width: 150px} +.table-status {width: 100px} +.table-action {width: 200px} .usertable th, td { border-bottom: 1px solid #ddd; padding: 3px; + word-wrap: break-word; } .usertable th, tr { @@ -51,6 +55,10 @@ background-color: #f5f5f5; } +.bancomment { + width: 80%; +} + .bancommentedit { display: none; } 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/public/styles/main.css b/website/public/styles/main.css index 650a30f..5bb7b1d 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -256,8 +256,6 @@ div[data-title]:hover:after { top: 150%; z-index: 200; white-space: nowrap; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; border-radius: 3px; box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22); background-color: #333; diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 24badcb..e82129b 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -91,17 +91,5 @@ .deleteButton { background-color: firebrick; - -} - -.deleteButton i { - display: inline-block; -} - -.deleteButton:hover span { - display: inline-block; -} - -.deleteButton span { - display: none; + float: right; } \ No newline at end of file diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 27ff7fd..8a93d12 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -27,14 +27,22 @@ 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; - width: 200px; font-size: 18px; } +.status-buttons-container button { + float: left; +} .group-button-container button { float: right; @@ -71,9 +79,24 @@ .group-picture { border: none; - margin-right: 15px; } +.fancy-button span { + display: none; +} + +.fancy-button:hover { + text-align: right; +} + +.fancy-button i { + display: inline-block; +} + +.fancy-button:hover span { + display: inline-block; + margin-right: 5px; +} /* Old */ diff --git a/website/public/tiny.png b/website/public/tiny.png new file mode 100644 index 0000000..971db99 Binary files /dev/null and b/website/public/tiny.png differ diff --git a/website/public/wide.png b/website/public/wide.png new file mode 100644 index 0000000..6ba43b6 Binary files /dev/null and b/website/public/wide.png differ diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 69274ce..03f7b48 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -41,7 +41,11 @@ function checkInputChoice($variable, $option){ } } -/* Checks for only letters and spaces. */ +/** + * Checks for only letters and spaces. + * @param $variable + * @throws lettersAndSpacesException + */ function checkName($variable){ if (empty($variable)) { throw new lettersAndSpacesException("Verplicht!"); @@ -52,7 +56,11 @@ function checkName($variable){ } } -/* Checks for bday */ +/** + * Checks for bday + * @param $variable + * @throws bdayException + */ function validateBday($variable){ if (empty($variable)) { throw new bdayException("Verplicht!"); @@ -68,7 +76,7 @@ function validateBday($variable){ } } -// Checks for date +/* Checks for date */ function validateDate($date, $format) { $d = DateTime::createFromFormat($format, $date); @@ -124,7 +132,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 +146,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 +162,6 @@ function resetEmail($variable){ } } - /* checks if two passwords matches. */ function matchPassword(){ if ($_POST["password"] != $_POST["confirmpassword"]) { @@ -216,9 +224,13 @@ function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); + $data = trim($data); return $data; } +/** + * Class lettersAndSpacesException + */ class lettersAndSpacesException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -227,7 +239,9 @@ class lettersAndSpacesException extends Exception } } - +/** + * Class bdayException + */ class bdayException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -236,6 +250,9 @@ class bdayException extends Exception } } +/** + * Class usernameException + */ class usernameException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -244,6 +261,9 @@ class usernameException extends Exception } } +/** + * Class passwordException + */ class passwordException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -252,6 +272,9 @@ class passwordException extends Exception } } +/** + * Class confirmPasswordException + */ class confirmPasswordException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -260,6 +283,9 @@ class confirmPasswordException extends Exception } } +/** + * Class fbConfirmPasswordException + */ class fbConfirmPasswordException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -268,6 +294,9 @@ class fbConfirmPasswordException extends Exception } } +/** + * Class emailException + */ class emailException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -276,6 +305,9 @@ class emailException extends Exception } } +/** + * Class confirmEmailException + */ class confirmEmailException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -284,6 +316,9 @@ class confirmEmailException extends Exception } } +/** + * Class captchaException + */ class captchaException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) @@ -292,6 +327,9 @@ class captchaException extends Exception } } +/** + * Class registerException + */ class registerException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) diff --git a/website/queries/connect.php b/website/queries/connect.php index 3971a74..30ce271 100644 --- a/website/queries/connect.php +++ b/website/queries/connect.php @@ -10,6 +10,11 @@ else { or die('Error connecting to mysql server'); } +/** + * Helperfunction to create a database query. + * @param string $query + * @return PDOStatement + */ function prepareQuery(string $query) : PDOStatement { return $GLOBALS["db"]->prepare($query); } \ No newline at end of file diff --git a/website/queries/createGroup.php b/website/queries/createGroup.php new file mode 100644 index 0000000..84843d2 --- /dev/null +++ b/website/queries/createGroup.php @@ -0,0 +1,44 @@ +bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $createGroup->bindValue(':description', test_input($_POST["bio"])); + $createGroup->execute(); + + // Gets the groupID just created. + $getGroupID = prepareQuery(" + SELECT + `groupID` + FROM + `group_page` + WHERE + `name` LIKE :name"); + $getGroupID->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR); + $getGroupID->execute(); + $groupID = $getGroupID->fetch()["groupID"]; + + // Adds the user as an admin. + $makeUserAdmin = prepareQuery(" + INSERT INTO + `group_member` (userID, groupID, role) + VALUES (:userID, :groupID, 'admin') + "); + $makeUserAdmin->bindValue(":userID", $_SESSION["userID"]); + $makeUserAdmin->bindValue("groupID", $groupID); + $makeUserAdmin->execute(); + + updateAvatar($groupID); +} \ No newline at end of file diff --git a/website/queries/emailconfirm.php b/website/queries/emailconfirm.php index 0e6aab1..ff9c672 100644 --- a/website/queries/emailconfirm.php +++ b/website/queries/emailconfirm.php @@ -1,5 +1,8 @@ fetchAll()); } - +/** + * Selects all friends of a user. + * @param $userID + * @return PDOStatement + */ function selectAllFriends($userID) { $stmt = prepareQuery(" SELECT @@ -83,6 +98,10 @@ function selectAllFriends($userID) { return $stmt; } +/** + * Returns all friend requests of the current user. + * @return string + */ function selectAllFriendRequests() { $stmt = prepareQuery(" SELECT @@ -119,6 +138,11 @@ function selectAllFriendRequests() { return json_encode($stmt->fetchAll()); } +/** + * Gets the friendship status from current user and userID. + * @param $userID + * @return int + */ function getFriendshipStatus($userID) { # -2: Query failed. # -1: user1 and 2 are the same user @@ -162,6 +186,11 @@ function getFriendshipStatus($userID) { return intval($stmt->fetch()["friend_state"]); } +/** + * Request friendship from current user to target user. + * @param $userID + * @return bool + */ function requestFriendship($userID) { $stmt = prepareQuery(" INSERT INTO `friendship` (user1ID, user2ID) @@ -173,6 +202,11 @@ function requestFriendship($userID) { return $stmt->execute(); } +/** + * Removes friendship between current and target user. + * @param $userID + * @return bool + */ function removeFriendship($userID) { $stmt = prepareQuery(" DELETE FROM `friendship` @@ -189,6 +223,11 @@ function removeFriendship($userID) { return $stmt->execute(); } +/** + * Sets the friendship between current and target user to accepted. + * @param $userID + * @return bool + */ function acceptFriendship($userID) { $stmt = prepareQuery(" UPDATE `friendship` @@ -204,6 +243,11 @@ function acceptFriendship($userID) { return $stmt->execute(); } +/** + * Sets the last time the user visited the chat with specified friend. + * @param $friend + * @return PDOStatement + */ function setLastVisited($friend) { $stmt = prepareQuery(" UPDATE @@ -234,6 +278,13 @@ function setLastVisited($friend) { return $stmt; } +/** + * Searches m friends from n filtered by search. + * @param $n + * @param $m + * @param $search + * @return string + */ function searchSomeFriends($n, $m, $search) { $stmt = prepareQuery(" SELECT @@ -281,6 +332,11 @@ function searchSomeFriends($n, $m, $search) { return json_encode($stmt->fetchAll()); } +/** + * Counts all friends of current user filtered by search. + * @param $search + * @return string + */ function countSomeFriends($search) { $stmt = prepareQuery(" SELECT diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php new file mode 100644 index 0000000..6240009 --- /dev/null +++ b/website/queries/groupAdmin.php @@ -0,0 +1,192 @@ +bindParam(":groupID", $groupID); + $stmt->execute(); + return $stmt->fetch(); +} + +/** + * Updates the settings for a group. + * @param int $groupID + * @throws AngryAlert + * @throws HappyAlert + */ +function updateGroupSettings(int $groupID) +{ + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Je hebt geen rechten in deze groep"); + } + $stmt = prepareQuery(" + UPDATE + `group_page` + SET + `name` = :name, + `description` = :bio + WHERE + `groupID` = :groupID + "); + $stmt->bindValue(":bio", test_input($_POST["bio"])); + $stmt->bindValue(":name", test_input($_POST["name"])); + $stmt->bindValue(":groupID", test_input($_POST["groupID"])); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Groep aangepast!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } +} + +/** + * Checks if a user is an admin for a page. + * @param int $groupID + * @param int $userID + * @return bool + */ +function checkGroupAdmin(int $groupID, int $userID) : bool { + $stmt = prepareQuery(" + SELECT + `role` + FROM + `group_member` + WHERE + `groupID` = :groupID AND + `userID` = :userID + "); + $stmt->bindValue(":userID", $userID); + $stmt->bindValue(":groupID", $groupID); + $stmt->execute(); + if (!$stmt->rowCount()) { + return false; + } + $role = $stmt->fetch()["role"]; + return ($role == "admin"); +} + +/** + * Returns all normal members for a group. + * @param int $groupID + * @return array|bool + */ +function getAllGroupUsers(int $groupID) { + return getAllGroupMembers($groupID, 'member'); +} + +/** + * Returns all admin for a group. + * @param int $groupID + * @return array|bool + */ +function getAllGroupAdmins(int $groupID) { + return getAllGroupMembers($groupID, 'admin'); +} + +/** + * Returns all Moderators for a group. + * @param int $groupID + * @return array|bool + */ +function getAllGroupMods(int $groupID) { + return getAllGroupMembers($groupID, 'mod'); +} + +/** + * Returns all members for a group specified by a string. + * @param int $groupID + * @param string $role + * @return array|bool + */ +function getAllGroupMembers(int $groupID, string $role) { + $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` = :role + "); + + $stmt->bindParam(':groupID', $groupID); + $stmt->bindParam(":role", $role); + if (!$stmt->execute()) { + return False; + } + return $stmt->fetchAll(); +} + +/** + * Upgrades or downgrades a groupmember to a different role. + * @param int $groupID + * @param int $userID + * @param string $role + * @throws AngryAlert + * @throws HappyAlert + */ +function upgradeUser(int $groupID, int $userID, string $role) { + if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { + throw new AngryAlert("Geen toestemming om te wijzigen"); + } + + $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"); + } +} + +/** + * Removes a group form the database. + * @throws AngryAlert + * @throws HappyAlert + */ +function deleteGroup() { + if (!checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { + throw new AngryAlert("Geen toestemming om de groep te verwijderen!"); + } + $stmt = prepareQuery(" + DELETE FROM + `group_page` + WHERE + `groupID` = :groupID + "); + $stmt->bindValue(":groupID", $_POST["groupID"]); + $stmt->execute(); + if ($stmt->rowCount()) { + throw new HappyAlert("Group verwijderd!"); + } else { + throw new AngryAlert("Er is iets mis gegaan"); + } +} \ No newline at end of file diff --git a/website/queries/group_member.php b/website/queries/group_member.php index 7844235..4c23540 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -1,9 +1,20 @@ fetchAll()); } +/** + * Returns m groups offset by n filtered by search that the current user is part of. + * @param $n + * @param $m + * @param $search + * @return string + */ function searchSomeOwnGroups($n, $m, $search) { $stmt = prepareQuery(" SELECT @@ -55,6 +73,11 @@ function searchSomeOwnGroups($n, $m, $search) { return json_encode($stmt->fetchAll()); } +/** + * Counts all groups filtered by search that the current user is member of. + * @param $search + * @return string + */ function countSomeOwnGroups($search) { $stmt = prepareQuery(" SELECT @@ -78,6 +101,13 @@ function countSomeOwnGroups($search) { return $stmt->fetchColumn(); } +/** + * Adds a user by userID to a group by groupID with a specified role. + * @param $groupID + * @param $userID + * @param $role + * @return bool + */ function addMember($groupID, $userID, $role) { $stmt = prepareQuery(" INSERT INTO @@ -92,6 +122,13 @@ function addMember($groupID, $userID, $role) { return $stmt->execute(); } +/** + * Changes te role of a user within a group to the specified one. + * @param $groupID + * @param $userID + * @param $role + * @return bool + */ function changeMember($groupID, $userID, $role) { $stmt = prepareQuery(" UPDATE @@ -109,6 +146,12 @@ function changeMember($groupID, $userID, $role) { return $stmt->execute(); } +/** + * Removes a user from a group. + * @param $groupID + * @param $userID + * @return bool + */ function deleteMember($groupID, $userID) { $stmt = prepareQuery(" DELETE FROM diff --git a/website/queries/group_page.php b/website/queries/group_page.php index a6676c4..bf992de 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -2,6 +2,10 @@ require_once("connect.php"); +/** + * Selects some info from a group by name. + * @return bool|mixed + */ function selectGroupByName($name) { $stmt = prepareQuery(" SELECT @@ -41,6 +45,11 @@ function selectGroupByName($name) { return $row; } +/** + * Selects the current user's role within a group by the group's ID. + * @param int $groupID + * @return bool|string + */ function selectGroupRole(int $groupID) { $stmt = prepareQuery(" SELECT @@ -63,6 +72,11 @@ function selectGroupRole(int $groupID) { return $stmt->fetch()["role"]; } +/** + * Returns the status of a group by it's ID. + * @param int $groupID + * @return bool + */ function selectGroupStatus(int $groupID) { $stmt = prepareQuery(" SELECT @@ -80,6 +94,11 @@ function selectGroupStatus(int $groupID) { return $stmt->fetch()["status"]; } +/** + * Returns some info of all group members. + * @param int $groupID + * @return bool|PDOStatement + */ function selectGroupMembers(int $groupID) { $stmt = prepareQuery(" SELECT @@ -105,9 +124,14 @@ function selectGroupMembers(int $groupID) { if (!$stmt->execute()) { return False; } - return $stmt->fetchAll(); + return $stmt; } +/** + * Returns group info by it's ID. + * @param $groupID + * @return PDOStatement + */ function selectGroupById($groupID) { $q = prepareQuery(" SELECT @@ -127,6 +151,11 @@ function selectGroupById($groupID) { return $q; } +/** + * Returns some info of 20 groups offset by n. + * @param $n + * @return PDOStatement + */ function select20GroupsFromN($n) { $q = prepareQuery(" SELECT @@ -149,6 +178,12 @@ function select20GroupsFromN($n) { return $q; } +/** + * Returns info of 20 groups offset by n, filtered by status. + * @param $n + * @param $status + * @return PDOStatement + */ function select20GroupsByStatusFromN($n, $status) { $q = prepareQuery(" SELECT @@ -174,6 +209,13 @@ function select20GroupsByStatusFromN($n, $status) { return $q; } +/** + * Returns info of 20 groups offset by n, filtered by status, filtered by search. + * @param $n + * @param $keyword + * @param $status + * @return PDOStatement + */ function search20GroupsFromNByStatus($n, $keyword, $status) { $q = prepareQuery(" SELECT @@ -201,6 +243,14 @@ function search20GroupsFromNByStatus($n, $keyword, $status) { return $q; } +/** + * Returns info of n groups offset by m, filtered by status and search. + * @param $n + * @param $m + * @param $search + * @param $status + * @return PDOStatement + */ function searchSomeGroupsByStatus($n, $m, $search, $status) { // parentheses not needed in where clause, for clarity as // role search should override status filter. @@ -233,6 +283,12 @@ function searchSomeGroupsByStatus($n, $m, $search, $status) { return $q; } +/** + * Count all groups filtered by status and search. + * @param $search + * @param $status + * @return PDOStatement + */ function countSomeGroupsByStatus($search, $status) { $q = prepareQuery(" SELECT @@ -256,6 +312,12 @@ function countSomeGroupsByStatus($search, $status) { return $q; } +/** + * Changes the status of a group with the given ID. + * @param $id + * @param $status + * @return PDOStatement + */ function changeGroupStatusByID($id, $status) { $q = prepareQuery(" UPDATE @@ -272,6 +334,12 @@ function changeGroupStatusByID($id, $status) { return $q; } +/** + * Changes the status of multiple groups to 1 status by an array of IDs. + * @param $ids + * @param $status + * @return PDOStatement + */ function changeMultipleGroupStatusByID($ids, $status) { $q = prepareQuery(" UPDATE @@ -289,6 +357,13 @@ function changeMultipleGroupStatusByID($ids, $status) { return $q; } +/** + * Returns m groups offset by n, filtered by search. + * @param $n + * @param $m + * @param $search + * @return string + */ function searchSomeGroups($n, $m, $search) { $stmt = prepareQuery(" SELECT @@ -312,6 +387,11 @@ function searchSomeGroups($n, $m, $search) { return json_encode($stmt->fetchAll()); } +/** + * Counts all group filtered by search. + * @param $search + * @return PDOStatement + */ function countSomeGroups($search) { $stmt = prepareQuery(" SELECT diff --git a/website/queries/login.php b/website/queries/login.php index 4dad5c5..c9305aa 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -1,5 +1,9 @@ fetch(PDO::FETCH_ASSOC); } -function validateLogin($username, $password){ - // Empty username or password field +function validateLogin($username, $password, $url){ + // Empty username or password field if (empty($username) || empty($password)) { throw new loginException("Inloggegevens zijn niet ingevuld"); } @@ -44,26 +48,42 @@ function validateLogin($username, $password){ $userID = getUser()["userID"]; $role = getUser()["role"]; - // If there's an account, go to the profile page + // If there's an account, check if the account is banned, frozen or unconfirmed. if(password_verify($psw, $hash)) { if ($role == "banned"){ echo ""; - } else if ($role == "frozen"){ + + } else if ($role == "frozen") { $_SESSION["userID"] = $userID; + if (!isset($url) or $url = "") { echo ""; + } else { + echo ""; + } + } else if ($role == "unconfirmed"){ sendConfirmEmail(getUser()["userID"]); echo ""; + } else { $_SESSION["userID"] = $userID; - header("location: profile.php"); + if(!isset($url) or $url == "") { + header("location: profile.php"); + echo "succes"; + } else{ + header("location: ".$url); + } + } } else { throw new loginException("Inloggevens zijn niet correct"); diff --git a/website/queries/nicetime.php b/website/queries/nicetime.php index e2e509e..3881cc7 100644 --- a/website/queries/nicetime.php +++ b/website/queries/nicetime.php @@ -1,9 +1,16 @@ $unix_date) { + // Check if it is in the future or not. + if($now >= $unix_date) { $difference = $now - $unix_date; $tense = "geleden"; } else { @@ -23,6 +31,7 @@ function nicetime($date) { $tense = "vanaf nu"; } + // Get the nice time. for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) { $difference /= $lengths[$i]; } diff --git a/website/queries/picture.php b/website/queries/picture.php index 8e99d9a..9c92540 100644 --- a/website/queries/picture.php +++ b/website/queries/picture.php @@ -6,7 +6,10 @@ * @throws AngryAlert * @throws HappyAlert */ -function updateAvatar(bool $group = false) { +function updateAvatar(int $group = 0) { + if (!array_key_exists("pp", $_FILES)) { + throw new AngryAlert("Geen afbeelding meegegeven!"); + } $publicDir = "/var/www/html/public/"; $tmpImg = $_FILES["pp"]["tmp_name"]; $avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/"; @@ -16,17 +19,17 @@ function updateAvatar(bool $group = false) { if ($_FILES["pp"]["size"] > 4000000) { throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan."); } - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif"; - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif"; + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); move_uploaded_file($tmpImg, $publicDir . $relativePath); } else { - $relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png"; + $relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png"; $scaledImg = scaleAvatar($tmpImg); - $group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar(); + $group ? removeOldGroupAvatar($group) : removeOldUserAvatar(); imagepng($scaledImg, $publicDir . $relativePath); } - $group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath); + $group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath); throw new HappyAlert("Profielfoto veranderd."); } diff --git a/website/queries/post.php b/website/queries/post.php index ecc5c48..5cd6354 100644 --- a/website/queries/post.php +++ b/website/queries/post.php @@ -2,6 +2,12 @@ require_once("connect.php"); +/** + * Select all posts on a user. + * @param $userID + * @param $groupID + * @return bool|PDOStatement + */ function selectAllPosts($userID, $groupID) { $stmt = prepareQuery(" SELECT @@ -46,6 +52,14 @@ function selectAllPosts($userID, $groupID) { } +/** + * Select $limit posts from $offset from a user or group. + * @param $userID + * @param $groupID + * @param $offset + * @param $limit + * @return bool|PDOStatement + */ function selectSomePosts($userID, $groupID, $offset, $limit) { $stmt = prepareQuery(" SELECT @@ -94,9 +108,13 @@ function selectSomePosts($userID, $groupID, $offset, $limit) { return False; } return $stmt; - } +/** + * Select all the post information from an postID. + * @param $postID + * @return PDOStatement + */ function selectPostById($postID) { $stmt = prepareQuery(" SELECT @@ -122,6 +140,11 @@ function selectPostById($postID) { return $stmt; } +/** + * Get all the comments from a post. + * @param $postID + * @return PDOStatement + */ function selectCommentsByPostId($postID) { $stmt = prepareQuery(" SELECT @@ -148,6 +171,13 @@ function selectCommentsByPostId($postID) { return $stmt; } +/** + * Insert a post to a group or user + * @param $userID + * @param $groupID + * @param $title + * @param $content + */ function makePost($userID, $groupID, $title, $content) { $stmt = prepareQuery(" INSERT INTO @@ -172,6 +202,13 @@ function makePost($userID, $groupID, $title, $content) { $stmt->execute(); } +/** + * Insert a comment by a post. + * @param $postID + * @param $userID + * @param $content + * @return int + */ function makeComment($postID, $userID, $content) : int { $stmt = prepareQuery(" INSERT INTO @@ -194,6 +231,12 @@ function makeComment($postID, $userID, $content) : int { return $stmt->rowCount(); } +/** + * If a post already is niet slechted. + * @param int $postID + * @param int $userID + * @return int + */ function makeNietSlecht(int $postID, int $userID) : int { if (checkNietSlecht($postID, $userID)) { return deleteNietSlecht($postID, $userID); @@ -202,6 +245,12 @@ function makeNietSlecht(int $postID, int $userID) : int { } } +/** + * Toggle a niet slecht of a post. + * @param int $postID + * @param int $userID + * @return int + */ function checkNietSlecht(int $postID, int $userID) { $stmt = prepareQuery(" SELECT @@ -218,6 +267,12 @@ function checkNietSlecht(int $postID, int $userID) { return $stmt->rowCount(); } +/** + * Add a niet slecht to a post. + * @param int $postID + * @param int $userID + * @return int + */ function addNietSlecht(int $postID, int $userID) { $stmt = prepareQuery(" INSERT INTO @@ -230,6 +285,12 @@ function addNietSlecht(int $postID, int $userID) { return $stmt->rowCount(); } +/** + * Delete a niet slecht. + * @param int $postID + * @param int $userID + * @return int + */ function deleteNietSlecht(int $postID, int $userID) { $stmt = prepareQuery(" DELETE FROM @@ -244,6 +305,11 @@ function deleteNietSlecht(int $postID, int $userID) { return $stmt->rowCount(); } +/** + * Delete a post + * @param int $postID + * @param int $userID + */ function deletePost(int $postID, int $userID) { if (checkPermissionOnPost($postID, $userID)) { $stmt = prepareQuery(" @@ -257,6 +323,12 @@ function deletePost(int $postID, int $userID) { } } +/** + * Check if a user has premissions to delete a post. + * @param int $postID + * @param int $userID + * @return bool + */ function checkPermissionOnPost(int $postID, int $userID) : bool { $getGroupID = prepareQuery(" SELECT @@ -281,6 +353,12 @@ function checkPermissionOnPost(int $postID, int $userID) : bool { } } +/** + * Returns role of a user. + * @param int $userID + * @param int $groupID + * @return mixed role of a user. + */ function getRoleInGroup(int $userID, int $groupID) { $stmt = prepareQuery(" SELECT diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 3b88563..de18144 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -1,23 +1,33 @@ bindParam(":user1", $user1ID); @@ -31,6 +41,12 @@ function getOldChatMessages($user2ID) { } } +/** + * Send a chat message. + * @param $destination + * @param $content + * @return bool + */ function sendMessage($destination, $content) { require_once("friendship.php"); if (getFriendshipStatus($destination) == 1) { @@ -60,6 +76,12 @@ function sendMessage($destination, $content) { } } +/** + * Get all the chat messages after an messageID ($lastID). + * @param $lastID + * @param $destination + * @return string + */ function getNewChatMessages($lastID, $destination) { require_once("friendship.php"); if (getFriendshipStatus($destination) == 1) { @@ -76,7 +98,7 @@ function getNewChatMessages($lastID, $destination) { `destination` = :user1) AND `messageID` > :lastID ORDER BY - `creationdate` ASC + `messageID` ASC "); $stmt->bindParam(':user1', $_SESSION["userID"]); @@ -91,7 +113,10 @@ function getNewChatMessages($lastID, $destination) { } } - +/** + * Get of every friend the first unread chat message. + * @return string + */ function selectAllUnreadChat() { $stmt = prepareQuery(" SELECT diff --git a/website/queries/settings.php b/website/queries/settings.php index 9b17d17..6d6dc74 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -16,7 +16,10 @@ function getSettings() { `location`, `birthdate`, `bio`, - `profilepicture`, + IFNULL( + `profilepicture`, + '../img/avatar-standard.png' + ) AS profilepicture, `showBday`, `showEmail`, `showProfile` @@ -148,6 +151,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 +171,11 @@ function changeEmail() { } } +/** + * Checks if an emailadres is available in the database. + * @param $email + * @throws AngryAlert + */ function emailIsAvailableInDatabase($email) { $stmt = prepareQuery(" SELECT @@ -181,6 +193,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/queries/user.php b/website/queries/user.php index 422edc4..044b480 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -2,6 +2,10 @@ require_once ("connect.php"); +/** + * This sets the last activity of the session user to now. + * @return bool, true is it ran correctly + */ function updateLastActivity() { $stmt = prepareQuery(" UPDATE @@ -15,6 +19,11 @@ function updateLastActivity() { return $stmt->execute(); } +/** + * This gets the userID from a username + * @param $username + * @return mixed + */ function getUserID($username) { $stmt = prepareQuery(" SELECT @@ -30,6 +39,11 @@ function getUserID($username) { return $stmt->fetch()["userID"]; } +/** + * This gets the username from a userID + * @param $userID + * @return mixed + */ function getUsername($userID) { $stmt = prepareQuery(" SELECT @@ -45,6 +59,12 @@ function getUsername($userID) { return $stmt->fetch()["username"]; } +/** + * This selects the information about the other user and the connection between the two. + * @param $me + * @param $other + * @return bool|mixed + */ function selectUser($me, $other) { $stmt = prepareQuery(" SELECT @@ -107,6 +127,11 @@ function selectUser($me, $other) { return $stmt->fetch(); } +/** + * Select all the users from a group. + * @param $userID + * @return PDOStatement + */ function selectAllUserGroups($userID) { $stmt = prepareQuery(" SELECT @@ -130,6 +155,11 @@ function selectAllUserGroups($userID) { return $stmt; } +/** + * Selects 20 users from a given point in the table, ordered by role and name + * @param $n + * @return PDOStatement + */ function select20UsersFromN($n) { $q = prepareQuery(" SELECT @@ -155,6 +185,12 @@ function select20UsersFromN($n) { return $q; } +/** + * Search 20 users from a given point in the table, ordered by role and name + * @param $n + * @param $keyword + * @return PDOStatement + */ function search20UsersFromN($n, $keyword) { $q = prepareQuery(" SELECT @@ -183,6 +219,13 @@ function search20UsersFromN($n, $keyword) { return $q; } +/** + * Search 20 users from a given point in the database where the status @param $status + * @param $n + * @param $keyword + * @param $status + * @return PDOStatement + */ function search20UsersFromNByStatus($n, $keyword, $status) { $q = prepareQuery(" SELECT @@ -215,6 +258,14 @@ function search20UsersFromNByStatus($n, $keyword, $status) { return $q; } +/** + * Search users from a given point in the database where the status @param $status + * @param $n + * @param $m + * @param $search + * @param $status + * @return PDOStatement + */ function searchSomeUsersByStatus($n, $m, $search, $status) { // parentheses not needed in where clause, for clarity as // role search should override status filter. @@ -252,6 +303,12 @@ function searchSomeUsersByStatus($n, $m, $search, $status) { return $q; } +/** + * Count the users with a name like $search and a $status + * @param $search + * @param $status + * @return PDOStatement + */ function countSomeUsersByStatus($search, $status) { $q = prepareQuery(" SELECT @@ -276,7 +333,12 @@ function countSomeUsersByStatus($search, $status) { return $q; } - +/** + * Change the user status + * @param $id + * @param $status + * @return PDOStatement + */ function changeUserStatusByID($id, $status) { $q = prepareQuery(" UPDATE @@ -293,6 +355,12 @@ function changeUserStatusByID($id, $status) { return $q; } +/** + * Change multiple user statuses by an id array. + * @param $ids + * @param $status + * @return PDOStatement + */ function changeMultipleUserStatusByID($ids, $status) { $q = prepareQuery(" UPDATE @@ -310,6 +378,13 @@ function changeMultipleUserStatusByID($ids, $status) { return $q; } +/** + * Change multiple user statuses by an id array. + * This excludes that admins and owners statuses can be changed. + * @param $ids + * @param $status + * @return PDOStatement + */ function changeMultipleUserStatusByIDAdmin($ids, $status) { $q = prepareQuery(" UPDATE @@ -329,6 +404,11 @@ function changeMultipleUserStatusByIDAdmin($ids, $status) { return $q; } +/** + * Select a random user that is nog your friend. + * @param $userID + * @return mixed + */ function selectRandomNotFriendUser($userID) { $stmt = prepareQuery(" SELECT @@ -357,6 +437,13 @@ function selectRandomNotFriendUser($userID) { return $stmt->fetch(); } +/** + * Search users. + * @param $n + * @param $m + * @param $search + * @return string + */ function searchSomeUsers($n, $m, $search) { $stmt = prepareQuery(" SELECT @@ -397,6 +484,11 @@ function searchSomeUsers($n, $m, $search) { return json_encode($stmt->fetchAll()); } +/** + * Count the users that you get searching for a user with a keyword. + * @param $search + * @return PDOStatement + */ function countSomeUsers($search) { $q = prepareQuery(" SELECT @@ -420,6 +512,11 @@ function countSomeUsers($search) { return $q; } +/** + * Get the role of a user by userID. + * @param $userID + * @return mixed + */ function getRoleByID($userID) { $stmt = prepareQuery(" SELECT @@ -435,6 +532,11 @@ function getRoleByID($userID) { return $stmt->fetch()["role"]; } +/** + * Edit the ban comment. + * @param $userID + * @param $comment + */ function editBanCommentByID($userID, $comment) { $stmt = prepareQuery(" UPDATE diff --git a/website/views/adminpanel-grouptable.php b/website/views/adminpanel-grouptable.php index 2449b3d..d30e2ba 100644 --- a/website/views/adminpanel-grouptable.php +++ b/website/views/adminpanel-grouptable.php @@ -3,7 +3,7 @@ Groepsnaam Status Beschrijving - Actie + Zichtbaarheid + - + Gebruikersnaam Status Aantekening diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index 2c0bec2..00e6bf5 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -1,5 +1,4 @@ - - + Maak Admin "; } ?> @@ -140,9 +139,9 @@ if (isset($_GET["groupstatus"])) { onsubmit="adminUpdate(this); return false;"> - - - + + + @@ -152,5 +151,3 @@ if (isset($_GET["groupstatus"])) { - - \ No newline at end of file diff --git a/website/views/createGroup.php b/website/views/createGroup.php new file mode 100644 index 0000000..736fc45 --- /dev/null +++ b/website/views/createGroup.php @@ -0,0 +1,42 @@ + + +
+
+
+
Maak een groep!
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+
diff --git a/website/views/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 @@
" - return= $correct method="post" name="fbModal"> @@ -66,17 +65,16 @@
- * +
- + 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 @@
" - return= $correct method="post" name="forgotPassword"> @@ -26,8 +25,7 @@
diff --git a/website/views/group.php b/website/views/group.php index b27f18c..287bd7f 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -1,6 +1,6 @@
- ">
+ <?= $group[" class="group-picture main-picture" src="">
@@ -16,9 +16,18 @@

Leden ()

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

diff --git a/website/views/groupAdmin.php b/website/views/groupAdmin.php new file mode 100644 index 0000000..d406e5c --- /dev/null +++ b/website/views/groupAdmin.php @@ -0,0 +1,168 @@ + +
+
+ +
+ +
+ +
+
    +
  • + + "> + + +
  • +
+
+ +
Groep Instellingen
+ "> +
    +
  • + + " + > +
  • +
  • + + + +
  • +
  • + + +
  • +
+ +
+
Verander groepsafbeelding.
+ "> +
    +
  • + + " + class="group-picture" + > +
  • +
  • + + +
  • +
  • + + +
  • +
+
+
+
Voeg een admin/mod toe
+
    + + " type="hidden"> + + + + + +
+
+
+
Verwijder een admin/mod
+
    + + " type="hidden"> + + + + +
+
+
+
    +
    Verwijder groep
    +
  • + + " type="hidden"> + +
  • +
+
+
+
    +
  • + + "> +
  • +
+
+
+
\ No newline at end of file diff --git a/website/views/head.php b/website/views/head.php index f831f5d..b774e8e 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,7 +1,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyHyvesbook+ @@ -26,8 +60,8 @@ require_once ("../queries/user.php"); session_start(); -if(!isset($_SESSION["userID"])){ - header("location:login.php"); +if(!isset($_SESSION["userID"])) { + header("location:login.php?url=" . "$_SERVER[REQUEST_URI]"); } else { updateLastActivity(); } diff --git a/website/views/header.php b/website/views/header.php index c1379fc..e13eca6 100644 --- a/website/views/header.php +++ b/website/views/header.php @@ -23,9 +23,9 @@ $userinfo = getHeaderInfo();
Hallo
- +
- "/> + <?= $userinfo[" id="own-profile-picture" class="profile-picture" src=""/>
diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index 54c2015..95b6c53 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -1,18 +1,26 @@ + window.onload=checkLoggedIn(); + "; +} // 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 = ""; @@ -26,7 +34,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { case "login": try { $user = ($_POST["user"]); - validateLogin($_POST["user"], $_POST["psw"]); + validateLogin($_POST["user"], $_POST["psw"], $_POST["url"]); } catch(loginException $e) { $loginErr = $e->getMessage(); } @@ -45,18 +53,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(); @@ -71,6 +83,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); @@ -79,13 +92,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"]; @@ -93,16 +107,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 " \ No newline at end of file +?> \ No newline at end of file diff --git a/website/views/login_head.php b/website/views/login_head.php index b4b2724..e8e3a84 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,8 +1,42 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyHyvesbook+
  • - + Maak een groep aan
  • diff --git a/website/views/post-view.php b/website/views/post-view.php index f8fe902..fadc791 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -5,14 +5,6 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . " ?>

    - -
    - gepost door , '> @@ -20,7 +12,14 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
    - + +
    +

    diff --git a/website/views/profile.php b/website/views/profile.php index 4139099..e9178f4 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -4,13 +4,19 @@
- " src="">
+ <?= $user[" class="profile-picture main-picture " src="">
- - +
+ +
+
+ +

:)

@@ -33,28 +39,33 @@

Informatie

-

-

    - -
  • Leeftijd: jaar
  • - - -
  • Email:
  • - -
  • Locatie:
  • -
  • Lid sinds:
  • -
-

+
    + +
  • Leeftijd: jaar
  • + + +
  • Email:
  • + +
  • Locatie:
  • +
  • Lid sinds:
  • +

Vrienden

fetch()) { - echo "${friend["username"]}"; + $friendcount = $profile_friends->rowCount(); + $frienddif = $friendcount - 7; + + for ($i = 0; $i < min($friendcount, 7); $i += 1) { + $friend = $profile_friends->fetch(); + echo "${friend["username"]}"; } + if ($frienddif > 0) { + echo $frienddif === 1 ? "en nog 1 andere." : "...en nog $frienddif anderen."; + } if($profile_friends->rowCount() === 0) { echo "

Deze gebruiker heeft nog geen vrienden gemaakt.

"; @@ -67,10 +78,18 @@

Groepen

fetch()) { + $groupcount = $profile_groups->rowCount(); + $groupdif = $groupcount - 7; + + for ($i = 0; $i < min($groupcount, 7); $i += 1) { + $group = $profile_groups->fetch(); echo "${group["name"]}s logo"; } + if ($groupdif > 0) { + echo $groupdif === 1 ? "en nog 1 andere." : "...en nog $groupdif anderen."; + } + if($profile_groups->rowCount() === 0) { echo "

Deze gebruiker is nog geen lid van een groep.

"; } diff --git a/website/public/register.php b/website/views/register.php similarity index 100% rename from website/public/register.php rename to website/views/register.php diff --git a/website/views/registerModal.php b/website/views/registerModal.php index 9ad48dc..b9f8d95 100644 --- a/website/views/registerModal.php +++ b/website/views/registerModal.php @@ -4,7 +4,6 @@
" - return= $correct method="post" name="forgotPassword"> @@ -15,14 +14,11 @@

Registreer uw account

- " - return= $correct - method="post">
-
+
@@ -82,7 +78,6 @@ placeholder="Voer uw wachtwoord in" name="password" value="" - id="password" required> *
    @@ -96,7 +91,6 @@ placeholder="Herhaal wachtwoord" name="confirmpassword" value="" - id="confirmpassword" title="Herhaal wachtwoord" required> * @@ -120,7 +114,6 @@ placeholder="Voer uw email in" name="email" value="" - id="email" title="Voer een geldige email in" required> * @@ -133,7 +126,6 @@ placeholder="Herhaal uw email" name="confirmEmail" value="" - id="email" title="Herhaal uw email" required> * @@ -152,8 +144,7 @@
diff --git a/website/views/settings-view.php b/website/views/settings-view.php index cf5317f..0800cc8 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -45,8 +45,8 @@ $settings = getSettings();
  • - - - - format("Y"); for ($year = $now; $year >= 1900; $year--): ?>