本文整理汇总了PHP中Subnets::find_gateway方法的典型用法代码示例。如果您正苦于以下问题:PHP Subnets::find_gateway方法的具体用法?PHP Subnets::find_gateway怎么用?PHP Subnets::find_gateway使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subnets
的用法示例。
在下文中一共展示了Subnets::find_gateway方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: User
$User = new User($Database);
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Addresses = new Addresses($Database);
//$Ping = new Scan ($Database);
$DNS = new DNS($Database);
$validNM = $GLOBALS['Net_IPv4_Netmask_Map'];
# verify that user is logged in
$User->check_user_session();
# id must be numeric
is_numeric($_POST['id']) || strlen($_POST['id']) == 0 ?: $Result->show("danger", _("Invalid ID"), true);
# get IP address id
$id = $_POST['id'];
$subnetId = $_POST['subnetId'];
$address = (array) $Addresses->fetch_address(null, $id);
$gateway = $Subnets->find_gateway($subnetId);
$resolve = $DNS->resolve_address($address['ip_addr'], $address['dns_name'], false, $subnet['nameserverId']);
$subnet = (array) $Subnets->fetch_subnet(null, $address['subnetId']);
$mask = $validNM[$subnet['mask']];
# validate post
#is_numeric($_POST['subnetId']) ?: $Result->show("danger", _("Invalid ID"), true, true, false, true);
#if(is_numeric($id)) {
# strlen($id)!=0 ?: $Result->show("danger", _("Invalid ID"), true, true, false, true);
# fetch address
# $address = (array) $Addresses->fetch_address(null, $id);
#}
// from adding new IP, validate
#else {
# $validate = $Subnets->identify_address ($_POST['id'])=="IPv4" ? filter_var($_POST['id'], FILTER_VALIDATE_IP) : filter_var($_POST['id'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
# if ($validate===false) { $Result->show("danger", _("Invalid IP address"), true, true, false, true); }
# else {
示例2: empty
sizeof($address) > 0 ?: $Result->show("danger", _("Invalid ID"), true);
sizeof($subnet) > 0 ?: $Result->show("danger", _("Invalid subnet"), true);
# set title
$title = _('IP address details') . ' :: ' . $address['ip'];
# address
$content[] = "• " . _('IP address') . ": \t\t {$address['ip']}/{$subnet['mask']}";
# description
empty($address['description']) ?: ($content[] = "• " . _('Description') . ":\t\t {$address['description']}");
# hostname
empty($address['dns_name']) ?: ($content[] = "• " . _('Hostname') . ": \t {$address['dns_name']}");
# subnet desc
$s_descrip = empty($subnet['description']) ? "" : " (" . $subnet['description'] . ")";
# subnet
$content[] = "• " . _('Subnet') . ": \t\t {$subnet['ip']}/{$subnet['mask']} {$s_descrip}";
# gateway
$gateway = $Subnets->find_gateway($subnet['id']);
if ($gateway !== false) {
$content[] = "• " . _('Gateway') . ": \t\t" . $Subnets->transform_to_dotted($gateway->ip_addr);
}
# VLAN
empty($subnet['vlanId']) ?: ($content[] = "• " . _('VLAN ID') . ": \t\t {$vlan['number']} ({$vlan['name']})");
# Nameserver sets
if (!empty($subnet['nameserverId'])) {
$nslist = str_replace(";", ", ", $nameservers['namesrv1']);
$content[] = "• " . _('Nameservers') . ": \t {$nslist} ({$nameservers['name']})";
}
# Switch
if (!empty($address['switch'])) {
# get device by id
$device = (array) $Tools->fetch_object("devices", "id", $address['switch']);
!sizeof($device) > 1 ?: ($content[] = "• " . _('Device') . ": \t\t {$device['hostname']}");
示例3: array
}
//insert to ipaddresses table
$values = array("action" => "add", "ip_addr" => $Addresses->transform_address($_POST['ip_addr'], "decimal"), "subnetId" => $_POST['subnetId'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "mac" => @$_POST['mac'], "owner" => @$_POST['owner'], "state" => @$_POST['state'], "switch" => @$_POST['switch'], "port" => @$_POST['port'], "note" => @$_POST['note']);
if (!$Addresses->modify_address($values)) {
$Result->show("danger", _("Failed to create IP address"), true);
}
//accept message
$values2 = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 1, "adminComment" => $comment);
if (!$Admin->object_modify("requests", "edit", "id", $values2)) {
$Result->show("danger", _("Cannot confirm IP address"), true);
} else {
$Result->show("success", _("IP request accepted/rejected"), false);
}
# send mail
//save subnt
$tmp['subnetId'] = $_POST['subnetId'];
unset($_POST['subnetId']);
// gateway
$gateway = $Subnets->find_gateway($tmp['subnetId']);
if ($gateway !== false) {
$tmp['gateway'] = $Subnets->transform_address($gateway->ip_addr, "dotted");
}
//set vlan
$vlan = $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']);
$tmp['vlan'] = $vlan == false ? "" : $vlan->number . " - " . $vlan->description;
//set dns
$dns = $Tools->fetch_object("nameservers", "id", $subnet['nameserverId']);
$tmp['dns'] = $dns == false ? "" : $dns->description . " <br> " . str_replace(";", ", ", $dns->namesrv1);
$_POST = array_merge($tmp, $_POST);
$Tools->ip_request_send_mail("accept", $_POST);
}