mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-13 19:06:27 +00:00
41 lines
803 B
PHP
41 lines
803 B
PHP
<?
|
|
//Don't allow bigger queries than specified below regardless of called function
|
|
$SizeLimit = 10;
|
|
|
|
$Count = (int)$_GET['count'];
|
|
$Offset = (int)$_GET['offset'];
|
|
|
|
if (!isset($_GET['count']) || !isset($_GET['offset']) || $Count <= 0 || $Offset < 0 || $Count > $SizeLimit) {
|
|
json_die('failure');
|
|
}
|
|
|
|
Text::$TOC = true;
|
|
|
|
global $DB;
|
|
$DB->query("
|
|
SELECT
|
|
ID,
|
|
Title,
|
|
Body,
|
|
Time
|
|
FROM news
|
|
ORDER BY Time DESC
|
|
LIMIT $Offset, $Count");
|
|
$News = $DB->to_array(false, MYSQLI_NUM, false);
|
|
|
|
$NewsResponse = array();
|
|
foreach ($News as $NewsItem) {
|
|
list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
|
|
array_push(
|
|
$NewsResponse,
|
|
array(
|
|
$NewsID,
|
|
Text::full_format($Title),
|
|
time_diff($NewsTime),
|
|
Text::full_format($Body)
|
|
)
|
|
);
|
|
}
|
|
|
|
json_print('success', json_encode($NewsResponse));
|