From 5779ade6707ba530517da239d9ec3fc751d17d83 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Fri, 31 Jul 2015 10:03:34 -0300 Subject: Introduce a new item to $g global, 'product_version' and stop reading /etc/version all around --- usr/local/pkg/miniupnpd.inc | 4 ++-- usr/local/www/crash_reporter.php | 2 +- usr/local/www/pkg_mgr_installed.php | 3 +-- usr/local/www/pkg_mgr_settings.php | 3 +-- usr/local/www/system_firmware_auto.php | 7 +++---- usr/local/www/system_firmware_check.php | 5 ++--- usr/local/www/widgets/widgets/system_information.widget.php | 5 ++--- 7 files changed, 12 insertions(+), 17 deletions(-) (limited to 'usr') diff --git a/usr/local/pkg/miniupnpd.inc b/usr/local/pkg/miniupnpd.inc index a545744..4ea768c 100644 --- a/usr/local/pkg/miniupnpd.inc +++ b/usr/local/pkg/miniupnpd.inc @@ -145,7 +145,7 @@ } function sync_package_miniupnpd() { - global $config; + global $g, $config; global $input_errors; $upnp_config = $config['installedpackages']['miniupnpd']['config'][0]; @@ -238,7 +238,7 @@ $config_text .= "serial=".strtoupper(substr(upnp_uuid(), 0, 8))."\n"; /* set model number */ - $config_text .= "model_number=".file_get_contents("/etc/version")."\n"; + $config_text .= "model_number=" . $g['product_version'] . "\n"; /* upnp access restrictions */ foreach ($upnp_config['row'] as $row) { diff --git a/usr/local/www/crash_reporter.php b/usr/local/www/crash_reporter.php index 24cb36f..3b00e47 100644 --- a/usr/local/www/crash_reporter.php +++ b/usr/local/www/crash_reporter.php @@ -57,7 +57,7 @@ function upload_crash_report($files) { 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'] . '/' . rtrim(file_get_contents("/etc/version"))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version']); curl_setopt($ch, CURLOPT_URL, $g['crashreporterurl']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); diff --git a/usr/local/www/pkg_mgr_installed.php b/usr/local/www/pkg_mgr_installed.php index e190fec..3801271 100644 --- a/usr/local/www/pkg_mgr_installed.php +++ b/usr/local/www/pkg_mgr_installed.php @@ -109,10 +109,9 @@ include("head.inc"); $upgrade_latest_tgz_sha256) { */ function read_body_firmware($ch, $string) { - global $fout, $file_size, $downloaded, $counter, $version, $latest_version, $current_installed_version; + global $g, $fout, $file_size, $downloaded, $counter, $version, $latest_version; $length = strlen($string); $downloaded += intval($length); $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0); @@ -275,7 +274,7 @@ function read_body_firmware($ch, $string) { $c = $downloadProgress; $text = " " . gettext("Auto Update Download Status") . "\\n"; $text .= "----------------------------------------------------\\n"; - $text .= " " . gettext("Current Version") . " : {$current_installed_version}\\n"; + $text .= " " . gettext("Current Version") . " : {$g['product_version']}\\n"; $text .= " " . gettext("Latest Version") . " : {$latest_version}\\n"; $text .= " " . gettext("File size") . " : {$a}\\n"; $text .= " " . gettext("Downloaded") . " : {$b}\\n"; diff --git a/usr/local/www/system_firmware_check.php b/usr/local/www/system_firmware_check.php index d240a63..2e56943 100644 --- a/usr/local/www/system_firmware_check.php +++ b/usr/local/www/system_firmware_check.php @@ -157,12 +157,11 @@ if (!$remote_version) { update_output_window($static_text); $current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime")); - $current_installed_version = trim(file_get_contents("/etc/version")); $static_text .= "done\\n"; update_output_window($static_text); - if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) { + if (pfs_version_compare($current_installed_buildtime, $g['product_version'], $remote_version) == -1) { $needs_system_upgrade = true; } else { $static_text .= "\\n" . gettext("You are on the latest version.") . "\\n"; @@ -191,7 +190,7 @@ echo "//]]>\n"; echo "\n"; $txt = gettext("A new version is now available") . "\\n\\n"; -$txt .= gettext("Current version") . ": " . $current_installed_version . "\\n"; +$txt .= gettext("Current version") . ": " . $g['product_version'] . "\\n"; if ($g['platform'] == "nanobsd") { $txt .= " " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "\\n"; } diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 6143ac1..231f2ee 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -66,13 +66,12 @@ if ($_REQUEST['getupdatestatus']) { echo "

Unable to check for updates."; } else { $current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime")); - $current_installed_version = trim(file_get_contents("/etc/version")); if (!$remote_version) { echo "

Unable to check for updates."; } else { $needs_system_upgrade = false; - if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) { + if (pfs_version_compare($current_installed_buildtime, $g['product_version'], $remote_version) == -1) { echo "
Update available. Click Here to view update."; echo "\n