The code below is how to obtain the Mac Address.
Impossible to award another network, PHP engine and Windows NT machines in the underlying
MAC Addr can get through the Microsoft NetBEUI protocol
class NtMacAddress {
function getMac ($ what) {
$ what = & strtolower ($ what);
if ($ what == 'server') {
return $ this-> __server_macaddress ();
}
elseif ($ what == 'client') {
return $ this-> __client_macaddress ();
}
else {
return'' client 'or' server '?';
}
}
function __ server_macaddress () {
$ output = Array ();
exec ('netstat-r', $ output);
for ($ a = 0, $ b = & count ($ output); $ a <$ b; $ a + +) {
if (preg_match ("/ (? i) ([a-z0-9] {2}) {6} /", $ output [$ a]) == true) {
$ macaddress = & $ output [$ a];
$ uniquekey = & md5 ($ macaddress);
$ output [$ a] = & preg_replace ("/ (? i) ([^ a-z0-9] *?) ([a-z0-9] {2}) {6} / i", "1 {$ uniquekey} ", $ output [$ a]);
$ output [$ a] = & explode ("{$ uniquekey}", $ output [$ a]);
$ uniquekey = Array (trim ($ output [$ a] [0]), trim ($ output [$ a] [1]));
$ macaddress = & str_replace ($ uniquekey, "", $ macaddress);
return trim ($ macaddress);
}
}
return 'not found';
}
function __ client_macaddress () {
$ output = Array ();
exec ('nbtstat-A'. $ _SERVER ['REMOTE_ADDR'], $ output);
$ reg = '([a-f0-9] {2} -) {5} ([a-f0-9] {2})';
for ($ a = 0, $ b = & count ($ output); $ a <$ b; $ a + +) {
if (preg_match ("/ (? i) {$ reg} /", $ output [$ a]) == true) {
return preg_replace ("/ (? iU) (. +) ({$ reg}) (. *) /", "2", $ output [$ a]);
}
}
return 'not found';
}
}
/ / How to ..
$ mac = & new NtMacAddress ();
echo 'SERVER MAC:'. $ mac-> getMac ('server'). '
CLIENT MAC: '. $ Mac-> getMac (' client ');
>
No comments:
Post a Comment