index.php 4.3 KB
Newer Older
1
<?php
2

3
4
/*
 * Copyright 2005-2020 Centreon
5
 * Centreon is developed by : Julien Mathis and Romain Le Merlus under
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 * GPL Licence 2.0.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation ; either version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, see <http://www.gnu.org/licenses>.
 *
 * Linking this program statically or dynamically with other modules is making a
 * combined work based on this program. Thus, the terms and conditions of the GNU
 * General Public License cover the whole combination.
 *
23
 * As a special exception, the copyright holders of this program give Centreon
24
25
 * permission to link this program with independent modules to produce an executable,
 * regardless of the license terms of these independent modules, and to copy and
26
27
 * distribute the resulting executable under terms of Centreon choice, provided that
 * Centreon also meet, for each linked independent module, the terms  and conditions
28
29
30
31
32
33
34
35
36
37
38
39
40
 * 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
 *
 */

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/centreonWidget.class.php';
ClaireGizard's avatar
ClaireGizard committed
41
42
43
44
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';
Guillaume28's avatar
Guillaume28 committed
45
require_once $centreon_path . 'bootstrap.php';
ClaireGizard's avatar
ClaireGizard committed
46

47
CentreonSession::start(1);
48

49
50
51
52
if (!isset($_SESSION['centreon']) || !isset($_REQUEST['widgetId'])) {
    exit;
}
$centreon = $_SESSION['centreon'];
53
$widgetId = filter_input(INPUT_GET, 'widgetId', FILTER_VALIDATE_INT, ['options' => ['default' => 0]]);
54
55

try {
Guillaume28's avatar
Guillaume28 committed
56
57
    $db_centreon = $dependencyInjector['configuration_db'];
    $db = $dependencyInjector['realtime_db'];
ClaireGizard's avatar
ClaireGizard committed
58

59
60
61
62
63
    if ($centreon->user->admin == 0) {
        $access = new CentreonACL($centreon->user->get_id());
        $grouplist = $access->getAccessGroups();
        $grouplistStr = $access->getAccessGroupsString();
    }
ClaireGizard's avatar
ClaireGizard committed
64

65
66
    $widgetObj = new CentreonWidget($centreon, $db_centreon);
    $preferences = $widgetObj->getWidgetPreferences($widgetId);
67
68
69
    $autoRefresh = (isset($preferences['refresh_interval']) && (int)$preferences['refresh_interval'] > 0)
        ? (int)$preferences['refresh_interval']
        : 30;
70
71
72
73
74
    $variablesThemeCSS = match ($centreon->user->theme) {
        'light' => "Generic-theme",
        'dark' => "Centreon-Dark",
        default => throw new \Exception('Unknown user theme : ' . $centreon->user->theme),
    };
75
76
77
78
79
} catch (Exception $e) {
    echo $e->getMessage() . "<br/>";
    exit;
}

ClaireGizard's avatar
ClaireGizard committed
80
81
82
$path = $centreon_path . "www/widgets/tactical-overview/src/";
$template = new Smarty();
$template = initSmartyTplForPopup($path, $template, "./", $centreon_path);
83

84
85
86
87
88
89
90
$template->assign(
    'theme',
    $variablesThemeCSS === 'Generic-theme'
        ? $variablesThemeCSS . '/Variables-css'
        : $variablesThemeCSS
);

91
92
93
94
95
$kernel = \App\Kernel::createForWeb();
$resourceController = $kernel->getContainer()->get(
    \Centreon\Application\Controller\MonitoringResourceController::class
);

96
$buildParameter = function (string $id, string $name) {
97
98
99
100
101
102
    return [
        'id' => $id,
        'name' => $name,
    ];
};

103
104
if (
    isset($preferences['object_type'])
105
106
    && ($preferences['object_type'] === "hosts" || $preferences['object_type'] == "")
) {
107
    require_once 'src/hosts_status.php';
108
} elseif (isset($preferences['object_type']) && $preferences['object_type'] === "services") {
109
    require_once 'src/services_status.php';
110
}