We often encounter the need to automatically change the IP address, for example, simulate click voting, data collection of blocked IP addresses, Alexa cheating, and so on, that is, we need to change the IP address frequently, we can use PHP to control the router to change the IP address, so that we don't need to be so tired of using the press Key wizard. Haha. Some routers provide router configuration management through WEB, with one
We often encounter the need to automatically change the IP address, for example, simulate click voting, data collection of blocked IP addresses, Alexa cheating, and so on, that is, we need to change the IP address frequently, we can use PHP to control the router to change the IP address, so that we don't need to be so tired of using the press Key wizard. Haha. Some routers provide router configuration management through WEB, with one
We often encounter the need to automatically change the IP address, for example, simulate click voting, data collection of blocked IP addresses, Alexa cheating, and so on, that is, we need to change the IP address frequently, we can use PHP to control the router to change the IP address, so that we don't need to be so tired of using the press Key wizard. Haha.
Some routers provide WEB-based router configuration management. One feature in the middle is disconnection and reconnection. We can use this feature. For more information, see the code below:
Function router ($ target = ''){
$ Server = '192. 168.1.1 '; // IP address
$ Host = '1970. 168.1.1 '; // Domain name
$ Port = 80;
$ Referer = 'HTTP: // '. $ host. $ target; // Referer
$ Username = "admin"; # username of the ADSL route
$ Password = "admin"; # The management password of the ADSL route
$ Authorization = base64_encode ($ username. ":". $ password); // echo $ authorization; exit ();
$ File = fsockopen ($ server, $ port, $ errno, $ errstr, 30 );
If ($ File ){
$ Out = "GET $ target HTTP/1.1 \ r \ n ";
$ Out. = "Host: $ host \ r \ n ";
$ Out. = "Referer: $ referer \ r \ n ";
$ Out. = "Authorization: Basic $ authorization \ r \ n ";
$ Out. = "Connection: Closern \ r \ n ";
Fputs ($ File, $ out );
$ MakeFile = $ buffer = "";
While ($ buffer = fread ($ File, 4096 )){
$ MakeFile = $ makeFile. $ buffer;
}
Fclose ($ File );
}
}
Router ("/userRpm/StatusRpm.htm? Disconnect = % B6 % CF % 20% CF % DF & wan = 1 ");
// Add php below to obtain the IP address of the current Gateway
Function getIP (){
$ Target = "/userRpm/StatusRpm.htm ";
$ Server = '192. 168.1.1 '; // IP address
$ Host = '1970. 168.1.1 '; // Domain name
$ Port = 80;
$ Referer = 'HTTP: // '. $ host. $ target; // Referer
$ Username = "admin"; # username of the ADSL route
$ Password = "admin"; # The management password of the ADSL route
$ Authorization = base64_encode ($ username. ":". $ password); // echo $ authorization; exit ();
$ File = fsockopen ($ server, $ port, $ errno, $ errstr, 30 );
If ($ File ){
$ Out = "GET $ target HTTP/1.1 \ r \ n ";
$ Out. = "Host: $ host \ r \ n ";
$ Out. = "Referer: $ referer \ r \ n ";
$ Out. = "Authorization: Basic $ authorization \ r \ n ";
$ Out. = "Connection: Closern \ r \ n ";
Fputs ($ File, $ out );
$ MakeFile = $ buffer = "";
While ($ buffer = fread ($ File, 4096 )){
$ MakeFile = $ makeFile. $ buffer;
}
Fclose ($ File );
}
// Match the current Gateway
$ Pattern = "/\" [A-Z0-9] {2} \-[A-Z0-9] {2} \-[A-Z0-9] {2} \-[A-Z0-9] {2 }\-[ a-Z0-9] {2} \-[A-Z0-9] {2 }\", \ "([0-9 \.] +) \ "/s ";
If (preg_match_all ($ pattern, $ makeFile, $ match )){
$ NowIP = $ match [1] [1];
}
Return $ nowIP;
}