Lười phải vào web để reboot router/wireles, function dưới đây giúp làm chuyện đó trong 1 nốt nhạc. Mã này hỗ trợ hầu như tất cả các router của TP-LINK vì có trang quản trị giống nhau.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/** * Remote reboot TP-LINK router / wireless * @param string $router_ip: example 192.168.1.1 * @param string $admin_username * @param string $admin_password */ function remoteRebootTPLINK($router_ip, $admin_username, $admin_password) { $host = "http://{$router_ip}/userRpm/SysRebootRpm.htm?Reboot=Reboot"; $process = curl_init($host); curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); curl_setopt($process, CURLOPT_HEADER, 1); curl_setopt($process, CURLOPT_USERPWD, $admin_username . ":" . $admin_password); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_REFERER, "http://{$router_ip}/"); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); $return = curl_exec($process); curl_close($process); } |
Continue reading “PHP Code: Remote reboot TP-Link Router / Wireless”