From 8dce797c3b6f19853b2d175a5c1f483ad3e925b5 Mon Sep 17 00:00:00 2001 From: Steve Beaver Date: Mon, 14 Aug 2017 13:12:36 -0400 Subject: Adding widget and login css files --- .../netgate_services_and_support.widget.php | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 src/usr/local/www/widgets/widgets/netgate_services_and_support.widget.php (limited to 'src/usr/local/www/widgets') diff --git a/src/usr/local/www/widgets/widgets/netgate_services_and_support.widget.php b/src/usr/local/www/widgets/widgets/netgate_services_and_support.widget.php new file mode 100644 index 0000000..0d8b28b --- /dev/null +++ b/src/usr/local/www/widgets/widgets/netgate_services_and_support.widget.php @@ -0,0 +1,163 @@ + $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("
"); + +?> + + -- cgit v1.1