Hii,
I need to know is there any way to get the mac id's of the machines accessing ma site! I want to make a access lock using the mac id's -
<?php
-
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);
-
// get the remote ip address (the ip address of the client, the browser)
-
$remoteIp = $_SERVER['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;
-
}
-
echo returnmacaddress();
-
?>
I found this code by googling! But its not printing anything!! :(
why should the system ID / CPU ID be submitted? you can’t read what’s not provided.
if those computers have static IPs, you can use those.
29 37250
then it’s probably returning false, which does not have a print representation (check with var_dump()).
@Dormilich
I did not get u!! :( !i have never used var_dump()!!
@pradeepjain
shame on you, that’s probably the #1 debugging function in PHP. see ref. @Dormilich
okie!!i will learn now!!thanks for the comments !!
I tried to print the $location value!!! it had nothin in it!!!
after this line - $location = rtrim($location);
may I see the code?
my output: - // formatted through xdebug
-
string 'which arp' (length=9)
@Dormilich
sorry for the mistake i am also getting 'which arp' ...
i dono y he he is using 'which arp ' here! i am not getting the logic in that code! so i am facing problem!
hasn’t there been a description?
besides the code usage looks odd.
this is what I found somewhere else and looks way more sensible. - $mac = `ping $ip && arp -a | grep $ip`;
@Dormilich
okie thanks for help!will give it a try!
- <?php
-
$ip = '192.168.2.213';
-
-
$mac = `ping $ip && arp -a | grep $ip`;
-
echo $mac;
-
?>
i wrote this code !!its printing nothing! i am getting an error in error log like
ping: icmp open socket: Permission denied when i run this code!
to know what arp does go to a posix machine (linux, unix, bsd, mac), open a terminal (on linux you can also use ALT+F2), type
hit enter and read the description.
@pradeepjain
that’s always the problem with shell commands, you need permission.
so we cannot generally find the MAC id's of a machine connected to net as one of the problems will be permission!
do you get the same result if you try - $mac = `arp -a | grep $ip`;
?
then you can’t do anything about it (although the concept is right)
is there any parameter by which we can recognize a system over internet ?
recognize in what kind of way?
like suppose if that system is accessing ma website its should be identified by unique thing specific to that comp! bcos we need to lock our website for a few ips' of outside internet!
what is a "comp", company, computer, competitor?
do you mean allow certain IPs or exclude certain IPs?
sorry for shortcuts..i mean to say a computer /pc
is there anything specific about allowed/denied computers/clients?
its like the website will be accessed at only 2 places say 2 hospitals so need to lock them to those places!
IS there no solution for this problem . like i am using all linux machines . cant i uniquely identify the system accessing it .something like system ID / CPU ID.
why should the system ID / CPU ID be submitted? you can’t read what’s not provided.
if those computers have static IPs, you can use those.
nope !! but they use laptops for accessing the site. so they dont have a static IP's .
This functionality will work on a local network, but not the internet as the MAC is hidden by the clients router.
In short, the MAC is not present in the IP packet header.
You can retrieve the client IP address via <?php echo $_SERVER['REMOTE_ADDR']; ?> however this is not 100% accurate because of IP address spoofing.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Marchello |
last post by:
Hi All.
I will try to explain my question on following example:
Having class CInteger (wraper on 'int' values):
class CInteger
{
public:...
|
by: eddiekwang |
last post by:
Hello,
Is it necessary to upgrade the Client Connectivity Tools on all client
machines after the SQL Server database server is upgraded from...
|
by: Sean |
last post by:
I've developed a VB6 application that uses a VB.Net dll. When
distributed to client machines it works fine except for a few cases.
The clients...
|
by: navin123 |
last post by:
Im writing a code to retirve the mac address of the client. I hv the javascript dat retrives the mac address.. but it works only id the IE's security...
|
by: =?Utf-8?B?S2plbGw=?= |
last post by:
Hi
I'm new to C# and .Net so be nice :-)
I'm going throught a steep learing curve right now and finding it really
hard when after several...
|
by: =?Utf-8?B?ZGF2aWQ=?= |
last post by:
I used Visual Studio .NEt 2003 to develop a web form in which there is a bmp
format image. I used WebControls.Image in Design and set ImageUrl...
|
by: =?Utf-8?B?R2xlbm4gVGhpbW1lcw==?= |
last post by:
Hello,
I have a c# application hitting an asp.net web service. .net 2.0
I have been told by a customer of mine that it is necessary that I...
|
by: omerbutt |
last post by:
can any body tell me the right code to get the client ip address,i have tried these two ways
//$ip=@$REMOTE_ADDR;
$ip=$_SERVER;
but it...
|
by: kenny doel |
last post by:
How to get IP list of a client machines in a network
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |