wk_down
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by wk_down
-
-
I am working on a project for a friend where I need to pass a client's MAC address to a MySQL database. I am fairly new to PHP (I have read the W3 tutorial, some of the PHP.net manual and own O'Reilly's Learning PHP 5) and cannot find a solution. What I have so far is this:
Is there a better function to use than strspn()? Not sure if I can pass a variable and a wildcard mask in that function anyway. Like I said, not sure where I can go with this. Any help would be much appreciated!<?php/* Some code to establish connection to client */if ($user_os == "Windows") $ip_out = system('ipconfig /all'); $mac = strspn($ip_out, '??:??:??:??:??:??');elseif ($user_os == "Linux") { $ip_out = shell_exec() /* ... and so on *//* Code to pass $mac into MySQL database */?>
MAC Address via PHP
in PHP
Posted
I believe I have figured it out. I don't have my entire file finished yet so I haven't tested it, but here goes:
Basically, I would run some code to establish the OS of the client and pass that to $client_os. $output recieves the dump from the ipconfig/ifconfig command. $mac_pos determines the point right before the MAC address and then the substr() function throws it to $client_mac. Sounds good to me in theory. If anyone sees something I missed, please feel free to comment.