-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgrab_router_ip.php
More file actions
34 lines (28 loc) · 881 Bytes
/
grab_router_ip.php
File metadata and controls
34 lines (28 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/*
// Program : Show NetGear ADSL Router WAN IP
// Author : Ap.Muthu <apmuthu@usa.net>
// Version : 1.0
// Release Date : 2017-09-19
// Tested on : NetGear DG834G
// Example Usage : php.exe grab_router_ip.php
*/
// Router credentials
$rt_user = "admin";
$rt_pass = "MySecretRouterPassword";
$baseurl='192.168.0.1'; // router management interface LAN IP
// $baseurl='www.routerlogin.com';
$url = "http://".$rt_user.":".$rt_pass."@".$baseurl."/setup.cgi?next_file=s_status.htm";
$a = file_get_contents($url);
sleep(2); // seconds
$b = explode('<td width="50%"><b>IP Address </b></td>', $a);
$IP = get_inner_str($b[1]);
echo $IP;
function get_inner_str($str) {
$strip_str = array('<strong>', '</strong>', "\t", "\r", "\n");
$str = str_replace($strip_str, '', $str);
$x = explode('>', $str);
$y = explode('<', $x[1]);
return trim($y[0]);
}
?>