Project

General

Profile

Download (7.12 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
	system_firmware.php
6
	part of m0n0wall (http://m0n0.ch/wall)
7

    
8
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10

    
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13

    
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16

    
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20

    
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32

    
33
$d_isfwfile = 1;
34
require("guiconfig.inc");
35
require("xmlrpc_client.inc");
36

    
37
function old_checkversion() {
38
        global $g;
39
        $versioncheck_base_url = 'www.pfSense.com';
40
        $versioncheck_path = '/pfSense/checkversion.php';
41
        $post = "platform=" . rawurlencode(trim(file_get_contents("/etc/platform"))) .
42
                "&version=" . rawurlencode(trim(file_get_contents("/etc/version")));
43
        $rfd = @fsockopen($versioncheck_base_url, 80, $errno, $errstr, 3);
44
        if ($rfd) {
45
                $hdr = "POST {$versioncheck_path} HTTP/1.0\r\n";
46
                $hdr .= "Content-Type: application/x-www-form-urlencoded\r\n";
47
                $hdr .= "User-Agent: pfSense-webConfigurator/1.0\r\n";
48
                $hdr .= "Host: www.pfSense.com\r\n";
49
                $hdr .= "Content-Length: " . strlen($post) . "\r\n\r\n";
50

    
51
                fwrite($rfd, $hdr);
52
                fwrite($rfd, $post);
53

    
54
                $inhdr = true;
55
                $resp = "";
56
                while (!feof($rfd)) {
57
                        $line = fgets($rfd);
58
                        if ($inhdr) {
59
                                if (trim($line) == "")
60
                                        $inhdr = false;
61
                        } else {
62
                                $resp .= $line;
63
                        }
64
                }
65

    
66
                fclose($rfd);
67

    
68
                if($_GET['autoupgrade'] <> "")
69
                    return;
70

    
71
                return $resp;
72
        }
73

    
74
        return null;
75
}
76

    
77
?>
78
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
79
<html>
80
<head>
81
<title><?=gentitle("System: Firmware: Invoke Auto Upgrade");?></title>
82
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
83
<link href="gui.css" rel="stylesheet" type="text/css">
84
</head>
85

    
86
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
87

    
88
<?php include("fbegin.inc"); ?>
89
<p class="pgtitle">System: Firmware: Auto Upgrade</p>
90

    
91
<form action="system_firmware_auto.php" method="post">
92
<table width="100%" border="0" cellpadding="0" cellspacing="0">
93
  <tr>
94
    <td>
95
      <ul id="tabnav">
96
	<li class="tabinact"><a href="system_firmware.php">Firmware Update</a></li>
97
    	<li class="tabact">Auto Update</a></li>
98
      </ul>
99
    </td>
100
  </tr>
101
	<tr>
102
	  <td class="tabcont">
103
	      <table width="100%" border="0" cellpadding="6" cellspacing="0">
104
		<tr>
105
		  <td>
106
		      <!-- progress bar -->
107
		      <center>
108
		      <table id="progholder" name="progholder" height='20' border='1' bordercolor='black' width='420' bordercolordark='#000000' bordercolorlight='#000000' style='border-collapse: collapse' colspacing='2' cellpadding='2' cellspacing='2'><tr><td><img border='0' src='progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar'></td></tr></table>
109
		      <br>
110
		      <!-- status box -->
111
                      <input size="60" name="status" id="status" value="Checking version information...">
112
		      <!-- command output box -->
113
		      <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='60' rows='5' name='output' id='output' wrap='hard'>
114
		      </textarea>                      
115
		      </center>
116
                      <p>
117
                      <center><input type="submit" value="Invoke Auto Upgrade">
118
		  </td>
119
		</tr>
120
	      </table>
121
	  </td>
122
	</tr>
123
</table>
124

    
125
<p>
126

    
127
<?php
128

    
129
/* Define necessary variables. */
130
$platform =		trim(file_get_contents('/etc/platform'));
131
$firmware_version =	trim(file_get_contents('/etc/version'));
132
$kernel_version =	trim(file_get_contents('/etc/version_kernel'));
133
$base_version =		trim(file_get_contents('/etc/version_base'));
134
$use_old_checkversion = true;
135

    
136
update_status("Downloading current version information...");
137
$static_text = "Downloading current version information... ";
138
update_output_window($static_text);
139
if($use_old_checkversion == true) {
140
	$versions = old_checkversion();
141
} else {
142
	$versions = check_firmware_version();
143
}
144
$static_text .= "done.\n";
145
update_output_window($static_text);
146

    
147
if($use_old_checkversion == false) {
148
	$upgrades = array('firmware', 'kernel', 'base');
149
	$bdiff_errors = array();
150
	if(array_shift($versions) == true) {
151
		$i = 0;
152
		$need_update = array();
153
		update_status("Found required updates");
154
		foreach($versions as $ver) {
155
			if(is_string($ver[0])) {
156
				$static_text .= ucfirst($upgrades[$i]) . "\n\tInstalled: " . $firmware_version . "\n\tCurrent: " . $ver[count($ver) -1] . "\n";
157
				$needupdate[] = true;
158
			} else {
159
				$needupdate[] = false;
160
			}
161
			$i++;
162
		}
163
		$i = 0;
164
		//              if(isset($versions[3])) $static_text = $versions[4] . '\n'; // If we have additional data (a CHANGELOG etc) to display, do so.
165
	} else {
166
		update_status("No updates required.");
167
	}
168

    
169

    
170
} else {
171
	if($versions != "") {
172
		update_output_window("There are updates available: \n\n" . $versions . "\n\n");
173
		$http_auth_username = "";
174
		$http_auth_password = "";
175
		if($config['system']['proxy_auth_username'])
176
			$http_auth_username = $config['system']['proxy_auth_username'];
177
		if($config['system']['proxy_auth_password'])
178
			$http_auth_password = $config['system']['proxy_auth_password'];
179

    
180
		/* custom firmware option */
181
		if (isset($config['system']['alt_firmware_url']['enabled'])) {
182
			$firmwareurl=$config['system']['alt_firmware_url']['firmware_base_url'];
183
			$firmwarename=$config['system']['alt_firmware_url']['firmware_filename'];
184
		} else {
185
			$firmwareurl=$g['firmwarebaseurl'];
186
			$firmwarename=$g['firmwarefilename'];
187
		}
188
	} elseif($versions == "") {
189
		update_output_window("You are running the latest version of pfSense.");
190
	} elseif(is_null($versions)) {
191
		update_output_window("Unable to receive version information from pfSense.com.");
192
	} else {
193
		update_output_window("An unknown error occurred.");
194
	}
195
}
196

    
197
echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';\n</script>";
198

    
199
?>
200

    
201
</form>
202
<?php include("fend.inc"); ?>
203
</body>
204
</html>
205

    
206

    
207
</body>
208
</html>
(96-96/112)