diff --git a/src/www/widgets/widgets/system_information.widget.php b/src/www/widgets/widgets/system_information.widget.php index 2e3a2c3ce..64cab19bf 100644 --- a/src/www/widgets/widgets/system_information.widget.php +++ b/src/www/widgets/widgets/system_information.widget.php @@ -35,36 +35,22 @@ require_once('notices.inc'); include_once("includes/functions.inc.php"); require_once("script/load_phalcon.php"); -/* XXX keep redirect through file because we know it works, but zap this later */ -$file_pkg_status = '/tmp/pkg_status.json'; - -if ($_POST['action'] == 'pkg_update') { +if ($_REQUEST['getupdatestatus']) { $pkg_json = trim(configd_run('firmware pkgstatus')); if ($pkg_json != '') { - file_put_contents($file_pkg_status, $pkg_json); - } -} - -if ($_REQUEST['getupdatestatus']) { - if (file_exists($file_pkg_status)) { - $json = file_get_contents($file_pkg_status); - $pkg_status = json_decode($json, true); - unlink($file_pkg_status); + $pkg_status = json_decode($pkg_json, true); } - if (isset($pkg_status)) { - if ($pkg_status["connection"]=="error") { - echo "".gettext("Connection Error")."
".gettext("Click to retry").""; - } elseif ($pkg_status["repository"]=="error") { - echo "".gettext("Repository Problem")."
".gettext("Click to retry").""; - } elseif ($pkg_status["updates"]=="0") { - echo "".gettext("At")." ".$pkg_status["last_check"]."".gettext(" no updates found.")."
Click to check for updates"; - } else { - echo "".gettext("There are ").$pkg_status["updates"].gettext(" update(s) available.")."
(When last checked at: ".$pkg_status["last_check"]." )"."

".gettext("Click to upgrade")." | Re-check now"; - } + if (!isset($pkg_status) || $pkg_status["connection"]=="error") { + echo "".gettext("Connection Error")."
".gettext("Click to retry").""; + } elseif ($pkg_status["repository"]=="error") { + echo "".gettext("Repository Problem")."
".gettext("Click to retry").""; + } elseif ($pkg_status["updates"]=="0") { + echo "".gettext("Your system is up to date.")."
Click to check for updates"; } else { - echo "".gettext("Click to check for updates").""; + echo "".gettext("There are ").$pkg_status["updates"].gettext(" update(s) available.")."
".gettext("Click to upgrade")." | Re-check now"; } + exit; } @@ -118,18 +104,14 @@ endif; ?> - Updates -
Fetching status
+
- @@ -315,30 +297,24 @@ endforeach; ?> } }); } - window.onload = function(){ - getstatus(); - } - - function getstatus() { - scroll(0,0); - var url = "/widgets/widgets/system_information.widget.php"; - var pars = 'getupdatestatus=yes'; - jQuery.ajax( - url, - { + function getstatus() { + scroll(0,0); + var url = "/widgets/widgets/system_information.widget.php"; + var pars = 'getupdatestatus=yes'; + jQuery.ajax( + url, + { type: 'get', data: pars, complete: activitycallback - }); - } - function activitycallback(transport) { - // .html() method process all script tags contained in responseText, - // to avoid this we set the innerHTML property - jQuery('#updatestatus').prop('innerHTML',transport.responseText); - } - + }); + } + + function activitycallback(transport) { + // .html() method process all script tags contained in responseText, + // to avoid this we set the innerHTML property + jQuery('#updatestatus').prop('innerHTML',transport.responseText); + } //]]>