473,745 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting mac address of client machines

pradeepjain
563 Contributor
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function returnmacaddress() {
  3. // This code is under the GNU Public Licence
  4. // Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
  5. // Tested only on linux, please report bugs
  6.  
  7. // WARNING: the commands 'which' and 'arp' should be executable
  8. // by the apache user; on most linux boxes the default configuration
  9. // should work fine
  10.  
  11. // get the arp executable path
  12. $location = 'which arp';
  13. $location = rtrim($location);
  14. // Execute the arp command and store the output in $arpTable
  15. $arpTable = '$location -n';
  16. // Split the output so every line is an entry of the $arpSplitted array
  17. $arpSplitted = split("\n",$arpTable);
  18. // get the remote ip address (the ip address of the client, the browser)
  19. $remoteIp = $_SERVER['REMOTE_ADDR'];
  20. $remoteIp = str_replace(".", "\\.", $remoteIp);
  21. // Cicle the array to find the match with the remote ip address
  22. foreach ($arpSplitted as $value) {
  23. // Split every arp line, this is done in case the format of the arp
  24. // command output is a bit different than expected
  25. $valueSplitted = split(" ",$value);
  26. foreach ($valueSplitted as $spLine) {
  27. if (preg_match("/$remoteIp/",$spLine)) {
  28. $ipFound = true;
  29. }
  30. // The ip address has been found, now rescan all the string
  31. // to get the mac address
  32. if ($ipFound) {
  33. // Rescan all the string, in case the mac address, in the string
  34. // returned by arp, comes before the ip address
  35. // (you know, Murphy's laws)
  36. reset($valueSplitted);
  37. foreach ($valueSplitted as $spLine) {
  38. if (preg_match("/[0-9a-f][0-9a-f][:-]".
  39. "[0-9a-f][0-9a-f][:-]".
  40. "[0-9a-f][0-9a-f][:-]".
  41. "[0-9a-f][0-9a-f][:-]".
  42. "[0-9a-f][0-9a-f][:-]".
  43. "[0-9a-f][0-9a-f]/i",$spLine)) {
  44. return $spLine;
  45. }
  46. }
  47. }
  48. $ipFound = false;
  49. }
  50. }
  51. return false;
  52. }
  53. echo returnmacaddress();
  54. ?>
I found this code by googling! But its not printing anything!! :(
Sep 10 '09 #1
29 37502
Dormilich
8,658 Recognized Expert Moderator Expert
then it’s probably returning false, which does not have a print representation (check with var_dump()).
Sep 10 '09 #2
pradeepjain
563 Contributor
@Dormilich
I did not get u!! :( !i have never used var_dump()!!
Sep 10 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
@pradeepjain
shame on you, that’s probably the #1 debugging function in PHP. see ref.
Sep 10 '09 #4
pradeepjain
563 Contributor
@Dormilich
okie!!i will learn now!!thanks for the comments !!
Sep 10 '09 #5
pradeepjain
563 Contributor
I tried to print the $location value!!! it had nothin in it!!!
Sep 10 '09 #6
Dormilich
8,658 Recognized Expert Moderator Expert
@pradeepjain
where did you try to print it?
Sep 10 '09 #7
pradeepjain
563 Contributor
after this line

Expand|Select|Wrap|Line Numbers
  1. $location = rtrim($location);
Sep 10 '09 #8
Dormilich
8,658 Recognized Expert Moderator Expert
may I see the code?

my output:
Expand|Select|Wrap|Line Numbers
  1. // formatted through xdebug
  2. string 'which arp' (length=9)
Sep 10 '09 #9
pradeepjain
563 Contributor
@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!
Sep 10 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
1707
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: ..... void SetValueFromPoiner(int *new_value)
1
1442
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 Version 7.0 to 2000? Thank you in advance! Eddy
4
30926
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 having problems seem to be missing RegAsm.exe from their machines, and the .Net dll is not being registered correctly (no tlb file is being created), causing an error saying "ActiveX cannot create object" when trying to create an object from the type library. What do the clients need to do to get...
7
14350
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 is set to low. If it is set to high it throws an error "Automation server cant create object". Can aneonle help me on how to sign the ActiveX control??? coz i think dats what is creating the problem??/
2
2204
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 hours of coding is running into security issue when trying the new application on a client machine. (I'm a domain admin on the client/network) and apparantly the problem is in the very first lines of code in my
5
2184
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 property field to file:///C:\Inetpub\wwwroot\Demo\webimages\b2pentagons2.bmp Any problem about it? How to make a change for it? Thanks
3
4106
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 reduce the MTU size of all my outbound client web requests to 1470. I've done a bit of searching on the topic, and it is apparent to me that this can only be set at the client machine level through a registry modification, not through my application itself. Is this correct? Is there a way that my c#...
5
3023
omerbutt
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 gives me 127.0.0.1 where as i want such figure 203933791. i am using the ip database regards Omer Aslam
1
1547
by: kenny doel | last post by:
How to get IP list of a client machines in a network
0
8795
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9486
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9277
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8218
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6057
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3286
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.