当前位置: 首页>>代码示例>>PHP>>正文


PHP add_audit_ext函数代码示例

本文整理汇总了PHP中add_audit_ext函数的典型用法代码示例。如果您正苦于以下问题:PHP add_audit_ext函数的具体用法?PHP add_audit_ext怎么用?PHP add_audit_ext使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add_audit_ext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Tries to login a user and populates self::$data on success.
  *
  * @param string $login			user login
  * @param string $password		user password
  *
  * @throws Exception if user cannot be logged in
  *
  * @return bool
  */
 public static function login($login, $password)
 {
     try {
         self::setDefault();
         self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
         if (!self::$data) {
             throw new Exception();
         }
         if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
             error(_('GUI access disabled.'));
             throw new Exception();
         }
         if (empty(self::$data['url'])) {
             self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
         }
         $result = (bool) self::$data;
         if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
             CProfile::init();
             CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
             CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
             CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
             $result &= CProfile::flush();
         }
         // remove guest session after successful login
         $result &= DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
         if ($result) {
             self::setSessionCookie(self::$data['sessionid']);
             add_audit_ext(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, self::$data['userid'], '', null, null, null);
         }
         return $result;
     } catch (Exception $e) {
         self::setDefault();
         return false;
     }
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:45,代码来源:CWebUser.php

示例2: add_mediatype

