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


PHP ip2ulong函数代码示例

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


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

示例1: save

 /**
  * Сохранение бана
  * @param array $data массив данных
  * @return null
  * @throws EngineException 
  */
 protected function save($data)
 {
     $admin_file = globals::g('admin_file');
     $id = (int) $data['id'];
     $cols = array('user' => 'username', 'email', 'ip_f', 'ip_t', 'reason', 'period', 'up' => 'update');
     extract(rex($data, $cols));
     $ip_f = ip2ulong($ip_f);
     $ip_t = ip2ulong($ip_t);
     $period = (double) $period;
     /* @var $etc etc */
     $etc = n("etc");
     $uid = 0;
     if ($user) {
         $r = $etc->select_user(null, $user, "id");
         $uid = $r["id"];
     }
     if (!$uid && !$email && !$ip_f && !$ip_t) {
         throw new EngineException("bans_nothing_banned");
     }
     $etc->ban_user($uid, !$id || $up ? $period : 0, $reason, $email, $ip_f, $ip_t, $id);
     if ($id) {
         $this->show($id);
         return;
     } else {
         furl::o()->location($admin_file);
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:33,代码来源:bans.php

示例2: sprintf

					break;
				}
			}

			/* make sure that the DHCP Relay isn't enabled on this interface */
			if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false))
				$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]);

			$dynsubnet_start = ip2ulong($_POST['range_from']);
			$dynsubnet_end = ip2ulong($_POST['range_to']);
			if (is_array($a_maps)) {
				foreach ($a_maps as $map) {
					if (empty($map['ipaddr']))
						continue;
					if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
						(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
						$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
						break;
					}
				}
			}
		}
	}

	if (!$input_errors) {
		if (!is_numeric($pool)) {
			if ($act == "newpool") {
				$dhcpdconf = array();
			} else {
				if (!is_array($config['dhcpd'][$if]))
					$config['dhcpd'][$if] = array();
开发者ID:Toudix,项目名称:core,代码行数:31,代码来源:services_dhcp.php

示例3: ip2ulong

         continue;
     }
     if ($mapent['hostname'] == $_POST['hostname'] && $mapent['hostname'] || $mapent['mac'] == $_POST['mac']) {
         $input_errors[] = "Bu sunucu adı, IP adresi veya MAC adresi zaten kayıtlı.";
         break;
     }
 }
 if ($_POST['ipaddr']) {
     $dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
     $dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
     if (ip2ulong($_POST['ipaddr']) >= $dynsubnet_start && ip2ulong($_POST['ipaddr']) <= $dynsubnet_end) {
         $input_errors[] = "Sabit IP adresi otomatik dağıtım aralığında olmamalıdır.";
     }
     $lansubnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
     $lansubnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | ~gen_subnet_mask_long($ifcfgsn)));
     if (ip2ulong($_POST['ipaddr']) < $lansubnet_start || ip2ulong($_POST['ipaddr']) > $lansubnet_end) {
         $input_errors[] = sprintf("IP adresi %s ağında bulunmalıdır.", $ifcfgdescr);
     }
 }
 if (!$input_errors) {
     $mapent = array();
     $mapent['mac'] = $_POST['mac'];
     $mapent['ipaddr'] = $_POST['ipaddr'];
     $mapent['hostname'] = $_POST['hostname'];
     $mapent['descr'] = base64_encode($_POST['descr']);
     if (isset($id) && $a_maps[$id]) {
         $a_maps[$id] = $mapent;
     } else {
         $a_maps[] = $mapent;
     }
     staticmaps_sort($if);
开发者ID:nuclewall,项目名称:nuclewall,代码行数:31,代码来源:services_dhcp_edit.php

示例4: sort_by_ip

function sort_by_ip($a, $b)
{
    return ip2ulong($a) < ip2ulong($b) ? -1 : 1;
}
开发者ID:8191,项目名称:opnsense-core,代码行数:4,代码来源:diag_states_summary.php

示例5: get_ips

 /**
  * Получение первого и второго IP
  * @param string $firstip первый IP
  * @param string $lastip второй IP
  * @param bool $long преобразовывать в long?
  * @return null
  */
 public function get_ips(&$firstip, &$lastip, $long = false)
 {
     if ($long) {
         $firstip = ip2ulong($firstip);
         $lastip = ip2ulong($lastip);
     } else {
         $ip_f = longval($ip_f);
         $ip_t = longval($ip_t);
     }
     if ($lastip && !$firstip) {
         $firstip = $lastip;
     }
     if ($firstip && !$lastip) {
         $lastip = $firstip;
     }
     if ($firstip > $lastip && $lastip) {
         $t = $firstip;
         $firstip = $lastip;
         $lastip = $t;
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:28,代码来源:class.etc.php

示例6: foreach

                     $data['if'] = $dhcpif;
                     break;
                 }
             }
         }
         /* exit as soon as we have an interface */
         if ($data['if'] != "") {
             break;
         }
     }
 } else {
     foreach ($dhcpd as $dhcpif => $dhcpifconf) {
         if (!is_array($dhcpifconf['range'])) {
             continue;
         }
         if ($lip >= ip2ulong($dhcpifconf['range']['from']) && $lip <= ip2ulong($dhcpifconf['range']['to'])) {
             $data['if'] = $dhcpif;
             break;
         }
     }
 }
 echo "<tr>\n";
 echo "<td class=\"listlr\">{$fspans}{$data['ip']}{$fspane}</td>\n";
 $mac = $data['mac'];
 $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
 if ($data['online'] != "online") {
     if (isset($mac_man[$mac_hi])) {
         // Manufacturer for this MAC is defined
         echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&amp;mac={$mac}\" title=\"" . gettext("{$mac} - send Wake on LAN packet to this MAC address") . "\">{$mac}</a><br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n";
     } else {
         echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&amp;mac={$data['mac']}\" title=\"" . gettext("send Wake on LAN packet to this MAC address") . "\">{$data['mac']}</a>{$fspane}</td>\n";
开发者ID:hlcherub,项目名称:core,代码行数:31,代码来源:status_dhcp_leases.php

示例7: get_ip

 /**
  * Получение беззнакового целого представления IP
  * @param string $ip строка с IP
  * @return int беззнаковое целое представление IP
  */
 public function get_ip($ip)
 {
     return ip2ulong($ip);
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:9,代码来源:cyberhype.php

示例8: gettext

                 $input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
                 break;
             }
         }
         /* make sure that the DHCP Relay isn't enabled on this interface */
         if (isset($config['dhcrelay']['enable']) && stristr($config['dhcrelay']['interface'], $if) !== false) {
             $input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."), $iflist[$if]);
         }
         $dynsubnet_start = ip2ulong($_POST['range_from']);
         $dynsubnet_end = ip2ulong($_POST['range_to']);
         if (is_array($a_maps)) {
             foreach ($a_maps as $map) {
                 if (empty($map['ipaddr'])) {
                     continue;
                 }
                 if (ip2ulong($map['ipaddr']) > $dynsubnet_start && ip2ulong($map['ipaddr']) < $dynsubnet_end) {
                     $input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
                     break;
                 }
             }
         }
     }
 }
 if (!$input_errors) {
     if (!is_numeric($pool)) {
         if ($act == "newpool") {
             $dhcpdconf = array();
         } else {
             if (!is_array($config['dhcpd'][$if])) {
                 $config['dhcpd'][$if] = array();
             }
开发者ID:karawan,项目名称:core,代码行数:31,代码来源:services_dhcp.php

示例9: etc

 * @version             1.00
 */
require_once './include/include_announce.php';
require_once ROOT . '/include/classes/class.etc.php';
$etc = new etc();
$a = array("passkey", "peer_id", "port", "uploaded", "ip", "left", "compact", "event", "info_hash", "no_peer_id");
$c = count($a);
extract(rex($_REQUEST, $a));
if ($_REQUEST['num want']) {
    $_REQUEST['numwant'] = $_REQUEST['num want'];
}
if ($_REQUEST['num_want']) {
    $_REQUEST['numwant'] = $_REQUEST['num_want'];
}
$numwant = (int) $_REQUEST['numwant'];
$ip = ip2ulong($ip ? $ip : $_SERVER['REMOTE_ADDR']);
if (!$ip) {
    $bt->err('Invalid IP.');
}
$info_hash = bin2hex($info_hash);
$seeder = $left > 0 ? '0' : '1';
$area = $seeder ? 'seeders' : 'leechers';
//$bt->err('Unknown user. Passkey - ' . print_r($_SERVER, true));
$itime = config::o()->v('announce_interval') * 60;
if (!$itime) {
    $bt->err('There\'s not an announce interval o_O.');
}
$q = db::o()->p($info_hash)->query('SELECT cid, ' . $area . ',downloaded FROM content_torrents WHERE
    info_hash=? AND banned="0" LIMIT 1');
list($torrent, $seedleech, $downloaded) = db::o()->fetch_row($q);
if (!$torrent) {
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:31,代码来源:announce.php

示例10: foreach

         }
         foreach ($a_pools as $id => $p) {
             if (is_numeric($pool) && $id == $pool) {
                 continue;
             }
             if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) || is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
                 $input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
                 break;
             }
         }
         /* make sure that the DHCP Relay isn't enabled on this interface */
         if (isset($config['dhcrelay']['enable']) && stristr($config['dhcrelay']['interface'], $if) !== false) {
             $input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."), $iflist[$if]);
         }
         $dynsubnet_start = ip2ulong($_POST['range_from']);
         $dynsubnet_end = ip2ulong($_POST['range_to']);
     }
 }
 if (!$input_errors) {
     if (!is_numeric($pool)) {
         if ($act == "newpool") {
             $dhcpdconf = array();
         } else {
             if (!is_array($config['dhcpd'][$if])) {
                 $config['dhcpd'][$if] = array();
             }
             $dhcpdconf = $config['dhcpd'][$if];
         }
     } else {
         if (is_array($a_pools[$pool])) {
             $dhcpdconf = $a_pools[$pool];
开发者ID:mtisza,项目名称:pfsense,代码行数:31,代码来源:services_dhcp.php

示例11: array

                $slease = array();
                $slease['ip'] = $static['ipaddr'];
                $slease['act'] = "static";
                $slease['staticmap_array_index'] = $staticmap_array_index;
                $leases[] = $slease;
                $staticmap_array_index++;
            }
        }
    }
    $ifcfgip = get_interface_ip($dhcpif);
    $ifcfgsn = get_interface_subnet($dhcpif);
    $subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
    $subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | ~gen_subnet_mask_long($ifcfgsn)));
    $result['range'] = ip2ulong($config['dhcpd'][$dhcpif]['range']['to']) - ip2ulong($config['dhcpd'][$dhcpif]['range']['from']);
    foreach ($leases as $data) {
        $lip = ip2ulong($data['ip']);
        if ($data['act'] != "active" && $data['act'] != "static" && $_GET['all'] != 1) {
            continue;
        }
        if ($data['act'] != "static") {
            if ($lip >= ip2ulong($config['dhcpd'][$dhcpif]['range']['from']) && $lip <= ip2ulong($config['dhcpd'][$dhcpif]['range']['to'])) {
                $result['active'] = $result['active'] + 1;
            }
        } else {
            if ($lip >= $subnet_start && $lip <= $subnet_end) {
                $result['static'] = $result['static'] + 1;
            }
        }
    }
}
echo $result['active'] . ":" . $result['static'] . ":" . $result['range'];
开发者ID:sjourdois,项目名称:pfsense,代码行数:31,代码来源:dhcpd_gather_stats.php

