Project

General

Profile

Download (7.15 KB) Statistics
| Branch: | Tag: | Revision:
1 3dc6bb60 Scott Ullrich
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5 39e10a30 Colin Smith
    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 3dc6bb60 Scott Ullrich
*/
30
31 6605faea Scott Ullrich
require_once("guiconfig.inc");
32
require_once("xmlrpc.inc");
33 3dc6bb60 Scott Ullrich
34 2629e5d1 Scott Ullrich
if(isset($config['system']['disablefirmwarecheck']))
35 0935ad4d Holger Bauer
	Header("Location: system_firmware.php");
36 52380979 Scott Ullrich
37 74f446e8 Bill Marquette
$versions = check_firmware_version();
38 94656ba5 Bill Marquette
$pgtitle = "System: Firmware: Auto Update";
39 52380979 Scott Ullrich
include("head.inc");
40
41 3dc6bb60 Scott Ullrich
?>
42 74f446e8 Bill Marquette
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
43
<?php include("fbegin.inc"); ?>
44
<p class="pgtitle"><?=$pgtitle?></p>
45 0935ad4d Holger Bauer
		<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 677c0869 Erik Kristensen
					img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_o_black.gif";
54 0935ad4d Holger Bauer
				} else {
55
					for (var r = 0; r < table.rows.length; r++)
56
						table.rows[r].style.display = 'none';
57 677c0869 Erik Kristensen
					img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif";
58 0935ad4d Holger Bauer
				}
59
			}
60
		//-->
61
		</SCRIPT>
62
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
63
			<tr>
64
				<td>
65 4820d297 Scott Ullrich
<?php
66
	$tab_array = array();
67
	$tab_array[0] = array("Manual Update", false, "system_firmware.php");
68
	$tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
69
	$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
70
	display_top_tabs($tab_array);
71
?>
72 0935ad4d Holger Bauer
				</td>
73 1f6b9deb Colin Smith
			</tr>
74 0935ad4d Holger Bauer
			<tr>
75 e12d98ea Bill Marquette
				<td>
76 0935ad4d Holger Bauer
<?php
77
if(is_array($versions)) {
78
?>
79 e12d98ea Bill Marquette
					<div id="mainarea">
80
					<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont">
81 0935ad4d Holger Bauer
						<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 677c0869 Erik Kristensen
			$img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
94 0935ad4d Holger Bauer
			$pastlatest = true;
95 3c554363 John Fleming
		} elseif( strcmp($currentver , $version[count($version) - 1]['version']) ){
96 677c0869 Erik Kristensen
			$img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
97 0935ad4d Holger Bauer
			$pastlatest = true;
98
		} else {
99
			$allinstall = true;
100 677c0869 Erik Kristensen
			$img = "./themes/".$g['theme']."/images/icons/icon_block.gif";
101 0935ad4d Holger Bauer
		}
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 588b7fc5 Bill Marquette
							<td class="listbggrey"><font color="#FFFFFF"><?= $newver ?></td>
116 0935ad4d Holger Bauer
<?php
117
		} else {
118
			$newver = $version[count($version) - 1]['version'];
119
?>
120 588b7fc5 Bill Marquette
							<td class="listbg"><font color="#FFFFFF"><?= $newver ?></td>
121 0935ad4d Holger Bauer
<?php
122
		} 
123
		if(!$pastlatest) {
124
?>
125
							<td valign="middle" class="list" nowrap>
126 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>
127 0935ad4d Holger Bauer
							</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 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>
144 0935ad4d Holger Bauer
						</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 1f6b9deb Colin Smith
<?php
188 0935ad4d Holger Bauer
			}
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 e12d98ea Bill Marquette
		</div>
208 0935ad4d Holger Bauer
<?php
209
	}
210 1f6b9deb Colin Smith
} else {
211 0935ad4d Holger Bauer
	print_info_box("Unable to receive version information.");
212 1f6b9deb Colin Smith
}
213
?>
214 0935ad4d Holger Bauer
				</td>
215
			</tr>
216
		</table>
217 3dc6bb60 Scott Ullrich
<?php
218 0935ad4d Holger Bauer
include("fend.inc");
219
$versions['cachetime'] = time();
220
$fout = fopen("/tmp/versioncheck.cache", "w");
221
fwrite($fout, serialize($versions));
222
fclose($fout);
223 3dc6bb60 Scott Ullrich
?>
224 0935ad4d Holger Bauer
	</body>
225 22abaf42 Bill Marquette
</html>