Project

General

Profile

Download (5.45 KB) Statistics
| Branch: | Tag: | Revision:
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
	
8
	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
34
$d_isfwfile = 1;
35
require("guiconfig.inc");
36 3dc6bb60 Scott Ullrich
37 da55e467 Scott Ullrich
$curcfg = $config['system']['firmware'];
38 52380979 Scott Ullrich
39
include("head.inc");
40
41 3dc6bb60 Scott Ullrich
?>
42 da55e467 Scott Ullrich
43
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
44
45
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
46
<link href="gui.css" rel="stylesheet" type="text/css">
47
</head>
48
49 74f446e8 Bill Marquette
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
50 da55e467 Scott Ullrich
51 74f446e8 Bill Marquette
<?php include("fbegin.inc"); ?>
52 d402dcaa Scott Dale
<p class="pgtitle">System: Firmware: Auto Update</p>
53 da55e467 Scott Ullrich
54
<form action="system_firmware_auto.php" method="post">
55
<table width="100%" border="0" cellpadding="0" cellspacing="0">
56
	<tr>
57
		<td>
58 4820d297 Scott Ullrich
<?php
59
	$tab_array = array();
60
	$tab_array[0] = array("Manual Update", false, "system_firmware.php");
61 e15be9c5 Scott Dale
	$tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
62 4820d297 Scott Ullrich
	$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
63
	display_top_tabs($tab_array);
64
?>
65 da55e467 Scott Ullrich
		</td>
66
	</tr>
67
	<tr>
68
	  <td class="tabcont">
69
	      <table width="100%" border="0" cellpadding="6" cellspacing="0">
70
		<tr>
71
		  <td>
72
		      <!-- progress bar -->
73
		      <center>
74
							<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
75
76
							<tr>
77
								<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
78
								</td>
79
								<td>
80
								<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
81
									<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
82
										<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
83
									</td>
84 0935ad4d Holger Bauer
								</table>
85
							</td>
86 da55e467 Scott Ullrich
							<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
87 0935ad4d Holger Bauer
							</td>
88
						</tr>
89
					</table>
90 da55e467 Scott Ullrich
		      <br>                      
91
		      <!-- command output box -->
92
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='60' rows='7' name='output' id='output' wrap='hard'>
93
		      </textarea>                      
94
		      </center>
95
 			<p>
96
			<center><input id='invokeupgrade' style='visibility:hidden' type="submit" value="Invoke Auto Upgrade">
97
		  </td>
98
		</tr>
99
	      </table>
100
	  </td>
101
	</tr>
102
</table>
103
104
<p>
105
106 0935ad4d Holger Bauer
<?php
107 da55e467 Scott Ullrich
108
/* Define necessary variables. */
109
$firmware_version =	trim(file_get_contents('/etc/version'));
110
111
$static_text = "Downloading current version information... ";
112
update_output_window($static_text);
113
114
$static_text .= "done.\n";
115
update_output_window($static_text);
116
117
if(isset($curcfg['alturl']['enable']))
118
	$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
119 52629104 Scott Ullrich
else 
120 ef794b01 Scott Ullrich
	$updater_url = $g['update_url'];
121 da55e467 Scott Ullrich
122
update_status("Downloading current version information...");
123
$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
124
125 df0631d1 Scott Ullrich
if(strstr($latest_version,"404")) {
126
	update_output_window("Could not download version information file {$updater_url}/version");
127
	include("fend.inc");
128
	exit;	
129
}
130
131 da55e467 Scott Ullrich
$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
132
$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
133
134
$needs_system_upgrade = false;
135
if($current_installed_pfsense_version <> $latest_version) 
136
	$needs_system_upgrade = true;
137
138
if(!$latest_version) {
139
		if(isset($curcfg['alturl']['enable']))
140
			update_output_window("Could not contact custom update server.");
141
		else 
142 ef794b01 Scott Ullrich
			update_output_window("Could not contact {$g['product_name']} update server {$updater_url}.");
143 1f6b9deb Colin Smith
} else {
144 da55e467 Scott Ullrich
	if($needs_system_upgrade) {
145
		echo "\n<script language=\"JavaScript\">$('invokeupgrade').style.visibility = 'visible';</script>";
146 55337ac5 Scott Ullrich
		$txt  = "A new version is now available \\n\\n";
147
		$txt .= "New version:     {$latest_version}\\n";
148
		$txt .= "Current version: {$current_installed_pfsense_version}\\n";
149 3e08a4fb Scott Ullrich
		$txt .= "Update source:   {$updater_url}\\n";
150 55337ac5 Scott Ullrich
		update_output_window($txt);
151 da55e467 Scott Ullrich
	} else {
152
		update_output_window("You are on the latest version.");
153
	}
154 1f6b9deb Colin Smith
}
155
?>
156 da55e467 Scott Ullrich
157
</form>
158
<?php include("fend.inc"); ?>
159
</body>
160 22abaf42 Bill Marquette
</html>
161 da55e467 Scott Ullrich
162
163
</body>
164
</html>