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 {
    //outside of the loop, to send first events as fast as possible
    $notification = $user->count(false, true);
    $push('notification', 'ok', $notification);
    $pm = $user->countPms();
    $push('pm', 'ok', $pm);
    session_write_close();
    //unlock $_SESSION (other scripts can now run)
    sleep(5);
    $viewonline = empty($_SESSION['mark_offline']) ? '1' : '0';
    while (1) {
        $newNotifications = $user->count(false, true);
        if ($newNotifications != $notification) {
            $notification = $newNotifications;
            $push('notification', 'ok', $notification);
        }
        $newPm = $user->countPms();
        if ($newPm != $pm) {
Example #2
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Notification;
use NERDZ\Core\User;
$notification = new Notification();
$user = new User();
if ($user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('ok', $notification->count(false, true)));
}
die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));