Project

General

Profile

Download (7.26 KB) Statistics
| Branch: | Tag: | Revision:
1 3dc6bb60 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4 39e10a30 Colin Smith
    system_firmware.php
5
    Copyright (C) 2004, 2005 Scott Ullrich and Colin Smith
6
    All rights reserved.
7
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28 3dc6bb60 Scott Ullrich
*/
29
30 9b7d7aa9 Scott Ullrich
Header("Location: system_firmware.php");
31
exit;
32
33 6605faea Scott Ullrich
require_once("guiconfig.inc");
34
require_once("xmlrpc.inc");
35 3dc6bb60 Scott Ullrich
36 2629e5d1 Scott Ullrich
if(isset($config['system']['disablefirmwarecheck']))
37 0935ad4d Holger Bauer
	Header("Location: system_firmware.php");
38 52380979 Scott Ullrich
39 74f446e8 Bill Marquette
$versions = check_firmware_version();
40 d88c6a9f Scott Ullrich
$pgtitle = array("System","Firmware","Auto Update");
41 52380979 Scott Ullrich
include("head.inc");
42
43 3dc6bb60 Scott Ullrich
?>
44 74f446e8 Bill Marquette
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
45
<?php include("fbegin.inc"); ?>
46 0935ad4d Holger Bauer
		<SCRIPT>
47
		<!--
48
			function toggleTable (table, img) {
49
				var table = document.getElementById(table);
50
				var img = document.getElementById(img);
51
				if (table.rows[0].style.display == 'none') {
52
					for (var r = 0; r < table.rows.length; r++)
53
						table.rows[r].style.display = '';
54 677c0869 Erik Kristensen
					img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_o_black.gif";
55 0935ad4d Holger Bauer
				} else {
56
					for (var r = 0; r < table.rows.length; r++)
57
						table.rows[r].style.display = 'none';
58 677c0869 Erik Kristensen
					img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif";
59 0935ad4d Holger Bauer
				}
60
			}
61
		//-->
62
		</SCRIPT>
63
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
64
			<tr>
65
				<td>
66 4820d297 Scott Ullrich
<?php
67
	$tab_array = array();
68
	$tab_array[0] = array("Manual Update", false, "system_firmware.php");
69
	$tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
70
	$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
71
	display_top_tabs($tab_array);
72
?>
73 0935ad4d Holger Bauer
				</td>
74 1f6b9deb Colin Smith
			</tr>
75 0935ad4d Holger Bauer
			<tr>
76 e12d98ea Bill Marquette
				<td>
77 0935ad4d Holger Bauer
<?php
78
if(is_array($versions)) {
79
?>
80 e12d98ea Bill Marquette
					<div id="mainarea">
81
					<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont">
82 0935ad4d Holger Bauer
						<tr>
83
							<td width="10%" class="listhdrr">Act</td>
84
							<td width="30%" class="listhdrr">Category</td>
85
							<td width="30%" class="listhdrr">Installed</td>
86
							<td width="30%" class="listhdrr">Current<td>
87
						</tr>
88
<?php
89
	$currentvers = $versions['current'];
90
	foreach($versions as $key => $version) {
91
		if($key == "current") continue;
92
		$currentver = array_shift(explode('-', $currentvers[$key]['version']));
93
		if($version == 1) {
94 677c0869 Erik Kristensen
			$img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
95 0935ad4d Holger Bauer
			$pastlatest = true;
96 3c554363 John Fleming
		} elseif( strcmp($currentver , $version[count($version) - 1]['version']) ){
97 677c0869 Erik Kristensen
			$img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
98 0935ad4d Holger Bauer
			$pastlatest = true;
99
		} else {
100
			$allinstall = true;
101 677c0869 Erik Kristensen
			$img = "./themes/".$g['theme']."/images/icons/icon_block.gif";
102 0935ad4d Holger Bauer
		}
103
?>
104
						<tr valign="top">
105
							<td class="listlr" nowrap align="middle"><img src="<?=$img;?>" width="11" height="11" align="absmiddle"></td>
106
							<td class="listlr"><?= ucfirst($key) ?></td>
107
							<td class="listlr"><?= $currentver ?></td>
108
<?php
109
		if($version == 1) {
110
?>
111
							<td class="listlr"><?= $currentver ?></td>
112
<?php
113
		} elseif($pastlatest) {
114
			$newver = $version[count($version) - 1]['version'];
115
?>
116 588b7fc5 Bill Marquette
							<td class="listbggrey"><font color="#FFFFFF"><?= $newver ?></td>
117 0935ad4d Holger Bauer
<?php
118
		} else {
119
			$newver = $version[count($version) - 1]['version'];
120
?>
121 588b7fc5 Bill Marquette
							<td class="listbg"><font color="#FFFFFF"><?= $newver ?></td>
122 0935ad4d Holger Bauer
<?php
123
		} 
124
		if(!$pastlatest) {
125
?>
126
							<td valign="middle" class="list" nowrap>
127 677c0869 Erik Kristensen
								<a href="system_firmware_auto.php?category=<?=$key;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
128 0935ad4d Holger Bauer
							</td>
129
<?php
130
		}
131
?>
132
						</tr>
133
<?php
134
	}
135
?>
136
					</table>
137
<?php
138
	if($allinstall) {
139
?>
140
					<br>
141
					<br>
142
					<table align="center" width="80%" border="0" cellpadding="0" cellspacing="0">
143
						<tr>
144 677c0869 Erik Kristensen
							<td align="center"><a href="javascript:toggleTable('updates', 'tri_updates')"><img src="./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif" id="tri_updates" width="14" height="10" border="0"></a><strong><a href="javascript:toggleTable('updates', 'tri_updates')">Needed Updates</a></strong></td>
145 0935ad4d Holger Bauer
						</tr>
146
						<tr>
147
							<td>
148
								<br>
149
								<br>
150
								<table id="updates" align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
151
									<tr>
152
										<td width="20%" class="listhdrr">Released</td>
153
										<td width="20%" class="listhdrr">Category</td>  
154
										<td width="20%" class="listhdrr">Version</td>
155
										<td width="20%" class="listhdrr">Size</td>
156
										<td width="20%" class="listhdr">Type</td>
157
									</tr>
158
<?php
159 66952258 Scott Ullrich
		if(is_array($versions)) {
160
			foreach($versions as $key => $value) {
161
				if(($key == "current") or ($value == 1)) continue;
162
				if(is_array($value)) {
163
					foreach($value as $version) {
164
						if(!$version['time']) $version['time'] = "Unknown";
165
						if(!$version['size']) $version['size'] = "Unknown";
166
						if(!$version['type']) $version['type'] = "Unknown";
167
						$version['category'] = $key;
168
						$times[$version['time']][] = $version;
169
					}
170
				}
171 0935ad4d Holger Bauer
			}
172
		}
173
		asort($times);
174 66952258 Scott Ullrich
		if(is_array($times)) {
175
			foreach($times as $time) {
176
				foreach($time as $version) {
177 0935ad4d Holger Bauer
?>
178
									<tr>
179
										<td class="listlr">
180
<?php
181
				if($version['time'] != "Unknown") {
182
					echo date("D M j G:i:s", $version['time']);
183
				} else {
184
					echo $version['time'];
185
				}
186
?>
187
										</td>
188
										<td class="listlr"><?= ucfirst($version['category']) ?></td>
189
										<td class="listlr"><?= $version['version'] ?></td>
190
										<td class="listlr"><?= $version['size'] ?></td>
191
										<td class="listlr"><?= ucfirst($version['type']) ?></td>
192
									</tr>
193 1f6b9deb Colin Smith
<?php
194 66952258 Scott Ullrich
				}
195 0935ad4d Holger Bauer
			}
196
		}
197
?>
198
								</table>
199
								<br>
200
								<br>
201
								<script language="javascript">toggleTable('updates', 'tri_updates');</script>
202
							</td>
203
						</tr>
204
					</table>
205
					<table align="center">
206
						<tr>
207
							<td>
208
								<form action="system_firmware_auto.php" method="post" enctype="multipart/form-data">
209
									<input name="full" type="submit" class="formbtn" value="Begin Full Update">
210
								</form>
211
							</td>
212
						</tr>
213
					</table>
214 e12d98ea Bill Marquette
		</div>
215 0935ad4d Holger Bauer
<?php
216
	}
217 1f6b9deb Colin Smith
} else {
218 0935ad4d Holger Bauer
	print_info_box("Unable to receive version information.");
219 1f6b9deb Colin Smith
}
220
?>
221 0935ad4d Holger Bauer
				</td>
222
			</tr>
223
		</table>
224 3dc6bb60 Scott Ullrich
<?php
225 0935ad4d Holger Bauer
include("fend.inc");
226
$versions['cachetime'] = time();
227
$fout = fopen("/tmp/versioncheck.cache", "w");
228
fwrite($fout, serialize($versions));
229
fclose($fout);
230 3dc6bb60 Scott Ullrich
?>
231 0935ad4d Holger Bauer
	</body>
232 22abaf42 Bill Marquette
</html>