本文整理汇总了PHP中prefix2mask函数的典型用法代码示例。如果您正苦于以下问题:PHP prefix2mask函数的具体用法?PHP prefix2mask怎么用?PHP prefix2mask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prefix2mask函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: VerifyHost
function VerifyHost($hosts = '')
{
if (!$hosts) {
return TRUE;
}
$allowedlist = explode(',', $hosts);
$isin = FALSE;
foreach ($allowedlist as $value) {
$net = '';
$mask = '';
if (strpos($value, '/') === FALSE) {
$net = $value;
} else {
list($net, $mask) = explode('/', $value);
}
$net = trim($net);
$mask = trim($mask);
if ($mask == '') {
$mask = '255.255.255.255';
} elseif (is_numeric($mask)) {
$mask = prefix2mask($mask);
}
if (isipinstrict($this->ip, $net, $mask)) {
return TRUE;
}
}
return FALSE;
}
示例2: trans
$error['gateway'] = trans('Incorrect gateway IP address!');
} elseif (!isipin($netadd['gateway'], getnetaddr($netadd['address'], prefix2mask($netadd['prefix'])), prefix2mask($netadd['prefix']))) {
$error['gateway'] = trans('Specified gateway address does not match with network address!');
}
}
if ($netadd['dhcpstart'] != '') {
if (!check_ip($netadd['dhcpstart'])) {
$error['dhcpstart'] = trans('Incorrect IP address for DHCP range start!');
} 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) {
示例3: NetworkAdd
public function NetworkAdd($netadd)
{
global $SYSLOG_RESOURCE_KEYS;
if ($netadd['prefix'] != '') {
$netadd['mask'] = prefix2mask($netadd['prefix']);
}
$netadd['name'] = strtoupper($netadd['name']);
$args = array('name' => $netadd['name'], 'address' => $netadd['address'], 'mask' => $netadd['mask'], 'interface' => strtolower($netadd['interface']), 'gateway' => $netadd['gateway'], 'dns' => $netadd['dns'], 'dns2' => $netadd['dns2'], 'domain' => $netadd['domain'], 'wins' => $netadd['wins'], 'dhcpstart' => $netadd['dhcpstart'], 'dhcpend' => $netadd['dhcpend'], 'notes' => $netadd['notes'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_HOST] => $netadd['hostid']);
if ($this->db->Execute('INSERT INTO networks (name, address, mask, interface, gateway,
dns, dns2, domain, wins, dhcpstart, dhcpend, notes, hostid)
VALUES (?, inet_aton(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args))) {
$netid = $this->db->GetOne('SELECT id FROM networks WHERE address = inet_aton(?) AND hostid = ?', array($netadd['address'], $netadd['hostid']));
if ($this->syslog && $netid) {
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_NETWORK]] = $netid;
$keys = array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_NETWORK], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_HOST]);
if ($netadd['ownerid']) {
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST]] = $netadd['ownerid'];
$keys[] = $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST];
$this->db->Execute('INSERT INTO nodes (name, ownerid, netid) VALUES(?, ?, ?)', array($netadd['name'], $netadd['ownerid'], $netid));
}
$this->syslog->AddMessage(SYSLOG_RES_NETWORK, SYSLOG_OPER_ADD, $args, $keys);
}
return $netid;
} else {
return FALSE;
}
}
示例4: trans
else
if(!isipin($networkdata['gateway'],getnetaddr($networkdata['address'],prefix2mask($networkdata['prefix'])),prefix2mask($networkdata['prefix'])))
$error['gateway'] = trans('Specified gateway address does not match with network address!');
if($networkdata['dhcpstart']!='')
if(!check_ip($networkdata['dhcpstart']))
$error['dhcpstart'] = trans('Incorrect IP address for DHCP range start!');
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']);
示例5: NetworkAdd
function NetworkAdd($netadd)
{
if ($netadd['prefix'] != '') {
$netadd['mask'] = prefix2mask($netadd['prefix']);
}
if ($this->DB->Execute('INSERT INTO networks (name, address, mask, interface, gateway,
dns, dns2, domain, wins, dhcpstart, dhcpend, notes, hostid, ipnat)
VALUES (?, inet_aton(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(strtoupper($netadd['name']), $netadd['address'], $netadd['mask'], strtolower($netadd['interface']), $netadd['gateway'], $netadd['dns'], $netadd['dns2'], $netadd['domain'], $netadd['wins'], $netadd['dhcpstart'], $netadd['dhcpend'], $netadd['notes'], $netadd['hostid'] ? $netadd['hostid'] : NULL, $netadd['ipnat'] ? $netadd['ipnat'] : ''))) {
return $this->DB->getLastInsertId('networks');
} else {
return FALSE;
}
}
示例6: NetworkAdd
function NetworkAdd($netadd)
{
if ($netadd['prefix'] != '') {
$netadd['mask'] = prefix2mask($netadd['prefix']);
}
if ($this->DB->Execute('INSERT INTO networks (name, address, mask, interface, gateway,
dns, dns2, domain, wins, dhcpstart, dhcpend, notes)
VALUES (?, inet_aton(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(strtoupper($netadd['name']), $netadd['address'], $netadd['mask'], strtolower($netadd['interface']), $netadd['gateway'], $netadd['dns'], $netadd['dns2'], $netadd['domain'], $netadd['wins'], $netadd['dhcpstart'], $netadd['dhcpend'], $netadd['notes']))) {
return $this->DB->GetOne('SELECT id FROM networks WHERE address = inet_aton(?)', array($netadd['address']));
} else {
return FALSE;
}
}
示例7: NetworkAdd
public function NetworkAdd($netadd)
{
if ($netadd['prefix'] != '') {
$netadd['mask'] = prefix2mask($netadd['prefix']);
}
$netadd['name'] = strtoupper($netadd['name']);
$args = array('name' => $netadd['name'], 'address' => $netadd['address'], 'mask' => $netadd['mask'], 'interface' => strtolower($netadd['interface']), 'gateway' => $netadd['gateway'], 'dns' => $netadd['dns'], 'dns2' => $netadd['dns2'], 'domain' => $netadd['domain'], 'wins' => $netadd['wins'], 'dhcpstart' => $netadd['dhcpstart'], 'dhcpend' => $netadd['dhcpend'], 'notes' => $netadd['notes'], 'vlanid' => intval($netadd['vlanid']), SYSLOG::RES_HOST => $netadd['hostid'], 'authtype' => $netadd['authtype']);
if ($this->db->Execute('INSERT INTO networks (name, address, mask, interface, gateway,
dns, dns2, domain, wins, dhcpstart, dhcpend, notes, vlanid, hostid, authtype)
VALUES (?, inet_aton(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args))) {
$netid = $this->db->GetLastInsertID('networks');
if (!$netid) {
return false;
}
if ($this->syslog) {
$this->syslog->AddMessage(SYSLOG::RES_NETWORK, SYSLOG::OPER_ADD, $args);
}
if ($netadd['ownerid']) {
$args = array('name' => $netadd['name'], SYSLOG::RES_CUST => $netadd['ownerid'], SYSLOG::RES_NETWORK => $netid);
$this->db->Execute('INSERT INTO nodes (name, ownerid, netid) VALUES(?, ?, ?)', array_values($args));
if ($this->syslog) {
$this->syslog->AddMessage(SYSLOG::RES_NODE, SYSLOG::OPER_ADD, $args);
}
}
return $netid;
} else {
return false;
}
}