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


PHP is_private_ip函数代码示例

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


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

示例1:

                 $duplicate_peer = TRUE;
             } else {
                 // Neither IP nor Domain exist
                 $duplicate_peer = FALSE;
             }
         } else {
             $duplicate_peer = TRUE;
         }
     } else {
         // Using IP only, is there a duplicate
         if (empty($duplicate_check1) == TRUE) {
             if ($my_server_domain == $peer_domain || empty($duplicate_check2) == FALSE) {
                 $duplicate_peer = TRUE;
             } else {
                 // Check for non-private IP range
                 if (is_private_ip($peer_IP, $allow_lan_peers) == FALSE) {
                     // Neither IP nor Domain exist
                     $duplicate_peer = FALSE;
                 } else {
                     $duplicate_peer = TRUE;
                 }
             }
         } else {
             $duplicate_peer = TRUE;
         }
     }
 }
 if ($duplicate_peer == FALSE) {
     // Save only domain name if both IP and Domain exist
     if (empty($peer_domain) == FALSE) {
         $peer_IP = NULL;
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:peerlist.php

示例2: is_domain_valid

function is_domain_valid($domain)
{
    $result = TRUE;
    if (empty($domain) == TRUE) {
        $result = FALSE;
    }
    if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == TRUE) {
        $result = FALSE;
    }
    if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) == TRUE) {
        $result = FALSE;
    }
    if (is_private_ip($domain) == FALSE) {
        $result = FALSE;
    }
    if (strtolower($domain) == "localhost") {
        $result = FALSE;
    }
    return $result;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:20,代码来源:function.php

示例3: gethostbyname

 $domain_fail = FALSE;
 // Reset Variable
 if (empty($peer_domain) == FALSE) {
     // Check if the hostname and IP fields actually match
     // and not made up or unrelated.
     $dns_ip = gethostbyname($peer_domain);
     if ($dns_ip != $peer_ip) {
         // No match between Domain IP and Encoded IP
         $domain_fail = TRUE;
     } else {
         $domain_fail = FALSE;
     }
 }
 // Does the public key half match what is encrypted in the 3rd crypt field from
 // the same peer?
 if ($arr1[0] == $gen_key_crypt && empty($peer_ip) == FALSE && empty($IP_exist1) == TRUE && $domain_fail == FALSE && is_private_ip($peer_ip) == FALSE) {
     if ($delete_request == "DELETE_IP") {
         // Delete my IP and any public key linked to it as it belongs to a previous unknown owner
         mysql_query("DELETE FROM `generating_peer_list` WHERE `generating_peer_list`.`IP_Address` = '{$peer_ip}' LIMIT 1");
         write_log("DELETE IP Request ({$peer_ip}) was allowed for Public Key: " . base64_encode($public_key), "GP");
     } else {
         // My server has moved to another IP, update the list
         mysql_query("UPDATE `generating_peer_list` SET `IP_Address` = '{$peer_ip}' WHERE `generating_peer_list`.`public_key` = '{$public_key}' LIMIT 1");
         write_log("New Generation Peer IP Address ({$peer_ip}) was updated for Public Key: " . base64_encode($public_key), "GP");
     }
 } else {
     if (my_public_key() == $public_key) {
         if (election_cycle(1) == TRUE) {
             if (empty($IP_exist1) == TRUE) {
                 mysql_query("UPDATE `generating_peer_list` SET `IP_Address` = '{$peer_ip}' WHERE `generating_peer_list`.`public_key` = '{$public_key}' LIMIT 1");
                 write_log("Generation Peer List was updated with My New IP Address ({$peer_ip})", "GP");
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:genpeer.php

示例4: is_private_ip

    $iponly = $remoteip;
}
function is_private_ip($ip)
{
    if (empty($ip) or !ip2long($ip)) {
        return NULL;
    }
    $private_ips = array(array('10.0.0.0', '10.255.255.255'), array('172.16.0.0', '172.31.255.255'), array('192.168.0.0', '192.168.255.255'));
    $ip = ip2long($ip);
    foreach ($private_ips as $ipr) {
        $min = ip2long($ipr[0]);
        $max = ip2long($ipr[1]);
        if ($ip >= $min && $ip <= $max) {
            return true;
        }
    }
    return false;
}
if (is_private_ip($iponly) || $iponly == "0.0.0.0") {
    $ip = $remoteip . $port;
}
$remoteip = $remoteip . $port;
//	$querystring="SELECT * FROM serverinfo WHERE ip LIKE '$ip' AND timestamp > NOW() - INTERVAL 10 MINUTE";
//	$result=OCmysql_query($querystring);
//	$rowsreturned=mysql_num_rows($result);
//	if($rowsreturned==0){
OCmysql_query("INSERT INTO serverinfo SET ip='{$ip}', timestamp_firstseen=NOW() ON DUPLICATE KEY UPDATE timestamp=NOW(), remoteip='{$remoteip}' , hostname='{$hostname}',version='{$version}',game='{$game}',map='{$map}',players='{$players}',maxplayers='{$maxplayers}',\tfromext='1' , postdataext='" . mysql_real_escape_string("HEADER:::: " . json_encode(getallheaders()) . " \$_REQUEST::serverinfoext.php:: " . json_encode($_REQUEST)) . "'");
//	}
//aggregate players is in funcaggregateplayrecount.php
echo "success serverinfoext";
echo json_encode($_REQUEST) . "INSERT INTO serverinfo SET ip='{$ip}', timestamp_firstseen=NOW() ON DUPLICATE KEY UPDATE timestamp=NOW(), remoteip='{$remoteip}' , hostname='{$hostname}',version='{$version}',game='{$game}',map='{$map}',players='{$players}',maxplayers='{$maxplayers}',\tfromext='1' ";
开发者ID:Will-Scarlet,项目名称:War3Source,代码行数:31,代码来源:serverinfoext.php

示例5: sipstation_get_config

function sipstation_get_config($account_key, $online = true, $filter_sections = array())
{
    global $db;
    global $ast_codec_hash;
    global $codec_array;
    if (!empty($account_key)) {
        $json_array = array();
        $xml_parser = sipstation_get_settings($account_key, $online);
        if (!empty($xml_parser->data)) {
            foreach ($xml_parser->data['xml'] as $key => $value) {
                switch ($key) {
                    case 'xml_version':
                    case 'query_status':
                    case 'query_status_message':
                    case 'sip_username':
                    case 'sip_password':
                    case 'num_trunks':
                    case 'monthly_cost':
                    case 'cid_format':
                    case 'nat_troubleshooting':
                        if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) {
                            continue;
                        }
                        $json_array[$key] = trim("{$value}");
                        break;
                    case 'gateways':
                    case 'e911_address':
                    case 'registered_status':
                        if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) {
                            continue;
                        }
                        foreach ($value as $key2 => $value2) {
                            if (is_array($value2)) {
                                foreach ($value2 as $gw => $value3) {
                                    $json_array[$key][$key2][$gw] = $value3 ? trim($value3) : '';
                                }
                            } else {
                                $json_array[$key][$key2] = $value2 ? trim($value2) : '';
                            }
                        }
                        if ($key == 'registered_status') {
                            foreach ($value as $key2 => $value2) {
                                if (is_array($value2)) {
                                    if ($value2['contact_ip'] == $value2['network_ip']) {
                                        $json_array[$key][$key2]['ips_match'] = 'yes';
                                    } else {
                                        $json_array[$key][$key2]['ips_match'] = is_private_ip($value2['contact_ip']) ? 'private' : 'no';
                                    }
                                } else {
                                    if ($key2 != 'registered') {
                                        continue;
                                    }
                                    if ($json_array[$key]['contact_ip'] == $json_array[$key]['network_ip'] && $value2 == 'yes') {
                                        $json_array[$key]['ips_match'] = 'yes';
                                    } else {
                                        $json_array[$key]['ips_match'] = 'no';
                                        $json_array[$key]['ips_match'] = is_private_ip($json_array[$key]['contact_ip']) ? 'private' : 'no';
                                    }
                                }
                            }
                        }
                        break;
                    case 'dids':
                        if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) {
                            continue;
                        }
                        if (!empty($value['did']) && !is_array($value['did'])) {
                            $tmp = $value['did'];
                            unset($value['did']);
                            $value['did'][] = $tmp;
                            $single = true;
                        } else {
                            $single = false;
                        }
                        $idx = 0;
                        foreach ($value['did'] as $did) {
                            $path = $single ? "/xml/dids/did" : "/xml/dids/did/{$idx}";
                            $idx++;
                            $failover = $xml_parser->attributes[$path]['failover'];
                            $did = trim($did);
                            $exten = core_did_get($did);
                            if (empty($exten)) {
                                $json_array[$key][$did] = array('destination' => 'blank', 'desc' => _("Not Set"), 'description' => '', 'failover' => "{$failover}");
                            } else {
                                $dest_results = framework_identify_destinations($exten['destination']);
                                if (is_array($dest_results[$exten['destination']])) {
                                    /* This is really bad but the calls to core_users get are so heavy and core_users_list don't give details
                                         that we will do this for now and deal with it later.
                                       */
                                    $user_cid_hash = array();
                                    $sql = "SELECT `extension`, `outboundcid` FROM `users`";
                                    $user_cids = $db->getAll($sql, DB_FETCHMODE_ASSOC);
                                    if (DB::IsError($user_cids)) {
                                        freepbx_debug("Failed trying to get user cids");
                                        freepbx_debug($user_cids->getMessage());
                                        $user_cids = array();
                                    }
                                    foreach ($user_cids as $item) {
                                        $user_cid_hash[$item['extension']] = $item['outboundcid'];
                                    }
//.........这里部分代码省略.........
开发者ID:hardikk,项目名称:HNH,代码行数:101,代码来源:sipstation.utility.php

示例6: array

 $natent['interface'] = $if2;
 $natent['destination']['any'] = true;
 $natent['natport'] = "";
 $a_out[] = $natent;
 $natent = array();
 $natent['source']['network'] = "127.0.0.0/8";
 $natent['dstport'] = "";
 $natent['descr'] = sprintf(gettext('Auto created rule for localhost to %1$s'), $ifdesc2);
 $natent['target'] = "";
 $natent['interface'] = $if2;
 $natent['destination']['any'] = true;
 $natent['staticnatport'] = false;
 $natent['natport'] = "1024:65535";
 $a_out[] = $natent;
 /* PPTP subnet */
 if ($config['pptpd']['mode'] == "server" && is_private_ip($config['pptpd']['remoteip'])) {
     $pptptopip = $config['pptpd']['n_pptp_units'] - 1;
     $pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip']) + $pptptopip));
     foreach ($pptp_subnets as $pptpsn) {
         $natent = array();
         $natent['source']['network'] = $pptpsn;
         $natent['sourceport'] = "";
         $natent['descr'] = gettext("Auto created rule for PPTP server");
         $natent['target'] = "";
         $natent['interface'] = $if2;
         $natent['destination']['any'] = true;
         $natent['natport'] = "";
         $a_out[] = $natent;
     }
 }
 /* PPPoE subnet */
开发者ID:rdmenezes,项目名称:pfsense,代码行数:31,代码来源:firewall_nat_out.php


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