Project

General

Profile

« Previous | Next » 

Revision da55e467

Added by Scott Ullrich about 17 years ago

Just because elvis is dead, does not mean our auto updating system
needs to be. Bring it back from the dead and make it match the
new world order. Add a custom URL firmware update page which will
have snapshot support shortly.

View differences:

etc/inc/globals.inc
74 74
    "captiveportal_element_sizelimit" => 262144,
75 75
    "xmlrpcpath" => "/pfSense/xmlrpc.php",
76 76
    "embeddedbootupslice" => "/dev/ad0a",
77
	"update_url" => "http://updates.pfSense.com/_updaters",
77 78
    "wireless_regex" => "/^(ndis|wi|ath|an|ral|ural|wai|iwi|awi|wlan)/",
78 79
    "vlan_native_supp" => array("vge", "bfe", "dc", "fxp", "gem", "hme", "rl", "sis", "ste", "tl", "tx", "xl"),
79 80
    "vlan_long_frame" => array("vge", "bfe",  "bge",  "dc",  "em",  "fxp",  "gem",  "hme",  "ixgb",  "le",  "nge",  "re",  "rl",  "sis",  "sk",  "ste",  "ti",  "tl",  "tx",  "txp",  "vr", "xl")
......
85 86
/* TCP flags */
86 87
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg");
87 88

  
88
?>
89
?>
usr/local/www/system_firmware.php
31 31

  
32 32
$d_isfwfile = 1;
33 33
require_once("guiconfig.inc");
34

  
35
$curcfg = $config['system']['firmware'];
36

  
37

  
34 38
require_once("xmlrpc_client.inc");
35 39

  
36 40
/* Allow additional execution time 0 = no limit. */
......
135 139
	}
136 140
}
137 141

  
142
$pgtitle = array("Diagnostics","Firmware");
138 143
include("head.inc");
139 144

  
140 145
?>
......
165 170
<?php
166 171
	$tab_array = array();
167 172
	$tab_array[0] = array("Manual Update", true, "system_firmware.php");
168
	//$tab_array[1] = array("Auto Update", false, "system_firmware_check.php");
169
	//$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
173
	$tab_array[1] = array("Auto Update", false, "system_firmware_check.php");
174
	$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
170 175
	display_top_tabs($tab_array);
171 176
?>
172 177
		</td>
usr/local/www/system_firmware_auto.php
1
#!/usr/local/bin/php
1 2
<?php
2 3
/* $Id$ */
3 4
/*
4 5
	system_firmware_auto.php
5
	part of pfSense (http://www.pfsense.com)
6

  
7
	Copyright (C) 2005 Scott Ullrich and Colin Smith
6
	Copyright (C) 2005 Scott Ullrich
8 7

  
8
        Based originally on system_firmware.php
9
        (C)2003-2004 Manuel Kasper
9 10
	All rights reserved.
10 11

  
11 12
	Redistribution and use in source and binary forms, with or without
......
28 29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 31
	POSSIBILITY OF SUCH DAMAGE.
31

  
32
	TODO:
33
		* modify pfSense.com XMLRPC server to return md5 hashes of firmware updates.
34 32
*/
35 33

  
36
Header("Location: system_firmware.php");
37
exit;
34
require("guiconfig.inc");
35

  
36
$curcfg = $config['system']['firmware'];
38 37

  
39
require_once("guiconfig.inc");
40
require_once("xmlrpc.inc");
38
if(isset($curcfg['alturl']['enable'])
39
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
41 40

  
42
$pgtitle = array("System","Firmware","Auto Update");
41
$pgtitle = array("Diagnostics","Firmware","Auto Update");
43 42
include("head.inc");
44 43

  
45 44
?>
46 45

  
46
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
47
<link href="gui.css" rel="stylesheet" type="text/css">
48
</head>
49

  
47 50
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
51

  
48 52
<?php include("fbegin.inc"); ?>
49 53

  
50 54
<form action="system_firmware_auto.php" method="post">
51
<table width="100%" border="0" cellpadding="0" cellspacing="0">
52
  <tr>
53
    <td>
55
<table width="100%" border="0" cellpadding="6" cellspacing="0">
56
	<tr>
57
		<td>
54 58
<?php
55 59
	$tab_array = array();
56
	$tab_array[0] = array("Manual Update", false, "system_firmware.php");
57
	$tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
60
	$tab_array[0] = array("Manual Update", true, "system_firmware.php");
61
	$tab_array[1] = array("Auto Update", false, "system_firmware_check.php");
58 62
	$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
59 63
	display_top_tabs($tab_array);
60 64
?>
61
    </td>
62
  </tr>
65
		</td>
66
	</tr>
63 67
	<tr>
64
	  <td>
65
	      <div id="mainarea">
66
	      <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
67
		<tr>
68
		  <td>
69
		      <!-- progress bar -->
70
		      <center>
71
		      <table id="progholder" name="progholder" height='20' border='1' bordercolor='black' width='420' bordercolordark='#000000' bordercolorlight='#000000' style='border-collapse: collapse' colspacing='2' cellpadding='2' cellspacing='2'><tr><td><img border='0' src='./themes/<?= $g['theme']; ?>/images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar'></td></tr></table>
72
		      <br>
73
		      <!-- status box -->
74
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols="60" rows="1" name="status" id="status" wrap="hard">
75
		      Beginning system autoupdate...
76
		      </textarea>
77
		      <!-- command output box -->
78
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols="60" rows="25" name="output" id="output" wrap="hard">
79
		      </textarea>
80
		      </center>
81
		  </td>
82
		</tr>
68
	  <td class="tabcont">
69
	      <table width="100%" border="0" cellpadding="6" cellspacing="0">
70
			  <tr>
71
			    <td class="tabcont">
72
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
73
						<tr>
74
							<td>
75
								<center>
76
								<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
77

  
78
								<tr>
79
									<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
80
									</td>
81
									<td>
82
									<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
83
										<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
84
											<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
85
										</td>
86
									</table>
87
								</td>
88
								<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
89
								</td>
90
							</tr>
91
						</table>
92
						<br>
93
						<!-- status box -->
94
						<textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
95
						<!-- command output box -->
96
						<textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
97
					</center>
98
					</td>
99
				</tr>
83 100
	      </table>
84
	      </div>
101
		</table>
85 102
	  </td>
86 103
	</tr>
87 104
</table>
......
92 109

  
93 110
<?php
94 111

  
95
/* Define necessary variables. */
96
$update_types = array('full', 'diff');
97
$didupdate = false;
112
update_status("Downloading current version information...");
113
$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
114

  
115
$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
116
$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
117

  
118
if($current_installed_pfsense_version <> $latest_version) 
119
	$needs_system_upgrade = true;
98 120

  
99
if($_GET['category'] == 'full') {
100
	$tocheck = 'all';
101
	$categories = array('firmware', 'kernel', 'base');
121
if($needs_system_upgrade == true) {
122
	update_status("Downloading updates ...");
123
	$status = download_file_with_progress_bar("{$updater_url}/latest.tgz", "/tmp/latest.tgz");	
124
	$status = download_file_with_progress_bar("{$updater_url}/latest.tgz.sha256", "/tmp/latest.tgz.sha256");
125
	update_output_window("{$g['product_name']} download complete.");
126
}
127

  
128
/* launch external upgrade helper */
129
$external_upgrade_helper_text = "/etc/rc.firmware pfSenseupgrade ";
130
if($needs_system_upgrade == true)
131
	$external_upgrade_helper_text .= "/tmp/latest.tgz";
132

  
133
$downloaded_latest_tgz_sha256 = str_replace("\n", "", `sha256 /tmp/latest.tgz  | awk '{ print $4 }'`);
134
$upgrade_latest_tgz_sha256 = str_replace("\n", "", `cat /tmp/latest.tgz.sha256 | awk '{ print $4 }'`);
135

  
136
if($downloaded_latest_tgz_sha256 <> $upgrade_latest_tgz_sha256) {
137
	update_status("Downloading complete but sha256 does not match.");
138
	update_output_window("Auto upgrade aborted.  \n\nDownloaded SHA256: $downloaded_latest_tgz_sha256 \n\nNeeded SHA256: $upgrade_latest_tgz_sha256");	
102 139
} else {
103
	$tocheck = array($_GET['category']);
104
	$categories = $tocheck;
140
	update_status("Downloading complete.");
141
	update_output_window("{$g['product_name']} is now upgrading.\\n\\nThe firewall will reboot once the operation is completed.");
142
	echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';\n</script>";
143
	exec_rc_script_async("{$external_upgrade_helper_text}");
105 144
}
106 145

  
107
$static_output = "Downloading current version information... ";
108
update_status($static_output);
109
update_output_window($static_output);
146
/*
147
	Helper functions
148
*/
110 149

  
111
if(file_exists("/tmp/versioncheck.cache")) {
112
	$versions = unserialize("/tmp/versioncheck.cache");
113
	if(time() - $versions['cachetime'] > 300) { // Our cached data is stale, get a new copy.
114
		$versions = check_firmware_version($tocheck);
115
	} else { // Our cached data is relatively currently, remove the cachetime label.
116
		unset($versions['cachetime']);
150
function download_file_with_progress_bar($url_file, $destination_file) {
151
	global $ch, $fout, $file_size, $downloaded, $counter;
152
	$file_size  = 1;
153
	$downloaded = 1;
154
	/* open destination file */
155
	$fout = fopen($destination_file, "wb");
156

  
157
	/*
158
		Originally by Author: Keyvan Minoukadeh
159
		Modified by Scott Ullrich to return Content-Length size
160
	*/
161

  
162
	$ch = curl_init();
163
	curl_setopt($ch, CURLOPT_URL, $url_file);
164
	curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
165
	curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
166
	curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
167

  
168
	curl_exec($ch);
169
	fclose($fout);
170
	return 1;
171

  
172
	if ($error = curl_error($ch)) {
173
	    return -1;
117 174
	}
118 175
}
119 176

  
120
$static_output .= "done.\n";
121
update_output_window($static_output);
122

  
123
foreach($categories as $index => $key) {
124
	$bdiff_errors = array();
125
	if(is_array($versions[$key][0])) { // Make sure we really need to update this section.
126
		$didupdate = true;
127
		update_status("Found required " . $key . " updates. Downloading...");
128
		$static_output .= "Downloading " . $key . " updates... ";
129
		update_output_window($static_output);
130
		foreach($versions[$key] as $ver) { // Begin system updates.
131
			foreach($update_types as $type) if(in_array($type, array_keys($ver))) $url_type = $type;
132
			$tofetch = "pfSense-" . ucfirst($url_type) . "-" . ucfirst($key) . "-Update-" . $ver['version'] . ".tgz";
133
			$static_output_bak = $static_output;
134
			$static_output .= "\n\t" . $ver['version'] . "-" . $ver['name'] . " ";
135
			update_output_window($static_output);
136
			download_file_with_progress_bar("http://www.pfsense.com/updates/" . $tofetch, "/tmp/" . $tofetch);
137
			if($url_type == "binary") {
138
				exec("/etc/rc.firmware delta_update " . "/tmp/" . $tofetch, $bdiff_errors);
139
				if(is_string($bdiff_errors[0])) {
140
					unlink_if_exists("/tmp/" . $tofetch);
141
					$static_output .= "failed!\n";
142
					update_output_window($static_output);
143
					break;
144
				}
145
			} else {
146
				$tofetch = "pfSense-" . ucfirst($url_type) . "-Update-" . $ver['version'] . ".tgz";
147
				exec("/etc/rc.firmware pfSenseupgrade " . "/tmp/" . $tofetch);
148
				unlink_if_exists("/tmp/" . $tofetch);
149
			}
150
			$static_output = $static_output_bak . "done.\n";
151
		}
177
function read_header($ch, $string) {
178
	global $file_size, $ch, $fout;
179
	$length = strlen($string);
180
	ereg("(Content-Length:) (.*)", $string, $regs);
181
	if($regs[2] <> "") {
182
		$file_size = intval($regs[2]);
152 183
	}
184
	return $length;
153 185
}
154 186

  
155
if($didupdate == true) {
156
	update_status("Update finished. Rebooting...");
157
	exec("/etc/rc.reboot");
158
} else {
159
	update_status("No updates required.");
187
function read_body($ch, $string) {
188
	global $fout, $file_size, $downloaded, $counter, $version, $latest_version, $current_installed_pfsense_version;
189
	$length = strlen($string);
190
	$downloaded += intval($length);
191
	$downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
192
	$downloadProgress = 100 - $downloadProgress;
193
	$a = $file_size;
194
	$b = $downloaded;
195
	$c = $downloadProgress;
196
	$text  = "  Auto Update Download Status\\n";
197
	$text .= "---------------------------------\\n";
198
	$text .= "  Latest Version  : {$latest_version}\\n";
199
	$text .= "  Current Version : {$current_installed_pfsense_version}\\n";
200
	$text .= "  File size       : {$a}\\n";
201
	$text .= "  Downloaded      : {$b}\\n";
202
	$text .= "  Percent         : {$c}%\\n";
203
	$text .= "---------------------------------\\n";
204
	$counter++;
205
	if($counter > 150) {
206
		update_output_window($text);
207
		update_progress_bar($downloadProgress);
208
		$counter = 0;
209
	}
210
	fwrite($fout, $string);
211
	echo "<script language='javascript'>'>document.progressbar.style.width=\"$c%\";</script>\n";
212
	return $length;
160 213
}
161 214

  
162
echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';\n</script>";
163
?>
215
?>
usr/local/www/system_firmware_check.php
1 1
<?php
2 2
/* $Id$ */
3 3
/*
4
    system_firmware.php
5
    Copyright (C) 2004, 2005 Scott Ullrich and Colin Smith
6
    All rights reserved.
7

  
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

  
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

  
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

  
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
4
	system_firmware.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

  
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

  
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

  
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
29 15

  
30
Header("Location: system_firmware.php");
31
exit;
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
32 19

  
33
require_once("guiconfig.inc");
34
require_once("xmlrpc.inc");
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

  
32
$d_isfwfile = 1;
33
require("guiconfig.inc");
35 34

  
36
if(isset($config['system']['disablefirmwarecheck']))
37
	Header("Location: system_firmware.php");
35
$curcfg = $config['system']['firmware'];
38 36

  
39
$versions = check_firmware_version();
40
$pgtitle = array("System","Firmware","Auto Update");
41 37
include("head.inc");
42 38

  
43 39
?>
40

  
41
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
42

  
43
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
44
<link href="gui.css" rel="stylesheet" type="text/css">
45
</head>
46

  
44 47
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
48

  
45 49
<?php include("fbegin.inc"); ?>
46
		<SCRIPT>
47
		<!--
48
			function toggleTable (table, img) {
49
				var table = document.getElementById(table);
50
				var img = document.getElementById(img);
51
				if (table.rows[0].style.display == 'none') {
52
					for (var r = 0; r < table.rows.length; r++)
53
						table.rows[r].style.display = '';
54
					img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_o_black.gif";
55
				} else {
56
					for (var r = 0; r < table.rows.length; r++)
57
						table.rows[r].style.display = 'none';
58
					img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif";
59
				}
60
			}
61
		//-->
62
		</SCRIPT>
63
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
64
			<tr>
65
				<td>
50
<p class="pgtitle">System: Firmware: Auto Upgrade</p>
51

  
52
<form action="system_firmware_auto.php" method="post">
53
<table width="100%" border="0" cellpadding="0" cellspacing="0">
54
	<tr>
55
		<td>
66 56
<?php
67 57
	$tab_array = array();
68 58
	$tab_array[0] = array("Manual Update", false, "system_firmware.php");
69
	$tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
59
	$tab_array[1] = array("Auto Update Check", true, "system_firmware_check.php");
70 60
	$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
71 61
	display_top_tabs($tab_array);
72 62
?>
73
				</td>
74
			</tr>
75
			<tr>
76
				<td>
77
<?php
78
if(is_array($versions)) {
79
?>
80
					<div id="mainarea">
81
					<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont">
82
						<tr>
83
							<td width="10%" class="listhdrr">Act</td>
84
							<td width="30%" class="listhdrr">Category</td>
85
							<td width="30%" class="listhdrr">Installed</td>
86
							<td width="30%" class="listhdrr">Current<td>
87
						</tr>
88
<?php
89
	$currentvers = $versions['current'];
90
	foreach($versions as $key => $version) {
91
		if($key == "current") continue;
92
		$currentver = array_shift(explode('-', $currentvers[$key]['version']));
93
		if($version == 1) {
94
			$img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
95
			$pastlatest = true;
96
		} elseif( strcmp($currentver , $version[count($version) - 1]['version']) ){
97
			$img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
98
			$pastlatest = true;
99
		} else {
100
			$allinstall = true;
101
			$img = "./themes/".$g['theme']."/images/icons/icon_block.gif";
102
		}
103
?>
104
						<tr valign="top">
105
							<td class="listlr" nowrap align="middle"><img src="<?=$img;?>" width="11" height="11" align="absmiddle"></td>
106
							<td class="listlr"><?= ucfirst($key) ?></td>
107
							<td class="listlr"><?= $currentver ?></td>
108
<?php
109
		if($version == 1) {
110
?>
111
							<td class="listlr"><?= $currentver ?></td>
112
<?php
113
		} elseif($pastlatest) {
114
			$newver = $version[count($version) - 1]['version'];
115
?>
116
							<td class="listbggrey"><font color="#FFFFFF"><?= $newver ?></td>
117
<?php
118
		} else {
119
			$newver = $version[count($version) - 1]['version'];
120
?>
121
							<td class="listbg"><font color="#FFFFFF"><?= $newver ?></td>
122
<?php
123
		} 
124
		if(!$pastlatest) {
125
?>
126
							<td valign="middle" class="list" nowrap>
127
								<a href="system_firmware_auto.php?category=<?=$key;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
128
							</td>
129
<?php
130
		}
131
?>
132
						</tr>
133
<?php
134
	}
135
?>
136
					</table>
137
<?php
138
	if($allinstall) {
139
?>
140
					<br>
141
					<br>
142
					<table align="center" width="80%" border="0" cellpadding="0" cellspacing="0">
143
						<tr>
144
							<td align="center"><a href="javascript:toggleTable('updates', 'tri_updates')"><img src="./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif" id="tri_updates" width="14" height="10" border="0"></a><strong><a href="javascript:toggleTable('updates', 'tri_updates')">Needed Updates</a></strong></td>
145
						</tr>
146
						<tr>
147
							<td>
148
								<br>
149
								<br>
150
								<table id="updates" align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
151
									<tr>
152
										<td width="20%" class="listhdrr">Released</td>
153
										<td width="20%" class="listhdrr">Category</td>  
154
										<td width="20%" class="listhdrr">Version</td>
155
										<td width="20%" class="listhdrr">Size</td>
156
										<td width="20%" class="listhdr">Type</td>
157
									</tr>
158
<?php
159
		if(is_array($versions)) {
160
			foreach($versions as $key => $value) {
161
				if(($key == "current") or ($value == 1)) continue;
162
				if(is_array($value)) {
163
					foreach($value as $version) {
164
						if(!$version['time']) $version['time'] = "Unknown";
165
						if(!$version['size']) $version['size'] = "Unknown";
166
						if(!$version['type']) $version['type'] = "Unknown";
167
						$version['category'] = $key;
168
						$times[$version['time']][] = $version;
169
					}
170
				}
171
			}
172
		}
173
		asort($times);
174
		if(is_array($times)) {
175
			foreach($times as $time) {
176
				foreach($time as $version) {
177
?>
178
									<tr>
179
										<td class="listlr">
180
<?php
181
				if($version['time'] != "Unknown") {
182
					echo date("D M j G:i:s", $version['time']);
183
				} else {
184
					echo $version['time'];
185
				}
186
?>
187
										</td>
188
										<td class="listlr"><?= ucfirst($version['category']) ?></td>
189
										<td class="listlr"><?= $version['version'] ?></td>
190
										<td class="listlr"><?= $version['size'] ?></td>
191
										<td class="listlr"><?= ucfirst($version['type']) ?></td>
192
									</tr>
193
<?php
194
				}
195
			}
196
		}
197
?>
63
		</td>
64
	</tr>
65
	<tr>
66
	  <td class="tabcont">
67
	      <table width="100%" border="0" cellpadding="6" cellspacing="0">
68
		<tr>
69
		  <td>
70
		      <!-- progress bar -->
71
		      <center>
72
							<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
73

  
74
							<tr>
75
								<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
76
								</td>
77
								<td>
78
								<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
79
									<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
80
										<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
81
									</td>
198 82
								</table>
199
								<br>
200
								<br>
201
								<script language="javascript">toggleTable('updates', 'tri_updates');</script>
202 83
							</td>
203
						</tr>
204
					</table>
205
					<table align="center">
206
						<tr>
207
							<td>
208
								<form action="system_firmware_auto.php" method="post" enctype="multipart/form-data">
209
									<input name="full" type="submit" class="formbtn" value="Begin Full Update">
210
								</form>
84
							<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
211 85
							</td>
212 86
						</tr>
213 87
					</table>
214
		</div>
88
		      <br>                      
89
		      <!-- command output box -->
90
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='60' rows='7' name='output' id='output' wrap='hard'>
91
		      </textarea>                      
92
		      </center>
93
 			<p>
94
			<center><input id='invokeupgrade' style='visibility:hidden' type="submit" value="Invoke Auto Upgrade">
95
		  </td>
96
		</tr>
97
	      </table>
98
	  </td>
99
	</tr>
100
</table>
101

  
102
<p>
103

  
215 104
<?php
216
	}
105

  
106
/* Define necessary variables. */
107
$firmware_version =	trim(file_get_contents('/etc/version'));
108

  
109
$static_text = "Downloading current version information... ";
110
update_output_window($static_text);
111

  
112
$static_text .= "done.\n";
113
update_output_window($static_text);
114

  
115
if(isset($curcfg['alturl']['enable']))
116
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
117

  
118
update_status("Downloading current version information...");
119
$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
120

  
121
$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
122
$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
123

  
124
$needs_system_upgrade = false;
125
if($current_installed_pfsense_version <> $latest_version) 
126
	$needs_system_upgrade = true;
127

  
128
if(!$latest_version) {
129
		if(isset($curcfg['alturl']['enable']))
130
			update_output_window("Could not contact custom update server.");
131
		else 
132
			update_output_window("Could not contact {$g['product_name']} update server.");
217 133
} else {
218
	print_info_box("Unable to receive version information.");
134
	if($needs_system_upgrade) {
135
		echo "\n<script language=\"JavaScript\">$('invokeupgrade').style.visibility = 'visible';</script>";
136
		update_output_window("A new version is now available. \n\nNew version: {$latest_version}");
137
	} else {
138
		update_output_window("You are on the latest version.");
139
	}
219 140
}
220 141
?>
221
				</td>
222
			</tr>
223
		</table>
224
<?php
225
include("fend.inc");
226
$versions['cachetime'] = time();
227
$fout = fopen("/tmp/versioncheck.cache", "w");
228
fwrite($fout, serialize($versions));
229
fclose($fout);
230
?>
231
	</body>
142

  
143
</form>
144
<?php include("fend.inc"); ?>
145
</body>
232 146
</html>
147

  
148

  
149
</body>
150
</html>
usr/local/www/system_firmware_settings.php
27 27
	POSSIBILITY OF SUCH DAMAGE.
28 28
*/
29 29

  
30
Header("Location: system_firmware.php");
31
exit;
32

  
33 30
require("guiconfig.inc");
34 31

  
35 32
if ($_POST) {
36
	/* input validation */
37
	if($_POST['firmwareurl'] && !is_string($_POST['firmwareurl'])) {
38
		$input_errors[] = "The base XMLRPC URL must be a string.";
39
	}
40
	if($_POST['firmwarepath'] && !is_string($_POST['firmwarepath'])) {
41
		$input_errors[] = "The XMLRPC path must be a string.";
42
	}
43 33
	if (!$input_errors) {
44
		$config['system']['firmware']['branch'] = $_POST['branch'];
45 34
		if($_POST['alturlenable'] == "yes") {
46
			$config['system']['firmware']['alturl']['enable'] = "";
35
			$config['system']['firmware']['alturl']['enable'] = true;
47 36
			$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
48
			$config['system']['firmware']['alturl']['firmwarepath'] = $_POST['firmwarepath'];
49 37
		} else {
50 38
			unset($config['system']['firmware']['alturl']['enable']);
39
			unset($config['system']['firmware']['alturl']['firmwareurl']);
51 40
		}
52 41
		write_config();
53 42
	}
......
62 51

  
63 52
<script language="JavaScript">
64 53
<!--
65
var systemdescs=new Array(4);
66
systemdescs[0]="This patch system uses a combination of unified and binary diffs. This system requires the least bandwidth, but is less forgiving of errors.";
67
systemdescs[1]="This patch system uses tar files to update the system. This requires the most bandwidth, but is more reliable.";
68
systemdescs[2]="This patch system uses tar files for the kernel and base system, and unified diffs for other components.";
69 54

  
70
var branchinfo=new Array(4);
71
branchinfo[0]="The stable branch contains only those updates believed to be stable by the developers.";
72
branchinfo[1]="This branch contains both stable updates as well as those believed to be fairly stable.";
73
branchinfo[2]="This branch contains all released updates, regardless of stability.";
74

  
75
function update_description(itemnum) {
76
        document.forms[0].branchinfo.value=branchinfo[itemnum];
77
}
78 55

  
79 56
function enable_altfirmwareurl(enable_over) {  	 
80 57
	if (document.iform.alturlenable.checked || enable_over) { 	 
81 58
		document.iform.firmwareurl.disabled = 0; 	 
82
		document.iform.firmwarepath.disabled = 0; 	 
83 59
	} else { 	 
84 60
		document.iform.firmwareurl.disabled = 1; 	 
85
		document.iform.firmwarepath.disabled = 1; 	 
86 61
	} 	 
87 62
}
88 63

  
......
111 86
	<tr>
112 87
		<td colspan="2" valign="top" class="listtopic">Firmware Branch</td>
113 88
	</tr>
89

  
114 90
	<tr>
115
                  <td valign="top" class="vncell">Firmware Branch</td>
116
                  <td class="vtable">
117
			<select onChange="update_description(this.selectedIndex);" name="branch" id="branch">
118
			<option value="stable"<?php if($curcfg['branch']=="stable") echo " SELECTED"; ?>>Stable</option>
119
			<option value="beta"<?php if($curcfg['branch']=="beta") echo " SELECTED"; ?>>Beta</option>
120
			<option value="alpha"<?php if($curcfg['branch']=="alpha") echo " SELECTED"; ?>>Alpha</option>
121
			</select>
122
			<br>
123
			<textarea cols="60" rows="2" id="branchinfo" name="branchinfo"style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000; font-size: 8pt;">
124
			</textarea>
125
			<script language="javascript">
126
			update_description(document.forms[0].branch.selectedIndex);
127
			</script>
128
			<br><span class="vexpl">Select the update branch you would like this system to track.</td>
129
	</tr>
130
	<tr>
131
		<td valign="top" class="vncell">Firmware XMLRPC URL</td>
91
		<td valign="top" class="vncell">Firmware Auto Update URL</td>
132 92
		<td class="vtable">
133
			<input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onClick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked"; ?>> Use a different XMLRPC server for firmware upgrades<br>
93
			<input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onClick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked"; ?>> Use a different URL server for firmware upgrades<br>
134 94
			<table>
135
			<tr><td>Base URL:</td><td><input name="firmwareurl" type="input" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['xmlrpcbaseurl']; ?>"></td></tr>
136
			<tr><td>Path:</td><td><input name="firmwarepath" type="input" class="formfld unknown"id="firmwarepath" size="64" value="<?php if($curcfg['alturl']['firmwarepath']) echo $curcfg['alturl']['firmwarepath']; else echo $g['xmlrpcpath']; ?>"></td></tr>
95
			<tr><td>Base URL:</td><td><input name="firmwareurl" type="input" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['']; ?>"></td></tr>
137 96
			</table>
138
			<span class="vexpl">This is where {$g['product_name']} will check for newer firmware versions when the <a href="system_firmware_check.php">System: Firmware: Auto Update</a> page is viewed.</span></td>
97
			<span class="vexpl">This is where <?php echo $g['product_name'] ?> will check for newer firmware versions when the <a href="system_firmware_check.php">System: Firmware: Auto Update</a> page is viewed.</span></td>
139 98
	</tr>
140 99
	<script>enable_altfirmwareurl();</script>
141
<!--
142
	<tr>
143
                  <td width="22%" valign="top" class="vncell">Update Preference</td>
144
                  <td width="78%" class="vtable">
145
			<select onChange="update_description(branchinfo, this.selectedIndex);" name="branch" id="branch">
146
			<option value="patches"<?php if($curcfg['updates']=="diffs") echo " SELECTED"; ?>>Patches</option>
147
			<option value="full"<?php if($curcfg['updates']=="full") echo " SELECTED"; ?>>Full Updates</option>
148
			<option value="combination"<?php if($config['updates']=="combination") echo " SELECTED"; ?>>Combination</option>
149
			</select>
150
			<textarea cols="60" rows="2" id="info" name="info"style="border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;">
151
			</textarea>
152
			<script language="javascript">
153
			update_description(branchinfo, document.forms[0].optimization.selectedIndex);
154
			</script>
155
			<br><span class="vexpl"><b>Select the update branch you would like this system to track</b></td>
156
                </tr>
157
-->
158 100
                <tr>
159 101
                  <td width="22%" valign="top">&nbsp;</td>
160 102
                  <td width="78%">

Also available in: Unified diff