diff options
author | Renato Botelho <renato@netgate.com> | 2015-11-16 10:25:45 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-11-16 10:25:45 -0200 |
commit | 0582a6334fb43346b8aa3db9b44924ea4b184ceb (patch) | |
tree | 2dced2e58a51e833f36a9be2858ffdd05e6c2d80 /src/usr/local | |
parent | ccf0fd941f741046a7563fe58c541734b62f8667 (diff) | |
download | pfsense-0582a6334fb43346b8aa3db9b44924ea4b184ceb.zip pfsense-0582a6334fb43346b8aa3db9b44924ea4b184ceb.tar.gz |
Change system information widget to be able to find system updates when it's available
Diffstat (limited to 'src/usr/local')
-rw-r--r-- | src/usr/local/www/widgets/widgets/system_information.widget.php | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php index b58e31e..0dd9be4 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -61,54 +61,47 @@ require_once('notices.inc'); include_once("includes/functions.inc.php"); if ($_REQUEST['getupdatestatus']) { - if (isset($config['system']['firmware']['disablecheck'])) { - exit; - } - if (isset($config['system']['firmware']['alturl']['enable'])) { - $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}"; - } else { - $updater_url = $g['update_url']; - } + require_once("pkg-utils.inc"); - $nanosize = ""; - if ($g['platform'] == "nanobsd") { - if (!isset($g['enableserial_force'])) { - $nanosize = "-nanobsd-vga-"; - } else { - $nanosize = "-nanobsd-"; - } - $nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt"))); + $system_version = get_system_pkg_version(); + + if ($system_version === false) { + echo "<i>Unable to check for updates</i>"; + exit; } - @unlink("/tmp/{$g['product_name']}_version"); - if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true) { - $remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); + if (!is_array($system_version) || + !isset($system_version['version']) || + !isset($system_version['installed_version'])) { + echo "<i>Wrong version information</i>"; + exit; } - if(empty($remote_version)) - echo "<i>Unable to check for updates</i>"; - else { - $current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime")); + $version_compare = pkg_version_compare( + $system_version['installed_version'], $system_version['version']); - if(!$remote_version) { - echo "<i>Unable to check for updates</i>"; - } - else { - $needs_system_upgrade = false; - $version_compare = pfs_version_compare($current_installed_buildtime, $g['product_version'], $remote_version); - if ($version_compare == -1) { + switch ($version_compare) { + case '<': ?> -<div class="alert alert-warning" role="alert"> - Version <?=$remote_version?> is available. <a href="/system_firmware_check.php" class="alert-link">Click Here to view.</a> -</div> + <div class="alert alert-warning" role="alert"> + Version <?=$system_version['version']?> is available. + <a href="/pkg_mgr_install.php?id=firmware" class="alert-link"> + Click Here to view. + </a> + </div> <?php - } elseif ($version_compare == 1) { - echo "You are on a later version than<br />the official release."; - } else { - echo "You are on the latest version."; - } - } + break; + case '=': + echo "You are on the latest version."; + break; + case '>': + echo "You are on a later version than<br />the official release."; + break; + default: + echo "<i>Error comparing installed version with latest available</i>"; + break; } + exit; } |