forked from eFiction/v3_stable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
334 lines (324 loc) · 19.6 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
// ----------------------------------------------------------------------
// eFiction 3.0
// Copyright (c) 2007 by Tammy Keefer
// Valid HTML 4.01 Transitional
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
$current = "update";
include("header.php");
$blocks['news']['status'] = 0;
$blocks['info']['status'] = 0;
//make a new TemplatePower object
if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
else $tpl = new TemplatePower("default_tpls/default.tpl");
include("includes/pagesetup.php");
if(file_exists("languages/".$language."_admin.php")) include_once("languages/".$language."_admin.php");
else include_once("languages/en_admin.php");
// end basic page setup
if(!isADMIN) {
$output .= "<script language=\"javascript\" type=\"text/javascript\">
location = \"maintenance.php\";
</script>";
$tpl->assign( "output", $output );
$tpl->printToScreen();
dbclose( );
exit( );
}
$oldVersion = explode(".", $settings['version']);
$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
if($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 3)) {
if($confirm == "yes") {
// For the slow-pokes who haven't updated to 3.1
if($oldVersion[1] == 0 ) {
list($field) = dbrow(dbquery("SELECT field_id FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_name = 'betareader'"));
dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info = '"._YES."' WHERE field = '$field' AND info = '1'");
dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info = '"._NO."' WHERE field = '$field' AND info != '"._YES."'");
dbquery("alter table ".TABLEPREFIX."fanfiction_authorinfo add primary key(uid,field);");
dbquery("alter table ".TABLEPREFIX."fanfiction_blocks drop index block_name;");
dbquery("alter table ".TABLEPREFIX."fanfiction_blocks add unique index block_name (block_name);");
dbquery("alter table ".TABLEPREFIX."fanfiction_categories drop index category;");
dbquery("alter table ".TABLEPREFIX."fanfiction_categories drop index parentcatid;");
dbquery("create index byparent on ".TABLEPREFIX."fanfiction_categories (parentcatid,displayorder);");
dbquery("create index forstoryblock on ".TABLEPREFIX."fanfiction_chapters (sid,validated);");
dbquery("create index byname on ".TABLEPREFIX."fanfiction_classes (class_type,class_name,class_id);");
dbquery("alter table ".TABLEPREFIX."fanfiction_classtypes drop index classtype_title;");
dbquery("create unique index classtype_name on ".TABLEPREFIX."fanfiction_classtypes(classtype_name);");
dbquery("create index code_type on ".TABLEPREFIX."fanfiction_codeblocks(code_type);");
dbquery("alter table ".TABLEPREFIX."fanfiction_comments drop index nid;");
dbquery("alter table ".TABLEPREFIX."fanfiction_comments add index commentlist (nid,time);");
dbquery("alter table ".TABLEPREFIX."fanfiction_favorites drop index uid;");
dbquery("create unique index byitem on ".TABLEPREFIX."fanfiction_favorites (item,type,uid);");
dbquery("create unique index byuid on ".TABLEPREFIX."fanfiction_favorites (uid,type,item);");
dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index seriesid;");
dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index inorder;");
dbquery("alter table ".TABLEPREFIX."fanfiction_inseries add index (seriesid,inorder);");
dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index sid;");
dbquery("alter table ".TABLEPREFIX."fanfiction_inseries add primary key (sid,seriesid);");
dbquery("create index message_name on ".TABLEPREFIX."fanfiction_messages (message_name);");
dbquery("alter table ".TABLEPREFIX."fanfiction_pagelinks drop index link_text;");
dbquery("alter table ".TABLEPREFIX."fanfiction_panels drop index panel_hidden;");
dbquery("alter table ".TABLEPREFIX."fanfiction_panels drop index panel_type;");
dbquery("alter table ".TABLEPREFIX."fanfiction_panels add index panel_type (panel_type,panel_name);");
dbquery("create index avgrating on ".TABLEPREFIX."fanfiction_reviews(type,item,rating);");
dbquery("alter table ".TABLEPREFIX."fanfiction_reviews drop index sid;");
dbquery("create index bychapter on ".TABLEPREFIX."fanfiction_reviews (chapid,rating);");
dbquery("alter table ".TABLEPREFIX."fanfiction_reviews add index byuid (uid,item,type);");
dbquery("alter table ".TABLEPREFIX."fanfiction_series drop index owner;");
dbquery("create index owner on ".TABLEPREFIX."fanfiction_series (uid,title);");
dbquery("alter table ".TABLEPREFIX."fanfiction_stories drop index validated;");
dbquery("create index validateduid on ".TABLEPREFIX."fanfiction_stories (validated,uid);");
dbquery("create index recent on ".TABLEPREFIX."fanfiction_stories (updated,validated);");
$alltables = dbquery("SHOW TABLES");
}
// Still a little behind.
if($oldVersion[1] < 2) {
dbquery("
CREATE TABLE `".TABLEPREFIX."fanfiction_stats` (
`sitekey` varchar(50) NOT NULL default '0',
`stories` int(11) NOT NULL default '0',
`chapters` int(11) NOT NULL default '0',
`series` int(11) NOT NULL default '0',
`reviews` int(11) NOT NULL default '0',
`wordcount` int(11) NOT NULL default '0',
`authors` int(11) NOT NULL default '0',
`members` int(11) NOT NULL default '0',
`reviewers` int(11) NOT NULL default '0',
`newestmember` int(11) NOT NULL default '0'
) ENGINE=MyISAM");
dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_stats(`sitekey`) VALUES('SITEKEY')");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_inseries` DROP `updated`");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_news` ADD `comments` INT NOT NULL DEFAULT '0'");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_series` ADD `numstories` INT NOT NULL DEFAULT '0'");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_pagelinks` ADD `link_key` CHAR( 1 ) NULL AFTER `link_text`");
if(!isset($allowseries)) dbquery("ALTER TABLE `".$settingsprefix."fanfiction_settings` ADD `allowseries` TINYINT NOT NULL DEFAULT '2' AFTER `roundrobins`");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_log` CHANGE `log_ip` `log_ip` INT( 11 ) UNSIGNED NULL DEFAULT NULL");
dbquery("UPDATE ".TABLEPREFIX."fanfiction_inseries SET confirmed = 1");
$serieslist = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_series");
$totalseries = dbnumrows($serieslist);
while($s = dbassoc($serieslist)) {
$numstories = count(storiesInSeries($s['seriesid']));
dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET numstories = '$numstories' WHERE seriesid = ".$s['seriesid']." LIMIT 1");
}
$newslist = dbquery("SELECT count(cid) as count, nid FROM ".TABLEPREFIX."fanfiction_comments GROUP BY nid");
while($n = dbassoc($newslist)) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET comments = '".$n['count']."' WHERE nid = ".$n['nid']);
}
$storiesquery =dbquery("SELECT COUNT(sid) as totals, COUNT(DISTINCT uid) as totala, SUM(wordcount) as totalwords FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 ");
list($stories, $authors, $words) = dbrow($storiesquery);
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET stories = '$stories', authors = '$authors', wordcount = '$words' WHERE sitekey = 'SITEKEY'");
$chapterquery = dbquery("SELECT COUNT(chapid) as chapters FROM ".TABLEPREFIX."fanfiction_chapters where validated > 0");
list($chapters) = dbrow($chapterquery);
$authorquery = dbquery("SELECT COUNT("._UIDFIELD.") as totalm FROM "._AUTHORTABLE);
list($members) = dbrow($authorquery);
list($newest) = dbrow(dbquery("SELECT "._UIDFIELD." as uid FROM "._AUTHORTABLE." ORDER BY "._UIDFIELD." DESC LIMIT 1"));
$reviewquery = dbquery("SELECT COUNT(reviewid) as totalr FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review'");
list($reviews) = dbrow($reviewquery);
$reviewquery = dbquery("SELECT COUNT(DISTINCT uid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review' AND uid > 0");
list($reviewers) = dbrow($reviewquery);
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET series = '$totalseries', chapters = '$chapters', members = '$members', newestmember = '$newest', reviews = '$reviews', reviewers = '$reviewers' WHERE sitekey = 'SITEKEY'");
$news = dbquery("SELECT count(nid) as count, nid FROM ".TABLEPREFIX."fanfiction_comments GROUP BY nid");
while($n = dbassoc($news)) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET comments = '".$n['count']."' WHERE nid = '".$n['nid']."' LIMIT 1");
}
} // End version 3.2 updates.
if($oldVersion[1] < 3) {
dbquery("
CREATE TABLE `".TABLEPREFIX."fanfiction_modules` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(100) NOT NULL default 'Test Module',
`version` varchar(10) NOT NULL default '1.0',
PRIMARY KEY (`id`),
KEY `name_version` (`name`,`version`)
)");
list($panelCount) = dbrow(dbquery("SELECT count(panel_name) AS count FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_type = 'A' AND panel_level = '1' AND panel_hidden = '0'"));
$panelCount++;
dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_panels` (`panel_name`, `panel_title`, `panel_url`, `panel_level`, `panel_order`, `panel_hidden`, `panel_type`) VALUES ('modules', 'Modules', '', 1, ".$panelCount.", 0, 'A')");
// Insert the modules into the table.
$dir = opendir(_BASEDIR."modules");
while($folder = readdir($dir)) {
if($folder == "." || $folder == ".." || !is_dir("modules/$folder")) continue;
if(file_exists("modules/$folder/version.php")) {
$moduleVersion = ""; $moduleName = "";
include("modules/$folder/version.php");
if(empty($moduleName)) $moduleName = $folder;
// The next few lines try to determine if the module is installed.
if($folder == "challenges" && !isset($anonchallenges)) continue;
if($folder == "recommendations" && !isset($anonrecs)) continue;
dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_modules(`name`, `version`) VALUES('$moduleName', '1.0')");
}
}
if($ratings == "1") dbquery("UPDATE ".TABLEPREFIX."fanfiction_reviews SET rating = '-1' WHERE rating = '0'");
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '0', reviews = '0'"); // Set them all to 0 before we re-insert.
$stories = dbquery("SELECT AVG(rating) as average, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND rating != '-1' GROUP BY item");
while($s = dbassoc($stories)) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '".round($s['average'])."' WHERE sid = '".$s['item']."'");
}
$stories = dbquery("SELECT COUNT(reviewid) as count, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND review != 'No Review' GROUP BY item");
while($s = dbassoc($stories)) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET reviews = '".$s['count']."' WHERE sid = '".$s['item']."'");
}
dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '0', reviews = '0'");
$chapters = dbquery("SELECT AVG(rating) as average, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND rating != '-1' GROUP BY chapid");
while($c = dbassoc($chapters)) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '".round($c['average'])."' WHERE chapid = '".$c['chapid']."'");
}
$chapters = dbquery("SELECT COUNT(reviewid) as count, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND review != 'No Review' GROUP BY chapid");
while($c = dbassoc($chapters)) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET reviews = '".$c['count']."' WHERE chapid = '".$c['chapid']."'");
}
dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '0', reviews = '0'");
$series = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_series");
while($s = dbassoc($series)) {
$thisseries = $s['seriesid'];
include("includes/seriesreviews.php");
}
} // End 3.3 updates
// Version 3.3.1 updates
if($oldVersion[1] == 3 && empty($oldVersion[2])) {
if(isset($anonchallenges)) dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_codeblocks` (`code_text`, `code_type`, `code_module`) VALUES('include(_BASEDIR.\"modules/challenges/stats.php\");', 'sitestats', 'challenges');");
}
// Versin 3.4 updates
if($oldVersion[1] < 4) {
dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_coauthors` (
`sid` int(11) NOT NULL default '0',
`uid` int(11) NOT NULL default '0',
PRIMARY KEY (`sid`,`uid`)
) ENGINE=MyISAM;");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_authorprefs` ADD `stories` INT NOT NULL DEFAULT '0'");
$alist = array( );
$authors = dbquery("SELECT uid, count(uid) AS count FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 GROUP BY uid");
while($a = dbassoc($authors)) {
$alist[$a['uid']] = $a['count'];
}
$coauthors = dbquery("SELECT coauthors,sid FROM ".TABLEPREFIX."fanfiction_stories WHERE coauthors != '0'");
while($ca = dbassoc($coauthors)) {
$co = explode(",", $ca['coauthors']);
foreach($co AS $a) {
if(!isNumber($a)) continue;
if(in_array($a, $alist)) $alist[$a]++;
else $alist[$a] = 1;
dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_coauthors(`uid`, `sid`) VALUES('$a', '".$ca['sid']."')");
}
}
foreach($alist AS $a => $s) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = '$s' WHERE uid = '$a' LIMIT 1");
}
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET coauthors = '1' WHERE coauthors != '0'");
}
if($oldVersion[1] == 4 && !isset($oldVersion[2])) {
$statsupdate = dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET sitekey = '".SITEKEY."' WHERE sitekey = 'SITEKEY' LIMIT 1");
$coauthors = dbquery("SHOW TABLES LIKE '".TABLEPREFIX."fanfiction_coauthors'");
if(!dbnumrows($coauthors)) {
dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_coauthors` (
`sid` int(11) NOT NULL default '0',
`uid` int(11) NOT NULL default '0',
PRIMARY KEY (`sid`,`uid`)
) ENGINE=MyISAM;");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_authorprefs` ADD `stories` INT NOT NULL DEFAULT '0'");
}
$authors = dbquery("SELECT uid, count(uid) AS count FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 GROUP BY uid");
while($a = dbassoc($authors)) {
$alist[$a['uid']] = $a['count'];
}
$coauthors = dbquery("SELECT uid, count(sid) AS count FROM ".TABLEPREFIX."fanfiction_coauthors GROUP BY uid");
while($ca = dbassoc($coauthors)) {
if(in_array($ca['uid'], $alist)) $alist[$ca['uid']] = $alist[$ca['uid']] + $ca['count'];
else $alist[$ca['uid']] = $ca['count'];
}
foreach($alist AS $a => $s) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = '$s' WHERE uid = '$a' LIMIT 1");
}
}
if($oldVersion[1] == 4 && $oldVersion[2] < 2) {
$coauthors = dbquery("SHOW TABLES LIKE '".TABLEPREFIX."fanfiction_coauthors'");
if(!dbnumrows($coauthors)) {
dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_coauthors` (
`sid` int(11) NOT NULL default '0',
`uid` int(11) NOT NULL default '0',
PRIMARY KEY (`sid`,`uid`)
) ENGINE=MyISAM;");
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_authorprefs` ADD `stories` INT NOT NULL DEFAULT '0'");
}
$storiesAdded = dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_authorprefs LIKE 'stories'");
if(!$storiesAdded) {
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_authorprefs` ADD `stories` INT NOT NULL DEFAULT '0'");
$authors = dbquery("SELECT uid, count(uid) AS count FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 GROUP BY uid");
while($a = dbassoc($authors)) {
$alist[$a['uid']] = $a['count'];
}
$coauthors = dbquery("SELECT uid, count(sid) AS count FROM ".TABLEPREFIX."fanfiction_coauthors GROUP BY uid");
while($ca = dbassoc($coauthors)) {
if(in_array($ca['uid'], $alist)) $alist[$ca['uid']] = $alist[$ca['uid']] + $ca['count'];
else $alist[$ca['uid']] = $ca['count'];
}
foreach($alist AS $a => $s) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = '$s' WHERE uid = '$a' LIMIT 1");
}
}
}
if($oldVersion[1] == 5) { // Try to fix some errors for people
// Recalculate the story count for authors.
$authors = dbquery("SELECT uid, count(uid) AS count FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 GROUP BY uid");
$alist = array( );
while($a = dbassoc($authors)) {
$alist[$a['uid']] = $a['count'];
}
$coauthors = dbquery("SELECT uid, count(sid) AS count FROM ".TABLEPREFIX."fanfiction_coauthors GROUP BY uid");
while($ca = dbassoc($coauthors)) {
if(isset($alist[$ca['uid']])) $alist[$ca['uid']] = $alist[$ca['uid']] + $ca['count'];
else $alist[$ca['uid']] = $ca['count'];
}
foreach($alist AS $a => $s) {
dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = '$s' WHERE uid = '$a' LIMIT 1");
}
// Recalculate the number of authors
list($authors) = dbrow(dbquery("SELECT count(uid) FROM ".TABLEPREFIX."fanfiction_authorprefs WHERE stories > 0"));
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET authors = '$authors' WHERE sitekey = '".SITEKEY."'");
}
if($oldVersion[1] == 5 && $oldVersion[2] < 3) {
// fix the indexes for the inseries table.
$exists = dbnumrows(dbquery("SHOW INDEX FROM ".TABLEPREFIX."fanfiction_inseries WHERE Key_name = 'seriesid'"));
if($exists) dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index seriesid;");
$exists = dbnumrows(dbquery("SHOW INDEX FROM ".TABLEPREFIX."fanfiction_inseries WHERE Key_name = 'inorder'"));
if($exists) dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index inorder;");
dbquery("alter table ".TABLEPREFIX."fanfiction_inseries add index (seriesid,inorder);");
$exists = dbnumrows(dbquery("SHOW INDEX FROM ".TABLEPREFIX."fanfiction_inseries WHERE Key_name = 'sid'"));
if($exists) dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index sid;");
$exists = dbnumrows(dbquery("SHOW INDEX FROM ".TABLEPREFIX."fanfiction_inseries WHERE Key_name = 'PRIMARY'"));
if($exists) dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop primary key");
dbquery("alter ignore table ".TABLEPREFIX."fanfiction_inseries add primary key (sid,seriesid,subseriesid);");
}
$update = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET version = '".$version."' WHERE sitekey = '".SITEKEY."'");
if($update) $output .= write_message(_ACTIONSUCCESSFUL);
else $output .= write_error(_ERROR);
}
else if($confirm == "no") {
$output .= write_message(_ACTIONCANCELLED);
}
else {
if($oldVersion[0] == 3 && ($oldVersion[1] < 4 || $oldVersion[1] == 4 && (!isset($oldVersion[2]) || $oldVersion[2] < 3))) $output .= write_message(_CONFIRMUPDATE."<br /> <a href='update.php?confirm=yes'>"._YES."</a> "._OR." <a href='update.php?confirm=no'>"._NO."</a>");
else $output .= write_message("Are you ready to update? <a href='update.php?confirm=yes'>"._YES."</a> "._OR." <a href='update.php?confirm=no'>"._NO."</a>");
}
}
else $output .= write_message(_ALREADYUPDATED);
$tpl->assign( "output", $output );
$tpl->printToScreen();
dbclose( );
?>