add infinite scroll on profile

This commit is contained in:
Hendrik
2017-02-01 14:05:04 +01:00
parent 77448d98ba
commit 9b89058484
5 changed files with 156 additions and 49 deletions

View File

@@ -1,26 +1,30 @@
<?php
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
header('HTTP/1.1 500 Non enough arguments');
if(!isset($_POST["offset"]) or !isset($_POST["limit"])) {
header('HTTP/1.1 500 Not enough arguments');
}
if(!isset($_POST["usr"]) and !isset($_POST["grp"])) {
header('HTTP/1.1 500 Not enough arguments');
}
require_once ("../../queries/post.php");
require_once ("../../queries/nicetime.php");
if(empty($_POST["usr"])) {
$posts = selectAllPosts(0, $_POST["grp"]);
$posts = selectSomePosts(0, $_POST["grp"], $_POST["offset"], $_POST["limit"]);
} else {
$posts = selectAllPosts($_POST["usr"], 0);
$posts = selectSomePosts($_POST["usr"], 0, $_POST["offset"], $_POST["limit"]);
}
if(!$posts) {
header('HTTP/1.1 500 Query failed');
echo false;
} else {
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
for($i = 0; $i < sizeof($results); $i++) {
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
}
echo json_encode($results);
}
$results = $posts->fetchAll(PDO::FETCH_ASSOC);
for($i = 0; $i < sizeof($results); $i++) {
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
}
echo json_encode($results);