Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2.  
  3. function get_mac_address1() {
  4. exec("ipconfig /all", $arr, $retval);
  5. $arr[14];
  6. $ph = explode(":", $arr[14]);
  7. return trim($ph[1]);
  8. }
  9.  
  10. function get_mac_address2() {
  11. ob_start(); // Turn on output buffering
  12. system('ipconfig /all'); //Execute external program to display output
  13. $mycom = ob_get_contents(); // Capture the output into a variable
  14. ob_clean(); // Clean (erase) the output buffer
  15.  
  16. $findme = 'Physical';
  17. $pmac = strpos($mycom, $findme); // Find the position of Physical text
  18. $mac = substr($mycom, ($pmac + 36), 17); // Get Physical Address
  19. return $mac;
  20. }
  21.  
  22. echo "<pre>";
  23.  
  24. echo get_mac_address1(), PHP_EOL;
  25.  
  26. echo get_mac_address2(), PHP_EOL;
  27.  
  28. echo "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement