本文整理汇总了PHP中check_mac函数的典型用法代码示例。如果您正苦于以下问题:PHP check_mac函数的具体用法?PHP check_mac怎么用?PHP check_mac使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_mac函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: macformat
function macformat($mac, $escape=false)
{
global $DB;
$res = str_replace('-', ':', $mac);
// allow eg. format "::ab:3::12", only whole addresses
if(preg_match('/^([0-9a-f]{0,2}):([0-9a-f]{0,2}):([0-9a-f]{0,2}):([0-9a-f]{0,2}):([0-9a-f]{0,2}):([0-9a-f]{0,2})$/i', $mac, $arr))
{
$res = '';
for($i=1; $i<=6; $i++)
{
if($i > 1) $res .= ':';
if(strlen($arr[$i]) == 1) $res .= '0';
if(strlen($arr[$i]) == 0) $res .= '00';
$res .= $arr[$i];
}
}
else // other formats eg. cisco xxxx.xxxx.xxxx or parts of addresses
{
$tmp = preg_replace('/[^0-9a-f]/i', '', $mac);
if(strlen($tmp) == 12) // we've the whole address
if(check_mac($tmp))
$res = $tmp;
}
if ($escape)
$res = $DB->Escape("%$res%");
return $res;
}
示例2: trans
$error['ipaddr_pub'] = trans('Specified IP address is in use!');
} elseif ($ip != $nodeedit['ipaddr_pub'] && $LMS->IsIPGateway($nodeedit['ipaddr_pub'])) {
$error['ipaddr_pub'] = trans('Specified IP address is network gateway!');
}
} else {
$error['ipaddr_pub'] = trans('Specified IP address doesn\'t overlap with any network!');
}
} else {
$error['ipaddr_pub'] = trans('Incorrect IP address!');
}
} else {
$nodeedit['ipaddr_pub'] = '0.0.0.0';
}
$macs = array();
foreach ($nodeedit['macs'] as $key => $value) {
if (check_mac($value)) {
if ($value != '00:00:00:00:00:00' && !ConfigHelper::checkConfig('phpui.allow_mac_sharing')) {
if (($nodeid = $LMS->GetNodeIDByMAC($value)) != NULL && $nodeid != $nodeinfo['id']) {
$error['mac' . $key] = trans('Specified MAC address is in use!');
}
}
$macs[] = $value;
} elseif ($value != '') {
$error['mac' . $key] = trans('Incorrect MAC address!');
}
}
if (empty($macs)) {
$error['mac0'] = trans('MAC address is required!');
}
$nodeedit['macs'] = $macs;
if ($nodeedit['name'] == '') {
示例3: 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;
}
示例4: array
$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':
if (intval($filtervalue)) {
$where[] = 's.nodeid = ' . intval($filtervalue);
} else {
$filtervalue = '';
}
break;