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


PHP delete_port函数代码示例

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


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

示例1: delete_device

function delete_device($id, $delete_rrd = FALSE)
{
    global $config;
    $ret = PHP_EOL;
    $device = device_by_id_cache($id);
    $host = $device['hostname'];
    if ($host == '') {
        $ret .= "发现错误的主机数据库中.";
    } else {
        $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id));
        if (!empty($ports)) {
            $ret .= ' * Deleted interfaces: ';
            foreach ($ports as $int_data) {
                $int_if = $int_data['ifDescr'];
                $int_id = $int_data['port_id'];
                delete_port($int_id, $delete_rrd);
                $deleted_ports[] = "id={$int_id} ({$int_if})";
            }
            $ret .= implode(', ', $deleted_ports) . PHP_EOL;
        }
        $ret .= ' * Deleted device entries from tables: ';
        foreach ($config['device_tables'] as $table) {
            $where = '`device_id` = ?';
            if ($table == 'entity_permissions') {
                $where = "`entity_type` = 'device' AND `entity_id` = ?";
            }
            $table_status = dbDelete($table, $where, array($id));
            if ($table_status) {
                $deleted_tables[] = $table;
            }
        }
        $ret .= implode(', ', $deleted_tables) . PHP_EOL;
        if ($delete_rrd) {
            $device_rrd = rtrim(get_rrd_path($device, ''), '/');
            if (is_file($device_rrd . '/status.rrd')) {
                external_exec("rm -rf " . escapeshellarg($device_rrd));
                $ret .= ' * 删除设备 RRDs 目录: ' . $device_rrd . PHP_EOL;
            }
        }
        $ret .= " * Deleted device: {$host}";
    }
    return $ret;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:43,代码来源:functions.inc.php

示例2: delete_device

function delete_device($id)
{
    global $config, $debug;
    $ret = '';
    $host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
    if (empty($host)) {
        return "No such host.";
    }
    // Remove IPv4/IPv6 addresses before removing ports as they depend on port_id
    dbQuery("DELETE `ipv4_addresses` FROM `ipv4_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `device_id`=?", array($id));
    dbQuery("DELETE `ipv6_addresses` FROM `ipv6_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv6_addresses`.`port_id` WHERE `device_id`=?", array($id));
    foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) {
        $int_if = $int_data['ifDescr'];
        $int_id = $int_data['port_id'];
        delete_port($int_id);
        $ret .= "Removed interface {$int_id} ({$int_if})\n";
    }
    $fields = array('device_id', 'host');
    foreach ($fields as $field) {
        foreach (dbFetch("SELECT table_name FROM information_schema.columns WHERE table_schema = ? AND column_name = ?", array($config['db_name'], $field)) as $table) {
            $table = $table['table_name'];
            $entries = (int) dbDelete($table, "`{$field}` =  ?", array($id));
            if ($entries > 0 && $debug === true) {
                $ret .= "{$field}@{$table} = #{$entries}\n";
            }
        }
    }
    $ex = shell_exec("bash -c '( [ ! -d " . trim($config['rrd_dir']) . "/" . $host . " ] || rm -vrf " . trim($config['rrd_dir']) . "/" . $host . " 2>&1 ) && echo -n OK'");
    $tmp = explode("\n", $ex);
    if ($tmp[sizeof($tmp) - 1] != "OK") {
        $ret .= "Could not remove files:\n{$ex}\n";
    }
    $ret .= "Removed device {$host}\n";
    return $ret;
}
开发者ID:syzdek,项目名称:librenms,代码行数:35,代码来源:functions.php

示例3: delete_device

function delete_device($id)
{
    global $config;
    $host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
    foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) {
        $int_if = $int_data['ifDescr'];
        $int_id = $int_data['port_id'];
        delete_port($int_id);
        $ret .= "Removed interface {$int_id} ({$int_if})\n";
    }
    dbDelete('devices', "`device_id` =  ?", array($id));
    $device_tables = array('entPhysical', 'devices_attribs', 'devices_perms', 'bgpPeers', 'vlans', 'vrfs', 'storage', 'alerts', 'eventlog', 'syslog', 'ports', 'services', 'toner', 'frequency', 'current', 'sensors', 'ciscoASA');
    foreach ($device_tables as $table) {
        dbDelete($table, "`device_id` =  ?", array($id));
    }
    shell_exec("rm -rf " . trim($config['rrd_dir']) . "/{$host}");
    $ret = "Removed device {$host}";
    return $ret;
}
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:19,代码来源:functions.php

示例4: mysql_query

    $ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `port_id` = '{$port_id}'");
    while ($ipaddr = mysql_fetch_assoc($ipaddrs)) {
        echo "<div style='padding-left:8px; font-weight: normal;'>删除 IPv4 地址 " . $ipaddr['addr'] . "/" . $ipaddr['cidr'];
        mysql_query("DELETE FROM addr WHERE id = '" . $addr['id'] . "'");
        echo "</div>";
    }
    $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `port_id` = '{$port_id}'");
    while ($ip6addr = mysql_fetch_assoc($ip6addrs)) {
        echo "<div style='padding-left:8px; font-weight: normal;'>删除 IPv6 地址 " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'];
        mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '" . $ip6addr['ip6_addr_id'] . "'");
        echo "</div>";
    }
    $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `port_id` = '{$port_id}'");
    while ($ip6addr = mysql_fetch_assoc($ip6addrs)) {
        echo "<div style='padding-left:8px; font-weight: normal;'>删除 IPv6 地址 " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'];
        mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '" . $ip6addr['ip6_addr_id'] . "'");
        echo "</div>";
    }
    mysql_query("DELETE FROM `pseudowires` WHERE `port_id` = '{$port_id}'");
    mysql_query("DELETE FROM `mac_accounting` WHERE `port_id` = '{$port_id}'");
    mysql_query("DELETE FROM `links` WHERE `local_port_id` = '{$port_id}'");
    mysql_query("DELETE FROM `links` WHERE `remote_port_id` = '{$port_id}'");
    mysql_query("DELETE FROM `ports_perms` WHERE `port_id` = '{$port_id}'");
    mysql_query("DELETE FROM `ports` WHERE `port_id` = '{$port_id}'");
}
$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'");
while ($port = mysql_fetch_assoc($ports)) {
    echo "<div style='font-weight: bold;'>删除端口 " . $port['port_id'] . " - " . $port['ifDescr'];
    delete_port($port['port_id']);
    echo "</div>";
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:purgeports.inc.php

示例5: age_to_unixtime

 * @package    observium
 * @subpackage housekeeping
 * @author     Adam Armstrong <adama@observium.org>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$cutoff = age_to_unixtime($config['housekeeping']['deleted_ports']['age']);
if ($cutoff) {
    $where = "`deleted` = 1 AND UNIX_TIMESTAMP(`ifLastChange`) < {$cutoff}";
    $ports = dbFetchRows("SELECT `port_id` FROM `ports` WHERE {$where}");
    $count = count($ports);
    if ($count) {
        if ($prompt) {
            $answer = print_prompt("{$count} ports marked as deleted before " . format_unixtime($cutoff) . " will be deleted");
        }
        if ($answer) {
            foreach ($ports as $entry) {
                delete_port($entry['port_id']);
            }
            print_debug("Deleted ports housekeeping: deleted {$count} entries");
            logfile("housekeeping.log", "Deleted ports: deleted {$count} entries older than " . format_unixtime($cutoff));
        }
    } else {
        if ($prompt) {
            print_message("No ports found marked as deleted before " . format_unixtime($cutoff));
        }
    }
} else {
    print_message("Deleted ports housekeeping disabled in configuration.");
}
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:ports.inc.php

示例6: foreach

<?php

$pagetitle[] = 'Deleted ports';
if ($vars['purge'] == 'all') {
    foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) {
        if (port_permitted($interface['port_id'], $interface['device_id'])) {
            delete_port($interface['port_id']);
            echo '<div class=infobox>Deleted ' . generate_device_link($interface) . ' - ' . generate_port_link($interface) . '</div>';
        }
    }
} elseif ($vars['purge']) {
    $interface = dbFetchRow('SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['purge']));
    if (port_permitted($interface['port_id'], $interface['device_id'])) {
        delete_port($interface['port_id']);
    }
    echo '<div class=infobox>Deleted ' . generate_device_link($interface) . ' - ' . generate_port_link($interface) . '</div>';
}
echo '<table class="table table-hover table-condensed">';
echo "<tr><td>Device</td><td>Port</td><td></td><td><a href='deleted-ports/purge=all/'><i class='fa fa-times'></i> Purge All</a></td></tr>";
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id", array(), true) as $interface) {
    $interface = ifLabel($interface, $interface);
    if (port_permitted($interface['port_id'], $interface['device_id'])) {
        echo '<tr class=list>';
        echo '<td width=250>' . generate_device_link($interface) . '</td>';
        echo '<td width=250>' . generate_port_link($interface) . '</td>';
        echo '<td></td>';
        echo "<td width=100><a href='deleted-ports/purge=" . $interface['port_id'] . "/'><i class='fa fa-times'></i> Purge</a></td>";
    }
}
echo '</table>';
开发者ID:awlx,项目名称:librenms,代码行数:30,代码来源:deleted-ports.inc.php

示例7: delete_device

function delete_device($id, $delete_rrd = FALSE)
{
    global $config;
    $ret = PHP_EOL;
    $host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
    $ports = dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id));
    if (!empty($ports)) {
        $ret .= '> Deleted interfaces: ';
        foreach ($ports as $int_data) {
            $int_if = $int_data['ifDescr'];
            $int_id = $int_data['port_id'];
            delete_port($int_id);
            $ret .= "id={$int_id} ({$int_if}), ";
        }
        $ret .= PHP_EOL;
    }
    dbDelete('devices', "`device_id` =  ?", array($id));
    $device_tables = array('entPhysical', 'devices_attribs', 'devices_perms', 'bgpPeers', 'vlans', 'vrfs', 'storage', 'alerts', 'eventlog', 'syslog', 'ports', 'services', 'toner', 'frequency', 'current', 'sensors', 'ospf_areas', 'ospf_ports', 'ospf_nbrs', 'ospf_instances', 'alert_table');
    $ret .= '> Deleted table entries: ';
    foreach ($device_tables as $table) {
        $table_status = dbDelete($table, "`device_id` = ?", array($id));
        if ($table_status) {
            $ret .= $table . ', ';
        }
    }
    $ret .= PHP_EOL;
    if ($delete_rrd) {
        shell_exec("rm -rf " . trim($config['rrd_dir']) . '/' . $host);
        $ret .= '> Deleted device RRDs dir: ' . $config['rrd_dir'] . '/' . $host . PHP_EOL;
    }
    $ret .= "> Deleted device: {$host}\n";
    return $ret;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:33,代码来源:functions.php

示例8: foreach

 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2015 Adam Armstrong
 *
 */
$page_title[] = '删除端口';
if ($vars['purge'] == 'all') {
    foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = "1" AND D.device_id = P.device_id') as $port) {
        if (port_permitted($port['port_id'], $port['device_id'])) {
            print_message(delete_port($port['port_id']), 'console');
        }
    }
} else {
    if (is_numeric($vars['purge'])) {
        $port = dbFetchRow('SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['purge']));
        if ($port && port_permitted($port['port_id'], $port['device_id'])) {
            print_message(delete_port($port['port_id']), 'console');
        }
    }
}
echo '<table class="table table-condensed table-striped table-bordered table-condensed">
  <thead><tr>
    <th>设备</th>
    <th>端口</th>
    <th>描述</th>
    <th>删除自</th>
    <th style="text-align: right;"><a href="' . generate_url(array('page' => 'deleted-ports', 'purge' => 'all')) . '"><button class="btn btn-danger btn-mini"><i class="icon-remove icon-white"></i> 清除全部</button></a></th>
  </tr></thead>';
foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = "1" AND D.device_id = P.device_id') as $port) {
    humanize_port($port);
    $since = $config['time']['now'] - strtotime($port['ifLastChange']);
    if (port_permitted($port['port_id'], $port['device_id'])) {
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:deleted-ports.inc.php

示例9: delete_device

function delete_device($id, $delete_rrd = FALSE)
{
    global $config;
    $ret = PHP_EOL;
    $device = device_by_id_cache($id);
    $host = $device['hostname'];
    if ($host == '') {
        $ret .= "Error finding host in the database.";
    } else {
        $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id));
        if (!empty($ports)) {
            $ret .= ' * Deleted interfaces: ';
            foreach ($ports as $int_data) {
                $int_if = $int_data['ifDescr'];
                $int_id = $int_data['port_id'];
                delete_port($int_id, $delete_rrd);
                $deleted_ports[] = "id={$int_id} ({$int_if})";
            }
            $ret .= implode(', ', $deleted_ports) . PHP_EOL;
        }
        // Remove entities from common tables
        $deleted_entities = array();
        foreach (get_device_entities($id) as $entity_type => $entity_ids) {
            foreach ($config['entity_tables'] as $table) {
                $where = '`entity_type` = ?' . generate_query_values($entity_ids, 'entity_id');
                $table_status = dbDelete($table, $where, array($entity_type));
                if ($table_status) {
                    $deleted_entities[$entity_type] = 1;
                }
            }
        }
        if (count($deleted_entities)) {
            $ret .= ' * Deleted common entity entries linked to device: ';
            $ret .= implode(', ', array_keys($deleted_entities)) . PHP_EOL;
        }
        $deleted_tables = array();
        $ret .= ' * Deleted device entries from tables: ';
        foreach ($config['device_tables'] as $table) {
            $where = '`device_id` = ?';
            $table_status = dbDelete($table, $where, array($id));
            if ($table_status) {
                $deleted_tables[] = $table;
            }
        }
        $ret .= implode(', ', $deleted_tables) . PHP_EOL;
        if ($delete_rrd) {
            $device_rrd = rtrim(get_rrd_path($device, ''), '/');
            if (is_file($device_rrd . '/status.rrd')) {
                external_exec("rm -rf " . escapeshellarg($device_rrd));
                $ret .= ' * Deleted device RRDs dir: ' . $device_rrd . PHP_EOL;
            }
        }
        $ret .= " * Deleted device: {$host}";
    }
    return $ret;
}
开发者ID:Natolumin,项目名称:observium,代码行数:56,代码来源:functions.inc.php

示例10: foreach

 * @subpackage webui
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$pagetitle[] = 'Deleted ports';
if ($vars['purge'] == 'all') {
    foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = "1" AND D.device_id = P.device_id') as $port) {
        if (port_permitted($port['port_id'], $port['device_id'])) {
            print_warning(delete_port($port['port_id']));
        }
    }
} elseif (is_numeric($vars['purge'])) {
    $port = dbFetchRow('SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['purge']));
    if ($port && port_permitted($port['port_id'], $port['device_id'])) {
        print_warning(delete_port($port['port_id']));
    }
}
echo '<table class="table table-striped table-bordered table-condensed">
  <thead><tr>
    <th>Device</th>
    <th>Port</th>
    <th>Description</th>
    <th>Deleted since</th>
    <th style="text-align: right;"><a href="' . generate_url(array('page' => 'deleted-ports', 'purge' => 'all')) . '"><button class="btn btn-danger btn-small"><i class="icon-remove icon-white"></i> Purge All</button></a></th>
  </tr></thead>';
foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = "1" AND D.device_id = P.device_id') as $port) {
    humanize_port($port);
    $since = $config['time']['now'] - strtotime($port['ifLastChange']);
    if (port_permitted($port['port_id'], $port['device_id'])) {
        echo '<tr class="list">';
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:deleted-ports.inc.php

示例11: mysql_query

    $ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '{$interface_id}'");
    while ($ipaddr = mysql_fetch_array($ipaddrs)) {
        echo "<div style='padding-left:8px; font-weight: normal;'>Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr'];
        mysql_query("DELETE FROM addr WHERE id = '" . $addr['id'] . "'");
        echo "</div>";
    }
    $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '{$interface_id}'");
    while ($ip6addr = mysql_fetch_array($ip6addrs)) {
        echo "<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'];
        mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '" . $ip6addr['ip6_addr_id'] . "'");
        echo "</div>";
    }
    $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '{$interface_id}'");
    while ($ip6addr = mysql_fetch_array($ip6addrs)) {
        echo "<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'];
        mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '" . $ip6addr['ip6_addr_id'] . "'");
        echo "</div>";
    }
    mysql_query("DELETE FROM `pseudowires` WHERE `interface_id` = '{$interface_id}'");
    mysql_query("DELETE FROM `mac_accounting` WHERE `interface_id` = '{$interface_id}'");
    mysql_query("DELETE FROM `links` WHERE `local_interface_id` = '{$interface_id}'");
    mysql_query("DELETE FROM `links` WHERE `remote_interface_id` = '{$interface_id}'");
    mysql_query("DELETE FROM `ports_perms` WHERE `interface_id` = '{$interface_id}'");
    mysql_query("DELETE FROM `ports` WHERE `interface_id` = '{$interface_id}'");
}
$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'");
while ($port = mysql_fetch_array($ports)) {
    echo "<div style='font-weight: bold;'>Deleting port " . $port['interface_id'] . " - " . $port['ifDescr'];
    delete_port($port['interface_id']);
    echo "</div>";
}
开发者ID:kyrisu,项目名称:observernms,代码行数:31,代码来源:purgeports.php


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