/usr/share/zabbix/screens.php is in zabbix-frontend-php 1:1.8.11-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | <?php
/*
** ZABBIX
** Copyright (C) 2000-2010 SIA Zabbix
**
** 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, or
** (at your option) any later version.
**
** 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, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
?>
<?php
require_once('include/config.inc.php');
require_once('include/graphs.inc.php');
require_once('include/screens.inc.php');
require_once('include/blocks.inc.php');
$page['title'] = 'S_CUSTOM_SCREENS';
$page['file'] = 'screens.php';
$page['hist_arg'] = array('elementid', 'screenname');
$page['scripts'] = array('class.calendar.js','gtlc.js');
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
if(PAGE_TYPE_HTML == $page['type']){
define('ZBX_PAGE_DO_REFRESH', 1);
}
include_once('include/page_header.php');
?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
'groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
// STATUS OF TRIGGER
'tr_groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
'tr_hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
'elementid'=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID,null),
'screenname'=> array(T_ZBX_STR, O_OPT, P_SYS, null,null),
'step'=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535),NULL),
'period'=> array(T_ZBX_INT, O_OPT, P_SYS, null,NULL),
'stime'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL,NULL),
'reset'=> array(T_ZBX_STR, O_OPT, P_SYS, IN("'reset'"),NULL),
'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2'), NULL),
//ajax
'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL),
'favref'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL),
'favid'=> array(T_ZBX_INT, O_OPT, P_ACT, NULL, NULL),
'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, NULL),
'action'=> array(T_ZBX_STR, O_OPT, P_ACT, IN("'add','remove','flop'"),NULL)
);
check_fields($fields);
?>
<?php
if(isset($_REQUEST['favobj'])){
if('hat' == $_REQUEST['favobj']){
CProfile::update('web.screens.hats.'.$_REQUEST['favref'].'.state',$_REQUEST['state'], PROFILE_TYPE_INT);
}
if('filter' == $_REQUEST['favobj']){
CProfile::update('web.screens.filter.state',$_REQUEST['state'], PROFILE_TYPE_INT);
}
if('timeline' == $_REQUEST['favobj']){
if(isset($_REQUEST['elementid']) && isset($_REQUEST['period'])){
navigation_bar_calc('web.screens', $_REQUEST['elementid'],true);
}
}
if(str_in_array($_REQUEST['favobj'],array('screenid','slideshowid'))){
$result = false;
if('add' == $_REQUEST['action']){
$result = add2favorites('web.favorite.screenids',$_REQUEST['favid'],$_REQUEST['favobj']);
if($result){
print('$("addrm_fav").title = "'.S_REMOVE_FROM.' '.S_FAVOURITES.'";'."\n");
print('$("addrm_fav").onclick = function(){rm4favorites("'.$_REQUEST['favobj'].'","'.$_REQUEST['favid'].'",0);}'."\n");
}
}
else if('remove' == $_REQUEST['action']){
$result = rm4favorites('web.favorite.screenids',$_REQUEST['favid'],$_REQUEST['favobj']);
if($result){
print('$("addrm_fav").title = "'.S_ADD_TO.' '.S_FAVOURITES.'";'."\n");
print('$("addrm_fav").onclick = function(){ add2favorites("'.$_REQUEST['favobj'].'","'.$_REQUEST['favid'].'");}'."\n");
}
}
if((PAGE_TYPE_JS == $page['type']) && $result){
print('switchElementsClass("addrm_fav","iconminus","iconplus");');
}
}
// saving fixed/dynamic setting to profile
if('timelinefixedperiod' == $_REQUEST['favobj']){
if(isset($_REQUEST['favid'])){
CProfile::update('web.screens.timelinefixed', $_REQUEST['favid'], PROFILE_TYPE_INT);
}
}
}
if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){
include_once('include/page_footer.php');
exit();
}
?>
<?php
//whether we should use screen name to fetch a screen (if this is false, elementid is used)
$use_screen_name = isset($_REQUEST['screenname']);
//getiing element id from GET paramters
$elementid = get_request('elementid', false);
//if none is provided
if($elementid === false && !$use_screen_name){
//get element id saved in profile from the last visit
$elementid = CProfile::get('web.screens.elementid', null);
//this flag will be used in case this element does not exist
$id_has_been_fetched_from_profile = true;
}
else{
$id_has_been_fetched_from_profile = false;
}
$screens_wdgt = new CWidget();
$scroll_div = new CDiv();
$scroll_div->setAttribute('id', 'scrollbar_cntr');
$screens_wdgt->addFlicker($scroll_div, CProfile::get('web.screens.filter.state',1));
$formHeader = new CForm();
$cmbConfig = new CComboBox('config', 'screens.php', 'javascript: redirect(this.options[this.selectedIndex].value);');
$cmbConfig->addItem('screens.php', S_SCREENS);
$cmbConfig->addItem('slides.php', S_SLIDESHOWS);
$formHeader->addItem($cmbConfig);
$screens = CScreen::get(array(
'nodeids' => get_current_nodeid(),
'output' => API_OUTPUT_EXTEND
));
//if screen name is provided it takes priority over elementid
if ($use_screen_name) {
$screens = zbx_toHash($screens, 'name');
$elementIdentifier = $_REQUEST['screenname'];
}
else {
$screens = zbx_toHash($screens, 'screenid');
$elementIdentifier = $elementid;
}
order_result($screens, 'name');
//no screens defined at all
if(empty($screens)){
$screens_wdgt->addPageHeader(S_SCREENS_BIG, $formHeader);
$screens_wdgt->addItem(BR());
$screens_wdgt->addItem(new CTableInfo(S_NO_SCREENS_DEFINED));
$screens_wdgt->show();
}
//if screen we are searching for does not exist and was not fetched from profile
elseif(!isset($screens[$elementIdentifier]) && !$id_has_been_fetched_from_profile){
$error_msg = $use_screen_name
? sprintf(S_ERROR_SCREEN_WITH_NAME_DOES_NOT_EXIST, $elementIdentifier)
: sprintf(S_ERROR_SCREEN_WITH_ID_DOES_NOT_EXIST, $elementIdentifier);
show_error_message($error_msg);
}
else{
if(!isset($screens[$elementIdentifier])){
//this means id was fetched from profile and this screen does not exist
//in this case we need to show the first one
$screen = reset($screens);
}
else{
$screen = $screens[$elementIdentifier];
}
//if elementid is used to fetch an element, saving it in profile
if(2 != $_REQUEST['fullscreen'] && !$use_screen_name){
CProfile::update('web.screens.elementid', $screen['screenid'], PROFILE_TYPE_ID);
}
$effectiveperiod = navigation_bar_calc('web.screens', $screen['screenid'], true);
$element_name = $screen['name'];
// PAGE HEADER {{{
$icon = get_icon('favourite', array(
'fav' => 'web.favorite.screenids',
'elname' => 'screenid',
'elid' => $screen['screenid'],
));
$fs_icon = get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']));
$screens_wdgt->addPageHeader(S_SCREENS_BIG, array($formHeader, SPACE, $icon, $fs_icon));
$screens_wdgt->addItem(BR());
// }}} PAGE HEADER
// HEADER {{{
$form = new CForm(null, 'get');
$form->addVar('fullscreen', $_REQUEST['fullscreen']);
$cmbElements = new CComboBox('elementid', $screen['screenid'], 'submit()');
foreach($screens as $snum => $scr){
/**
* Adding htmlspecialchars function to output of the screen name, so
* that it would be available to use symbols like ">" in screen names
* @see ZBX-2844
* @author Konstantin Buravcov
*/
$displayed_screen_name = htmlspecialchars(get_node_name_by_elid($scr['screenid'], null, ': ').$scr['name']);
$cmbElements->addItem($scr['screenid'], $displayed_screen_name);
}
$form->addItem(array(S_SCREENS.SPACE, $cmbElements));
$screens_wdgt->addHeader($element_name, $form);
// }}} HEADER
if((2 != $_REQUEST['fullscreen']) && check_dynamic_items($screen['screenid'], 0)){
if(!isset($_REQUEST['hostid'])){
$_REQUEST['groupid'] = $_REQUEST['hostid'] = 0;
}
$options = array('allow_all_hosts', 'monitored_hosts', 'with_items');
if(!$ZBX_WITH_ALL_NODES) array_push($options, 'only_current_node');
$params = array();
foreach($options as $option) $params[$option] = 1;
$PAGE_GROUPS = get_viewed_groups(PERM_READ_ONLY, $params);
$PAGE_HOSTS = get_viewed_hosts(PERM_READ_ONLY, $PAGE_GROUPS['selected'], $params);
//SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']);
validate_group_with_host($PAGE_GROUPS,$PAGE_HOSTS);
$cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
foreach($PAGE_GROUPS['groups'] as $groupid => $name){
$cmbGroups->addItem($groupid, get_node_name_by_elid($groupid, null, ': ').$name);
}
$form->addItem(array(SPACE.S_GROUP.SPACE, $cmbGroups));
$PAGE_HOSTS['hosts']['0'] = S_DEFAULT;
$cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
foreach($PAGE_HOSTS['hosts'] as $hostid => $name){
$cmbHosts->addItem($hostid, get_node_name_by_elid($hostid, null, ': ').$name);
}
$form->addItem(array(SPACE.S_HOST.SPACE, $cmbHosts));
}
$element = get_screen($screen['screenid'], 0, $effectiveperiod);
if(2 != $_REQUEST['fullscreen']){
$timeline = array(
'period' => $effectiveperiod,
'starttime' => date('YmdHis', time() - ZBX_MAX_PERIOD)
);
if(isset($_REQUEST['stime'])){
$timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
}
$dom_graph_id = 'screen_scroll';
$objData = array(
'id' => $screen['screenid'],
'domid' => $dom_graph_id,
'loadSBox' => 0,
'loadImage' => 0,
'loadScroll' => 1,
'scrollWidthByImage' => 0,
'dynamic' => 0,
'mainObject' => 1,
'periodFixed' => CProfile::get('web.screens.timelinefixed', 1)
);
zbx_add_post_js('timeControl.addObject("'.$dom_graph_id.'",'.zbx_jsvalue($timeline).','.zbx_jsvalue($objData).');');
zbx_add_post_js('timeControl.processObjects();');
}
$screens_wdgt->addItem($element);
$screens_wdgt->show();
echo SBR;
}
include_once('include/page_footer.php');
?>
|