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


PHP generate_query_permitted函数代码示例

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


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

示例1: build_alert_table_query

function build_alert_table_query($vars)
{
    $args = array();
    $where = ' WHERE 1 ';
    // Loop through the vars building a sql query from relevant values
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                // Search by device_id if we have a device or device_id
                case 'device_id':
                    $where .= ' AND `device_id` = ?';
                    $param[] = $value;
                    break;
                case 'entity_type':
                    if ($value != 'all') {
                        $where .= ' AND `entity_type` = ?';
                        $param[] = $value;
                    }
                    break;
                case 'entity_id':
                    $where .= ' AND `entity_id` = ?';
                    $param[] = $value;
                    break;
                case 'alert_test_id':
                    $where .= ' AND `alert_test_id` = ?';
                    $param[] = $value;
                    break;
                case 'status':
                    if ($value == 'failed') {
                        $where .= " AND `alert_status` IN (0,2,3)";
                    }
                    break;
            }
        }
    }
    // Permissions query
    $query_permitted = generate_query_permitted(array('device'), array('hide_ignored' => TRUE));
    // Base query
    $query = 'FROM `alert_table` ';
    $query .= 'LEFT JOIN `alert_table-state` USING(`alert_table_id`) ';
    $query .= $where . $query_permitted;
    // Build the query to get a count of entries
    $query_count = 'SELECT COUNT(`alert_table_id`) ' . $query;
    // Build the query to get the list of entries
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `device_id`, `alert_test_id`, `entity_type`, `entity_id` DESC ';
    if (isset($vars['pagination']) && $vars['pagination']) {
        pagination($vars, 0, TRUE);
        // Get default pagesize/pageno
        $vars['start'] = $vars['pagesize'] * $vars['pageno'] - $vars['pagesize'];
        $query .= 'LIMIT ' . $vars['start'] . ',' . $vars['pagesize'];
    }
    return array($query, $param, $query_count);
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:54,代码来源:alert.inc.php

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: print_inventory

/**
 * Display Devices Inventory.
 *
 * @param array $vars
 * @return none
 *
 */
function print_inventory($vars)
{
    // On "Inventory" device tab display hierarchical list
    if ($vars['page'] == 'device' && is_numeric($vars['device']) && device_permitted($vars['device'])) {
        echo '<table class="table table-striped table-bordered table-condensed table-rounded"><tr><td>';
        echo '<div class="btn-group pull-right" style="margin-top:5px; margin-right: 5px;">
      <button class="btn btn-small" onClick="expandTree(\'enttree\');return false;"><i class="icon-plus muted small"></i> Expand</button>
      <button class="btn btn-small" onClick="collapseTree(\'enttree\');return false;"><i class="icon-minus muted small"></i> Collapse</button>
    </div>';
        echo '<div style="clear: left; margin: 5px;"><ul class="mktree" id="enttree" style="margin-left: -10px;">';
        $level = 0;
        $ent['entPhysicalIndex'] = 0;
        print_ent_physical($ent['entPhysicalIndex'], $level, "liOpen");
        echo '</ul></div>';
        echo '</td></tr></table>';
        return TRUE;
    }
    // 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, 'E.device_id');
                    break;
                case 'parts':
                    $where .= generate_query_values($value, 'E.entPhysicalModelName', 'LIKE');
                    break;
                case 'serial':
                    $where .= ' AND E.`entPhysicalSerialNum` LIKE ?';
                    $param[] = '%' . $value . '%';
                    break;
                case 'description':
                    $where .= ' AND E.`entPhysicalDescr` LIKE ?';
                    $param[] = '%' . $value . '%';
                    break;
            }
        }
    }
    // Show inventory only for permitted devices
    $query_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
    $query = 'FROM `entPhysical` AS E ';
    $query .= 'LEFT JOIN `devices` AS D ON D.`device_id` = E.`device_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY D.`hostname`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query inventories
    $entries = dbFetchRows($query, $param);
    // Query inventory count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'inventory') {
        $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>Name</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '      <th>Part #</th>' . PHP_EOL;
        $string .= '      <th>Serial #</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        $string .= '  <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '    <td class="entity" style="white-space: nowrap">' . generate_device_link($entry, NULL, array('page' => 'device', 'tab' => 'entphysical')) . '</td>' . PHP_EOL;
        }
        if ($entry['ifIndex']) {
            $interface = get_port_by_ifIndex($entry['device_id'], $entry['ifIndex']);
            $entry['entPhysicalName'] = generate_port_link($interface);
        } elseif ($entry['entPhysicalClass'] == "sensor") {
            $sensor = dbFetchRow("SELECT * FROM `sensors` AS S\n                            LEFT JOIN `sensors-state` AS ST ON S.`sensor_id` = ST.`sensor_id`\n                            WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)", array($entry['device_id'], $entry['entPhysicalIndex'], $entry['entPhysicalIndex']));
            //$ent_text .= ' ('.$sensor['sensor_value'] .' '. $sensor['sensor_class'].')';
            $entry['entPhysicalName'] = generate_entity_link('sensor', $sensor);
//.........这里部分代码省略.........
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:inventory.inc.php

示例7: generate_query_permitted

    $where = "WHERE 1";
}
// FIXME this shit probably needs tidied up.
if (isset($vars['format']) && preg_match("/^[a-z]*\$/", $vars['format'])) {
    #  $map = 'digraph G { bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=LR
    $map = 'digraph G { bgcolor=transparent; splines=true; overlap=scale; rankdir=LR
     node [ fontname="helvetica", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false];
     edge [ bgcolor=white, fontname="helvetica", fontstyle=bold, arrowhead=dot, arrowtail=dot];
     graph [bgcolor=transparent;];

';
    if (!$_SESSION['authenticated']) {
        $map .= "\"没有经过身份验证\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n";
    } else {
        $loc_count = 1;
        $cache['where']['devices_permitted'] = generate_query_permitted(array('device'), array('device_table' => 'D'));
        foreach (dbFetch("SELECT D.*, COUNT(L.local_port_id) FROM devices AS D LEFT JOIN (ports AS I, links AS L) ON (D.device_id = I.device_id AND I.port_id = L.local_port_id) " . $where . $cache['where']['devices_permitted'] . " GROUP BY D.hostname ORDER BY COUNT(L.local_port_id) DESC") as $device) {
            if ($device) {
                $links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", array($device['device_id']));
                if (count($links)) {
                    $ranktype = substr($device['hostname'], 0, 2);
                    $ranktype2 = substr($device['hostname'], 0, 3);
                    if (!strncmp($device['hostname'], "c", 1) && !strstr($device['hostname'], "kalooga")) {
                        $ranks[$ranktype][] = $device['hostname'];
                    } else {
                        $ranks[$ranktype2][] = $device['hostname'];
                    }
                    if ($anon) {
                        $device['hostname'] = md5($device['hostname']);
                    }
                    if (!isset($locations[$device['location']])) {
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:map.php

示例8: unset

 */
// Set Defaults here
if (!isset($vars['format'])) {
    $vars['format'] = "detail";
}
if (!$config['web_show_disabled'] && !isset($vars['disabled'])) {
    $vars['disabled'] = '0';
}
if ($vars['format'] != 'graphs') {
    // reset all from/to vars if not use graphs
    unset($vars['from'], $vars['to'], $vars['timestamp_from'], $vars['timestamp_to'], $vars['graph']);
}
/// FIXME - new style (print_search_simple) of searching here
$where = ' WHERE 1 ';
$where_array = array();
$query_permitted = generate_query_permitted(array('device'), array('device_table' => 'devices'));
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, 'location', '%LIKE%');
                break;
            case 'os':
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:devices.inc.php

示例9: array

 * @subpackage webui
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if ($bg == "#ffffff") {
    $bg = "#e5e5e5";
} else {
    $bg = "#ffffff";
}
if (!is_array($vars['type'])) {
    $vars['type'] = array($vars['type']);
}
$where = 'WHERE 1';
$where .= generate_query_values($vars['type'], 'port_descr_type', 'LIKE');
$where .= generate_query_permitted(array('port'));
$ports = dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D {$where} AND I.`device_id` = D.`device_id` ORDER BY I.`ifAlias`");
$if_list = array();
foreach ($ports as $port) {
    $if_list[] = $port['port_id'];
}
$if_list = implode(',', $if_list);
for ($i = 0; $i < count($vars['type']); $i++) {
    $vars['type'][$i] = nicecase($vars['type'][$i]);
}
$types = implode(' + ', $vars['type']);
echo '<h4>Total Graph for ports of type : ' . $types . '</h4>';
if ($if_list) {
    $graph_type = "multiport_bits_separate";
    $port['port_id'] = $if_list;
    include "includes/print-interface-graphs.inc.php";
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:iftype.inc.php

示例10: print_dot1xtable

/**
 * Display dot1x sessions
 *
 * @param array $vars
 * @return none
 *
 */
function print_dot1xtable($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 'address':
                    if (isset($vars['searchby']) && $vars['searchby'] == 'ip') {
                        $value = trim($value);
                        $where .= generate_query_values($value, 'ipv4_addr', '%LIKE%');
                    } else {
                        if (isset($vars['searchby']) && $vars['searchby'] == 'mac') {
                            $value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
                            $where .= generate_query_values($value, 'M.mac_addr', '%LIKE%');
                        } else {
                            $value = trim($value);
                            $where .= generate_query_values($value, 'username', '%LIKE%');
                        }
                    }
                    break;
            }
        }
    }
    // Check permissions
    $query_permitted = generate_query_permitted(array('device'), array('device_table' => 'M'));
    $query = 'FROM `wifi_sessions` AS M ';
    $query .= 'LEFT JOIN `wifi_radios` AS I ON I.`wifi_radio_id` = M.`radio_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`wifi_session_id`) ' . $query;
    $query = 'SELECT *, M.`mac_addr` AS `session_mac` ' . $query;
    $query .= ' ORDER BY M.`timestamp` DESC';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query wireless  sessions table
    $entries = dbFetchRows($query, $param);
    // Query wireless  sessions table count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $aps_db = dbFetchRows("SELECT `wifi_accesspoint_id`, `name`, `ap_number`  FROM `wifi_accesspoints`");
    foreach ($aps_db as $ap_db) {
        $aps_sorted_db[$ap_db['wifi_accesspoint_id']] = $ap_db;
    }
    $list = array('device' => FALSE, 'port' => FALSE);
    // A radio is like a port
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] == 'search') {
        $list['port'] = TRUE;
    }
    $string = generate_box_open();
    $string .= '<table class="table  table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        $string .= '      <th>IP Address</th>' . PHP_EOL;
        $string .= '      <th>Username</th>' . PHP_EOL;
        $string .= '      <th>SSID/VLAN</th>' . PHP_EOL;
        $string .= '      <th>Last Seen</th>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        if ($list['port']) {
            $string .= '      <th>Interface/AP</th>' . PHP_EOL;
        }
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        $ap_id = $entry['accesspoint_id'];
        $interface = $aps_sorted_db[$ap_id]['name'];
        $string .= '  <tr>' . PHP_EOL;
        $string .= '    <td style="width: 140px;">' . generate_popup_link('mac', format_mac($entry['session_mac'])) . '</td>' . PHP_EOL;
        $string .= '    <td style="width: 140px;">' . generate_popup_link('ip', $entry['ipv4_addr']) . '</td>' . PHP_EOL;
        $string .= '    <td style="white-space: nowrap;">' . $entry['username'] . '</td>' . PHP_EOL;
        $string .= '    <td style="width: 140px;">' . $entry['ssid'] . '</td>' . PHP_EOL;
        $string .= '    <td style="white-space: nowrap;">' . $entry['timestamp'] . '</td>' . PHP_EOL;
        if ($list['device']) {
            $dev = device_by_id_cache($entry['device_id']);
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:dot1xtable.inc.php

示例11: print_arptable

/**
 * Display ARP/NDP table addresses.
 *
 * Display pages with ARP/NDP tables addresses from devices.
 *
 * @param array $vars
 * @return none
 *
 */
function print_arptable($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 'port':
                case 'port_id':
                    $where .= generate_query_values($value, 'I.port_id');
                    break;
                case 'ip_version':
                    $where .= generate_query_values($value, 'ip_version');
                    break;
                case 'address':
                    if (isset($vars['searchby']) && $vars['searchby'] == 'ip') {
                        $value = trim($value);
                        if (strpos($value, ':') !== FALSE) {
                            if (Net_IPv6::checkIPv6($value)) {
                                $value = Net_IPv6::uncompress($value, TRUE);
                            } else {
                                // FIXME. Need another conversion ("2001:b08:b08" -> "2001:0b08:0b08") -- mike
                            }
                        }
                        $where .= generate_query_values($value, 'ip_address', '%LIKE%');
                    } else {
                        // MAC Addresses
                        $value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
                        $where .= generate_query_values($value, 'mac_address', '%LIKE%');
                    }
                    break;
            }
        }
    }
    if (isset($vars['sort'])) {
        switch ($vars['sort']) {
            case "port":
                $sort = " ORDER BY `I`.`port_label`";
                break;
            case "ip_version":
                $sort = " ORDER BY `ip_version`";
                break;
            case "ip":
            case "address":
                $sort = " ORDER BY `ip_address`";
                break;
            case "mac":
            default:
                $sort = " ORDER BY `mac_address`";
        }
    }
    // Show ARP tables only for permitted ports
    $query_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    $query = 'FROM `ip_mac` AS M ';
    $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = M.`port_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`mac_id`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= $sort;
    $query .= " LIMIT {$start},{$pagesize}";
    // Query ARP/NDP table addresses
    $entries = dbFetchRows($query, $param);
    // Query ARP/NDP table address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE, 'port' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] == 'search') {
        $list['port'] = TRUE;
    }
    $string = generate_box_open();
    $string .= '<table class="table  table-striped table-hover table-condensed">' . PHP_EOL;
    $cols = array('mac' => 'MAC Address', 'ip' => 'IP Address', 'device' => 'Device', 'port' => 'Port', '!remote_device' => 'Remote Device', '!remote_port' => 'Remote Port');
    if (!$list['device']) {
        unset($cols['device']);
    }
    if (!$list['port']) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:arptable.inc.php

示例12: generate_query_permitted

 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
?>
<div class="row">
<div class="col-md-12">

<?php 
$where = ' WHERE 1 ';
$where .= generate_query_permitted(array('device'), array('device_table' => 'F'));
// Select devices and vlans only with FDB tables
foreach (dbFetchRows('SELECT F.`device_id`, `vlan_vlan`, `vlan_name` FROM `vlans_fdb` AS F
                     LEFT JOIN `vlans` as V ON V.`vlan_vlan` = F.`vlan_id` AND V.`device_id` = F.`device_id`' . $where . 'GROUP BY `device_id`, `vlan_vlan`;') as $data) {
    if (is_numeric($data['vlan_vlan'])) {
        $form_devices[] = $data['device_id'];
        $form_items['vlans'][$data['vlan_vlan']] = 'Vlan ' . $data['vlan_vlan'];
        $form_items['vlan_name'][$data['vlan_name']] = $data['vlan_name'];
    }
}
ksort($form_items['vlans']);
natcasesort($form_items['vlan_name']);
// Select the devices with FDB tables
//$form_devices = dbFetchColumn('SELECT DISTINCT `device_id` FROM `vlans_fdb`');
$form_items['devices'] = generate_form_values('device', $form_devices);
$form = array('type' => 'rows', 'space' => '5px', 'submit_by_key' => TRUE, 'url' => 'search/search=fdb/');
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:fdb.inc.php

示例13: generate_query_permitted

<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$graph_type = "processor_usage";
$sql = "SELECT *, `processors`.`processor_id` AS `processor_id` FROM `processors`";
$sql .= " LEFT JOIN  `processors-state` ON `processors`.`processor_id` = `processors-state`.`processor_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, 'processors.processor_id');
}
$processors = array();
foreach (dbFetchRows($sql) as $proc) {
    if (isset($cache['devices']['id'][$proc['device_id']])) {
        $proc['hostname'] = $cache['devices']['id'][$proc['device_id']]['hostname'];
        $proc['html_row_class'] = $cache['devices']['id'][$proc['device_id']]['html_row_class'];
        $processors[] = $proc;
    }
}
$processors = array_sort_by($processors, 'hostname', SORT_ASC, SORT_STRING, 'processor_descr', SORT_ASC, SORT_STRING);
$processors_count = count($processors);
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:processor.inc.php

示例14: print_fdbtable

/**
 * Display FDB table.
 *
 * @param array $vars
 * @return none
 *
 */
function print_fdbtable($vars)
{
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    $pageno = isset($vars['pageno']) && !empty($vars['pageno']) ? $vars['pageno'] : 1;
    $pagesize = isset($vars['pagesize']) && !empty($vars['pagesize']) ? $vars['pagesize'] : 10;
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            $cond = array();
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= ' AND I.`device_id` = ?';
                    $param[] = $value;
                    break;
                case 'port':
                case 'port_id':
                    $where .= ' AND I.`port_id` = ?';
                    $param[] = $value;
                    break;
                case 'interface':
                    $where .= ' AND I.`ifDescr` LIKE ?';
                    $param[] = $value;
                    break;
                case 'vlan_id':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $v) {
                        $cond[] = '?';
                        $param[] = $v;
                    }
                    $where .= " AND F.`vlan_id` IN (";
                    $where .= implode(', ', $cond);
                    $where .= ')';
                    break;
                case 'vlan_name':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $v) {
                        $cond[] = '?';
                        $param[] = $v;
                    }
                    $where .= " AND V.`vlan_name` IN (";
                    $where .= implode(', ', $cond);
                    $where .= ')';
                    break;
                case 'address':
                    $where .= ' AND F.`mac_address` LIKE ?';
                    $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    break;
            }
        }
    }
    // Show FDB tables only for permitted ports
    $query_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    $query = 'FROM `vlans_fdb` AS F ';
    $query .= 'LEFT JOIN `vlans` as V ON V.`vlan_vlan` = F.`vlan_id` AND V.`device_id` = F.`device_id` ';
    $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = F.`port_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY F.`mac_address`';
    $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;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>VLAN ID</th>' . PHP_EOL;
        $string .= '      <th>VLAN Name</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:fdbtable.inc.php

示例15: unset

 *
 */
?>
<div class="row">
<div class="col-md-12">

<?php 
///FIXME. Mike: should be more checks, at least a confirmation click.
//if ($vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10')
//{
//  dbFetchCell("TRUNCATE TABLE `syslog`");
//  print_message('系统日志截断');
//}
unset($search, $devices_array, $priorities, $programs);
$where = ' WHERE 1 ';
$where .= generate_query_permitted();
//Device field
// Show devices only with syslog messages
foreach (dbFetchRows('SELECT `device_id` FROM `syslog`' . $where . 'GROUP BY `device_id`') as $data) {
    $device_id = $data['device_id'];
    if ($cache['devices']['id'][$device_id]['hostname']) {
        $devices_array[$device_id] = $cache['devices']['id'][$device_id]['hostname'];
    }
}
natcasesort($devices_array);
$search[] = array('type' => 'select', 'name' => 'Devices', 'id' => 'device_id', 'width' => '150px', 'value' => $vars['device_id'], 'values' => $devices_array);
if (is_numeric($vars['device_id'])) {
    $where .= ' AND `device_id` = ' . $vars['device_id'] . ' ';
}
// Add device_id limit for other fields
//Message field
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:syslog.inc.php


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