Размер файла: 1.07Kb
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/system/App.php');
if($sys->isAjax() && $_SERVER['REQUEST_METHOD'] == 'POST')
{
$offset = !empty($_POST['offset']) ? (int) $_POST['offset'] : 0;
$count = !empty($_POST['count']) ? (int) $_POST['count'] : 10;
$arrNews = $news->get($offset, $count);
if (!empty($arrNews) && is_array($arrNews))
{
foreach($arrNews as $newsKey => $newsValue)
{
$arrNews[$newsKey]['user_date_last'] = App::$sys->time($newsValue['user_date_last']);
$arrNews[$newsKey]['time'] = App::$sys->time($newsValue['time']);
$arrNews[$newsKey]['likes'] = $news->countLikes($newsValue['id']);
$arrNews[$newsKey]['views'] = $news->countViews($newsValue['id']);
$arrNews[$newsKey]['files'] = $news->getFiles($newsValue['id']);
}
$json = [
'success' => 1,
'response' => $arrNews,
];
}
else
{
$json = [
'error' => 1,
'comment' => 'Пока пусто'
];
}
}
else
{
$json = [
'error' => 1,
'comment' => '404 Bad Request'
];
}
echo json_encode($json, JSON_UNESCAPED_UNICODE);