Merge branch 'master' into lars
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
|
if(!isset($_POST["offset"]) or !isset($_POST["limit"])) {
|
||||||
header('HTTP/1.1 500 Non enough arguments');
|
header('HTTP/1.1 500 Not enough arguments');
|
||||||
|
}
|
||||||
|
if(!isset($_POST["usr"]) and !isset($_POST["grp"])) {
|
||||||
|
header('HTTP/1.1 500 Not enough arguments');
|
||||||
}
|
}
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
@@ -12,17 +15,15 @@ require_once("../../queries/user.php");
|
|||||||
|
|
||||||
if (isset($_SESSION["userID"]) &&
|
if (isset($_SESSION["userID"]) &&
|
||||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||||
|
|
||||||
if(empty($_POST["usr"])) {
|
if(empty($_POST["usr"])) {
|
||||||
$posts = selectAllPosts(0, $_POST["grp"]);
|
$posts = selectSomePosts(0, $_POST["grp"], $_POST["offset"], $_POST["limit"]);
|
||||||
} else {
|
} else {
|
||||||
$posts = selectAllPosts($_POST["usr"], 0);
|
$posts = selectSomePosts($_POST["usr"], 0, $_POST["offset"], $_POST["limit"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$posts) {
|
if(!$posts) {
|
||||||
header('HTTP/1.1 500 Query failed');
|
echo false;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
|
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
for($i = 0; $i < sizeof($results); $i++) {
|
for($i = 0; $i < sizeof($results); $i++) {
|
||||||
@@ -30,6 +31,7 @@ if (isset($_SESSION["userID"]) &&
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($results);
|
echo json_encode($results);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
header('HTTP/1.0 403 Forbidden');
|
header('HTTP/1.0 403 Forbidden');
|
||||||
}
|
}
|
||||||
BIN
website/public/img/nietslecht_small.png
Normal file
BIN
website/public/img/nietslecht_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -45,6 +45,21 @@ function postPost() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var masonryMode = 0;
|
||||||
|
var windowWidth;
|
||||||
|
var columnCount;
|
||||||
|
var columns;
|
||||||
|
var postLimit;
|
||||||
|
var postAmount = 0;
|
||||||
|
var noposts = false;
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
windowWidth = $(window).width();
|
||||||
|
columnCount = Math.floor($(".posts").width() / 250);
|
||||||
|
columns = new Array(columnCount);
|
||||||
|
postLimit = columnCount * 7;
|
||||||
|
});
|
||||||
|
|
||||||
$(window).on("load", function() {
|
$(window).on("load", function() {
|
||||||
$(".modal-close").click(function () {
|
$(".modal-close").click(function () {
|
||||||
$(".modal").hide();
|
$(".modal").hide();
|
||||||
@@ -52,18 +67,31 @@ $(window).on("load", function() {
|
|||||||
$('#modal-response').hide();
|
$('#modal-response').hide();
|
||||||
$('.modal-default').show();
|
$('.modal-default').show();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
var masonryMode = 0;
|
// http://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom
|
||||||
var windowWidth = $(window).width();
|
// $(window).on("scroll", function () {
|
||||||
|
// if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
|
||||||
|
// loadMorePosts(userID, groupID, postAmount, postLimit);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
window.onscroll = function(ev) {
|
||||||
|
if($(window).scrollTop() + $(window).height() == $(document).height() ) {
|
||||||
|
loadMorePosts(userID, groupID, postAmount, postLimit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
clearTimeout(window.resizedFinished);
|
clearTimeout(window.resizedFinished);
|
||||||
window.resizeFinished = setTimeout(function() {
|
window.resizeFinished = setTimeout(function() {
|
||||||
if ($(window).width() != windowWidth) {
|
if ($(window).width() != windowWidth) {
|
||||||
windowWidth = $(window).width();
|
windowWidth = $(window).width();
|
||||||
|
|
||||||
|
if (columnCount != Math.floor($(".posts").width() / 250)) {
|
||||||
|
columnCount = Math.floor($(".posts").width() / 250);
|
||||||
masonry(masonryMode);
|
masonry(masonryMode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, 250);
|
}, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -72,12 +100,10 @@ var $container = $(".posts");
|
|||||||
function masonry(mode) {
|
function masonry(mode) {
|
||||||
masonryMode = mode;
|
masonryMode = mode;
|
||||||
$container.children().remove();
|
$container.children().remove();
|
||||||
columnCount = Math.floor($(".posts").width() / 250);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise columns.
|
* Initialise columns.
|
||||||
*/
|
*/
|
||||||
var columns = new Array(columnCount);
|
|
||||||
|
|
||||||
for (i = 0; i < columnCount; i++) {
|
for (i = 0; i < columnCount; i++) {
|
||||||
$column = $("<div class=\"column\">");
|
$column = $("<div class=\"column\">");
|
||||||
@@ -106,6 +132,14 @@ function masonry(mode) {
|
|||||||
/*
|
/*
|
||||||
* Function will find the column with the shortest height.
|
* Function will find the column with the shortest height.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the posts from the server.
|
||||||
|
*/
|
||||||
|
loadMorePosts(userID, groupID, 0, postLimit);
|
||||||
|
}
|
||||||
|
|
||||||
function getShortestColumn(columns) {
|
function getShortestColumn(columns) {
|
||||||
column = columns[0];
|
column = columns[0];
|
||||||
|
|
||||||
@@ -117,11 +151,25 @@ function masonry(mode) {
|
|||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
function loadMorePosts(uID, gID, offset, limit) {
|
||||||
* Get the posts from the server.
|
if (noposts) {
|
||||||
*/
|
return;
|
||||||
$.post("API/getPosts.php", { usr : userID, grp : groupID })
|
}
|
||||||
|
|
||||||
|
console.log(uID, gID, offset, limit);
|
||||||
|
|
||||||
|
|
||||||
|
$.post("API/getPosts.php", { usr : uID,
|
||||||
|
grp : gID,
|
||||||
|
offset : offset,
|
||||||
|
limit : limit})
|
||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
|
if (!data) {
|
||||||
|
$('.noposts').show();
|
||||||
|
noposts = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
posts = JSON.parse(data);
|
posts = JSON.parse(data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -139,5 +187,6 @@ function masonry(mode) {
|
|||||||
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
|
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
postAmount += limit;
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/* Modal Content/Box */
|
/* Modal Content/Box */
|
||||||
.modal-content {
|
.modal-content {
|
||||||
margin: 5% auto;
|
margin: 50px auto;
|
||||||
width: 70%; /* Could be more or less, depending on screen size */
|
width: 70%; /* Could be more or less, depending on screen size */
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,11 @@ div.posts .post form textarea.newpost {
|
|||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.noposts {
|
||||||
|
display: none;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 1500px) {
|
@media only screen and (max-width: 1500px) {
|
||||||
.post-box {
|
.post-box {
|
||||||
width: calc(50% - 68px);
|
width: calc(50% - 68px);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function getUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getUserID() {
|
function getUserID() {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`userID`
|
`userID`
|
||||||
FROM
|
FROM
|
||||||
@@ -73,7 +73,7 @@ function validateLogin($username, $password){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fbLogin($fbID) {
|
function fbLogin($fbID) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`email`,
|
`email`,
|
||||||
`userID`,
|
`userID`,
|
||||||
@@ -91,7 +91,7 @@ function fbLogin($fbID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getfbUserID($fbID) {
|
function getfbUserID($fbID) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`userID`,
|
`userID`,
|
||||||
`role`
|
`role`
|
||||||
|
|||||||
@@ -46,6 +46,57 @@ function selectAllPosts($userID, $groupID) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectSomePosts($userID, $groupID, $offset, $limit) {
|
||||||
|
$stmt = prepareQuery("
|
||||||
|
SELECT
|
||||||
|
`post`.`postID`,
|
||||||
|
`post`.`author`,
|
||||||
|
`title`,
|
||||||
|
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
|
||||||
|
WHEN TRUE THEN
|
||||||
|
CONCAT(LEFT(`post`.`content`, 150), '...')
|
||||||
|
WHEN FALSE THEN
|
||||||
|
`post`.`content`
|
||||||
|
END
|
||||||
|
AS `content`,
|
||||||
|
`post`.`creationdate`,
|
||||||
|
COUNT(DISTINCT `commentID`) AS `comments`,
|
||||||
|
COUNT(DISTINCT `niet_slecht`.`postID`) AS `niet_slechts`
|
||||||
|
FROM
|
||||||
|
`post`
|
||||||
|
LEFT JOIN
|
||||||
|
`niet_slecht`
|
||||||
|
ON
|
||||||
|
`post`.`postID` = `niet_slecht`.`postID`
|
||||||
|
LEFT JOIN
|
||||||
|
`comment`
|
||||||
|
ON
|
||||||
|
`post`.`postID` = `comment`.`postID`
|
||||||
|
WHERE
|
||||||
|
`post`.`author` = :userID AND
|
||||||
|
`groupID` IS NULL OR
|
||||||
|
`groupID` = :groupID
|
||||||
|
GROUP BY
|
||||||
|
`post`.`postID`
|
||||||
|
ORDER BY
|
||||||
|
`post`.`creationdate` DESC
|
||||||
|
LIMIT
|
||||||
|
:offset, :limit
|
||||||
|
");
|
||||||
|
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(':groupID', $groupID , PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(':offset', intval($offset), PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(':limit', intval($limit), PDO::PARAM_INT);
|
||||||
|
if(!$stmt->execute()) {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
if($stmt->rowCount() == 0) {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
return $stmt;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function selectPostById($postID) {
|
function selectPostById($postID) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function getExistingUsername() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExistingFBUsername() {
|
function getExistingFBUsername() {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`username`
|
`username`
|
||||||
FROM
|
FROM
|
||||||
@@ -49,7 +49,7 @@ function getExistingEmail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExistingFBEmail() {
|
function getExistingFBEmail() {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
`email`,
|
`email`,
|
||||||
`userID`
|
`userID`
|
||||||
@@ -120,7 +120,7 @@ function registerAccount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fbRegisterAccount() {
|
function fbRegisterAccount() {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`user`(fname,
|
`user`(fname,
|
||||||
lname,
|
lname,
|
||||||
|
|||||||
@@ -81,18 +81,14 @@
|
|||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
name="fbName"
|
name="fbName"
|
||||||
value="<?php echo $fbName ?>">
|
value="<?php echo $fbName ?>">
|
||||||
<?php echo $fbName ?>
|
|
||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
name="fbSurname"
|
name="fbSurname"
|
||||||
value="<?php echo $fbSurname ?>">
|
value="<?php echo $fbSurname ?>">
|
||||||
<?php echo $fbSurname ?>
|
|
||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
name="fbUserID"
|
name="fbUserID"
|
||||||
value="<?php echo $fbUserID ?>">
|
value="<?php echo $fbUserID ?>">
|
||||||
<?php echo $fbUserID ?>
|
|
||||||
<input type="hidden"
|
<input type="hidden"
|
||||||
name="fbEmail"
|
name="fbEmail"
|
||||||
value="<?php echo $fbEmail ?>">
|
value="<?php echo $fbEmail ?>">
|
||||||
<?php echo $fbEmail ?>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -58,7 +58,7 @@ $fb = new Facebook\Facebook([
|
|||||||
'app_secret' => $appSecret,
|
'app_secret' => $appSecret,
|
||||||
'default_graph_version' => 'v2.2',
|
'default_graph_version' => 'v2.2',
|
||||||
]);
|
]);
|
||||||
$redirect = "https://myhyvesbookplus.nl/~joey/login.php";
|
$redirect = "https://myhyvesbookplus.nl/login.php";
|
||||||
$helper = $fb->getRedirectLoginHelper();
|
$helper = $fb->getRedirectLoginHelper();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -80,12 +80,6 @@ if(!isset($acces_token)){
|
|||||||
$response = $fb->get('/me?fields=email,name,birthday');
|
$response = $fb->get('/me?fields=email,name,birthday');
|
||||||
$usernode = $response->getGraphUser();
|
$usernode = $response->getGraphUser();
|
||||||
|
|
||||||
// echo $usernode->getName() . "</br>";
|
|
||||||
echo $usernode->getID() . "</br>";
|
|
||||||
// echo $usernode->getProperty("email") . "<br><br>";
|
|
||||||
// echo "Picture<br>";
|
|
||||||
// echo "<img src='$image' /><br><br>";
|
|
||||||
|
|
||||||
$nameSplit = explode(" ", $usernode->getName());
|
$nameSplit = explode(" ", $usernode->getName());
|
||||||
$fbName = $nameSplit[0];
|
$fbName = $nameSplit[0];
|
||||||
$fbSurname = $nameSplit[1];
|
$fbSurname = $nameSplit[1];
|
||||||
@@ -93,7 +87,6 @@ if(!isset($acces_token)){
|
|||||||
$fbEmail = $usernode->getProperty("email");
|
$fbEmail = $usernode->getProperty("email");
|
||||||
// $image = 'https://graph.facebook.com/' . $usernode->getId() . '/picture?width=200';
|
// $image = 'https://graph.facebook.com/' . $usernode->getId() . '/picture?width=200';
|
||||||
|
|
||||||
|
|
||||||
if (fbLogin($fbUserID) == 1) {
|
if (fbLogin($fbUserID) == 1) {
|
||||||
$fbID = getfbUserID($fbUserID)["userID"];
|
$fbID = getfbUserID($fbUserID)["userID"];
|
||||||
$fbRole = getfbUserID($fbUserID)["role"];
|
$fbRole = getfbUserID($fbUserID)["role"];
|
||||||
|
|||||||
@@ -3,22 +3,21 @@ $postID = $_GET['postID'];
|
|||||||
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
|
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
|
||||||
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
|
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
|
||||||
session_start();
|
session_start();
|
||||||
|
?>
|
||||||
echo("
|
|
||||||
<div class='post-header header'>
|
<div class='post-header header'>
|
||||||
<h4>" . $post['title'] . "</h4>
|
<h4><?=$post['title']?></h4>
|
||||||
|
<form method="post" onclick=""><span class="delete-post">verwijder post</span><br /></form>
|
||||||
<span class='postinfo'>
|
<span class='postinfo'>
|
||||||
gepost door $fullname,
|
gepost door <?=$fullname?>,
|
||||||
<span class='posttime' title='" . $post['creationdate'] . "'>
|
<span class='posttime' title='<?=$post['creationdate']?>'>
|
||||||
" . nicetime($post['creationdate']) . "
|
<?=nicetime($post['creationdate'])?>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='post-content'>
|
<div class='post-content'>
|
||||||
<p>" . $post['content'] . "</p>
|
<p><?=$post['content']?></p>
|
||||||
</div>
|
</div>
|
||||||
"); ?>
|
|
||||||
|
|
||||||
<div class='post-comments'>
|
<div class='post-comments'>
|
||||||
<div class="commentfield">
|
<div class="commentfield">
|
||||||
|
|||||||
@@ -71,6 +71,10 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="noposts platform">
|
||||||
|
<p>Geen posts meer!</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-content platform">
|
<div class="modal-content platform">
|
||||||
<div class="modal-close">
|
<div class="modal-close">
|
||||||
|
|||||||
Reference in New Issue
Block a user