I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?
I don't think you can get MAC address in PHP, but you can get IP from $_SERVER['REMOTE_ADDR']
variable.
In windows, If the user is using your script locally, it will be very simple :
<?php
// get all the informations about the client's network
$ipconfig = shell_exec ("ipconfig/all"));
// display those informations
echo $ipconfig;
/*
look for the value of "physical adress" and use substr() function to
retrieve the adress from this long string.
here in my case i'm using a french cmd.
you can change the numbers according adress mac position in the string.
*/
echo substr(shell_exec ("ipconfig/all"),1821,18);
?>
Perhaps getting the Mac address is not the best approach for verifying a client's machine over the internet. Consider using a token instead which is stored in the client's browser by an administrator's login.
Therefore the client can only have this token if the administrator grants it to them through their browser. If the token is not present or valid then the client's machine is invalid.
under linux using iptables you can log to a file each request to web server with mac address and ip. from php lookup last item with ip address and get mac address.
As stated remember that the mac address is from last router on the trace.
Use this class (https://github.com/BlakeGardner/php-mac-address)
This is a PHP class for MAC address manipulation on top of Unix, Linux and Mac OS X operating systems. it was primarily written to help with spoofing for wireless security audits.
For windows server I think u can use this:
<?php
echo exec('getmac');
?>