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


PHP ip_long函数代码示例

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


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

示例1: ip_last

function ip_last($net)
{
    list($ip, $cidr) = explode('/', $net);
    $mask = '';
    for ($i = 1; $i < 33; $i++) {
        if ($i > $cidr) {
            $mask .= '1';
        }
    }
    $add = bindec($mask);
    return ip_long($ip) + $add;
    //$last_long=dechex(ip_long($ip)+$add);
    //return hexdec(substr($last_long,0,2)).'.'.hexdec(substr($last_long,2,2)).'.'.hexdec(substr($last_long,4,2)).'.'.hexdec(substr($last_long,6,2));
}
开发者ID:runcz,项目名称:lvip,代码行数:14,代码来源:index.php

示例2: GetNetworkRecord

    public function GetNetworkRecord($id, $page = 0, $plimit = 4294967296, $firstfree = false)
    {
        $network = $this->db->GetRow('SELECT no.ownerid, ne.id, ne.name, inet_ntoa(ne.address) AS address,
                ne.address AS addresslong, ne.mask, ne.interface, ne.gateway, ne.dns, ne.dns2,
                ne.domain, ne.wins, ne.dhcpstart, ne.dhcpend, ne.hostid,
                mask2prefix(inet_aton(ne.mask)) AS prefix, ne.notes,
                inet_ntoa(broadcast(ne.address, inet_aton(ne.mask))) AS broadcast
            FROM networks ne
            LEFT JOIN nodes no ON (no.netid = ne.id AND no.ipaddr = 0 AND no.ipaddr_pub = 0)
            WHERE ne.id = ?', array($id));
        if ($network['ownerid']) {
            $customer_manager = new LMSCustomerManager($this->db, $this->auth, $this->cache, $this->syslog);
            $network['customername'] = $customer_manager->GetCustomerName($network['ownerid']);
        }
        $nodes = $this->db->GetAllByKey('
				SELECT id, name, ipaddr, ownerid, netdev 
				FROM vnodes WHERE netid = ? AND ipaddr > ? AND ipaddr < ?
				UNION ALL
				SELECT id, name, ipaddr_pub AS ipaddr, ownerid, netdev 
				FROM vnodes WHERE ipaddr_pub > ? AND ipaddr_pub < ?', 'ipaddr', array($id, $network['addresslong'], ip_long($network['broadcast']), $network['addresslong'], ip_long($network['broadcast'])));
        if ($network['hostid']) {
            $network['hostname'] = $this->db->GetOne('SELECT name FROM hosts WHERE id=?', array($network['hostid']));
        }
        $network['size'] = pow(2, 32 - $network['prefix']);
        $network['assigned'] = sizeof($nodes);
        $network['free'] = $network['size'] - $network['assigned'] - 2;
        if ($network['dhcpstart']) {
            $network['free'] = $network['free'] - (ip_long($network['dhcpend']) - ip_long($network['dhcpstart']) + 1);
        }
        if (!$plimit) {
            $plimit = 256;
        }
        $network['pages'] = ceil($network['size'] / $plimit);
        if ($page > $network['pages']) {
            $page = $network['pages'];
        }
        if ($page < 1) {
            $page = 1;
        }
        $page--;
        while (1) {
            $start = $page * $plimit;
            $end = $network['size'] > $plimit ? $start + $plimit : $network['size'];
            $network['pageassigned'] = 0;
            unset($network['nodes']);
            for ($i = 0; $i < $end - $start; $i++) {
                $longip = (string) ($network['addresslong'] + $i + $start);
                $network['nodes']['addresslong'][$i] = $longip;
                $network['nodes']['address'][$i] = long2ip($longip);
                if (isset($nodes[$longip])) {
                    $network['nodes']['id'][$i] = $nodes[$longip]['id'];
                    $network['nodes']['netdev'][$i] = $nodes[$longip]['netdev'];
                    $network['nodes']['ownerid'][$i] = $nodes[$longip]['ownerid'];
                    $network['nodes']['name'][$i] = $nodes[$longip]['name'];
                    $network['pageassigned']++;
                } else {
                    $network['nodes']['id'][$i] = 0;
                    if ($longip == $network['addresslong']) {
                        $network['nodes']['name'][$i] = '<b>NETWORK</b>';
                    } elseif ($network['nodes']['address'][$i] == $network['broadcast']) {
                        $network['nodes']['name'][$i] = '<b>BROADCAST</b>';
                    } elseif ($network['nodes']['address'][$i] == $network['gateway']) {
                        $network['nodes']['name'][$i] = '<b>GATEWAY</b>';
                    } elseif ($longip >= ip_long($network['dhcpstart']) && $longip <= ip_long($network['dhcpend'])) {
                        $network['nodes']['name'][$i] = '<b>DHCP</b>';
                    } else {
                        $freenode = true;
                    }
                }
            }
            if ($firstfree && !isset($freenode)) {
                if ($page + 1 >= $network['pages']) {
                    break;
                }
                $page++;
            } else {
                break;
            }
        }
        $network['rows'] = ceil(sizeof($network['nodes']['address']) / 4);
        $network['page'] = $page + 1;
        return $network;
    }
开发者ID:pjona,项目名称:lms,代码行数:83,代码来源:LMSNetworkManager.php

示例3: isipinstrict

function isipinstrict($ip, $net, $mask)
{
    if (ip_long($ip) >= ip_long(getnetaddr($net, $mask)) && ip_long($ip) <= ip_long(getbraddr($net, $mask))) {
        return true;
    } else {
        return false;
    }
}
开发者ID:pcela,项目名称:lms,代码行数:8,代码来源:common.php

示例4: elseif

        } elseif (!isipin($netadd['dhcpstart'], getnetaddr($netadd['address'], prefix2mask($netadd['prefix'])), prefix2mask($netadd['prefix'])) && $netadd['address'] != '') {
            $error['dhcpstart'] = trans('IP address for DHCP range start does not match with network address!');
        }
    }
    if ($netadd['dhcpend'] != '') {
        if (!check_ip($netadd['dhcpend'])) {
            $error['dhcpend'] = trans('Incorrect IP address for DHCP range end!');
        } elseif (!isipin($netadd['dhcpend'], getnetaddr($netadd['address'], prefix2mask($netadd['prefix'])), prefix2mask($netadd['prefix'])) && $netadd['address'] != '') {
            $error['dhcpend'] = trans('IP address for DHCP range end does not match with network address!');
        }
    }
    if (!isset($error['dhcpstart']) && !isset($error['dhcpend'])) {
        if ($netadd['dhcpstart'] != '' && $netadd['dhcpend'] == '' || $netadd['dhcpstart'] == '' && $netadd['dhcpend'] != '') {
            $error['dhcpend'] = trans('Both IP addresses for DHCP range are required!');
        }
        if ($netadd['dhcpstart'] != '' && $netadd['dhcpend'] != '' && !(ip_long($netadd['dhcpend']) >= ip_long($netadd['dhcpstart']))) {
            $error['dhcpend'] = trans('End of DHCP range has to be equal or greater than start!');
        }
    }
    if (!empty($netadd['ownerid']) && !$LMS->CustomerExists($netadd['ownerid'])) {
        $error['ownerid'] = trans('Customer with the specified ID does not exist');
    }
    if (!$error) {
        $SESSION->redirect('?m=netinfo&id=' . $LMS->NetworkAdd($netadd));
    }
    $SMARTY->assign('error', $error);
    $SMARTY->assign('netadd', $netadd);
} elseif (isset($_GET['ownerid'])) {
    if ($LMS->CustomerExists($_GET['ownerid']) == true) {
        $netadd['ownerid'] = $_GET['ownerid'];
        $SMARTY->assign('netadd', $netadd);
开发者ID:itav,项目名称:lms,代码行数:31,代码来源:netadd.php

示例5: trans

		else
			if(!isipin($networkdata['dhcpstart'],getnetaddr($networkdata['address'],prefix2mask($networkdata['prefix'])),prefix2mask($networkdata['prefix'])) && $networkdata['address']!='')
				$error['dhcpstart'] = trans('IP address for DHCP range start does not match with network address!');

	if($networkdata['dhcpend']!='')
		if(!check_ip($networkdata['dhcpend']))
			$error['dhcpend'] =  trans('Incorrect IP address for DHCP range end!');
		else
			if(!isipin($networkdata['dhcpend'],getnetaddr($networkdata['address'],prefix2mask($networkdata['prefix'])),prefix2mask($networkdata['prefix'])) && $networkdata['address']!='')
				$error['dhcpend'] = trans('IP address for DHCP range end does not match with network address!');
	
	if(!isset($error['dhcpstart']) && !isset($error['dhcpend']))
	{
		if(($networkdata['dhcpstart']!='' && $networkdata['dhcpend']=='')||($networkdata['dhcpstart']=='' && $networkdata['dhcpend']!=''))
			$error['dhcpend'] = trans('Both IP addresses for DHCP range are required!');
		if($networkdata['dhcpstart']!='' && $networkdata['dhcpend']!='' && !(ip_long($networkdata['dhcpend']) >= ip_long($networkdata['dhcpstart'])))
			$error['dhcpend'] = trans('End of DHCP range has to be equal or greater than start!');
	}
	
	if(!$error)
	{
	        if(isset($networkdata['needshft']) && $networkdata['needshft'])
		        $LMS->NetworkShift($network['address'],$network['mask'],$networkdata['addresslong'] - $network['addresslong']);

		$LMS->NetworkUpdate($networkdata);
		$SESSION->redirect('?m=netinfo&id='.$networkdata['id']);
	}	

	$network['interface'] = $networkdata['interface'];
	$network['prefix'] = $networkdata['prefix'];
	$network['address'] = $networkdata['address'];
开发者ID:rzt,项目名称:lms,代码行数:31,代码来源:netedit.php

示例6: GetTransactions

    function GetTransactions($params)
    {
        $key = isset($params['key']) && !empty($params['key']) ? $params['key'] : '';
        $value = isset($params['value']) && preg_match('/^[0-9]+$/', $params['value']) ? $params['value'] : '';
        $propname = isset($params['propname']) && !empty($params['propname']) ? $params['propname'] : '';
        $propvalue = isset($params['propvalue']) && !empty($params['propvalue']) ? $params['propvalue'] : '';
        $userid = isset($params['userid']) && !empty($params['userid']) ? intval($params['userid']) : 0;
        $offset = isset($params['offset']) && !empty($params['offset']) ? intval($params['offset']) : 0;
        $limit = isset($params['limit']) && !empty($params['limit']) ? intval($params['limit']) : 20;
        $order = isset($params['order']) && preg_match('/ASC/i', $params['order']) ? 'ASC' : 'DESC';
        $datefrom = isset($params['datefrom']) && !empty($params['datefrom']) ? intval($params['datefrom']) : 0;
        $dateto = isset($params['dateto']) && !empty($params['dateto']) ? intval($params['dateto']) : 0;
        $resource = isset($params['resource']) && !empty($params['resource']) ? $params['resource'] : 0;
        switch ($propname) {
            case 'ipaddr':
            case 'ipaddr_pub':
                if (check_ip($propvalue)) {
                    $propvalue = ip_long($propvalue);
                }
                break;
        }
        $args = array();
        $where = array();
        $joins = array();
        if ($key != '' && strval($value) != '') {
            $joins[] = 'JOIN logmessagekeys lmk ON lmk.logmessageid = lm.id';
            $where[] = 'lmk.name = ? AND lmk.value ' . (empty($value) ? '>' : '=') . ' ?';
            $args[] = $key;
            $args[] = $value;
        }
        if ($propname != '' && $propvalue != '') {
            $joins[] = 'JOIN logmessagedata lmd ON lmd.logmessageid = lm.id';
            $where[] = 'lmd.name = ? AND lmd.value ?LIKE? ?';
            $args[] = $propname;
            $args[] = '%' . $propvalue . '%';
        }
        if ($resource) {
            $where[] = 'lm.resource = ?';
            $args[] = $resource;
        }
        if ($userid) {
            $where[] = 'lt.userid = ?';
            $args[] = $userid;
        }
        if ($datefrom) {
            $where[] = 'lt.time >= ?';
            $args[] = $datefrom;
        }
        if ($dateto) {
            $where[] = 'lt.time <= ?';
            $args[] = $dateto;
        }
        $trans = $this->DB->GetAll('SELECT DISTINCT lt.id, lt.time, lt.userid, u.login, lt.module FROM logtransactions lt
			JOIN logmessages lm ON lm.transactionid = lt.id 
			LEFT JOIN users u ON u.id = lt.userid ' . implode(' ', $joins) . (!empty($where) ? ' WHERE ' . implode(' AND ', $where) : '') . ' ORDER BY lt.id ' . $order . ' LIMIT ' . $limit . (!empty($offset) ? ' OFFSET ' . $offset : ''), $args);
        return $trans;
    }
开发者ID:Akheon23,项目名称:lms,代码行数:57,代码来源:SYSLOG.class.php

示例7: GetMACs

 function GetMACs()
 {
     $result = array();
     if ($this->CONFIG['phpui']['arp_table_backend'] != '') {
         exec($this->CONFIG['phpui']['arp_table_backend'], $result);
         foreach ($result as $arpline) {
             list($ip, $mac) = explode(' ', $arpline);
             $result['mac'][] = $mac;
             $result['ip'][] = $ip;
             $result['longip'][] = ip_long($ip);
             $result['nodename'][] = $this->GetNodeNameByMAC($mac);
         }
     } else {
         switch (PHP_OS) {
             case 'Linux':
                 if (@is_readable('/proc/net/arp')) {
                     $file = fopen('/proc/net/arp', 'r');
                 } else {
                     break;
                 }
                 while (!feof($file)) {
                     $line = fgets($file, 4096);
                     $line = preg_replace('/[\\t ]+/', ' ', $line);
                     if (preg_match('/[0-9]/', $line)) {
                         // skip header line
                         list($ip, $hwtype, $flags, $hwaddr, $mask, $device) = explode(' ', $line);
                         if ($flags != '0x6' && $hwaddr != '00:00:00:00:00:00' && check_mac($hwaddr)) {
                             $result['mac'][] = $hwaddr;
                             $result['ip'][] = $ip;
                             $result['longip'][] = ip_long($ip);
                             $result['nodename'][] = $this->GetNodeNameByMAC($hwaddr);
                         }
                     }
                 }
                 fclose($file);
                 break;
             default:
                 exec('arp -an|grep -v incompl', $result);
                 foreach ($result as $arpline) {
                     list($fqdn, $ip, $at, $mac, $hwtype, $perm) = explode(' ', $arpline);
                     $ip = str_replace('(', '', str_replace(')', '', $ip));
                     if ($perm != "PERM") {
                         $result['mac'][] = $mac;
                         $result['ip'][] = $ip;
                         $result['longip'][] = ip_long($ip);
                         $result['nodename'][] = $this->GetNodeNameByMAC($mac);
                     }
                 }
                 break;
         }
     }
     return $result;
 }
开发者ID:bochniak,项目名称:lms,代码行数:53,代码来源:LMS.class.php

示例8: trans

 $LMS->PaymentAdd($paymentdata);
 echo ' [OK]<BR>';
 echo '<B>' . trans('Generating host...') . '</B>';
 flush();
 $DB->Execute('INSERT INTO hosts (name, description) VALUES(?, ?)', array('test', 'test host'));
 $hostid = $DB->GetLastInsertID('hosts');
 echo ' [OK]<BR>';
 echo '<B>' . trans('Generating network...') . '</B>';
 flush();
 $prefix = $_GET['l'] * 2 > 1024 ? 16 : 22;
 $netdata = array('name' => 'LAN1', 'address' => '192.168.0.0', 'prefix' => $prefix, 'gateway' => '192.168.0.1', 'dns' => '192.168.0.1', 'dns2' => '192.168.3.254', 'domain' => 'ultralan.net', 'wins' => '192.168.0.2', 'dhcpstart' => '192.168.3.230', 'dhcpend' => '192.168.3.253', 'interface' => 'eth0', 'hostid' => $hostid, 'notes' => '');
 $netid = $LMS->NetworkAdd($netdata);
 echo ' [OK]<BR>';
 echo '<B>' . trans('Generating customers...') . '</B>';
 flush();
 $startip = ip_long('192.168.0.0') + 1;
 $cnt = 0;
 $lnsize = sizeof($lastnames);
 $nsize = sizeof($names);
 $nodsize = sizeof($nodenames);
 $ppsize = sizeof($phoneprefix);
 $ssize = sizeof($streets);
 $esize = sizeof($emaildomains);
 for ($i = 0; $i < sprintf('%d', $_GET['l']); $i++) {
     $customeradd['lastname'] = $lastnames[mt_rand(0, $lnsize - 1)];
     $customeradd['name'] = $names[mt_rand(0, $nsize - 1)];
     $customeradd['phone'] = $phoneprefix[mt_rand(0, $ppsize - 1)];
     for ($j = 0; $j < 6; $j++) {
         $customeradd['phone'] .= mt_rand(0, 9);
     }
     $street = mt_rand(0, $ssize - 1);
开发者ID:jarecky,项目名称:lms,代码行数:31,代码来源:genfake.php

示例9: intval

    $filtertype = 'nodeid';
    $filtervalue = intval($_GET['nodeid']);
    $type = 0;
}
$SESSION->save('nslfiltertype', $filtertype);
$SESSION->save('nslfiltervalue', $filtervalue);
$where = array();
if (!empty($type)) {
    $where[] = '(s.type & ' . intval($type) . ') > 0';
}
$where[] = 's.start > ' . $datefrom . ' AND s.stop < ' . $dateto;
if (!empty($filtertype)) {
    switch ($filtertype) {
        case 'ip':
            if (check_ip($filtervalue)) {
                $where[] = 's.ipaddr = ' . ip_long($filtervalue);
            } else {
                $filtervalue = '';
            }
            break;
        case 'mac':
            if (check_mac($filtervalue)) {
                $where[] = 's.mac = \'' . $filtervalue . '\'';
            } else {
                $filtervalue = '';
            }
            break;
        case 'customer':
            $where[] = '(c.name ?LIKE? ' . $DB->Escape("%{$filtervalue}%") . ' OR c.lastname ?LIKE? ' . $DB->Escape("%{$filtervalue}%") . ')';
            break;
        case 'nodeid':
开发者ID:itav,项目名称:lms,代码行数:31,代码来源:nodesessionlist.php

示例10: GetNetworkPageForIp

 public function GetNetworkPageForIp($netid, $ip)
 {
     $netmask = $this->db->GetOne('SELECT mask FROM networks WHERE id = ?', array($netid));
     $net = ip_long(getnetaddr($ip, $netmask));
     $ip = ip_long($ip);
     $page = floor(($ip - $net) / ConfigHelper::getConfig('phpui.networkhosts_pagelimit')) + 1;
     return $page;
 }
开发者ID:prezeskk,项目名称:lms,代码行数:8,代码来源:LMSNetworkManager.php


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