} } elseif ($_REQUEST['favaction'] == 'remove') { $result = CFavorite::remove('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { add2favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } $result = DBend($result); if ($page['type'] == PAGE_TYPE_JS && $result) { echo 'switchElementClass("addrm_fav", "iconminus", "iconplus");'; } } } if (!empty($_REQUEST['period']) || !empty($_REQUEST['stime'])) { CScreenBase::calculateTime(array('profileIdx' => 'web.screens', 'profileIdx2' => $pageFilter->graphid, 'updateProfile' => true, 'period' => getRequest('period'), 'stime' => getRequest('stime'))); $curl = new CUrl(); $curl->removeArgument('period'); $curl->removeArgument('stime'); ob_end_clean(); DBstart(); CProfile::flush(); DBend(); redirect($curl->getUrl()); } ob_end_flush(); if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /*
$fields = array('itemid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'screenid' => array(T_ZBX_STR, O_OPT, null, null, null), 'period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'stime' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'profileIdx' => array(T_ZBX_STR, O_OPT, null, null, null), 'profileIdx2' => array(T_ZBX_STR, O_OPT, null, null, null), 'updateProfile' => array(T_ZBX_STR, O_OPT, null, null, null), 'from' => array(T_ZBX_INT, O_OPT, null, '{}>=0', null), 'width' => array(T_ZBX_INT, O_OPT, null, '{}>0', null), 'height' => array(T_ZBX_INT, O_OPT, null, '{}>0', null), 'border' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), null)); 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); }
/** * Init screen data. * * @param array $options * @param boolean $options['isFlickerfree'] * @param string $options['pageFile'] * @param int $options['mode'] * @param int $options['timestamp'] * @param int $options['hostid'] * @param int $options['period'] * @param int $options['stime'] * @param string $options['profileIdx'] * @param int $options['profileIdx2'] * @param boolean $options['updateProfile'] * @param array $options['screen'] */ public function __construct(array $options = array()) { $this->isFlickerfree = isset($options['isFlickerfree']) ? $options['isFlickerfree'] : true; $this->mode = isset($options['mode']) ? $options['mode'] : SCREEN_MODE_SLIDESHOW; $this->timestamp = !empty($options['timestamp']) ? $options['timestamp'] : time(); $this->hostid = !empty($options['hostid']) ? $options['hostid'] : null; // get page file if (!empty($options['pageFile'])) { $this->pageFile = $options['pageFile']; } else { global $page; $this->pageFile = $page['file']; } // get screen if (!empty($options['screen'])) { $this->screen = $options['screen']; } elseif (!empty($options['screenid'])) { $this->screen = API::Screen()->get(array('screenids' => $options['screenid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND, 'editable' => $this->mode == SCREEN_MODE_EDIT)); if (!empty($this->screen)) { $this->screen = reset($this->screen); } else { access_deny(); } } // calculate time $this->profileIdx = !empty($options['profileIdx']) ? $options['profileIdx'] : ''; $this->profileIdx2 = !empty($options['profileIdx2']) ? $options['profileIdx2'] : null; $this->updateProfile = isset($options['updateProfile']) ? $options['updateProfile'] : true; $this->timeline = CScreenBase::calculateTime(array('profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'period' => !empty($options['period']) ? $options['period'] : null, 'stime' => !empty($options['stime']) ? $options['stime'] : null)); }
foreach ($items as $item) { if (!isset($dbItems[$item['itemid']])) { access_deny(); } } $name = getRequest('name', ''); } else { show_error_message(_('No items defined.')); exit; } /* * Display */ $profileIdx = getRequest('profileIdx', 'web.httptest'); $profileIdx2 = getRequest('httptestid', getRequest('profileIdx2')); $timeline = CScreenBase::calculateTime(array('profileIdx' => $profileIdx, 'profileIdx2' => $profileIdx2, 'period' => getRequest('period'), 'stime' => getRequest('stime'))); CProfile::update($profileIdx . '.httptestid', $profileIdx2, PROFILE_TYPE_ID); $graph = new CLineGraphDraw(getRequest('graphtype', GRAPH_TYPE_NORMAL)); $graph->setHeader($name); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['stime']); $graph->setWidth(getRequest('width', 900)); $graph->setHeight(getRequest('height', 200)); $graph->showLegend(getRequest('legend', 1)); $graph->showWorkPeriod(getRequest('showworkperiod', 1)); $graph->showTriggers(getRequest('showtriggers', 1)); $graph->setYMinAxisType(getRequest('ymin_type', GRAPH_YAXIS_TYPE_CALCULATED)); $graph->setYMaxAxisType(getRequest('ymax_type', GRAPH_YAXIS_TYPE_CALCULATED)); $graph->setYAxisMin(getRequest('yaxismin', 0.0)); $graph->setYAxisMax(getRequest('yaxismax', 100.0)); $graph->setYMinItemId(getRequest('ymin_itemid', 0));
$graphTable->setAttribute('id', 'graph'); // dims $graphDims = getGraphDims(); $graphDims['shiftYtop'] += 1; $graphDims['width'] = -120; $graphDims['graphHeight'] = 150; /* * Graph in */ $graphInScreen = new CScreenBase(array('resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_in', 'profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $src = 'chart3.php?' . url_param('period') . url_param($db_httptest['name'], false, 'name') . url_param(150, false, 'height') . url_param(get_request('stime', 0), false, 'stime') . url_param(HTTPSTEP_ITEM_TYPE_IN, false, 'http_item_type') . url_param($db_httptest['httptestid'], false, 'httptestid') . url_param(GRAPH_TYPE_STACKED, false, 'graphtype'); $graphInContainer = new CDiv(new CLink(null, $src), 'flickerfreescreen', 'flickerfreescreen_graph_in'); $graphInContainer->setAttribute('style', 'position: relative'); $graphInContainer->setAttribute('data-timestamp', time()); $graphTable->addRow(array(bold(_('Speed')), $graphInContainer)); $timeline = $graphInScreen->calculateTime(array('profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $timeline['starttime'] = date('YmdHis', get_min_itemclock_by_itemid($itemIds)); $timeControlData = array('id' => 'graph_in', 'containerid' => 'flickerfreescreen_graph_in', 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("graph_in", ' . zbx_jsvalue($timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); $graphInScreen->insertFlickerfreeJs(); /* * Graph time */ $graphTimeScreen = new CScreenBase(array('resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_time', 'profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $src = 'chart3.php?' . url_param('period') . url_param('from') . url_param($db_httptest['name'], false, 'name') . url_param(150, false, 'height') . url_param(get_request('stime', 0), false, 'stime') . url_param(HTTPSTEP_ITEM_TYPE_TIME, false, 'http_item_type') . url_param($db_httptest['httptestid'], false, 'httptestid') . url_param(GRAPH_TYPE_STACKED, false, 'graphtype'); $graphTimeContainer = new CDiv(new CLink(null, $src), 'flickerfreescreen', 'flickerfreescreen_graph_time'); $graphTimeContainer->setAttribute('style', 'position: relative'); $graphTimeContainer->setAttribute('data-timestamp', time()); $graphTable->addRow(array(bold(_('Response time')), $graphTimeContainer)); $timeControlData = array('id' => 'graph_time', 'containerid' => 'flickerfreescreen_graph_time', 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("graph_time", ' . zbx_jsvalue($timeline) . ', ' . zbx_jsvalue($timeControlData) . ');');