From 328f0665f3832ef180d3399d6fb6153545d6c6bd Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 26 Jan 2017 11:35:18 +0100 Subject: [PATCH 1/6] add basic post functionality --- website/public/API/postComment.php | 16 ++++++++++++++++ website/public/API/postPost.php | 17 +++++++++++++++++ website/queries/post.php | 2 +- website/views/post-view.php | 5 +++-- website/views/profile.php | 6 +++--- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 website/public/API/postComment.php create mode 100644 website/public/API/postPost.php diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php new file mode 100644 index 0000000..c5b30cc --- /dev/null +++ b/website/public/API/postComment.php @@ -0,0 +1,16 @@ +prepare(" + $stmt = $GLOBALS["db"]->prepare(" INSERT INTO `comment` ( `postID`, diff --git a/website/views/post-view.php b/website/views/post-view.php index 044c23e..0f091a6 100644 --- a/website/views/post-view.php +++ b/website/views/post-view.php @@ -21,8 +21,9 @@ echo("
-
-
+ + +
diff --git a/website/views/profile.php b/website/views/profile.php index 19b9eae..404d957 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -58,9 +58,9 @@ if ($_SESSION["userID"] === $userID) { ?>
-
- - + + +
From 44f86a4fbb614f56b013c964b92662f15f680a5b Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 26 Jan 2017 12:05:28 +0100 Subject: [PATCH 2/6] Email confirm and password change now use messagepage function. --- website/public/emailconfirm.php | 12 ++--- website/public/resetpassword.php | 16 +++--- website/views/messagepage.php | 23 +++++++++ website/views/resetpassword.php | 85 ++++++++++++++------------------ 4 files changed, 77 insertions(+), 59 deletions(-) create mode 100644 website/views/messagepage.php diff --git a/website/public/emailconfirm.php b/website/public/emailconfirm.php index 97eb2f6..2812eaa 100644 --- a/website/public/emailconfirm.php +++ b/website/public/emailconfirm.php @@ -1,5 +1,6 @@ prepare(" SELECT @@ -18,11 +19,11 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) { if ($role == "unconfirmed") { doActivate($email); } else { - echo "Ongeldige link."; + messagePage("Ongeldige link."); } } else { - echo "Ongeldige link."; + messagePage("Ongeldige link."); } function doActivate(string $email) { @@ -39,11 +40,10 @@ function doActivate(string $email) { $confirmUser->bindParam(":userID", $_GET["u"]); $confirmUser->execute(); if ($confirmUser->rowCount()) { - echo "Email bevestigd
- U wordt automatisch doorgestuurd naar de login pagina over 5 seconden. "; - header("refresh:5;url=login.php"); + messagePage("Email bevestigd
+ Klik hier om terug te gaan naar de login pagina."); } } else { - echo "Ongeldige link."; + messagePage("Ongeldige link."); } } \ No newline at end of file diff --git a/website/public/resetpassword.php b/website/public/resetpassword.php index 54b706b..3ca2698 100644 --- a/website/public/resetpassword.php +++ b/website/public/resetpassword.php @@ -1,26 +1,30 @@ + + + + + +
+ +
$content
+
+ + + "); + + echo $webpage; + } \ No newline at end of file diff --git a/website/views/resetpassword.php b/website/views/resetpassword.php index 24d3aaf..a3107f9 100644 --- a/website/views/resetpassword.php +++ b/website/views/resetpassword.php @@ -1,47 +1,38 @@ - - - - - - -
- - -
-
Voer een nieuw wachtwoord in
- " - > - " - > -
    -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
-
-
- - \ No newline at end of file + +
Voer een nieuw wachtwoord in
+ + +
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+ "; + return $content; +} \ No newline at end of file From 47eed5514a80408a735bafbfbf756166dad27542 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 26 Jan 2017 12:14:07 +0100 Subject: [PATCH 3/6] Removed .idea folder --- .idea/WebDB.iml | 18 ---------------- .idea/inspectionProfiles/Project_Default.xml | 22 -------------------- .idea/modules.xml | 8 ------- .idea/php.xml | 4 ---- .idea/sqldialects.xml | 6 ------ .idea/vcs.xml | 6 ------ 6 files changed, 64 deletions(-) delete mode 100644 .idea/WebDB.iml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/sqldialects.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/WebDB.iml b/.idea/WebDB.iml deleted file mode 100644 index b313593..0000000 --- a/.idea/WebDB.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index f08a78f..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index e1b2ef9..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 10b171f..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml deleted file mode 100644 index af0e43a..0000000 --- a/.idea/sqldialects.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 423c2fd7712b0be152c4201e3e2063b9917ac85b Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 26 Jan 2017 12:16:28 +0100 Subject: [PATCH 4/6] Revert "Merge branch 'marijn-settings' into 'master'" This reverts merge request !128 --- .idea/WebDB.iml | 18 ++++++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 22 ++++++++++++++++++++ .idea/modules.xml | 8 +++++++ .idea/php.xml | 4 ++++ .idea/sqldialects.xml | 6 ++++++ .idea/vcs.xml | 6 ++++++ 6 files changed, 64 insertions(+) create mode 100644 .idea/WebDB.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/sqldialects.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/WebDB.iml b/.idea/WebDB.iml new file mode 100644 index 0000000..b313593 --- /dev/null +++ b/.idea/WebDB.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..f08a78f --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,22 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e1b2ef9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..10b171f --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..af0e43a --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 3ebacd62515c89cf6633c7ad0d41631211d09434 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Thu, 26 Jan 2017 12:20:32 +0100 Subject: [PATCH 5/6] Fixed masonry grid (posts). --- website/public/js/masonry.js | 66 ++++++++++++++---------------------- website/public/profile.php | 16 ++++++++- website/queries/user.php | 4 ++- website/views/profile.php | 50 +++++++++++++-------------- 4 files changed, 69 insertions(+), 67 deletions(-) diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index e9419a2..b523828 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -1,37 +1,28 @@ margin = 20; -$(window).on("load", function() { - console.log("LOADED"); - container = $("div.posts"); - posts = container.children(); - posts.remove(); - - column = $('
').append(posts); - container.append(column); - - mansonry(); - mansonry(); -}); - $(window).resize(function() { clearTimeout(window.resizedFinished); window.resizeFinished = setTimeout(function() { - mansonry(); + masonry(); }, 250); }); -function mansonry() { +var $container = $(".posts"); +function masonry() { + $container.children().remove(); columnCount = Math.floor($(".posts").width() / 250); - console.log("columns: " + columnCount); /* * Initialise columns. */ var columns = new Array(columnCount); + var $columns = new Array(columnCount); for (i = 0; i < columnCount; i++) { - columns[i] = [0, []]; - console.log(columns[i]); + $column = $("
"); + $column.width(100/columnCount + "%"); + $container.append($column); + columns[i] = [0, $column]; } /* @@ -45,32 +36,27 @@ function mansonry() { column = columns[i]; } } - return column; } /* - * Rearange the objects. + * Get the posts from the server. */ - j = 0; - posts.each(function(i) { - post = posts[i]; - shortestColumn = getShortestColumn(columns); - shortestColumn[0] = shortestColumn[0] + $(post).height() + margin; - shortestColumn[1].push(post); + $.post("API/getPosts.php", { usr : userID }) + .done(function(data) { + posts = JSON.parse(data); - }); - - container.children().remove(); - /* - * Display the objects again in the correct order. - */ - for (i = 0; i < columnCount; i++) { - column = $('
').append(columns[i][1]); - console.log(column); - container.append(column); + /* + * Rearange the objects. + */ + jQuery.each(posts, function() { + $post = $("
"); + $post.append($("

").text(this["title"])); + $post.append($("

").html(this["content"])); - } - - $("div.posts div.column").width(100/columnCount + "%"); -} \ No newline at end of file + shortestColumn = getShortestColumn(columns); + shortestColumn[1].append($post); + shortestColumn[0] = shortestColumn[0] + $post.height() + margin; + }); + }); +} diff --git a/website/public/profile.php b/website/public/profile.php index 6e188c4..1423483 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -2,7 +2,6 @@ - @@ -45,10 +44,25 @@ include("../views/footer.php"); ?> + diff --git a/website/queries/user.php b/website/queries/user.php index 9904eee..7672746 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -126,7 +126,9 @@ function selectAllUserPosts($userID) { "); $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); - $stmt->execute(); + if(!$stmt->execute()) { + return False; + } return $stmt; } diff --git a/website/views/profile.php b/website/views/profile.php index 3719ff1..6b7b283 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -5,7 +5,7 @@

- +

@@ -43,29 +43,29 @@
- -
-
- - - -
-
- fetch()) { - $nicetime = nicetime($post["creationdate"]); - echo " -
-

${post["title"]}

-

${post["content"]}

-

${nicetime} geplaatst.

-
- "; - } - ?> + + + + + + + + +fetch()) { +// $nicetime = nicetime($post["creationdate"]); +// echo " +//
+//

${post["title"]}

+//

${post["content"]}

+//

${nicetime} geplaatst.

+//
+// "; +// } +// ?>
\ No newline at end of file From 91aca6baa740f48958435a3f12ee608cbd8d4e14 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 26 Jan 2017 12:21:01 +0100 Subject: [PATCH 6/6] change comments to use ajax --- website/public/API/postComment.php | 14 ++++++++------ website/public/js/post.js | 18 ++++++++++++++++++ website/public/js/profile.js | 8 -------- website/public/profile.php | 2 +- website/views/post-view.php | 6 +++--- 5 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 website/public/js/post.js diff --git a/website/public/API/postComment.php b/website/public/API/postComment.php index c5b30cc..b840e0b 100644 --- a/website/public/API/postComment.php +++ b/website/public/API/postComment.php @@ -5,12 +5,14 @@ session_start(); require("../../queries/post.php"); require("../../queries/connect.php"); require("../../queries/checkInput.php"); - if (empty($_POST['newcomment-content'])) { + echo 0; } else { - makeComment($_POST['postID'], + if(makeComment($_POST['postID'], $_SESSION['userID'], - test_input($_POST['newcomment-content'])); -} - -header("Location: ../profile.php"); \ No newline at end of file + test_input($_POST['newcomment-content']))) { + echo 1; + } else { + echo 0; + } +} \ No newline at end of file diff --git a/website/public/js/post.js b/website/public/js/post.js new file mode 100644 index 0000000..62ace68 --- /dev/null +++ b/website/public/js/post.js @@ -0,0 +1,18 @@ +function postComment() { + $.post( + "API/postComment.php", + $("#newcommentform").serialize() + ); + + $("#newcomment").val(""); + + //reload post + $.get( + "API/loadPost.php", + $("#newcommentform").serialize() + ).done(function (data) { + $('#modal-response').html(data); + }); +} + + diff --git a/website/public/js/profile.js b/website/public/js/profile.js index 2a47dce..e69de29 100644 --- a/website/public/js/profile.js +++ b/website/public/js/profile.js @@ -1,8 +0,0 @@ -function loadPost(postID) { - $.get( - "API/loadPost.php", - $(postID).serialize() - ).done(function (data) { - $('#modal-response').innerHTML= JSON.parse(data); - }); -} \ No newline at end of file diff --git a/website/public/profile.php b/website/public/profile.php index d2d3c3f..c8f27c4 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -3,7 +3,7 @@ - +