Project

General

Profile

Download (6.95 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
    system_firmware.php
6
    Copyright (C) 2004, 2005 Scott Ullrich and Colin Smith
7
    All rights reserved.
8

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

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

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

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

    
31
require_once("guiconfig.inc");
32
require_once("xmlrpc.inc");
33

    
34
if(isset($config['system']['disablefirmwarecheck']))
35
	Header("Location: system_firmware.php");
36

    
37
$versions = check_firmware_version();
38
$pgtitle = "System: Auto Update";
39
include("head.inc");
40

    
41
?>
42
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
43
<?php include("fbegin.inc"); ?>
44
<p class="pgtitle"><?=$pgtitle?></p>
45
		<SCRIPT>
46
		<!--
47
			function toggleTable (table, img) {
48
				var table = document.getElementById(table);
49
				var img = document.getElementById(img);
50
				if (table.rows[0].style.display == 'none') {
51
					for (var r = 0; r < table.rows.length; r++)
52
						table.rows[r].style.display = '';
53
					img.src = "/tri_o_black.gif";
54
				} else {
55
					for (var r = 0; r < table.rows.length; r++)
56
						table.rows[r].style.display = 'none';
57
					img.src = "/tri_c_black.gif";
58
				}
59
			}
60
		//-->
61
		</SCRIPT>
62
		<div id="bottomonly">
63
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
64
			<tr>
65
				<td>
66
<?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
				</td>
74
			</tr>
75
			<tr>
76
				<td class="tabcont">
77
<?php
78
if(is_array($versions)) {
79
?>
80
					<table align="center" width="60%" border="0" cellpadding="0" cellspacing="0">
81
						<tr>
82
							<td width="10%" class="listhdrr">Act</td>
83
							<td width="30%" class="listhdrr">Category</td>
84
							<td width="30%" class="listhdrr">Installed</td>
85
							<td width="30%" class="listhdrr">Current<td>
86
						</tr>
87
<?php
88
	$currentvers = $versions['current'];
89
	foreach($versions as $key => $version) {
90
		if($key == "current") continue;
91
		$currentver = array_shift(explode('-', $currentvers[$key]['version']));
92
		if($version == 1) {
93
			$img = "pass.gif";
94
			$pastlatest = true;
95
		} elseif($currentver > $version[count($version) - 1]['version']) {
96
			$img = "pass.gif";
97
			$pastlatest = true;
98
		} else {
99
			$allinstall = true;
100
			$img = "block.gif";
101
		}
102
?>
103
						<tr valign="top">
104
							<td class="listlr" nowrap align="middle"><img src="<?=$img;?>" width="11" height="11" align="absmiddle"></td>
105
							<td class="listlr"><?= ucfirst($key) ?></td>
106
							<td class="listlr"><?= $currentver ?></td>
107
<?php
108
		if($version == 1) {
109
?>
110
							<td class="listlr"><?= $currentver ?></td>
111
<?php
112
		} elseif($pastlatest) {
113
			$newver = $version[count($version) - 1]['version'];
114
?>
115
							<td class="listbggrey"><font color="#FFFFFFF"><?= $newver ?></td>
116
<?php
117
		} else {
118
			$newver = $version[count($version) - 1]['version'];
119
?>
120
							<td class="listbg"><font color="#FFFFFFF"><?= $newver ?></td>
121
<?php
122
		} 
123
		if(!$pastlatest) {
124
?>
125
							<td valign="middle" class="list" nowrap>
126
								<a href="system_firmware_auto.php?category=<?=$key;?>"><img src="plus.gif" width="17" height="17" border="0"></a>
127
							</td>
128
<?php
129
		}
130
?>
131
						</tr>
132
<?php
133
	}
134
?>
135
					</table>
136
<?php
137
	if($allinstall) {
138
?>
139
					<br>
140
					<br>
141
					<table align="center" width="80%" border="0" cellpadding="0" cellspacing="0">
142
						<tr>
143
							<td align="center"><a href="javascript:toggleTable('updates', 'tri_updates')"><img src="/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>
144
						</tr>
145
						<tr>
146
							<td>
147
								<br>
148
								<br>
149
								<table id="updates" align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
150
									<tr>
151
										<td width="20%" class="listhdrr">Released</td>
152
										<td width="20%" class="listhdrr">Category</td>  
153
										<td width="20%" class="listhdrr">Version</td>
154
										<td width="20%" class="listhdrr">Size</td>
155
										<td width="20%" class="listhdr">Type</td>
156
									</tr>
157
<?php
158
		foreach($versions as $key => $value) {
159
			if(($key == "current") or ($value == 1)) continue;
160
			foreach($value as $version) {
161
				if(!$version['time']) $version['time'] = "Unknown";
162
				if(!$version['size']) $version['size'] = "Unknown";
163
				if(!$version['type']) $version['type'] = "Unknown";
164
				$version['category'] = $key;
165
				$times[$version['time']][] = $version;
166
			}
167
		}
168
		asort($times);
169
		foreach($times as $time) {
170
			foreach($time as $version) {
171
?>
172
									<tr>
173
										<td class="listlr">
174
<?php
175
				if($version['time'] != "Unknown") {
176
					echo date("D M j G:i:s", $version['time']);
177
				} else {
178
					echo $version['time'];
179
				}
180
?>
181
										</td>
182
										<td class="listlr"><?= ucfirst($version['category']) ?></td>
183
										<td class="listlr"><?= $version['version'] ?></td>
184
										<td class="listlr"><?= $version['size'] ?></td>
185
										<td class="listlr"><?= ucfirst($version['type']) ?></td>
186
									</tr>
187
<?php
188
			}
189
		}
190
?>
191
								</table>
192
								<br>
193
								<br>
194
								<script language="javascript">toggleTable('updates', 'tri_updates');</script>
195
							</td>
196
						</tr>
197
					</table>
198
					<table align="center">
199
						<tr>
200
							<td>
201
								<form action="system_firmware_auto.php" method="post" enctype="multipart/form-data">
202
									<input name="full" type="submit" class="formbtn" value="Begin Full Update">
203
								</form>
204
							</td>
205
						</tr>
206
					</table>
207
<?php
208
	}
209
} else {
210
	print_info_box("Unable to receive version information.");
211
}
212
?>
213
				</td>
214
			</tr>
215
		</table>
216
		</div>
217
<?php
218
include("fend.inc");
219
$versions['cachetime'] = time();
220
$fout = fopen("/tmp/versioncheck.cache", "w");
221
fwrite($fout, serialize($versions));
222
fclose($fout);
223
?>
224
<script type="text/javascript">
225
NiftyCheck();
226
Rounded("div#bottomonly","bl br","#FFF","#eeeeee","smooth");
227
</script>
228
	</body>
229
</html>
(107-107/128)