Project

General

Profile

Download (5.55 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
##|+PRIV
35
##|*IDENT=page-system-firmware-autoupdate
36
##|*NAME=System: Firmware: Auto Update page
37
##|*DESCR=Allow access to the 'System: Firmware: Auto Update' page.
38
##|*MATCH=system_firmware_check.php*
39
##|-PRIV
40

    
41

    
42
$d_isfwfile = 1;
43
require("guiconfig.inc");
44

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

    
49
?>
50

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

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

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

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

    
81
							<tr>
82
								<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
83
								</td>
84
								<td>
85
								<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
86
									<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
87
										<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
88
									</td>
89
								</table>
90
							</td>
91
							<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
92
							</td>
93
						</tr>
94
					</table>
95
		      <br>                      
96
		      <!-- command output box -->
97
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='80' rows='7' name='output' id='output' wrap='hard'>
98
		      </textarea>                      
99
		      </center>
100
 			<p>
101
			<center><input id='invokeupgrade' style='visibility:hidden' type="submit" value="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
$firmware_version =	trim(file_get_contents('/etc/version'));
115

    
116
$static_text = "Downloading current version information... ";
117
update_output_window($static_text);
118

    
119
$static_text .= "done.\n";
120
update_output_window($static_text);
121

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

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

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

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

    
139
$needs_system_upgrade = false;
140
if($current_installed_pfsense_version <> $latest_version) 
141
	$needs_system_upgrade = true;
142

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

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

    
167

    
168
</body>
169
</html>
(179-179/216)