I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
All you need to do is to put arp into diferrent group.
Default:
With command:
you will get:
And because apache is a daemon running under the user www-data, it's now able to execute this command.
So if you now use a PHP script, e.g.:
you will get the output of linux
arp -an
command.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.
The MAC address of a client (in the sense of the computer that issued the HTTP request) is overwritten by every router between the client and the server.
Client IP is conveniently provided to the script in
$_SERVER['REMOTE_ADDR']
. In some scenarios, particularly if your web server is behind a proxy (i.e. a caching proxy)$_SERVER['REMOTE ADDR']
will return the IP of the proxy, and there will be an extra value, often$_SERVER['HTTP_X_FORWARDED_FOR']
, that contains the IP of the original request client.Sometimes, particularly when you're dealing with an anonymizing proxy that you don't control, the proxy won't return the real IP address, and all you can hope for is the IP address of the proxy.
I don't think you can get MAC address in PHP, but you can get IP from
$_SERVER['REMOTE_ADDR']
variable.This works for me on Windows, as
ipconfig /all
is Windows system command.You can use the following solution to solve your problem: