function get_status()
{
    $status = array('triggers_count' => 0, 'triggers_count_enabled' => 0, 'triggers_count_disabled' => 0, 'triggers_count_off' => 0, 'triggers_count_on' => 0, 'triggers_count_unknown' => 0, 'items_count' => 0, 'items_count_monitored' => 0, 'items_count_disabled' => 0, 'items_count_not_supported' => 0, 'hosts_count' => 0, 'hosts_count_monitored' => 0, 'hosts_count_not_monitored' => 0, 'hosts_count_template' => 0, 'users_online' => 0, 'qps_total' => 0);
    // server
    $status['zabbix_server'] = zabbixIsRunning() ? _('Yes') : _('No');
    // triggers
    $dbTriggers = DBselect('SELECT COUNT(DISTINCT t.triggerid) AS cnt,t.status,t.value' . ' FROM triggers t' . ' INNER JOIN functions f ON t.triggerid=f.triggerid' . ' INNER JOIN items i ON f.itemid=i.itemid' . ' INNER JOIN hosts h ON i.hostid=h.hostid' . ' WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND h.status=' . HOST_STATUS_MONITORED . ' GROUP BY t.status,t.value');
    while ($dbTrigger = DBfetch($dbTriggers)) {
        switch ($dbTrigger['status']) {
            case TRIGGER_STATUS_ENABLED:
                switch ($dbTrigger['value']) {
                    case TRIGGER_VALUE_FALSE:
                        $status['triggers_count_off'] = $dbTrigger['cnt'];
                        break;
                    case TRIGGER_VALUE_TRUE:
                        $status['triggers_count_on'] = $dbTrigger['cnt'];
                        break;
                    case TRIGGER_VALUE_UNKNOWN:
                        $status['triggers_count_unknown'] = $dbTrigger['cnt'];
                        break;
                }
                break;
            case TRIGGER_STATUS_DISABLED:
                $status['triggers_count_disabled'] += $dbTrigger['cnt'];
                break;
        }
    }
    $status['triggers_count_enabled'] = $status['triggers_count_off'] + $status['triggers_count_on'] + $status['triggers_count_unknown'];
    $status['triggers_count'] = $status['triggers_count_enabled'] + $status['triggers_count_disabled'];
    // items
    $dbItems = DBselect('SELECT COUNT(*) AS cnt,i.status' . ' FROM items i' . ' INNER JOIN hosts h ON i.hostid=h.hostid' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND ' . dbConditionInt('i.status', array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED)) . ' GROUP BY i.status');
    while ($dbItem = DBfetch($dbItems)) {
        switch ($dbItem['status']) {
            case ITEM_STATUS_ACTIVE:
                $status['items_count_monitored'] = $dbItem['cnt'];
                break;
            case ITEM_STATUS_DISABLED:
                $status['items_count_disabled'] = $dbItem['cnt'];
                break;
            case ITEM_STATUS_NOTSUPPORTED:
                $status['items_count_not_supported'] = $dbItem['cnt'];
                break;
        }
    }
    $status['items_count'] = $status['items_count_monitored'] + $status['items_count_disabled'] + $status['items_count_not_supported'];
    // hosts
    $dbHosts = DBselect('SELECT COUNT(*) AS cnt,h.status' . ' FROM hosts h' . ' WHERE h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ' )' . ' GROUP BY h.status');
    while ($dbHost = DBfetch($dbHosts)) {
        switch ($dbHost['status']) {
            case HOST_STATUS_MONITORED:
                $status['hosts_count_monitored'] = $dbHost['cnt'];
                break;
            case HOST_STATUS_NOT_MONITORED:
                $status['hosts_count_not_monitored'] = $dbHost['cnt'];
                break;
            case HOST_STATUS_TEMPLATE:
                $status['hosts_count_template'] = $dbHost['cnt'];
                break;
        }
    }
    $status['hosts_count'] = $status['hosts_count_monitored'] + $status['hosts_count_not_monitored'] + $status['hosts_count_template'];
    // users
    $row = DBfetch(DBselect('SELECT COUNT(*) AS usr_cnt FROM users u WHERE ' . DBin_node('u.userid')));
    $status['users_count'] = $row['usr_cnt'];
    $status['users_online'] = 0;
    $db_sessions = DBselect('SELECT s.userid,s.status,MAX(s.lastaccess) AS lastaccess' . ' FROM sessions s' . ' WHERE ' . DBin_node('s.userid') . ' AND s.status=' . ZBX_SESSION_ACTIVE . ' GROUP BY s.userid,s.status');
    while ($session = DBfetch($db_sessions)) {
        if ($session['lastaccess'] + ZBX_USER_ONLINE_TIME >= time()) {
            $status['users_online']++;
        }
    }
    // comments: !!! Don't forget sync code with C !!!
    $row = DBfetch(DBselect('SELECT SUM(CAST(1.0/i.delay AS DECIMAL(20,10))) AS qps' . ' FROM items i,hosts h' . ' WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND i.hostid=h.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.delay<>0' . ' AND i.flags<>' . ZBX_FLAG_DISCOVERY_CHILD));
    $status['qps_total'] = round($row['qps'], 2);
    return $status;
}
     }
     array_multisort($sortClock, SORT_ASC, $sortEvent, SORT_ASC, $result);
     break;
 case 'message.closeAll':
     $msgsettings = getMessageSettings();
     switch (strtolower($data['params']['caption'])) {
         case 'events':
             $msgsettings['last.clock'] = (int) $data['params']['time'] + 1;
             updateMessageSettings($msgsettings);
             break;
     }
     break;
 case 'zabbix.status':
     $session = Z::getInstance()->getSession();
     if (!isset($session['serverCheckResult']) || $session['serverCheckTime'] + SERVER_CHECK_INTERVAL <= time()) {
         $session['serverCheckResult'] = zabbixIsRunning();
         $session['serverCheckTime'] = time();
     }
     $result = array('result' => (bool) $session['serverCheckResult'], 'message' => $session['serverCheckResult'] ? '' : _('Zabbix server is not running: the information displayed may not be current.'));
     break;
 case 'screen.get':
     $options = array('pageFile' => !empty($data['pageFile']) ? $data['pageFile'] : null, 'mode' => !empty($data['mode']) ? $data['mode'] : null, 'timestamp' => !empty($data['timestamp']) ? $data['timestamp'] : time(), 'resourcetype' => !empty($data['resourcetype']) ? $data['resourcetype'] : null, 'screenitemid' => !empty($data['screenitemid']) ? $data['screenitemid'] : null, 'groupid' => !empty($data['groupid']) ? $data['groupid'] : null, 'hostid' => !empty($data['hostid']) ? $data['hostid'] : null, 'period' => !empty($data['period']) ? $data['period'] : null, 'stime' => !empty($data['stime']) ? $data['stime'] : null, 'profileIdx' => !empty($data['profileIdx']) ? $data['profileIdx'] : null, 'profileIdx2' => !empty($data['profileIdx2']) ? $data['profileIdx2'] : null, 'updateProfile' => isset($data['updateProfile']) ? $data['updateProfile'] : null);
     if ($options['resourcetype'] == SCREEN_RESOURCE_HISTORY) {
         $options['itemid'] = !empty($data['itemid']) ? $data['itemid'] : null;
         $options['action'] = !empty($data['action']) ? $data['action'] : null;
         $options['filter'] = !empty($data['filter']) ? $data['filter'] : null;
         $options['filter_task'] = !empty($data['filter_task']) ? $data['filter_task'] : null;
         $options['mark_color'] = !empty($data['mark_color']) ? $data['mark_color'] : null;
     } elseif ($options['resourcetype'] == SCREEN_RESOURCE_CHART) {
         $options['graphid'] = !empty($data['graphid']) ? $data['graphid'] : null;
         $options['profileIdx2'] = $options['graphid'];