Regarding display of mac address of a system

Reply

Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Regarding display of mac address of a system

 
0
  #1
Apr 6th, 2009
How to get Ip address and MAC address of system for an IP address i tried this code

echo $ip=GetHostByName($REMOTE_ADDR);
But after uploading through FTP i'm getting Server ip But i want local system IP can any one solve problem.
Last edited by peter_budo; Apr 6th, 2009 at 3:52 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 164
Reputation: rm_daniweb is an unknown quantity at this point 
Solved Threads: 10
rm_daniweb rm_daniweb is offline Offline
Junior Poster

Re: Regarding display of mac address of a system

 
0
  #2
Apr 6th, 2009
Originally Posted by srilakshmitr7 View Post
How to get Ip address and MAC address of system for an IP address i tried this code

echo $ip=GetHostByName($REMOTE_ADDR);

But after uploading through FTP i'm getting Server ip But i want local system IP can any one solve problem.
try this...
http://www.webmasterworld.com/forum88/4312.htm
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Re: Regarding display of mac address of a system

 
0
  #3
Apr 7th, 2009
I already tried this it is showing error as $ipFound as undefined variable.Is there any other solution?
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 164
Reputation: rm_daniweb is an unknown quantity at this point 
Solved Threads: 10
rm_daniweb rm_daniweb is offline Offline
Junior Poster

Re: Regarding display of mac address of a system

 
0
  #4
Apr 7th, 2009
Originally Posted by srilakshmitr7 View Post
I already tried this it is showing error as $ipFound as undefined variable.Is there any other solution?
<?php

returnMacAddress($location) //type the location here

function returnMacAddress($location) {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
// Tested only on linux, please report bugs

// WARNING: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine

// Get the arp executable path
//$location = `which arp`;
$location = rtrim($location);
// Execute the arp command and store the output in $arpTable
$arpTable = `$location -n`;
// Split the output so every line is an entry of the $arpSplitted array
$arpSplitted = split("\n",$arpTable);
// Get the remote ip address (the ip address of the client, the browser)
$remoteIp = $GLOBALS['REMOTE_ADDR'];
$remoteIp = str_replace(".", "\\.", $remoteIp);
// Cicle the array to find the match with the remote ip address
foreach ($arpSplitted as $value) {
// Split every arp line, this is done in case the format of the arp
// command output is a bit different than expected
$valueSplitted = split(" ",$value);
foreach ($valueSplitted as $spLine) {
if (preg_match("/$remoteIp/",$spLine)) {
$ipFound = true;
}
// The ip address has been found, now rescan all the string
// to get the mac address
if ($ipFound) {
// Rescan all the string, in case the mac address, in the string
// returned by arp, comes before the ip address
// (you know, Murphy's laws)
reset($valueSplitted);
foreach ($valueSplitted as $spLine) {
if (preg_match("/[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f]/i",$spLine)) {
return $spLine;
}
}
}
$ipFound = false;
}
}
return false;
} 
?>

NOTE: // WARNING: the commands 'which' and 'arp' should be executable // by the apache user; on most linux boxes the default configuration
// should work fine


are you using LAMP?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Re: Regarding display of mac address of a system

 
0
  #5
Apr 7th, 2009
No I am using IIS Server.Is this problem will show effect to this server.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC