Gazelle/sections/ajax/tcomments.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2013-08-28 23:08:41 +00:00
<?
2013-05-27 08:00:58 +00:00
include(SERVER_ROOT.'/classes/text.class.php');
2012-06-27 08:00:15 +00:00
$Text = new TEXT;
2013-08-28 23:08:41 +00:00
if (empty($_GET['id']) || !is_number($_GET['id'])) {
json_die("failure");
2012-06-27 08:00:15 +00:00
}
2013-08-28 23:08:41 +00:00
list($NumComments, $Page, $Thread) = Comments::load('torrents', (int)$_GET['id'], false);
2012-06-27 08:00:15 +00:00
//---------- Begin printing
$JsonComments = array();
foreach ($Thread as $Key => $Post) {
list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
2012-10-11 08:00:15 +00:00
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
2012-06-27 08:00:15 +00:00
$JsonComments[] = array(
'postId' => (int) $PostID,
'addedTime' => $AddedTime,
2012-07-06 08:00:11 +00:00
'bbBody' => $Body,
2012-06-27 08:00:15 +00:00
'body' => $Text->full_format($Body),
'editedUserId' => (int) $EditedUserID,
'editedTime' => $EditedTime,
'editedUsername' => $EditedUsername,
'userinfo' => array(
'authorId' => (int) $AuthorID,
'authorName' => $Username,
'artist' => $Artist == 1,
'donor' => $Donor == 1,
'warned' => ($Warned != '0000-00-00 00:00:00'),
'avatar' => $Avatar,
2013-05-28 08:01:02 +00:00
'enabled' => ($Enabled == 2 ? false : true),
2012-06-27 08:00:15 +00:00
'userTitle' => $UserTitle
)
);
}
2013-04-24 08:00:23 +00:00
json_die("success", array(
2013-05-14 08:00:34 +00:00
'page' => (int) $Page,
2013-08-28 23:08:41 +00:00
'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
2013-05-14 08:00:34 +00:00
'comments' => $JsonComments
2013-04-24 08:00:23 +00:00
));