Пример #1
0
<?php

if (!isset($_GET['id'])) {
    return [];
}
require_once realpath(dirname(__DIR__) . "/class/CommentManager.php");
$aid = $_GET['id'] + 0;
//force it to be a number
$commentIDs = CommentManager::getCommentIDsFromAddon($aid);
$comments = [];
foreach ($commentIDs as $cid) {
    $comments[] = CommentManager::getFromID($cid);
}
return $comments;
//	require_once(realpath(dirname(__DIR__) . "/private/class/DatabaseManager.php"));
//	$database = new DatabaseManager();
//
//	//the "and `verified` = 1 can be deleted if we decide to force blid database entries to be unique
//	$result = $database->query("SELECT * FROM `addon_comments` WHERE `blid` = '" . $database->sanitize($_GET['blid']) . "' AND `verified` = 1");
//
//	if(!$result) {
//		echo("Database error: " . $database->error());
//	} else {
//		if($result->num_rows == 0) {
//			echo("<tr style=\"vertical-align:top\">");
//			echo("<td colspan=\"2\" style=\"text-align: center;\">");
//			echo("There are no comments here yet.");
//			echo("</td></tr>");
//		} else {
//			require_once(realpath(dirname(__DIR__) . "/private/class/UserHandler.php"));
//
Пример #2
0
<?php

/*$_GET['aid'] = $_REQUEST['id'];
$comments = include(dirname(__DIR__) . "/../../../private/json/getPageCommentsWithUsers.php");
echo json_encode($comments, JSON_PRETTY_PRINT);*/
require_once dirname(__DIR__) . "/../../../private/class/AddonManager.php";
require_once dirname(__DIR__) . "/../../../private/class/CommentManager.php";
$aid = $_REQUEST['id'];
if (!isset($_REQUEST['page'])) {
    $page = 0;
} else {
    $page = $_REQUEST['page'];
}
$addonObject = AddonManager::getFromID($aid);
$ret = array();
$start = $page * 10;
$comments = CommentManager::getCommentIDsFromAddon($addonObject->getId(), $start, 10);
foreach ($comments as $comid) {
    $comment = CommentManager::getFromId($comid);
    $commento = new stdClass();
    $commento->id = $comment->getId();
    $commento->author = UserLog::getCurrentUsername($comment->getBLID());
    $commento->authorblid = $comment->getBlid();
    $text = str_replace("\r\n", "<br>", $comment->getComment());
    $text = str_replace("\n", "<br>", $text);
    $commento->text = $text;
    $commento->date = date("F j, g:i a", strtotime($comment->getTimeStamp()));
    $ret[] = $commento;
}
echo json_encode($ret, JSON_PRETTY_PRINT);