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/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/js/chat.js b/website/public/js/chat.js index a3ff430..f431b91 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -43,6 +43,8 @@ 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(); 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 47c476a..87222e9 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/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 a628e96..d43577b 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -26,7 +26,7 @@ function requestPost(postID) { function postPost() { title = $("input.newpost[name='title']").val(); content = $("textarea.newpost[name='content']").val(); - + console.log(masonryMode); if (masonryMode == 2) { $.post("API/postPost.php", { title: title, content : content, @@ -36,6 +36,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); @@ -49,6 +53,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); 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/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/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/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 541b52c..e82129b 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -91,16 +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 f6e545e..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 { @@ -74,22 +79,21 @@ .group-picture { border: none; - margin-right: 15px; } -.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/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 4dad5c5..3480991 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -1,5 +1,6 @@ fetch(PDO::FETCH_ASSOC); } -function validateLogin($username, $password){ +function validateLogin($username, $password, $url){ + echo $url; // Empty username or password field if (empty($username) || empty($password)) { throw new loginException("Inloggegevens zijn niet ingevuld"); @@ -44,26 +46,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/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"]); 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..250fc9f 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -1,6 +1,6 @@
- ">
+ <?= $group[" class="group-picture main-picture" src="">
diff --git a/website/views/head.php b/website/views/head.php index f831f5d..3ec8a79 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,5 +1,5 @@ - + MyHyvesbook+ @@ -26,8 +26,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..2e00905 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..9e580df 100644 --- a/website/views/login_head.php +++ b/website/views/login_head.php @@ -1,6 +1,6 @@ - + MyHyvesbook+ 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..0cb5cc2 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -4,13 +4,19 @@
- " src="">
+ <?= $user[" class="profile-picture main-picture " src="">
- - +
+ +
+
+ +

:)

@@ -33,18 +39,16 @@

Informatie

-

-

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

+
    + +
  • Leeftijd: jaar
  • + + +
  • Email:
  • + +
  • Locatie:
  • +
  • Lid sinds:
  • +
@@ -52,7 +56,7 @@

fetch()) { - echo "${friend["username"]}"; + echo "${friend["username"]}"; } 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--): ?>