$search = $tab[1];
    }
    if ($op && isset($search) && $search != "") {
        $query = CentreonUtils::conditionBuilder($query, "name1 " . CentreonUtils::operandToMysqlFormat($op) . " '" . $dbb->escape($search) . "' ");
    }
}
if (!$centreon->user->admin) {
    $query = CentreonUtils::conditionBuilder($query, "name1 IN (" . $aclObj->getServiceGroupsString("NAME") . ")");
}
$orderby = "name ASC";
if (isset($preferences['order_by']) && $preferences['order_by'] != "") {
    $orderby = $preferences['order_by'];
}
$query .= "ORDER BY {$orderby}";
$query .= " LIMIT " . $page * $preferences['entries'] . "," . $preferences['entries'];
$res = $dbb->query($query);
$nbRows = $dbb->numberRows();
$data = array();
$detailMode = false;
if (isset($preferences['enable_detailed_mode']) && $preferences['enable_detailed_mode']) {
    $detailMode = true;
}
while ($row = $res->fetchRow()) {
    foreach ($row as $key => $value) {
        $data[$row['name']][$key] = $value;
        $data[$row['name']]['host_state'] = $sgMonObj->getHostStates($row['name'], $detailMode, $centreon->user->admin, $aclObj, $preferences, true, $ndoPrefix);
        $data[$row['name']]['service_state'] = $sgMonObj->getServiceStates($row['name'], $detailMode, $centreon->user->admin, $aclObj, $preferences, true, $ndoPrefix);
    }
}
$template->assign('preferences', $preferences);
$template->assign('hostStateLabels', $hostStateLabels);
$inc = 0;
$services = explode(",", $preferences['service']);
if (count($services)) {
    $query3 .= " AND (";
    foreach ($services as $elem) {
        if (!$inc) {
            $query3 .= "T1.description LIKE '{$elem}'";
        } else {
            $query3 .= " OR T1.description like '{$elem}'";
        }
        $inc++;
    }
    $query3 .= ")";
}
/* Get host listing */
$res = $db->query($query1);
while ($row = $res->fetchRow()) {
    $data[] = $row;
}
/* Get service listing */
$res2 = $db->query($query2);
while ($row = $res2->fetchRow()) {
    $data_service[$row['description']] = array('description' => $row['description'], 'hosts' => array(), 'hostsStatus' => array());
}
/* Get host service statuses */
$res3 = $db->query($query3);
while ($row = $res3->fetchRow()) {
    if (isset($data_service[$row['description']])) {
        $data_service[$row['description']]['hosts'][] = $row['host_id'];
        $data_service[$row['description']]['hostsStatus'][$row['host_id']] = $colors[$row['state']];
    }
     $grouplistStr = $access->getAccessGroupsString();
 }
 $widgetObj = new CentreonWidget($centreon, $db);
 $preferences = $widgetObj->getWidgetPreferences($widgetId);
 $autoRefresh = 0;
 if (isset($preferences['refresh_interval'])) {
     $autoRefresh = $preferences['refresh_interval'];
 }
 /*
  * Prepare URL
  */
 if (isset($preferences['service']) && $preferences['service']) {
     $tab = split("-", $preferences['service']);
     $host_name = "";
     $service_description = "";
     $res = $db2->query("SELECT host_name, service_description\n    \t\tFROM index_data\n    \t\tWHERE host_id = " . $db->escape($tab[0]) . "\n    \t\tAND service_id = " . $db->escape($tab[1]) . "\n    \t\tLIMIT 1");
     if ($res->numRows()) {
         $row = $res->fetchRow();
         $host_name = $row["host_name"];
         $service_description = $row["service_description"];
     }
 }
 /*
  * Check ACL
  */
 $acl = 1;
 if (isset($tab[0]) && isset($tab[1]) && $centreon->user->admin == 0) {
     $query = "SELECT host_id FROM centreon_acl WHERE host_id = " . $db->escape($tab[0]) . " AND service_id = " . $db->escape($tab[1]) . " AND group_id IN (" . $grouplistStr . ")";
     $res = $db2->query($query);
     if (!$res->numRows()) {
         $acl = 0;
 * SVN : $Id: generateImage.php 12494 2011-09-15 07:28:16Z shotamchay $
 *
 */
/**
 * Include config file
 */
include "../../require.php";
require_once $centreon_path . '/www/class/centreonGraph.class.php';
require_once $centreon_path . '/www/class/centreonDB.class.php';
session_start();
if (!isset($_GET['service']) || !isset($_GET['session_id'])) {
    exit;
}
list($hostId, $serviceId) = explode('-', $_GET['service']);
$db = new CentreonDB("centstorage");
$res = $db->query("SELECT `id`\n\t\t\t\t   FROM index_data\n    \t\t\t   WHERE host_id = " . $db->escape($hostId) . "\n    \t\t\t   AND service_id = " . $db->escape($serviceId) . "\n    \t\t\t   LIMIT 1");
if ($res->numRows()) {
    $row = $res->fetchRow();
    $index = $row["id"];
} else {
    $index = 0;
}
/**
 * Create XML Request Objects
 */
$obj = new CentreonGraph($_GET["session_id"], $index, 0, 1);
if (trim(session_id()) != trim($_GET['session_id'])) {
    $obj->displayError();
}
require_once $centreon_path . "www/include/common/common-Func.php";
/**
 * For more information : contact@centreon.com
 *
 */
$dataCRI = array();
$dataWA = array();
$dataOK = array();
$dataUNK = array();
$dataPEND = array();
$db = new CentreonDB("centstorage");
$queryCRI = "SELECT SUM(CASE WHEN s.state = 2 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status,\n         SUM(CASE WHEN s.acknowledged = 1 AND s.state = 2 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS ack,                                                                                                      \n         SUM(CASE WHEN s.scheduled_downtime_depth = 1 AND s.state = 2 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS down,\n         SUM(CASE WHEN s.state = 2 AND (h.state = 1 or h.state = 4 or h.state = 2) AND s.enabled = 1 AND h.name not like '%Module%' then 1 else 0 END) AS pb\n         FROM services AS s\n         LEFT JOIN hosts AS h ON h.host_id = s.host_id " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ") \n         GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryWA = "SELECT SUM(CASE WHEN s.state = 1 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status,                                                                                                               \n         SUM(CASE WHEN s.acknowledged = 1 AND s.state = 1 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS ack,                                                                                                     \n         SUM(CASE WHEN s.scheduled_downtime_depth = 1 AND s.state = 1 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS down,\n         SUM(CASE WHEN s.state = 1 AND (h.state = 1 or h.state = 4 or h.state = 2) AND s.enabled = 1 AND h.name not like '%Module%' then 1 else 0 END) AS pb                                                                               \n         FROM services AS s\n         LEFT JOIN hosts AS h ON h.host_id = s.host_id " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n         GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryOK = "SELECT SUM(CASE WHEN s.state = 0 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status \n         FROM services AS s\n         LEFT JOIN hosts AS h ON h.host_id = s.host_id " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n         GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryPEND = "SELECT SUM(CASE WHEN s.state = 4 AND s.enabled AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status                                                                                                              \n           FROM services AS s\n           LEFT JOIN hosts AS h ON h.host_id = s.host_id " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n           GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$queryUNK = "SELECT SUM(CASE WHEN s.state = 3 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS status,\n          SUM(CASE WHEN s.acknowledged = 1 AND s.state = 3 AND s.enabled = 1 AND h.name not like '%Module%' THEN 1 ELSE 0 END) AS ack,                                                                                                  \n          SUM(CASE WHEN s.state = 3 AND s.enabled = 1 AND h.name not like '%Module%' AND (s.scheduled_downtime_depth = 1 or h.scheduled_downtime_depth = 1) THEN 1 ELSE 0 END) AS down,\n          SUM(CASE WHEN s.state = 3 AND (h.state = 1 or h.state = 4 or h.state = 2) AND s.enabled = 1 AND h.name not like '%Module%' then 1 else 0 END) AS pb\n          FROM services AS s\n          LEFT JOIN hosts AS h ON h.host_id = s.host_id " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n          GROUP BY host_id,service_id) x ON x.host_id = h.host_id AND x.service_id = s.service_id" : "") . ";";
$numLine = 1;
$res = $db->query($queryCRI);
while ($row = $res->fetchRow()) {
    $row['un'] = $row['status'] - ($row['ack'] + $row['down'] + $row['pb']);
    $dataCRI[] = $row;
}
$res = $db->query($queryWA);
while ($row = $res->fetchRow()) {
    $row['un'] = $row['status'] - ($row['ack'] + $row['down'] + $row['pb']);
    $dataWA[] = $row;
}
$res = $db->query($queryOK);
while ($row = $res->fetchRow()) {
    $dataOK[] = $row;
}
$res = $db->query($queryPEND);
while ($row = $res->fetchRow()) {
    $autoRefresh = 0;
    $autoRefresh = $preferences['autoRefresh'];
} catch (Exception $e) {
    echo $e->getMessage() . "<br/>";
    exit;
}
$path = $centreon_path . "www/widgets/engine-status/src/";
$template = new Smarty();
$template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
$dataLat = array();
$dataEx = array();
$dataSth = array();
$dataSts = array();
$db = new CentreonDB("centstorage");
$queryName = "Select T1.name, T1.instance_id as instance, T2.instance_id\n             FROM instances T1, hosts T2\n             WHERE T1.name like '%" . $preferences['poller'] . "%';";
$res = $db->query($queryName);
while ($row = $res->fetchRow()) {
    $idP = $row['instance'];
}
$queryLat = "Select Max(T1.latency) as h_max, AVG(T1.latency) as h_moy, Max(T2.latency) as s_max, AVG(T2.latency) as s_moy \n             from hosts T1, services T2  \n             where T1.instance_id = " . $idP . " and T1.host_id = T2.host_id and T2.enabled = '1';";
$res = $db->query($queryLat);
while ($row = $res->fetchRow()) {
    $row['h_max'] = round($row['h_max'], 3);
    $row['h_moy'] = round($row['h_moy'], 3);
    $row['s_max'] = round($row['s_max'], 3);
    $row['s_moy'] = round($row['s_moy'], 3);
    $dataLat[] = $row;
}
$queryEx = "Select Max(T1.execution_time) as h_max, AVG(T1.execution_time) as h_moy, Max(T2.execution_time) as s_max, AVG(T2.execution_time) as s_moy \n            from hosts T1, services T2  \n            where T1.instance_id = " . $idP . " and T1.host_id = T2.host_id and T2.enabled = '1';";
$res = $db->query($queryEx);
while ($row = $res->fetchRow()) {
Esempio n. 7
0
require_once $centreon_path . 'www/class/centreon.class.php';
require_once $centreon_path . 'www/class/centreonACL.class.php';
include_once $centreon_path . 'www/include/reporting/dashboard/DB-Func.php';
include_once $centreon_path . "www/include/common/common-Func.php";
require_once "Mail-Func.php";
require_once "PDF-Func.php";
require_once "DB-Func.php";
## Get centreon version
/*
 * Connector to centreon DB
 */
$pearDB = new CentreonDB();
// Bug #1556
//$pearDBndo = new CentreonDB("ndo");
$pearDBO = new CentreonDB("centstorage");
$DBRESULT =& $pearDB->query("SELECT `value` FROM `informations` WHERE `key` = 'version'");
$version =& $DBRESULT->fetchRow();
$centreon_version = substr(str_replace(".", "", $version["value"]), 0, 3);
if ($centreon_version >= 220) {
    require_once $centreon_path . "www/class/centreonDuration.class.php";
} else {
    require_once $centreon_path . "www/class/other.class.php";
}
function getCentreonVersion()
{
    ## Get centreon version
    global $pearDB;
    $DBRESULT =& $pearDB->query("SELECT `value` FROM `informations` WHERE `key` = 'version'");
    $version =& $DBRESULT->fetchRow();
    $centreon_version = substr(str_replace(".", "", $version["value"]), 0, 3);
    return $centreon_version;
Esempio n. 8
0
 public function loadSelection($db_storage = null, $cmd, $selection)
 {
     global $centreon_bg;
     if (is_null($db_storage)) {
         $db_storage = new CentreonDB('centstorage');
     }
     $selected_values = explode(',', $selection);
     $selected = array('host_selected' => array(), 'service_selected' => array());
     if ($cmd == 3) {
         $selected_str = '';
         $selected_str_append = '';
         foreach ($selected_values as $value) {
             $str = explode(';', $value);
             $selected_str .= $selected_str_append . 'services.host_id = ' . $str[0] . ' AND services.service_id = ' . $str[1];
             $selected_str_append = ' OR ';
         }
         $query = "SELECT services.*, hosts.state as host_state, hosts.name as host_name, hosts.instance_id FROM services, hosts";
         $query_where = " WHERE (" . $selected_str . ') AND services.host_id = hosts.host_id';
         if (!$centreon_bg->is_admin) {
             $query_where .= " AND EXISTS(SELECT * FROM centreon_acl WHERE centreon_acl.group_id IN (" . $centreon_bg->grouplistStr . ") AND hosts.host_id = centreon_acl.host_id \n                AND services.service_id = centreon_acl.service_id)";
         }
         $DBRESULT = $db_storage->query($query . $query_where);
         while ($row = $DBRESULT->fetchRow()) {
             $row['service_state'] = $row['state'];
             $row['state_str'] = $this->getServiceStateStr($row['state']);
             $row['last_state_change_duration'] = CentreonDuration::toString(time() - $row['last_state_change']);
             $row['last_hard_state_change_duration'] = CentreonDuration::toString(time() - $row['last_hard_state_change']);
             $selected['service_selected'][] = $row;
         }
     } else {
         if ($cmd == 4) {
             $hosts_selected_str = '';
             $hosts_selected_str_append = '';
             foreach ($selected_values as $value) {
                 $str = explode(';', $value);
                 $hosts_selected_str .= $hosts_selected_str_append . $str[0];
                 $hosts_selected_str_append = ', ';
             }
             $query = "SELECT * FROM hosts";
             $query_where = " WHERE host_id IN (" . $hosts_selected_str . ")";
             if (!$centreon_bg->is_admin) {
                 $query_where .= " AND EXISTS(SELECT * FROM centreon_acl WHERE centreon_acl.group_id IN (" . $centreon_bg->grouplistStr . ") AND hosts.host_id = centreon_acl.host_id)";
             }
             $DBRESULT = $db_storage->query($query . $query_where);
             while ($row = $DBRESULT->fetchRow()) {
                 $row['host_state'] = $row['state'];
                 $row['state_str'] = $this->getHostStateStr($row['state']);
                 $row['last_state_change_duration'] = CentreonDuration::toString(time() - $row['last_state_change']);
                 $row['last_hard_state_change_duration'] = CentreonDuration::toString(time() - $row['last_hard_state_change']);
                 $selected['host_selected'][] = $row;
             }
         }
     }
     return $selected;
 }
}
$sid = $_GET['session_id'];
/* Test session id format */
$match = preg_match("/^[\\w-]+\$/", $sid);
if (false === $match || 0 === $match) {
    sendJson("Forbidden access", 403);
}
require_once $centreon_path . "/www/class/centreonDB.class.php";
require_once $centreon_path . "/www/class/centreonACL.class.php";
require_once dirname(dirname(__FILE__)) . "/class/GraphService.php";
#require_once dirname("GraphService.php");
$pearDB = new CentreonDB();
$pearDBD = new CentreonDB("centstorage");
$sid = CentreonDB::escape($sid);
/* Check if session is initialised */
$res = $pearDB->query("SELECT s.user_id, c.contact_admin FROM session s, contact c WHERE s.user_id = c.contact_id AND s.session_id = '" . $sid . "'");
if (PEAR::isError($res)) {
    sendJson("Internal Server Error", 500);
}
$row = $res->fetchRow();
if (is_null($row)) {
    sendJson("Forbidden access", 403);
}
$isAdmin = $row['contact_admin'];
$userId = $row['user_id'];
/* Get ACL if user is not admin */
if (!$isAdmin) {
    $acl = new CentreonACL($userId, $isAdmin);
    $aclGroups = $acl->getAccessGroupsString();
}
/* Validate options */
 *
 * For more information : contact@centreon.com
 *
 */
$dataDO = array();
$dataUN = array();
$dataUP = array();
$dataPEND = array();
$dataList = array();
$db = new CentreonDB("centstorage");
$queryDO = "SELECT SUM(CASE WHEN h.state = 1 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status,\n         SUM(CASE WHEN h.acknowledged = 1 AND h.state = 1 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as ack,\n         SUM(CASE WHEN h.scheduled_downtime_depth = 1 AND h.state = 1 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as down                \n         FROM hosts AS h " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ") \n         GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$queryUN = "SELECT SUM(CASE WHEN h.state = 2 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status,\n         SUM(CASE WHEN h.acknowledged = 1 AND h.state = 2 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as ack,\n         SUM(CASE WHEN h.state = 2 and h.enabled = 1 and h.name not like '%Module% 'and h.scheduled_downtime_depth = 1 THEN 1 ELSE 0 END) as down                 \n         FROM hosts AS h " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n         GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$queryUP = "SELECT SUM(CASE WHEN h.state = 0 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status\n         FROM hosts AS h " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n         GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$queryPEND = "SELECT SUM(CASE WHEN h.state = 4 and h.enabled = 1 and h.name not like '%Module%' THEN 1 ELSE 0 END) as status                   \n         FROM hosts AS h " . ($centreon->user->admin == 0 ? "JOIN (SELECT acl.host_id, acl.service_id FROM centreon_acl AS acl WHERE acl.group_id IN (" . ($grouplistStr != "" ? $grouplistStr : 0) . ")\n         GROUP BY host_id) x ON x.host_id = h.host_id AND x.service_id IS NULL" : "") . ";";
$numLine = 1;
$res = $db->query($queryDO);
while ($row = $res->fetchRow()) {
    $row['un'] = $row['status'] - ($row['ack'] + $row['down']);
    $dataDO[] = $row;
}
$res = $db->query($queryUN);
while ($row = $res->fetchRow()) {
    $row['un'] = $row['status'] - ($row['ack'] + $row['down']);
    $dataUN[] = $row;
}
$res = $db->query($queryUP);
while ($row = $res->fetchRow()) {
    $dataUP[] = $row;
}
$res = $db->query($queryPEND);
while ($row = $res->fetchRow()) {
 /**
  * Get the index data id for a service
  *
  * @param int $hostId The host id
  * @param int $serviceId The service id
  * @param CentreonDB $dbc The database connection to centreon_storage
  * @return int
  */
 public static function getIndexId($hostId, $serviceId, $dbc)
 {
     $query = "SELECT id FROM index_data\n            WHERE host_id = " . $hostId . " AND service_id = " . $serviceId;
     $res = $dbc->query($query);
     $row = $res->fetchRow();
     if (false == $row) {
         throw new OutOfRangeException();
     }
     return $row['id'];
 }
session_start();
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
try {
    $db = new CentreonDB();
    $widgetObj = new CentreonWidget($centreon, $db);
    $preferences = $widgetObj->getWidgetPreferences($widgetId);
    $autoRefresh = 0;
    if (isset($preferences['refresh_interval'])) {
        $autoRefresh = $preferences['refresh_interval'];
    }
    $broker = "broker";
    $res = $db->query("SELECT `value` FROM `options` WHERE `key` = 'broker'");
    if ($res->numRows()) {
        $row = $res->fetchRow();
        $broker = strtolower($row['value']);
    } else {
        throw new Exception('Unknown broker module');
    }
} catch (Exception $e) {
    echo $e->getMessage() . "<br/>";
    exit;
}
?>
<html>
    <style type="text/css">
         body{ margin:0; padding:100px 0 0 0; }
         div#actionBar { position:absolute; top:0; left:0; width:100%; height:25px; background-color: #FFFFFF; }
Esempio n. 13
0
        $idC .= $d1['sc_id'];
    }
    $query .= " AND cv2.`value` IN ({$idC}) ";
}
if (!$centreon->user->admin) {
    $pearDB = $db;
    $aclObj = new CentreonACL($centreon->user->user_id, $centreon->user->admin);
    $groupList = $aclObj->getAccessGroupsString();
    $query .= " AND h.host_id = acl.host_id\n\tAND acl.service_id = s.service_id\n\tAND acl.group_id IN ({$groupList})";
}
$orderby = "hostname ASC , description ASC";
if (isset($preferences['order_by']) && $preferences['order_by'] != "") {
    $orderby = $preferences['order_by'];
}
$query .= "ORDER BY {$orderby}";
$res = $dbb->query($query);
$nbRows = $dbb->numberRows();
$data = array();
$outputLength = $preferences['output_length'] ? $preferences['output_length'] : 50;
$commentLength = $preferences['comment_length'] ? $preferences['comment_length'] : 50;
$hostObj = new CentreonHost($db);
$svcObj = new CentreonService($db);
while ($row = $res->fetchRow()) {
    foreach ($row as $key => $value) {
        if ($key == "last_check") {
            $value = date("Y-m-d H:i:s", $value);
        } elseif ($key == "last_state_change" || $key == "last_hard_state_change") {
            $value = time() - $value;
            $value = CentreonDuration::toString($value);
        } elseif ($key == "check_attempt") {
            $value = $value . "/" . $row['max_check_attempts'];
        $grouplist = $access->getAccessGroups();
        $grouplistStr = $access->getAccessGroupsString();
    }
    $widgetObj = new CentreonWidget($centreon, $db);
    $preferences = $widgetObj->getWidgetPreferences($widgetId);
    $autoRefresh = 0;
    if (isset($preferences['refresh_interval'])) {
        $autoRefresh = $preferences['refresh_interval'];
    }
    /*
     * Check ACL
     */
    $acl = 1;
    if (isset($tab[0]) && isset($tab[1]) && $centreon->user->admin == 0) {
        $query = "SELECT host_id FROM centreon_acl WHERE host_id = " . $db->escape($tab[0]) . " AND service_id = " . $db->escape($tab[1]) . " AND group_id IN (" . $grouplistStr . ")";
        $res = $db2->query($query);
        if (!$res->numRows()) {
            $acl = 0;
        }
    }
} catch (Exception $e) {
    echo $e->getMessage() . "<br/>";
    exit;
}
?>
<html>
<style type="text/css">
         body{ margin:0; padding:0 0 0 0; }
         div#actionBar { position:absolute; top:0; left:0; width:100%; height:25px; background-color: #FFFFFF; }
         @media screen { body>div#actionBar { position: fixed; } }
         * html body { overflow:hidden ; text-align:center;}