Project

General

Profile

Download (5.58 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

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

    
51
?>
52

    
53
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
54
<link href="all.css" rel="stylesheet" type="text/css">
55
</head>
56

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

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

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

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

    
111
<p>
112

    
113
<?php
114

    
115
/* Define necessary variables. */
116
$firmware_version =	trim(file_get_contents('/etc/version'));
117

    
118
$static_text = "Downloading current version information... ";
119
update_output_window($static_text);
120

    
121
$static_text .= "done.\n";
122
update_output_window($static_text);
123

    
124
if(isset($curcfg['alturl']['enable']))
125
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
126
else 
127
	$updater_url = $g['update_url'];
128

    
129
update_output_window("Downloading current version information...");
130
$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
131

    
132
if(strstr($latest_version,"404")) {
133
	update_output_window("Could not download version information file {$updater_url}/version");
134
	include("fend.inc");
135
	exit;	
136
}
137

    
138
$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
139
$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
140

    
141
$needs_system_upgrade = false;
142
if($current_installed_pfsense_version <> $latest_version) 
143
	$needs_system_upgrade = true;
144

    
145
if(!$latest_version) {
146
		if(isset($curcfg['alturl']['enable']))
147
			update_output_window("Could not contact custom update server.");
148
		else 
149
			update_output_window("Could not contact {$g['product_name']} update server {$updater_url}.");
150
} else {
151
	if($needs_system_upgrade) {
152
		echo "\n<script>$('invokeupgrade').style.visibility = 'visible';</script>";
153
		$txt  = "A new version is now available \\n\\n";
154
		$txt .= "New version:     {$latest_version}\\n";
155
		$txt .= "Current version: {$current_installed_pfsense_version}\\n";
156
		$txt .= "Update source:   {$updater_url}\\n";
157
		update_output_window($txt);
158
	} else {
159
		update_output_window("You are on the latest version.");
160
	}
161
}
162
?>
163

    
164
</form>
165
<?php include("fend.inc"); ?>
166
</body>
167
</html>
168

    
169

    
170
</body>
171
</html>
(178-178/215)