Logic 1 :
<?php
/*
* Getting MAC Address using PHP
* Mr. Vetrivel Samidurai
*/
ob_start(); // Turn on output buffering
system('ipconfig /all'); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer
$findme = "Physical";
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address
echo $mac;
?>
Logic 2 :
$ipAddress=$_SERVER['REMOTE_ADDR'];
#here U can run external command
$arp=`arp -a $ipAddress`;
$lines=explode("n", $arp);
#looking up the arp U need
foreach($lines as $line){
$cols=preg_split('/s+/', trim($line));
if ($cols[0]==$ipAddress)
$macAddr=$cols[1];
}
1 comment:
Thanks!!!,First logic is working,But Second one is not working..
Post a Comment