Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,137 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.0
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+$version = explode(".", $version);
27
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
28
+
29
+if($version[0] == 3 && $version[1] < 2) {
30
+if($confirm == "yes") {
31
+	// For the slow-pokes who haven't updated to 3.1
32
+	if($version[0] == 3 && $version[1] == 0 ) {
33
+		list($field) = dbrow(dbquery("SELECT field_id FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_name = 'betareader'"));
34
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info = '"._YES."' WHERE field = '$field' AND info = '1'");
35
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info = '"._NO."' WHERE field = '$field' AND info != '"._YES."'");
36
+		dbquery("alter table ".TABLEPREFIX."fanfiction_authorinfo add primary key(uid,field);");
37
+		dbquery("alter table ".TABLEPREFIX."fanfiction_blocks drop index block_name;");
38
+		dbquery("alter table ".TABLEPREFIX."fanfiction_blocks add unique index block_name (block_name);");
39
+		dbquery("alter table ".TABLEPREFIX."fanfiction_categories drop index category;");
40
+		dbquery("alter table ".TABLEPREFIX."fanfiction_categories drop index parentcatid;");
41
+		dbquery("create index byparent on ".TABLEPREFIX."fanfiction_categories (parentcatid,displayorder);");
42
+		dbquery("create index forstoryblock on ".TABLEPREFIX."fanfiction_chapters (sid,validated);");
43
+		dbquery("create index byname on ".TABLEPREFIX."fanfiction_classes (class_type,class_name,class_id);");
44
+		dbquery("alter table ".TABLEPREFIX."fanfiction_classtypes drop index classtype_title;");
45
+		dbquery("create unique index classtype_name on ".TABLEPREFIX."fanfiction_classtypes(classtype_name);");
46
+		dbquery("create index code_type on ".TABLEPREFIX."fanfiction_codeblocks(code_type);");
47
+		dbquery("alter table ".TABLEPREFIX."fanfiction_comments drop index nid;");
48
+		dbquery("alter table ".TABLEPREFIX."fanfiction_comments add index commentlist (nid,time);");
49
+		dbquery("alter table ".TABLEPREFIX."fanfiction_favorites drop index uid;");
50
+		dbquery("create unique index byitem on ".TABLEPREFIX."fanfiction_favorites (item,type,uid);");
51
+		dbquery("create unique index byuid on ".TABLEPREFIX."fanfiction_favorites (uid,type,item);");
52
+		dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index seriesid;");
53
+		dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index inorder;");
54
+		dbquery("alter table ".TABLEPREFIX."fanfiction_inseries add index (seriesid,inorder);");
55
+		dbquery("alter table ".TABLEPREFIX."fanfiction_inseries drop index sid;");
56
+		dbquery("alter table ".TABLEPREFIX."fanfiction_inseries add primary key (sid,seriesid);");
57
+		dbquery("create index message_name on ".TABLEPREFIX."fanfiction_messages (message_name);");
58
+		dbquery("alter table ".TABLEPREFIX."fanfiction_pagelinks drop index link_text;");
59
+		dbquery("alter table ".TABLEPREFIX."fanfiction_panels drop index panel_hidden;");
60
+		dbquery("alter table ".TABLEPREFIX."fanfiction_panels drop index panel_type;");
61
+		dbquery("alter table ".TABLEPREFIX."fanfiction_panels add index panel_type (panel_type,panel_name);");
62
+		dbquery("create index avgrating on ".TABLEPREFIX."fanfiction_reviews(type,item,rating);");
63
+		dbquery("alter table ".TABLEPREFIX."fanfiction_reviews drop index sid;");
64
+		dbquery("create index bychapter on ".TABLEPREFIX."fanfiction_reviews (chapid,rating);");
65
+		dbquery("alter table ".TABLEPREFIX."fanfiction_reviews add index byuid (uid,item,type);");
66
+		dbquery("alter table ".TABLEPREFIX."fanfiction_series drop index owner;");
67
+		dbquery("create index owner on ".TABLEPREFIX."fanfiction_series (uid,title);");
68
+		dbquery("alter table ".TABLEPREFIX."fanfiction_stories drop index validated;");
69
+		dbquery("create index validateduid on ".TABLEPREFIX."fanfiction_stories (validated,uid);");
70
+		dbquery("create index recent on ".TABLEPREFIX."fanfiction_stories (updated,validated);");
71
+		$alltables = dbquery("SHOW TABLES");
72
+	}
73
+	dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_stats` (
74
+  `sitekey` varchar(50) collate latin1_general_ci NOT NULL default '0',
75
+  `stories` int(11) NOT NULL default '0',
76
+  `chapters` int(11) NOT NULL default '0',
77
+  `series` int(11) NOT NULL default '0',
78
+  `reviews` int(11) NOT NULL default '0',
79
+  `wordcount` int(11) NOT NULL default '0',
80
+  `authors` int(11) NOT NULL default '0',
81
+  `members` int(11) NOT NULL default '0',
82
+  `reviewers` int(11) NOT NULL default '0',
83
+  `newestmember` int(11) NOT NULL default '0'
84
+) ENGINE=MyISAM");
85
+	dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_stats(`sitekey`) VALUES('".SITEKEY."')");
86
+	dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_inseries` DROP `updated`");
87
+	dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_news` ADD `comments` INT NOT NULL DEFAULT '0'");
88
+	dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_series` ADD `numstories` INT NOT NULL DEFAULT '0'");
89
+	dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_pagelinks` ADD `link_key` CHAR( 1 ) NULL AFTER `link_text`");
90
+	dbquery("ALTER TABLE `".$settingsprefix."fanfiction_settings` ADD `allowseries` TINYINT NOT NULL DEFAULT '2' AFTER `roundrobins`");
91
+	$serieslist = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_series");
92
+	while($s = dbassoc($serieslist)) {
93
+		$numstories = count(storiesInSeries($s['seriesid']));
94
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET numstories = '$numstories' WHERE seriesid = ".$s['seriesid']." LIMIT 1");
95
+	}
96
+	$newslist = dbquery("SELECT count(cid) as count, nid FROM ".TABLEPREFIX."fanfiction_comments GROUP BY nid");
97
+	while($n = dbassoc($newslist)) {
98
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET comments = '".$n['count']." WHERE nid = ".$n['nid']);
99
+	}
100
+
101
+	$storiesquery =dbquery("SELECT COUNT(sid) as totals, COUNT(DISTINCT uid) as totala, SUM(wordcount) as totalwords FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 ");
102
+	list($stories, $authors, $words) = dbrow($storiesquery);
103
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET stories = '$stories', authors = '$authors', wordcount = '$words' WHERE sitekey ='".SITEKEY."'"); 
104
+
105
+	$chapterquery = dbquery("SELECT COUNT(chapid) as chapters FROM ".TABLEPREFIX."fanfiction_chapters where validated > 0");
106
+	list($chapters) = dbrow($chapterquery);
107
+
108
+	$authorquery = dbquery("SELECT COUNT("._UIDFIELD.") as totalm FROM "._AUTHORTABLE);
109
+	list($members) = dbrow($authorquery);
110
+
111
+	$newest = dbrow(dbquery("SELECT "._UIDFIELD." as uid FROM "._AUTHORTABLE." ORDER BY "._UIDFIELD." DESC LIMIT 1"));
112
+	$reviewquery = dbquery("SELECT COUNT(reviewid) as totalr FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review'");
113
+	list($reviews) = dbrow($reviewquery);
114
+	$reviewquery = dbquery("SELECT COUNT(uid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review' AND uid != 0");
115
+	list($reviewers) = dbrow($reviewquery);
116
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET chapters = '$chapters', members = '$members', newestmember = '$newest', reviews = '$reviews', reviewers = '$reviewers' WHERE sitekey ='".SITEKEY."'"); 
117
+	
118
+	$update = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET version = '3.2' WHERE sitekey ='".SITEKEY."'");
119
+	$alltables = dbquery("SHOW TABLES");
120
+	while ($table = dbassoc($alltables)) {
121
+		foreach ($table as $db => $tablename) {
122
+			dbquery("OPTIMIZE TABLE `".$tablename."`");
123
+		}
124
+	}
125
+	if($update) $output .= write_message(_ACTIONSUCCESSFUL);
126
+	else $output .= write_error(_ERROR);
127
+}
128
+else if($confirm == "no") {
129
+	$output .= write_message(_ACTIONCANCELLED);
130
+}
131
+else {
132
+  	$output .= write_message("This update will perform some tasks on the database to better your site's performance.  You are advised to back up your database before starting! <br />
133
+Are you ready to update? <a href='admin.php?action=maintenance&maint=update&amp;confirm=yes'>"._YES."</a> "._OR." <a href='admin.php?action=maintenance&maint=update&amp;confirm=no'>"._NO."</a>");
134
+}
135
+}
136
+else $output .= write_message(_ALREADYUPDATED);
137
+?>
0 138
\ No newline at end of file