0

I wanted mac(system physical address) address of client and i got it but when i hosted in server am not getting anything.

The code i used for getting mac address is :

ob_start();  

system('ipconfig /all');  

$mycomsys=ob_get_contents();  

ob_clean();  

$find_mac = "LAN Card"; 

$pmac = strpos($mycomsys, $find_mac); 

$macaddress=substr($mycomsys,($pmac+49),17);  

echo $macaddress;  

I dont known where am going wrong. Plesae help me to fix this.

Noopur Dabhi
  • 1,687
  • 25
  • 37
Ashok
  • 1
  • 6
  • php is executed BEFORE the html code is sent to the browser. In this case you are trying to get the mac address of the server. – jeff Dec 22 '17 at 11:57
  • 1
    Refer this : https://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php – Rahul Rana Dec 22 '17 at 12:02
  • I am trying to get system physical of client – Ashok Dec 22 '17 at 12:12
  • Duplicate question https://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php – Reinstate Monica Cellio Dec 22 '17 at 12:28
  • Possible duplicate of [How can I get the MAC and the IP address of a connected client in PHP?](https://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php) – Jonnix Dec 22 '17 at 14:58

2 Answers2

0

What system is running on your server? If it is not Windows, other systems (Linux etc.) don't understand the /all. If it is Windows, beware that the server card need not be called "LAN Card". First look at the full output of ifconfig.

-1

If you use windows server. Then try this code.

<?php
ob_start();  

system('ipconfig /all');  

$mycomsys=ob_get_contents();  

ob_clean();  

$find_mac = "Physical Address"; 

$pmac = strpos($mycomsys, $find_mac); 

$macaddress=substr($mycomsys,($pmac+35),17);  

echo $macaddress;  
rubyshine72
  • 132
  • 1
  • 6
  • This gets the MAC address of the server, not of the client, which is what he requested. – RJK Dec 22 '17 at 12:10
  • So do you want get mac address of client? – rubyshine72 Dec 22 '17 at 12:10
  • If you want to get mac address of client, it is available only on intranet. – rubyshine72 Dec 22 '17 at 12:11
  • That is what is asked in the question - **I wanted mac(system physical address) address of client** – RJK Dec 22 '17 at 12:11
  • You can get mac address of intranet users. but can not get of internet users through router. – rubyshine72 Dec 22 '17 at 12:12
  • The client MAC address it not available to a server, this is because the source and destination MAC address in the packets header is changed at every hop, therefore the MAC is only significant to the local network segment. – RJK Dec 22 '17 at 12:13
  • i have used the same code and its working well and good in localhost but when i hosted on server its not getting – Ashok Dec 22 '17 at 12:13
  • Sorry Ashok, but it is not possible to get the clients MAC address, purely because the information is not available within the packet that is received by the server, and the protocol that acquires it, Address Resolution Protocol, is only able to send the broadcast out on the local network segment – RJK Dec 22 '17 at 12:14
  • Yeah, its code only work on localhost, but it doesn`t work with users access thourgh router. – rubyshine72 Dec 22 '17 at 12:14
  • actually i wanted users to login only through there allocated systems only and inside some predefined premises (ex : like office only).How can i get this – Ashok Dec 22 '17 at 12:19
  • You must try another method. On http protocol, it is impossible. – rubyshine72 Dec 22 '17 at 12:23
  • ok can anyone please suggest me how to do it like "actually i wanted users to login only through there allocated systems only and inside some predefined premises (ex : like office only).How can i get this" – Ashok Dec 22 '17 at 12:46