$items = get_request('items', array()); asort_by_key($items, 'sortorder'); $dbItems = API::Item()->get(array('webitems' => true, 'itemids' => zbx_objectValues($items, 'itemid'), 'nodeids' => get_current_nodeid(true), 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => true, 'filter' => array('flags' => null))); $dbItems = zbx_toHash($dbItems, 'itemid'); foreach ($items as $item) { if (!isset($dbItems[$item['itemid']])) { access_deny(); } } $name = get_request('name', ''); } /* * Display */ if ($isDataValid) { $graph = new CChart(get_request('graphtype', GRAPH_TYPE_NORMAL)); $graph->setHeader($name); navigation_bar_calc(); $graph->setPeriod($_REQUEST['period']); $graph->setSTime($_REQUEST['stime']); $graph->setWidth(get_request('width', 900)); $graph->setHeight(get_request('height', 200)); $graph->showLegend(get_request('legend', 1)); $graph->showWorkPeriod(get_request('showworkperiod', 1)); $graph->showTriggers(get_request('showtriggers', 1)); $graph->setYMinAxisType(get_request('ymin_type', GRAPH_YAXIS_TYPE_CALCULATED)); $graph->setYMaxAxisType(get_request('ymax_type', GRAPH_YAXIS_TYPE_CALCULATED)); $graph->setYAxisMin(get_request('yaxismin', 0.0)); $graph->setYAxisMax(get_request('yaxismax', 100.0)); $graph->setYMinItemId(get_request('ymin_itemid', 0)); $graph->setYMaxItemId(get_request('ymax_itemid', 0));
include_once 'include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'from' => array(T_ZBX_INT, O_OPT, P_NZERO, null, null), 'stime' => array(T_ZBX_INT, O_OPT, P_NZERO, null, null), 'border' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'name' => array(T_ZBX_STR, O_OPT, NULL, null, null), 'width' => array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0, 65535), null), 'height' => array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0, 65535), null), 'ymin_type' => array(T_ZBX_INT, O_OPT, NULL, IN('0,1,2'), null), 'ymax_type' => array(T_ZBX_INT, O_OPT, NULL, IN('0,1,2'), null), 'ymin_itemid' => array(T_ZBX_INT, O_OPT, NULL, DB_ID, null), 'ymax_itemid' => array(T_ZBX_INT, O_OPT, NULL, DB_ID, null), 'graphtype' => array(T_ZBX_INT, O_OPT, NULL, IN('0,1'), null), 'yaxismin' => array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(-65535, 65535), null), 'yaxismax' => array(T_ZBX_DBL, O_OPT, NULL, null, null), 'percent_left' => array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(0, 100), null), 'percent_right' => array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(0, 100), null), 'items' => array(T_ZBX_STR, O_OPT, NULL, null, null)); check_fields($fields); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true)); $items = get_request('items', array()); asort_by_key($items, 'sortorder'); foreach ($items as $id => $gitem) { if (!($host = DBfetch(DBselect('select h.* from hosts h,items i where h.hostid=i.hostid and i.itemid=' . $gitem['itemid'])))) { fatal_error(S_NO_ITEM_DEFINED); } if (!isset($available_hosts[$host['hostid']])) { access_deny(); } } $graph = new CChart(get_request('graphtype', GRAPH_TYPE_NORMAL)); $chart_header = ''; if (id2nodeid($host['hostid']) != get_current_nodeid()) { $chart_header = get_node_name_by_elid($host['hostid'], true); } $chart_header .= $host['host'] . ':' . get_request('name', ''); $graph->setHeader($chart_header); unset($host); if (isset($_REQUEST['period'])) { $graph->setPeriod($_REQUEST['period']); } if (isset($_REQUEST['from'])) { $graph->setFrom($_REQUEST['from']); } if (isset($_REQUEST['stime'])) { $graph->setSTime($_REQUEST['stime']);
check_fields($fields); /* * Permissions */ if (!DBfetch(DBselect('SELECT i.itemid FROM items i WHERE i.itemid=' . $_REQUEST['itemid']))) { show_error_message(_('No items defined.')); } $dbItems = API::Item()->get(array('itemids' => $_REQUEST['itemid'], 'webitems' => true, 'nodeids' => get_current_nodeid(true), 'filter' => array('flags' => null))); if (empty($dbItems)) { access_deny(); } /* * Display */ $timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime'))); $graph = new CChart(); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['stime']); if (isset($_REQUEST['from'])) { $graph->setFrom($_REQUEST['from']); } if (isset($_REQUEST['width'])) { $graph->setWidth($_REQUEST['width']); } if (isset($_REQUEST['height'])) { $graph->setHeight($_REQUEST['height']); } if (isset($_REQUEST['border'])) { $graph->setBorder(0); } $graph->addItem($_REQUEST['itemid'], GRAPH_YAXIS_SIDE_DEFAULT, CALC_FNC_ALL);
if (empty($db_data)) { access_deny(); } else { $db_data = reset($db_data); } $options = array('nodeids' => get_current_nodeid(true), 'graphids' => $_REQUEST['graphid'], 'output' => API_OUTPUT_EXTEND); $host = CHost::get($options); $host = reset($host); $effectiveperiod = navigation_bar_calc(); CProfile::update('web.charts.graphid', $_REQUEST['graphid'], PROFILE_TYPE_ID); $chart_header = ''; if (id2nodeid($db_data['graphid']) != get_current_nodeid()) { $chart_header = get_node_name_by_elid($db_data['graphid'], true, ': '); } $chart_header .= $host['host'] . ': ' . $db_data['name']; $graph = new CChart($db_data['graphtype']); $graph->setHeader($chart_header); if (isset($_REQUEST['period'])) { $graph->setPeriod($_REQUEST['period']); } if (isset($_REQUEST['stime'])) { $graph->setSTime($_REQUEST['stime']); } if (isset($_REQUEST['border'])) { $graph->setBorder(0); } $width = get_request('width', 0); if ($width <= 0) { $width = $db_data['width']; } $height = get_request('height', 0);