Projet

Général

Profil

Télécharger (7,04 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_firmware_check.php @ 0fab7eb1

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
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
55

    
56
<?php include("fbegin.inc"); ?>
57

    
58
<form action="system_firmware_auto.php" method="post">
59
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware check">
60
	<tr>
61
		<td>
62
		<?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
		</td>
72
	</tr>
73
	<tr>
74
		<td class="tabcont">
75
			<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="">
76
				<tr>
77
					<td align="center">
78
						<!-- progress bar -->
79
						<table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images">
80

    
81
							<tr>
82
								<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_left.gif')" height="15" width="5"></td>
83
								<td>
84
									<table id="progholder" style="height:15;colspacing:0" width="410" border="0" cellpadding="0" cellspacing="0" summary="">
85
										<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
										</td></tr>
88
									</table>
89
								</td>
90
								<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_right.gif')" height="15" width="5"></td>
91
							</tr>
92
						</table>
93
						<br />
94
						<!-- command output box -->
95
						<textarea style="border:1;bordercolordark:#000000;bordercolorlight:#000000" cols="90" rows="9" name="output" id="output" wrap="hard"></textarea>
96
						<div id="backupdiv" style="visibility:hidden">
97
							<?php if ($g['hidebackupbeforeupgrade'] === false): ?>
98
							<br /><input type="checkbox" name="backupbeforeupgrade" id="backupbeforeupgrade" /><?=gettext("Perform full backup prior to upgrade");?>
99
							<?php endif; ?>
100
						</div>
101
						<input id='invokeupgrade' style='visibility:hidden' type="submit" value="<?=gettext("Invoke Auto Upgrade"); ?>" />
102
					</td>
103
				</tr>
104
			</table>
105
		</td>
106
	</tr>
107
</table>
108

    
109
<p>
110

    
111
<?php
112

    
113
/* Define necessary variables. */
114
if(isset($curcfg['alturl']['enable']))
115
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
116
else
117
	$updater_url = $g['update_url'];
118
$needs_system_upgrade = false;
119
$static_text .= gettext("Downloading new version information...");
120

    
121
$nanosize = "";
122
if ($g['platform'] == "nanobsd") {
123
	if (file_exists("/etc/nano_use_vga.txt"))
124
		$nanosize = "-nanobsd-vga-";
125
	else
126
		$nanosize = "-nanobsd-";
127

    
128
	$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
129
}
130

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

    
144
	$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
145
	$current_installed_version = trim(file_get_contents("/etc/version"));
146

    
147
	$static_text .= "done\\n";
148
	update_output_window($static_text);
149

    
150
	if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) {
151
		$needs_system_upgrade = true;
152
	} else {
153
		$static_text .= "\\n" . gettext("You are on the latest version.") . "\\n";
154
	}
155
}
156

    
157
update_output_window($static_text);
158
if ($needs_system_upgrade == false) {
159
	echo "</p>";
160
	echo "</form>";
161
	require("fend.inc");
162
	echo "</body>";
163
	echo "</html>";
164
	exit;
165
}
166

    
167
echo "\n<script type=\"text/javascript\">\n";
168
echo "//<![CDATA[\n";
169
echo "jQuery('#invokeupgrade').css('visibility','visible');\n";
170
echo "//]]>\n";
171
echo "</script>\n";
172
echo "\n<script type=\"text/javascript\">\n";
173
echo "//<![CDATA[\n";
174
echo "jQuery('#backupdiv').css('visibility','visible');\n";
175
echo "//]]>\n";
176
echo "</script>\n";
177

    
178
$txt  = gettext("A new version is now available") . "\\n\\n";
179
$txt .= gettext("Current version") .": ". $current_installed_version . "\\n";
180
if ($g['platform'] == "nanobsd") {
181
	$txt .= "  " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "\\n";
182
}
183
$txt .= "       " . gettext("Built On") .": ".  $current_installed_buildtime . "\\n";
184
$txt .= "    " . gettext("New version") .": ".  htmlspecialchars($remote_version, ENT_QUOTES | ENT_HTML401). "\\n\\n";
185
$txt .= "  " . gettext("Update source") .": ".  $updater_url . "\\n";
186
update_output_window($txt);
187
?>
188
</p>
189
</form>
190
<?php include("fend.inc"); ?>
191
</body>
192
</html>
(215-215/254)