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 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
55 |
10d72e1e
|
Scott Ullrich
|
<link href="all.css" rel="stylesheet" type="text/css">
|
56 |
da55e467
|
Scott Ullrich
|
</head>
|
57 |
|
|
|
58 |
74f446e8
|
Bill Marquette
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
59 |
da55e467
|
Scott Ullrich
|
|
60 |
74f446e8
|
Bill Marquette
|
<?php include("fbegin.inc"); ?>
|
61 |
da55e467
|
Scott Ullrich
|
|
62 |
|
|
<form action="system_firmware_auto.php" method="post">
|
63 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
64 |
|
|
<tr>
|
65 |
|
|
<td>
|
66 |
4820d297
|
Scott Ullrich
|
<?php
|
67 |
|
|
$tab_array = array();
|
68 |
a53e451b
|
Carlos Eduardo Ramos
|
$tab_array[0] = array(gettext("Manual Update"), false, "system_firmware.php");
|
69 |
|
|
$tab_array[1] = array(gettext("Auto Update"), true, "system_firmware_check.php");
|
70 |
|
|
$tab_array[2] = array(gettext("Updater Settings"), false, "system_firmware_settings.php");
|
71 |
4820d297
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
72 |
|
|
?>
|
73 |
da55e467
|
Scott Ullrich
|
</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 |
0935ad4d
|
Holger Bauer
|
</table>
|
93 |
|
|
</td>
|
94 |
da55e467
|
Scott Ullrich
|
<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
|
95 |
0935ad4d
|
Holger Bauer
|
</td>
|
96 |
|
|
</tr>
|
97 |
|
|
</table>
|
98 |
939e4a91
|
jim-p
|
<br>
|
99 |
da55e467
|
Scott Ullrich
|
<!-- command output box -->
|
100 |
773c99bc
|
Ermal
|
<textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='90' rows='9' name='output' id='output' wrap='hard'>
|
101 |
939e4a91
|
jim-p
|
</textarea>
|
102 |
da55e467
|
Scott Ullrich
|
</center>
|
103 |
|
|
<p>
|
104 |
a53e451b
|
Carlos Eduardo Ramos
|
<center><input id='invokeupgrade' style='visibility:hidden' type="submit" value="<?=gettext("Invoke Auto Upgrade"); ?>">
|
105 |
da55e467
|
Scott Ullrich
|
</td>
|
106 |
|
|
</tr>
|
107 |
|
|
</table>
|
108 |
|
|
</td>
|
109 |
|
|
</tr>
|
110 |
|
|
</table>
|
111 |
|
|
|
112 |
|
|
<p>
|
113 |
|
|
|
114 |
0935ad4d
|
Holger Bauer
|
<?php
|
115 |
da55e467
|
Scott Ullrich
|
|
116 |
|
|
/* Define necessary variables. */
|
117 |
|
|
if(isset($curcfg['alturl']['enable']))
|
118 |
|
|
$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
|
119 |
939e4a91
|
jim-p
|
else
|
120 |
ef794b01
|
Scott Ullrich
|
$updater_url = $g['update_url'];
|
121 |
da55e467
|
Scott Ullrich
|
$needs_system_upgrade = false;
|
122 |
a53e451b
|
Carlos Eduardo Ramos
|
$static_text .= gettext("Downloading new version information...");
|
123 |
414053da
|
jim-p
|
|
124 |
|
|
$nanosize = "";
|
125 |
|
|
if ($g['platform'] == "nanobsd") {
|
126 |
0d7715eb
|
Renato Botelho
|
if (file_exists("/etc/nano_use_vga.txt"))
|
127 |
|
|
$nanosize = "-nanobsd-vga-";
|
128 |
|
|
else
|
129 |
|
|
$nanosize = "-nanobsd-";
|
130 |
|
|
|
131 |
|
|
$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
|
132 |
414053da
|
jim-p
|
}
|
133 |
|
|
|
134 |
4ed69f33
|
jim-p
|
if(download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true)
|
135 |
d164643a
|
jim-p
|
$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
|
136 |
a53e451b
|
Carlos Eduardo Ramos
|
$static_text .= gettext("done") . "\\n";
|
137 |
a76c1c45
|
jim-p
|
if (!$remote_version) {
|
138 |
a53e451b
|
Carlos Eduardo Ramos
|
$static_text .= gettext("Unable to check for updates.") . "\\n";
|
139 |
93b8266e
|
jim-p
|
if(isset($curcfg['alturl']['enable']))
|
140 |
a53e451b
|
Carlos Eduardo Ramos
|
$static_text .= gettext("Could not contact custom update server.") . "\\n";
|
141 |
93b8266e
|
jim-p
|
else
|
142 |
ddc55e12
|
Erik Fonnesbeck
|
$static_text .= sprintf(gettext('Could not contact %1$s update server %2$s%3$s'), $g['product_name'], $updater_url, "\\n");
|
143 |
93b8266e
|
jim-p
|
} else {
|
144 |
a53e451b
|
Carlos Eduardo Ramos
|
$static_text .= gettext("Obtaining current version information...");
|
145 |
773c99bc
|
Ermal
|
update_output_window($static_text);
|
146 |
a76c1c45
|
jim-p
|
|
147 |
|
|
$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
|
148 |
|
|
$current_installed_version = trim(file_get_contents("/etc/version"));
|
149 |
|
|
|
150 |
|
|
$static_text .= "done\\n";
|
151 |
773c99bc
|
Ermal
|
update_output_window($static_text);
|
152 |
a76c1c45
|
jim-p
|
|
153 |
|
|
if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) {
|
154 |
93b8266e
|
jim-p
|
$needs_system_upgrade = true;
|
155 |
939e4a91
|
jim-p
|
} else {
|
156 |
a53e451b
|
Carlos Eduardo Ramos
|
$static_text .= "\\n" . gettext("You are on the latest version.") . "\\n";
|
157 |
939e4a91
|
jim-p
|
}
|
158 |
773c99bc
|
Ermal
|
}
|
159 |
a76c1c45
|
jim-p
|
|
160 |
773c99bc
|
Ermal
|
update_output_window($static_text);
|
161 |
|
|
if ($needs_system_upgrade == false) {
|
162 |
|
|
require("fend.inc");
|
163 |
|
|
exit;
|
164 |
1f6b9deb
|
Colin Smith
|
}
|
165 |
da55e467
|
Scott Ullrich
|
|
166 |
773c99bc
|
Ermal
|
echo "\n<script>$('invokeupgrade').style.visibility = 'visible';</script>";
|
167 |
a53e451b
|
Carlos Eduardo Ramos
|
$txt = gettext("A new version is now available") . "\\n\\n";
|
168 |
79eaddf4
|
Renato Botelho
|
$txt .= gettext("Current version") .": ". $current_installed_version . "\\n";
|
169 |
414053da
|
jim-p
|
if ($g['platform'] == "nanobsd") {
|
170 |
|
|
$txt .= " " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "\\n";
|
171 |
|
|
}
|
172 |
79eaddf4
|
Renato Botelho
|
$txt .= " " . gettext("Built On") .": ". $current_installed_buildtime . "\\n";
|
173 |
|
|
$txt .= " " . gettext("New version") .": ". $remote_version . "\\n\\n";
|
174 |
|
|
$txt .= " " . gettext("Update source") .": ". $updater_url . "\\n";
|
175 |
773c99bc
|
Ermal
|
update_output_window($txt);
|
176 |
|
|
?>
|
177 |
da55e467
|
Scott Ullrich
|
</form>
|
178 |
|
|
<?php include("fend.inc"); ?>
|
179 |
|
|
</body>
|
180 |
22abaf42
|
Bill Marquette
|
</html>
|