Project

General

Profile

Download (7.13 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    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
*/
29

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

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

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

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