Merge branch 'master' into lars
This commit is contained in:
24
website/public/API/getPosts.php
Normal file
24
website/public/API/getPosts.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(empty($_POST["usr"])) {
|
||||||
|
header('HTTP/1.1 500 Non enough arguments');
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once ("../../queries/user.php");
|
||||||
|
require_once ("../../queries/nicetime.php");
|
||||||
|
|
||||||
|
$posts = selectAllUserPosts($_POST["usr"]);
|
||||||
|
|
||||||
|
if(!$posts) {
|
||||||
|
header('HTTP/1.1 500 Query failed');
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
for($i = 0; $i < sizeof($results); $i++) {
|
||||||
|
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$results[0]["niceTime"] = nicetime($results[0]["creationdate"]);
|
||||||
|
|
||||||
|
echo json_encode($results);
|
||||||
18
website/public/API/postComment.php
Normal file
18
website/public/API/postComment.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
require("../../queries/post.php");
|
||||||
|
require("../../queries/connect.php");
|
||||||
|
require("../../queries/checkInput.php");
|
||||||
|
if (empty($_POST['newcomment-content'])) {
|
||||||
|
echo 0;
|
||||||
|
} else {
|
||||||
|
if(makeComment($_POST['postID'],
|
||||||
|
$_SESSION['userID'],
|
||||||
|
test_input($_POST['newcomment-content']))) {
|
||||||
|
echo 1;
|
||||||
|
} else {
|
||||||
|
echo 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
website/public/API/postPost.php
Normal file
17
website/public/API/postPost.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
require("../../queries/post.php");
|
||||||
|
require("../../queries/connect.php");
|
||||||
|
require("../../queries/checkInput.php");
|
||||||
|
|
||||||
|
if (empty($_POST['newpost-title'])) {
|
||||||
|
} else {
|
||||||
|
makePost($_SESSION['userID'],
|
||||||
|
null,
|
||||||
|
test_input($_POST['newpost-title']),
|
||||||
|
test_input($_POST['newpost-content']));
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: ../profile.php");
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once("../queries/connect.php");
|
include_once("../queries/connect.php");
|
||||||
|
include_once("../views/messagepage.php");
|
||||||
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
||||||
$checkHash = $GLOBALS["db"]->prepare("
|
$checkHash = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -18,11 +19,11 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
|||||||
if ($role == "unconfirmed") {
|
if ($role == "unconfirmed") {
|
||||||
doActivate($email);
|
doActivate($email);
|
||||||
} else {
|
} else {
|
||||||
echo "Ongeldige link.";
|
messagePage("Ongeldige link.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "Ongeldige link.";
|
messagePage("Ongeldige link.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function doActivate(string $email) {
|
function doActivate(string $email) {
|
||||||
@@ -39,11 +40,10 @@ function doActivate(string $email) {
|
|||||||
$confirmUser->bindParam(":userID", $_GET["u"]);
|
$confirmUser->bindParam(":userID", $_GET["u"]);
|
||||||
$confirmUser->execute();
|
$confirmUser->execute();
|
||||||
if ($confirmUser->rowCount()) {
|
if ($confirmUser->rowCount()) {
|
||||||
echo "Email bevestigd <br />
|
messagePage("Email bevestigd <br />
|
||||||
<a href='index.php'>U wordt automatisch doorgestuurd naar de login pagina over 5 seconden.</a> ";
|
<a href='index.php'>Klik hier om terug te gaan naar de login pagina.</a>");
|
||||||
header("refresh:5;url=login.php");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "Ongeldige link.";
|
messagePage("Ongeldige link.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,12 +11,10 @@ function scrollbarMargin(width, overflow) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function requestPost(post) {
|
function requestPost(postID) {
|
||||||
$(".modal").show();
|
$(".modal").show();
|
||||||
$.get(
|
|
||||||
"API/loadPost.php",
|
$.get("API/loadPost.php", { postID : postID }).done(function(data) {
|
||||||
$(post).children("form").serialize()
|
|
||||||
).done(function (data) {
|
|
||||||
$('.modal-default').hide();
|
$('.modal-default').hide();
|
||||||
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
|
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
|
||||||
scrollbarMargin(scrollBarWidth, 'hidden');
|
scrollbarMargin(scrollBarWidth, 'hidden');
|
||||||
@@ -26,37 +24,55 @@ function requestPost(post) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(window).on("load", function() {
|
$(window).on("load", function() {
|
||||||
console.log("LOADED");
|
$(".modal-close").click(function () {
|
||||||
container = $("div.posts");
|
$(".modal").hide();
|
||||||
posts = container.children();
|
scrollbarMargin(0, 'auto');
|
||||||
posts.remove();
|
$('#modal-response').hide();
|
||||||
|
$('.modal-default').show();
|
||||||
column = $('<div class="column"></div>').append(posts);
|
|
||||||
container.append(column);
|
|
||||||
|
|
||||||
mansonry();
|
|
||||||
mansonry();
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var masonryMode = 0;
|
||||||
|
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
clearTimeout(window.resizedFinished);
|
clearTimeout(window.resizedFinished);
|
||||||
window.resizeFinished = setTimeout(function() {
|
window.resizeFinished = setTimeout(function() {
|
||||||
mansonry();
|
masonry(masonryMode);
|
||||||
}, 250);
|
}, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
function mansonry() {
|
var $container = $(".posts");
|
||||||
|
|
||||||
|
function masonry(mode) {
|
||||||
|
masonryMode = mode;
|
||||||
|
$container.children().remove();
|
||||||
columnCount = Math.floor($(".posts").width() / 250);
|
columnCount = Math.floor($(".posts").width() / 250);
|
||||||
console.log("columns: " + columnCount);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise columns.
|
* Initialise columns.
|
||||||
*/
|
*/
|
||||||
var columns = new Array(columnCount);
|
var columns = new Array(columnCount);
|
||||||
|
var $columns = new Array(columnCount);
|
||||||
for (i = 0; i < columnCount; i++) {
|
for (i = 0; i < columnCount; i++) {
|
||||||
columns[i] = [0, []];
|
$column = $("<div class=\"column\">");
|
||||||
console.log(columns[i]);
|
$column.width(100/columnCount + "%");
|
||||||
|
$container.append($column);
|
||||||
|
columns[i] = [0, $column];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode == 1) {
|
||||||
|
$postInput = $("<div class=\"post platform\">");
|
||||||
|
$form = $("<form action=\"API/postPost.php\" method=\"post\">");
|
||||||
|
$postInput.append($form);
|
||||||
|
|
||||||
|
$form.append($("<input class=\"newpost\" name=\"newpost-title\" placeholder=\"Titel\" type=\"text\">"));
|
||||||
|
$form.append($("<textarea class=\"newpost\" name=\"newpost-content\" placeholder=\"Schrijf een berichtje...\">"));
|
||||||
|
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
|
||||||
|
columns[0][1].append($postInput);
|
||||||
|
|
||||||
|
$postInput.on("load", function() {
|
||||||
|
columns[0][0] = $postInput.height() + margin;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -70,38 +86,29 @@ function mansonry() {
|
|||||||
column = columns[i];
|
column = columns[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the posts from the server.
|
||||||
|
*/
|
||||||
|
$.post("API/getPosts.php", { usr : userID })
|
||||||
|
.done(function(data) {
|
||||||
|
posts = JSON.parse(data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rearange the objects.
|
* Rearange the objects.
|
||||||
*/
|
*/
|
||||||
j = 0;
|
jQuery.each(posts, function() {
|
||||||
posts.each(function(i) {
|
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
|
||||||
post = posts[i];
|
$post.append($("<h2>").text(this["title"]));
|
||||||
|
$post.append($("<p>").html(this["content"]));
|
||||||
|
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
|
||||||
|
|
||||||
shortestColumn = getShortestColumn(columns);
|
shortestColumn = getShortestColumn(columns);
|
||||||
shortestColumn[0] = shortestColumn[0] + $(post).height() + margin;
|
shortestColumn[1].append($post);
|
||||||
shortestColumn[1].push(post);
|
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.children().remove();
|
|
||||||
/*
|
|
||||||
* Display the objects again in the correct order.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < columnCount; i++) {
|
|
||||||
column = $('<div class="column"></div>').append(columns[i][1]);
|
|
||||||
console.log(column);
|
|
||||||
container.append(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("div.posts div.column").width(100/columnCount + "%");
|
|
||||||
|
|
||||||
$(".modal-close").click(function () {
|
|
||||||
$(".modal").hide();
|
|
||||||
scrollbarMargin(0, 'auto');
|
|
||||||
$('#modal-response').hide();
|
|
||||||
$('.modal-default').show();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
website/public/js/post.js
Normal file
18
website/public/js/post.js
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
function loadPost(postID) {
|
|
||||||
$.get(
|
|
||||||
"API/loadPost.php",
|
|
||||||
$(postID).serialize()
|
|
||||||
).done(function (data) {
|
|
||||||
$('#modal-response').innerHTML= JSON.parse(data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<?php include("../views/head.php"); ?>
|
<?php include("../views/head.php"); ?>
|
||||||
|
|
||||||
<script src="js/masonry.js"></script>
|
<script src="js/masonry.js"></script>
|
||||||
<!-- <script src="js/profile.js"></script>-->
|
<script src="js/post.js"></script>
|
||||||
<style>
|
<style>
|
||||||
@import url("styles/profile.css");
|
@import url("styles/profile.css");
|
||||||
@import url("styles/post-popup.css");
|
@import url("styles/post-popup.css");
|
||||||
@@ -30,8 +31,10 @@ $posts = selectAllUserPosts($userID);
|
|||||||
|
|
||||||
if ($userID == $_SESSION["userID"]) {
|
if ($userID == $_SESSION["userID"]) {
|
||||||
$friendship_status = -1;
|
$friendship_status = -1;
|
||||||
|
$masonry_mode = 1;
|
||||||
} else {
|
} else {
|
||||||
$friendship_status = $user["friend_status"];
|
$friendship_status = $user["friend_status"];
|
||||||
|
$masonry_mode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -48,10 +51,25 @@ include("../views/footer.php");
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script src="js/friendButtons.js"></script>
|
<script src="js/friendButtons.js"></script>
|
||||||
|
<script src="js/masonry.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
var posts;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
userID = <?= $userID ?>;
|
userID = <?= $userID ?>;
|
||||||
placeFriendButtons();
|
placeFriendButtons();
|
||||||
|
|
||||||
|
masonry(<?= $masonry_mode ?>);
|
||||||
|
// alert("blap");
|
||||||
|
// $.post("API/getPosts.php", { usr : userID }, "json")
|
||||||
|
// .done(function(data) {
|
||||||
|
// posts = JSON.parse(data);
|
||||||
|
// alert(posts[0]["content"]);
|
||||||
|
// }).fail(function() {
|
||||||
|
// alert("failure...");
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,26 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once("../queries/connect.php");
|
include_once("../queries/connect.php");
|
||||||
|
include_once("../views/messagepage.php");
|
||||||
|
include_once("../views/resetpassword.php");
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "GET") {
|
if ($_SERVER["REQUEST_METHOD"] == "GET") {
|
||||||
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
|
||||||
if (verifyLink($_GET["u"], $_GET["h"])) {
|
if (verifyLink($_GET["u"], $_GET["h"])) {
|
||||||
include "../views/resetpassword.php";
|
messagePage(passwordResetFields());
|
||||||
} else {
|
} else {
|
||||||
echo "Ongeldige link.";
|
messagePage("Wachtwoorden komen niet overeen.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "Ongeldige link.";
|
messagePage("Ongeldige links");
|
||||||
}
|
}
|
||||||
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
|
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
if (verifyLink($_POST["u"], $_POST["h"])) {
|
if (verifyLink($_POST["u"], $_POST["h"])) {
|
||||||
if ($_POST["password"] == $_POST["password-confirm"]) {
|
if ($_POST["password"] == $_POST["password-confirm"]) {
|
||||||
changePassword();
|
changePassword();
|
||||||
echo "Wachtwoord is veranderd";
|
messagePage("Wachtwoord gewijzigd");
|
||||||
} else {
|
} else {
|
||||||
echo "Wachtwoorden zijn niet hetzelfde";
|
messagePage("Ongeldige link");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "Ongeldige link.";
|
messagePage("Ongeldige link");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePassword() {
|
function changePassword() {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ function makePost($userID, $groupID, $title, $content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeComment($postID, $userID, $content) {
|
function makeComment($postID, $userID, $content) {
|
||||||
$stmt = $_GLOBAL["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`comment` (
|
`comment` (
|
||||||
`postID`,
|
`postID`,
|
||||||
|
|||||||
@@ -126,7 +126,9 @@ function selectAllUserPosts($userID) {
|
|||||||
");
|
");
|
||||||
|
|
||||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
if(!$stmt->execute()) {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
website/views/messagepage.php
Normal file
23
website/views/messagepage.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
function messagePage(string $content) {
|
||||||
|
$webpage = ("
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
@import url(styles/main.css);
|
||||||
|
@import url(styles/settings.css);
|
||||||
|
@import url(styles/resetpassword.css);
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class='password-change'>
|
||||||
|
<div class='top-logo'><a href='login.php'><img src='img/top-logo.png' alt='MyHyvesbook+'/></a></div>
|
||||||
|
<div class='item-box platform'>$content</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
");
|
||||||
|
|
||||||
|
echo $webpage;
|
||||||
|
}
|
||||||
@@ -21,8 +21,9 @@ echo("
|
|||||||
|
|
||||||
<div class='post-comments'>
|
<div class='post-comments'>
|
||||||
<div class="commentfield">
|
<div class="commentfield">
|
||||||
<form name="newcomment" method="post">
|
<form id="newcommentform" action="javascript:postComment();">
|
||||||
<textarea placeholder="Laat een reactie achter..."></textarea> <br>
|
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
|
||||||
|
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..."></textarea> <br>
|
||||||
<input type="submit" value="Reageer!">
|
<input type="submit" value="Reageer!">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -43,37 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
<?php
|
|
||||||
if ($_SESSION["userID"] === $userID) {
|
|
||||||
?>
|
|
||||||
<div class="post platform">
|
|
||||||
<form>
|
|
||||||
<input type="text" class="newpost" placeholder="Titel">
|
|
||||||
<textarea class="newpost" placeholder="Schrijf een berichtje..."></textarea>
|
|
||||||
<input type="submit" value="Plaats!">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
while($post = $posts->fetch()) {
|
|
||||||
$nicetime = nicetime($post["creationdate"]);
|
|
||||||
$postID = $post["postID"];
|
|
||||||
echo "
|
|
||||||
<div class='post platform' onclick='requestPost(this)'>
|
|
||||||
<h2>${post["title"]}</h2>
|
|
||||||
<p>${post["content"]}</p>
|
|
||||||
<p class=\"subscript\" title='" . $post["creationdate"] ."'>${nicetime} geplaatst.</p>
|
|
||||||
<form>
|
|
||||||
<input type='hidden'
|
|
||||||
name='postID'
|
|
||||||
value='$postID'
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
|
|||||||
@@ -1,25 +1,17 @@
|
|||||||
<!DOCTYPE html>
|
<?php
|
||||||
<html>
|
function passwordResetFields() {
|
||||||
<head>
|
$username = $_GET['u'];
|
||||||
<style>
|
$hash = $_GET['h'];
|
||||||
@import url(styles/main.css);
|
$content ="
|
||||||
@import url(styles/settings.css);
|
<form class='settings' method = 'post' >
|
||||||
@import url(styles/resetpassword.css);
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class='password-change'>
|
|
||||||
<div class="top-logo"><img src="img/top-logo.png" alt="MyHyvesbook+"/></div>
|
|
||||||
|
|
||||||
<form class='settings platform item-box' method='post'>
|
|
||||||
<h5 > Voer een nieuw wachtwoord in </h5 >
|
<h5 > Voer een nieuw wachtwoord in </h5 >
|
||||||
<input type="hidden"
|
<input type = 'hidden'
|
||||||
name="u"
|
name = 'u'
|
||||||
value="<?=$_GET["u"]?>"
|
value = '$username'
|
||||||
>
|
>
|
||||||
<input type="hidden"
|
<input type = 'hidden'
|
||||||
name="h"
|
name = 'h'
|
||||||
value="<?=$_GET["h"]?>"
|
value = '$hash'
|
||||||
>
|
>
|
||||||
<ul >
|
<ul >
|
||||||
<li >
|
<li >
|
||||||
@@ -41,7 +33,6 @@
|
|||||||
<button type = 'submit' > Verander wachtwoord </button >
|
<button type = 'submit' > Verander wachtwoord </button >
|
||||||
</li >
|
</li >
|
||||||
</ul >
|
</ul >
|
||||||
</form>
|
</form >";
|
||||||
</div>
|
return $content;
|
||||||
</body>
|
}
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user