Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I am access mac address using php code.
But display this error : NetBIOS over Tcpip. . . . . . . . : Disabled
please give your suggestion.

PHP
<?php
/**
access to network card MAC address of the original code; Currently supported Windows/LINUX system
get the machine card physical (MAC) address
**/
class GetMacAddr
{
var $return_array=array();//returns an array of strings with the MAC address
var $mac_addr;
function GetMacAddr ($os_type) {
switch ($os_type) {
case "Linux" :
$this -> ForLinux();
break;
case "solaris" :
break;
case "Unix" :
break;
case "wins" :
$this -> ForWindows();
break;
default:
 echo"plz select os";
break;

} $temp_array=array();
foreach ($this ->return_array as $value) {
if (
preg_match("/[0-9 a - f] [0-9] a - f [-] ". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f/I", $value,
$temp_array)) {
$this ->Mac_addr=$temp_array [0];
break;

}}
unset ($temp_array);
return $this ->Mac_addr;

} function forWindows () {
	//echo "wisn";
@exec("ipconfig/all", $this ->return_array);// interchange to echo instead of @ then display //error. 
if ($this -> return_array)
return $this ->Return_array;
else {
$ipconfig=$_SERVER["WINDIR"]."\system32\ipconfig.exe";
if (is_file ($ipconfig))
echo exec($ipconfig."/all", $this ->return_array);
else
@exec($_SERVER["WINDIR"]."\system\ipconfig.exe/all", $this -> return_array);
return $this -> Return_array;
}}
function forLinux () {
@exec("ifconfig -a", $this ->return_array);
return $this ->Return_array;

}}

//method using the
$MAC=new GetMacAddr("wins");

print_r($MAC ->Mac_addr);

?>
Posted
Updated 23-Jan-14 18:24pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900