foreach ($items as $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(); } } $effectiveperiod = navigation_bar_calc(); if (count($items) == 1) { $_REQUEST['period'] = get_request('period', get_profile('web.item.graph.period', ZBX_PERIOD_DEFAULT, null, $items['itemid'])); if ($_REQUEST['period'] >= ZBX_MIN_PERIOD) { update_profile('web.item.graph.period', $_REQUEST['period'], PROFILE_TYPE_INT, $items['itemid']); } } $graph = new CPie(get_request('graphtype', GRAPH_TYPE_NORMAL)); $graph->setHeader($host['host'] . ':' . get_request('name', '')); $graph3d = get_request('graph3d', 0); $legend = get_request('legend', 0); if ($graph3d == 1) { $graph->switchPie3D(); } $graph->switchLegend($legend); unset($host); if (isset($_REQUEST['period'])) { $graph->SetPeriod($_REQUEST['period']); } if (isset($_REQUEST['from'])) { $graph->SetFrom($_REQUEST['from']); } if (isset($_REQUEST['stime'])) {
$page['title'] = "S_CHART"; $page['type'] = PAGE_TYPE_IMAGE; include_once 'include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('graphid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), '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_STR, O_OPT, P_SYS, null, null), 'border' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'width' => array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null), 'height' => array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null), 'graph3d' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'legend' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null)); check_fields($fields); if (!DBfetch(DBselect('select graphid from graphs where graphid=' . $_REQUEST['graphid']))) { show_error_message(S_NO_GRAPH_DEFINED); } $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true)); if (!graph_accessible($_REQUEST['graphid'])) { access_deny(); } $sql = 'SELECT g.*,h.host,h.hostid ' . ' FROM graphs g ' . ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid ' . ' LEFT JOIN items i ON gi.itemid=i.itemid ' . ' LEFT JOIN hosts h ON i.hostid=h.hostid ' . ' WHERE g.graphid=' . $_REQUEST['graphid'] . ' AND ' . DBcondition('h.hostid', $available_hosts); $db_data = DBfetch(DBselect($sql)); $graph = new CPie($db_data['graphtype']); 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); if ($height <= 0) {
*/ if (!DBfetch(DBselect('SELECT g.graphid FROM graphs g WHERE g.graphid=' . $_REQUEST['graphid']))) { show_error_message(_('No graphs defined.')); } $db_data = API::Graph()->get(array('graphids' => $_REQUEST['graphid'], 'selectHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND)); if (empty($db_data)) { access_deny(); } else { $db_data = reset($db_data); } $host = reset($db_data['hosts']); /* * 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 CPie($db_data['graphtype']); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['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); if ($height <= 0) { $height = $db_data['height']; } $graph->setWidth($width); $graph->setHeight($height);
foreach ($items as $item) { if ($item['type'] == GRAPH_ITEM_SUM) { if (!in_array($item['type'], $types)) { array_push($types, $item['type']); } else { show_error_message(_('Warning. Cannot display more than one item with type "Graph sum".')); break; } } } /* * Display */ if ($isDataValid) { navigation_bar_calc(); $graph = new CPie(get_request('graphtype', GRAPH_TYPE_NORMAL)); $graph->setHeader(get_request('name', '')); if (!empty($_REQUEST['graph3d'])) { $graph->switchPie3D(); } $graph->showLegend(get_request('legend', 0)); 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']); }