DBstart(); $result = deleteHistoryByHttpTestIds($httpTestIds); $result = $result && DBexecute('UPDATE httptest SET nextcheck=0 WHERE ' . dbConditionInt('httptestid', $httpTestIds)); if ($result) { foreach ($httpTests as $httpTest) { $host = reset($httpTest['hosts']); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCENARIO, 'Scenario [' . $httpTest['name'] . '] [' . $httpTest['httptestid'] . '] ' . 'Host [' . $host['name'] . '] history cleared'); } } $result = DBend($result); if ($result) { uncheckTableRows(getRequest('hostid')); } } show_messages($result, _('History cleared'), _('Cannot clear history')); } elseif (hasRequest('action') && getRequest('action') === 'httptest.massdelete' && hasRequest('group_httptestid') && is_array(getRequest('group_httptestid'))) { $result = API::HttpTest()->delete(getRequest('group_httptestid')); if ($result) { uncheckTableRows(getRequest('hostid')); } show_messages($result, _('Web scenario deleted'), _('Cannot delete web scenario')); } show_messages(); /* * Display */ if (isset($_REQUEST['form'])) { $data = array('hostid' => getRequest('hostid', 0), 'httptestid' => getRequest('httptestid'), 'form' => getRequest('form'), 'form_refresh' => getRequest('form_refresh'), 'templates' => array()); $host = API::Host()->get(array('output' => array('status'), 'hostids' => $data['hostid'], 'templated_hosts' => true)); $data['host'] = reset($host); if (isset($data['httptestid'])) {
$page['file'] = 'screens.php'; $page['hist_arg'] = array('elementid'); $page['scripts'] = array('effects.js', 'dragdrop.js', 'class.calendar.js', 'gtlc.js', 'flickerfreescreen.js'); $page['type'] = detect_page_type(PAGE_TYPE_HTML); define('ZBX_PAGE_DO_JS_REFRESH', 1); require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 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), 'screenid' => array(T_ZBX_INT, O_OPT, P_SYS | P_NZERO, DB_ID, 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'), null), 'filterState' => array(T_ZBX_INT, O_OPT, P_ACT, null, null), 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, null, null), 'favid' => array(T_ZBX_INT, O_OPT, P_ACT, null, null), 'favaction' => array(T_ZBX_STR, O_OPT, P_ACT, IN('"add","remove"'), null)); check_fields($fields); /* * Ajax */ if (hasRequest('filterState')) { CProfile::update('web.hostscreen.filter.state', getRequest('filterState'), PROFILE_TYPE_INT); } if (getRequest('favobj') === 'timeline' && hasRequest('elementid') && hasRequest('period')) { navigation_bar_calc('web.hostscreen', getRequest('elementid'), true); } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Display */ $data = array('hostid' => getRequest('hostid', 0), 'fullscreen' => $_REQUEST['fullscreen'], 'screenid' => getRequest('screenid', CProfile::get('web.hostscreen.screenid', null)), 'period' => getRequest('period'), 'stime' => getRequest('stime')); CProfile::update('web.hostscreen.screenid', $data['screenid'], PROFILE_TYPE_ID); // get screen list $data['screens'] = API::TemplateScreen()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND)); $data['screens'] = zbx_toHash($data['screens'], 'screenid'); order_result($data['screens'], 'name');
CProfile::update('web.auditlogs.timelinefixed', $_REQUEST['favid'], PROFILE_TYPE_INT); } } } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Filter */ if (hasRequest('filter_set')) { CProfile::update('web.auditlogs.filter.alias', getRequest('alias', ''), PROFILE_TYPE_STR); CProfile::update('web.auditlogs.filter.action', getRequest('action', -1), PROFILE_TYPE_INT); CProfile::update('web.auditlogs.filter.resourcetype', getRequest('resourcetype', -1), PROFILE_TYPE_INT); } elseif (hasRequest('filter_rst')) { DBStart(); CProfile::delete('web.auditlogs.filter.alias'); CProfile::delete('web.auditlogs.filter.action'); CProfile::delete('web.auditlogs.filter.resourcetype'); DBend(); } /* * Display */ $effectivePeriod = navigation_bar_calc('web.auditlogs.timeline', 0, true); $data = ['stime' => getRequest('stime'), 'actions' => [], 'action' => CProfile::get('web.auditlogs.filter.action', -1), 'resourcetype' => CProfile::get('web.auditlogs.filter.resourcetype', -1), 'alias' => CProfile::get('web.auditlogs.filter.alias', '')]; $from = zbxDateToTime($data['stime']); $till = $from + $effectivePeriod; // get audit $config = select_config();
show_messages($result, $messageSuccess, $messageFailed); } elseif (hasRequest('action') && getRequest('action') == 'itemprototype.massdelete' && hasRequest('group_itemid')) { DBstart(); $result = API::Itemprototype()->delete(getRequest('group_itemid')); $result = DBend($result); if ($result) { uncheckTableRows(getRequest('parent_discoveryid')); } show_messages($result, _('Item prototypes deleted'), _('Cannot delete item prototypes')); } /* * Display */ if (isset($_REQUEST['form'])) { $itemPrototype = []; if (hasRequest('itemid')) { $itemPrototype = API::ItemPrototype()->get(['itemids' => getRequest('itemid'), 'output' => ['itemid', 'type', 'snmp_community', 'snmp_oid', 'hostid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'multiplier', 'delta', 'snmpv3_securityname', 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'formula', 'logtimefmt', 'templateid', 'valuemapid', 'delay_flex', 'params', 'ipmi_sensor', 'data_type', 'authtype', 'username', 'password', 'publickey', 'privatekey', 'interfaceid', 'port', 'description', 'snmpv3_authprotocol', 'snmpv3_privprotocol', 'snmpv3_contextname']]); $itemPrototype = reset($itemPrototype); } $data = getItemFormData($itemPrototype); $data['config'] = select_config(); // render view $itemView = new CView('configuration.item.prototype.edit', $data); $itemView->render(); $itemView->show(); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config();
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/include/config.inc.php'; $page['title'] = _('Configuration of trigger displaying options'); $page['file'] = 'adm.triggerdisplayoptions.php'; require_once dirname(__FILE__) . '/include/page_header.php'; $fields = ['problem_unack_color' => [T_ZBX_CLR, O_OPT, null, null, 'isset({update})', _('Unacknowledged PROBLEM events')], 'problem_ack_color' => [T_ZBX_CLR, O_OPT, null, null, 'isset({update})', _('Acknowledged PROBLEM events')], 'ok_unack_color' => [T_ZBX_CLR, O_OPT, null, null, 'isset({update})', _('Unacknowledged OK events')], 'ok_ack_color' => [T_ZBX_CLR, O_OPT, null, null, 'isset({update})', _('Acknowledged OK events')], 'problem_unack_style' => [T_ZBX_INT, O_OPT, null, IN('1'), null, _('Blinking')], 'problem_ack_style' => [T_ZBX_INT, O_OPT, null, IN('1'), null, _('Blinking')], 'ok_unack_style' => [T_ZBX_INT, O_OPT, null, IN('1'), null, _('Blinking')], 'ok_ack_style' => [T_ZBX_INT, O_OPT, null, IN('1'), null, _('Blinking')], 'ok_period' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, 999999), 'isset({update})', _('Display OK triggers for')], 'blink_period' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, 999999), 'isset({update})', _('On status change triggers blink for')], 'update' => [T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null], 'form_refresh' => [T_ZBX_INT, O_OPT, null, null, null]]; check_fields($fields); /* * Actions */ if (hasRequest('update')) { DBstart(); $result = update_config(['problem_unack_color' => getRequest('problem_unack_color'), 'problem_ack_color' => getRequest('problem_ack_color'), 'ok_unack_color' => getRequest('ok_unack_color'), 'ok_ack_color' => getRequest('ok_ack_color'), 'problem_unack_style' => getRequest('problem_unack_style', 0), 'problem_ack_style' => getRequest('problem_ack_style', 0), 'ok_unack_style' => getRequest('ok_unack_style', 0), 'ok_ack_style' => getRequest('ok_ack_style', 0), 'ok_period' => getRequest('ok_period'), 'blink_period' => getRequest('blink_period')]); $result = DBend($result); show_messages($result, _('Configuration updated'), _('Cannot update configuration')); } /* * Display */ $config = select_config(); // form has been submitted if (hasRequest('form_refresh')) { $data = ['problem_unack_color' => getRequest('problem_unack_color', $config['problem_unack_color']), 'problem_ack_color' => getRequest('problem_ack_color', $config['problem_ack_color']), 'ok_unack_color' => getRequest('ok_unack_color', $config['ok_unack_color']), 'ok_ack_color' => getRequest('ok_ack_color', $config['ok_ack_color']), 'problem_unack_style' => getRequest('problem_unack_style', 0), 'problem_ack_style' => getRequest('problem_ack_style', 0), 'ok_unack_style' => getRequest('ok_unack_style', 0), 'ok_ack_style' => getRequest('ok_ack_style', 0), 'ok_period' => getRequest('ok_period', $config['ok_period']), 'blink_period' => getRequest('blink_period', $config['blink_period'])]; } else { $data = ['problem_unack_color' => $config['problem_unack_color'], 'problem_ack_color' => $config['problem_ack_color'], 'ok_unack_color' => $config['ok_unack_color'], 'ok_ack_color' => $config['ok_ack_color'], 'problem_unack_style' => $config['problem_unack_style'], 'problem_ack_style' => $config['problem_ack_style'], 'ok_unack_style' => $config['ok_unack_style'], 'ok_ack_style' => $config['ok_ack_style'], 'ok_period' => $config['ok_period'], 'blink_period' => $config['blink_period']]; } $view = new CView('administration.general.trigger.options.edit', $data); $view->render(); $view->show(); require_once dirname(__FILE__) . '/include/page_footer.php';
** 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/triggers.inc.php'; $page['file'] = 'chart4.php'; $page['type'] = PAGE_TYPE_IMAGE; require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('triggerid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null)); check_fields($fields); /* * Permissions */ if (!hasRequest('triggerid')) { fatal_error(_('No triggers defined.')); } $dbTrigger = API::Trigger()->get(array('triggerids' => getRequest('triggerid'), 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true)); if (!$dbTrigger) { access_deny(); } else { $dbTrigger = reset($dbTrigger); } /* * Display */ $startTime = microtime(true); $sizeX = 900; $sizeY = 300; $shiftX = 12;
/** * Get data for item edit page. * * @param array $item item, item prototype or LLD rule to take the data from * @param bool $options['is_discovery_rule'] * * @return array */ function getItemFormData(array $item = array(), array $options = array()) { $data = array('form' => getRequest('form'), 'form_refresh' => getRequest('form_refresh'), 'is_discovery_rule' => !empty($options['is_discovery_rule']), 'parent_discoveryid' => getRequest('parent_discoveryid', !empty($options['is_discovery_rule']) ? getRequest('itemid') : null), 'itemid' => getRequest('itemid'), 'limited' => false, 'interfaceid' => getRequest('interfaceid', 0), 'name' => getRequest('name', ''), 'description' => getRequest('description', ''), 'key' => getRequest('key', ''), 'hostname' => getRequest('hostname'), 'delay' => getRequest('delay', ZBX_ITEM_DELAY_DEFAULT), 'history' => getRequest('history', 90), 'status' => getRequest('status', isset($_REQUEST['form_refresh']) ? 1 : 0), 'type' => getRequest('type', 0), 'snmp_community' => getRequest('snmp_community', 'public'), 'snmp_oid' => getRequest('snmp_oid', 'interfaces.ifTable.ifEntry.ifInOctets.1'), 'port' => getRequest('port', ''), 'value_type' => getRequest('value_type', ITEM_VALUE_TYPE_UINT64), 'data_type' => getRequest('data_type', ITEM_DATA_TYPE_DECIMAL), 'trapper_hosts' => getRequest('trapper_hosts', ''), 'units' => getRequest('units', ''), 'valuemapid' => getRequest('valuemapid', 0), 'params' => getRequest('params', ''), 'multiplier' => getRequest('multiplier', 0), 'delta' => getRequest('delta', 0), 'trends' => getRequest('trends', DAY_IN_YEAR), 'new_application' => getRequest('new_application', ''), 'applications' => getRequest('applications', array()), 'delay_flex' => getRequest('delay_flex', array()), 'new_delay_flex' => getRequest('new_delay_flex', array('delay' => 50, 'period' => ZBX_DEFAULT_INTERVAL)), 'snmpv3_contextname' => getRequest('snmpv3_contextname', ''), 'snmpv3_securityname' => getRequest('snmpv3_securityname', ''), 'snmpv3_securitylevel' => getRequest('snmpv3_securitylevel', 0), 'snmpv3_authprotocol' => getRequest('snmpv3_authprotocol', ITEM_AUTHPROTOCOL_MD5), 'snmpv3_authpassphrase' => getRequest('snmpv3_authpassphrase', ''), 'snmpv3_privprotocol' => getRequest('snmpv3_privprotocol', ITEM_PRIVPROTOCOL_DES), 'snmpv3_privpassphrase' => getRequest('snmpv3_privpassphrase', ''), 'ipmi_sensor' => getRequest('ipmi_sensor', ''), 'authtype' => getRequest('authtype', 0), 'username' => getRequest('username', ''), 'password' => getRequest('password', ''), 'publickey' => getRequest('publickey', ''), 'privatekey' => getRequest('privatekey', ''), 'formula' => getRequest('formula', 1), 'logtimefmt' => getRequest('logtimefmt', ''), 'add_groupid' => getRequest('add_groupid', getRequest('groupid', 0)), 'valuemaps' => null, 'possibleHostInventories' => null, 'alreadyPopulated' => null, 'initial_item_type' => null, 'templates' => array()); // hostid if (!empty($data['parent_discoveryid'])) { $discoveryRule = API::DiscoveryRule()->get(array('itemids' => $data['parent_discoveryid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true)); $discoveryRule = reset($discoveryRule); $data['hostid'] = $discoveryRule['hostid']; } else { $data['hostid'] = getRequest('hostid', 0); } // types, http items only for internal processes $data['types'] = item_type2str(); unset($data['types'][ITEM_TYPE_HTTPTEST]); if (!empty($options['is_discovery_rule'])) { unset($data['types'][ITEM_TYPE_AGGREGATE], $data['types'][ITEM_TYPE_CALCULATED], $data['types'][ITEM_TYPE_SNMPTRAP]); } // item if ($item) { $data['item'] = $item; $data['hostid'] = !empty($data['hostid']) ? $data['hostid'] : $data['item']['hostid']; $data['limited'] = $data['item']['templateid'] != 0; // get templates $itemid = $item['itemid']; do { $params = array('itemids' => $itemid, 'output' => array('itemid', 'templateid'), 'selectHosts' => array('name')); if ($data['is_discovery_rule']) { $item = API::DiscoveryRule()->get($params); } else { $params['selectDiscoveryRule'] = array('itemid'); $params['filter'] = array('flags' => null); $item = API::Item()->get($params); } $item = reset($item); if (!empty($item)) { $host = reset($item['hosts']); if (!empty($item['hosts'])) { $host['name'] = CHtml::encode($host['name']); if (bccomp($data['itemid'], $itemid) == 0) { } elseif ($data['is_discovery_rule']) { $data['templates'][] = new CLink($host['name'], 'host_discovery.php?form=update&itemid=' . $item['itemid'], 'highlight underline weight_normal'); $data['templates'][] = SPACE . '⇒' . SPACE; } elseif ($item['discoveryRule']) { $data['templates'][] = new CLink($host['name'], 'disc_prototypes.php?form=update&itemid=' . $item['itemid'] . '&parent_discoveryid=' . $item['discoveryRule']['itemid'], 'highlight underline weight_normal'); $data['templates'][] = SPACE . '⇒' . SPACE; } else { $data['templates'][] = new CLink($host['name'], 'items.php?form=update&itemid=' . $item['itemid'], 'highlight underline weight_normal'); $data['templates'][] = SPACE . '⇒' . SPACE; } } $itemid = $item['templateid']; } else { break; } } while ($itemid != 0); $data['templates'] = array_reverse($data['templates']); array_shift($data['templates']); } // caption if (!empty($data['is_discovery_rule'])) { $data['caption'] = _('Discovery rule'); } else { $data['caption'] = !empty($data['parent_discoveryid']) ? _('Item prototype') : _('Item'); } // hostname if (empty($data['is_discovery_rule']) && empty($data['hostname'])) { if (!empty($data['hostid'])) { $hostInfo = API::Host()->get(array('hostids' => $data['hostid'], 'output' => array('name'), 'templated_hosts' => true)); $hostInfo = reset($hostInfo); $data['hostname'] = $hostInfo['name']; } else { $data['hostname'] = _('not selected'); } } // fill data from item if (!hasRequest('form_refresh') && ($item || $data['limited'])) { $data['name'] = $data['item']['name']; $data['description'] = $data['item']['description']; $data['key'] = $data['item']['key_']; $data['interfaceid'] = $data['item']['interfaceid']; $data['type'] = $data['item']['type']; $data['snmp_community'] = $data['item']['snmp_community']; $data['snmp_oid'] = $data['item']['snmp_oid']; $data['port'] = $data['item']['port']; $data['value_type'] = $data['item']['value_type']; $data['data_type'] = $data['item']['data_type']; $data['trapper_hosts'] = $data['item']['trapper_hosts']; $data['units'] = $data['item']['units']; $data['valuemapid'] = $data['item']['valuemapid']; $data['multiplier'] = $data['item']['multiplier']; $data['hostid'] = $data['item']['hostid']; $data['params'] = $data['item']['params']; $data['snmpv3_contextname'] = $data['item']['snmpv3_contextname']; $data['snmpv3_securityname'] = $data['item']['snmpv3_securityname']; $data['snmpv3_securitylevel'] = $data['item']['snmpv3_securitylevel']; $data['snmpv3_authprotocol'] = $data['item']['snmpv3_authprotocol']; $data['snmpv3_authpassphrase'] = $data['item']['snmpv3_authpassphrase']; $data['snmpv3_privprotocol'] = $data['item']['snmpv3_privprotocol']; $data['snmpv3_privpassphrase'] = $data['item']['snmpv3_privpassphrase']; $data['ipmi_sensor'] = $data['item']['ipmi_sensor']; $data['authtype'] = $data['item']['authtype']; $data['username'] = $data['item']['username']; $data['password'] = $data['item']['password']; $data['publickey'] = $data['item']['publickey']; $data['privatekey'] = $data['item']['privatekey']; $data['logtimefmt'] = $data['item']['logtimefmt']; $data['new_application'] = getRequest('new_application', ''); if (!$data['is_discovery_rule']) { $data['formula'] = $data['item']['formula']; } if (!$data['limited'] || !isset($_REQUEST['form_refresh'])) { $data['delay'] = $data['item']['delay']; if (($data['type'] == ITEM_TYPE_TRAPPER || $data['type'] == ITEM_TYPE_SNMPTRAP) && $data['delay'] == 0) { $data['delay'] = ZBX_ITEM_DELAY_DEFAULT; } $data['history'] = $data['item']['history']; $data['status'] = $data['item']['status']; $data['delta'] = $data['item']['delta']; $data['trends'] = $data['item']['trends']; $db_delay_flex = $data['item']['delay_flex']; if (isset($db_delay_flex)) { $arr_of_dellays = explode(';', $db_delay_flex); foreach ($arr_of_dellays as $one_db_delay) { $arr_of_delay = explode('/', $one_db_delay); if (!isset($arr_of_delay[0]) || !isset($arr_of_delay[1])) { continue; } array_push($data['delay_flex'], array('delay' => $arr_of_delay[0], 'period' => $arr_of_delay[1])); } } $data['applications'] = array_unique(zbx_array_merge($data['applications'], get_applications_by_itemid($data['itemid']))); } } // applications if (count($data['applications']) == 0) { array_push($data['applications'], 0); } $data['db_applications'] = DBfetchArray(DBselect('SELECT DISTINCT a.applicationid,a.name' . ' FROM applications a' . ' WHERE a.hostid=' . zbx_dbstr($data['hostid']))); order_result($data['db_applications'], 'name'); // interfaces $data['interfaces'] = API::HostInterface()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND)); // valuemapid if ($data['limited']) { if (!empty($data['valuemapid'])) { if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid=' . zbx_dbstr($data['valuemapid'])))) { $data['valuemaps'] = $map_data['name']; } } } else { $data['valuemaps'] = DBfetchArray(DBselect('SELECT v.* FROM valuemaps v')); order_result($data['valuemaps'], 'name'); } // possible host inventories if (empty($data['parent_discoveryid'])) { $data['possibleHostInventories'] = getHostInventories(); // get already populated fields by other items $data['alreadyPopulated'] = API::item()->get(array('output' => array('inventory_link'), 'filter' => array('hostid' => $data['hostid']), 'nopermissions' => true)); $data['alreadyPopulated'] = zbx_toHash($data['alreadyPopulated'], 'inventory_link'); } // template $data['is_template'] = isTemplate($data['hostid']); // unset snmpv3 fields if ($data['type'] != ITEM_TYPE_SNMPV3) { $data['snmpv3_contextname'] = ''; $data['snmpv3_securityname'] = ''; $data['snmpv3_securitylevel'] = ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV; $data['snmpv3_authprotocol'] = ITEM_AUTHPROTOCOL_MD5; $data['snmpv3_authpassphrase'] = ''; $data['snmpv3_privprotocol'] = ITEM_PRIVPROTOCOL_DES; $data['snmpv3_privpassphrase'] = ''; } // unset ssh auth fields if ($data['type'] != ITEM_TYPE_SSH) { $data['authtype'] = ITEM_AUTHTYPE_PASSWORD; $data['publickey'] = ''; $data['privatekey'] = ''; } return $data; }
} $updated = count($update); $messageSuccess = $enable ? _n('Trigger prototype enabled', 'Trigger prototypes enabled', $updated) : _n('Trigger prototype disabled', 'Trigger prototypes disabled', $updated); $messageFailed = $enable ? _n('Cannot enable trigger prototype', 'Cannot enable trigger prototypes', $updated) : _n('Cannot disable trigger prototype', 'Cannot disable trigger prototypes', $updated); show_messages($result, $messageSuccess, $messageFailed); } elseif (hasRequest('action') && getRequest('action') == 'triggerprototype.massdelete' && hasRequest('g_triggerid')) { $result = API::TriggerPrototype()->delete(getRequest('g_triggerid')); if ($result) { uncheckTableRows(getRequest('parent_discoveryid')); } show_messages($result, _('Trigger prototypes deleted'), _('Cannot delete trigger prototypes')); } /* * Display */ if (hasRequest('action') && getRequest('action') == 'triggerprototype.massupdateform' && hasRequest('g_triggerid')) { $data = getTriggerMassupdateFormData(); $data['action'] = 'triggerprototype.massupdate'; $triggersView = new CView('configuration.triggers.massupdate', $data); $triggersView->render(); $triggersView->show(); } elseif (isset($_REQUEST['form'])) { $triggersView = new CView('configuration.triggers.edit', getTriggerFormData($exprAction)); $triggersView->render(); $triggersView->show(); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'description')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $data = array('parent_discoveryid' => getRequest('parent_discoveryid'), 'showInfoColumn' => false, 'discovery_rule' => $discovery_rule, 'hostid' => getRequest('hostid'), 'showdisabled' => getRequest('showdisabled', 1), 'triggers' => array(), 'sort' => $sortField, 'sortorder' => $sortOrder);
$result = update_config($configs); show_messages($result, _('Configuration updated'), _('Cannot update configuration')); if ($result) { $audit = array(_s('Refresh unsupported items (in sec) "%1$s".', get_request('refresh_unsupported'))); if (hasRequest('discovery_groupid')) { $hostGroup = API::HostGroup()->get(array('groupids' => get_request('discovery_groupid'), 'editable' => true, 'output' => array('groupid', 'name'))); if ($hostGroup) { $hostGroup = reset($hostGroup); $audit[] = _s('Group for discovered hosts "%1$s".', $hostGroup['name']); if (bccomp($hostGroup['groupid'], $orig_config['discovery_groupid']) != 0) { setHostGroupInternal($orig_config['discovery_groupid'], ZBX_NOT_INTERNAL_GROUP); setHostGroupInternal($hostGroup['groupid'], ZBX_INTERNAL_GROUP); } } } if (hasRequest('alert_usrgrpid')) { $userGroupId = get_request('alert_usrgrpid'); if ($userGroupId) { $userGroupName = DBfetch(DBselect('SELECT u.name FROM usrgrp u WHERE u.usrgrpid=' . zbx_dbstr($userGroupId))); $userGroupName = reset($userGroupName); } else { $userGroupName = _('None'); } $audit[] = _s('User group for database down message "%1$s".', $userGroupName); } add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, implode('; ', $audit)); } DBend($result); } /* * Display
if (isset($_REQUEST['delete']) && isset($_REQUEST['serviceid'])) { DBstart(); $result = API::Service()->delete(array($service['serviceid'])); if ($result) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_IT_SERVICE, 'Name [' . $service['name'] . '] id [' . $service['serviceid'] . ']'); unset($_REQUEST['form']); } unset($service); $result = DBend($result); show_messages($result, _('Service deleted'), _('Cannot delete service')); } if (isset($_REQUEST['form'])) { $_REQUEST['showsla'] = getRequest('showsla', 0); $result = false; // save if (hasRequest('add') || hasRequest('update')) { DBstart(); $children = getRequest('children', array()); $dependencies = array(); foreach ($children as $child) { $dependencies[] = array('dependsOnServiceid' => $child['serviceid'], 'soft' => isset($child['soft']) ? $child['soft'] : 0); } $serviceRequest = array('name' => getRequest('name'), 'triggerid' => getRequest('triggerid'), 'algorithm' => getRequest('algorithm'), 'showsla' => getRequest('showsla', 0), 'goodsla' => getRequest('goodsla'), 'sortorder' => getRequest('sortorder'), 'times' => getRequest('times', array()), 'parentid' => getRequest('parentid'), 'dependencies' => $dependencies); if (isset($service['serviceid'])) { $serviceRequest['serviceid'] = $service['serviceid']; $result = API::Service()->update($serviceRequest); $messageSuccess = _('Service updated'); $messageFailed = _('Cannot update service'); $auditAction = AUDIT_ACTION_UPDATE; } else { $result = API::Service()->create($serviceRequest);
$newgroup = get_request('newgroup', ''); $templateIds = get_request('templates', array()); $clear_templates = get_request('clear_templates', array()); $macros = get_request('macros', array()); $frm_title = _('Template'); if ($templateid > 0) { $frm_title .= SPACE . ' [' . $this->data['dbTemplate']['name'] . ']'; } $frmHost = new CForm(); $frmHost->setName('tpl_for'); $frmHost->addVar('form', get_request('form', 1)); $frmHost->addVar('groupid', $_REQUEST['groupid']); if ($templateid) { $frmHost->addVar('templateid', $templateid); } if ($templateid > 0 && !hasRequest('form_refresh')) { $host = $this->data['dbTemplate']['host']; $visiblename = $this->data['dbTemplate']['name']; // display empty visible name if equal to host name if ($visiblename === $host) { $visiblename = ''; } // get template groups from db $groups = $this->data['dbTemplate']['groups']; $groups = zbx_objectValues($groups, 'groupid'); $macros = order_macros($this->data['dbTemplate']['macros'], 'macro'); // get template hosts from db $hosts_linked_to = API::Host()->get(array('output' => array('hostid'), 'templateids' => $templateid, 'templated_hosts' => true)); $hosts_linked_to = zbx_objectValues($hosts_linked_to, 'hostid'); $hosts_linked_to = zbx_toHash($hosts_linked_to, 'hostid'); $templateIds = $this->data['original_templates'];
$groupUserId = getRequest('group_userid'); DBstart(); $result = unblock_user_login($groupUserId); if ($result) { $users = API::User()->get(array('userids' => $groupUserId, 'output' => API_OUTPUT_EXTEND)); foreach ($users as $user) { info('User ' . $user['alias'] . ' unblocked'); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_USER, 'Unblocked user alias [' . $user['alias'] . '] name [' . $user['name'] . '] surname [' . $user['surname'] . ']'); } } $result = DBend($result); if ($result) { uncheckTableRows(); } show_messages($result, _('Users unblocked'), _('Cannot unblock users')); } elseif (hasRequest('action') && getRequest('action') == 'user.massdelete' && hasRequest('group_userid')) { $result = false; $groupUserId = getRequest('group_userid'); $dbUsers = API::User()->get(array('userids' => $groupUserId, 'output' => API_OUTPUT_EXTEND)); $dbUsers = zbx_toHash($dbUsers, 'userid'); DBstart(); foreach ($groupUserId as $userId) { if (!isset($dbUsers[$userId])) { continue; } $result |= (bool) API::User()->delete(array($userId)); if ($result) { $userData = $dbUsers[$userId]; add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_USER, 'User alias [' . $userData['alias'] . '] name [' . $userData['name'] . '] surname [' . $userData['surname'] . ']'); } }
$templateWidget->addItem(get_header_host_table('', $templateId)); } $data = array(); if ($templateId) { $dbTemplates = API::Template()->get(array('templateids' => $templateId, 'selectGroups' => API_OUTPUT_EXTEND, 'selectParentTemplates' => array('templateid', 'name'), 'selectMacros' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND)); $data['dbTemplate'] = reset($dbTemplates); $data['original_templates'] = array(); foreach ($data['dbTemplate']['parentTemplates'] as $parentTemplate) { $data['original_templates'][$parentTemplate['templateid']] = $parentTemplate['templateid']; } } else { $data['original_templates'] = array(); } // description $data['description'] = $templateId && !hasRequest('form_refresh') ? $data['dbTemplate']['description'] : getRequest('description'); $templateIds = getRequest('templates', hasRequest('form_refresh') ? array() : $data['original_templates']); // linked templates $data['linkedTemplates'] = API::Template()->get(array('templateids' => $templateIds, 'output' => array('templateid', 'name'))); CArrayHelper::sort($data['linkedTemplates'], array('name')); $templateForm = new CView('configuration.template.edit', $data); $templateWidget->addItem($templateForm->render()); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $frmForm = new CForm(); $frmForm->cleanItems(); $frmForm->addItem(new CDiv(array(new CSubmit('form', _('Create template')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=template")')))); $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id')); $templateWidget->addPageHeader(_('CONFIGURATION OF TEMPLATES'), $frmForm);
$mediaTypeIds = getRequest('mediatypeids'); $enable = getRequest('action') == 'mediatype.massenable'; $status = $enable ? MEDIA_TYPE_STATUS_ACTIVE : MEDIA_TYPE_STATUS_DISABLED; $update = array(); foreach ($mediaTypeIds as $mediaTypeId) { $update[] = array('mediatypeid' => $mediaTypeId, 'status' => $status); } $result = API::Mediatype()->update($update); if ($result) { uncheckTableRows(); } $updated = count($update); $messageSuccess = $enable ? _n('Media type enabled', 'Media types enabled', $updated) : _n('Media type disabled', 'Media types disabled', $updated); $messageFailed = $enable ? _n('Cannot enable media type', 'Cannot enable media types', $updated) : _n('Cannot disable media type', 'Cannot disable media types', $updated); show_messages($result, $messageSuccess, $messageFailed); } elseif (hasRequest('action') && getRequest('action') == 'mediatype.massdelete' && hasRequest('mediatypeids')) { $result = API::Mediatype()->delete(getRequest('mediatypeids')); if ($result) { uncheckTableRows(); } show_messages($result, _('Media type deleted'), _('Cannot delete media type')); } /* * Display */ if (!empty($_REQUEST['form'])) { $data = array('form' => getRequest('form'), 'form_refresh' => getRequest('form_refresh', 0), 'mediatypeid' => $mediaTypeId); if (isset($data['mediatypeid']) && empty($_REQUEST['form_refresh'])) { $mediaType = reset($mediaTypes); $data['type'] = $mediaType['type']; $data['description'] = $mediaType['description'];
/** * Check request, if exist request - return request value, else return default value. * * @param string $name * @param mixed $def * * @return mixed */ function getRequest($name, $def = null) { return hasRequest($name) ? $_REQUEST[$name] : $def; }
$data['action']['def_shortdata'] = getRequest('def_shortdata', ACTION_DEFAULT_SUBJ_AUTOREG); $data['action']['def_longdata'] = getRequest('def_longdata', ACTION_DEFAULT_MSG_AUTOREG); } else { $data['action']['def_shortdata'] = getRequest('def_shortdata'); $data['action']['def_longdata'] = getRequest('def_longdata'); $data['action']['r_shortdata'] = getRequest('r_shortdata'); $data['action']['r_longdata'] = getRequest('r_longdata'); } } } if (!$data['actionid'] && !hasRequest('form_refresh') && $data['eventsource'] == EVENT_SOURCE_TRIGGERS) { $data['action']['filter']['conditions'] = array(array('formulaid' => 'A', 'conditiontype' => CONDITION_TYPE_MAINTENANCE, 'operator' => CONDITION_OPERATOR_NOT_IN, 'value' => ''), array('formulaid' => 'B', 'conditiontype' => CONDITION_TYPE_TRIGGER_VALUE, 'operator' => CONDITION_OPERATOR_EQUAL, 'value' => TRIGGER_VALUE_TRUE)); } $data['allowedConditions'] = get_conditions_by_eventsource($data['eventsource']); $data['allowedOperations'] = get_operations_by_eventsource($data['eventsource']); if (!hasRequest('add_condition')) { $data['action']['filter']['conditions'] = CConditionHelper::sortConditionsByFormulaId($data['action']['filter']['conditions']); } // new condition $data['new_condition'] = array('conditiontype' => isset($data['new_condition']['conditiontype']) ? $data['new_condition']['conditiontype'] : CONDITION_TYPE_TRIGGER_NAME, 'operator' => isset($data['new_condition']['operator']) ? $data['new_condition']['operator'] : CONDITION_OPERATOR_LIKE, 'value' => isset($data['new_condition']['value']) ? $data['new_condition']['value'] : ''); if (!str_in_array($data['new_condition']['conditiontype'], $data['allowedConditions'])) { $data['new_condition']['conditiontype'] = $data['allowedConditions'][0]; } // new operation if (!empty($data['new_operation'])) { if (!is_array($data['new_operation'])) { $data['new_operation'] = array('operationtype' => 0, 'esc_period' => 0, 'esc_step_from' => 1, 'esc_step_to' => 1, 'evaltype' => 0); } } // render view $actionView = new CView('configuration.action.edit', $data);
* Display */ if (isset($_REQUEST['form'])) { $formItem = hasRequest('itemid') && !hasRequest('clone') ? $item : []; $data = getItemFormData($formItem, ['is_discovery_rule' => true]); $data['lifetime'] = getRequest('lifetime', 30); $data['evaltype'] = getRequest('evaltype'); $data['formula'] = getRequest('formula'); $data['conditions'] = getRequest('conditions', []); // update form if (hasRequest('itemid') && !getRequest('form_refresh')) { $data['lifetime'] = $item['lifetime']; $data['evaltype'] = $item['filter']['evaltype']; $data['formula'] = $item['filter']['formula']; $data['conditions'] = $item['filter']['conditions']; } elseif (hasRequest('clone')) { unset($data['itemid']); $data['form'] = 'clone'; } // render view $itemView = new CView('configuration.host.discovery.edit', $data); $itemView->render(); $itemView->show(); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config(); $data = ['hostid' => getRequest('hostid', 0), 'host' => $host, 'showInfoColumn' => $host['status'] != HOST_STATUS_TEMPLATE, 'sort' => $sortField, 'sortorder' => $sortOrder]; // discoveries
break; case 'map': $data['rules']['maps'] = ['updateExisting' => true, 'createMissing' => true]; $data['backurl'] = 'sysmaps.php'; break; case 'screen': $data['rules']['screens'] = ['updateExisting' => true, 'createMissing' => true]; $data['backurl'] = 'screenconf.php'; break; case 'valuemap': $data['rules']['valueMaps'] = ['updateExisting' => false, 'createMissing' => true]; $data['backurl'] = 'adm.valuemapping.php'; break; } } if (hasRequest('rules')) { $requestRules = getRequest('rules', []); // if form was submitted with some checkboxes unchecked, those values are not submitted // so that we set missing values to false foreach ($data['rules'] as $ruleName => $rule) { if (!array_key_exists($ruleName, $requestRules)) { if (array_key_exists('updateExisting', $rule)) { $requestRules[$ruleName]['updateExisting'] = false; } if (array_key_exists('createMissing', $rule)) { $requestRules[$ruleName]['createMissing'] = false; } if (array_key_exists('deleteMissing', $rule)) { $requestRules[$ruleName]['deleteMissing'] = false; } }
show_messages($result, $messageSuccess, $messageFailed); } } elseif (hasRequest('delete') && hasRequest('scriptid')) { $scriptId = getRequest('scriptid'); DBstart(); $result = API::Script()->delete(array($scriptId)); if ($result) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCRIPT, _('Script') . ' [' . $scriptId . ']'); unset($_REQUEST['form'], $_REQUEST['scriptid']); } $result = DBend($result); if ($result) { uncheckTableRows(); } show_messages($result, _('Script deleted'), _('Cannot delete script')); } elseif (hasRequest('action') && getRequest('action') == 'script.massdelete' && hasRequest('scripts')) { $scriptIds = getRequest('scripts'); DBstart(); $result = API::Script()->delete($scriptIds); if ($result) { foreach ($scriptIds as $scriptId) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCRIPT, _('Script') . ' [' . $scriptId . ']'); } unset($_REQUEST['form'], $_REQUEST['scriptid']); } $result = DBend($result); if ($result) { uncheckTableRows(); } show_messages($result, _('Script deleted'), _('Cannot delete script')); }
<?php $counter = null; if (hasRequest('conditions')) { $conditions = getRequest('conditions'); krsort($conditions); $counter = key($conditions) + 1; } include dirname(__FILE__) . '/common.item.edit.js.php'; ?> <script type="text/x-jquery-tmpl" id="condition-row"> <tr class="form_row"> <td> <span class="formulaid">#{formulaId}</span> <input type="hidden" name="conditions[#{rowNum}][formulaid]" value="#{formulaId}"> </td> <td> <input class="<?php echo ZBX_STYLE_UPPERCASE; ?> macro" type="text" id="conditions_#{rowNum}_macro" name="conditions[#{rowNum}][macro]" style="width: <?php echo ZBX_TEXTAREA_MACRO_WIDTH; ?> px" maxlength="64" placeholder="{#MACRO}" data-formulaid="#{formulaId}"> </td> <td> <span><?php echo _('matches'); ?> </span> </td>
} elseif (isset($_REQUEST['password1']) && CWebUser::$data['alias'] != ZBX_GUEST_USER && zbx_empty($_REQUEST['password1'])) { show_error_message(_('Password should not be empty')); } else { $user = array(); $user['userid'] = CWebUser::$data['userid']; $user['alias'] = CWebUser::$data['alias']; $user['passwd'] = getRequest('password1'); $user['url'] = getRequest('url'); $user['autologin'] = getRequest('autologin', 0); $user['autologout'] = hasRequest('autologout_visible') ? getRequest('autologout') : 0; $user['theme'] = getRequest('theme'); $user['refresh'] = getRequest('refresh'); $user['rows_per_page'] = getRequest('rows_per_page'); $user['user_groups'] = null; $user['user_medias'] = getRequest('user_medias', array()); if (hasRequest('lang')) { $user['lang'] = getRequest('lang'); } $messages = getRequest('messages', array()); if (!isset($messages['enabled'])) { $messages['enabled'] = 0; } if (!isset($messages['triggers.recovery'])) { $messages['triggers.recovery'] = 0; } if (!isset($messages['triggers.severities'])) { $messages['triggers.severities'] = array(); } DBstart(); updateMessageSettings($messages); $result = API::User()->updateProfile($user);
CScreenBuilder::insertScreenStandardJs(['timeline' => $screenBuilder->timeline, 'profileIdx' => $screenBuilder->profileIdx]); insertPagePostJs(); } // refresh rate if (hasRequest('widgetRefreshRate')) { $widgetRefreshRate = substr(getRequest('widgetRefreshRate'), 1); CProfile::update('web.slides.rf_rate.' . WIDGET_SLIDESHOW, $widgetRefreshRate, PROFILE_TYPE_STR, $elementId); } else { $widgetRefreshRate = CProfile::get('web.slides.rf_rate.' . WIDGET_SLIDESHOW, 1, getRequest('elementid', CProfile::get('web.slides.elementid'))); } $delay = $screen['delay'] > 0 ? $screen['delay'] : $data['screen']['delay']; insert_js('PMasters["slideshows"].dolls["' . WIDGET_SLIDESHOW . '"].frequency(' . CJs::encodeJson($delay * $widgetRefreshRate) . ');' . "\n" . 'PMasters["slideshows"].dolls["' . WIDGET_SLIDESHOW . '"].restartDoll();'); } } // filter state if (hasRequest('favobj') && hasRequest('favid')) { $favouriteObject = getRequest('favobj'); $favouriteId = getRequest('favid'); // saving fixed/dynamic setting to profile if ($favouriteObject === 'timelinefixedperiod') { CProfile::update('web.slides.timelinefixed', $favouriteId, PROFILE_TYPE_INT); } } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Display */ if ($data['screen']) {
$messageFailed = _('Cannot update regular expression'); } else { $result = addRegexp($regExp, $expressions); $messageSuccess = _('Regular expression added'); $messageFailed = _('Cannot add regular expression'); } if ($result) { add_audit(hasRequest('update') ? AUDIT_ACTION_UPDATE : AUDIT_ACTION_ADD, AUDIT_RESOURCE_REGEXP, _('Name') . NAME_DELIMITER . getRequest('name')); unset($_REQUEST['form']); } $result = DBend($result); if ($result) { uncheckTableRows(); } show_messages($result, $messageSuccess, $messageFailed); } elseif (hasRequest('action') && getRequest('action') == 'regexp.massdelete') { $regExpIds = getRequest('regexpids', getRequest('regexpid', [])); zbx_value2array($regExpIds); $regExps = []; foreach ($regExpIds as $regExpId) { $regExps[$regExpId] = getRegexp($regExpId); } DBstart(); $result = DBexecute('DELETE FROM regexps WHERE ' . dbConditionInt('regexpid', $regExpIds)); $regExpCount = count($regExpIds); if ($result) { foreach ($regExps as $regExpId => $regExp) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_REGEXP, 'Id [' . $regExpId . '] ' . _('Name') . ' [' . $regExp['name'] . ']'); } unset($_REQUEST['form'], $_REQUEST['regexpid']); }
if (!isset($applications[$dbApplication['applicationid']])) { continue; } $result &= (bool) API::Application()->delete(array($dbApplication['applicationid'])); if ($result) { $host = get_host_by_hostid($dbApplication['hostid']); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_APPLICATION, 'Application [' . $dbApplication['name'] . '] from host [' . $host['host'] . ']'); } $deleted++; } $result = DBend($result); if ($result) { uncheckTableRows($pageFilter->hostid); } show_messages($result, _n('Application deleted', 'Applications deleted', $deleted), _n('Cannot delete application', 'Cannot delete applications', $deleted)); } elseif (hasRequest('applications') && str_in_array(getRequest('action'), array('application.massenable', 'application.massdisable'))) { $enableApplicationItems = getRequest('action') === 'application.massenable'; $applications = API::Application()->get(array('output' => array(), 'applicationids' => getRequest('applications', array()), 'selectItems' => array('itemid'), 'hostids' => $pageFilter->hostid > 0 ? $pageFilter->hostid : null)); $actionSuccessful = true; $updatedItemCount = 0; DBstart(); foreach ($applications as $application) { foreach ($application['items'] as $item) { $actionSuccessful &= $enableApplicationItems ? activate_item($item['itemid']) : disable_item($item['itemid']); $updatedItemCount++; } } $actionSuccessful = DBend($actionSuccessful); if ($actionSuccessful) { uncheckTableRows($pageFilter->hostid); }
$item['snmpv3_privprotocol'] = ITEM_PRIVPROTOCOL_DES; } $item = CArrayHelper::unsetEqualValues($item, $dbItem); $item['itemid'] = $itemId; $result = API::DiscoveryRule()->update($item); $result = DBend($result); show_messages($result, _('Discovery rule updated'), _('Cannot update discovery rule')); } else { $result = API::DiscoveryRule()->create(array($item)); show_messages($result, _('Discovery rule created'), _('Cannot add discovery rule')); } if ($result) { unset($_REQUEST['itemid'], $_REQUEST['form']); clearCookies($result, $_REQUEST['hostid']); } } elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasRequest('g_hostdruleid')) { $groupHostDiscoveryRuleId = getRequest('g_hostdruleid'); $enable = getRequest('go') == 'activate'; DBstart(); $result = $enable ? activate_item($groupHostDiscoveryRuleId) : disable_item($groupHostDiscoveryRuleId); $result = DBend($result); $updated = count($groupHostDiscoveryRuleId); $messageSuccess = $enable ? _n('Discovery rule enabled', 'Discovery rules enabled', $updated) : _n('Discovery rule disabled', 'Discovery rules disabled', $updated); $messageFailed = $enable ? _n('Cannot enable discovery rules', 'Cannot enable discovery rules', $updated) : _n('Cannot disable discovery rules', 'Cannot disable discovery rules', $updated); show_messages($result, $messageSuccess, $messageFailed); clearCookies($result, getRequest('hostid')); } elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_hostdruleid'])) { $goResult = API::DiscoveryRule()->delete($_REQUEST['g_hostdruleid']); show_messages($goResult, _('Discovery rules deleted'), _('Cannot delete discovery rules')); clearCookies($goResult, $_REQUEST['hostid']); }
$data['action']['r_longdata'] = get_request('r_longdata', ACTION_DEFAULT_MSG_TRIGGER); } elseif ($data['eventsource'] == EVENT_SOURCE_DISCOVERY) { $data['action']['def_shortdata'] = get_request('def_shortdata', ACTION_DEFAULT_SUBJ_DISCOVERY); $data['action']['def_longdata'] = get_request('def_longdata', ACTION_DEFAULT_MSG_DISCOVERY); } elseif ($data['eventsource'] == EVENT_SOURCE_AUTO_REGISTRATION) { $data['action']['def_shortdata'] = get_request('def_shortdata', ACTION_DEFAULT_SUBJ_AUTOREG); $data['action']['def_longdata'] = get_request('def_longdata', ACTION_DEFAULT_MSG_AUTOREG); } else { $data['action']['def_shortdata'] = get_request('def_shortdata'); $data['action']['def_longdata'] = get_request('def_longdata'); $data['action']['r_shortdata'] = get_request('r_shortdata'); $data['action']['r_longdata'] = get_request('r_longdata'); } } } if (!$data['actionid'] && !hasRequest('form_refresh') && $data['eventsource'] == EVENT_SOURCE_TRIGGERS) { $data['action']['conditions'] = array(array('conditiontype' => CONDITION_TYPE_TRIGGER_VALUE, 'operator' => CONDITION_OPERATOR_EQUAL, 'value' => TRIGGER_VALUE_TRUE), array('conditiontype' => CONDITION_TYPE_MAINTENANCE, 'operator' => CONDITION_OPERATOR_NOT_IN, 'value' => '')); } $data['allowedConditions'] = get_conditions_by_eventsource($data['eventsource']); $data['allowedOperations'] = get_operations_by_eventsource($data['eventsource']); // sort conditions $sortFields = array(array('field' => 'conditiontype', 'order' => ZBX_SORT_DOWN), array('field' => 'operator', 'order' => ZBX_SORT_DOWN), array('field' => 'value', 'order' => ZBX_SORT_DOWN)); CArrayHelper::sort($data['action']['conditions'], $sortFields); // new condition $data['new_condition'] = array('conditiontype' => isset($data['new_condition']['conditiontype']) ? $data['new_condition']['conditiontype'] : CONDITION_TYPE_TRIGGER_NAME, 'operator' => isset($data['new_condition']['operator']) ? $data['new_condition']['operator'] : CONDITION_OPERATOR_LIKE, 'value' => isset($data['new_condition']['value']) ? $data['new_condition']['value'] : ''); if (!str_in_array($data['new_condition']['conditiontype'], $data['allowedConditions'])) { $data['new_condition']['conditiontype'] = $data['allowedConditions'][0]; } // new operation if (!empty($data['new_operation'])) { if (!is_array($data['new_operation'])) {
check_fields($fields); if (!isset($_REQUEST['triggerid'])) { fatal_error(_('No triggers defined.')); } /* * Permissions */ $trigger = API::Trigger()->get(['triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true]); if (!$trigger) { access_deny(); } $trigger = reset($trigger); /* * Actions */ if (hasRequest('update')) { DBstart(); $result = DBexecute('UPDATE triggers' . ' SET comments=' . zbx_dbstr(getRequest('comments')) . ' WHERE triggerid=' . zbx_dbstr(getRequest('triggerid'))); $trigger['comments'] = $_REQUEST['comments']; if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, _('Trigger') . ' [' . $_REQUEST['triggerid'] . '] [' . $trigger['description'] . '] ' . _('Comments') . ' [' . $_REQUEST['comments'] . ']'); } $result = DBend($result); show_messages($result, _('Description updated'), _('Cannot update description')); } elseif (isset($_REQUEST['cancel'])) { jsRedirect('tr_status.php'); exit; } /* * Display */
$ipmiAgentId = $_REQUEST['mainInterfaces'][INTERFACE_TYPE_JMX]; $interfaces[$ipmiAgentId]['main'] = '1'; } if (isset($_REQUEST['mainInterfaces'][INTERFACE_TYPE_IPMI])) { $jmxAgentId = $_REQUEST['mainInterfaces'][INTERFACE_TYPE_IPMI]; $interfaces[$jmxAgentId]['main'] = '1'; } // get items that populate host inventory fields $hostItemsToInventory = API::Item()->get(array('filter' => array('hostid' => $dbHost['hostid']), 'output' => array('inventory_link', 'name', 'key_'), 'preserveKeys' => true, 'nopermissions' => true)); $hostItemsToInventory = zbx_toHash($hostItemsToInventory, 'inventory_link'); } else { $original_templates = array(); } // load data from the DB when opening the full clone form for the first time $cloneFormOpened = in_array(getRequest('form'), array('clone', 'full_clone')) && getRequest('form_refresh') == 1; if (getRequest('hostid') && (!hasRequest('form_refresh') || $cloneFormOpened)) { $proxy_hostid = $dbHost['proxy_hostid']; $host = $dbHost['host']; $visiblename = $dbHost['name']; if ($visiblename == $host) { // display empty visible name if equal to host name $visiblename = ''; } $status = $dbHost['status']; $ipmi_authtype = $dbHost['ipmi_authtype']; $ipmi_privilege = $dbHost['ipmi_privilege']; $ipmi_username = $dbHost['ipmi_username']; $ipmi_password = $dbHost['ipmi_password']; $macros = order_macros($dbHost['macros'], 'macro'); $host_groups = zbx_objectValues($dbHost['groups'], 'groupid'); $host_inventory = $dbHost['inventory'];
} if (getRequest('graphid')) { $graphs = API::Graph()->get(array('graphids' => array($_REQUEST['graphid']), 'output' => array('graphid'))); if (!$graphs) { access_deny(); } } $pageFilter = new CPageFilter(array('groups' => array('real_hosts' => true, 'with_graphs' => true), 'hosts' => array('with_graphs' => true), 'groupid' => getRequest('groupid'), 'hostid' => getRequest('hostid'), 'graphs' => array('templated' => 0), 'graphid' => getRequest('graphid'))); /* * Ajax */ if (hasRequest('filterState')) { CProfile::update('web.charts.filter.state', getRequest('filterState'), PROFILE_TYPE_INT); } if (isset($_REQUEST['favobj'])) { if (getRequest('favobj') === 'timelinefixedperiod' && hasRequest('favid')) { CProfile::update('web.screens.timelinefixed', getRequest('favid'), PROFILE_TYPE_INT); } if (str_in_array($_REQUEST['favobj'], array('itemid', 'graphid'))) { $result = false; DBstart(); if ($_REQUEST['favaction'] == 'add') { $result = CFavorite::add('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Remove from favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { rm4favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } elseif ($_REQUEST['favaction'] == 'remove') { $result = CFavorite::remove('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n";
$page['title'] = _('Configuration of network maps'); $page['file'] = 'sysmap.php'; $page['hist_arg'] = array('sysmapid'); $page['scripts'] = array('class.cmap.js', 'class.cviewswitcher.js', 'multiselect.js'); $page['type'] = detect_page_type(); require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('sysmapid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'selementid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'sysmap' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({action})'), 'selements' => array(T_ZBX_STR, O_OPT, P_SYS, DB_ID, null), 'links' => array(T_ZBX_STR, O_OPT, P_SYS, DB_ID, null), 'action' => array(T_ZBX_STR, O_OPT, P_ACT, IN('"update"'), 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), 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, null, null), 'favid' => array(T_ZBX_STR, O_OPT, P_ACT, null, null)); check_fields($fields); /* * Ajax */ if (isset($_REQUEST['favobj'])) { $json = new CJson(); // if ($_REQUEST['favobj'] == 'sysmap' && getRequest('action') == 'update') { if (getRequest('favobj') == 'sysmap' && hasRequest('action') && getRequest('action') == 'update') { $sysmapid = getRequest('sysmapid', 0); @ob_start(); try { DBstart(); $sysmap = API::Map()->get(array('sysmapids' => $sysmapid, 'editable' => true, 'output' => array('sysmapid'))); $sysmap = reset($sysmap); if ($sysmap === false) { throw new Exception(_('Access denied!') . "\n\r"); } $sysmapUpdate = $json->decode($_REQUEST['sysmap'], true); $sysmapUpdate['sysmapid'] = $sysmapid; $result = API::Map()->update($sysmapUpdate); if ($result !== false) { echo 'if (confirm(' . CJs::encodeJson(_('Map is updated! Return?')) . ')) { location.href = "sysmaps.php"; }'; } else {