/usr/share/zabbix/screenedit.php is in zabbix-frontend-php 1:2.2.7+dfsg-2+deb8u3.
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 | <?php
/*
** Zabbix
** Copyright (C) 2001-2014 Zabbix SIA
**
** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/screens.inc.php';
require_once dirname(__FILE__).'/include/forms.inc.php';
require_once dirname(__FILE__).'/include/blocks.inc.php';
$page['title'] = _('Configuration of screens');
$page['file'] = 'screenedit.php';
$page['hist_arg'] = array('screenid');
$page['scripts'] = array('class.cscreen.js', 'class.calendar.js', 'gtlc.js', 'flickerfreescreen.js', 'multiselect.js');
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
require_once dirname(__FILE__).'/include/page_header.php';
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array(
'screenid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
'screenitemid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
'resourcetype' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 16), 'isset({save})'),
'caption' => array(T_ZBX_STR, O_OPT, null, null, null),
'resourceid' => array(T_ZBX_INT, O_OPT, null, DB_ID, 'isset({save})',
isset($_REQUEST['save']) ? getResourceNameByType($_REQUEST['resourcetype']) : null),
'templateid' => array(T_ZBX_INT, O_OPT, null, DB_ID, null),
'width' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Width')),
'height' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Height')),
'colspan' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null, _('Column span')),
'rowspan' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null, _('Row span')),
'elements' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 100), null, _('Show lines')),
'sort_triggers' => array(T_ZBX_INT, O_OPT, null, BETWEEN(SCREEN_SORT_TRIGGERS_DATE_DESC, SCREEN_SORT_TRIGGERS_RECIPIENT_DESC), null),
'valign' => array(T_ZBX_INT, O_OPT, null, BETWEEN(VALIGN_MIDDLE, VALIGN_BOTTOM), null),
'halign' => array(T_ZBX_INT, O_OPT, null, BETWEEN(HALIGN_CENTER, HALIGN_RIGHT), null),
'style' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 2), 'isset({save})'),
'url' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
'dynamic' => array(T_ZBX_INT, O_OPT, null, null, null),
'x' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 100), 'isset({save})&&(isset({form})&&({form}!="update"))'),
'y' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 100), 'isset({save})&&(isset({form})&&({form}!="update"))'),
'screen_type' => array(T_ZBX_INT, O_OPT, null, null, null),
'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),
'application' => array(T_ZBX_STR, O_OPT, null, null, null),
// actions
'save' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
'delete' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null),
'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null),
'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null),
'add_row' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null),
'add_col' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null),
'rmv_row' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null),
'rmv_col' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null),
'sw_pos' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 100), null),
'ajaxAction' => array(T_ZBX_STR, O_OPT, P_ACT, null, null)
);
check_fields($fields);
$_REQUEST['dynamic'] = get_request('dynamic', SCREEN_SIMPLE_ITEM);
/*
* Permissions
*/
$options = array(
'screenids' => $_REQUEST['screenid'],
'editable' => true,
'output' => API_OUTPUT_EXTEND,
'selectScreenItems' => API_OUTPUT_EXTEND
);
$screens = API::Screen()->get($options);
if (empty($screens)) {
$screens = API::TemplateScreen()->get($options);
if (empty($screens)) {
access_deny();
}
}
$screen = reset($screens);
/*
* Ajax
*/
if (!empty($_REQUEST['ajaxAction']) && $_REQUEST['ajaxAction'] == 'sw_pos') {
$sw_pos = get_request('sw_pos', array());
if (count($sw_pos) > 3) {
$fitem = DBfetch(DBselect(
'SELECT s.screenitemid,s.colspan,s.rowspan'.
' FROM screens_items s'.
' WHERE s.y='.zbx_dbstr($sw_pos[0]).
' AND s.x='.zbx_dbstr($sw_pos[1]).
' AND s.screenid='.zbx_dbstr($screen['screenid'])
));
$sitem = DBfetch(DBselect(
'SELECT s.screenitemid,s.colspan,s.rowspan'.
' FROM screens_items s'.
' WHERE s.y='.zbx_dbstr($sw_pos[2]).
' AND s.x='.zbx_dbstr($sw_pos[3]).
' AND s.screenid='.zbx_dbstr($screen['screenid'])
));
if ($fitem) {
DBexecute('UPDATE screens_items'.
' SET y='.zbx_dbstr($sw_pos[2]).',x='.zbx_dbstr($sw_pos[3]).
',colspan='.(isset($sitem['colspan']) ? zbx_dbstr($sitem['colspan']) : 1).
',rowspan='.(isset($sitem['rowspan']) ? zbx_dbstr($sitem['rowspan']) : 1).
' WHERE y='.zbx_dbstr($sw_pos[0]).
' AND x='.zbx_dbstr($sw_pos[1]).
' AND screenid='.zbx_dbstr($screen['screenid']).
' AND screenitemid='.zbx_dbstr($fitem['screenitemid'])
);
}
if ($sitem) {
DBexecute('UPDATE screens_items '.
' SET y='.zbx_dbstr($sw_pos[0]).',x='.zbx_dbstr($sw_pos[1]).
',colspan='.(isset($fitem['colspan']) ? zbx_dbstr($fitem['colspan']) : 1).
',rowspan='.(isset($fitem['rowspan']) ? zbx_dbstr($fitem['rowspan']) : 1).
' WHERE y='.zbx_dbstr($sw_pos[2]).
' AND x='.zbx_dbstr($sw_pos[3]).
' AND screenid='.zbx_dbstr($screen['screenid']).
' AND screenitemid='.zbx_dbstr($sitem['screenitemid'])
);
}
add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Screen items switched');
}
echo '{"result": true}';
}
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
require_once dirname(__FILE__).'/include/page_footer.php';
exit();
}
/*
* Actions
*/
if (isset($_REQUEST['save'])) {
$screenItem = array(
'screenid' => get_request('screenid'),
'resourceid' => get_request('resourceid'),
'resourcetype' => get_request('resourcetype'),
'caption' => get_request('caption'),
'style' => get_request('style'),
'url' => get_request('url'),
'width' => get_request('width'),
'height' => get_request('height'),
'halign' => get_request('halign'),
'valign' => get_request('valign'),
'colspan' => get_request('colspan'),
'rowspan' => get_request('rowspan'),
'dynamic' => get_request('dynamic'),
'elements' => get_request('elements', 0),
'sort_triggers' => get_request('sort_triggers', SCREEN_SORT_TRIGGERS_DATE_DESC),
'application' => get_request('application', '')
);
DBstart();
if (!empty($_REQUEST['screenitemid'])) {
$screenItem['screenitemid'] = $_REQUEST['screenitemid'];
$result = API::ScreenItem()->update($screenItem);
show_messages($result, _('Item updated'), _('Cannot update item'));
}
else {
$screenItem['x'] = get_request('x');
$screenItem['y'] = get_request('y');
$result = API::ScreenItem()->create($screenItem);
show_messages($result, _('Item added'), _('Cannot add item'));
}
DBend($result);
if ($result) {
add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Cell changed '.
(isset($_REQUEST['screenitemid']) ? 'screen itemid "'.$_REQUEST['screenitemid'].'"' : '').
(isset($_REQUEST['x']) && isset($_REQUEST['y']) ? ' coordinates "'.$_REQUEST['x'].','.$_REQUEST['y'].'"' : '').
(isset($_REQUEST['resourcetype']) ? ' resource type "'.$_REQUEST['resourcetype'].'"' : '')
);
unset($_REQUEST['form']);
}
}
elseif (isset($_REQUEST['delete'])) {
DBstart();
$screenitemid = API::ScreenItem()->delete($_REQUEST['screenitemid']);
$result = DBend($screenitemid);
show_messages($result, _('Item deleted'), _('Cannot delete item'));
if ($result && !empty($screenitemid)) {
$screenitemid = reset($screenitemid);
$screenitemid = reset($screenitemid);
add_audit_details(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Screen itemid "'.$screenitemid.'"');
}
unset($_REQUEST['x']);
}
elseif (isset($_REQUEST['add_row'])) {
DBexecute('UPDATE screens SET vsize=(vsize+1) WHERE screenid='.zbx_dbstr($screen['screenid']));
$add_row = get_request('add_row', 0);
if ($screen['vsize'] > $add_row) {
DBexecute('UPDATE screens_items SET y=(y+1) WHERE screenid='.zbx_dbstr($screen['screenid']).' AND y>='.zbx_dbstr($add_row));
}
add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Row added');
}
elseif (isset($_REQUEST['add_col'])) {
DBexecute('UPDATE screens SET hsize=(hsize+1) WHERE screenid='.zbx_dbstr($screen['screenid']));
$add_col = get_request('add_col', 0);
if ($screen['hsize'] > $add_col) {
DBexecute('UPDATE screens_items SET x=(x+1) WHERE screenid='.zbx_dbstr($screen['screenid']).' AND x>='.zbx_dbstr($add_col));
}
add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Column added');
}
elseif (isset($_REQUEST['rmv_row'])) {
if ($screen['vsize'] > 1) {
$rmv_row = get_request('rmv_row', 0);
DBexecute('UPDATE screens SET vsize=(vsize-1) WHERE screenid='.zbx_dbstr($screen['screenid']));
DBexecute('DELETE FROM screens_items WHERE screenid='.zbx_dbstr($screen['screenid']).' AND y='.zbx_dbstr($rmv_row));
DBexecute('UPDATE screens_items SET y=(y-1) WHERE screenid='.zbx_dbstr($screen['screenid']).' AND y>'.zbx_dbstr($rmv_row));
// reduce the rowspan of the items that are displayed in the removed row
DBexecute(
'UPDATE screens_items'.
' SET rowspan=(rowspan-1)'.
' WHERE screenid='.zbx_dbstr($screen['screenid']).
' AND y+rowspan>'.zbx_dbstr($rmv_row).
' AND y<'.zbx_dbstr($rmv_row)
);
add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Row deleted');
}
else {
error(_('Screen should contain at least one row and column.'));
show_error_message(_('Impossible to remove last row and column.'));
}
}
elseif (isset($_REQUEST['rmv_col'])) {
if ($screen['hsize'] > 1) {
$rmv_col = get_request('rmv_col', 0);
DBexecute('UPDATE screens SET hsize=(hsize-1) WHERE screenid='.zbx_dbstr($screen['screenid']));
DBexecute('DELETE FROM screens_items WHERE screenid='.zbx_dbstr($screen['screenid']).' AND x='.zbx_dbstr($rmv_col));
DBexecute('UPDATE screens_items SET x=(x-1) WHERE screenid='.zbx_dbstr($screen['screenid']).' AND x>'.zbx_dbstr($rmv_col));
// reduce the colspan of the items that are displayed in the removed column
DBexecute(
'UPDATE screens_items'.
' SET colspan=(colspan-1)'.
' WHERE screenid='.zbx_dbstr($screen['screenid']).
' AND x+colspan>'.zbx_dbstr($rmv_col).
' AND x<'.zbx_dbstr($rmv_col)
);
add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Column deleted');
}
else {
error(_('Screen should contain at least one row and column.'));
show_error_message(_('Impossible to remove last row and column.'));
}
}
/*
* Display
*/
$data = array(
'screenid' => get_request('screenid', 0)
);
// getting updated screen, so we wont have to refresh the page to see changes
$data['screen'] = API::Screen()->get($options);
if (empty($data['screen'])) {
$data['screen'] = API::TemplateScreen()->get($options);
if (empty($data['screen'])) {
access_deny();
}
}
$data['screen'] = reset($data['screen']);
// render view
$screenView = new CView('configuration.screen.constructor.list', $data);
$screenView->render();
$screenView->show();
require_once dirname(__FILE__).'/include/page_footer.php';
|