8d05dc7f1aaf8574d54dbb6e1a80b410046855b4
[racktables] / upgrade.php
1 <?php
2
3 $relnotes = array
4 (
5 '0.17.0' => "LDAP options have been moved to LDAP_options array. This means, that if you were<br>" .
6 "using LDAP authentication for users in version 0.16.x, it will break right after<br>" .
7 "upgrade to 0.17.0. To get things working again, adjust existing secret.php file<br>" .
8 "according to secret-sample.php file provided with 0.17.0 release.<br><br>" .
9 "Another change is the addition of support for file uploads. Files are stored<br>" .
10 "in the database. There are several settings in php.ini which you may need to modify:<br>" .
11 "<ul><li>file_uploads - needs to be On</li>" .
12 "<li>upload_max_filesize - max size for uploaded files</li>" .
13 "<li>post_max_size - max size of all form data submitted via POST (including files)</li></ul><br>" .
14 "Local user accounts used to have 'enabled' flag, which allowed individual blocking and<br>" .
15 "unblocking of each. This flag was dropped in favor of existing mean of access<br>" .
16 "setup (RackCode). An unconditional denying rule is automatically added into RackCode<br>" .
17 "for such blocked account, so the effective security policy remains the same.<br>",
18 );
19
20 // At the moment we assume, that for any two releases we can
21 // sequentally execute all batches, that separate them, and
22 // nothing will break. If this changes one day, the function
23 // below will have to generate smarter upgrade paths, while
24 // the upper layer will remain the same.
25 // Returning an empty array means that no upgrade is necessary.
26 // Returning NULL indicates an error.
27 function getDBUpgradePath ($v1, $v2)
28 {
29 $versionhistory = array
30 (
31 '0.16.4',
32 '0.16.5',
33 '0.16.6',
34 '0.17.0',
35 '0.17.1',
36 '0.17.2',
37 );
38 if (!in_array ($v1, $versionhistory) or !in_array ($v2, $versionhistory))
39 return NULL;
40 $skip = TRUE;
41 $path = NULL;
42 // Now collect all versions > $v1 and <= $v2
43 foreach ($versionhistory as $v)
44 {
45 if ($skip and $v == $v1)
46 {
47 $skip = FALSE;
48 $path = array();
49 continue;
50 }
51 if ($skip)
52 continue;
53 $path[] = $v;
54 if ($v == $v2)
55 break;
56 }
57 return $path;
58 }
59
60 // Upgrade batches are named exactly as the release where they first appear.
61 // That is simple, but seems sufficient for beginning.
62 function executeUpgradeBatch ($batchid)
63 {
64 $query = array();
65 global $dbxlink, $dictreload;
66 switch ($batchid)
67 {
68 case '0.16.5':
69 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4_TREE_SHOW_USAGE','yes','string','no','no','Show address usage in IPv4 tree')";
70 $query[] = "update Config set varvalue = '0.16.5' where varname = 'DB_VERSION'";
71 break;
72 case '0.16.6':
73 $query[] = "update Config set varvalue = '0.16.6' where varname = 'DB_VERSION'";
74 break;
75 case '0.17.0':
76 // create tables for storing files (requires InnoDB support)
77 if (!isInnoDBSupported ())
78 {
79 showFailure ("Cannot upgrade because InnoDB tables are not supported by your MySQL server. See the README for details.", __FILE__);
80 die;
81 }
82
83 $query[] = "alter table Chapter change chapter_no id int(10) unsigned NOT NULL auto_increment";
84 $query[] = "alter table Chapter change chapter_name name char(128) NOT NULL";
85 $query[] = "alter table Chapter drop key chapter_name";
86 $query[] = "alter table Chapter add UNIQUE KEY name (name)";
87 $query[] = "alter table Attribute change attr_id id int(10) unsigned NOT NULL auto_increment";
88 $query[] = "alter table Attribute change attr_type type enum('string','uint','float','dict') default NULL";
89 $query[] = "alter table Attribute change attr_name name char(64) default NULL";
90 $query[] = "alter table Attribute drop key attr_name";
91 $query[] = "alter table Attribute add UNIQUE KEY name (name)";
92 $query[] = "alter table AttributeMap change chapter_no chapter_id int(10) unsigned NOT NULL";
93 $query[] = "alter table Dictionary change chapter_no chapter_id int(10) unsigned NOT NULL";
94 // Only after the above call it is Ok to use reloadDictionary()
95 if (isset ($dictreload[$batchid]))
96 $query = array_merge ($query, reloadDictionary ($dictreload[$batchid]['from'], $dictreload[$batchid]['to']));
97 // schema changes for file management
98 $query[] = "
99 CREATE TABLE `File` (
100 `id` int(10) unsigned NOT NULL auto_increment,
101 `name` char(255) NOT NULL,
102 `type` char(255) NOT NULL,
103 `size` int(10) unsigned NOT NULL,
104 `ctime` datetime NOT NULL,
105 `mtime` datetime NOT NULL,
106 `atime` datetime NOT NULL,
107 `contents` longblob NOT NULL,
108 `comment` text,
109 PRIMARY KEY (`id`),
110 UNIQUE KEY `name` (`name`)
111 ) ENGINE=InnoDB";
112 $query[] = "
113 CREATE TABLE `FileLink` (
114 `id` int(10) unsigned NOT NULL auto_increment,
115 `file_id` int(10) unsigned NOT NULL,
116 `entity_type` enum('ipv4net','ipv4rspool','ipv4vs','object','rack','user') NOT NULL default 'object',
117 `entity_id` int(10) NOT NULL,
118 PRIMARY KEY (`id`),
119 UNIQUE KEY `FileLink-unique` (`file_id`,`entity_type`,`entity_id`),
120 KEY `FileLink-file_id` (`file_id`),
121 CONSTRAINT `FileLink-File_fkey` FOREIGN KEY (`file_id`) REFERENCES `File` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
122 ) ENGINE=InnoDB";
123 $query[] = "ALTER TABLE TagStorage MODIFY COLUMN target_realm enum('file','ipv4net','ipv4rspool','ipv4vs','object','rack','user') NOT NULL default 'object'";
124
125 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (24,'no','network security models')";
126 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (25,'no','wireless models')";
127 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,1,0)";
128 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,2,24)";
129 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,3,0)";
130 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,5,0)";
131 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,14,0)";
132 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,16,0)";
133 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,17,0)";
134 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,18,0)";
135 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,20,0)";
136 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,21,0)";
137 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,22,0)";
138 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (798,24,0)";
139 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (965,1,0)";
140 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (965,3,0)";
141 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (965,2,25)";
142 $query[] = 'alter table IPBonds rename to IPv4Allocation';
143 $query[] = 'alter table PortForwarding rename to IPv4NAT';
144 $query[] = 'alter table IPRanges rename to IPv4Network';
145 $query[] = 'alter table IPAddress rename to IPv4Address';
146 $query[] = 'alter table IPLoadBalancer rename to IPv4LB';
147 $query[] = 'alter table IPRSPool rename to IPv4RSPool';
148 $query[] = 'alter table IPRealServer rename to IPv4RS';
149 $query[] = 'alter table IPVirtualService rename to IPv4VS';
150 $query[] = "alter table TagStorage change column target_realm entity_realm enum('file','ipv4net','ipv4vs','ipv4rspool','object','rack','user') NOT NULL default 'object'";
151 $query[] = 'alter table TagStorage change column target_id entity_id int(10) unsigned NOT NULL';
152 $query[] = 'alter table TagStorage drop key entity_tag';
153 $query[] = 'alter table TagStorage drop key target_id';
154 $query[] = 'alter table TagStorage add UNIQUE KEY `entity_tag` (`entity_realm`,`entity_id`,`tag_id`)';
155 $query[] = 'alter table TagStorage add KEY `entity_id` (`entity_id`)';
156 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_TEXT_MAXCHARS','10240','uint','yes','no','Max chars for text file preview')";
157 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_TEXT_ROWS','25','uint','yes','no','Rows for text file preview')";
158 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_TEXT_COLS','80','uint','yes','no','Columns for text file preview')";
159 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('PREVIEW_IMAGE_MAXPXS','320','uint','yes','no','Max pixels per axis for image file preview')";
160 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('VENDOR_SIEVE','','string','yes','no','Vendor sieve configuration')";
161 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4LB_LISTSRC','{\$typeid_4}','string','yes','no','List source: IPv4 load balancers')";
162 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4OBJ_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8} or {\$typeid_12} or {\$typeid_445} or {\$typeid_447}','string','yes','no','List source: IPv4-enabled objects')";
163 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4NAT_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','List source: IPv4 NAT performers')";
164 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('ASSETWARN_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','List source: object, for which asset tag should be set')";
165 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('NAMEWARN_LISTSRC','{\$typeid_4} or {\$typeid_7} or {\$typeid_8}','string','yes','no','List source: object, for which common name should be set')";
166 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('RACKS_PER_ROW','12','unit','yes','no','Racks per row')";
167 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_PREDICATE_SIEVE','','string','yes','no','Predicate sieve regex(7)')";
168 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_DEFAULT_ANDOR','or','string','no','no','Default list filter boolean operation (or/and)')";
169 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_ANDOR','yes','string','no','no','Suggest and/or selector in list filter')";
170 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_TAGS','yes','string','no','no','Suggest tags in list filter')";
171 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_PREDICATES','yes','string','no','no','Suggest predicates in list filter')";
172 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('FILTER_SUGGEST_EXTRA','no','string','no','no','Suggest extra expression in list filter')";
173 $query[] = "delete from Config where varname = 'USER_AUTH_SRC'";
174 $query[] = "delete from Config where varname = 'COOKIE_TTL'";
175 $query[] = "delete from Config where varname = 'rtwidth_0'";
176 $query[] = "delete from Config where varname = 'rtwidth_1'";
177 $query[] = "delete from Config where varname = 'rtwidth_2'";
178 $query[] = "delete from Config where varname = 'NAMEFUL_OBJTYPES'";
179 $query[] = "delete from Config where varname = 'REQUIRE_ASSET_TAG_FOR'";
180 $query[] = "delete from Config where varname = 'IPV4_PERFORMERS'";
181 $query[] = "delete from Config where varname = 'NATV4_PERFORMERS'";
182 $query[] = "alter table TagTree add column valid_realm set('file','ipv4net','ipv4vs','ipv4rspool','object','rack','user') not null default 'file,ipv4net,ipv4vs,ipv4rspool,object,rack,user' after parent_id";
183 $result = $dbxlink->query ("select user_id, user_name, user_realname from UserAccount where user_enabled = 'no'");
184 while ($row = $result->fetch (PDO::FETCH_ASSOC))
185 $query[] = "update Script set script_text = concat('deny {\$userid_${row['user_id']}} # ${row['user_name']} (${row['user_realname']})\n', script_text) where script_name = 'RackCode'";
186 $query[] = "update Script set script_text = NULL where script_name = 'RackCodeCache'";
187 unset ($result);
188 $query[] = "alter table UserAccount drop column user_enabled";
189
190 $query[] = "CREATE TABLE RackRow ( id int(10) unsigned NOT NULL auto_increment, name char(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM";
191
192 $result = $dbxlink->query ("select dict_key, dict_value from Dictionary where chapter_no = 3");
193 while($row = $result->fetch(PDO::FETCH_NUM))
194 $query[] = "insert into RackRow set id=${row[0]}, name='${row[1]}'";
195 unset ($result);
196 $query[] = "delete from Dictionary where chapter_id = 3";
197 $query[] = "delete from Chapter where id = 3";
198 $query[] = "
199 CREATE TABLE `LDAPCache` (
200 `presented_username` char(64) NOT NULL,
201 `successful_hash` char(40) NOT NULL,
202 `first_success` timestamp NOT NULL default CURRENT_TIMESTAMP,
203 `last_retry` timestamp NOT NULL default '0000-00-00 00:00:00',
204 `displayed_name` char(128) default NULL,
205 `memberof` text,
206 UNIQUE KEY `presented_username` (`presented_username`),
207 KEY `scanidx` (`presented_username`,`successful_hash`)
208 ) ENGINE=InnoDB;";
209 $query[] = "alter table UserAccount modify column user_password_hash char(40) NULL";
210 $query[] = 'ALTER TABLE Rack DROP COLUMN deleted';
211 $query[] = 'ALTER TABLE RackHistory DROP COLUMN deleted';
212 $query[] = 'ALTER TABLE RackObject DROP COLUMN deleted';
213 $query[] = 'ALTER TABLE RackObjectHistory DROP COLUMN deleted';
214 // Can't be added straight due to many duplicates, even in "dictbase" data.
215 $result = $dbxlink->query ('SELECT type1, type2, count(*) - 1 as excess FROM PortCompat GROUP BY type1, type2 HAVING excess > 0');
216 while ($row = $result->fetch (PDO::FETCH_ASSOC))
217 $query[] = "DELETE FROM PortCompat WHERE type1 = ${row['type1']} AND type2 = ${row['type2']} limit ${row['excess']}";
218 unset ($result);
219 $query[] = 'ALTER TABLE PortCompat DROP KEY type1';
220 $query[] = 'ALTER TABLE PortCompat ADD UNIQUE `type1_2` (type1, type2)';
221 $query[] = "UPDATE Config SET varvalue = '0.17.0' WHERE varname = 'DB_VERSION'";
222
223 break;
224 case '0.17.1':
225 $query[] = "ALTER TABLE Dictionary DROP KEY `chap_to_key`";
226 if (isset ($dictreload[$batchid]))
227 $query = array_merge ($query, reloadDictionary ($dictreload[$batchid]['from'], $dictreload[$batchid]['to']));
228 // Token set has changed, so the cache isn't valid any more.
229 $query[] = "UPDATE Script SET script_text = NULL WHERE script_name = 'RackCodeCache'";
230 $query[] = "UPDATE Config SET varvalue = '0.17.1' WHERE varname = 'DB_VERSION'";
231 break;
232 case '0.17.2':
233 $query[] = "INSERT INTO `Chapter` (`id`, `sticky`, `name`) VALUES (26,'no','fibre channel switch models')";
234 if (isset ($dictreload[$batchid]))
235 $query = array_merge ($query, reloadDictionary ($dictreload[$batchid]['from'], $dictreload[$batchid]['to']));
236 $query[] = "INSERT INTO `AttributeMap` (`objtype_id`, `attr_id`, `chapter_id`) VALUES (1055,2,26)";
237 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('DEFAULT_SNMP_COMMUNITY','public','string','no','no','Default SNMP Community string')";
238 // wipe irrelevant records (ticket:250)
239 $query[] = "DELETE FROM TagStorage WHERE entity_realm = 'file' AND entity_id NOT IN (SELECT id FROM File)";
240 $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4_ENABLE_KNIGHT','yes','string','no','no','Enable IPv4 knight feature')";
241 $query[] = "ALTER TABLE IPv4Network ADD COLUMN comment text AFTER name";
242 $query[] = "ALTER TABLE Port ADD INDEX comment (reservation_comment)";
243 $query[] = "ALTER TABLE Port DROP KEY l2address"; // UNIQUE
244 $query[] = "ALTER TABLE Port ADD KEY (l2address)"; // not UNIQUE
245 $query[] = "ALTER TABLE Port DROP KEY object_id";
246 $query[] = "ALTER TABLE Port ADD UNIQUE KEY per_object (object_id, name, type)";
247 $query[] = "UPDATE Config SET varvalue = '0.17.2' WHERE varname = 'DB_VERSION'";
248 break;
249 default:
250 showFailure ("executeUpgradeBatch () failed, because batch '${batchid}' isn't defined", __FILE__);
251 die;
252 break;
253 }
254 $failures = array();
255 echo "<tr><th>Executing batch '${batchid}'</th><td>";
256 foreach ($query as $q)
257 {
258 $result = $dbxlink->query ($q);
259 if ($result == NULL)
260 {
261 $errorInfo = $dbxlink->errorInfo();
262 $failures[] = array ($q, $errorInfo[2]);
263 }
264 }
265 if (!count ($failures))
266 echo "<strong><font color=green>done</font></strong>";
267 else
268 {
269 echo "<strong><font color=red>The following queries failed:</font></strong><br><pre>";
270 foreach ($failures as $f)
271 {
272 list ($q, $i) = $f;
273 echo "${q} -- ${i}\n";
274 }
275 echo "</pre>";
276 }
277 echo '</td></tr>';
278 }
279
280 // ******************************************************************
281 //
282 // Execution starts here
283 //
284 // ******************************************************************
285
286 $root = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://';
287 $root .= isset ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=='80'?'':$_SERVER['SERVER_PORT']));
288 $root .= strtr (dirname ($_SERVER['PHP_SELF']), '\\', '/');
289 if (substr ($root, -1) != '/')
290 $root .= '/';
291
292 // a clone of showError() to drop dependency on interface.php
293 function showFailure ($info = '', $location = 'N/A')
294 {
295 global $root;
296 if (preg_match ('/\.php$/', $location))
297 $location = basename ($location);
298 elseif ($location != 'N/A')
299 $location = $location . '()';
300 echo "<div class=msg_error>An error has occured in [${location}]. ";
301 if (empty ($info))
302 echo 'No additional information is available.';
303 else
304 echo "Additional information:<br><p>\n<pre>\n${info}\n</pre></p>";
305 echo "This failure is most probably fatal.<br></div>\n";
306 }
307
308 require_once 'inc/config.php'; // for CODE_VERSION
309 require_once 'inc/database.php'; // for getDatabaseVersion()
310 require_once 'inc/dictionary.php';
311 // Enforce default value for now, releases prior to 0.17.0 didn't support 'httpd' auth source.
312 $user_auth_src = 'database';
313
314 if (file_exists ('inc/secret.php'))
315 require_once 'inc/secret.php';
316 else
317 die ("Database connection parameters are read from inc/secret.php file, " .
318 "which cannot be found.\nCopy provided inc/secret-sample.php to " .
319 "inc/secret.php and modify to your setup.\n\nThen reload the page.");
320
321 try
322 {
323 $dbxlink = new PDO ($pdo_dsn, $db_username, $db_password);
324 }
325 catch (PDOException $e)
326 {
327 die ("Database connection failed:\n\n" . $e->getMessage());
328 }
329
330 // Now we need to be sure that the current user is the administrator.
331 // The rest doesn't matter within this context.
332
333 function authenticate_admin ($username, $password)
334 {
335 global $dbxlink;
336 $hash = sha1 ($password);
337 $query = "select count(*) from UserAccount where user_id = 1 and user_name = '${username}' and user_password_hash = '${hash}'";
338 if (($result = $dbxlink->query ($query)) == NULL)
339 die ('SQL query failed in ' . __FUNCTION__);
340 $rows = $result->fetchAll (PDO::FETCH_NUM);
341 return $rows[0][0] == 1;
342 }
343
344 switch ($user_auth_src)
345 {
346 case 'database':
347 case 'ldap': // authenticate against DB as well
348 if
349 (
350 !isset ($_SERVER['PHP_AUTH_USER']) or
351 !strlen ($_SERVER['PHP_AUTH_USER']) or
352 !isset ($_SERVER['PHP_AUTH_PW']) or
353 !strlen ($_SERVER['PHP_AUTH_PW']) or
354 !authenticate_admin (escapeString ($_SERVER['PHP_AUTH_USER']), escapeString ($_SERVER['PHP_AUTH_PW']))
355 )
356 {
357 header ('WWW-Authenticate: Basic realm="RackTables upgrade"');
358 header ('HTTP/1.0 401 Unauthorized');
359 showFailure ('You must be authenticated as an administrator to complete the upgrade.', __FILE__);
360 die;
361 }
362 break; // cleared
363 case 'httpd':
364 if
365 (
366 !isset ($_SERVER['REMOTE_USER']) or
367 !strlen ($_SERVER['REMOTE_USER'])
368 )
369 {
370 showFailure ('System misconfiguration. The web-server didn\'t authenticate the user, although ought to do.');
371 die;
372 }
373 break; // cleared
374 default:
375 showFailure ('authentication source misconfiguration', __FILE__);
376 die;
377 }
378
379 $dbver = getDatabaseVersion();
380 echo '<table border=1>';
381 echo "<tr><th>Current status</th><td>Data version: ${dbver}<br>Code version: " . CODE_VERSION . "</td></tr>\n";
382
383 $path = getDBUpgradePath ($dbver, CODE_VERSION);
384 if ($path === NULL)
385 {
386 echo "<tr><th>Upgrade path</th><td><font color=red>not found</font></td></tr>\n";
387 echo "<tr><th>Summary</th><td>Check README for more information.</td></tr>\n";
388 }
389 else
390 {
391 if (!count ($path))
392 echo "<tr><th>Summary</th><td>Come back later.</td></tr>\n";
393 else
394 {
395 echo "<tr><th>Upgrade path</th><td>${dbver} &rarr; " . implode (' &rarr; ', $path) . "</td></tr>\n";
396 foreach ($path as $batchid)
397 {
398 executeUpgradeBatch ($batchid);
399 if (isset ($relnotes[$batchid]))
400 echo "<tr><th>Release notes for ${batchid}</th><td>" . $relnotes[$batchid] . "</td></tr>\n";
401 }
402 echo "<tr><th>Summary</th><td>Upgrade complete, it is Ok to <a href='${root}'>enter</a> the system.</td></tr>\n";
403 }
404 }
405 echo '</table>';
406
407 ?>