/
get-comments.php
38 lines (28 loc) · 1.15 KB
/
get-comments.php
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
33
34
35
36
37
38
<?php
use Controller\SessionManager;
use Util\Util;
use DTO\CommentForPrintOut;
require_once 'classes/Util/Util.php';
Util::initRequest();
set_time_limit(0);
if(isset($_POST['pageID']) && !empty($_POST['pageID']) && isset($_POST['pageCount'])){
$pageID = htmlentities($_POST['pageID'], ENT_QUOTES);
$controller = \Controller\SessionManager::getController();
while(true){
$databaseCommentCount = $controller->getCommentCount($pageID);
if($_POST['pageCount'] < $databaseCommentCount){
$comment = $controller->getOneComment($pageID, $databaseCommentCount-$_POST['pageCount']-1);
$editable = false;
if($controller->getNicknameByID(@$_SESSION[Util::USER_SESSION_NAME]) == $comment->getNickname())
$editable = true;
$jsonComment = array("nickname"=>$comment->getNickname(), "date"=>$comment->getDate(), "commentMsg"=>$comment->getCommentMsg(), "editable"=>$editable);
echo \json_encode($jsonComment);
return;
}
\session_write_close();
\sleep(1);
\session_start();
}
SessionManager::storeController($controller);
}
?>