View file siwap.ru/AJAX/chat/getMessages.php

File size: 647B
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/system/App.php');
	
if ($sys->isAjax())
{
	$offset = !empty($_POST['offset']) ? (int) $_POST['offset'] : 0;
	$count = !empty($_POST['count']) ? (int) $_POST['count'] : 20;
	
	$arrMessages = $chat->getMessages($offset, $count);
	
	if (!empty($arrMessages) && is_array($arrMessages))
	{
		$json = [
			'success' => 1, 
			'response' => $arrMessages,
		];
	}
	else
	{
		$json = [
			'error' => 1, 
			'comment' => 'Пока пусто'
		];
	}
}
else
{
	$json = [
		'error' => 1, 
		'comment' => '404 Bad Request',
	];
}
echo json_encode($json, JSON_UNESCAPED_UNICODE);