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