require_once $centreon_path . 'www/class/centreonACL.class.php';
require_once $centreon_path . 'www/class/centreonHost.class.php';
/* load smarty Class */
require_once $centreon_path . 'GPL_LIB/Smarty/libs/Smarty.class.php';
session_start();
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
/* INIT */
$colors = array(0 => '#8FCF3C', 1 => '#ff9a13', 2 => '#e00b3d', 3 => '#bcbdc0', 4 => '#2AD1D4');
try {
    global $pearDB;
    $db_centreon = new CentreonDB();
    $db = new CentreonDB("centstorage");
    $pearDB = $db_centreon;
    if ($centreon->user->admin == 0) {
        $access = new CentreonACL($centreon->user->get_id());
        $grouplist = $access->getAccessGroups();
        $grouplistStr = $access->getAccessGroupsString();
    }
    $widgetObj = new CentreonWidget($centreon, $db_centreon);
    $preferences = $widgetObj->getWidgetPreferences($widgetId);
    $autoRefresh = 0;
    if (isset($preferences['refresh_interval'])) {
        $autoRefresh = $preferences['refresh_interval'];
    }
} catch (Exception $e) {
    echo $e->getMessage() . "<br/>";
    exit;
require_once $centreon_path . 'www/class/centreonDuration.class.php';
require_once $centreon_path . 'www/class/centreonUtils.class.php';
require_once $centreon_path . 'www/class/centreonACL.class.php';
require_once $centreon_path . 'www/class/centreonHost.class.php';
session_start();
//load smarty
require_once $centreon_path . 'GPL_LIB/Smarty/libs/Smarty.class.php';
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
try {
    global $pearDB;
    $db_centreon = new CentreonDB("centreon");
    $db = new CentreonDB("centstorage");
    $pearDB = $db_centreon;
    $widgetObj = new CentreonWidget($centreon, $db_centreon);
    $preferences = $widgetObj->getWidgetPreferences($widgetId);
    $autoRefresh = 0;
    if (isset($preferences['refresh_interval'])) {
        $autoRefresh = $preferences['refresh_interval'];
    }
} catch (Exception $e) {
    echo $e->getMessage() . "<br/>";
    exit;
}
//configure smarty
if ($centreon->user->admin == 0) {
    $access = new CentreonACL($centreon->user->get_id());
    $grouplist = $access->getAccessGroups();
 * distribute the resulting executable under terms of Centreon choice, provided that
 * Centreon also meet, for each linked independent module, the terms  AND conditions
 * of the license of that module. An independent module is a module which is not
 * derived from this program. If you modify this program, you may extend this
 * exception to your version of the program, but you are not obliged to do so. If you
 * do not wish to do so, delete this exception statement from your version.
 *
 * 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;
require_once $centreon_path . 'www/class/centreonAuth.class.php';
require_once $centreon_path . 'www/class/centreonLog.class.php';
require_once $centreon_path . 'www/class/centreonUser.class.php';
require_once $centreon_path . 'www/class/centreonSession.class.php';
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;
 * SVN : $URL: http://svn.centreon.com/branches/centreon-2.3.x/www/include/views/graphs/generateGraphs/generateImage.php $
 * 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";
    exit;
}
$db = new CentreonDB();
if (CentreonSession::checkSession(session_id(), $db) == 0) {
    exit;
}
// Init Smarty
$template = new Smarty();
$template = initSmartyTplForPopup($centreon_path . "www/widgets/open-tickets/src/", $template, "./", $centreon_path);
/* Init Objects */
$criticality = new CentreonCriticality($db);
$media = new CentreonMedia($db);
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
$page = $_REQUEST['page'];
$dbb = new CentreonDB("centstorage");
$widgetObj = new CentreonWidget($centreon, $db);
$preferences = $widgetObj->getWidgetPreferences($widgetId);
// Set Colors Table
$res = $db->query("SELECT `key`, `value` FROM `options` WHERE `key` LIKE 'color%'");
$stateSColors = array(0 => "#13EB3A", 1 => "#F8C706", 2 => "#F91D05", 3 => "#DCDADA", 4 => "#2AD1D4");
$stateHColors = array(0 => "#13EB3A", 1 => "#F91D05", 2 => "#DCDADA", 3 => "#2AD1D4");
while ($row = $res->fetchRow()) {
    if ($row['key'] == "color_ok") {
        $stateSColors[0] = $row['value'];
    } elseif ($row['key'] == "color_warning") {
        $stateSColors[1] = $row['value'];
    } elseif ($row['key'] == "color_critical") {
        $stateSColors[2] = $row['value'];
    } elseif ($row['key'] == "color_unknown") {
        $stateSColors[3] = $row['value'];
Example #7
0
}
$db = new CentreonDB();
if (CentreonSession::checkSession(session_id(), $db) == 0) {
    exit;
}
// Init Smarty
$template = new Smarty();
$template = initSmartyTplForPopup($centreon_path . "www/widgets/open-tickets/src/templates/", $template, "./", $centreon_path);
/* Init Objects */
$criticality = new CentreonCriticality($db);
$media = new CentreonMedia($db);
$rule = new Centreon_OpenTickets_Rule($db);
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
$page = $_REQUEST['page'];
$dbb = new CentreonDB("centstorage");
$widgetObj = new CentreonWidget($centreon, $db);
$preferences = $widgetObj->getWidgetPreferences($widgetId);
if (!isset($preferences['rule'])) {
    exit;
}
$macro_tickets = $rule->getMacroNames($preferences['rule'], $widgetId);
// Set Colors Table
$res = $db->query("SELECT `key`, `value` FROM `options` WHERE `key` LIKE 'color%'");
$stateSColors = array(0 => "#13EB3A", 1 => "#F8C706", 2 => "#F91D05", 3 => "#DCDADA", 4 => "#2AD1D4");
$stateHColors = array(0 => "#13EB3A", 1 => "#F91D05", 2 => "#DCDADA", 3 => "#2AD1D4");
while ($row = $res->fetchRow()) {
    if ($row['key'] == "color_ok") {
        $stateSColors[0] = $row['value'];
    } elseif ($row['key'] == "color_warning") {
        $stateSColors[1] = $row['value'];
Example #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;
 }
}
/* Test if the session id for authentification */
if (false === isset($_GET['session_id'])) {
    sendJson("Forbidden access", 403);
}
$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) {
 /**
  * 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'];
 }
 * distribute the resulting executable under terms of Centreon choice, provided that
 * Centreon also meet, for each linked independent module, the terms  and conditions
 * of the license of that module. An independent module is a module which is not
 * derived from this program. If you modify this program, you may extend this
 * exception to your version of the program, but you are not obliged to do so. If you
 * do not wish to do so, delete this exception statement from your version.
 *
 * 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;
}
 * For more information : contact@centreon.com
 *
 */
require_once "../require.php";
require_once $centreon_path . 'www/class/centreon.class.php';
require_once $centreon_path . 'www/class/centreonSession.class.php';
require_once $centreon_path . 'www/class/centreonDB.class.php';
require_once $centreon_path . 'www/class/centreonWidget.class.php';
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) {
require_once $centreon_path . 'www/class/centreonSession.class.php';
require_once $centreon_path . 'www/class/centreonDB.class.php';
require_once $centreon_path . 'www/class/centreonWidget.class.php';
require_once $centreon_path . 'www/class/centreonUtils.class.php';
require_once $centreon_path . 'www/class/centreonACL.class.php';
require_once $centreon_path . "GPL_LIB/Smarty/libs/Smarty.class.php";
session_start();
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId']) || !isset($_REQUEST['page'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$db = new CentreonDB();
if (CentreonSession::checkSession(session_id(), $db) == 0) {
    exit;
}
$dbb = new CentreonDB("centstorage");
$path = $centreon_path . "www/widgets/logs/src/";
$template = new Smarty();
$template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
$page = $_REQUEST['page'];
$widgetObj = new CentreonWidget($centreon, $db);
$preferences = $widgetObj->getWidgetPreferences($widgetId);
// Get status colors
$stateHColors = getStatusColors($db, 'host');
$stateSColors = getStatusColors($db, 'service');
$stateINColors = getStatusColors($db, 'info');
// Get status labels
$stateHLabels = getStatusLabels('host');
$stateSLabels = getStatusLabels('service');
require_once $centreon_path . 'www/class/centreonDuration.class.php';
require_once $centreon_path . 'www/class/centreonUtils.class.php';
require_once $centreon_path . 'www/class/centreonACL.class.php';
require_once $centreon_path . 'www/class/centreonHost.class.php';
//load Smarty
require_once $centreon_path . 'GPL_LIB/Smarty/libs/Smarty.class.php';
session_start();
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
try {
    global $pearDB;
    $db_centreon = new CentreonDB("centreon");
    $db = new CentreonDB("centstorage");
    $pearDB = $db_centreon;
    $widgetObj = new CentreonWidget($centreon, $db_centreon);
    $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            FROM index_data\n            WHERE host_id = " . $db->escape($tab[0]) . "\n            AND service_id = " . $db->escape($tab[1]) . "\n            LIMIT 1");
ini_set("display_errors", "Off");
require_once "../require.php";
require_once $centreon_path . 'www/class/centreon.class.php';
require_once $centreon_path . 'www/class/centreonSession.class.php';
require_once $centreon_path . 'www/class/centreonDB.class.php';
require_once $centreon_path . 'www/class/centreonWidget.class.php';
session_start();
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
try {
    global $pearDB;
    $db = new CentreonDB();
    $db2 = new CentreonDB("centstorage");
    $pearDB = $db;
    if ($centreon->user->admin == 0) {
        $access = new CentreonACL($centreon->user->get_id());
        $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'];
    }
    /*
     * Prepare URL
     */
    $widgetObj = new CentreonWidget($centreon, $db_centreon);
    $preferences = $widgetObj->getWidgetPreferences($widgetId);
    $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';";
    exit;
}
$prefixRes = $db->query("SELECT db_prefix FROM cfg_ndo2db WHERE activate = '1' LIMIT 1");
if (!$prefixRes->numRows()) {
    exit;
}
$prefixRow = $prefixRes->fetchRow();
$ndoPrefix = $prefixRow['db_prefix'];
require_once $centreon_path . "GPL_LIB/Smarty/libs/Smarty.class.php";
$path = $centreon_path . "www/widgets/servicegroup-monitoring/src/";
$template = new Smarty();
$template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
$page = $_REQUEST['page'];
$dbb = new CentreonDB("ndo");
$widgetObj = new CentreonWidget($centreon, $db);
$sgMonObj = new ServicegroupMonitoring($dbb);
$preferences = $widgetObj->getWidgetPreferences($widgetId);
$pearDB = $db;
$aclObj = new CentreonACL($centreon->user->user_id, $centreon->user->admin);
$res = $db->query("SELECT `key`, `value` FROM `options` WHERE `key` LIKE 'color%'");
$hostStateColors = array(0 => "#19EE11", 1 => "#F91E05", 2 => "#82CFD8", 4 => "#2AD1D4");
$serviceStateColors = array(0 => "#13EB3A", 1 => "#F8C706", 2 => "#F91D05", 3 => "#DCDADA", 4 => "#2AD1D4");
while ($row = $res->fetchRow()) {
    if ($row['key'] == "color_up") {
        $hostStateColors[0] = $row['value'];
    } elseif ($row['key'] == "color_down") {
        $hostStateColors[1] = $row['value'];
    } elseif ($row['key'] == "color_unreachable") {
        $hostStateColors[2] = $row['value'];
ini_set("display_errors", "Off");
require_once "../require.php";
require_once $centreon_path . 'www/class/centreon.class.php';
require_once $centreon_path . 'www/class/centreonSession.class.php';
require_once $centreon_path . 'www/class/centreonDB.class.php';
require_once $centreon_path . 'www/class/centreonWidget.class.php';
session_start();
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
$widgetId = $_REQUEST['widgetId'];
try {
    global $pearDB;
    $db = new CentreonDB();
    $db2 = new CentreonDB("centstorage");
    $pearDB = $db;
    if ($centreon->user->admin == 0) {
        $access = new CentreonACL($centreon->user->get_id());
        $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
     */