Project

General

Profile

Download (6.59 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_firmware.php
5
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
6
	All rights reserved.
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	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

    
18
	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

    
22
	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
/*
34
	pfSense_MODULE:	firmware
35
*/
36

    
37
##|+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
$d_isfwfile = 1;
45
require("guiconfig.inc");
46
require_once("pfsense-utils.inc");
47

    
48
$curcfg = $config['system']['firmware'];
49
$pgtitle=array(gettext("System"), gettext("Firmware"), gettext("Auto Update"));
50
include("head.inc");
51

    
52
?>
53

    
54
</head>
55

    
56
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
57

    
58
<?php include("fbegin.inc"); ?>
59

    
60
<form action="system_firmware_auto.php" method="post">
61
<table width="100%" border="0" cellpadding="0" cellspacing="0">
62
	<tr>
63
		<td>
64
<?php
65
	$tab_array = array();
66
	$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
67
	$tab_array[] = array(gettext("Auto Update"), true, "system_firmware_check.php");
68
	$tab_array[] = array(gettext("Updater Settings"), false, "system_firmware_settings.php");
69
	if($g['hidedownloadbackup'] == false)
70
		$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
71
	display_top_tabs($tab_array);
72
?>
73
		</td>
74
	</tr>
75
	<tr>
76
	  <td class="tabcont">
77
	      <table width="100%" border="0" cellpadding="6" cellspacing="0">
78
		<tr>
79
		  <td>
80
		      <!-- progress bar -->
81
		      <center>
82
							<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
83

    
84
							<tr>
85
								<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
86
								</td>
87
								<td>
88
								<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
89
									<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
90
										<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
91
									</td>
92
								</table>
93
							</td>
94
							<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
95
							</td>
96
						</tr>
97
					</table>
98
		      <br>
99
		      <!-- command output box -->
100
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='90' rows='9' name='output' id='output' wrap='hard'>
101
		      </textarea>
102
			  <div id='backupdiv' name='backupdiv' style='visibility:hidden'>
103
			  	<br/><input type="checkbox" name='backupbeforeupgrade' id='backupbeforeupgrade'> <?=gettext("Perform full backup prior to upgrade");?>
104
			  </div>
105
		      </center>
106
 			<p>
107
			<center><input id='invokeupgrade' style='visibility:hidden' type="submit" value="<?=gettext("Invoke Auto Upgrade"); ?>">
108
		  </td>
109
		</tr>
110
	      </table>
111
	  </td>
112
	</tr>
113
</table>
114

    
115
<p>
116

    
117
<?php
118

    
119
/* Define necessary variables. */
120
if(isset($curcfg['alturl']['enable']))
121
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
122
else
123
	$updater_url = $g['update_url'];
124
$needs_system_upgrade = false;
125
$static_text .= gettext("Downloading new version information...");
126

    
127
$nanosize = "";
128
if ($g['platform'] == "nanobsd") {
129
	if (file_exists("/etc/nano_use_vga.txt"))
130
		$nanosize = "-nanobsd-vga-";
131
	else
132
		$nanosize = "-nanobsd-";
133

    
134
	$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
135
}
136

    
137
if(download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true)
138
	$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
139
$static_text .= gettext("done") . "\\n";
140
if (!$remote_version) {
141
	$static_text .= gettext("Unable to check for updates.") . "\\n";
142
	if(isset($curcfg['alturl']['enable']))
143
		$static_text .= gettext("Could not contact custom update server.") . "\\n";
144
	else
145
		$static_text .= sprintf(gettext('Could not contact %1$s update server %2$s%3$s'), $g['product_name'], $updater_url, "\\n");
146
} else {
147
	$static_text .= gettext("Obtaining current version information...");
148
	update_output_window($static_text);
149

    
150
	$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
151
	$current_installed_version = trim(file_get_contents("/etc/version"));
152

    
153
	$static_text .= "done\\n";
154
	update_output_window($static_text);
155

    
156
	if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) {
157
		$needs_system_upgrade = true;
158
	} else {
159
		$static_text .= "\\n" . gettext("You are on the latest version.") . "\\n";
160
	}
161
}
162

    
163
update_output_window($static_text);
164
if ($needs_system_upgrade == false) {
165
	require("fend.inc");
166
	exit;
167
}
168

    
169
echo "\n<script>jQuery('#invokeupgrade').css('visibility','visible');</script>";
170
echo "\n<script>jQuery('#backupdiv').css('visibility','visible');</script>";
171

    
172
$txt  = gettext("A new version is now available") . "\\n\\n";
173
$txt .= gettext("Current version") .": ". $current_installed_version . "\\n";
174
if ($g['platform'] == "nanobsd") {
175
	$txt .= "  " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "\\n";
176
}
177
$txt .= "       " . gettext("Built On") .": ".  $current_installed_buildtime . "\\n";
178
$txt .= "    " . gettext("New version") .": ".  $remote_version . "\\n\\n";
179
$txt .= "  " . gettext("Update source") .": ".  $updater_url . "\\n";
180
update_output_window($txt);
181
?>
182
</form>
183
<?php include("fend.inc"); ?>
184
</body>
185
</html>
(210-210/249)