mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Introduce a new item to $g global, 'product_version' and stop reading /etc/version all around
This commit is contained in:
parent
6fed300c6a
commit
5779ade670
@ -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 */
|
||||
|
||||
@ -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'])) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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";
|
||||
}
|
||||
|
||||
@ -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"); ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user