Project

General

Profile

Download (7.35 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
?>
38
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
39
<html>
40
<head>
41
<title><?=gentitle("System: Auto Update");?></title>
42
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
43
<link href="gui.css" rel="stylesheet" type="text/css">
44
</head>
45
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
46
<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
	img.src = "/tri_o_black.gif";
55
  } else {
56
	for (var r = 0; r < table.rows.length; r++)
57
		table.rows[r].style.display = 'none';
58
	img.src = "/tri_c_black.gif";
59
  }
60
}
61
-->
62
</SCRIPT>
63
<?php
64
include("fbegin.inc");
65
$versions = check_firmware_version();
66
?>
67
<p class="pgtitle">System: Auto Update</p>
68
<br>
69
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
70
  <ul id="tabnav">
71
    <li class="tabinact"><a href="system_firmware.php">Manual Update</a></li>
72
    <li class="tabact">Auto Update</a></li>
73
    <li class="tabinact"><a href="system_firmware_settings.php">Updater Settings</a></li>
74
  </ul>
75
  </td></tr>
76
  <tr>
77
    <td class="tabcont">
78
<?php if(is_array($versions)) { ?>
79
              <table align="center" width="60%" border="0" cellpadding="0" cellspacing="0">
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

    
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
				
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
				<td class="listbggrey"><font color="#FFFFFFF"><?= $newver ?></td>
117
			<?php
118
			} else {
119
				$newver = $version[count($version) - 1]['version'];
120
			?>
121
				<td class="listbg"><font color="#FFFFFFF"><?= $newver ?></td>
122
			<?php } 
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
			$allinstall = true;
131
		    if($allinstall) {
132
			?></table>
133
			<table align="center" width="80%" border="0" cellpadding="0" cellspacing="0">
134
			<br><br>
135
				<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>
136
			</tr>
137
			<tr><td><table id="updates" align="center" width="100%" border="0" cellpadding="0" cellspacing="0"><br><br>
138
				<tr>
139
					<td width="20%" class="listhdrr">Released</td>
140
                  			<td width="20%" class="listhdrr">Category</td>  
141
                  			<td width="20%" class="listhdrr">Version</td>
142
                 	 		<td width="20%" class="listhdrr">Size</td>
143
                  			<td width="20%" class="listhdr">Type</td>
144
                		</tr>
145
				<?php
146
					foreach($versions as $key => $value) {
147
						if(($key == "current") or ($value == 1)) continue;
148
						foreach($value as $version) {
149
							if(!$version['time']) $version['time'] = "Unknown";
150
							if(!$version['size']) $version['size'] = "Unknown";
151
							if(!$version['type']) $version['type'] = "Unknown";
152
							$version['category'] = $key;
153
							$times[$version['time']][] = $version;
154
						}
155
					}
156
					asort($times);
157
					foreach($times as $time) {
158
						foreach($time as $version) {
159
							echo '<tr>';
160
							echo '<td class="listlr">';
161
								if($version['time'] != "Unknown") {
162
									echo date("D M j G:i:s", $version['time']);
163
								} else {
164
									echo $version['time'];
165
								}
166
							echo '</td>';
167
							echo '<td class="listlr">' . ucfirst($version['category']) . '</td>';
168
							echo '<td class="listlr">' . $version['version'] . '</td>';
169
							echo '<td class="listlr">' . $version['size'] . '</td>';
170
							echo '<td class="listlr">' . ucfirst($version['type']) . '</td>';
171
							echo '</tr>';
172
						}
173
					}
174
				?>
175
				<tr><td><br><br></td></tr>
176
			</table>
177
			<script language="javascript">toggleTable('updates', 'tri_updates');</script>
178
			</td></tr>
179
			</table>
180
                                <table align="center"><tr><td><form action="system_firmware_auto.php" method="post" enctype="multipart/form-data">
181
                                        <input name="full" type="submit" class="formbtn" value="Begin Full Update">
182
                                </form></td></tr></table>
183
		<?php } ?>
184
		</tr>
185
<?php
186
} else {
187
		print_info_box("Unable to receive version information.");
188
}
189
?>
190
    </td>
191
  </tr>
192
</table>
193
<?php
194
	include("fend.inc");
195
	$versions['cachetime'] = time();
196
	$fout = fopen("/tmp/versioncheck.cache", "w");
197
	fwrite($fout, serialize($versions));
198
	fclose($fout);
199
?>
200
</body>
201
</html>
(102-102/123)