$refreshinterval)) { if (file_exists($supportfile)) { unlink($supportfile); } updateSupport(); } if (file_exists($supportfile)) { print(file_get_contents($supportfile)); } exit; } // If the widget is called with act=refresh, delete the JSON file and reload the page, thereby forcing the // widget to get a fresh copy of the support information if ($_REQUEST['act'] == "refresh") { if (file_exists($supportfile)) { unlink($supportfile); } header("Location: /"); exit; } // Poll the Netgate server to obtain the JSON/HTML formatted support information // and write it to the JSON file function updateSupport() { global $g, $supportfile, $idfile, $FQDN; if (file_exists($idfile)) { if (function_exists('curl_version')) { $post = ['uid' => file_get_contents($idfile), 'language' => '0']; $url = $FQDN; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version']); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,4); $response = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($status == 200) { file_put_contents($supportfile, $response); } } } } $doajax = "yes"; print("
"); if (file_exists($supportfile) && ( time()-filemtime($supportfile) < $refreshinterval)) { // Print the support data from the file $str = file_get_contents($supportfile); $json = json_decode($str, true); print($json['summary']); print($json['htmltext']); $doajax = "no"; } else { //Print empty
s and request the data by AJAX print(sprintf(gettext("%sRetrieving support information %s %s"), "
", "", "
")); } // Print a low-key refresh link print('
'); print("
"); ?>