mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:35:12 +00:00
66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Code\Module;
|
|
|
|
use Code\Web\Controller;
|
|
|
|
/**
|
|
* @brief Fastping Controller.
|
|
* Called from the client at regular intervals to check for updates from the server
|
|
*
|
|
*/
|
|
class Fastping extends Controller
|
|
{
|
|
|
|
/**
|
|
* @brief do several updates when pinged.
|
|
*
|
|
* This function does several tasks. Whenever called it checks for new messages,
|
|
* introductions, notifications, etc. and returns a json with the results.
|
|
*
|
|
* @result JSON
|
|
*/
|
|
|
|
public function init()
|
|
{
|
|
$result['notice'] = [];
|
|
$result['info'] = [];
|
|
|
|
$vnotify = (-1);
|
|
|
|
$result['invalid'] = ((isset($_GET['uid']) && intval($_GET['uid'])) && (intval($_GET['uid']) != local_channel()) ? 1 : 0);
|
|
|
|
if (local_channel()) {
|
|
$vnotify = get_pconfig(local_channel(), 'system', 'vnotify', (-1));
|
|
}
|
|
|
|
/**
|
|
* Send all system messages (alerts) to the browser.
|
|
* Some are marked as informational and some represent
|
|
* errors or serious notifications. These typically
|
|
* will provide a popup on the current page (no matter
|
|
* what page it is).
|
|
*/
|
|
|
|
if (x($_SESSION, 'sysmsg')) {
|
|
foreach ($_SESSION['sysmsg'] as $m) {
|
|
$result['notice'][] = ['message' => $m];
|
|
}
|
|
unset($_SESSION['sysmsg']);
|
|
}
|
|
if (x($_SESSION, 'sysmsg_info')) {
|
|
foreach ($_SESSION['sysmsg_info'] as $m) {
|
|
$result['info'][] = ['message' => $m];
|
|
}
|
|
unset($_SESSION['sysmsg_info']);
|
|
}
|
|
if (!($vnotify & VNOTIFY_INFO)) {
|
|
$result['info'] = [];
|
|
}
|
|
if (!($vnotify & VNOTIFY_ALERT)) {
|
|
$result['notice'] = [];
|
|
}
|
|
|
|
json_return_and_die($result);
|
|
}
|
|
}
|