Project

General

Profile

Download (6.96 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
$pgtitle = "System: Auto Update";
38
include("head.inc");
39

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