Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $username = 'admin';
- $password = 'PASSWORD!';
- $routerIp = '192.168.1.1'
- $context = stream_context_create(array(
- 'http' => array(
- 'header' => "Authorization: Basic " . base64_encode("$username:$password")
- )
- )
- );
- $data = file_get_contents("http://$routerIp/status-devices.asp", false, $context);
- //dhcpd_lease = [ ['Name-Of-Device','192.168.1.100','**:**:**:**:**:52','0 days, 19:37:18'],[ ... ],[ ... ]]
- preg_match("/dhcpd_lease =(.+);\n/",$data,$list);
- $found = substr(str_replace(array(' ',"'"),'',$list[1]),2,-2);
- $results = array();
- foreach(explode('],[',$found) as $single){
- $device = explode(',',$single);
- $singleDevice = array();
- $singleDevice['name'] = $device[0];
- $singleDevice['ip'] = $device[1];
- //key is the MAC address
- $results[$device[2]] = $singleDevice;
- }
- var_dump($results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement