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


PHP andDbNode函数代码示例

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


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

示例1: bodyToString

 public function bodyToString()
 {
     $this->cleanItems();
     $total = 0;
     // fetch accessible host ids
     $hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => array('hostid'), 'preservekeys' => true));
     $hostIds = array_keys($hosts);
     if (remove_nodes_from_id($this->groupid) > 0) {
         $cond_from = ',hosts_groups hg';
         $cond_where = ' AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid);
     } else {
         $cond_from = '';
         $cond_where = andDbNode('h.hostid', $this->nodeid);
     }
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $avail = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $notav = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $uncn = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $node = get_node_by_nodeid($this->nodeid);
     $header_str = _('Hosts info') . SPACE;
     if ($node > 0) {
         $header_str .= '(' . $node['name'] . ')' . SPACE;
     }
     if (remove_nodes_from_id($this->groupid) > 0) {
         $group = get_hostgroup_by_groupid($this->groupid);
         $header_str .= _('Group') . SPACE . '"' . $group['name'] . '"';
     } else {
         $header_str .= _('All groups');
     }
     $header = new CCol($header_str, 'header');
     if ($this->style == STYLE_HORISONTAL) {
         $header->setColspan(4);
     }
     $this->addRow($header);
     $avail = new CCol($avail . '  ' . _('Available'), 'avail');
     $notav = new CCol($notav . '  ' . _('Not available'), 'notav');
     $uncn = new CCol($uncn . '  ' . _('Unknown'), 'uncn');
     $total = new CCol($total . '  ' . _('Total'), 'total');
     if ($this->style == STYLE_HORISONTAL) {
         $this->addRow(array($avail, $notav, $uncn, $total));
     } else {
         $this->addRow($avail);
         $this->addRow($notav);
         $this->addRow($uncn);
         $this->addRow($total);
     }
     return parent::bodyToString();
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:56,代码来源:class.chostsinfo.php

示例2: updateRegexp

function updateRegexp(array $regexp, array $expressions)
{
    try {
        $regexpId = $regexp['regexpid'];
        unset($regexp['regexpid']);
        // check existence
        if (!getRegexp($regexpId)) {
            throw new Exception(_('Regular expression does not exist.'));
        }
        // check required fields
        $dbFields = array('name' => null);
        if (!check_db_fields($dbFields, $regexp)) {
            throw new Exception(_('Incorrect arguments passed to function') . ' [updateRegexp]');
        }
        // check duplicate name
        $dbRegexp = DBfetch(DBselect('SELECT re.regexpid' . ' FROM regexps re' . ' WHERE re.name=' . zbx_dbstr($regexp['name']) . andDbNode('re.regexpid')));
        if ($dbRegexp && bccomp($regexpId, $dbRegexp['regexpid']) != 0) {
            throw new Exception(_s('Regular expression "%s" already exists.', $regexp['name']));
        }
        rewriteRegexpExpressions($regexpId, $expressions);
        DB::update('regexps', array('values' => $regexp, 'where' => array('regexpid' => $regexpId)));
    } catch (Exception $e) {
        error($e->getMessage());
        return false;
    }
    return true;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:27,代码来源:regexp.inc.php

示例3: checkInput

 /**
  * Check input.
  *
  * @param array  $triggers
  * @param string $method
  */
 public function checkInput(array &$triggers, $method)
 {
     $create = $method == 'create';
     $update = $method == 'update';
     // permissions
     if ($update) {
         $triggerDbFields = array('triggerid' => null);
         $dbTriggers = $this->get(array('triggerids' => zbx_objectValues($triggers, 'triggerid'), 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'preservekeys' => true, 'selectDependencies' => API_OUTPUT_REFER));
         $updateDiscoveredValidator = new CUpdateDiscoveredValidator(array('allowed' => array('triggerid', 'status'), 'messageAllowedField' => _('Cannot update "%1$s" for a discovered trigger.')));
         foreach ($triggers as $trigger) {
             // check permissions
             if (!isset($dbTriggers[$trigger['triggerid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             // discovered fields, except status, cannot be updated
             $this->checkPartialValidator($trigger, $updateDiscoveredValidator, $dbTriggers[$trigger['triggerid']]);
         }
         $triggers = $this->extendObjects($this->tableName(), $triggers, array('description'));
     } else {
         $triggerDbFields = array('description' => null, 'expression' => null, 'value' => TRIGGER_VALUE_FALSE);
     }
     foreach ($triggers as $tnum => &$trigger) {
         $currentTrigger = $triggers[$tnum];
         $this->checkNoParameters($trigger, array('templateid', 'state', 'value', 'value_flag'), $update ? _('Cannot update "%1$s" for trigger "%2$s".') : _('Cannot set "%1$s" for trigger "%2$s".'), $trigger['description']);
         if (!check_db_fields($triggerDbFields, $trigger)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect fields for trigger.'));
         }
         $expressionChanged = true;
         if ($update) {
             $dbTrigger = $dbTriggers[$trigger['triggerid']];
             if (isset($trigger['expression'])) {
                 $expressionFull = explode_exp($dbTrigger['expression']);
                 if (strcmp($trigger['expression'], $expressionFull) == 0) {
                     $expressionChanged = false;
                 }
             }
             if (isset($trigger['description']) && strcmp($trigger['description'], $dbTrigger['description']) == 0) {
                 unset($trigger['description']);
             }
         }
         // if some of the properties are unchanged, no need to update them in DB
         // validating trigger expression
         if (isset($trigger['expression']) && $expressionChanged) {
             // expression permissions
             $expressionData = new CTriggerExpression(array('lldmacros' => false));
             if (!$expressionData->parse($trigger['expression'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, $expressionData->error);
             }
             if (!isset($expressionData->expressions[0])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Trigger expression must contain at least one host:key reference.'));
             }
             $expressionHosts = $expressionData->getHosts();
             $hosts = API::Host()->get(array('filter' => array('host' => $expressionHosts), 'editable' => true, 'output' => array('hostid', 'host', 'status'), 'templated_hosts' => true, 'preservekeys' => true));
             $hosts = zbx_toHash($hosts, 'host');
             $hostsStatusFlags = 0x0;
             foreach ($expressionHosts as $host) {
                 if (!isset($hosts[$host])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect trigger expression. Host "%s" does not exist or you have no access to this host.', $host));
                 }
                 // find out if both templates and hosts are referenced in expression
                 $hostsStatusFlags |= $hosts[$host]['status'] == HOST_STATUS_TEMPLATE ? 0x1 : 0x2;
                 if ($hostsStatusFlags == 0x3) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect trigger expression. Trigger expression elements should not belong to a template and a host simultaneously.'));
                 }
             }
             foreach ($expressionData->expressions as $exprPart) {
                 $sql = 'SELECT i.itemid,i.value_type' . ' FROM items i,hosts h' . ' WHERE i.key_=' . zbx_dbstr($exprPart['item']) . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' AND h.host=' . zbx_dbstr($exprPart['host']) . ' AND h.hostid=i.hostid' . andDbNode('i.itemid');
                 if (!DBfetch(DBselect($sql))) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect item key "%1$s" provided for trigger expression on "%2$s".', $exprPart['item'], $exprPart['host']));
                 }
             }
         }
         // check existing
         $this->checkIfExistsOnHost($currentTrigger);
     }
     unset($trigger);
 }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:83,代码来源:CTrigger.php

示例4: get_host_by_hostid

        if ($goResult) {
            $host = get_host_by_hostid($dbApplication['hostid']);
            add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_APPLICATION, 'Application [' . $dbApplication['name'] . '] from host [' . $host['host'] . ']');
        }
    }
    $goResult = DBend($goResult);
    show_messages($goResult, _('Application deleted'), _('Cannot delete application'));
    clearCookies($goResult, $_REQUEST['hostid']);
} elseif (str_in_array(getRequest('go'), array('activate', 'disable'))) {
    $result = true;
    $hostId = getRequest('hostid');
    $enable = getRequest('go') == 'activate';
    $updated = 0;
    DBstart();
    foreach (getRequest('applications') as $id => $appid) {
        $dbItems = DBselect('SELECT ia.itemid,i.hostid,i.key_' . ' FROM items_applications ia' . ' LEFT JOIN items i ON ia.itemid=i.itemid' . ' WHERE ia.applicationid=' . zbx_dbstr($appid) . ' AND i.hostid=' . zbx_dbstr($hostId) . ' AND i.type<>' . ITEM_TYPE_HTTPTEST . andDbNode('ia.applicationid'));
        while ($item = DBfetch($dbItems)) {
            $result &= $enable ? activate_item($item['itemid']) : disable_item($item['itemid']);
            $updated++;
        }
    }
    $result = DBend($result);
    $messageSuccess = $enable ? _n('Item enabled', 'Items enabled', $updated) : _n('Item disabled', 'Items disabled', $updated);
    $messageFailed = $enable ? _n('Cannot enable item', 'Cannot enable items', $updated) : _n('Cannot disable item', 'Cannot disable items', $updated);
    show_messages($result, $messageSuccess, $messageFailed);
    clearCookies($result, $hostId);
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:applications.php

示例5: getExpressionItems

/**
 * Get items from expression.
 *
 * @param CTriggerExpression $triggerExpression
 *
 * @return array
 */
function getExpressionItems(CTriggerExpression $triggerExpression)
{
    $items = array();
    $processedFunctions = array();
    $processedItems = array();
    foreach ($triggerExpression->expressions as $expression) {
        if (isset($processedFunctions[$expression['expression']])) {
            continue;
        }
        if (!isset($processedItems[$expression['host']][$expression['item']])) {
            $dbItems = DBselect('SELECT i.itemid,i.flags' . ' FROM items i,hosts h' . ' WHERE i.key_=' . zbx_dbstr($expression['item']) . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED, ZBX_FLAG_DISCOVERY_PROTOTYPE)) . ' AND h.host=' . zbx_dbstr($expression['host']) . ' AND h.hostid=i.hostid' . andDbNode('i.itemid'));
            if ($dbItem = DBfetch($dbItems)) {
                $items[] = $dbItem;
                $processedItems[$expression['host']][$expression['item']] = true;
            }
        }
        $processedFunctions[$expression['expression']] = true;
    }
    return $items;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:27,代码来源:triggers.inc.php

示例6: get_status

function get_status()
{
    global $ZBX_SERVER, $ZBX_SERVER_PORT;
    $status = array('triggers_count' => 0, 'triggers_count_enabled' => 0, 'triggers_count_disabled' => 0, 'triggers_count_off' => 0, 'triggers_count_on' => 0, 'items_count' => 0, 'items_count_monitored' => 0, 'items_count_disabled' => 0, 'items_count_not_supported' => 0, 'hosts_count' => 0, 'hosts_count_monitored' => 0, 'hosts_count_not_monitored' => 0, 'hosts_count_template' => 0, 'users_online' => 0, 'qps_total' => 0);
    // server
    $zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, 0);
    $status['zabbix_server'] = $zabbixServer->isRunning() ? _('Yes') : _('No');
    // triggers
    $dbTriggers = DBselect('SELECT COUNT(DISTINCT t.triggerid) AS cnt,t.status,t.value' . ' FROM triggers t' . ' INNER JOIN functions f ON t.triggerid=f.triggerid' . ' INNER JOIN items i ON f.itemid=i.itemid' . ' INNER JOIN hosts h ON i.hostid=h.hostid' . ' WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.flags IN (' . ZBX_FLAG_DISCOVERY_NORMAL . ',' . ZBX_FLAG_DISCOVERY_CREATED . ')' . ' GROUP BY t.status,t.value');
    while ($dbTrigger = DBfetch($dbTriggers)) {
        switch ($dbTrigger['status']) {
            case TRIGGER_STATUS_ENABLED:
                switch ($dbTrigger['value']) {
                    case TRIGGER_VALUE_FALSE:
                        $status['triggers_count_off'] = $dbTrigger['cnt'];
                        break;
                    case TRIGGER_VALUE_TRUE:
                        $status['triggers_count_on'] = $dbTrigger['cnt'];
                        break;
                }
                break;
            case TRIGGER_STATUS_DISABLED:
                $status['triggers_count_disabled'] += $dbTrigger['cnt'];
                break;
        }
    }
    $status['triggers_count_enabled'] = $status['triggers_count_off'] + $status['triggers_count_on'];
    $status['triggers_count'] = $status['triggers_count_enabled'] + $status['triggers_count_disabled'];
    // items
    $dbItems = DBselect('SELECT COUNT(i.itemid) AS cnt,i.status,i.state' . ' FROM items i' . ' INNER JOIN hosts h ON i.hostid=h.hostid' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND i.flags IN (' . ZBX_FLAG_DISCOVERY_NORMAL . ',' . ZBX_FLAG_DISCOVERY_CREATED . ')' . ' AND i.type<>' . ITEM_TYPE_HTTPTEST . ' GROUP BY i.status,i.state');
    while ($dbItem = DBfetch($dbItems)) {
        if ($dbItem['status'] == ITEM_STATUS_ACTIVE) {
            if ($dbItem['state'] == ITEM_STATE_NORMAL) {
                $status['items_count_monitored'] = $dbItem['cnt'];
            } else {
                $status['items_count_not_supported'] = $dbItem['cnt'];
            }
        } elseif ($dbItem['status'] == ITEM_STATUS_DISABLED) {
            $status['items_count_disabled'] += $dbItem['cnt'];
        }
    }
    $status['items_count'] = $status['items_count_monitored'] + $status['items_count_disabled'] + $status['items_count_not_supported'];
    // hosts
    $dbHosts = DBselect('SELECT COUNT(*) AS cnt,h.status' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.status', array(HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED, HOST_STATUS_TEMPLATE)) . ' AND ' . dbConditionInt('h.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' GROUP BY h.status');
    while ($dbHost = DBfetch($dbHosts)) {
        switch ($dbHost['status']) {
            case HOST_STATUS_MONITORED:
                $status['hosts_count_monitored'] = $dbHost['cnt'];
                break;
            case HOST_STATUS_NOT_MONITORED:
                $status['hosts_count_not_monitored'] = $dbHost['cnt'];
                break;
            case HOST_STATUS_TEMPLATE:
                $status['hosts_count_template'] = $dbHost['cnt'];
                break;
        }
    }
    $status['hosts_count'] = $status['hosts_count_monitored'] + $status['hosts_count_not_monitored'] + $status['hosts_count_template'];
    // users
    $row = DBfetch(DBselect('SELECT COUNT(*) AS usr_cnt' . ' FROM users u' . whereDbNode('u.userid')));
    $status['users_count'] = $row['usr_cnt'];
    $status['users_online'] = 0;
    $db_sessions = DBselect('SELECT s.userid,s.status,MAX(s.lastaccess) AS lastaccess' . ' FROM sessions s' . ' WHERE s.status=' . ZBX_SESSION_ACTIVE . andDbNode('s.userid') . ' GROUP BY s.userid,s.status');
    while ($session = DBfetch($db_sessions)) {
        if ($session['lastaccess'] + ZBX_USER_ONLINE_TIME >= time()) {
            $status['users_online']++;
        }
    }
    // comments: !!! Don't forget sync code with C !!!
    $row = DBfetch(DBselect('SELECT SUM(1.0/i.delay) AS qps' . ' FROM items i,hosts h' . ' WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND i.hostid=h.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.delay<>0'));
    $status['qps_total'] = round($row['qps'], 2);
    return $status;
}
开发者ID:itnihao,项目名称:Zabbix_,代码行数:73,代码来源:func.inc.php

示例7: get_actions_hint_by_eventid

function get_actions_hint_by_eventid($eventid, $status = null)
{
    $tab_hint = new CTableInfo(_('No actions found.'));
    $tab_hint->setAttribute('style', 'width: 300px;');
    $tab_hint->setHeader(array(is_show_all_nodes() ? _('Nodes') : null, _('User'), _('Details'), _('Status')));
    $sql = 'SELECT a.alertid,mt.description,u.alias,u.name,u.surname,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype' . ' FROM events e,alerts a' . ' LEFT JOIN users u ON u.userid=a.userid' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE a.eventid=' . zbx_dbstr($eventid) . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid=a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . andDbNode('a.alertid') . ' ORDER BY a.alertid';
    $result = DBselect($sql, 30);
    while ($row = DBfetch($result)) {
        if ($row['status'] == ALERT_STATUS_SENT) {
            $status = new CSpan(_('Sent'), 'green');
        } elseif ($row['status'] == ALERT_STATUS_NOT_SENT) {
            $status = new CSpan(_('In progress'), 'orange');
        } else {
            $status = new CSpan(_('not sent'), 'red');
        }
        switch ($row['alerttype']) {
            case ALERT_TYPE_MESSAGE:
                $message = empty($row['description']) ? '-' : $row['description'];
                break;
            case ALERT_TYPE_COMMAND:
                $message = array(bold(_('Command') . NAME_DELIMITER));
                $msg = explode("\n", $row['message']);
                foreach ($msg as $m) {
                    array_push($message, BR(), $m);
                }
                break;
            default:
                $message = '-';
        }
        if (!$row['alias']) {
            $row['alias'] = ' - ';
        } else {
            $fullname = '';
            if ($row['name']) {
                $fullname = $row['name'];
            }
            if ($row['surname']) {
                $fullname .= $fullname ? ' ' . $row['surname'] : $row['surname'];
            }
            if ($fullname) {
                $row['alias'] .= ' (' . $fullname . ')';
            }
        }
        $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), $row['alias'], $message, $status));
    }
    return $tab_hint;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:47,代码来源:actions.inc.php

示例8: get_icon

    $columns[$col][] = $lastiss;
}
// web monitoring
$refresh_menu = get_icon('menu', array('menu' => 'hat_webovr'));
$web_mon = new CUIWidget('hat_webovr', new CSpan(_('Loading...'), 'textcolorstyles'), CProfile::get('web.dashboard.widget.webovr.state', 1));
$web_mon->setHeader(_('Web monitoring'), array($refresh_menu));
$web_mon->setFooter(new CDiv(SPACE, 'textwhite', 'hat_webovr_footer'));
$col = CProfile::get('web.dashboard.widget.webovr.col', '1');
$row = CProfile::get('web.dashboard.widget.webovr.row', '4');
if (!isset($columns[$col][$row])) {
    $columns[$col][$row] = $web_mon;
} else {
    $columns[$col][] = $web_mon;
}
// discovery info
$drules = DBfetch(DBselect('SELECT COUNT(d.druleid) AS cnt' . ' FROM drules d' . ' WHERE d.status=' . DRULE_STATUS_ACTIVE . andDbNode('d.druleid')));
if ($drules['cnt'] > 0 && check_right_on_discovery()) {
    $refresh_tab[] = array('id' => 'hat_dscvry', 'frequency' => CProfile::get('web.dashboard.widget.dscvry.rf_rate', 60));
    $refresh_menu = get_icon('menu', array('menu' => 'hat_dscvry'));
    $dcvr_mon = new CUIWidget('hat_dscvry', new CSpan(_('Loading...'), 'textcolorstyles'), CProfile::get('web.dashboard.widget.dscvry.state', 1));
    $dcvr_mon->setHeader(_('Discovery status'), array($refresh_menu));
    $dcvr_mon->setFooter(new CDiv(SPACE, 'textwhite', 'hat_dscvry_footer'));
    $col = CProfile::get('web.dashboard.widget.dscvry.col', '1');
    $row = CProfile::get('web.dashboard.widget.dscvry.row', '5');
    if (!isset($columns[$col][$row])) {
        $columns[$col][$row] = $dcvr_mon;
    } else {
        $columns[$col][] = $dcvr_mon;
    }
}
add_doll_objects($refresh_tab);
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:dashboard.php

示例9: updateDB

 private static function updateDB($idx, $value, $type, $idx2)
 {
     $sql_cond = '';
     if ($idx != 'web.nodes.switch_node') {
         $sql_cond .= andDbNode('profileid', false);
     }
     if ($idx2 > 0) {
         $sql_cond .= ' AND idx2=' . $idx2 . andDbNode('idx2', false);
     }
     $value_type = self::getFieldByType($type);
     return DBexecute('UPDATE profiles SET ' . $value_type . '=' . zbx_dbstr($value) . ',' . ' type=' . $type . ' WHERE userid=' . self::$userDetails['userid'] . ' AND idx=' . zbx_dbstr($idx) . $sql_cond);
 }
开发者ID:hujingguang,项目名称:work,代码行数:12,代码来源:profiles.inc.php

示例10: checkAuthentication

 /**
  * Check if session id is authenticated.
  *
  * @param string $sessionid		session id
  *
  * @return array				an array of user data
  */
 public function checkAuthentication($sessionid)
 {
     global $ZBX_LOCALNODEID;
     // access DB only once per page load
     if (!is_null(self::$userData)) {
         return self::$userData;
     }
     $time = time();
     $userInfo = DBfetch(DBselect('SELECT u.userid,u.autologout,s.lastaccess' . ' FROM sessions s,users u' . ' WHERE s.sessionid=' . zbx_dbstr($sessionid) . ' AND s.status=' . ZBX_SESSION_ACTIVE . ' AND s.userid=u.userid' . ' AND (s.lastaccess+u.autologout>' . $time . ' OR u.autologout=0)' . andDbNode('u.userid', $ZBX_LOCALNODEID)));
     if (!$userInfo) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Session terminated, re-login, please.'));
     }
     // don't check permissions on the same second
     if ($time != $userInfo['lastaccess']) {
         if (!check_perm2system($userInfo['userid'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions for system access.'));
         }
         if ($userInfo['autologout'] > 0) {
             DBexecute('DELETE FROM sessions WHERE userid=' . $userInfo['userid'] . ' AND lastaccess<' . (time() - $userInfo['autologout']));
         }
         DBexecute('UPDATE sessions SET lastaccess=' . time() . ' WHERE userid=' . $userInfo['userid'] . ' AND sessionid=' . zbx_dbstr($sessionid));
     }
     $dbAccess = DBfetch(DBselect('SELECT MAX(g.gui_access) AS gui_access' . ' FROM usrgrp g,users_groups ug' . ' WHERE ug.userid=' . $userInfo['userid'] . ' AND g.usrgrpid=ug.usrgrpid'));
     if (!zbx_empty($dbAccess['gui_access'])) {
         $guiAccess = $dbAccess['gui_access'];
     } else {
         $guiAccess = GROUP_GUI_ACCESS_SYSTEM;
     }
     $userData = $this->_getUserData($userInfo['userid']);
     $userData['sessionid'] = $sessionid;
     $userData['gui_access'] = $guiAccess;
     CWebUser::$data = self::$userData = $userData;
     return $userData;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:41,代码来源:CUser.php

示例11: array

$regExpWidget->addPageHeader(_('CONFIGURATION OF REGULAR EXPRESSIONS'), $regExpForm);
if (isset($_REQUEST['form'])) {
    $data = array('form_refresh' => get_request('form_refresh'), 'regexpid' => get_request('regexpid'));
    if (isset($_REQUEST['regexpid']) && !isset($_REQUEST['form_refresh'])) {
        $regExp = DBfetch(DBSelect('SELECT re.name,re.test_string' . ' FROM regexps re' . ' WHERE re.regexpid=' . zbx_dbstr($_REQUEST['regexpid']) . andDbNode('re.regexpid')));
        $data['name'] = $regExp['name'];
        $data['test_string'] = $regExp['test_string'];
        $dbExpressions = DBselect('SELECT e.expressionid,e.expression,e.expression_type,e.exp_delimiter,e.case_sensitive' . ' FROM expressions e' . ' WHERE e.regexpid=' . zbx_dbstr($_REQUEST['regexpid']) . andDbNode('e.expressionid') . ' ORDER BY e.expression_type');
        $data['expressions'] = DBfetchArray($dbExpressions);
    } else {
        $data['name'] = get_request('name', '');
        $data['test_string'] = get_request('test_string', '');
        $data['expressions'] = get_request('expressions', array());
    }
    $regExpForm = new CView('administration.general.regularexpressions.edit', $data);
} else {
    $data = array('displayNodes' => is_array(get_current_nodeid()), 'cnf_wdgt' => &$regExpWidget, 'regexps' => array(), 'regexpids' => array());
    $dbRegExp = DBselect('SELECT re.* FROM regexps re ' . whereDbNode('re.regexpid'));
    while ($regExp = DBfetch($dbRegExp)) {
        $regExp['expressions'] = array();
        $regExp['nodename'] = $data['displayNodes'] ? get_node_name_by_elid($regExp['regexpid'], true) : '';
        $data['regexps'][$regExp['regexpid']] = $regExp;
        $data['regexpids'][$regExp['regexpid']] = $regExp['regexpid'];
    }
    order_result($data['regexps'], 'name');
    $data['db_exps'] = DBfetchArray(DBselect('SELECT e.*' . ' FROM expressions e' . ' WHERE ' . dbConditionInt('e.regexpid', $data['regexpids']) . andDbNode('e.expressionid') . ' ORDER BY e.expression_type'));
    $regExpForm = new CView('administration.general.regularexpressions.list', $data);
}
$regExpWidget->addItem($regExpForm->render());
$regExpWidget->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:adm.regexps.php

示例12: array

        $dbTrigger = API::Trigger()->get(array('triggerids' => $linkTrigger['triggerid'], 'output' => array('description', 'expression'), 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'expandDescription' => true));
        $dbTrigger = reset($dbTrigger);
        $host = reset($dbTrigger['hosts']);
        $link['linktriggers'][$lnum]['desc_exp'] = $host['name'] . NAME_DELIMITER . $dbTrigger['description'];
    }
    order_result($link['linktriggers'], 'desc_exp');
}
unset($link);
// get iconmapping
if ($data['sysmap']['iconmapid']) {
    $iconMap = API::IconMap()->get(array('iconmapids' => $data['sysmap']['iconmapid'], 'output' => array('default_iconid'), 'preservekeys' => true));
    $iconMap = reset($iconMap);
    $data['defaultAutoIconId'] = $iconMap['default_iconid'];
}
// get icon list
$icons = DBselect('SELECT i.imageid,i.name' . ' FROM images i' . ' WHERE i.imagetype=' . IMAGE_TYPE_ICON . andDbNode('i.imageid'));
while ($icon = DBfetch($icons)) {
    $data['iconList'][] = array('imageid' => $icon['imageid'], 'name' => $icon['name']);
    if ($icon['name'] == MAP_DEFAULT_ICON || !isset($data['defaultIconId'])) {
        $data['defaultIconId'] = $icon['imageid'];
        $data['defaultIconName'] = $icon['name'];
    }
}
if ($data['iconList']) {
    CArrayHelper::sort($data['iconList'], array('name'));
    $data['iconList'] = array_values($data['iconList']);
}
// render view
$sysmapView = new CView('configuration.sysmap.constructor', $data);
$sysmapView->render();
$sysmapView->show();
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:sysmap.php

示例13: get

 /**
  * Get scripts data.
  *
  * @param array  $options
  * @param array  $options['itemids']
  * @param array  $options['hostids']	deprecated (very slow)
  * @param array  $options['groupids']
  * @param array  $options['triggerids']
  * @param array  $options['scriptids']
  * @param bool   $options['status']
  * @param bool   $options['editable']
  * @param bool   $options['count']
  * @param string $options['pattern']
  * @param int    $options['limit']
  * @param string $options['order']
  *
  * @return array
  */
 public function get(array $options)
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     $sqlParts = array('select' => array('scripts' => 's.scriptid'), 'from' => array('scripts s'), 'where' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('nodeids' => null, 'groupids' => null, 'hostids' => null, 'scriptids' => null, 'usrgrpids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectGroups' => null, 'selectHosts' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + permission check
     if ($userType != USER_TYPE_SUPER_ADMIN) {
         if (!is_null($options['editable'])) {
             return $result;
         }
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $userGroups) . ')';
         $sqlParts['where'][] = '(s.groupid IS NULL OR EXISTS (' . 'SELECT NULL' . ' FROM rights r' . ' WHERE s.groupid=r.id' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' GROUP BY r.id' . ' HAVING MIN(r.permission)>' . PERM_DENY . '))';
     }
     // groupids
     if (!is_null($options['groupids'])) {
         zbx_value2array($options['groupids']);
         $sqlParts['where'][] = '(s.groupid IS NULL OR ' . dbConditionInt('s.groupid', $options['groupids']) . ')';
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         // only fetch scripts from the same nodes as the hosts
         $hostNodeIds = array();
         foreach ($options['hostids'] as $hostId) {
             $hostNodeIds[] = id2nodeid($hostId);
         }
         $hostNodeIds = array_unique($hostNodeIds);
         // return scripts that are assigned to the hosts' groups or to no group
         $hostGroups = API::HostGroup()->get(array('output' => array('groupid'), 'hostids' => $options['hostids'], 'nodeids' => $hostNodeIds));
         $hostGroupIds = zbx_objectValues($hostGroups, 'groupid');
         $sqlParts['where'][] = '(' . dbConditionInt('s.groupid', $hostGroupIds) . ' OR ' . '(s.groupid IS NULL' . andDbNode('s.scriptid', $hostNodeIds) . '))';
     }
     // usrgrpids
     if (!is_null($options['usrgrpids'])) {
         zbx_value2array($options['usrgrpids']);
         $sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $options['usrgrpids']) . ')';
     }
     // scriptids
     if (!is_null($options['scriptids'])) {
         zbx_value2array($options['scriptids']);
         $sqlParts['where'][] = dbConditionInt('s.scriptid', $options['scriptids']);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('scripts s', $options, $sqlParts);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('scripts s', $options, $sqlParts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQueryNodeOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($script = DBfetch($res)) {
         if ($options['countOutput']) {
             $result = $script['rowscount'];
         } else {
             $result[$script['scriptid']] = $script;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, array('groupid', 'host_access'), $options['output']);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:100,代码来源:CScript.php

示例14: get_userid_by_usrgrpid

/**
 * Get users ids by groups ids.
 *
 * @param array $userGroupIds
 *
 * @return array
 */
function get_userid_by_usrgrpid($userGroupIds)
{
    zbx_value2array($userGroupIds);
    $userIds = array();
    $dbUsers = DBselect('SELECT DISTINCT u.userid' . ' FROM users u,users_groups ug' . ' WHERE u.userid=ug.userid' . ' AND ' . dbConditionInt('ug.usrgrpid', $userGroupIds) . andDbNode('ug.usrgrpid', false));
    while ($user = DBFetch($dbUsers)) {
        $userIds[$user['userid']] = $user['userid'];
    }
    return $userIds;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:17,代码来源:users.inc.php

示例15: CComboBox

 // filter template
 $templateComboBox = new CComboBox('filter_hostid', $_REQUEST['filter_hostid'], 'javascript: submit();');
 $templateComboBox->addItem(0, _('all'));
 $templates = API::Template()->get(array('output' => array('templateid', 'name'), 'groupids' => empty($_REQUEST['filter_groupid']) ? null : $_REQUEST['filter_groupid'], 'with_triggers' => true));
 order_result($templates, 'name');
 $templateIds = array();
 foreach ($templates as $template) {
     $templateIds[$template['templateid']] = $template['templateid'];
     $templateComboBox->addItem($template['templateid'], get_node_name_by_elid($template['templateid'], null, NAME_DELIMITER) . $template['name']);
 }
 $filterForm->addRow(_('Template'), $templateComboBox);
 // filter trigger
 $triggerComboBox = new CComboBox('tpl_triggerid', get_request('tpl_triggerid', 0), 'javascript: submit()');
 $triggerComboBox->addItem(0, _('all'));
 $sqlCondition = empty($_REQUEST['filter_hostid']) ? ' AND ' . dbConditionInt('h.hostid', $templateIds) : ' AND h.hostid=' . zbx_dbstr($_REQUEST['filter_hostid']);
 $sql = 'SELECT DISTINCT t.triggerid,t.description,h.name' . ' FROM triggers t,hosts h,items i,functions f' . ' WHERE f.itemid=i.itemid' . ' AND h.hostid=i.hostid' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid' . ' AND h.status=' . HOST_STATUS_TEMPLATE . ' AND i.status=' . ITEM_STATUS_ACTIVE . $sqlCondition . andDbNode('t.triggerid') . ' ORDER BY t.description';
 $triggers = DBfetchArrayAssoc(DBselect($sql), 'triggerid');
 foreach ($triggers as $trigger) {
     $templateName = empty($_REQUEST['filter_hostid']) ? $trigger['name'] . NAME_DELIMITER : '';
     $triggerComboBox->addItem($trigger['triggerid'], get_node_name_by_elid($trigger['triggerid'], null, NAME_DELIMITER) . $templateName . $trigger['description']);
 }
 if (isset($_REQUEST['tpl_triggerid']) && !isset($triggers[$_REQUEST['tpl_triggerid']])) {
     unset($triggerOptions['filter']['templateid']);
 }
 $filterForm->addRow(_('Template trigger'), $triggerComboBox);
 // filter host group
 $hostGroupsComboBox = new CComboBox('hostgroupid', get_request('hostgroupid', 0), 'javascript: submit()');
 $hostGroupsComboBox->addItem(0, _('all'));
 $hostGroups = API::HostGroup()->get(array('output' => array('groupid', 'name'), 'hostids' => $triggerOptions['hostids'], 'monitored_hosts' => true, 'preservekeys' => true));
 order_result($hostGroups, 'name');
 foreach ($hostGroups as $hostGroup) {
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:report2.php


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