function add_mediatype($type, $description, $smtp_server, $smtp_helo, $smtp_email, $exec_path, $gsm_modem, $username, $password)
{
    $ret = 0;
    if ($description == "") {
        error(S_INCORRECT_DESCRIPTION);
        return 0;
    }
    $sql = "select * from media_type where description=" . zbx_dbstr($description);
    $result = DBexecute($sql);
    if (DBfetch($result)) {
        error("An action type with description '{$description}' already exists.");
    } else {
        $mediatypeid = get_dbid("media_type", "mediatypeid");
        $sql = "insert into media_type (mediatypeid,type,description,smtp_server,smtp_helo,smtp_email,exec_path,gsm_modem,username,passwd) values ({$mediatypeid},{$type}," . zbx_dbstr($description) . "," . zbx_dbstr($smtp_server) . "," . zbx_dbstr($smtp_helo) . "," . zbx_dbstr($smtp_email) . "," . zbx_dbstr($exec_path) . "," . zbx_dbstr($gsm_modem) . "," . zbx_dbstr($username) . "," . zbx_dbstr($password) . ")";
        $ret = DBexecute($sql);
        if ($ret) {
            $ret = $mediatypeid;
            add_audit_ext(AUDIT_ACTION_ADD, AUDIT_RESOURCE_MEDIA_TYPE, $mediatypeid, $description, NULL, NULL, NULL);
        }
    }
    return $ret;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:22,代码来源:media.inc.php

示例3: add_audit_ext

                add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_MACRO, $macro['globalmacroid'], $macro['macro'] . SPACE . RARR . SPACE . $macro['value'], null, null, null);
            }
        }
        // create
        if (!empty($newMacros)) {
            // mark marcos as new
            foreach ($newMacros as $number => $macro) {
                $_REQUEST['macros'][$number]['type'] = 'new';
            }
            $newMacrosIds = API::UserMacro()->createGlobal(array_values($newMacros));
            if (!$newMacrosIds) {
                throw new Exception(_('Cannot add macro.'));
            }
            $newMacrosCreated = API::UserMacro()->get(array('globalmacroids' => $newMacrosIds['globalmacroids'], 'globalmacro' => 1, 'output' => API_OUTPUT_EXTEND));
            foreach ($newMacrosCreated as $macro) {
                add_audit_ext(AUDIT_ACTION_ADD, AUDIT_RESOURCE_MACRO, $macro['globalmacroid'], $macro['macro'] . SPACE . RARR . SPACE . $macro['value'], null, null, null);
            }
        }
        // reload macros after updating to properly display them in the form
        $_REQUEST['macros'] = API::UserMacro()->get(array('globalmacro' => true, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
        $result = true;
        DBend(true);
        show_message(_('Macros updated'));
    } catch (Exception $e) {
        $result = false;
        DBend(false);
        error($e->getMessage());
        show_error_message(_('Cannot update macros'));
    }
}
/*
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:adm.macros.php

示例4: update


//.........这里部分代码省略.........
     }
     // check if maintenance already exists
     if ($maintenanceNamesChanged) {
         $dbMaintenances = $this->get(['output' => ['name'], 'filter' => ['name' => $maintenanceNamesChanged], 'nopermissions' => true, 'limit' => 1]);
         if ($dbMaintenances) {
             $dbMaintenance = reset($dbMaintenances);
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Maintenance "%1$s" already exists.', $dbMaintenance['name']));
         }
     }
     $hostids = [];
     $groupids = [];
     foreach ($maintenances as $maintenance) {
         // validate maintenance active since
         if (!validateUnixTime($maintenance['active_since'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active since')));
         }
         // validate maintenance active till
         if (!validateUnixTime($maintenance['active_till'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active till')));
         }
         // validate maintenance active interval
         if ($maintenance['active_since'] > $maintenance['active_till']) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Maintenance "Active since" value cannot be bigger than "Active till".'));
         }
         // validate timeperiods
         if (!array_key_exists('timeperiods', $maintenance) || !is_array($maintenance['timeperiods']) || !$maintenance['timeperiods']) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one maintenance period must be created.'));
         }
         foreach ($maintenance['timeperiods'] as $timeperiod) {
             if (!is_array($timeperiod)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one maintenance period must be created.'));
             }
         }
         $hostids = array_merge($hostids, $maintenance['hostids']);
         $groupids = array_merge($groupids, $maintenance['groupids']);
     }
     // validate hosts & groups
     if (empty($hostids) && empty($groupids)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one host or group should be selected.'));
     }
     // validate hosts permissions
     $options = ['hostids' => $hostids, 'editable' => true, 'output' => ['hostid'], 'preservekeys' => true];
     $updHosts = API::Host()->get($options);
     foreach ($hostids as $hostid) {
         if (!isset($updHosts[$hostid])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
         }
     }
     // validate groups permissions
     $options = ['groupids' => $groupids, 'editable' => true, 'output' => ['groupid'], 'preservekeys' => true];
     $updGroups = API::HostGroup()->get($options);
     foreach ($groupids as $groupid) {
         if (!isset($updGroups[$groupid])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
         }
     }
     $this->removeSecondsFromTimes($maintenances);
     $update = [];
     foreach ($maintenances as $mnum => $maintenance) {
         $dbFields = ['maintenanceid' => null];
         // validate fields
         if (!check_db_fields($dbFields, $maintenance)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect parameters for maintenance.'));
         }
         $update[$mnum] = ['values' => $maintenance, 'where' => ['maintenanceid' => $maintenance['maintenanceid']]];
         // update time periods
         $this->replaceTimePeriods($updMaintenances[$maintenance['maintenanceid']], $maintenance);
     }
     DB::update('maintenances', $update);
     // some of the hosts and groups bound to maintenance must be deleted, other inserted and others left alone
     $insertHosts = [];
     $insertGroups = [];
     foreach ($maintenances as $maintenance) {
         // putting apart those host<->maintenance connections that should be inserted, deleted and not changed
         // $hostDiff['first'] - new hosts, that should be inserted
         // $hostDiff['second'] - hosts, that should be deleted
         // $hostDiff['both'] - hosts, that should not be touched
         $hostDiff = zbx_array_diff(zbx_toObject($maintenance['hostids'], 'hostid'), $updMaintenances[$maintenance['maintenanceid']]['hosts'], 'hostid');
         foreach ($hostDiff['first'] as $host) {
             $insertHosts[] = ['hostid' => $host['hostid'], 'maintenanceid' => $maintenance['maintenanceid']];
         }
         foreach ($hostDiff['second'] as $host) {
             $deleteHosts = ['hostid' => $host['hostid'], 'maintenanceid' => $maintenance['maintenanceid']];
             DB::delete('maintenances_hosts', $deleteHosts);
         }
         // now the same with the groups
         $groupDiff = zbx_array_diff(zbx_toObject($maintenance['groupids'], 'groupid'), $updMaintenances[$maintenance['maintenanceid']]['groups'], 'groupid');
         foreach ($groupDiff['first'] as $group) {
             $insertGroups[] = ['groupid' => $group['groupid'], 'maintenanceid' => $maintenance['maintenanceid']];
         }
         foreach ($groupDiff['second'] as $group) {
             $deleteGroups = ['groupid' => $group['groupid'], 'maintenanceid' => $maintenance['maintenanceid']];
             DB::delete('maintenances_groups', $deleteGroups);
         }
         add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_MAINTENANCE, $maintenance['maintenanceid'], array_key_exists('name', $maintenance) ? $maintenance['name'] : $updMaintenances[$maintenance['maintenanceid']]['name'], 'maintenances', $updMaintenances[$maintenance['maintenanceid']], $maintenance);
     }
     DB::insert('maintenances_hosts', $insertHosts);
     DB::insert('maintenances_groups', $insertGroups);
     return ['maintenanceids' => $maintenanceids];
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CMaintenance.php

示例5: updateHostStatus

function updateHostStatus($hostids, $status)
{
    zbx_value2array($hostids);
    $hostIds = array();
    $oldStatus = $status == HOST_STATUS_MONITORED ? HOST_STATUS_NOT_MONITORED : HOST_STATUS_MONITORED;
    $db_hosts = DBselect('SELECT h.hostid,h.host,h.status' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.hostid', $hostids) . ' AND h.status=' . zbx_dbstr($oldStatus));
    while ($host = DBfetch($db_hosts)) {
        $hostIds[] = $host['hostid'];
        $host_new = $host;
        $host_new['status'] = $status;
        add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_HOST, $host['hostid'], $host['host'], 'hosts', $host, $host_new);
        info(_('Updated status of host') . ' "' . $host['host'] . '"');
    }
    return DB::update('hosts', array('values' => array('status' => $status), 'where' => array('hostid' => $hostIds)));
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:15,代码来源:hosts.inc.php

示例6: unset

    unset($_REQUEST['screenid']);
    $_REQUEST['form'] = 'clone';
} elseif (isset($_REQUEST['save'])) {
    if (isset($_REQUEST['screenid'])) {
        $screen = array('screenid' => $_REQUEST['screenid'], 'name' => $_REQUEST['name'], 'hsize' => $_REQUEST['hsize'], 'vsize' => $_REQUEST['vsize']);
        if (isset($_REQUEST['templateid'])) {
            $screenOld = API::TemplateScreen()->get(array('screenids' => $_REQUEST['screenid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true));
            $screenOld = reset($screenOld);
            $screenids = API::TemplateScreen()->update($screen);
        } else {
            $screenOld = API::Screen()->get(array('screenids' => $_REQUEST['screenid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true));
            $screenOld = reset($screenOld);
            $screenids = API::Screen()->update($screen);
        }
        if (!empty($screenids)) {
            add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'screens', $screenOld, $screen);
        }
        show_messages(!empty($screenids), _('Screen updated'), _('Cannot update screen'));
    } else {
        $screen = array('name' => $_REQUEST['name'], 'hsize' => $_REQUEST['hsize'], 'vsize' => $_REQUEST['vsize']);
        if (isset($_REQUEST['templateid'])) {
            $screen['templateid'] = get_request('templateid');
            $screenids = API::TemplateScreen()->create($screen);
        } else {
            $screenids = API::Screen()->create($screen);
        }
        if (!empty($screenids)) {
            $screenid = reset($screenids);
            $screenid = reset($screenid);
            add_audit_details(AUDIT_ACTION_ADD, AUDIT_RESOURCE_SCREEN, $screenid, $screen['name']);
        }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:31,代码来源:screenconf.php

示例7: updateReal

 /**
  * Updates trigger records in database.
  *
  * @param array $triggers
  */
 protected function updateReal(array $triggers)
 {
     $triggers = zbx_toArray($triggers);
     $infos = [];
     $triggerIds = zbx_objectValues($triggers, 'triggerid');
     $dbTriggers = $this->get(['output' => API_OUTPUT_EXTEND, 'triggerids' => $triggerIds, 'selectHosts' => ['name'], 'selectDependencies' => ['triggerid'], 'preservekeys' => true, 'nopermissions' => true]);
     $dbTriggers = CMacrosResolverHelper::resolveTriggerExpressions($dbTriggers);
     $changedPriorityTriggerIds = [];
     foreach ($triggers as &$trigger) {
         $descriptionChanged = false;
         $expressionChanged = false;
         $dbTrigger = $dbTriggers[$trigger['triggerid']];
         $hosts = zbx_objectValues($dbTrigger['hosts'], 'name');
         if (isset($trigger['description']) && strcmp($dbTrigger['description'], $trigger['description']) != 0) {
             $descriptionChanged = true;
         } else {
             $trigger['description'] = $dbTrigger['description'];
         }
         if (isset($trigger['expression']) && $dbTrigger['expression'] !== $trigger['expression']) {
             $this->validateItems($trigger);
             $expressionChanged = true;
             $expressionFull = $trigger['expression'];
         }
         if ($expressionChanged) {
             // check the expression
             $expressionData = new CTriggerExpression();
             if (!$expressionData->parse($expressionFull)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, $expressionData->error);
             }
             // remove triggers if expression is changed in a way that trigger will not appear in current host
             $oldExpressionData = new CTriggerExpression();
             $oldExpressionData->parse($dbTrigger['expression']);
             // check if at least one template has stayed in expression, this means that child trigger will stay in host
             $oldTemplates = $oldExpressionData->getHosts();
             $newTemplates = zbx_toHash($expressionData->getHosts());
             $proceed = true;
             foreach ($oldTemplates as $oldTemplate) {
                 if (isset($newTemplates[$oldTemplate])) {
                     $proceed = false;
                     break;
                 }
             }
             // proceed if there is possibility that child triggers should be deleted
             if ($proceed) {
                 $sql = 'SELECT t.triggerid' . ' FROM triggers t' . ' WHERE t.templateid=' . zbx_dbstr($trigger['triggerid']);
                 $cTrigCursor = DBselect($sql);
                 $cTrigIds = [];
                 while ($cTrig = DBfetch($cTrigCursor)) {
                     // get templates linked to templated trigger host
                     $templateNames = DBfetchArrayAssoc(DBselect('SELECT h.name' . ' FROM hosts h, hosts_templates ht, items i, functions f' . ' WHERE h.hostid = ht.templateid AND ht.hostid = i.hostid AND i.itemid = f.itemid AND' . ' f.triggerid=' . zbx_dbstr($cTrig['triggerid'])), 'name');
                     // if we have at least one template linked to trigger host inside trigger expression,
                     // then we don't delete this trigger
                     $expressionHosts = $expressionData->getHosts();
                     foreach ($expressionHosts as $templateName) {
                         if (isset($templateNames[$templateName])) {
                             continue 2;
                         }
                     }
                     $cTrigIds[] = $cTrig['triggerid'];
                 }
                 $this->deleteByIds($cTrigIds);
             }
             DB::delete('functions', ['triggerid' => $trigger['triggerid']]);
             try {
                 $trigger['expression'] = implode_exp($expressionFull, $trigger['triggerid'], $hosts);
             } catch (Exception $e) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot implode expression "%s".', $expressionFull) . ' ' . $e->getMessage());
             }
             // if the expression has changed, we must revalidate the existing dependencies
             if (!isset($trigger['dependencies'])) {
                 $trigger['dependencies'] = zbx_objectValues($dbTrigger['dependencies'], 'triggerid');
             }
         }
         $triggerUpdate = $trigger;
         if (!$descriptionChanged) {
             unset($triggerUpdate['description']);
         }
         if (!$expressionChanged) {
             unset($triggerUpdate['expression']);
         }
         // skip updating read only values
         unset($triggerUpdate['state'], $triggerUpdate['value'], $triggerUpdate['lastchange'], $triggerUpdate['error']);
         DB::update('triggers', ['values' => $triggerUpdate, 'where' => ['triggerid' => $trigger['triggerid']]]);
         // update service status
         if (isset($trigger['priority']) && $trigger['priority'] != $dbTrigger['priority']) {
             $changedPriorityTriggerIds[] = $trigger['triggerid'];
         }
         // restore the full expression to properly validate dependencies
         $trigger['expression'] = $expressionChanged ? $expressionFull : $dbTrigger['expression'];
         $infos[] = _s('Updated: Trigger "%1$s" on "%2$s".', $trigger['description'], implode(', ', $hosts));
         add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, $dbTrigger['triggerid'], $dbTrigger['description'], null, $dbTrigger, $triggerUpdate);
     }
     unset($trigger);
     if ($changedPriorityTriggerIds && $this->usedInItServices($changedPriorityTriggerIds)) {
         updateItServices();
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CTrigger.php

示例8: delete

 /**
  * Delete triggers.
  *
  * @param int|string|array $triggerIds array with trigger ids
  * @param bool             $nopermissions
  *
  * @return array
  */
 public function delete($triggerIds, $nopermissions = false)
 {
     if (empty($triggerIds)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameter.'));
     }
     $triggerIds = zbx_toArray($triggerIds);
     $triggerPrototypeIds = $triggerIds;
     $delTriggers = $this->get(array('triggerids' => $triggerIds, 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'preservekeys' => true));
     // TODO: remove $nopermissions hack
     if (!$nopermissions) {
         foreach ($triggerIds as $triggerId) {
             if (!isset($delTriggers[$triggerId])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             if ($delTriggers[$triggerId]['templateid'] != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot delete templated trigger "%1$s:%2$s".', $delTriggers[$triggerId]['description'], explode_exp($delTriggers[$triggerId]['expression'])));
             }
         }
     }
     // get child triggers
     $parentTriggerids = $triggerIds;
     do {
         $dbItems = DBselect('SELECT triggerid FROM triggers WHERE ' . dbConditionInt('templateid', $parentTriggerids));
         $parentTriggerids = array();
         while ($dbTrigger = DBfetch($dbItems)) {
             $parentTriggerids[] = $dbTrigger['triggerid'];
             $triggerIds[$dbTrigger['triggerid']] = $dbTrigger['triggerid'];
         }
     } while (!empty($parentTriggerids));
     // select all triggers which are deleted (include childs)
     $delTriggers = $this->get(array('triggerids' => $triggerIds, 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true, 'preservekeys' => true, 'selectHosts' => array('name')));
     // created triggers
     $createdTriggers = array();
     $sql = 'SELECT triggerid FROM trigger_discovery WHERE ' . dbConditionInt('parent_triggerid', $triggerIds);
     $dbTriggers = DBselect($sql);
     while ($trigger = DBfetch($dbTriggers)) {
         $createdTriggers[$trigger['triggerid']] = $trigger['triggerid'];
     }
     if (!empty($createdTriggers)) {
         $result = API::Trigger()->delete($createdTriggers, true);
         if (!$result) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot delete triggers created by low level discovery.'));
         }
     }
     // TODO: REMOVE info
     foreach ($delTriggers as $trigger) {
         info(_s('Deleted: Trigger prototype "%1$s" on "%2$s".', $trigger['description'], implode(', ', zbx_objectValues($trigger['hosts'], 'name'))));
         add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TRIGGER_PROTOTYPE, $trigger['triggerid'], $trigger['description'] . ':' . $trigger['expression'], null, null, null);
     }
     DB::delete('triggers', array('triggerid' => $triggerIds));
     return array('triggerids' => $triggerPrototypeIds);
 }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:60,代码来源:CTriggerPrototype.php

示例9: array

                }
            }
            // clone screens
            $screens = API::TemplateScreen()->get(array('templateids' => $cloneTemplateId, 'output' => array('screenid'), 'preservekeys' => true, 'inherited' => false));
            if ($screens) {
                $screensCopied = API::TemplateScreen()->copy(array('screenIds' => zbx_objectValues($screens, 'screenid'), 'templateIds' => $templateId));
                if (!$screensCopied) {
                    throw new Exception();
                }
            }
        }
        DBend(true);
        show_messages(true, $msgOk, $msgFail);
        clearCookies(true);
        if ($created) {
            add_audit_ext(AUDIT_ACTION_ADD, AUDIT_RESOURCE_TEMPLATE, $templateId, $templateName, 'hosts', null, null);
        }
        unset($_REQUEST['form'], $_REQUEST['templateid']);
    } catch (Exception $e) {
        DBend(false);
        show_messages(false, $msgOk, $msgFail);
    }
    unset($_REQUEST['save']);
} elseif (isset($_REQUEST['delete']) && isset($_REQUEST['templateid'])) {
    DBstart();
    $goResult = true;
    $result = API::Template()->massUpdate(array('templates' => zbx_toObject($_REQUEST['templateid'], 'templateid'), 'hosts' => array()));
    if ($result) {
        $result = API::Template()->delete($_REQUEST['templateid']);
    }
    $result = DBend($result);
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:templates.php

示例10: get_request

    $groups = get_request('groups', array());
    $go_result = API::HostGroup()->delete($groups);
    show_messages($go_result, _('Group deleted'), _('Cannot delete group'));
} elseif (str_in_array($_REQUEST['go'], array('activate', 'disable'))) {
    $status = $_REQUEST['go'] == 'activate' ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED;
    $groups = get_request('groups', array());
    if (!empty($groups)) {
        DBstart();
        $hosts = API::Host()->get(array('groupids' => $groups, 'editable' => 1, 'output' => API_OUTPUT_EXTEND));
        if (empty($hosts)) {
            $go_result = true;
        } else {
            $go_result = API::Host()->massUpdate(array('hosts' => $hosts, 'status' => $status));
            if ($go_result) {
                foreach ($hosts as $host) {
                    add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_HOST, $host['hostid'], $host['host'], 'hosts', array('status' => $host['status']), array('status' => $status));
                }
            }
        }
        $go_result = DBend($go_result);
        show_messages($go_result, _('Host status updated'), _('Cannot update host'));
    }
}
if ($_REQUEST['go'] != 'none' && isset($go_result) && $go_result) {
    $url = new CUrl();
    $path = $url->getPath();
    insert_js('cookie.eraseArray("' . $path . '")');
}
/*
 * Display
 */
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:hostgroups.php

示例11: delete

 /**
  * Delete host groups.
  *
  * @param array $groupids
  *
  * @return boolean
  */
 public function delete($groupids)
 {
     if (empty($groupids)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameter.'));
     }
     $groupids = zbx_toArray($groupids);
     $options = array('groupids' => $groupids, 'editable' => true, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true);
     $delGroups = $this->get($options);
     foreach ($groupids as $groupid) {
         if (!isset($delGroups[$groupid])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
         }
         if ($delGroups[$groupid]['internal'] == ZBX_INTERNAL_GROUP) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Group "%1$s" is internal and can not be deleted.', $delGroups[$groupid]['name']));
         }
     }
     $dltGroupids = getDeletableHostGroups($groupids);
     if (count($groupids) != count($dltGroupids)) {
         foreach ($groupids as $groupid) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Group "%s" cannot be deleted, because some hosts depend on it.', $delGroups[$groupid]['name']));
         }
     }
     $dbScripts = API::Script()->get(array('groupids' => $groupids, 'output' => array('scriptid', 'groupid'), 'nopermissions' => true));
     if (!empty($dbScripts)) {
         foreach ($dbScripts as $script) {
             if ($script['groupid'] == 0) {
                 continue;
             }
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Group "%s" cannot be deleted, because it is used in a global script.', $delGroups[$script['groupid']]['name']));
         }
     }
     // delete screens items
     $resources = array(SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO, SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW);
     DB::delete('screens_items', array('resourceid' => $groupids, 'resourcetype' => $resources));
     // delete sysmap element
     if (!empty($groupids)) {
         DB::delete('sysmaps_elements', array('elementtype' => SYSMAP_ELEMENT_TYPE_HOST_GROUP, 'elementid' => $groupids));
     }
     // disable actions
     // actions from conditions
     $actionids = array();
     $dbActions = DBselect('SELECT DISTINCT c.actionid' . ' FROM conditions c' . ' WHERE c.conditiontype=' . CONDITION_TYPE_HOST_GROUP . ' AND ' . dbConditionString('c.value', $groupids));
     while ($dbAction = DBfetch($dbActions)) {
         $actionids[$dbAction['actionid']] = $dbAction['actionid'];
     }
     // actions from operations
     $dbActions = DBselect('SELECT DISTINCT o.actionid' . ' FROM operations o,opgroup og' . ' WHERE o.operationid=og.operationid' . ' AND ' . dbConditionInt('og.groupid', $groupids));
     while ($dbAction = DBfetch($dbActions)) {
         $actionids[$dbAction['actionid']] = $dbAction['actionid'];
     }
     if (!empty($actionids)) {
         $update = array();
         $update[] = array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionids));
         DB::update('actions', $update);
     }
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_HOST_GROUP, 'value' => $groupids));
     // delete action operation commands
     $operationids = array();
     $dbOperations = DBselect('SELECT DISTINCT og.operationid' . ' FROM opgroup og' . ' WHERE ' . dbConditionInt('og.groupid', $groupids));
     while ($dbOperation = DBfetch($dbOperations)) {
         $operationids[$dbOperation['operationid']] = $dbOperation['operationid'];
     }
     DB::delete('opgroup', array('groupid' => $groupids));
     // delete empty operations
     $delOperationids = array();
     $dbOperations = DBselect('SELECT DISTINCT o.operationid' . ' FROM operations o' . ' WHERE ' . dbConditionInt('o.operationid', $operationids) . ' AND NOT EXISTS (SELECT NULL FROM opgroup og WHERE o.operationid=og.operationid)');
     while ($dbOperation = DBfetch($dbOperations)) {
         $delOperationids[$dbOperation['operationid']] = $dbOperation['operationid'];
     }
     DB::delete('operations', array('operationid' => $delOperationids));
     // host groups
     DB::delete('groups', array('groupid' => $groupids));
     // TODO: remove audit
     foreach ($groupids as $groupid) {
         add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST_GROUP, $groupid, $delGroups[$groupid]['name'], 'groups', null, null);
     }
     return array('groupids' => $groupids);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:86,代码来源:CHostGroup.php

