Exemplo n.º 1
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Notification;
use NERDZ\Core\Db;
use NERDZ\Core\Config;
use NERDZ\Core\RedisSessionHandler;
use NERDZ\Core\Utils;
$user = new Notification();
header("Content-Type: text/event-stream\n\n");
$push = function ($event, $status, $message) use($user) {
    echo 'event: ', $event, "\n", 'data: ', Utils::toJsonResponse($status, $message), "\n\n";
    ob_flush();
    flush();
};
$dontSendCacheLimiter = function () {
    // http://stackoverflow.com/a/12315542
    ini_set('session.use_only_cookies', false);
    ini_set('session.use_cookies', false);
    ini_set('session.use_trans_sid', false);
    ini_set('session.cache_limiter', null);
    if (Config\REDIS_HOST !== '' && Config\REDIS_PORT !== '') {
        new RedisSessionHandler(Config\REDIS_HOST, Config\REDIS_PORT);
    } else {
        session_start();
    }
};
if (!$user->isLogged()) {
    $push('notification', 'error', $user->lang('REGISTER'));
    $push('pm', 'error', $user->lang('REGISTER'));
} else {