Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $username = 'admin';
  2. $password = 'PASSWORD!';
  3. $routerIp = '192.168.1.1'
  4. $context = stream_context_create(array(
  5. 'http' => array(
  6. 'header' => "Authorization: Basic " . base64_encode("$username:$password")
  7. )
  8. )
  9. );
  10. $data = file_get_contents("http://$routerIp/status-devices.asp", false, $context);
  11. //dhcpd_lease = [ ['Name-Of-Device','192.168.1.100','**:**:**:**:**:52','0 days, 19:37:18'],[ ... ],[ ... ]]
  12.  
  13. preg_match("/dhcpd_lease =(.+);\n/",$data,$list);
  14.  
  15. $found = substr(str_replace(array(' ',"'"),'',$list[1]),2,-2);
  16. $results = array();
  17. foreach(explode('],[',$found) as $single){
  18. $device = explode(',',$single);
  19. $singleDevice = array();
  20. $singleDevice['name'] = $device[0];
  21. $singleDevice['ip'] = $device[1];
  22. //key is the MAC address
  23. $results[$device[2]] = $singleDevice;
  24. }
  25. var_dump($results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement