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


PHP generate_query_values函数代码示例

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


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

示例1: generate_sla_query

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package        observium
 * @subpackage     web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function generate_sla_query($vars)
{
    $sql = 'SELECT * FROM `slas` ';
    $sql .= ' LEFT JOIN `slas-state` USING (`sla_id`)';
    $sql .= ' WHERE `deleted` = 0';
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'slas.sla_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'slas.device_id');
                break;
            case "id":
                $sql .= generate_query_values($value, 'slas.sla_id');
                break;
            case "owner":
                $sql .= generate_query_values($value, 'slas.sla_owner');
                break;
            case "rtt_type":
                $sql .= generate_query_values($value, 'slas.rtt_type');
                break;
            case "event":
                $sql .= generate_query_values($value, 'rtt_event');
                break;
        }
    }
    $sql .= $GLOBALS['cache']['where']['devices_permitted'];
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:44,代码来源:sla.inc.php

示例2: generate_vm_query

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package        observium
 * @subpackage     web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function generate_vm_query($vars)
{
    $sql = 'SELECT * FROM `vminfo` WHERE 1 ';
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'vm_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'device_id');
                break;
            case "os":
                $sql .= generate_query_values($value, 'vm_guestos');
                break;
            case "state":
                $sql .= generate_query_values($value, 'vm_state');
                break;
            case "memory":
                $sql .= generate_query_values($value, 'vm_memory');
                break;
            case "cpu":
                $sql .= generate_query_values($value, 'vm_cpucount');
                break;
        }
    }
    $sql .= $GLOBALS['cache']['where']['devices_permitted'];
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:42,代码来源:virtualmachine.inc.php

示例3: generate_status_query

function generate_status_query($vars)
{
    $sql = "SELECT * FROM `status`";
    $sql .= " LEFT JOIN `status-state` USING(`status_id`)";
    $sql .= " WHERE 1";
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'status.status_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'status.device_id');
                break;
            case "id":
                $sql .= generate_query_values($value, 'status.status_id');
                break;
            case "class":
                $sql .= generate_query_values($value, 'status.entPhysicalClass');
                break;
            case "event":
                $sql .= generate_query_values($value, 'status_event');
                break;
        }
    }
    $sql .= $GLOBALS['cache']['where']['devices_permitted'];
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:status.inc.php

示例4: build_devices_where_array

/**
 * Build devices where array
 *
 * This function returns an array of "WHERE" statements from a $vars array.
 * The returned array can be implode()d and used on the devices table.
 * Originally extracted from the /devices/ page
 *
 * @param array $vars
 * @return array
 */
function build_devices_where_array($vars)
{
    $where_array = array();
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'group':
                    $values = get_group_entities($value);
                    $where_array[$var] = generate_query_values($values, 'device_id');
                    break;
                case 'hostname':
                case 'sysname':
                    $where_array[$var] = generate_query_values($value, $var, '%LIKE%');
                    break;
                case 'location_text':
                    $where_array[$var] = generate_query_values($value, 'devices.location', '%LIKE%');
                    break;
                case 'location':
                    $where_array[$var] = generate_query_values($value, 'devices.location');
                    break;
                case 'location_lat':
                case 'location_lon':
                case 'location_country':
                case 'location_state':
                case 'location_county':
                case 'location_city':
                    if ($GLOBALS['config']['geocoding']['enable']) {
                        $where_array[$var] = generate_query_values($value, 'devices_locations.' . $var);
                    }
                    break;
                case 'os':
                case 'version':
                case 'hardware':
                case 'features':
                case 'type':
                case 'status':
                case 'ignore':
                case 'disabled':
                    $where_array[$var] = generate_query_values($value, $var);
                    break;
                case 'graph':
                    $where_array[$var] = generate_query_values(devices_with_graph($value), "devices.device_id");
            }
        }
    }
    return $where_array;
}
开发者ID:Natolumin,项目名称:observium,代码行数:57,代码来源:device.inc.php

示例5: generate_p2pradio_query

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package        observium
 * @subpackage     functions
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function generate_p2pradio_query($vars)
{
    $sql = "SELECT * FROM `p2p_radios`";
    $sql .= ' WHERE 1' . generate_query_permitted(array('device'));
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'radio_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'device_id');
                break;
        }
    }
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:30,代码来源:p2pradio.inc.php

示例6: generate_processor_query

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function generate_processor_query($vars)
{
    $sql = "SELECT * FROM `processors`";
    $sql .= " LEFT JOIN `processors-state` USING(`processor_id`)";
    $sql .= ' WHERE 1' . generate_query_permitted(array('device'));
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'processor_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'device_id');
                break;
        }
    }
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:processor.inc.php

示例7: build_mempool_query

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package        observium
 * @subpackage     web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function build_mempool_query($vars)
{
    global $config, $cache;
    $sql = 'SELECT *, `mempools`.`mempool_id` AS `mempool_id` FROM `mempools`';
    $sql .= ' LEFT JOIN `mempools-state` USING(`mempool_id`)';
    $sql .= ' WHERE 1' . generate_query_permitted(array('device'));
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'mempools.mempool_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'mempools.device_id');
                break;
        }
    }
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:32,代码来源:mempool.inc.php

示例8: build_printersupplies_query

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package        observium
 * @subpackage     webui
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function build_printersupplies_query($vars)
{
    $sql = 'SELECT * FROM `printersupplies`';
    $sql .= ' WHERE 1' . generate_query_permitted(array('device'));
    // Build query
    foreach ($vars as $var => $value) {
        switch ($var) {
            case "group":
            case "group_id":
                $values = get_group_entities($value);
                $sql .= generate_query_values($values, 'printersupplies.supply_id');
                break;
            case "device":
            case "device_id":
                $sql .= generate_query_values($value, 'printersupplies.device_id');
                break;
            case "supply":
                $sql .= generate_query_values($value, 'printersupplies.supply_type');
                break;
        }
    }
    return $sql;
}
开发者ID:Natolumin,项目名称:observium,代码行数:33,代码来源:printersupply.inc.php

示例9: get_bgp_array

/**
 * Params:
 *
 * pagination, pageno, pagesize
 * device, type, adminstatus, state
 */
function get_bgp_array($vars)
{
    $array = array();
    // With pagination? (display page numbers in header)
    $array['pagination'] = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $array['pageno'] = $vars['pageno'];
    $array['pagesize'] = $vars['pagesize'];
    $start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
    $pagesize = $array['pagesize'];
    // Require cached IDs from html/includes/cache-data.inc.php
    $cache_bgp =& $GLOBALS['cache']['bgp'];
    // Begin query generate
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'B.device_id');
                    break;
                case 'peer':
                case 'peer_id':
                    $where .= generate_query_values($value, 'B.peer_device_id');
                    break;
                case 'local_ip':
                    $where .= generate_query_values($value, 'B.bgpPeerLocalAddr');
                    break;
                case 'peer_ip':
                    $where .= generate_query_values($value, 'B.bgpPeerRemoteAddr');
                    break;
                case 'local_as':
                    $where .= generate_query_values($value, 'D.bgpLocalAs');
                    break;
                case 'peer_as':
                    $where .= generate_query_values($value, 'B.bgpPeerRemoteAs');
                    break;
                case 'type':
                    if ($value == 'external' || $value == 'ebgp') {
                        $where .= generate_query_values($cache_bgp['external'], 'B.bgpPeer_id');
                    } else {
                        if ($value == 'internal' || $value == 'ibgp') {
                            $where .= generate_query_values($cache_bgp['internal'], 'B.bgpPeer_id');
                        }
                    }
                    break;
                case 'adminstatus':
                    if ($value == 'stop') {
                        $where .= generate_query_values($cache_bgp['start'], 'B.bgpPeer_id', '!=');
                        // NOT IN
                    } else {
                        if ($value == 'start') {
                            $where .= generate_query_values($cache_bgp['start'], 'B.bgpPeer_id');
                        }
                    }
                    break;
                case 'state':
                    if ($value == 'down') {
                        $where .= generate_query_values($cache_bgp['up'], 'B.bgpPeer_id', '!=');
                        // NOT IN
                    } else {
                        if ($value == 'up') {
                            $where .= generate_query_values($cache_bgp['up'], 'B.bgpPeer_id');
                        }
                    }
                    break;
            }
        }
    }
    // Show peers only for permitted devices
    $query_permitted = generate_query_values($cache_bgp['permitted'], 'B.bgpPeer_id');
    $query = 'FROM `bgpPeers` AS B';
    $query_count = 'SELECT COUNT(*) ' . $query . $where . $query_permitted;
    // Use only bgpPeer_id and device_id in query!
    $query .= ' LEFT JOIN `bgpPeers-state` AS S ON B.`bgpPeer_id` = S.`bgpPeer_id`';
    $query .= ' LEFT JOIN `devices` AS D ON B.`device_id` = D.`device_id`';
    $query .= $where . $query_permitted;
    $query = 'SELECT D.`hostname`, D.`bgpLocalAs`, B.*, S.* ' . $query;
    $query .= ' ORDER BY D.`hostname`, B.`bgpPeerRemoteAs`, B.`bgpPeerRemoteAddr`';
    $query .= " LIMIT {$start},{$pagesize}";
    $peer_devices = array();
    // Query BGP
    foreach (dbFetchRows($query, $param) as $entry) {
        humanize_bgp($entry);
        // Collect peer devices for AFI/SAFI
        $peer_devices[$entry['device_id']] = 1;
        $array['entries'][] = $entry;
    }
    // Query AFI/SAFI
    if (count($peer_devices)) {
        $query_afi = 'SELECT * FROM `bgpPeers_cbgp` WHERE 1' . generate_query_values(array_keys($peer_devices), 'device_id');
        foreach (dbFetchRows($query_afi) as $entry) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:routing.inc.php

示例10: print_syslogs

/**
 * Display syslog messages.
 *
 * Display pages with device syslog messages.
 * Examples:
 * print_syslogs() - display last 10 syslog messages from all devices
 * print_syslogs(array('pagesize' => 99)) - display last 99 syslog messages from all device
 * print_syslogs(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 syslog messages from page 3 with pagination header
 * print_syslogs(array('pagesize' => 10, 'device' = 4)) - display last 10 syslog messages for device_id 4
 * print_syslogs(array('short' => TRUE)) - show small block with last syslog messages
 *
 * @param array $vars
 * @return none
 *
 */
function print_syslogs($vars)
{
    // Short events? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $pageno = $vars['pageno'];
    $pagesize = $vars['pagesize'];
    $start = $pagesize * $pageno - $pagesize;
    $priorities = $GLOBALS['config']['syslog']['priorities'];
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            $cond = array();
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'priority':
                    if (!is_array($value)) {
                        $value = explode(',', $value);
                    }
                    foreach ($value as $k => $v) {
                        // Rewrite priority strings to numbers
                        $value[$k] = priority_string_to_numeric($v);
                    }
                    // Do not break here, it's true!
                // Do not break here, it's true!
                case 'program':
                    $where .= generate_query_values($value, $var);
                    break;
                case 'message':
                    $where .= generate_query_values($value, 'msg', '%LIKE%');
                    break;
                case 'timestamp_from':
                    $where .= ' AND `timestamp` > ?';
                    $param[] = $value;
                    break;
                case 'timestamp_to':
                    $where .= ' AND `timestamp` < ?';
                    $param[] = $value;
                    break;
            }
        }
    }
    // Show events only for permitted devices
    $query_permitted = generate_query_permitted();
    $query = 'FROM `syslog` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `seq` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query syslog messages
    $entries = dbFetchRows($query, $param);
    // Query syslog count
    if ($pagination && !$short) {
        $count = dbFetchCell($query_count, $param);
    } else {
        $count = count($entries);
    }
    if (!$count) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No syslog entries found!</h4>
Check that the syslog daemon and Observium configuration options are set correctly, that your devices are configured to send syslog to Observium and that there are no firewalls blocking the messages.

See <a href="' . OBSERVIUM_URL . '/wiki/Category:Documentation" target="_blank">documentation</a> and <a href="' . OBSERVIUM_URL . '/wiki/Configuration_Options#Syslog_Settings" target="_blank">configuration options</a> for more information.');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'priority' => TRUE);
        // For now (temporarily) priority always displayed
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'syslog') {
            $list['device'] = TRUE;
        }
        if ($short || !isset($vars['priority']) || empty($vars['priority'])) {
            $list['priority'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">' . PHP_EOL;
        if (!$short) {
            $string .= '  <thead>' . PHP_EOL;
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:syslogs.inc.php

示例11: dbFetchColumn

$neighbours_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `neighbours` WHERE 1' . $cache['where']['ports_permitted']);
$where = ' WHERE 1 ';
$where .= generate_query_values($neighbours_ports, 'port_id');
//r($where);
$form_items = array();
foreach (dbFetchColumn('SELECT DISTINCT `device_id` FROM `ports`' . $where) as $device_id) {
    if ($cache['devices']['id'][$device_id]['hostname']) {
        $form_items['devices'][$device_id] = $cache['devices']['id'][$device_id]['hostname'];
    }
}
natcasesort($form_items['devices']);
// If device IDs passed, limit ports to specified devices
if ($vars['device']) {
    $neighbours_ports = dbFetchColumn('SELECT DISTINCT `port_id` FROM `ports`' . $where . generate_query_values($vars['device'], 'device_id'));
    $where = ' WHERE 1 ';
    $where .= generate_query_values($neighbours_ports, 'port_id');
    //r($where);
}
$form_params = array('platforms' => 'remote_platform', 'versions' => 'remote_version', 'protocols' => 'protocol');
foreach ($form_params as $param => $column) {
    foreach (dbFetchColumn('SELECT DISTINCT `' . $column . '` FROM `neighbours`' . $where) as $entry) {
        if (!empty($entry)) {
            $form_items[$param][$entry] = $param == 'protocols' ? nicecase($entry) : escape_html($entry);
        }
    }
}
$form = array('type' => 'rows', 'space' => '5px', 'submit_by_key' => TRUE, 'url' => generate_url($vars));
$form['row'][0]['device'] = array('type' => 'multiselect', 'name' => 'Device', 'width' => '100%', 'value' => $vars['device'], 'values' => $form_items['devices']);
$form['row'][0]['protocol'] = array('type' => 'multiselect', 'name' => 'Protocol', 'width' => '100%', 'value' => $vars['protocol'], 'values' => $form_items['protocols']);
$form['row'][0]['platform'] = array('type' => 'multiselect', 'name' => 'Platform', 'width' => '100%', 'value' => $vars['platform'], 'values' => $form_items['platforms']);
$form['row'][0]['version'] = array('type' => 'multiselect', 'name' => 'Version', 'width' => '100%', 'value' => $vars['version'], 'values' => $form_items['versions']);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:neighbours.inc.php

示例12: unset

//  dbFetchCell('TRUNCATE TABLE `eventlog`');
//  print_message('Event log truncated');
//}
unset($search, $devices_array, $types);
$where = ' WHERE 1 ' . generate_query_permitted();
//Device field
foreach ($cache['devices']['hostname'] as $hostname => $device_id) {
    if ($cache['devices']['id'][$device_id]['disabled'] && !$config['web_show_disabled']) {
        continue;
    }
    $devices_array[$device_id] = $hostname;
}
$search[] = array('type' => 'multiselect', 'name' => '设备', 'id' => 'device_id', 'width' => '125px', 'value' => $vars['device_id'], 'values' => $devices_array);
// Add device_id limit for other fields
if (isset($vars['device_id'])) {
    $where .= generate_query_values($vars['device_id'], 'device_id');
}
//Message field
$search[] = array('type' => 'text', 'name' => '信息', 'id' => 'message', 'width' => '150px', 'placeholder' => 'Message', 'value' => $vars['message']);
//Severity field
foreach (dbFetchColumn('SELECT DISTINCT `severity` FROM `eventlog`' . $where) as $severity) {
    $severities[$severity] = ucfirst($config['syslog']['priorities'][$severity]['name']);
}
krsort($severities);
$search[] = array('type' => 'multiselect', 'name' => '严重程度', 'id' => 'severity', 'width' => '110px', 'subtext' => TRUE, 'value' => $vars['severity'], 'values' => $severities);
//Types field
$types['device'] = '设备';
foreach (dbFetchColumn('SELECT DISTINCT `entity_type` FROM `eventlog` IGNORE INDEX (`type`)' . $where) as $type) {
    //$type = $data['type'];
    $types[$type] = ucfirst($type);
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:eventlog.inc.php

示例13: print_mac_addresses

/**
 * Display Interface MACs addresses.
 *
 * Display pages with MAC addresses from device Interfaces.
 *
 * @param array $vars
 * @return none
 *
 */
function print_mac_addresses($vars)
{
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $pageno = $vars['pageno'];
    $pagesize = $vars['pagesize'];
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'interface':
                    $where .= ' AND `ifDescr` LIKE ?';
                    $param[] = $value;
                    break;
                case 'address':
                    $where .= ' AND `ifPhysAddress` LIKE ?';
                    # FIXME hm? mres in a dbFacile parameter?
                    $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    break;
            }
        }
    }
    $where .= ' AND `ifPhysAddress` IS NOT NULL';
    //Exclude empty MACs
    // Show MACs only for permitted ports
    $query_permitted = generate_query_permitted(array('port'));
    $query = 'FROM `ports` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `ifPhysAddress`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query addresses
    $entries = dbFetchRows($query, $param);
    // Query address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        if (port_permitted($entry['port_id'])) {
            humanize_port($entry);
            $string .= '  <tr>' . PHP_EOL;
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $string .= '    <td class="entity" style="white-space: nowrap;">' . generate_device_link($dev) . '</td>' . PHP_EOL;
            }
            if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
                $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
            }
            $string .= '    <td class="entity">' . generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL;
            $string .= '    <td style="width: 160px;">' . $entry['human_mac'] . '</td>' . PHP_EOL;
            $string .= '    <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print MAC addresses
    echo $string;
}
开发者ID:skive,项目名称:observium,代码行数:99,代码来源:mac_addresses.inc.php

示例14: array

            $params = array('port_id' => $port_id, 'mac_address' => $clean_mac, 'ip_address' => $ip, 'ip_version' => $ip_version);
            dbInsert($params, 'ip_mac');
            print_debug("Added MAC address " . format_mac($clean_mac) . " for {$ip}");
            //log_event("MAC added: $ip : " . format_mac($clean_mac), $device, "port", $port_id);
            echo "+";
        }
    }
}
// Remove expired ARP/NDP entries
$remove_mac_ids = array();
foreach ($cache_arp as $entry) {
    $entry_mac_id = $entry['mac_id'];
    $entry_mac = $entry['mac_address'];
    $entry_ip = $entry['ip_address'];
    $entry_version = $entry['ip_version'];
    $entry_if = $entry['ifIndex'];
    $entry_port_id = $interface[$entry_if];
    if (!isset($mac_table[$entry_if][$entry_version][$entry_ip])) {
        $remove_mac_ids[] = $entry_mac_id;
        //dbDelete('ip_mac', 'mac_id = ?', array($entry_mac_id));
        print_debug("Removed MAC address " . format_mac($entry_mac) . " for {$entry_ip}");
        //log_event("MAC removed: $entry_ip : " . format_mac($entry_mac), $device, "port", $entry['port_id']);
        echo "-";
    }
}
if (count($remove_mac_ids)) {
    dbDelete('ip_mac', '1' . generate_query_values($remove_mac_ids, 'mac_id'));
}
echo PHP_EOL;
unset($interface, $remove_mac_ids);
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:arp-table.inc.php

示例15: generate_query_permitted

 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$graph_type = "mempool_usage";
$sql = 'SELECT *, `mempools`.`mempool_id` AS `mempool_id` FROM `mempools`';
$sql .= ' LEFT JOIN `mempools-state` ON `mempools`.`mempool_id` = `mempools-state`.`mempool_id`';
$sql .= ' WHERE 1' . generate_query_permitted(array('device'));
// Groups
if (isset($vars['group'])) {
    $values = get_group_entities($vars['group']);
    $sql .= generate_query_values($values, 'mempools.mempool_id');
}
$mempools = array();
foreach (dbFetchRows($sql) as $mempool) {
    if (isset($cache['devices']['id'][$mempool['device_id']])) {
        $mempool['hostname'] = $cache['devices']['id'][$mempool['device_id']]['hostname'];
        $mempool['html_row_class'] = $cache['devices']['id'][$mempool['device_id']]['html_row_class'];
        $mempools[] = $mempool;
    }
}
$mempools = array_sort_by($mempools, 'hostname', SORT_ASC, SORT_STRING, 'mempool_descr', SORT_ASC, SORT_STRING);
$mempools_count = count($mempools);
// Pagination
$pagination_html = pagination($vars, $mempools_count);
echo $pagination_html;
if ($vars['pageno']) {
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:mempool.inc.php


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