Project

General

Profile

Download (5.54 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
$d_isfwfile = 1;
35
require("guiconfig.inc");
36

    
37
$curcfg = $config['system']['firmware'];
38

    
39
include("head.inc");
40

    
41
?>
42

    
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
</head>
47

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

    
52
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
53

    
54
<?php include("fbegin.inc"); ?>
55
<p class="pgtitle">System: Firmware: Auto Upgrade</p>
56

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

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

    
107
<p>
108

    
109
<?php
110

    
111
/* Define necessary variables. */
112
$firmware_version =	trim(file_get_contents('/etc/version'));
113

    
114
$static_text = "Downloading current version information... ";
115
update_output_window($static_text);
116

    
117
$static_text .= "done.\n";
118
update_output_window($static_text);
119

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

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

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

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

    
137
$needs_system_upgrade = false;
138
if($current_installed_pfsense_version <> $latest_version) 
139
	$needs_system_upgrade = true;
140

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

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

    
165

    
166
</body>
167
</html>
(143-143/175)