本文整理汇总了PHP中is_ipaddrv6函数的典型用法代码示例。如果您正苦于以下问题:PHP is_ipaddrv6函数的具体用法?PHP is_ipaddrv6怎么用?PHP is_ipaddrv6使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_ipaddrv6函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_static_route
function delete_static_route($id)
{
global $config, $a_routes, $changedesc_prefix;
if (!isset($a_routes[$id])) {
return;
}
$targets = array();
if (is_alias($a_routes[$id]['network'])) {
foreach (filter_expand_alias_array($a_routes[$id]['network']) as $tgt) {
if (is_ipaddrv4($tgt)) {
$tgt .= "/32";
} else {
if (is_ipaddrv6($tgt)) {
$tgt .= "/128";
}
}
if (!is_subnet($tgt)) {
continue;
}
$targets[] = $tgt;
}
} else {
$targets[] = $a_routes[$id]['network'];
}
foreach ($targets as $tgt) {
$family = is_subnetv6($tgt) ? "-inet6" : "-inet";
mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt));
}
unset($targets);
}
示例2: find_ip_interface
function find_ip_interface($ip, $bits = null)
{
if (!is_ipaddr($ip)) {
return false;
}
$isv6ip = is_ipaddrv6($ip);
/* if list */
$ifdescrs = get_configured_interface_list();
foreach ($ifdescrs as $ifdescr => $ifname) {
$ifip = $isv6ip ? get_interface_ipv6($ifname) : get_interface_ip($ifname);
if (is_null($ifip)) {
continue;
}
if (is_null($bits)) {
if ($ip == $ifip) {
$int = get_real_interface($ifname);
return $int;
}
} else {
if (ip_in_subnet($ifip, $ip . "/" . $bits)) {
$int = get_real_interface($ifname);
return $int;
}
}
}
return false;
}
示例3: build_gatewayv6_list
function build_gatewayv6_list()
{
global $a_gateways, $if;
$list = array("none" => "None");
foreach ($a_gateways as $gateway) {
if ($gateway['interface'] == $if && is_ipaddrv6($gateway['gateway'])) {
$list[$gateway['name']] = $gateway['name'] . " - " . $gateway['gateway'];
}
}
return $list;
}
示例4: unset
break;
}
}
}
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
/* input validation */
if ($_POST['enable']) {
$reqdfields = explode(" ", "server interface");
$reqdfieldsn = array(gettext("Destination Server"), gettext("Interface"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
$svrlist = '';
if ($_POST['server']) {
foreach ($_POST['server'] as $checksrv => $srv) {
if (!is_ipaddrv6($srv[0])) {
$input_errors[] = gettext("A valid Destination Server IPv6 address must be specified.");
}
if (!empty($srv[0])) {
// Filter out any empties
if (!empty($svrlist)) {
$svrlist .= ',';
}
$svrlist .= $srv[0];
}
}
}
}
if (!$input_errors) {
$config['dhcrelay6']['enable'] = $_POST['enable'] ? true : false;
$config['dhcrelay6']['interface'] = implode(",", $_POST['interface']);
示例5: Form_Input
$section->addInput(new Form_Input('domain', 'Domain', 'text', $pconfig['domain'], ['placeholder' => 'mycorp.com, home, office, private, etc.']))->setHelp('Do not use \'local\' as a domain name. It will cause local ' . 'hosts running mDNS (avahi, bonjour, etc.) to be unable to resolve ' . 'local hosts not running mDNS.');
$form->add($section);
$section = new Form_Section('DNS Server Settings');
for ($i = 1; $i < 5; $i++) {
// if (!isset($pconfig['dns'.$i]))
// continue;
$group = new Form_Group('DNS Server ' . $i);
$group->add(new Form_Input('dns' . $i, 'DNS Server', 'text', $pconfig['dns' . $i]))->setHelp($i == 4 ? 'Address' : null);
$help = "Enter IP addresses to be used by the system for DNS resolution. " . "These are also used for the DHCP service, DNS forwarder and for PPTP VPN clients.";
if ($multiwan) {
$options = array('none' => 'none');
foreach ($arr_gateways as $gwname => $gwitem) {
if (is_ipaddrv4(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && is_ipaddrv6($gwitem['gateway'])) {
continue;
}
if (is_ipaddrv6(lookup_gateway_ip_by_name($pconfig[$dnsgw])) && is_ipaddrv4($gwitem['gateway'])) {
continue;
}
$options[$gwname] = $gwname . ' - ' . $gwitem['friendlyiface'] . ' - ' . $gwitem['gateway'];
}
$group->add(new Form_Select('dns' . $i . 'gw', 'Gateway', $pconfig['dns' . $i . 'gw'], $options))->setHelp($i == 4 ? 'Gateway' : null);
$help .= '<br/>' . "In addition, optionally select the gateway for each DNS server. " . "When using multiple WAN connections there should be at least one unique DNS server per gateway.";
}
if ($i == 4) {
$group->setHelp($help);
}
$section->add($group);
}
$section->addInput(new Form_Checkbox('dnsallowoverride', 'DNS Server Override', 'Allow DNS server list to be overridden by DHCP/PPP on WAN', $pconfig['dnsallowoverride']))->setHelp(sprintf(gettext('If this option is set, %s will use DNS servers ' . 'assigned by a DHCP/PPP server on WAN for its own purposes (including ' . 'the DNS forwarder). However, they will not be assigned to DHCP and PPTP ' . 'VPN clients.'), $g['product_name']));
$section->addInput(new Form_Checkbox('dnslocalhost', 'Disable DNS Forwarder', 'Do not use the DNS Forwarder as a DNS server for the firewall', $pconfig['dnslocalhost']))->setHelp('By default localhost (127.0.0.1) will be used as the first DNS ' . 'server where the DNS Forwarder or DNS Resolver is enabled and set to ' . 'listen on Localhost, so system can use the local DNS service to perform ' . 'lookups. Checking this box omits localhost from the list of DNS servers.');
$form->add($section);
示例6: openvpn_create_key
} else {
$tls_mode = false;
}
if (!empty($pconfig['autokey_enable'])) {
$pconfig['shared_key'] = openvpn_create_key();
}
// all input validators
if (strpos($pconfig['interface'], '|') !== false) {
list($iv_iface, $iv_ip) = explode("|", $pconfig['interface']);
} else {
$iv_iface = $pconfig['interface'];
$iv_ip = null;
}
if (is_ipaddrv4($iv_ip) && stristr($pconfig['protocol'], "6") !== false) {
$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
} elseif (is_ipaddrv6($iv_ip) && stristr($pconfig['protocol'], "6") === false) {
$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
} elseif (stristr($pconfig['protocol'], "6") === false && !get_interface_ip($iv_iface) && $pconfig['interface'] != "any") {
$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
} elseif (stristr($pconfig['protocol'], "6") !== false && !get_interface_ipv6($iv_iface) && $pconfig['interface'] != "any") {
$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
}
if (empty($pconfig['authmode']) && ($pconfig['mode'] == "server_user" || $pconfig['mode'] == "server_tls_user")) {
$input_errors[] = gettext("You must select a Backend for Authentication if the server mode requires User Auth.");
}
if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) {
$input_errors[] = $result;
}
if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4")) {
$input_errors[] = $result;
}
示例7: gettext
if ($_POST['interface'] == 'lo0') {
$input_errors[] = gettext("For this type of vip localhost is not allowed.");
} else {
if (strpos($_POST['interface'], '_vip')) {
$input_errors[] = gettext("A CARP parent interface can only be used with IP Alias type Virtual IPs.");
}
}
break;
case 'ipalias':
if (strstr($_POST['interface'], "_vip")) {
if (is_ipaddrv4($_POST['subnet'])) {
$parent_ip = get_interface_ip($_POST['interface']);
$parent_sn = get_interface_subnet($_POST['interface']);
$subnet = gen_subnet($parent_ip, $parent_sn);
} else {
if (is_ipaddrv6($_POST['subnet'])) {
$parent_ip = get_interface_ipv6($_POST['interface']);
$parent_sn = get_interface_subnetv6($_POST['interface']);
$subnet = gen_subnetv6($parent_ip, $parent_sn);
}
}
if (isset($parent_ip) && !ip_in_subnet($_POST['subnet'], "{$subnet}/{$parent_sn}") && !ip_in_interface_alias_subnet(link_carp_interface_to_parent($_POST['interface']), $_POST['subnet'])) {
$cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'];
$input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."), $cannot_find);
}
unset($parent_ip, $parent_sn, $subnet);
}
break;
default:
if ($_POST['interface'] == 'lo0') {
$input_errors[] = gettext("For this type of vip localhost is not allowed.");
示例8: array
if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) {
$cpzoneid = $a_cp[$cpzone]['zoneid'];
}
$pgtitle = array(gettext("Services"), gettext("Captive Portal"), "Zone " . $a_cp[$cpzone]['zone'], gettext("Allowed Hostnames"));
$shortcut_section = "captiveportal";
if ($_GET['act'] == "del" && !empty($cpzone) && isset($cpzoneid)) {
$a_allowedhostnames =& $a_cp[$cpzone]['allowedhostname'];
if ($a_allowedhostnames[$_GET['id']]) {
$ipent = $a_allowedhostnames[$_GET['id']];
if (isset($a_cp[$cpzone]['enable'])) {
if (is_ipaddr($ipent['hostname'])) {
$ip = $ipent['hostname'];
} else {
$ip = gethostbyname($ipent['hostname']);
}
$sn = is_ipaddrv6($ip) ? 128 : 32;
if (is_ipaddr($ip)) {
$ipfw = pfSense_ipfw_getTablestats($cpzoneid, IP_FW_TABLE_XLISTENTRY, 3, $ip);
if (is_array($ipfw)) {
captiveportal_free_dn_ruleno($ipfw['dnpipe']);
pfSense_pipe_action("pipe delete {$ipfw['dnpipe']}");
pfSense_pipe_action("pipe delete " . ($ipfw['dnpipe'] + 1));
}
pfSense_ipfw_Tableaction($cpzoneid, IP_FW_TABLE_XDEL, 3, $ip, $sn);
pfSense_ipfw_Tableaction($cpzoneid, IP_FW_TABLE_XDEL, 4, $ip, $sn);
}
}
unset($a_allowedhostnames[$_GET['id']]);
write_config();
captiveportal_allowedhostname_configure();
header("Location: services_captiveportal_hostname.php?zone={$cpzone}");
示例9: gettext
$reqdfieldsn[] = gettext("Remote gateway");
}
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
if (isset($validate_pskey) && isset($pconfig['pskey']) && !preg_match('/^[[:ascii:]]*$/', $pconfig['pskey'])) {
unset($validate_pskey);
$input_errors[] = gettext("Pre-Shared Key contains invalid characters.");
}
if ($pconfig['lifetime'] && !is_numericint($pconfig['lifetime'])) {
$input_errors[] = gettext("The P1 lifetime must be an integer.");
}
if ($pconfig['remotegw']) {
if (!is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw'])) {
$input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
} elseif (is_ipaddrv4($pconfig['remotegw']) && $pconfig['protocol'] != "inet") {
$input_errors[] = gettext("A valid remote gateway IPv4 address must be specified or protocol needs to be changed to IPv6");
} elseif (is_ipaddrv6($pconfig['remotegw']) && $pconfig['protocol'] != "inet6") {
$input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or protocol needs to be changed to IPv4");
}
}
if ($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled'])) {
$t = 0;
foreach ($a_phase1 as $ph1tmp) {
if ($p1index != $t) {
$tremotegw = $pconfig['remotegw'];
if ($ph1tmp['remote-gateway'] == $tremotegw && !isset($ph1tmp['disabled'])) {
$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
}
}
$t++;
}
}
示例10: switch
break;
}
}
switch ($pconfig['remoteid_type']) {
case "network":
if ($pconfig['remoteid_netbits'] != 0 && !$pconfig['remoteid_netbits'] || !is_numeric($pconfig['remoteid_netbits'])) {
$input_errors[] = gettext("A valid remote network bit count must be specified.");
}
// address rules also apply to network type (hence, no break)
// address rules also apply to network type (hence, no break)
case "address":
if (!$pconfig['remoteid_address'] || !is_ipaddr($pconfig['remoteid_address'])) {
$input_errors[] = gettext("A valid remote network IP address must be specified.");
} elseif (is_ipaddrv4($pconfig['remoteid_address']) && $pconfig['mode'] != "tunnel") {
$input_errors[] = gettext("A valid remote network IPv4 address must be specified or you need to change Mode to IPv6");
} elseif (is_ipaddrv6($pconfig['remoteid_address']) && $pconfig['mode'] != "tunnel6") {
$input_errors[] = gettext("A valid remote network IPv6 address must be specified or you need to change Mode to IPv4");
}
break;
}
}
/* Validate enabled phase2's are not duplicates */
if (isset($pconfig['mobile'])) {
/* User is adding phase 2 for mobile phase1 */
foreach ($config['ipsec']['phase2'] as $key => $name) {
if (isset($name['mobile']) && $name['uniqid'] != $pconfig['uniqid']) {
/* check duplicate localids only for mobile clents */
$localid_data = ipsec_idinfo_to_cidr($name['localid'], false, $name['mode']);
$entered = array();
$entered['type'] = $pconfig['localid_type'];
if (isset($pconfig['localid_address'])) {
示例11: gettext
if (!is_ipaddr($_POST['tunnel-local-addr']) || !is_ipaddr($_POST['tunnel-remote-addr']) || !is_ipaddr($_POST['remote-addr'])) {
$input_errors[] = gettext("The tunnel local and tunnel remote fields must have valid IP addresses.");
}
if (!is_numericint($_POST['tunnel-remote-net'])) {
$input_errors[] = gettext("The GRE tunnel subnet must be an integer.");
}
if (is_ipaddrv4($_POST['tunnel-local-addr'])) {
if (!is_ipaddrv4($_POST['tunnel-remote-addr'])) {
$input_errors[] = gettext("The GRE Tunnel remote address must be IPv4 where tunnel local address is IPv4.");
}
if ($_POST['tunnel-remote-net'] > 32 || $_POST['tunnel-remote-net'] < 1) {
$input_errors[] = gettext("The GRE tunnel subnet must be an integer between 1 and 32.");
}
}
if (is_ipaddrv6($_POST['tunnel-local-addr'])) {
if (!is_ipaddrv6($_POST['tunnel-remote-addr'])) {
$input_errors[] = gettext("The GRE Tunnel remote address must be IPv6 where tunnel local address is IPv6.");
}
if ($_POST['tunnel-remote-net'] > 128 || $_POST['tunnel-remote-net'] < 1) {
$input_errors[] = gettext("The GRE tunnel subnet must be an integer between 1 and 128.");
}
}
foreach ($a_gres as $gre) {
if (isset($id) && $a_gres[$id] && $a_gres[$id] === $gre) {
continue;
}
if ($gre['if'] == $_POST['if'] && $gre['tunnel-remote-addr'] == $_POST['tunnel-remote-addr']) {
$input_errors[] = sprintf(gettext("A GRE tunnel with the network %s is already defined."), $gre['remote-network']);
break;
}
}
示例12: unset
}
}
if ($_POST) {
unset($input_errors);
if ($_POST['server']) {
$_POST['server'] = filterDestinationServers($_POST['server']);
}
$pconfig = $_POST;
/* input validation */
if ($_POST['enable']) {
$reqdfields = explode(" ", "server interface");
$reqdfieldsn = array(gettext("Destination Server"), gettext("Interface"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if ($_POST['server']) {
foreach ($_POST['server'] as $srv) {
if (!is_ipaddrv6($srv)) {
$input_errors[] = gettext("A valid Destination Server IPv6 address must be specified.");
}
}
}
}
if (!$input_errors) {
$config['dhcrelay6']['enable'] = $_POST['enable'] ? true : false;
$config['dhcrelay6']['interface'] = implode(",", $_POST['interface']);
$config['dhcrelay6']['agentoption'] = $_POST['agentoption'] ? true : false;
$config['dhcrelay6']['server'] = $_POST['server'];
write_config();
$retval = 0;
$retval = services_dhcrelay6_configure();
$savemsg = get_std_save_message($retval);
}
示例13: printf
<strong><?php
printf(gettext("Enable DHCPv6 relay on interface"));
?>
</strong>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?php
echo gettext('Interface(s)');
?>
</td>
<td width="78%" class="vtable">
<select id="interface" name="interface[]" multiple="multiple" class="formselect" size="3">
<?php
foreach ($iflist as $ifent => $ifdesc) {
if (!is_ipaddrv6(get_interface_ipv6($ifent))) {
continue;
}
echo "<option value=\"{$ifent}\"";
if (!empty($pconfig['interface']) && in_array($ifent, $pconfig['interface'])) {
echo " selected=\"selected\"";
}
echo ">{$ifdesc}</option>\n";
}
?>
</select>
<br /><?php
echo gettext("Interfaces without an IPv6 address will not be shown.");
?>
</td>
</tr>
示例14: gettext
echo $selected_key == "address" ? "selected=\"selected\"" : "";
?>
>
<?php
echo gettext("Interface Address");
?>
</option>
<?php
foreach (get_configured_carp_interface_list() as $vip => $address) {
if (!preg_match("/^{$gateway['friendlyiface']}_/i", $vip)) {
continue;
}
if ($gateway['ipprotocol'] == "inet" && !is_ipaddrv4($address)) {
continue;
}
if ($gateway['ipprotocol'] == "inet6" && !is_ipaddrv6($address)) {
continue;
}
?>
<option value="<?php
echo $vip;
?>
" <?php
echo $selected_key == $vip ? "selected=\"selected\"" : "";
?>
>
<?php
echo $vip;
?>
- <?php
echo $address;
示例15: gettext
}
if (isset($_POST['data_payload']) && is_numeric($_POST['data_payload']) && $_POST['data_payload'] < 0) {
$input_errors[] = gettext("A valid data payload must be specified.");
}
/* only allow correct IPv4 and IPv6 gateway addresses */
if ($_POST['gateway'] != "" && is_ipaddr($_POST['gateway']) && $_POST['gateway'] != "dynamic") {
if (is_ipaddrv6($_POST['gateway']) && $_POST['ipprotocol'] == "inet") {
$input_errors[] = sprintf(gettext("The IPv6 gateway address '%s' can not be used as a IPv4 gateway."), $_POST['gateway']);
}
if (is_ipaddrv4($_POST['gateway']) && $_POST['ipprotocol'] == "inet6") {
$input_errors[] = sprintf(gettext("The IPv4 gateway address '%s' can not be used as a IPv6 gateway."), $_POST['gateway']);
}
}
/* only allow correct IPv4 and IPv6 monitor addresses */
if ($_POST['monitor'] != "" && is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
if (is_ipaddrv6($_POST['monitor']) && $_POST['ipprotocol'] == "inet") {
$input_errors[] = sprintf(gettext("The IPv6 monitor address '%s' can not be used on a IPv4 gateway."), $_POST['monitor']);
}
if (is_ipaddrv4($_POST['monitor']) && $_POST['ipprotocol'] == "inet6") {
$input_errors[] = sprintf(gettext("The IPv4 monitor address '%s' can not be used on a IPv6 gateway."), $_POST['monitor']);
}
}
if (isset($_POST['name'])) {
/* check for overlaps */
foreach ($a_gateways as $gateway) {
if (isset($id) && $a_gateways[$id] && $a_gateways[$id] === $gateway) {
if ($gateway['name'] != $_POST['name']) {
$input_errors[] = gettext("Changing name on a gateway is not allowed.");
}
continue;
}