diff options
author | Renato Botelho <renato@netgate.com> | 2015-07-31 10:03:34 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-07-31 10:03:34 -0300 |
commit | 5779ade6707ba530517da239d9ec3fc751d17d83 (patch) | |
tree | 9295a06ae80c1dd54611e7c279c42e3e242a6790 | |
parent | 6fed300c6ae8c5bcac03f867daf737e2676dcc30 (diff) | |
download | pfsense-5779ade6707ba530517da239d9ec3fc751d17d83.zip pfsense-5779ade6707ba530517da239d9ec3fc751d17d83.tar.gz |
Introduce a new item to $g global, 'product_version' and stop reading /etc/version all around
-rw-r--r-- | etc/inc/globals.inc | 4 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 12 | ||||
-rw-r--r-- | etc/inc/services.inc | 3 | ||||
-rwxr-xr-x | etc/rc.banner | 3 | ||||
-rw-r--r-- | usr/local/pkg/miniupnpd.inc | 4 | ||||
-rw-r--r-- | usr/local/www/crash_reporter.php | 2 | ||||
-rw-r--r-- | usr/local/www/pkg_mgr_installed.php | 3 | ||||
-rw-r--r-- | usr/local/www/pkg_mgr_settings.php | 3 | ||||
-rwxr-xr-x | usr/local/www/system_firmware_auto.php | 7 | ||||
-rw-r--r-- | usr/local/www/system_firmware_check.php | 5 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/system_information.widget.php | 5 |
11 files changed, 22 insertions, 29 deletions
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 504f67c..b40a862 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -58,6 +58,7 @@ $g = array( "xml_rootobj" => "pfsense", "admin_group" => "admins", "product_name" => "pfSense", + "product_version" => trim(file_get_contents("{$g['etc_path']}/version"), " \n"), "product_copyright" => "Electric Sheep Fencing LLC", "product_copyright_url" => "http://www.electricsheepfencing.com", "product_copyright_years" => "2004 - ".date("Y"), @@ -98,9 +99,8 @@ $tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr"); if (file_exists("/etc/platform")) { $arch = php_uname("m"); - $current_version = trim(file_get_contents("{$g['etc_path']}/version")); - if (strstr($current_version, "-RELEASE")) { + if (strstr($g['product_version'], "-RELEASE")) { /* This is only necessary for RELEASE */ $arch = ($arch == "i386") ? "" : '/' . $arch; /* Full installs and NanoBSD use the same update directory and manifest in 2.x */ diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 22b0be0..93719ad 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -802,7 +802,7 @@ function check_firmware_version($tocheck = "all", $return_php = true) { } $version = php_uname('r'); $version = explode('-', $version); - $rawparams = array("firmware" => array("version" => trim(file_get_contents('/etc/version'))), + $rawparams = array("firmware" => array("version" => $g['product_version']), "kernel" => array("version" => $version[0]), "base" => array("version" => $version[0]), "platform" => trim(file_get_contents('/etc/platform')), @@ -841,7 +841,7 @@ function host_firmware_version($tocheck = "") { $os_version = trim(substr(php_uname("r"), 0, strpos(php_uname("r"), '-'))); return array( - "firmware" => array("version" => trim(file_get_contents('/etc/version', " \n"))), + "firmware" => array("version" => $g['product_version']), "kernel" => array("version" => $os_version), "base" => array("version" => $os_version), "platform" => trim(file_get_contents('/etc/platform', " \n")), @@ -1773,9 +1773,9 @@ function download_file($url, $destination, $verify_ssl = true, $connect_timeout curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if (!isset($config['system']['host_uuid'])) { - curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version") . ' : ' . get_single_sysctl('kern.hostuuid'))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version'] . ' : ' . get_single_sysctl('kern.hostuuid')); } else { - 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']); } if (!empty($config['system']['proxyurl'])) { @@ -1819,9 +1819,9 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); if (!isset($config['system']['host_uuid'])) { - curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version") . ' : ' . get_single_sysctl('kern.hostuuid'))); + curl_setopt($ch, CURLOPT_USERAGENT, $g['product_name'] . '/' . $g['product_version'] . ' : ' . get_single_sysctl('kern.hostuuid')); } else { - 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']); } if (!empty($config['system']['proxyurl'])) { diff --git a/etc/inc/services.inc b/etc/inc/services.inc index e3bf092..1412f7e 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -2084,13 +2084,12 @@ trap := "{$config['snmpd']['trapstring']}" EOD; } - $version = trim(file_get_contents('/etc/version')); $platform = trim(file_get_contents('/etc/platform')); if (($platform == "pfSense") && ($g['product_name'] != "pfSense")) { $platform = $g['product_name']; } $sysDescr = "{$g['product_name']} " . php_uname("n") . - " {$version} {$platform} " . php_uname("s") . + " {$g['product_version']} {$platform} " . php_uname("s") . " " . php_uname("r") . " " . php_uname("m"); $snmpdconf .= <<<EOD diff --git a/etc/rc.banner b/etc/rc.banner index 768a70d..e31d474 100755 --- a/etc/rc.banner +++ b/etc/rc.banner @@ -36,7 +36,6 @@ require_once("gwlb.inc"); require_once("interfaces.inc"); - $version = trim(file_get_contents("{$g['etc_path']}/version")); $platform = trim(file_get_contents("{$g['etc_path']}/platform")); $hostname = $config['system']['hostname']; $product = $g['product_name']; @@ -47,7 +46,7 @@ $platformbanner = "-{$platform}"; } - print "*** Welcome to {$product} {$version}{$platformbanner} ({$machine}) on {$hostname} ***\n"; + print "*** Welcome to {$product} {$g['product_version']}{$platformbanner} ({$machine}) on {$hostname} ***\n"; $iflist = get_configured_interface_with_descr(false, true); foreach ($iflist as $ifname => $friendly) { 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"); <tr> <td> <?php - $version = file_get_contents("/etc/version"); $tab_array = array(); $tab_array[] = array(gettext("Available Packages"), false, "pkg_mgr.php"); -// $tab_array[] = array("{$version} " . gettext("packages"), false, "pkg_mgr.php"); +// $tab_array[] = array("{$g['product_version']} " . gettext("packages"), false, "pkg_mgr.php"); // $tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none"); // $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); $tab_array[] = array(gettext("Installed Packages"), true, "pkg_mgr_installed.php"); diff --git a/usr/local/www/pkg_mgr_settings.php b/usr/local/www/pkg_mgr_settings.php index c222d28..04a5151 100644 --- a/usr/local/www/pkg_mgr_settings.php +++ b/usr/local/www/pkg_mgr_settings.php @@ -99,9 +99,8 @@ function enable_altpkgrepourl(enable_over) { <tr> <td> <?php - $version = file_get_contents("/etc/version"); $tab_array = array(); - $tab_array[] = array(sprintf(gettext("%s packages"), $version), false, "pkg_mgr.php"); + $tab_array[] = array(sprintf(gettext("%s packages"), $g['product_version']), false, "pkg_mgr.php"); $tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php"); $tab_array[] = array(gettext("Package Settings"), true, "pkg_mgr_settings.php"); display_top_tabs($tab_array); diff --git a/usr/local/www/system_firmware_auto.php b/usr/local/www/system_firmware_auto.php index 9c15ae3..e2970fa 100755 --- a/usr/local/www/system_firmware_auto.php +++ b/usr/local/www/system_firmware_auto.php @@ -163,7 +163,6 @@ if (!$latest_version) { exit; } else { $current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime")); - $current_installed_version = trim(file_get_contents("/etc/version")); $latest_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); $latest_version_pfsense = strtotime($latest_version); if (!$latest_version) { @@ -171,7 +170,7 @@ if (!$latest_version) { require("fend.inc"); exit; } else { - if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $latest_version) == -1) { + if (pfs_version_compare($current_installed_buildtime, $g['product_version'], $latest_version) == -1) { update_status(gettext("Downloading updates") . "..."); conf_mount_rw(); if ($g['platform'] == "nanobsd") { @@ -265,7 +264,7 @@ if ($downloaded_latest_tgz_sha256 <> $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 "</script>\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 "<br /><br />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 "<br /><br />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 "<br /><span class=\"red\" id=\"updatealert\"><b>Update available. </b></span><a href=\"/system_firmware_check.php\">Click Here</a> to view update."; echo "\n<script type=\"text/javascript\">\n"; echo "//<![CDATA[\n"; @@ -124,7 +123,7 @@ $filesystems = get_mounted_filesystems(); <tr> <td width="25%" valign="top" class="vncellt"><?=gettext("Version");?></td> <td width="75%" class="listr"> - <strong><?php readfile("/etc/version"); ?></strong> + <strong><?=$g['product_version']?></strong> (<?php echo php_uname("m"); ?>) <br /> built on <?php readfile("/etc/version.buildtime"); ?> |