示例12: search_ip

 /**
  * Функция для поиска IP вида 127.0.0.*
  * @param string $ip IP адрес
  * @param string $column столбец поиска
  * @return string условие, если верные IP
  */
 public function search_ip($ip, $column = 'ip')
 {
     if (!$column) {
         $column = 'ip';
     }
     $ip1 = ip2ulong(str_replace("*", "0", $ip));
     $ip2 = ip2ulong(str_replace("*", "255", $ip));
     $column = '`' . $column . '`';
     if ($ip1 && $ip2) {
         return '(' . $column . '<=' . $ip2 . ' AND ' . $column . '>=' . $ip1 . ')';
     } else {
         return '';
     }
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:20,代码来源:class.search.php

示例13: foreach

            $staticmap_array_index = 0;
            foreach ($config['dhcpd'][$ifname]['staticmap'] as $static) {
                $slease = array();
                $slease['ip'] = $static['ipaddr'];
                $slease['act'] = "static";
                $slease['staticmap_array_index'] = $staticmap_array_index;
                $leases[] = $slease;
                $staticmap_array_index++;
            }
        }
    }
    $ifcfgip = get_interface_ip($dhcpif);
    $ifcfgsn = get_interface_subnet($dhcpif);
    $subnet_start = gen_subnetv4($ifcfgip, $ifcfgsn);
    $subnet_end = gen_subnetv4_max($ifcfgip, $ifcfgsn);
    $result['range'] = ip2ulong($config['dhcpd'][$dhcpif]['range']['to']) - ip2ulong($config['dhcpd'][$dhcpif]['range']['from']);
    foreach ($leases as $data) {
        if ($data['act'] != "active" && $data['act'] != "static" && $_GET['all'] != 1) {
            continue;
        }
        if ($data['act'] != "static") {
            if (is_inrange_v4($data['ip'], $config['dhcpd'][$dhcpif]['range']['from'], $config['dhcpd'][$dhcpif]['range']['to'])) {
                $result['active'] = $result['active'] + 1;
            }
        } else {
            if (is_inrange_v4($data['ip'], $subnet_start, $subnet_end)) {
                $result['static'] = $result['static'] + 1;
            }
        }
    }
}
开发者ID:hexaclock,项目名称:pfsense,代码行数:31,代码来源:dhcpd_gather_stats.php

示例14: gettext

     $reqdfields[] = 'tunnel_network';
     $reqdfieldsn[] = gettext('Tunnel network');
 } else {
     if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network']) {
         $input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
     }
     if ($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end'] || !$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end']) {
         $input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined.");
     }
     if ($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start'])) {
         $input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address.");
     }
     if ($pconfig['serverbridge_dhcp_end'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_end'])) {
         $input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address.");
     }
     if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end'])) {
         $input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end).");
     }
 }
 do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
 if (count($input_errors) == 0) {
     // validation correct, save data
     $server = array();
     // delete(rename) old interface so a new TUN or TAP interface can be created.
     if (isset($id) && $pconfig['dev_mode'] != $a_server[$id]['dev_mode']) {
         openvpn_delete('server', $a_server[$id]);
     }
     // 1 on 1 copy of config attributes
     $copy_fields = "mode,protocol,dev_mode,local_port,description,crypto,digest,engine\n\t\t\t\t\t\t,tunnel_network,tunnel_networkv6,remote_network,remote_networkv6\n\t\t\t\t\t\t,gwredir,local_network,local_networkv6,maxclients,compression\n\t\t\t\t\t\t,passtos,client2client,dynamic_ip,pool_enable,topology_subnet\n\t\t\t\t\t\t,serverbridge_dhcp,serverbridge_interface,serverbridge_dhcp_start\n\t\t\t\t\t\t,serverbridge_dhcp_end,dns_domain,dns_server1,dns_server2,dns_server3\n\t\t\t\t\t\t,dns_server4,push_register_dns,ntp_server1,ntp_server2,netbios_enable\n\t\t\t\t\t\t,netbios_ntype,netbios_scope,no_tun_ipv6,verbosity_level,wins_server1\n\t\t\t\t\t\t,wins_server2,client_mgmt_port";
     foreach (explode(",", $copy_fields) as $fieldname) {
         $fieldname = trim($fieldname);
开发者ID:aya,项目名称:core,代码行数:31,代码来源:vpn_openvpn_server.php

示例15: get_ip

 /**
  * Получение IP пользователя
  * @param bool $longed в ip2ulong
  * @return string|int IP в формате целого числа, либо 4 чисел с точками
  */
 public function get_ip($longed = true)
 {
     $ip = $_SERVER['REMOTE_ADDR'] == "::1" ? "127.0.0.1" : $_SERVER['REMOTE_ADDR'];
     return $longed ? ip2ulong($ip) : $ip;
 }
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:10,代码来源:class.users.php


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