$v) $cookie_list[] = "$k=$v"; curl_setopt($ch, CURLOPT_COOKIE, implode('; ', $cookie_list)); } $response = curl_exec($ch); curl_close($ch); return json_decode($response, true); } function perform_auto_login($host, $password_file) { if (!file_exists($password_file)) return ['error' => 'password.txt not found']; $password = trim(file_get_contents($password_file)); // Step 1: Get Nonce $nonce_data = router_request("http://$host/cgi-bin/auth_cgi", ["module" => "authenticator", "action" => 0]); $nonce = $nonce_data['nonce'] ?? null; if (!$nonce) return ['error' => 'Failed to retrieve nonce']; // Step 2: Login $digest = md5($password . ":" . $nonce); $login_data = router_request("http://$host/cgi-bin/auth_cgi", ["module" => "authenticator", "action" => 1, "digest" => $digest]); if (isset($login_data['token'])) { return ['token' => $login_data['token'], 'success' => true]; } return ['error' => 'Login failed - check password']; } // --- Logic Routing --- // Handle AJAX command requests from the buttons if (isset($_GET['execute'])) { header('Content-Type: application/json'); $token = $_POST['token'] ?? ''; $action = (int)($_POST['action'] ?? 0); $res = router_request( "http://$host/cgi-bin/web_cgi", ["token" => $token, "module" => "reboot", "action" => $action], ["check_cookie" => "check_cookie", "tpweb_token" => $token] ); echo json_encode($res); exit; } // Perform Auto-Auth for the initial page load $auth = perform_auto_login($host, $password_file); ?>
Restart the cellular module and WiFi. Takes ~60-90 seconds.
Complete power off. Requires physical button to turn back on.