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


PHP is_ipaddr函数代码示例

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


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

示例1: get_realip

 /**
  * Real IPアドレスを戻す
  * プライベートアドレスの場合もある
  */
 function get_realip()
 {
     foreach ($this->proxy as $x) {
         if (!$x[2]) {
             continue;
         }
         // IP取得利用
         $rc = '';
         if (isset($_SERVER[$x[0]])) {
             $rc = trim($_SERVER[$x[0]]);
         }
         if (empty($rc)) {
             continue;
         }
         if (!is_ipaddr($rc)) {
             continue;
         }
         // IPアドレス体系か?
         if (!is_localIP($rc)) {
             return $rc;
         }
         // プライベートな生IPを取得してもあまり意味がない
     }
     return '';
 }
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:29,代码来源:proxy.cls.php

示例2: stat_block

function stat_block($summary, $stat, $num)
{
    global $g, $gotlines, $fields;
    uasort($summary[$stat], 'cmp');
    print "<table width=\"200\" cellpadding=\"3\" cellspacing=\"0\" border=\"1\" summary=\"source destination ip\">";
    print "<tr><th colspan=\"2\">{$fields[$stat]} " . gettext("data") . "</th></tr>";
    $k = array_keys($summary[$stat]);
    $total = 0;
    $numentries = 0;
    for ($i = 0; $i < $num; $i++) {
        if ($k[$i]) {
            $total += $summary[$stat][$k[$i]];
            $numentries++;
            $outstr = $k[$i];
            if (is_ipaddr($outstr)) {
                $outstr = "<a href=\"diag_dns.php?host={$outstr}\" title=\"" . gettext("Reverse Resolve with DNS") . "\"><img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_log.gif\" alt=\"log\" /></a> {$outstr}";
            } elseif (substr_count($outstr, '/') == 1) {
                list($proto, $port) = explode('/', $outstr);
                $service = getservbyport($port, strtolower($proto));
                if ($service) {
                    $outstr .= ": {$service}";
                }
            }
            print "<tr><td>{$outstr}</td><td width=\"50\" align=\"right\">{$summary[$stat][$k[$i]]}</td></tr>";
        }
    }
    $leftover = $gotlines - $total;
    if ($leftover > 0) {
        print "<tr><td>Other</td><td width=\"50\" align=\"right\">{$leftover}</td></tr>";
    }
    print "</table>";
}
开发者ID:OptimWIFI,项目名称:pfsense,代码行数:32,代码来源:diag_logs_filter_summary.php

示例3: output_ipsec_tunnel_status

function output_ipsec_tunnel_status($tunnel)
{
    global $g, $config, $sad;
    $if = "WAN";
    $interfaceip = get_ipsec_tunnel_src($tunnel);
    $foundsrc = false;
    $founddst = false;
    if (!is_ipaddr($tunnel['remote-gateway'])) {
        $tunnel['remote-gateway'] = resolve_retry($tunnel['remote-gateway']);
    }
    foreach ($sad as $sa) {
        if ($sa['src'] == $interfaceip) {
            $foundsrc = true;
        }
        if ($sa['dst'] == $tunnel['remote-gateway']) {
            $founddst = true;
        }
    }
    if ($foundsrc && $founddst) {
        /* tunnel is up */
        $iconfn = "pass";
    } else {
        /* tunnel is down */
        $iconfn = "reject";
    }
    echo "<img src ='/themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif'>";
}
开发者ID:rootsghost,项目名称:5651-pfsense,代码行数:27,代码来源:diag_ipsec.php

示例4: openvpn_validate_host

function openvpn_validate_host($value, $name)
{
    $value = trim($value);
    if (empty($value) || !is_domain($value) && !is_ipaddr($value)) {
        return sprintf(gettext("The field '%s' must contain a valid IP address or domain name."), $name);
    }
    return false;
}
开发者ID:Toudix,项目名称:core,代码行数:8,代码来源:vpn_openvpn_client.php

示例5: _getHostName

function _getHostName($mac, $ip)
{
    if (is_ipaddr($ip)) {
        if (gethostbyaddr($ip) != "" and gethostbyaddr($ip) != $ip) {
            return gethostbyaddr($ip);
        } else {
            return "";
        }
    }
}
开发者ID:rdmenezes,项目名称:pfsense,代码行数:10,代码来源:diag_ndp.php

示例6: fixup_host

function fixup_host($value, $position) {
	$host = strip_host_logic($value);
	$not = has_not($value) ? "not " : "";
	$andor = ($position > 0) ? get_host_boolean($value, $host) : "";
	if (is_ipaddr($host))
		return "{$andor}host {$not}" . $host;
	elseif (is_subnet($host))
		return "{$andor}net {$not}" . $host;
	else
		return "";
}
开发者ID:hlcherub,项目名称:core,代码行数:11,代码来源:diag_packet_capture.php

示例7: _getHostName

function _getHostName($mac, $ip)
{
    if (is_ipaddr($ip)) {
        list($ip, $scope) = explode("%", $ip);
        if (gethostbyaddr($ip) != "" and gethostbyaddr($ip) != $ip) {
            return gethostbyaddr($ip);
        } else {
            return "";
        }
    }
}
开发者ID:NewEraCracker,项目名称:pfsense,代码行数:11,代码来源:diag_ndp.php

示例8: lookup_gateway_monitor_ip_by_name

function lookup_gateway_monitor_ip_by_name($name)
{
    $gateways_arr = return_gateways_array(false, true);
    if (!empty($gateways_arr[$name])) {
        $gateway = $gateways_arr[$name];
        if (!is_ipaddr($gateway['monitor'])) {
            return $gateway['gateway'];
        }
        return $gateway['monitor'];
    }
    return false;
}
开发者ID:karawan,项目名称:core,代码行数:12,代码来源:status_gateway_groups.php

示例9: cisco_to_cidr

function cisco_to_cidr($addr)
{
    if (!is_ipaddr($addr)) {
        return 0;
    }
    $mask = decbin(~ip2long($addr));
    $mask = substr($mask, -32);
    $k = 0;
    for ($i = 0; $i <= 32; $i++) {
        $k += intval($mask[$i]);
    }
    return $k;
}
开发者ID:sjourdois,项目名称:pfsense,代码行数:13,代码来源:ipsec.attributes.php

示例10: delete_gateway_item

/**
 * delete gateway
 * @param int $id sequence item in $a_gateways
 * @param array $a_gateways gateway list
 */
function delete_gateway_item($id, $a_gateways)
{
    global $config;
    if (!isset($a_gateways[$id])) {
        return;
    }
    /* NOTE: Cleanup static routes for the monitor ip if any */
    if (!empty($a_gateways[$id]['monitor']) && $a_gateways[$id]['monitor'] != "dynamic" && is_ipaddr($a_gateways[$id]['monitor']) && $a_gateways[$id]['gateway'] != $a_gateways[$id]['monitor']) {
        if (is_ipaddrv4($a_gateways[$id]['monitor'])) {
            mwexec("/sbin/route delete " . escapeshellarg($a_gateways[$id]['monitor']));
        } else {
            mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateways[$id]['monitor']));
        }
    }
    if ($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway'] == $a_gateways[$id]['name']) {
        unset($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway']);
    }
    unset($config['gateways']['gateway_item'][$a_gateways[$id]['attribute']]);
}
开发者ID:8191,项目名称:opnsense-core,代码行数:24,代码来源:system_gateways.php

示例11: upnp_validate_ip

function upnp_validate_ip($ip, $check_cdir)
{
    /* validate cidr */
    $ip_array = array();
    if ($check_cdir) {
        $ip_array = explode('/', $ip);
        if (count($ip_array) == 2) {
            if ($ip_array[1] < 1 || $ip_array[1] > 32) {
                return false;
            }
        } else {
            if (count($ip_array) != 1) {
                return false;
            }
        }
    } else {
        $ip_array[] = $ip;
    }
    /* validate ip */
    if (!is_ipaddr($ip_array[0])) {
        return false;
    }
    return true;
}
开发者ID:8191,项目名称:opnsense-core,代码行数:24,代码来源:services_upnp.php

示例12: foreach

 /* subjectAltNames */
 foreach ($pconfig['altname_type'] as $altname_seq => $altname_type) {
     if (!empty($pconfig['altname_value'][$altname_seq])) {
         $altnames[] = array("type" => $altname_type, "value" => $pconfig['altname_value'][$altname_seq]);
     }
 }
 /* Input validation for subjectAltNames */
 foreach ($altnames as $altname) {
     switch ($altname['type']) {
         case "DNS":
             if (!is_hostname($altname['value'])) {
                 $input_errors[] = gettext("DNS subjectAltName values must be valid hostnames or FQDNs");
             }
             break;
         case "IP":
             if (!is_ipaddr($altname['value'])) {
                 $input_errors[] = gettext("IP subjectAltName values must be valid IP Addresses");
             }
             break;
         case "email":
             if (empty($altname['value'])) {
                 $input_errors[] = gettext("You must provide an e-mail address for this type of subjectAltName");
             }
             if (preg_match("/[\\!\\#\$\\%\\^\\(\\)\\~\\?\\>\\<\\&\\/\\\\,\"\\']/", $altname['value'])) {
                 $input_errors[] = gettext("The e-mail provided in a subjectAltName contains invalid characters.");
             }
             break;
         case "URI":
             if (!is_URL($altname['value'])) {
                 $input_errors[] = gettext("URI subjectAltName types must be a valid URI");
             }
开发者ID:paudam,项目名称:opnsense-core,代码行数:31,代码来源:system_certmanager.php

示例13: filter_configure

 if ($_POST['apply']) {
     $retval = 0;
     $retval |= filter_configure();
     $retval |= relayd_configure();
     $savemsg = get_std_save_message($retval);
     clear_subsystem_dirty('loadbalancer');
 } else {
     /* Keep a list of servers we find in POST variables */
     $newservers = array();
     foreach ($_POST as $name => $value) {
         /* Look through the POST vars to find the pool data */
         if (strpos($name, '|') !== false) {
             list($poolname, $ip) = explode("|", $name);
             $ip = str_replace('_', '.', $ip);
             $newservers[$poolname][] = $ip;
         } elseif (is_ipaddr($value)) {
             $newservers[$name][] = $value;
         }
     }
     foreach ($a_pool as &$pool) {
         if (is_array($pool['servers']) && is_array($pool['serversdisabled'])) {
             $oldservers = array_merge($pool['servers'], $pool['serversdisabled']);
         } elseif (is_array($pool['servers'])) {
             $oldservers = $pool['servers'];
         } elseif (is_array($pool['serversdisabled'])) {
             $oldservers = $pool['serversdisabled'];
         } else {
             $oldservers = array();
         }
         if (is_array($newservers[$pool['name']])) {
             $pool['servers'] = $newservers[$pool['name']];
开发者ID:mtisza,项目名称:pfsense,代码行数:31,代码来源:status_lb_pool.php

示例14: gettext

 }
 if (isset($_POST['wpa_gmk_rekey']) && (!is_numericint($_POST['wpa_gmk_rekey']) || $_POST['wpa_gmk_rekey'] < 1 || $_POST['wpa_gmk_rekey'] > 9999)) {
     $input_errors[] = gettext("Master Key Regeneration must be an integer between 1 and 9999.");
 }
 if (isset($_POST['wpa_group_rekey']) && isset($_POST['wpa_gmk_rekey'])) {
     if ($_POST['wpa_group_rekey'] > $_POST['wpa_gmk_rekey']) {
         $input_errors[] = gettext("Master Key Regeneration must be greater than Key Rotation.");
     }
 }
 if (!empty($_POST['auth_server_addr'])) {
     if (!is_domain($_POST['auth_server_addr']) && !is_ipaddr($_POST['auth_server_addr'])) {
         $input_errors[] = gettext("802.1X Authentication Server must be an IP or hostname.");
     }
 }
 if (!empty($_POST['auth_server_addr2'])) {
     if (!is_domain($_POST['auth_server_addr2']) && !is_ipaddr($_POST['auth_server_addr2'])) {
         $input_errors[] = gettext("Secondary 802.1X Authentication Server must be an IP or hostname.");
     }
 }
 if (!empty($_POST['auth_server_port'])) {
     if (!is_port($_POST['auth_server_port'])) {
         $input_errors[] = gettext("802.1X Authentication Server Port must be a valid port number (1-65535).");
     }
 }
 if (!empty($_POST['auth_server_port2'])) {
     if (!is_port($_POST['auth_server_port2'])) {
         $input_errors[] = gettext("Secondary 802.1X Authentication Server Port must be a valid port number (1-65535).");
     }
 }
 if (isset($_POST['channel']) && !is_numericint($_POST['channel'])) {
     if (!is_numericint($_POST['channel'])) {
开发者ID:simudream,项目名称:pfsense,代码行数:31,代码来源:interfaces.php

示例15: Check

 function Check()
 {
     if (!empty($this->target)) {
         // IP
         if (!empty($this->BlackList[0])) {
             $ips = is_ipaddr($this->target) ? array($this->target) : gethostbynamel($this->target);
             foreach ($ips as $ip) {
                 if ($this->RangeCheck($ip)) {
                     return true;
                 }
             }
         }
         // HOST
         if (!empty($this->BlackList[1])) {
             $host = gethostbyaddr($this->target);
             $len_host = strlen($host);
             foreach ($this->BlackList[1] as $x) {
                 // 後方一致のために、長さを確認
                 if (strlen($x) > $len_host) {
                     continue;
                 }
                 // 部分一致(後方一致)
                 if (stristr($host, $x) !== FALSE) {
                     return true;
                 }
             }
         }
     }
     // UA
     if (!empty($this->ua)) {
         foreach ($this->BlackList[2] as $x) {
             if ($this->ua == $x) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:38,代码来源:spamplus.php


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