diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b1c6649..241bda6 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -12,36 +12,39 @@ if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'frozen' && getRoleByID($_SESSION["userID"]) != 'banned') { - if (empty($_POST["title"]) or - empty($_POST["content"]) or - empty($_SESSION["userID"]) - ) { + if (empty($_SESSION["userID"])) { header('HTTP/1.1 500 Non enough arguments'); } - if (empty($_POST["group"])) { - // User Post - makePost( - $_SESSION["userID"], - null, - test_input($_POST["title"]), - test_input($_POST["content"]) - ); + if (empty(test_input($_POST["title"])) or + empty(test_input($_POST["content"])) + ) { + echo "empty"; } else { - // Group Post + if (empty($_POST["group"])) { + // User Post + makePost( + $_SESSION["userID"], + null, + test_input($_POST["title"]), + test_input($_POST["content"]) + ); + } else { + // Group Post - // Check if the user is an admin or mod of the group. - if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) { - header('HTTP/1.1 500 Non enough rights'); - return; + // Check if the user is an admin or mod of the group. + if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) { + header('HTTP/1.1 500 Non enough rights'); + return; + } + + makePost( + $_SESSION["userID"], + $_POST["group"], + test_input($_POST["title"]), + test_input($_POST["content"]) + ); } - - makePost( - $_SESSION["userID"], - $_POST["group"], - test_input($_POST["title"]), - test_input($_POST["content"]) - ); } } else { echo "frozen"; diff --git a/website/public/bits/niet-slecht.php b/website/public/bits/niet-slecht.php new file mode 100644 index 0000000..432fe41 --- /dev/null +++ b/website/public/bits/niet-slecht.php @@ -0,0 +1,8 @@ + +\"Niet slecht\" ons op MyHyvesbook+ diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 3f28c81..a3ff430 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -25,6 +25,9 @@ function loadMessages() { addMessages(messages); $("#lastID").val(messages[messages.length - 1].messageID); } + + loadUnreadMessages(); + gettingMessages = false; }); } else { @@ -56,7 +59,7 @@ function addMessages(messages) { for(var i in messages) { // Initialize message variables. var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); - var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); + var thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2); var type; thisDate.setHours(0,0,0,0); @@ -78,6 +81,8 @@ function addMessages(messages) { '; } previousDate = thisDate; + previousTime = thisTime; + previousType = type; messagesText += '
'; // If it is not the first message, and has a different date/time/type then the previous message, } else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) { diff --git a/website/public/js/main.js b/website/public/js/main.js index b6ab703..30cd3ed 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -31,7 +31,7 @@ function fancyText(text) { } // Add links else { - return "" + link + ""; + return "" + link + ""; } }); diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 190a26f..a628e96 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -31,14 +31,28 @@ function postPost() { $.post("API/postPost.php", { title: title, content : content, group : groupID }) - .done(function() { - masonry(masonryMode); + .done(function(data) { + if (data == "empty") { + $('#alertbox').show(); + $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); + window.scrollTo(0,0); + } else { + $('#alertbox').hide(); + masonry(masonryMode); + } }); } else { $.post("API/postPost.php", { title: title, content : content }) - .done(function() { - masonry(masonryMode); + .done(function(data) { + if (data == "empty") { + $('#alertbox').show(); + $('#alerttext').html("Geen titel of inhoud; vul a.u.b. in."); + window.scrollTo(0,0); + } else { + $('#alertbox').hide(); + masonry(masonryMode); + } }); } @@ -98,6 +112,10 @@ function masonry(mode) { masonryMode = mode; $container.children().remove(); + // reinit posts + noposts = false; + postAmount = 0; + /* * Initialise columns. */ @@ -153,9 +171,6 @@ function loadMorePosts(uID, gID, offset, limit) { return; } - console.log(uID, gID, offset, limit); - - $.post("API/getPosts.php", { usr : uID, grp : gID, offset : offset, diff --git a/website/public/settings.php b/website/public/settings.php index e40f042..9247d26 100644 --- a/website/public/settings.php +++ b/website/public/settings.php @@ -18,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { try { switch ($_POST["form"]) { case "profile": - updateSettings(); + checkUpdateSettings(); break; case "password": changePassword(); diff --git a/website/public/styles/index.css b/website/public/styles/index.css index 196485e..c7a0aa8 100644 --- a/website/public/styles/index.css +++ b/website/public/styles/index.css @@ -133,6 +133,12 @@ label { color: red; } +.login_containerNoscript { + padding: 4px; + text-align: center; + color: red; +} + @keyframes animatezoom { from {transform: scale(0)} to {transform: scale(1)} @@ -150,7 +156,7 @@ label { margin: 16px auto; overflow-y: auto; padding: 20px; - width: 600px; + width: 650px; } select{ diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css index 3f37ffd..24badcb 100644 --- a/website/public/styles/post-popup.css +++ b/website/public/styles/post-popup.css @@ -48,6 +48,10 @@ width: 90%; } +.post-content a { + text-decoration: underline; +} + .commentfield { margin-bottom: 20px; } diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 146a4fa..27ff7fd 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -1,5 +1,14 @@ /* New */ +.alertbox { + display: none; + background-color: firebrick; +} + +.alerttext { + color: white; +} + .user-box { text-align: center; } @@ -89,6 +98,10 @@ div.posts div.post { word-wrap: break-word; } +div.posts div.post a { + text-decoration: underline; +} + div.posts div.post:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } diff --git a/website/queries/checkInput.php b/website/queries/checkInput.php index 663da1f..69274ce 100644 --- a/website/queries/checkInput.php +++ b/website/queries/checkInput.php @@ -47,6 +47,8 @@ function checkName($variable){ throw new lettersAndSpacesException("Verplicht!"); } else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) { throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!"); + } else if (strlen($variable) > 63){ + throw new lettersAndSpacesException(("Mag maximaal 63 karakters hebben!")); } } @@ -81,6 +83,8 @@ function username($variable){ throw new usernameException("Moet minstens 6 karakters bevatten"); } else if (getExistingUsername() == 1) { throw new usernameException("Gebruikersnaam bestaal al"); + } else if (strlen($variable) > 50) { + throw new usernameException("Mag maximaal 50 karakters!"); } } @@ -92,6 +96,8 @@ function fbUsername($variable){ throw new usernameException("Moet minstens 6 karakters bevatten"); } else if (getExistingFBUsername() == 1) { throw new usernameException("Gebruikersnaam bestaal al"); + } else if (strlen($variable) > 50) { + throw new usernameException("Mag maximaal 50 karakters!"); } } @@ -101,6 +107,8 @@ function longerEight($variable){ throw new passwordException("Verplicht!"); } else if (strlen($variable) < 8) { throw new passwordException("Moet minstens 8 karakters bevatten"); + } else if (strlen($variable) > 50) { + throw new usernameException("Mag maximaal 50 karakters!"); } } @@ -112,9 +120,11 @@ function validateEmail($variable){ throw new emailException("Geldige email invullen"); } else if (getExistingEmail() == 1){ throw new emailException("Email bestaal al!"); + } else if (strlen($variable) > 255) { + throw new emailException("Mag maximaal 50 karakters!"); } } - +//255 /* checks if an input is a valid email. */ function validateFBEmail($variable){ if (empty($variable)) { @@ -122,7 +132,9 @@ function validateFBEmail($variable){ } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) { throw new emailException("Geldige email invullen"); } else if (getExistingFBEmail() == 1){ - throw new emailException("Email bestaal al!"); + throw new emailException("Uw email wordt al gebruikt voor een ander account!"); + } else if (strlen($variable) > 255) { + throw new emailException("Mag maximaal 50 karakters!"); } } diff --git a/website/queries/friendship.php b/website/queries/friendship.php index 7edada9..3dcd53b 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -17,7 +17,7 @@ function selectLimitedFriends($userID, $limit) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -58,7 +58,7 @@ function selectAllFriends($userID) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -94,7 +94,7 @@ function selectAllFriendRequests() { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -245,7 +245,7 @@ function searchSomeFriends($n, $m, $search) { `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, diff --git a/website/queries/settings.php b/website/queries/settings.php index dfd65a0..9b17d17 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -50,6 +50,15 @@ function getPasswordHash() { return $stmt->fetch(); } +function checkUpdateSettings() { + if (empty(test_input($_POST['fname'])) || empty(test_input($_POST['lname']))) { + throw new AngryAlert("Geen voornaam of achternaam."); + return; + } + + updateSettings(); +} + /** * Changes the setting from post. * @throws HappyAlert diff --git a/website/queries/user.php b/website/queries/user.php index 836c956..06487be 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -62,7 +62,7 @@ function selectUser($me, $other) { ) AS profilepicture, `bio`, `user`.`creationdate`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus`, @@ -137,7 +137,7 @@ function select20UsersFromN($n) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -162,7 +162,7 @@ function search20UsersFromN($n, $keyword) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -190,7 +190,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -224,7 +224,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) { `username`, `role`, `bancomment`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` @@ -368,7 +368,7 @@ function searchSomeUsers($n, $m, $search) { '../img/avatar-standard.png' ) AS profilepicture, LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, - CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) + CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' END AS `onlinestatus` diff --git a/website/views/adminpanel-grouptable.php b/website/views/adminpanel-grouptable.php index 9d2c8e8..2449b3d 100644 --- a/website/views/adminpanel-grouptable.php +++ b/website/views/adminpanel-grouptable.php @@ -1,8 +1,8 @@ - Gebruikersnaam + Groepsnaam Status - Aantekening + Beschrijving Actie @@ -33,9 +33,9 @@ while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
diff --git a/website/views/adminpanel-table.php b/website/views/adminpanel-table.php index aa790e6..f7bc966 100644 --- a/website/views/adminpanel-table.php +++ b/website/views/adminpanel-table.php @@ -55,7 +55,8 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) { OR $user['role'] == 'owner'))) { echo " - "; + + "; if ($userinfo == 'owner') { echo " diff --git a/website/views/adminpanel.php b/website/views/adminpanel.php index a4da648..2c0bec2 100644 --- a/website/views/adminpanel.php +++ b/website/views/adminpanel.php @@ -67,13 +67,13 @@ if (isset($_GET["groupstatus"])) { id="frozen" value="frozen" > -
+
> -
+
> - +
@@ -122,6 +122,7 @@ if (isset($_GET["groupstatus"])) { + Maak Owner"; + value=\"owner\">Maak Eigenaar"; } ?> @@ -139,9 +140,9 @@ if (isset($_GET["groupstatus"])) { onsubmit="adminUpdate(this); return false;"> - - - + + +
diff --git a/website/views/facebookRegisterModal.php b/website/views/facebookRegisterModal.php index 7db44b0..7271d63 100644 --- a/website/views/facebookRegisterModal.php +++ b/website/views/facebookRegisterModal.php @@ -55,7 +55,6 @@ *
-
@@ -67,6 +66,7 @@
+ * - diff --git a/website/views/head.php b/website/views/head.php index c4d13a5..f831f5d 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -2,7 +2,6 @@ - MyHyvesbook+ diff --git a/website/views/homeLoginRegister.php b/website/views/homeLoginRegister.php index beffff8..54c2015 100644 --- a/website/views/homeLoginRegister.php +++ b/website/views/homeLoginRegister.php @@ -7,7 +7,6 @@ $fbUsername = $fbPassword = $fbConfirmpassword = ""; $fbUsernameErr = $fbPasswordErr = $fbConfirmpasswordErr = $fbEmailErr = $fbBdayErr = ""; $fbCorrect = true; $fbName = $fbSurname = $fbBday = $fbEmail = $fbUserID = ""; -$bdayExist = false; // Register variables $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = ""; diff --git a/website/views/login-view.php b/website/views/login-view.php index f525103..98ce71c 100644 --- a/website/views/login-view.php +++ b/website/views/login-view.php @@ -1,3 +1,9 @@ +
+ +
login with Facebook!
'; + echo '
login met Facebook!
'; } ?> + diff --git a/website/views/menu.php b/website/views/menu.php index dab8fce..1c1cf01 100644 --- a/website/views/menu.php +++ b/website/views/menu.php @@ -12,6 +12,8 @@ + +