protected function doAction() { $script = []; $this->getInputs($script, ['scriptid', 'name', 'type', 'execute_on', 'command', 'description', 'usrgrpid', 'groupid', 'host_access']); $script['confirmation'] = $this->getInput('confirmation', ''); if ($this->getInput('type', ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) == ZBX_SCRIPT_TYPE_IPMI && $this->hasInput('commandipmi')) { $script['command'] = $this->getInput('commandipmi'); } if ($this->getInput('hgstype', 1) == 0) { $script['groupid'] = 0; } DBstart(); $result = API::Script()->update($script); if ($result) { $scriptId = reset($result['scriptids']); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCRIPT, 'Name [' . $this->getInput('name', '') . '] id [' . $scriptId . ']'); } $result = DBend($result); if ($result) { $response = new CControllerResponseRedirect('zabbix.php?action=script.list&uncheck=1'); $response->setMessageOk(_('Script updated')); } else { $response = new CControllerResponseRedirect('zabbix.php?action=script.edit&scriptid=' . $this->getInput('scriptid')); $response->setFormData($this->getInputAll()); $response->setMessageError(_('Cannot update script')); } $this->setResponse($response); }
function add_audit_if($condition, $action, $resourcetype, $details) { if ($condition) { return add_audit($action, $resourcetype, $details); } return false; }
protected function doAction() { $proxy = []; $this->getInputs($proxy, ['host', 'status', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk']); if ($this->getInput('status', HOST_STATUS_PROXY_ACTIVE) == HOST_STATUS_PROXY_PASSIVE) { $proxy['interface'] = []; $this->getInputs($proxy['interface'], ['dns', 'ip', 'useip', 'port']); } DBstart(); if ($this->hasInput('proxy_hostids')) { // skip discovered hosts $proxy['hosts'] = API::Host()->get(['output' => ['hostid'], 'hostids' => $this->getInput('proxy_hostids'), 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]); } $result = API::Proxy()->create([$proxy]); if ($result) { add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_PROXY, '[' . $this->getInput('host', '') . '] [' . reset($result['proxyids']) . ']'); } $result = DBend($result); if ($result) { $response = new CControllerResponseRedirect('zabbix.php?action=proxy.list&uncheck=1'); $response->setMessageOk(_('Proxy added')); } else { $response = new CControllerResponseRedirect('zabbix.php?action=proxy.edit'); $response->setFormData($this->getInputAll()); $response->setMessageError(_('Cannot add proxy')); } $this->setResponse($response); }
protected function doAction() { $scriptids = $this->getInput('scriptids'); DBstart(); $result = API::Script()->delete($scriptids); if ($result) { foreach ($scriptids as $scriptid) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCRIPT, _('Script') . ' [' . $scriptid . ']'); } } $result = DBend($result); $deleted = count($scriptids); $response = new CControllerResponseRedirect('zabbix.php?action=script.list&uncheck=1'); if ($result) { $response->setMessageOk(_n('Script deleted', 'Scripts deleted', $deleted)); } else { $response->setMessageError(_n('Cannot delete script', 'Cannot delete scripts', $deleted)); } $this->setResponse($response); }
// get groups that use this authentication method $result = DBfetch(DBselect('SELECT COUNT(g.usrgrpid) AS cnt_usrgrp FROM usrgrp g WHERE g.gui_access=' . GROUP_GUI_ACCESS_INTERNAL)); if ($result['cnt_usrgrp'] > 0) { info(_n('There is "%1$d" group with Internal GUI access.', 'There are "%1$d" groups with Internal GUI access.', $result['cnt_usrgrp'])); } $messageSuccess = _('Authentication method changed to HTTP'); $messageFailed = _('Cannot change authentication method to HTTP'); DBstart(); $result = update_config($config); if ($result) { // reset all sessions if ($isAuthenticationTypeChanged) { $result &= DBexecute('UPDATE sessions SET status=' . ZBX_SESSION_PASSIVE . ' WHERE sessionid<>' . zbx_dbstr(CWebUser::$data['sessionid'])); } $isAuthenticationTypeChanged = false; add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, $messageSuccess); } $result = DBend($result); show_messages($result, $messageSuccess, $messageFailed); } } show_messages(); /* * Display */ $data = array('form_refresh' => getRequest('form_refresh'), 'config' => $config, 'is_authentication_type_changed' => $isAuthenticationTypeChanged, 'user' => getRequest('user', CWebUser::$data['alias']), 'user_password' => getRequest('user_password', ''), 'user_list' => null, 'change_bind_password' => getRequest('change_bind_password')); // get tab title $data['title'] = authentication2str($config['authentication_type']); // get user list if (getUserGuiAccess(CWebUser::$data['userid']) == GROUP_GUI_ACCESS_INTERNAL) { $data['user_list'] = DBfetchArray(DBselect('SELECT u.alias,u.userid FROM users u ORDER BY u.alias'));
/** * Delete proxy. * * @param string|array $proxyIds * * @return array */ public function delete($proxyIds) { $proxyIds = zbx_toArray($proxyIds); // deprecated input support if ($proxyIds && is_array($proxyIds[0])) { $this->deprecated('Passing objects is deprecated, use an array of IDs instead.'); foreach ($proxyIds as $proxyId) { if (!check_db_fields(array('proxyid' => null), $proxyId)) { self::exception(ZBX_API_ERROR_PARAMETERS, _('No proxy ID given.')); } } $proxyIds = zbx_objectValues($proxyIds, 'proxyid'); } $this->validateDelete($proxyIds); $dbProxies = DBselect('SELECT h.hostid,h.host' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.hostid', $proxyIds)); $dbProxies = DBfetchArrayAssoc($dbProxies, 'hostid'); $actionIds = array(); // get conditions $dbActions = DBselect('SELECT DISTINCT c.actionid' . ' FROM conditions c' . ' WHERE c.conditiontype=' . CONDITION_TYPE_PROXY . ' AND ' . dbConditionString('c.value', $proxyIds)); while ($dbAction = DBfetch($dbActions)) { $actionIds[$dbAction['actionid']] = $dbAction['actionid']; } if ($actionIds) { DB::update('actions', array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionIds))); } // delete action conditions DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_PROXY, 'value' => $proxyIds)); // delete interface DB::delete('interface', array('hostid' => $proxyIds)); // delete host DB::delete('hosts', array('hostid' => $proxyIds)); // TODO: remove info from API foreach ($dbProxies as $proxy) { info(_s('Deleted: Proxy "%1$s".', $proxy['host'])); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_PROXY, '[' . $proxy['host'] . '] [' . $proxy['hostid'] . ']'); } return array('proxyids' => $proxyIds); }
add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCENARIO, _('Scenario') . ' [' . $httptest_data['name'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . ']' . _('Scenario disabled')); } } show_messages($go_result, _('Scenario disabled'), null); } elseif ($_REQUEST['go'] == 'clean_history' && isset($_REQUEST['group_httptestid'])) { $go_result = false; $group_httptestid = $_REQUEST['group_httptestid']; foreach ($group_httptestid as $id) { if (!($httptest_data = get_httptest_by_httptestid($id))) { continue; } if (delete_history_by_httptestid($id)) { $go_result = true; DBexecute('UPDATE httptest SET nextcheck=0 WHERE httptestid=' . $id); $host = get_host_by_applicationid($httptest_data['applicationid']); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCENARIO, _('Scenario') . ' [' . $httptest_data['name'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . ']' . _('History cleared')); } } show_messages($go_result, _('History cleared'), null); } elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['group_httptestid'])) { $go_result = API::WebCheck()->delete($_REQUEST['group_httptestid']); show_messages($go_result, _('Scenario deleted'), null); } if ($_REQUEST['go'] != 'none' && isset($go_result) && $go_result) { $url = new CUrl(); $path = $url->getPath(); insert_js('cookie.eraseArray("' . $path . '")'); } show_messages(); /* * Display
/** * Delete web scenario. * * @param array $httpTestIds * @param bool $nopermissions * * @return array */ public function delete(array $httpTestIds, $nopermissions = false) { if (empty($httpTestIds)) { return true; } $delHttpTests = $this->get(array('httptestids' => $httpTestIds, 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true)); if (!$nopermissions) { foreach ($httpTestIds as $httpTestId) { if (!empty($delHttpTests[$httpTestId]['templateid'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot delete templated web scenario "%1$s".', $delHttpTests[$httpTestId]['name'])); } if (!isset($delHttpTests[$httpTestId])) { self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!')); } } } $parentHttpTestIds = $httpTestIds; $childHttpTestIds = array(); do { $dbTests = DBselect('SELECT ht.httptestid FROM httptest ht WHERE ' . dbConditionInt('ht.templateid', $parentHttpTestIds)); $parentHttpTestIds = array(); while ($dbTest = DBfetch($dbTests)) { $parentHttpTestIds[] = $dbTest['httptestid']; $childHttpTestIds[$dbTest['httptestid']] = $dbTest['httptestid']; } } while (!empty($parentHttpTestIds)); $options = array('httptestids' => $childHttpTestIds, 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true, 'preservekeys' => true, 'selectHosts' => API_OUTPUT_EXTEND); $delHttpTestChilds = $this->get($options); $delHttpTests = zbx_array_merge($delHttpTests, $delHttpTestChilds); $httpTestIds = array_merge($httpTestIds, $childHttpTestIds); $itemidsDel = array(); $dbTestItems = DBselect('SELECT hsi.itemid' . ' FROM httptestitem hsi' . ' WHERE ' . dbConditionInt('hsi.httptestid', $httpTestIds)); while ($testitem = DBfetch($dbTestItems)) { $itemidsDel[] = $testitem['itemid']; } $dbStepItems = DBselect('SELECT DISTINCT hsi.itemid' . ' FROM httpstepitem hsi,httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', $httpTestIds) . ' AND hs.httpstepid=hsi.httpstepid'); while ($stepitem = DBfetch($dbStepItems)) { $itemidsDel[] = $stepitem['itemid']; } if (!empty($itemidsDel)) { API::Item()->delete($itemidsDel, true); } DB::delete('httptest', array('httptestid' => $httpTestIds)); // TODO: REMOVE foreach ($delHttpTests as $httpTest) { $host = reset($httpTest['hosts']); info(_s('Deleted: Web scenario "%1$s" on "%2$s".', $httpTest['name'], $host['host'])); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCENARIO, 'Web scenario [' . $httpTest['name'] . '] [' . $httpTest['httptestid'] . '] Host [' . $host['name'] . ']'); } return array('httptestids' => $httpTestIds); }
$maintenanceids = get_request('maintenanceid', array()); if (isset($_REQUEST['maintenanceids'])) { $maintenanceids = $_REQUEST['maintenanceids']; } zbx_value2array($maintenanceids); $maintenances = array(); foreach ($maintenanceids as $id => $maintenanceid) { $maintenances[$maintenanceid] = get_maintenance_by_maintenanceid($maintenanceid); } DBstart(); $result = delete_maintenance($maintenanceids); $result = DBend($result); show_messages($result, S_MAINTENANCE_DELETED, S_CANNOT_DELETE_MAINTENANCE); if ($result) { foreach ($maintenances as $maintenanceid => $maintenance) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_MAINTENANCE, 'Id [' . $maintenanceid . '] ' . S_NAME . ' [' . $maintenance['name'] . ']'); } unset($_REQUEST['form']); unset($_REQUEST['maintenanceid']); } } else { if (inarr_isset(array('add_timeperiod', 'new_timeperiod'))) { $new_timeperiod = $_REQUEST['new_timeperiod']; // START TIME $new_timeperiod['start_time'] = $new_timeperiod['hour'] * 3600 + $new_timeperiod['minute'] * 60; //-- // PERIOD $new_timeperiod['period'] = $new_timeperiod['period_days'] * 86400 + $new_timeperiod['period_hours'] * 3600 + $new_timeperiod['period_minutes'] * 60; //-- // DAYSOFWEEK if (!isset($new_timeperiod['dayofweek'])) {
$page["title"] = "S_TRIGGER_COMMENTS"; $page["file"] = "tr_comments.php"; include_once "include/page_header.php"; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array("triggerid" => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), "comments" => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), "save" => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), "cancel" => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null)); check_fields($fields); $sql = 'SELECT * ' . ' FROM items i, functions f ' . ' WHERE i.itemid=f.itemid ' . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND ' . DBin_node('f.triggerid'); if (!($db_data = DBfetch(DBselect($sql)))) { fatal_error(S_NO_TRIGGER_DEFINED); } $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($db_data['hostid'])); if (!isset($available_triggers[$_REQUEST['triggerid']])) { access_deny(); } $trigger_hostid = $db_data['hostid']; if (isset($_REQUEST["save"])) { $result = update_trigger_comments($_REQUEST["triggerid"], $_REQUEST["comments"]); show_messages($result, S_COMMENT_UPDATED, S_CANNOT_UPDATE_COMMENT); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_TRIGGER . " [" . $_REQUEST["triggerid"] . "] [" . expand_trigger_description($_REQUEST["triggerid"]) . "] " . S_COMMENTS . " [" . $_REQUEST["comments"] . "]"); } } else { if (isset($_REQUEST["cancel"])) { redirect('tr_status.php?hostid=' . $trigger_hostid); exit; } } show_table_header(S_TRIGGER_COMMENTS_BIG); echo SBR; insert_trigger_comment_form($_REQUEST["triggerid"]); include_once "include/page_footer.php";
/** * Delete proxy. * * @param array $proxyIds * * @return array */ public function delete(array $proxyIds) { $this->validateDelete($proxyIds); $dbProxies = DBselect('SELECT h.hostid,h.host' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.hostid', $proxyIds)); $dbProxies = DBfetchArrayAssoc($dbProxies, 'hostid'); $actionIds = array(); // get conditions $dbActions = DBselect('SELECT DISTINCT c.actionid' . ' FROM conditions c' . ' WHERE c.conditiontype=' . CONDITION_TYPE_PROXY . ' AND ' . dbConditionString('c.value', $proxyIds)); while ($dbAction = DBfetch($dbActions)) { $actionIds[$dbAction['actionid']] = $dbAction['actionid']; } if ($actionIds) { DB::update('actions', array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionIds))); } // delete action conditions DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_PROXY, 'value' => $proxyIds)); // delete interface DB::delete('interface', array('hostid' => $proxyIds)); // delete host DB::delete('hosts', array('hostid' => $proxyIds)); // TODO: remove info from API foreach ($dbProxies as $proxy) { info(_s('Deleted: Proxy "%1$s".', $proxy['host'])); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_PROXY, '[' . $proxy['host'] . '] [' . $proxy['hostid'] . ']'); } return array('proxyids' => $proxyIds); }
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ define('ZBX_PAGE_NO_AUTHORIZATION', true); define('ZBX_NOT_ALLOW_ALL_NODES', true); define('ZBX_HIDE_NODE_SELECTION', true); define('ZBX_PAGE_NO_MENU', true); require_once dirname(__FILE__) . '/include/config.inc.php'; require_once dirname(__FILE__) . '/include/forms.inc.php'; $page['title'] = _('ZABBIX'); $page['file'] = 'index.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('name' => array(T_ZBX_STR, O_NO, null, NOT_EMPTY, 'isset({enter})', _('Username')), 'password' => array(T_ZBX_STR, O_OPT, null, null, 'isset({enter})'), 'sessionid' => array(T_ZBX_STR, O_OPT, null, null, null), 'reconnect' => array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0, 65535), null), 'enter' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'autologin' => array(T_ZBX_INT, O_OPT, null, null, null), 'request' => array(T_ZBX_STR, O_OPT, null, null, null)); check_fields($fields); // logout if (isset($_REQUEST['reconnect'])) { add_audit(AUDIT_ACTION_LOGOUT, AUDIT_RESOURCE_USER, _('Manual Logout')); CWebUser::logout(); } $config = select_config(); if ($config['authentication_type'] == ZBX_AUTH_HTTP) { if (!empty($_SERVER['PHP_AUTH_USER'])) { $_REQUEST['enter'] = _('Sign in'); $_REQUEST['name'] = $_SERVER['PHP_AUTH_USER']; } else { access_deny(); } } // login via form if (isset($_REQUEST['enter']) && $_REQUEST['enter'] == _('Sign in')) { // try to login if (CWebUser::login(get_request('name', ''), get_request('password', ''))) {
/** * Delete drules. * * @param array $dRuleIds * * @return array */ public function delete(array $dRuleIds) { $this->validateDelete($dRuleIds); $actionIds = array(); $conditionIds = array(); $dCheckIds = array(); $dbChecks = DBselect('SELECT dc.dcheckid FROM dchecks dc WHERE ' . dbConditionInt('dc.druleid', $dRuleIds)); while ($dbCheck = DBfetch($dbChecks)) { $dCheckIds[] = $dbCheck['dcheckid']; } $dbConditions = DBselect('SELECT c.conditionid,c.actionid' . ' FROM conditions c' . ' WHERE (c.conditiontype=' . CONDITION_TYPE_DRULE . ' AND ' . dbConditionString('c.value', $dRuleIds) . ')' . ' OR (c.conditiontype=' . CONDITION_TYPE_DCHECK . ' AND ' . dbConditionString('c.value', $dCheckIds) . ')'); while ($dbCondition = DBfetch($dbConditions)) { $conditionIds[] = $dbCondition['conditionid']; $actionIds[] = $dbCondition['actionid']; } if ($actionIds) { DB::update('actions', array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => array_unique($actionIds)))); } if ($conditionIds) { DB::delete('conditions', array('conditionid' => $conditionIds)); } $result = DB::delete('drules', array('druleid' => $dRuleIds)); if ($result) { foreach ($dRuleIds as $dRuleId) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_DISCOVERY_RULE, '[' . $dRuleId . ']'); } } return array('druleids' => $dRuleIds); }
if ($result) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCRIPT, S_SCRIPT . ' [' . $scriptid . ']'); } show_messages($result, S_SCRIPT_DELETED, S_CANNOT_DELETE_SCRIPT); if ($result) { unset($_REQUEST['form']); unset($_REQUEST['scriptid']); } } else { if ($_REQUEST['go'] == 'delete' && isset($_REQUEST['scripts'])) { $scripts = $_REQUEST['scripts']; $result = true; foreach ($scripts as $scriptid) { $result &= delete_script($scriptid); if ($result) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCRIPT, S_SCRIPT . ' [' . $scriptid . ']'); } } show_messages($result, S_SCRIPT_DELETED, S_CANNOT_DELETE_SCRIPT); if ($result) { unset($_REQUEST['form']); unset($_REQUEST['scriptid']); } } } } } $row_count = 0; if (isset($_REQUEST['form'])) { $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY); show_table_header(S_SCRIPTS);
$config['authentication_type'] = ZBX_AUTH_HTTP; foreach ($config as $id => $value) { if (isset($_REQUEST[$id])) { $config[$id] = $_REQUEST[$id]; } else { unset($config[$id]); } } // If we do save and auth_type changed or is set to LDAP, reset all sessions if ($cur_auth_type != $config['authentication_type']) { DBexecute('UPDATE sessions SET status=' . ZBX_SESSION_PASSIVE . ' WHERE sessionid<>' . zbx_dbstr($USER_DETAILS['sessionid'])); } $result = update_config($config); show_messages($result, S_HTTP_AUTH . SPACE . S_UPDATED, S_CANNOT_UPDATE . SPACE . S_HTTP_AUTH); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, S_HTTP_AUTH); } } } } } show_messages(); $config = select_config(); switch ($config['authentication_type']) { case ZBX_AUTH_INTERNAL: $auth = S_ZABBIX_INTERNAL_AUTH; break; case ZBX_AUTH_LDAP: $auth = S_LDAP_AUTH; break; case ZBX_AUTH_HTTP:
} } } elseif ($config['authentication_type'] == ZBX_AUTH_HTTP) { if (isset($_REQUEST['save'])) { // get groups wich use this authentication method $result = DBfetch(DBselect('SELECT COUNT(g.usrgrpid) AS cnt_usrgrp FROM usrgrp g WHERE g.gui_access=' . GROUP_GUI_ACCESS_INTERNAL)); if ($result['cnt_usrgrp'] > 0) { info(_n('There is "%1$d" group with Internal GUI access.', 'There are "%1$d" groups with Internal GUI access.', $result['cnt_usrgrp'])); } if (update_config($config)) { // reset all sessions if ($isAuthenticationTypeChanged) { DBexecute('UPDATE sessions SET status=' . ZBX_SESSION_PASSIVE . ' WHERE sessionid<>' . zbx_dbstr($USER_DETAILS['sessionid'])); } $isAuthenticationTypeChanged = false; add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, _('Authentication method changed to HTTP')); show_message(_('Authentication method changed to HTTP')); } else { show_error_message(_('Cannot change authentication method to HTTP')); } } } show_messages(); /* * Display */ $data = array('form_refresh' => get_request('form_refresh'), 'config' => $config, 'is_authentication_type_changed' => $isAuthenticationTypeChanged, 'user' => get_request('user', $USER_DETAILS['alias']), 'user_password' => get_request('user_password', ''), 'user_list' => null, 'change_bind_password' => get_request('change_bind_password')); // get tab title switch ($config['authentication_type']) { case ZBX_AUTH_INTERNAL: $data['title'] = _('Zabbix internal authentication');
DBstart(); $configs = array('hk_events_mode' => getRequest('hk_events_mode', 0), 'hk_events_trigger' => getRequest('hk_events_trigger'), 'hk_events_internal' => getRequest('hk_events_internal'), 'hk_events_discovery' => getRequest('hk_events_discovery'), 'hk_events_autoreg' => getRequest('hk_events_autoreg'), 'hk_services_mode' => getRequest('hk_services_mode', 0), 'hk_services' => getRequest('hk_services'), 'hk_audit_mode' => getRequest('hk_audit_mode', 0), 'hk_audit' => getRequest('hk_audit'), 'hk_sessions_mode' => getRequest('hk_sessions_mode', 0), 'hk_sessions' => getRequest('hk_sessions'), 'hk_history_mode' => getRequest('hk_history_mode', 0), 'hk_history_global' => getRequest('hk_history_global', 0), 'hk_history' => getRequest('hk_history'), 'hk_trends_mode' => getRequest('hk_trends_mode', 0), 'hk_trends_global' => getRequest('hk_trends_global', 0), 'hk_trends' => getRequest('hk_trends')); $result = update_config($configs); show_messages($result, _('Configuration updated'), _('Cannot update configuration')); if ($result) { $msg = array(); $msg[] = _s('Trigger event and alert data storage period (in days) "%1$s".', getRequest('hk_events_trigger')); $msg[] = _s('Internal event and alert data storage period (in days) "%1$s".', getRequest('hk_events_internal')); $msg[] = _s('Network discovery event and alert data storage period (in days) "%1$s".', getRequest('hk_events_discovery')); $msg[] = _s('Auto-registration event and alert data storage period (in days) "%1$s".', getRequest('hk_events_autoreg')); $msg[] = _s('IT service data storage period (in days) "%1$s".', getRequest('hk_services')); $msg[] = _s('Audit data storage period (in days) "%1$s".', getRequest('hk_audit')); $msg[] = _s('User session data storage period (in days) "%1$s".', getRequest('hk_sessions')); $msg[] = _s('History data storage period (in days) "%1$s".', getRequest('hk_history')); $msg[] = _s('Trend data storage period (in days) "%1$s".', getRequest('hk_trends')); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, implode('; ', $msg)); } DBend($result); } $form = new CForm(); $form->cleanItems(); $cmbConf = new CComboBox('configDropDown', 'adm.housekeeper.php', 'redirect(this.options[this.selectedIndex].value);'); $cmbConf->addItems(array('adm.gui.php' => _('GUI'), 'adm.housekeeper.php' => _('Housekeeping'), 'adm.images.php' => _('Images'), 'adm.iconmapping.php' => _('Icon mapping'), 'adm.regexps.php' => _('Regular expressions'), 'adm.macros.php' => _('Macros'), 'adm.valuemapping.php' => _('Value mapping'), 'adm.workingtime.php' => _('Working time'), 'adm.triggerseverities.php' => _('Trigger severities'), 'adm.triggerdisplayoptions.php' => _('Trigger displaying options'), 'adm.other.php' => _('Other'))); $form->addItem($cmbConf); $cnf_wdgt = new CWidget(null, 'hk'); $cnf_wdgt->addPageHeader(_('CONFIGURATION OF HOUSEKEEPING'), $form); $data['form_refresh'] = getRequest('form_refresh', 0); if ($data['form_refresh']) { $data['config']['hk_events_mode'] = getRequest('hk_events_mode'); $data['config']['hk_events_trigger'] = isset($_REQUEST['hk_events_trigger']) ? getRequest('hk_events_trigger') : $data['config']['hk_events_trigger']; $data['config']['hk_events_internal'] = isset($_REQUEST['hk_events_internal']) ? getRequest('hk_events_internal') : $data['config']['hk_events_internal'];
$page['title'] = _('Configuration of working time'); $page['file'] = 'adm.workingtime.php'; $page['hist_arg'] = array(); require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('work_period' => array(T_ZBX_STR, O_NO, null, null, 'isset({save})'), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null)); check_fields($fields); /* * Actions */ if (isset($_REQUEST['save'])) { DBstart(); $result = update_config(array('work_period' => get_request('work_period'))); show_messages($result, _('Configuration updated'), _('Cannot update configuration')); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, _s('Working time "%1$s".', get_request('work_period'))); } DBend($result); } /* * Display */ $form = new CForm(); $form->cleanItems(); $cmbConf = new CComboBox('configDropDown', 'adm.workingtime.php', 'redirect(this.options[this.selectedIndex].value);'); $cmbConf->addItems(array('adm.gui.php' => _('GUI'), 'adm.housekeeper.php' => _('Housekeeping'), 'adm.images.php' => _('Images'), 'adm.iconmapping.php' => _('Icon mapping'), 'adm.regexps.php' => _('Regular expressions'), 'adm.macros.php' => _('Macros'), 'adm.valuemapping.php' => _('Value mapping'), 'adm.workingtime.php' => _('Working time'), 'adm.triggerseverities.php' => _('Trigger severities'), 'adm.triggerdisplayoptions.php' => _('Trigger displaying options'), 'adm.other.php' => _('Other'))); $form->addItem($cmbConf); $cnf_wdgt = new CWidget(); $cnf_wdgt->addPageHeader(_('CONFIGURATION OF WORKING TIME'), $form); $data = array(); $data['form_refresh'] = get_request('form_refresh', 0);
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')); } /* * Display */ if (isset($_REQUEST['form'])) { $data = array('form' => getRequest('form', 1), 'form_refresh' => getRequest('form_refresh', 0), 'scriptid' => getRequest('scriptid')); if (!$data['scriptid'] || isset($_REQUEST['form_refresh'])) {
/** * Delete web scenario. * * @param $httpTestIds * * @return array|bool */ public function delete($httpTestIds) { if (empty($httpTestIds)) { return true; } $httpTestIds = zbx_toArray($httpTestIds); $delHttpTests = $this->get(array('httptestids' => $httpTestIds, 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true)); foreach ($httpTestIds as $httpTestId) { if (!isset($delHttpTests[$httpTestId])) { self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!')); } } $itemidsDel = array(); $dbTestItems = DBselect('SELECT hsi.itemid' . ' FROM httptestitem hsi' . ' WHERE ' . dbConditionInt('hsi.httptestid', $httpTestIds)); while ($testitem = DBfetch($dbTestItems)) { $itemidsDel[] = $testitem['itemid']; } $dbStepItems = DBselect('SELECT DISTINCT hsi.itemid' . ' FROM httpstepitem hsi,httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', $httpTestIds) . ' AND hs.httpstepid=hsi.httpstepid'); while ($stepitem = DBfetch($dbStepItems)) { $itemidsDel[] = $stepitem['itemid']; } if (!empty($itemidsDel)) { API::Item()->delete($itemidsDel, true); } DB::delete('httptest', array('httptestid' => $httpTestIds)); // TODO: REMOVE info foreach ($delHttpTests as $httpTest) { info(_s('Scenario "%s" deleted.', $httpTest['name'])); } // TODO: REMOVE audit foreach ($delHttpTests as $httpTest) { $host = reset($httpTest['hosts']); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCENARIO, _s('Scenario "%1$s" "%2$s" host "%3$s".', $httpTest['name'], $httpTest['httptestid'], $host['host'])); } return array('httptestids' => $httpTestIds); }
if ($result) { $audit_action = $_REQUEST['set_gui_access'] == GROUP_GUI_ACCESS_DISABLED ? AUDIT_ACTION_DISABLE : AUDIT_ACTION_UPDATE; add_audit($audit_action, AUDIT_RESOURCE_USER_GROUP, 'GUI access for group name [' . $group['name'] . ']'); unset($_REQUEST['usrgrpid']); } unset($_REQUEST['form']); } else { if (isset($_REQUEST['set_users_status']) && isset($_REQUEST['usrgrpid'])) { $group = get_group_by_usrgrpid($_REQUEST['usrgrpid']); $result = change_group_status($_REQUEST['usrgrpid'], $_REQUEST['set_users_status']); $status_msg1 = $_REQUEST['set_users_status'] == GROUP_STATUS_ENABLED ? S_ENABLED : S_DISABLED; $status_msg2 = $_REQUEST['set_users_status'] == GROUP_STATUS_ENABLED ? S_ENABLE : S_DISABLE; show_messages($result, S_GROUP . SPACE . '"' . $group['name'] . '"' . SPACE . $status_msg1, S_CANNOT . SPACE . $status_msg2 . SPACE . S_GROUP); if ($result) { $audit_action = $_REQUEST['set_users_status'] == GROUP_STATUS_ENABLED ? AUDIT_ACTION_ENABLE : AUDIT_ACTION_DISABLE; add_audit($audit_action, AUDIT_RESOURCE_USER_GROUP, 'Group name [' . $group['name'] . ']'); unset($_REQUEST['usrgrpid']); } unset($_REQUEST['form']); } } } } } } } } } } $_REQUEST['filter_usrgrpid'] = get_request('filter_usrgrpid', get_profile('web.users.filter.usrgrpid', 0)); update_profile('web.users.filter.usrgrpid', $_REQUEST['filter_usrgrpid'], PROFILE_TYPE_ID);
clearCookies($result); } } elseif (isset($_REQUEST['delete']) && isset($_REQUEST['druleid'])) { $result = API::DRule()->delete(array($_REQUEST['druleid'])); show_messages($result, _('Discovery rule deleted'), _('Cannot delete discovery rule')); if ($result) { unset($_REQUEST['form'], $_REQUEST['druleid']); clearCookies($result); } } elseif (str_in_array($_REQUEST['go'], array('activate', 'disable')) && isset($_REQUEST['g_druleid'])) { $status = $_REQUEST['go'] == 'activate' ? DRULE_STATUS_ACTIVE : DRULE_STATUS_DISABLED; $goResult = false; foreach ($_REQUEST['g_druleid'] as $drid) { if (DBexecute('UPDATE drules SET status=' . $status . ' WHERE druleid=' . zbx_dbstr($drid))) { $rule_data = get_discovery_rule_by_druleid($drid); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_DISCOVERY_RULE, '[' . $drid . '] ' . $rule_data['name']); $goResult = true; } } show_messages($goResult, _('Discovery rules updated')); clearCookies($goResult); } elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_druleid'])) { $result = API::DRule()->delete($_REQUEST['g_druleid']); show_messages($result, _('Discovery rules deleted'), _('Cannot delete discovery rules')); clearCookies($result); } /* * Display */ if (isset($_REQUEST['form'])) { $data = array('druleid' => get_request('druleid'), 'drule' => array(), 'form' => get_request('form'), 'form_refresh' => get_request('form_refresh', 0));
$nodeid = add_node(get_request('new_nodeid'), get_request('name'), get_request('ip'), get_request('port'), get_request('nodetype'), get_request('masterid')); $result = DBend($nodeid); show_messages($result, _('Node added'), _('Cannot add node')); $audit_action = AUDIT_ACTION_ADD; } if ($result) { add_audit($audit_action, AUDIT_RESOURCE_NODE, 'Node [' . $_REQUEST['name'] . '] id [' . $nodeid . ']'); unset($_REQUEST['form']); } } elseif (isset($_REQUEST['delete'])) { DBstart(); $result = delete_node($_REQUEST['nodeid']); $result = DBend($result); show_messages($result, _('Node deleted'), _('Cannot delete node')); if ($result) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_NODE, 'Node [' . $node['name'] . '] id [' . $node['nodeid'] . ']'); unset($_REQUEST['form'], $node); } } /* * Display */ if (isset($_REQUEST['form'])) { $data = array('nodeid' => get_request('nodeid'), 'masterNode' => DBfetch(DBselect('SELECT n.name FROM nodes n WHERE n.masterid IS NULL AND n.nodetype=' . ZBX_NODE_MASTER))); if (get_request('nodeid') && !isset($_REQUEST['form_refresh'])) { $data['new_nodeid'] = $node['nodeid']; $data['name'] = $node['name']; $data['ip'] = $node['ip']; $data['port'] = $node['port']; $data['masterid'] = $node['masterid']; $data['nodetype'] = $node['nodetype'];
continue; } $host = get_host_by_hostid($item['hostid']); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM, _('Item') . ' [' . $item['key_'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . '] ' . _('History cleared')); } $go_result = DBend($go_result); show_messages($go_result, _('History cleared'), $go_result); } elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['group_itemid'])) { DBstart(); $group_itemid = $_REQUEST['group_itemid']; $itemsToDelete = API::Item()->get(array('output' => array('key_', 'itemid'), 'selectHosts' => array('name'), 'itemids' => $group_itemid, 'preservekeys' => true)); $go_result = API::Item()->delete($group_itemid); if ($go_result) { foreach ($itemsToDelete as $item) { $host = reset($item['hosts']); add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ITEM, _('Item') . ' [' . $item['key_'] . '] [' . $item['itemid'] . '] ' . _('Host') . ' [' . $host['name'] . ']'); } } show_messages(DBend($go_result), _('Items deleted'), _('Cannot delete items')); } if ($_REQUEST['go'] != 'none' && !empty($go_result)) { $url = new CUrl(); $path = $url->getPath(); insert_js('cookie.eraseArray("' . $path . '")'); } /* * Display */ if (isset($_REQUEST['form']) && str_in_array($_REQUEST['form'], array(_('Create item'), 'update', 'clone'))) { $data = getItemFormData(); $data['page_header'] = _('CONFIGURATION OF ITEMS');
if (!isset($messages['triggers.severities'])) { $messages['triggers.severities'] = array(); } DBstart(); updateMessageSettings($messages); $result = API::User()->updateProfile($user); if ($result && CwebUser::$data['type'] > USER_TYPE_ZABBIX_USER) { $result = API::User()->updateMedia(array('users' => $user, 'medias' => $user['user_medias'])); } $result = DBend($result); if (!$result) { error(API::User()->resetErrors()); } if ($result) { DBstart(); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_USER, 'User alias [' . CWebUser::$data['alias'] . '] Name [' . CWebUser::$data['name'] . ']' . ' Surname [' . CWebUser::$data['surname'] . '] profile id [' . CWebUser::$data['userid'] . ']'); DBend(true); ob_end_clean(); redirect(CWebUser::$data['last_page']['url']); } else { show_messages($result, _('User updated'), _('Cannot update user')); } } } ob_end_flush(); /* * Display */ $data = getUserFormData(CWebUser::$data['userid'], true); $data['userid'] = CWebUser::$data['userid']; $data['form'] = getRequest('form');
add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_IMAGE, $audit_action); unset($_REQUEST['form']); } $result = DBend($result); show_messages($result, $msgOk, $msgFail); } catch (Exception $e) { DBend(false); error($e->getMessage()); show_error_message($msgFail); } } elseif (isset($_REQUEST['delete']) && isset($_REQUEST['imageid'])) { DBstart(); $image = get_image_by_imageid($_REQUEST['imageid']); $result = API::Image()->delete([getRequest('imageid')]); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_IMAGE, 'Image [' . $image['name'] . '] deleted'); unset($_REQUEST['form'], $image, $_REQUEST['imageid']); } $result = DBend($result); show_messages($result, _('Image deleted'), _('Cannot delete image')); } /* * Display */ $data = ['form' => getRequest('form')]; if (!empty($data['form'])) { if (isset($_REQUEST['imageid'])) { $data['imageid'] = $_REQUEST['imageid']; $data['imagename'] = $dbImage['name']; $data['imagetype'] = $dbImage['imagetype']; } else {
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']); } $result = DBend($result); if ($result) { uncheckTableRows(); } show_messages($result, _n('Regular expression deleted', 'Regular expressions deleted', $regExpCount), _n('Cannot delete regular expression', 'Cannot delete regular expressions', $regExpCount)); } /* * Display */ if (isset($_REQUEST['form'])) { $data = ['form_refresh' => getRequest('form_refresh'), 'regexpid' => getRequest('regexpid')]; if (isset($_REQUEST['regexpid']) && !isset($_REQUEST['form_refresh'])) {
show_messages($result, _('Application deleted'), _('Cannot delete application')); } } elseif (hasRequest('action') && getRequest('action') == 'application.massdelete' && hasRequest('applications')) { $result = true; $applications = getRequest('applications'); $deleted = 0; DBstart(); $dbApplications = DBselect('SELECT a.applicationid,a.name,a.hostid' . ' FROM applications a' . ' WHERE ' . dbConditionInt('a.applicationid', $applications)); while ($dbApplication = DBfetch($dbApplications)) { 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) {
* 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 */ $triggerEditable = API::Trigger()->get(['triggerids' => $_REQUEST['triggerid'], 'output' => ['triggerid'], 'editable' => true]); $data = ['triggerid' => getRequest('triggerid'), 'trigger' => $trigger, 'isTriggerEditable' => !empty($triggerEditable), 'isCommentExist' => !empty($trigger['comments'])]; // render view $triggerCommentView = new CView('monitoring.triggerComment', $data); $triggerCommentView->render();
$status = $enable ? ACTION_STATUS_ENABLED : ACTION_STATUS_DISABLED; $statusName = $enable ? 'enabled' : 'disabled'; $actionIds = array(); $updated = 0; DBstart(); $dbActions = DBselect('SELECT a.actionid' . ' FROM actions a' . ' WHERE ' . dbConditionInt('a.actionid', $_REQUEST['g_actionid'])); while ($row = DBfetch($dbActions)) { $result &= DBexecute('UPDATE actions' . ' SET status=' . zbx_dbstr($status) . ' WHERE actionid=' . zbx_dbstr($row['actionid'])); if ($result) { $actionIds[] = $row['actionid']; } $updated++; } $result = DBend($result); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ACTION, ' Actions [' . implode(',', $actionIds) . '] ' . $statusName); } $messageSuccess = $enable ? _n('Action enabled', 'Actions enabled', $updated) : _n('Action disabled', 'Actions disabled', $updated); $messageFailed = $enable ? _n('Cannot enable action', 'Cannot enable actions', $updated) : _n('Cannot disable action', 'Cannot disable actions', $updated); show_messages($result, $messageSuccess, $messageFailed); clearCookies($result); } elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_actionid'])) { $goResult = API::Action()->delete($_REQUEST['g_actionid']); show_messages($goResult, _('Selected actions deleted'), _('Cannot delete selected actions')); clearCookies($goResult); } /* * Display */ show_messages(); if (hasRequest('form')) {