Project

General

Profile

Download (7.2 KB) Statistics
| Branch: | Tag: | Revision:
1 3dc6bb60 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4 da55e467 Scott Ullrich
	system_firmware.php
5 21602de0 Scott Ullrich
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
6
	All rights reserved.
7 939e4a91 jim-p
8 21602de0 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
9 da55e467 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 3dc6bb60 Scott Ullrich
18 da55e467 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21 9b7d7aa9 Scott Ullrich
22 da55e467 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33 1d333258 Scott Ullrich
/*
34
	pfSense_MODULE:	firmware
35
*/
36 da55e467 Scott Ullrich
37 6b07c15a Matthew Grooms
##|+PRIV
38
##|*IDENT=page-system-firmware-autoupdate
39
##|*NAME=System: Firmware: Auto Update page
40
##|*DESCR=Allow access to the 'System: Firmware: Auto Update' page.
41
##|*MATCH=system_firmware_check.php*
42
##|-PRIV
43
44 da55e467 Scott Ullrich
$d_isfwfile = 1;
45
require("guiconfig.inc");
46 773c99bc Ermal
require_once("pfsense-utils.inc");
47 3dc6bb60 Scott Ullrich
48 da55e467 Scott Ullrich
$curcfg = $config['system']['firmware'];
49 a53e451b Carlos Eduardo Ramos
$pgtitle=array(gettext("System"), gettext("Firmware"), gettext("Auto Update"));
50 52380979 Scott Ullrich
include("head.inc");
51
52 3dc6bb60 Scott Ullrich
?>
53 da55e467 Scott Ullrich
54 74f446e8 Bill Marquette
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
55 da55e467 Scott Ullrich
56 74f446e8 Bill Marquette
<?php include("fbegin.inc"); ?>
57 da55e467 Scott Ullrich
58
<form action="system_firmware_auto.php" method="post">
59 e8df541c Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware check">
60 da55e467 Scott Ullrich
	<tr>
61
		<td>
62 4b805dbc Renato Botelho
		<?php
63
			$tab_array = array();
64
			$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
65
			$tab_array[] = array(gettext("Auto Update"), true, "system_firmware_check.php");
66
			$tab_array[] = array(gettext("Updater Settings"), false, "system_firmware_settings.php");
67
			if($g['hidedownloadbackup'] == false)
68
				$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
69
			display_top_tabs($tab_array);
70
		?>
71 da55e467 Scott Ullrich
		</td>
72
	</tr>
73
	<tr>
74 4b805dbc Renato Botelho
		<td class="tabcont">
75 e8df541c Colin Fleming
			<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="">
76 4b805dbc Renato Botelho
				<tr>
77 e8df541c Colin Fleming
					<td align="center">
78 4b805dbc Renato Botelho
						<!-- progress bar -->
79 e8df541c Colin Fleming
						<table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images">
80 da55e467 Scott Ullrich
81
							<tr>
82 7bc1b968 Renato Botelho
								<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_left.gif')" height="15" width="5"></td>
83 da55e467 Scott Ullrich
								<td>
84 e8df541c Colin Fleming
									<table id="progholder" style="height:15;colspacing:0" width="410" border="0" cellpadding="0" cellspacing="0" summary="">
85 7bc1b968 Renato Botelho
										<tr><td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
86
										<img src="./themes/<?=$g['theme'];?>/images/misc/bar_blue.gif" width="0" height="15" name="progressbar" id="progressbar" alt="" />
87 e8df541c Colin Fleming
										</td></tr>
88 4b805dbc Renato Botelho
									</table>
89
								</td>
90 7bc1b968 Renato Botelho
								<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_right.gif')" height="15" width="5"></td>
91 4b805dbc Renato Botelho
							</tr>
92
						</table>
93 e8df541c Colin Fleming
						<br />
94 4b805dbc Renato Botelho
						<!-- command output box -->
95 587ecd08 Colin Fleming
						<script type="text/javascript">
96
						//<![CDATA[
97
						window.onload=function(){
98
							document.getElementById("output").wrap='hard';
99
						}
100
						//]]>
101
						</script>
102
						<textarea style="border:1;bordercolordark:#000000;bordercolorlight:#000000" cols="90" rows="9" name="output" id="output"></textarea>
103 e8df541c Colin Fleming
						<div id="backupdiv" style="visibility:hidden">
104 9beebb5e Renato Botelho
							<?php if ($g['hidebackupbeforeupgrade'] === false): ?>
105 8cd558b6 ayvis
							<br /><input type="checkbox" name="backupbeforeupgrade" id="backupbeforeupgrade" /><?=gettext("Perform full backup prior to upgrade");?>
106 9beebb5e Renato Botelho
							<?php endif; ?>
107 4b805dbc Renato Botelho
						</div>
108 e8df541c Colin Fleming
						<input id='invokeupgrade' style='visibility:hidden' type="submit" value="<?=gettext("Invoke Auto Upgrade"); ?>" />
109 4b805dbc Renato Botelho
					</td>
110
				</tr>
111
			</table>
112
		</td>
113 da55e467 Scott Ullrich
	</tr>
114
</table>
115
116
<p>
117
118 0935ad4d Holger Bauer
<?php
119 da55e467 Scott Ullrich
120
/* Define necessary variables. */
121
if(isset($curcfg['alturl']['enable']))
122
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
123 939e4a91 jim-p
else
124 ef794b01 Scott Ullrich
	$updater_url = $g['update_url'];
125 da55e467 Scott Ullrich
$needs_system_upgrade = false;
126 a53e451b Carlos Eduardo Ramos
$static_text .= gettext("Downloading new version information...");
127 414053da jim-p
128
$nanosize = "";
129
if ($g['platform'] == "nanobsd") {
130 0d7715eb Renato Botelho
	if (file_exists("/etc/nano_use_vga.txt"))
131
		$nanosize = "-nanobsd-vga-";
132
	else
133
		$nanosize = "-nanobsd-";
134
135
	$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
136 414053da jim-p
}
137
138 4ed69f33 jim-p
if(download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true)
139 d164643a jim-p
	$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
140 a53e451b Carlos Eduardo Ramos
$static_text .= gettext("done") . "\\n";
141 a76c1c45 jim-p
if (!$remote_version) {
142 a53e451b Carlos Eduardo Ramos
	$static_text .= gettext("Unable to check for updates.") . "\\n";
143 93b8266e jim-p
	if(isset($curcfg['alturl']['enable']))
144 a53e451b Carlos Eduardo Ramos
		$static_text .= gettext("Could not contact custom update server.") . "\\n";
145 93b8266e jim-p
	else
146 ddc55e12 Erik Fonnesbeck
		$static_text .= sprintf(gettext('Could not contact %1$s update server %2$s%3$s'), $g['product_name'], $updater_url, "\\n");
147 93b8266e jim-p
} else {
148 a53e451b Carlos Eduardo Ramos
	$static_text .= gettext("Obtaining current version information...");
149 773c99bc Ermal
	update_output_window($static_text);
150 a76c1c45 jim-p
151
	$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
152
	$current_installed_version = trim(file_get_contents("/etc/version"));
153
154
	$static_text .= "done\\n";
155 773c99bc Ermal
	update_output_window($static_text);
156 a76c1c45 jim-p
157
	if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) {
158 93b8266e jim-p
		$needs_system_upgrade = true;
159 939e4a91 jim-p
	} else {
160 a53e451b Carlos Eduardo Ramos
		$static_text .= "\\n" . gettext("You are on the latest version.") . "\\n";
161 939e4a91 jim-p
	}
162 773c99bc Ermal
}
163 a76c1c45 jim-p
164 773c99bc Ermal
update_output_window($static_text);
165
if ($needs_system_upgrade == false) {
166 e8df541c Colin Fleming
	echo "</p>";
167
	echo "</form>";
168 773c99bc Ermal
	require("fend.inc");
169 e8df541c Colin Fleming
	echo "</body>";
170
	echo "</html>";
171 773c99bc Ermal
	exit;
172 1f6b9deb Colin Smith
}
173 da55e467 Scott Ullrich
174 e8df541c Colin Fleming
echo "\n<script type=\"text/javascript\">\n";
175
echo "//<![CDATA[\n";
176
echo "jQuery('#invokeupgrade').css('visibility','visible');\n";
177
echo "//]]>\n";
178
echo "</script>\n";
179
echo "\n<script type=\"text/javascript\">\n";
180
echo "//<![CDATA[\n";
181
echo "jQuery('#backupdiv').css('visibility','visible');\n";
182
echo "//]]>\n";
183
echo "</script>\n";
184 a30afe0e Scott Ullrich
185 a53e451b Carlos Eduardo Ramos
$txt  = gettext("A new version is now available") . "\\n\\n";
186 79eaddf4 Renato Botelho
$txt .= gettext("Current version") .": ". $current_installed_version . "\\n";
187 414053da jim-p
if ($g['platform'] == "nanobsd") {
188
	$txt .= "  " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "\\n";
189
}
190 79eaddf4 Renato Botelho
$txt .= "       " . gettext("Built On") .": ".  $current_installed_buildtime . "\\n";
191 f458b2cb Renato Botelho
$txt .= "    " . gettext("New version") .": ".  htmlspecialchars($remote_version, ENT_QUOTES | ENT_HTML401). "\\n\\n";
192 79eaddf4 Renato Botelho
$txt .= "  " . gettext("Update source") .": ".  $updater_url . "\\n";
193 773c99bc Ermal
update_output_window($txt);
194
?>
195 e8df541c Colin Fleming
</p>
196 da55e467 Scott Ullrich
</form>
197
<?php include("fend.inc"); ?>
198
</body>
199 22abaf42 Bill Marquette
</html>