示例12: show_messages

                             show_messages($go_result, S_TRIGGER_ADDED, S_CANNOT_ADD_TRIGGER);
                         } else {
                             if ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_triggerid'])) {
                                 DBstart();
                                 $triggerids = array();
                                 $options = array('triggerids' => $_REQUEST['g_triggerid'], 'editable' => 1, 'select_hosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'expandDescription' => 1);
                                 $triggers = CTrigger::get($options);
                                 foreach ($triggers as $tnum => $trigger) {
                                     if ($trigger['templateid'] != 0) {
                                         unset($triggers[$tnum]);
                                         error(S_CANNOT_DELETE_TRIGGER . ' [ ' . $trigger['description'] . ' ] (' . S_TEMPLATED_TRIGGER . ')');
                                         continue;
                                     }
                                     $triggerids[] = $trigger['triggerid'];
                                     $host = reset($trigger['hosts']);
                                     add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TRIGGER, $trigger['triggerid'], $host['host'] . ':' . $trigger['description'], NULL, NULL, NULL);
                                 }
                                 $go_result = !empty($triggerids);
                                 if ($go_result) {
                                     $go_result = CTrigger::delete($triggerids);
                                 }
                                 $go_result = DBend($go_result);
                                 show_messages($go_result, S_TRIGGERS_DELETED, S_CANNOT_DELETE_TRIGGERS);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:triggers.php

示例13: error

                                } else {
                                    error('No target selection.');
                                }
                                show_messages($result, S_TRIGGER_ADDED, S_CANNOT_ADD_TRIGGER);
                            } else {
                                if ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_triggerid'])) {
                                    $_REQUEST['g_triggerid'] = array_intersect($_REQUEST['g_triggerid'], $available_triggers);
                                    DBstart();
                                    foreach ($_REQUEST['g_triggerid'] as $id => $triggerid) {
                                        $row = DBfetch(DBselect('SELECT triggerid,templateid FROM triggers t WHERE t.triggerid=' . $triggerid));
                                        if ($row['templateid'] != 0) {
                                            unset($_REQUEST['g_triggerid'][$id]);
                                            continue;
                                        }
                                        $description = expand_trigger_description($triggerid);
                                        add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TRIGGER, $triggerid, $description, NULL, NULL, NULL);
                                    }
                                    $result = delete_trigger($_REQUEST['g_triggerid']);
                                    $result = DBend($result);
                                    show_messages($result, S_TRIGGERS_DELETED, S_CANNOT_DELETE_TRIGGERS);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if (isset($_REQUEST['hostid']) && !isset($_REQUEST['groupid']) && !isset($_REQUEST['triggerid'])) {
    $sql = 'SELECT DISTINCT hg.groupid ' . ' FROM hosts_groups hg ' . ' WHERE hg.hostid=' . $_REQUEST['hostid'];
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:triggers.php

示例14: array

    $goResult = API::HostGroup()->delete(get_request('groups', array()));
    show_messages($goResult, _('Group deleted'), _('Cannot delete group'));
    clearCookies($goResult);
} elseif (str_in_array(getRequest('go'), array('activate', 'disable'))) {
    $enable = getRequest('go') == 'activate';
    $status = $enable ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED;
    $auditAction = $enable ? AUDIT_ACTION_ENABLE : AUDIT_ACTION_DISABLE;
    $groups = getRequest('groups', array());
    if ($groups) {
        DBstart();
        $hosts = API::Host()->get(array('groupids' => $groups, 'editable' => true, 'output' => API_OUTPUT_EXTEND));
        if ($hosts) {
            $result = API::Host()->massUpdate(array('hosts' => $hosts, 'status' => $status));
            if ($result) {
                foreach ($hosts as $host) {
                    add_audit_ext($auditAction, AUDIT_RESOURCE_HOST, $host['hostid'], $host['host'], 'hosts', array('status' => $host['status']), array('status' => $status));
                }
            }
        } else {
            $result = true;
        }
        $result = DBend($result);
        $updated = count($hosts);
        $messageSuccess = $enable ? _n('Host enabled', 'Hosts enabled', $updated) : _n('Host disabled', 'Hosts disabled', $updated);
        $messageFailed = $enable ? _n('Cannot enable host', 'Cannot enable hosts', $updated) : _n('Cannot disable host', 'Cannot disable hosts', $updated);
        show_messages($result, $messageSuccess, $messageFailed);
        clearCookies($result);
    }
}
/*
 * Display
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:hostgroups.php

示例15: delete_item

function delete_item($itemids)
{
    zbx_value2array($itemids);
    if (empty($itemids)) {
        return true;
    }
    // Get items INFO before delete them!
    $items = array();
    $item_res = DBselect('SELECT itemid, description, key_ FROM items WHERE ' . DBcondition('itemid', $itemids));
    while ($item_rows = DBfetch($item_res)) {
        $items[$item_rows['itemid']] = $item_rows;
    }
    // --
    $hosts = array();
    $hosts = get_host_by_itemid($itemids);
    // first delete child items
    $del_cld_items = array();
    $db_items = DBselect('SELECT itemid FROM items WHERE ' . DBcondition('templateid', $itemids));
    while ($db_item = DBfetch($db_items)) {
        // recursion !!!!
        $del_cld_items[$db_item['itemid']] = $db_item['itemid'];
    }
    if (!empty($del_cld_items)) {
        $result = delete_item($del_cld_items);
        if (!$result) {
            return $result;
        }
    }
    //--
    // triggers
    $result = delete_triggers_by_itemid($itemids);
    if (!$result) {
        return $result;
    }
    //--
    // delete graphs
    $del_graphs = array();
    $db_gitems = DBselect('SELECT DISTINCT graphid FROM graphs_items WHERE ' . DBcondition('itemid', $itemids));
    while ($db_gitem = DBfetch($db_gitems)) {
        $del_graphs[$db_gitem['graphid']] = $db_gitem['graphid'];
    }
    if (!empty($del_graphs)) {
        $result = delete_graph($del_graphs);
        if (!$result) {
            return $result;
        }
    }
    //--
    $result = delete_history_by_itemid($itemids, 1);
    if (!$result) {
        return $result;
    }
    $temp_arr = array(SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT);
    DBexecute('DELETE FROM screens_items WHERE ' . DBcondition('resourceid', $itemids) . ' AND ' . DBcondition('resourcetype', $temp_arr));
    DBexecute('DELETE FROM items_applications WHERE ' . DBcondition('itemid', $itemids));
    DBexecute("DELETE FROM profiles WHERE idx='web.favorite.graphids' AND source='itemid' AND " . DBcondition('value_id', $itemids));
    foreach ($itemids as $id) {
        /* The section should be improved */
        $item_old = get_item_by_itemid($id);
        $result = DBexecute('DELETE FROM items WHERE itemid=' . $id);
        if ($result) {
            add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ITEM, $id, $item_old['description'], 'items', NULL, NULL);
        } else {
            break;
        }
    }
    /*		$result = DBexecute('DELETE FROM items WHERE '.DBcondition('itemid',$itemids));*/
    if ($result) {
        foreach ($items as $itemid => $item) {
            info("Item '" . $hosts[$itemid]['host'] . ':' . $item['key_'] . "' deleted");
        }
    }
    return $result;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:74,代码来源:items.inc.php


注:本文中的add_audit_ext函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。