I want to make php page that make restriction that no one can use this page except from specific place(warehouse) so i want to get the mac address of the computer in the warehouse to compare it with the mac address of the client computers if it equal allow him to access this page , else prevent him , does any one can tell me how to get the mac address using php or javascript to do this task , also if there any idea to achieve this task without mac adrees?
I think this is not possible using JavaScript as it was not designed for such things. And if somehow you are able to do this using JavaScript, it will only work in IE using some ActiveX Objects and not in other browsers.
But I have found following PHP code. I have not tried this, but I think, you may get help from this.
function returnMacAddress()
{
// 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);
$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;
}
?>
PHP does not contain any built-in methods to acquire the MAC address of a connecting machine.
This file may give you something you can work with though:
http://phpclasses.promoxy.com/browse/file/7704.html
Although this relies on external Windows utilities so your web server must be a Windows server I believe.
Otherwise you might be able to code something in Python, but that will probably also be a Windows-specific solution.
Javascript definitely doesn't have anything like this.
I recommend NOT attempting to use this method of authentication because it is really inflexible. It would be better to use the IP address and Hostname as a basic auth method, then use an additional username/password auth method to keep your site private.