-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi-feed.php
More file actions
32 lines (21 loc) · 854 Bytes
/
api-feed.php
File metadata and controls
32 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once 'bootstrap.php';
if ($dbh->login_check()) {
$my_user_id = $_SESSION["user_id"];
if(isset($_POST['cat_changed']) && $_POST['cat_changed']=="true"){
$_SESSION["categoria_corrente"] = $_POST['categoria'];
$_SESSION["last_post"] = time();
}
$num_post = NUM_POST_FOR_REQUEST;
if(isset($_POST["num_post"])) $num_post = $_POST["num_post"];
$templateParams['posts'] = $dbh->load_posts_for($my_user_id, $_SESSION["categoria_corrente"], $_SESSION["last_post"], $num_post);
$cout_post = count($templateParams['posts']);
if ($cout_post != 0){
$_SESSION["last_post"] = $templateParams['posts'][$cout_post-1]["data_ora"];
}
require("./template/post.php");
} else { //non autorizzato
header('Content-Type: application/json');
echo json_encode("Accesso negato.");
}
?>