Browse code

Fix MySQL table creation, TYPE to ENGINE

Rainer Volkrodt authored on 2016/03/21 11:50:45
Showing 1 changed files
... ...
@@ -737,14 +737,14 @@ ADD `rating` TINYINT( 4 ) NOT NULL");
737 737
   `field_code_out` text,
738 738
   `field_on` tinyint(1) NOT NULL default '0',
739 739
   PRIMARY KEY  (`field_id`)
740
-) TYPE=MyISAM;");
740
+) ENGINE=MyISAM;");
741 741
 $output .= "<tr><td>".$tableprefix."fanfiction_authorfields</td><td align='center'>" . ($authorfields ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
742 742
 				$authorinfo = dbquery("CREATE TABLE `".$tableprefix."fanfiction_authorinfo` (
743 743
   `uid` int(11) NOT NULL default '0',
744 744
   `field` int(11) NOT NULL default '0',
745 745
   `info` varchar(255) NOT NULL default ' ',
746 746
   KEY `uid` (`uid`)
747
-) TYPE=MyISAM;");
747
+) ENGINE=MyISAM;");
748 748
 $output .= "<tr><td>".$tableprefix."fanfiction_authorinfo</td><td align='center'>" . ($authorinfo ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
749 749
 				$authorprefs = dbquery("
750 750
 CREATE TABLE `".$tableprefix."fanfiction_authorprefs` (
... ...
@@ -763,7 +763,7 @@ CREATE TABLE `".$tableprefix."fanfiction_authorprefs` (
763 763
   `contact` tinyint(1) NOT NULL default '0',
764 764
   `stories` int(11) NOT NULL default '0',
765 765
    PRIMARY KEY  (`uid`)
766
-) TYPE=MyISAM;");
766
+) ENGINE=MyISAM;");
767 767
 $output .= "<tr><td>".$tableprefix."fanfiction_authorprefs</td><td align='center'>" . ($authorprefs ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
768 768
 				$blocks = dbquery("CREATE TABLE `".$tableprefix."fanfiction_blocks` (
769 769
   `block_id` int(11) NOT NULL auto_increment,
... ...
@@ -774,7 +774,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_authorprefs</td><td align='center
774 774
   `block_variables` text NOT NULL,
775 775
   PRIMARY KEY  (`block_id`),
776 776
   KEY `block_name` (`block_name`)
777
-) TYPE=MyISAM;");
777
+) ENGINE=MyISAM;");
778 778
 $output .= "<tr><td>".$tableprefix."fanfiction_blocks</td><td align='center'>" . ($blocks ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
779 779
 				$chapters = dbquery("CREATE TABLE `".$tableprefix."fanfiction_chapters` (
780 780
   `chapid` int(11) NOT NULL auto_increment,
... ...
@@ -796,14 +796,14 @@ $output .= "<tr><td>".$tableprefix."fanfiction_blocks</td><td align='center'>" .
796 796
   KEY `inorder` (`inorder`),
797 797
   KEY `title` (`title`),
798 798
   KEY `validated` (`validated`)
799
-) TYPE=MyISAM;");
799
+) ENGINE=MyISAM;");
800 800
 $output .= "<tr><td>".$tableprefix."fanfiction_chapters</td><td align='center'>" . ($chapters ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
801 801
 				$classes = dbquery("CREATE TABLE `".$tableprefix."fanfiction_classes` (
802 802
   `class_id` int(11) NOT NULL auto_increment,
803 803
   `class_type` int(11) NOT NULL default '0',
804 804
   `class_name` varchar(100) NOT NULL default '',
805 805
   PRIMARY KEY  (`class_id`)
806
-) TYPE=MyISAM;");
806
+) ENGINE=MyISAM;");
807 807
 
808 808
 $output .= "<tr><td>".$tableprefix."fanfiction_classes</td><td align='center'>" . ($classes ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
809 809
 				$classtypes = dbquery("CREATE TABLE `".$tableprefix."fanfiction_classtypes` (
... ...
@@ -812,13 +812,13 @@ $output .= "<tr><td>".$tableprefix."fanfiction_classes</td><td align='center'>"
812 812
   `classtype_title` varchar(50) NOT NULL default '',
813 813
   PRIMARY KEY  (`classtype_id`),
814 814
   KEY `classtype_title` (`classtype_title`)
815
-) TYPE=MyISAM;");
815
+) ENGINE=MyISAM;");
816 816
 $output .= "<tr><td>".$tableprefix."fanfiction_classtypes</td><td align='center'>" . ($classtypes ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
817 817
 $coauthors = dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_coauthors` (
818 818
   `sid` int(11) NOT NULL default '0',
819 819
   `uid` int(11) NOT NULL default '0',
820 820
   PRIMARY KEY  (`sid`,`uid`)
821
-) TYPE=MyISAM;");
821
+) ENGINE=MyISAM;");
822 822
 $output .= "<tr><td>".$tableprefix."fanfiction_coauthors</td><td align='center'>" . ($coauthors ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
823 823
 				$codeblocks = dbquery("CREATE TABLE `".$tableprefix."fanfiction_codeblocks` (
824 824
   `code_id` int(11) NOT NULL auto_increment,
... ...
@@ -826,7 +826,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_coauthors</td><td align='center'>
826 826
   `code_type` varchar(20) default NULL,
827 827
   `code_module` varchar(60) default NULL,
828 828
   PRIMARY KEY  (`code_id`)
829
-) TYPE=MyISAM;");
829
+) ENGINE=MyISAM;");
830 830
 $output .= "<tr><td>".$tableprefix."fanfiction_codeblocks</td><td align='center'>" . ($codeblocks ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
831 831
 				$favorites = dbquery("CREATE TABLE `".$tableprefix."fanfiction_favorites` (
832 832
   `uid` int(11) NOT NULL default '0',
... ...
@@ -834,7 +834,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_codeblocks</td><td align='center'
834 834
   `type` char(2) NOT NULL default '',
835 835
   `comments` text NULL,
836 836
   KEY `uid` (`uid`)
837
-) TYPE=MyISAM;");
837
+) ENGINE=MyISAM;");
838 838
 $output .= "<tr><td>".$tableprefix."fanfiction_favorites</td><td align='center'>" . ($favorites ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
839 839
 				$inseries = dbquery("CREATE TABLE `".$tableprefix."fanfiction_inseries` (
840 840
   `seriesid` int(11) NOT NULL default '0',
... ...
@@ -844,7 +844,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_favorites</td><td align='center'>
844 844
   `inorder` int(11) NOT NULL default '0',
845 845
    PRIMARY KEY  (`sid`,`seriesid`, `subseriesid`),
846 846
    KEY `seriesid` (`seriesid`,`inorder`)
847
-) TYPE=MyISAM;");
847
+) ENGINE=MyISAM;");
848 848
 $output .= "<tr><td>".$tableprefix."fanfiction_inseries</td><td align='center'>" . ($inseries ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
849 849
 				$logs = dbquery("CREATE TABLE `".$tableprefix."fanfiction_log` (
850 850
   `log_id` int(11) NOT NULL auto_increment,
... ...
@@ -854,7 +854,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_inseries</td><td align='center'>"
854 854
   `log_timestamp` timestamp NOT NULL,
855 855
   `log_type` varchar(2) NOT NULL,
856 856
   PRIMARY KEY  (`log_id`)
857
-) TYPE=MyISAM");
857
+) ENGINE=MyISAM");
858 858
 $output .= "<tr><td>".$tableprefix."fanfiction_log</td><td align='center'>" . ($logs ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
859 859
 				$messages = dbquery("CREATE TABLE `".$tableprefix."fanfiction_messages` (
860 860
   `message_id` int(11) NOT NULL auto_increment,
... ...
@@ -862,7 +862,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_log</td><td align='center'>" . ($
862 862
   `message_title` varchar(200) NOT NULL default '',
863 863
   `message_text` text NULL,
864 864
   PRIMARY KEY  (`message_id`)
865
-) TYPE=MyISAM;");
865
+) ENGINE=MyISAM;");
866 866
 $output .= "<tr><td>".$tableprefix."fanfiction_messages</td><td align='center'>" . ($messages ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
867 867
 				$modules = dbquery("
868 868
 CREATE TABLE `".$tableprefix."fanfiction_modules` (
... ...
@@ -884,7 +884,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_modules</td><td align='center'>"
884 884
   PRIMARY KEY  (`link_id`),
885 885
   KEY `link_text` (`link_text`),
886 886
   KEY `link_name` (`link_name`)
887
-) TYPE=MyISAM;");
887
+) ENGINE=MyISAM;");
888 888
 $output .= "<tr><td>".$tableprefix."fanfiction_pagelinks</td><td align='center'>" . ($pagelinks ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
889 889
 				$panels = dbquery("CREATE TABLE `".$tableprefix."fanfiction_panels` (
890 890
   `panel_id` int(11) NOT NULL auto_increment,
... ...
@@ -898,7 +898,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_pagelinks</td><td align='center'>
898 898
   PRIMARY KEY  (`panel_id`),
899 899
   KEY `panel_hidden` (`panel_hidden`),
900 900
   KEY `panel_type` (`panel_type`)
901
-) TYPE=MyISAM;");
901
+) ENGINE=MyISAM;");
902 902
 $output .= "<tr><td>".$tableprefix."fanfiction_panels</td><td align='center'>" . ($panels ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
903 903
 				$series = dbquery("CREATE TABLE `".$tableprefix."fanfiction_series` (
904 904
   `seriesid` int(11) NOT NULL auto_increment,
... ...
@@ -917,7 +917,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_panels</td><td align='center'>" .
917 917
   KEY `characters` (`characters`),
918 918
   KEY `classes` (`classes`),
919 919
   KEY `owner` (`uid`,`title`)
920
-) TYPE=MyISAM;");
920
+) ENGINE=MyISAM;");
921 921
 $output .= "<tr><td>".$tableprefix."fanfiction_series</td><td align='center'>" . ($series ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
922 922
 	$stats = dbquery("CREATE TABLE `".$tableprefix."fanfiction_stats` (
923 923
   `sitekey` varchar(50) NOT NULL default '0',
... ...
@@ -930,7 +930,7 @@ $output .= "<tr><td>".$tableprefix."fanfiction_series</td><td align='center'>" .
930 930
   `members` int(11) NOT NULL default '0',
931 931
   `reviewers` int(11) NOT NULL default '0',
932 932
   `newestmember` int(11) NOT NULL default '0'
933
-) TYPE=MyISAM");
933
+) ENGINE=MyISAM");
934 934
 	dbquery("INSERT INTO ".$tableprefix."fanfiction_stats(`sitekey`) VALUES('".$sitekey."')");
935 935
 $output .= "<tr><td>".$tableprefix."fanfiction_stats</td><td align='center'>" . ($stats ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
936 936
 $output .= "</table>";
... ...
@@ -1109,7 +1109,7 @@ if(!empty(\$sitekey)) \$dbconnect = dbconnect(\$dbhost, \$dbuser,\$dbpass, \$dbn
1109 1109
   `smtp_username` varchar(50) default NULL,
1110 1110
   `smtp_password` varchar(50) default NULL,
1111 1111
   PRIMARY KEY  (`sitekey`)
1112
-) TYPE=MyISAM;");
1112
+) ENGINE=MyISAM;");
1113 1113
 if($settings) $output .= write_message("<img src=\"../images/check.gif\"> "._SETTINGSTABLESUCCESS." <br /><a href='upgrade11.php?step=2&amp;settingsprefix=".$_POST['settingsprefix']."'>"._CONTINUE."</a>");
1114 1114
 else $output .= write_message(_SETTINGSTABLEAUTOFAIL." <br /><a href='upgrade11.php?step=2&amp;settingsprefix=".$_POST['settingsprefix']."'>"._CONTINUE."</a> ");
1115 1115
 		}
Browse code

Initial uplad w/ php7 fixes

Rainer Volkrodt authored on 2016/03/12 15:54:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,1138 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Based on eFiction 1.1
5
+// Copyright (C) 2003 by Rebecca Smallwood.
6
+// http://efiction.sourceforge.net/
7
+// ----------------------------------------------------------------------
8
+// LICENSE
9
+//
10
+// This program is free software; you can redistribute it and/or
11
+// modify it under the terms of the GNU General Public License (GPL)
12
+// as published by the Free Software Foundation; either version 2
13
+// of the License, or (at your option) any later version.
14
+//
15
+// This program is distributed in the hope that it will be useful,
16
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+// GNU General Public License for more details.
19
+//
20
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
21
+// ----------------------------------------------------------------------
22
+
23
+function random_char($string)
24
+{
25
+	$length = strlen($string);
26
+	$position = mt_rand(0, $length - 1);
27
+	 return $string[$position];
28
+}
29
+
30
+function random_string ($charset_string, $length)
31
+{
32
+	$return_string = random_char($charset_string);
33
+	for ($x = 1; $x < $length; $x++)
34
+	$return_string .= random_char($charset_string);
35
+	return $return_string;
36
+}
37
+
38
+
39
+$randomcharset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ';
40
+
41
+// Strip out slashes if magic quotes isn't on.
42
+if(ini_get("magic_quotes_gpc")) {
43
+	foreach($_POST as $var => $val) {
44
+		$val = is_array( $val ) ? array_map( 'stripslashes', $val ) : stripslashes( $val );
45
+	}
46
+	foreach($_GET as $var => $val) {
47
+		$val = is_array( $val ) ? array_map( 'stripslashes', $val ) : stripslashes( $val );
48
+	}
49
+	foreach($_COOKIE as $var => $val) {
50
+		$val = is_array( $val ) ? array_map( 'stripslashes', $val ) : stripslashes( $val );
51
+	}
52
+}
53
+
54
+Header('Cache-Control: private, no-cache, must-revalidate, max_age=0, post-check=0, pre-check=0');
55
+header ("Pragma: no-cache"); 
56
+header ("Expires: 0"); 
57
+
58
+//make a new TemplatePower object
59
+echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
60
+<html><head><title>eFiction 1.1 to $version Upgrade</title>
61
+<style>
62
+LABEL { float: left; display: block; width: 50%; text-align: right; padding-right: 10px; clear: left;}
63
+.row { float: left; width: 99%; }
64
+#settingsform FORM { width: 80%; margin; 0 auto; }
65
+#settingsform LABEL { float: left; display: block; width: 30%; text-align: right; padding-right: 10px; clear: left; }
66
+#settingsform .fieldset SPAN { float: left; display: block; width: 30%; text-align: right; padding-right: 10px; clear: left;}
67
+#settingsform .fieldset LABEL { float: none; width: auto; display: inline; text-align: left; clear: none; }
68
+#settingsform .tinytoggle { text-align: center; }
69
+#settingsform .tinytoggle LABEL { float: none; display: inline; width: auto; text-align: center; padding: 0; clear: none; }
70
+#settingsform #submit { display: block; margin: 1ex auto; }
71
+a.pophelp{
72
+    position: relative; /* this is the key*/
73
+    z-index:24;
74
+    vertical-align: super;
75
+    text-decoration: none;
76
+}
77
+
78
+a.pophelp:hover{z-index:100; border: none; text-decoration: none;}
79
+
80
+a.pophelp span{display: none; position: absolute; text-decoration: none;}
81
+
82
+a.pophelp:hover span{ /*the span will display just on :hover state*/
83
+    display:block;
84
+    position: absolute;
85
+    top: 0; left: 8em; width: 225px;
86
+    border:1px solid #000;
87
+    background-color:#CCC; color:#000;
88
+    text-decoration: none;
89
+    text-align: left;
90
+    padding: 5px;
91
+    font-weight: normal;
92
+}
93
+.required { color: red; }
94
+</style>
95
+<link rel=\"stylesheet\" type=\"text/css\" href='../default_tpls/style.css'></head>";
96
+
97
+$output = "";
98
+define("_BASEDIR", "../");
99
+include ("../includes/class.TemplatePower.inc.php");
100
+if(isset($_GET['step']) && $_GET['step'] > 2) {
101
+	include("../config.php");
102
+	$settings = dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
103
+	list($tableprefix, $language) = dbrow($settings);
104
+	define("SITEKEY", $sitekey);
105
+	define("TABLEPREFIX", $tableprefix);
106
+}
107
+if(isset($language)) {
108
+if(file_exists("../languages/{$language}.php")) include ("../languages/{$language}.php");
109
+else include ("../languages/en.php");
110
+if(file_exists("../languages/{$language}_admin.php")) include ("../languages/{$language}_admin.php");
111
+else include ("../languages/en_admin.php");
112
+if(file_exists("languages/$language.php")) include ("languages/{$language}.php");
113
+else include("languages/en.php");
114
+}
115
+else {
116
+include ("../languages/en.php");
117
+include ("../languages/en_admin.php");
118
+include("languages/en.php");
119
+}
120
+include("../includes/corefunctions.php");
121
+
122
+
123
+//  So I don't have to keep updating the version number in 3 different files.
124
+include("../version.php");
125
+
126
+$tpl = new TemplatePower( "../default_tpls/default.tpl" );
127
+$tpl->assignInclude( "header", "./../default_tpls/header.tpl" );
128
+$tpl->assignInclude( "footer", "./../default_tpls/footer.tpl" );
129
+$tpl->prepare( );
130
+$tpl->newBlock("header");
131
+$tpl->assign("sitename", "Upgrade eFiction 1.1 to eFiction $version");
132
+$tpl->gotoBlock( "_ROOT" );
133
+$tpl->newBlock("footer");
134
+$tpl->assign( "footer", "eFiction $version &copy; 2006. <a href='http://efiction.org/'>http://efiction.org/</a>");
135
+$tpl->gotoBlock( "_ROOT" );
136
+
137
+switch($_GET['step']) {
138
+	case "18":
139
+		$output .= "<div id='pagetitle'>"._MISCDBUPDATE."</div>";
140
+		if(isset($_GET['install'])) {
141
+			if($_GET['install'] == "automatic") {
142
+				include("../config.php");
143
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
144
+				list($tableprefix) = dbrow($settings);
145
+				$alter1 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_characters` ADD `bio` TEXT NULL, ADD `image` VARCHAR( 200 ) NOT NULL");
146
+				$output .= write_message(_ALTER11CHARACTERS.($alter1 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
147
+				$alter1 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_categories` CHANGE `locked` `locked` CHAR( 1 ) DEFAULT '0' NOT NULL");
148
+				$output .= write_message(_ALTER11CATEGORIES.($alter1 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
149
+				$alter1 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_ratings` CHANGE `ratingwarning` `ratingwarning` CHAR( 1 ) DEFAULT '0' NOT NULL ");
150
+				$output .= write_message(_ALTER11RATINGS.($alter1 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
151
+				$alter1 = dbquery("DROP TABLE IF EXISTS `".$tableprefix."fanfiction_settings_old`");
152
+				dbquery("alter table ".$tableprefix."fanfiction_categories drop index category;");
153
+				dbquery("alter table ".$tableprefix."fanfiction_categories drop index parentcatid;");
154
+				dbquery("create index byparent on ".$tableprefix."fanfiction_categories (parentcatid,displayorder);");
155
+				dbquery("create index forstoryblock on ".$tableprefix."fanfiction_chapters (sid,validated);");
156
+				dbquery("alter table ".$tableprefix."fanfiction_comments drop index nid;");
157
+				dbquery("alter table ".$tableprefix."fanfiction_comments add index commentlist (nid,time);");
158
+				dbquery("create index avgrating on ".$tableprefix."fanfiction_reviews(type,item,rating);");
159
+				dbquery("alter table ".$tableprefix."fanfiction_reviews drop index sid;");
160
+				dbquery("create index bychapter on ".$tableprefix."fanfiction_reviews (chapid,rating);");
161
+				dbquery("alter table ".$tableprefix."fanfiction_reviews add index byuid (uid,item,type);");
162
+				dbquery("alter table ".$tableprefix."fanfiction_stories drop index validated;");
163
+				dbquery("create index validateduid on ".$tableprefix."fanfiction_stories (validated,uid);");
164
+				dbquery("create index recent on ".$tableprefix."fanfiction_stories (updated,validated);");
165
+				$serieslist = dbquery("SELECT seriesid FROM ".$tableprefix."fanfiction_series");
166
+				$totalseries = dbnumrows($serieslist);
167
+				while($s = dbassoc($serieslist)) {
168
+					$numstories = count(storiesInSeries($s['seriesid']));
169
+					dbquery("UPDATE ".$tableprefix."fanfiction_series SET numstories = '$numstories' WHERE seriesid = ".$s['seriesid']." LIMIT 1");
170
+				}
171
+				$storiesquery =dbquery("SELECT COUNT(sid) as totals, COUNT(DISTINCT uid) as totala, SUM(wordcount) as totalwords FROM ".$tableprefix."fanfiction_stories WHERE validated > 0 ");
172
+				list($stories, $authors, $words) = dbrow($storiesquery);
173
+				dbquery("UPDATE ".$tableprefix."fanfiction_stats SET stories = '$stories', authors = '$authors', wordcount = '$words' WHERE sitekey = '".$sitekey."'"); 
174
+
175
+				$chapterquery = dbquery("SELECT COUNT(chapid) as chapters FROM ".$tableprefix."fanfiction_chapters where validated > 0");
176
+				list($chapters) = dbrow($chapterquery);
177
+
178
+				$authorquery = dbquery("SELECT COUNT(uid) as totalm FROM ".$tableprefix."fanfiction_authors");
179
+				list($members) = dbrow($authorquery);
180
+
181
+				list($newest) = dbrow(dbquery("SELECT uid as uid FROM ".$tableprefix."fanfiction_authors ORDER BY uid DESC LIMIT 1"));
182
+				$reviewquery = dbquery("SELECT COUNT(reviewid) as totalr FROM ".$tableprefix."fanfiction_reviews WHERE review != 'No Review'");
183
+				list($reviews) = dbrow($reviewquery);
184
+				$reviewquery = dbquery("SELECT COUNT(uid) FROM ".$tableprefix."fanfiction_reviews WHERE review != 'No Review' AND uid != 0");
185
+				list($reviewers) = dbrow($reviewquery);
186
+				dbquery("UPDATE ".$tableprefix."fanfiction_stats SET series = '$totalseries', chapters = '$chapters', members = '$members', newestmember = '$newest', reviews = '$reviews', reviewers = '$reviewers' WHERE sitekey = '".$sitekey."'"); 
187
+				$alltables = dbquery("SHOW TABLES");
188
+				while ($table = dbassoc($alltables)) {
189
+					foreach ($table as $db => $tablename) {
190
+						dbquery("OPTIMIZE TABLE `".$tablename."`");
191
+					}
192
+				}
193
+				$output .= write_message(_UPGRADE11END);
194
+			}
195
+			else $output .= write_message(_MISCDBUPDATEMANUAL._UPGRADE11END);
196
+		}
197
+		else $output .= write_message(_MISCDBUPDATEINFO."<br /><br /><a href='upgrade11.php?step=18&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?step=18&amp;install=manual'>"._MANUAL2."</a>");
198
+	break;
199
+	case "17":
200
+		$output .= "<div id='pagetitle'>"._NEWSUPDATE."</div>";
201
+		if(isset($_GET['install'])) {
202
+			include("../config.php");
203
+
204
+			$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
205
+			list($tableprefix) = dbrow($settings);
206
+			dbquery("ALTER TABLE `".$tableprefix."fanfiction_news` ADD `comments` INT NOT NULL DEFAULT '0'");
207
+			$newslist = dbquery("SELECT count(cid) as count, nid FROM ".$tableprefix."fanfiction_comments GROUP BY nid");
208
+			while($n = dbassoc($newslist)) {
209
+				dbquery("UPDATE ".$tableprefix."fanfiction_news SET comments = '".$n['count']."' WHERE nid = ".$n['nid']);
210
+			}
211
+			$comments = dbquery("SELECT uname FROM ".$tableprefix."fanfiction_comments GROUP BY uname");
212
+			while($uname = dbassoc($comments)) {
213
+				unset($uid);
214
+				$nameinfo = dbquery("SELECT uid FROM ".$tableprefix."fanfiction_authors WHERE penname = '".$uname['uname']."'");
215
+				list($uid) = dbrow($nameinfo);
216
+				if(empty($uid)) $uid = 0;
217
+				dbquery("UPDATE ".$tableprefix."fanfiction_comments SET uname = '$uid' WHERE uname = '".$uname['uname']."'");
218
+			}
219
+			$result2 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_comments` CHANGE `uname` `uid` INT NOT NULL DEFAULT '0';");
220
+			$output .= write_message(_NEWSUPDATERESULT.($result2 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));	
221
+			$output .= write_message("<a href='upgrade11.php?step=18'>"._CONTINUE."</a>");				
222
+
223
+		}
224
+		else $output .= write_message(_NEWSUPDATEINFO."<br /><a href='upgrade11.php?step=17&amp;install=automatic'>"._CONTINUE."</a>");
225
+
226
+	break;
227
+	case "16":
228
+		$output .= "<div id='pagetitle'>"._AUTHORUPDATE."</div>";
229
+		if(isset($_GET['install'])) {
230
+			include("../config.php");
231
+			define("_BASEDIR", "../");
232
+			$settings = dbquery("SELECT tableprefix, defaultsort, displayindex, tinyMCE, storiespath FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
233
+			list($defaultsort, $displayindex, $tinyMCE, $storiespath) = dbrow($settings);
234
+			$result = dbquery("INSERT INTO ".$tableprefix."fanfiction_authorprefs(`uid`, `newreviews`, `validated`, `userskin`, `level`, `categories`, `contact`) SELECT uid, newreviews, validated, userskin, level, categories, contact FROM ".$tableprefix."fanfiction_authors");
235
+			$result2 = dbquery("UPDATE ".$tableprefix."fanfiction_authorprefs set sortby = '$defaultsort', storyindex = '$displayindex', tinyMCE = '$tinyMCE'");
236
+			$authors = dbquery("SELECT author.penname, author.uid, count(stories.uid) as count FROM ".$tableprefix."fanfiction_authors as author, ".$tableprefix."fanfiction_stories as stories WHERE author.uid = stories.uid GROUP BY stories.uid");
237
+			while($author = dbassoc($authors)) {
238
+				if( file_exists( _BASEDIR.STORIESPATH."/$author[penname]/") ) {
239
+					$moved = rename(_BASEDIR.STORIESPATH."/$author[penname]/", _BASEDIR.STORIESPATH."/$author[uid]/");
240
+					$output .= $author['penname'].($moved ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">")."<br />";
241
+				}
242
+			}
243
+			$output .= write_message(_AUTHORRESULT.($result ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
244
+			$fields = dbquery("SELECT * FROM ".$tableprefix."fanfiction_authorfields WHERE field_on = 1");
245
+			while($f = dbassoc($fields)) {
246
+				$col = dbquery("SHOW COLUMNS FROM ".$tableprefix."fanfiction_authors LIKE '".$f['field_name']."'");
247
+				if(dbnumrows($col) > 0) {
248
+					$result = dbquery("INSERT INTO ".$tableprefix."fanfiction_authorinfo(`uid`, `info`) SELECT uid, ".$f['field_name']." FROM ".$tableprefix."fanfiction_authors WHERE ".$f['field_name']." IS NOT NULL AND ".$f['field_name']." != ''");
249
+					$result2 = dbquery("UPDATE ".$tableprefix."fanfiction_authorinfo SET field = ".$f['field_id']." WHERE field = 0");
250
+				}
251
+			}
252
+			$result2 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_authors` DROP `validated`, DROP `userskin`, DROP `level`, DROP `contact`, DROP `categories`, DROP `carry`, CHANGE `admincreated` `admincreated` CHAR( 1 ) DEFAULT '0' NOT NULL;");
253
+			$output .= write_message(_AUTHORDROPRESULT.($result2 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));	
254
+			$output .= write_message("<a href='upgrade11.php?step=17'>"._CONTINUE."</a>");				
255
+
256
+		}
257
+		else $output .= write_message(_AUTHORUPDATEINFO."<br /><a href='upgrade11.php?step=16&amp;install=automatic'>"._CONTINUE."</a>");
258
+	break;
259
+	case "15":
260
+		$output .= "<div id='pagetitle'>"._AUTHORFIELDS."</div>";
261
+		include("../config.php");
262
+		$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
263
+		list($tableprefix) = dbrow($settings);
264
+		if(isset($_GET['install'])) {
265
+			if($_GET['install'] == "automatic") {
266
+				$fields[] = array('4','lj','Live Journal','http://{info}.livejournal.com','','','0');
267
+				$fields[] = array('1','website','Web Site','','','','1');
268
+				$fields[] = array('5','AOL','AIM','','$output .= "<div><label for=\'AOL\'>".$field[\'field_title\'].":</label><INPUT type=\'text\' class=\'textbox\'  name=\'af_".$field[\'field_name\']."\' maxlength=\'40\' value=\'".(!empty($user[\'af_\'.$field[\'field_id\']]) ? $user[\'af_\'.$field[\'field_id\']] : "")."\' size=\'20\'></div>";','$thisfield = "<img src=\"http://big.oscar.aol.com/".$field[\'info\']."?on_url=$url/images/aim.gif&off_url=$url/images/aim.gif\"> <a href=\"aim:goim?{aol}ScreenName=".$field[\'info\']."\">".format_email($field[\'info\'])."</a>";','1');
269
+				$fields[] = array('5','ICQ','ICQ','','$output .= "<div><label for=\'AOL\'>".$field[\'field_title\'].":</label><INPUT type=\'text\' class=\'textbox\'  name=\'af_".$field[\'field_name\']."\' maxlength=\'40\' value=\'".(!empty($user[\'af_\'.$field[\'field_id\']]) ? $user[\'af_\'.$field[\'field_id\']] : "")."\' size=\'20\'></div>";','$thisfield = "<img src=\"http://status.icq.com/online.gif?icq=".$field[\'info\']."&img=5\"> ".$field[\'info\'];','1');
270
+				$fields[] = array('5','MSN','MSN IM','','$output .= "<div><label for=\'AOL\'>".$field[\'field_title\'].":</label><INPUT type=\'text\' class=\'textbox\'  name=\'af_".$field[\'field_name\']."\' maxlength=\'40\' value=\'".(!empty($user[\'af_\'.$field[\'field_id\']]) ? $user[\'af_\'.$field[\'field_id\']] : "")."\' size=\'20\'></div>";','$thisfield = "<img src=\"images/msntalk.gif\" alt=\""._MSN."\"> ".format_email($field[\'info\']);','1');
271
+				$fields[] = array('5','Yahoo','Yahoo IM','','$output .= "<div><label for=\'AOL\'>".$field[\'field_title\'].":</label><INPUT type=\'text\' class=\'textbox\'  name=\'af_".$field[\'field_name\']."\' maxlength=\'40\' value=\'".(!empty($user[\'af_\'.$field[\'field_id\']]) ? $user[\'af_\'.$field[\'field_id\']] : "")."\' size=\'20\'></div>";','$thisfield = "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$field[\'info\']."&.src=pg\"><img border=\'0\' src=\"http://opi.yahoo.com/online?u=".$field[\'info\']."&m=g&t=1\"> ".format_email($field[\'info\'])."</a>";','1');
272
+				$fields[] = array('4','da','Deviant Art','http://{info}.deviantart.com','','','0');
273
+				$fields[] = array('3','betareader','Beta-reader','','','','1');
274
+				$fields[] = array('4','dj','DeadJournal','http://{info}.deadjournal.com/','','','0');
275
+				$fields[] = array('4','xanga','Xanga','http://www.xanga.com/{info}','','','0');
276
+				$fields[] = array('2', 'gender', 'Gender', 'male|#|female|#|undisclosed', '', '', '0');
277
+				$fields[] = array('4','myspace','MySpace','http://www.myspace.com/{info}','','','0');
278
+		
279
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
280
+				list($tableprefix) = dbrow($settings);
281
+
282
+				$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>"._FIELD."</th><th>"._RESULT."</th></tr>";
283
+				foreach($fields as $field) {
284
+					$f = dbquery("INSERT INTO `".$tableprefix."fanfiction_authorfields` (`field_type`, `field_name`, `field_title`, `field_options`, `field_code_in`, `field_code_out`, `field_on`) VALUES('".$field[0]."', '".$field[1]."','".$field[2]."','".escapestring($field[3])."','".escapestring($field[4])."','".escapestring($field[5])."','".$field[6]."');");
285
+					$output .= "<tr><td>".$field[2]."</td><td align='center'>" . ($f ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
286
+				}
287
+				$output .= "</table>";
288
+				$output .= write_message(_FIELDAUTOFAIL." "._FIELDUPDATE."<br /><br /> <a href='upgrade11.php?step=16'>"._CONTINUE."</a>");
289
+			}
290
+			else {
291
+				$output .= write_message(_FIELDMANUAL," "._FIELDUPDATE."<br /><br /><a href='upgrade11.php?step=16'>"._CONTINUE."</a>");
292
+			}
293
+		}
294
+		else $output .= write_message(_FIELDDATAINFO."<br /><br /><a href='upgrade11.php?step=15&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?step=15&amp;install=manual'>"._MANUAL2."</a>");
295
+	break;
296
+	case "14":
297
+		$output .= "<div id='pagetitle'>"._UPDATECATORDER."</div>";
298
+		if(isset($_GET['install'])) {
299
+			if($_GET['install'] == "automatic") {
300
+				include("../config.php");
301
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
302
+				list($tableprefix) = dbrow($settings);
303
+				$selectA = "SELECT category, catid FROM ".$tableprefix."fanfiction_categories ORDER BY leveldown, displayorder";
304
+				$resultA = dbquery($selectA);
305
+				$countA = 1;
306
+				while($cat = dbassoc($resultA)) {
307
+					$count = 1;
308
+					if($cat[parentcatid] = -1) {
309
+						dbquery("UPDATE ".$tableprefix."fanfiction_categories SET displayorder = $countA WHERE catid = $cat[catid]");
310
+						$countA++;
311
+					}
312
+					$selectB = "SELECT category, catid FROM ".$tableprefix."fanfiction_categories WHERE parentcatid = '$cat[catid]' ORDER BY displayorder";
313
+					$resultB = dbquery($selectB) or die(_FATALERROR."Query: ".$selectB."<br />Error: (".mysql_errno( ).") ".mysql_error( ));
314
+					while($sub = dbassoc($resultB)) {
315
+						dbquery("UPDATE ".$tableprefix."fanfiction_categories SET displayorder = $count WHERE catid = $sub[catid]");
316
+						$count++;
317
+					}
318
+				}
319
+				$output .= write_message(_ACTIONSUCCESSFUL."<br /> <a href='upgrade11.php?step=15'>"._CONTINUE."</a>");
320
+			}
321
+		}
322
+		else {
323
+			include("../config.php");
324
+			$output .= write_message(_UPDATECATORDERINFO." <BR /><BR /><a href='upgrade11.php?step=14&amp;install=automatic'>"._CONTINUE."</a>");
325
+		}
326
+	break;
327
+	case "13":
328
+		$output .= "<div id='pagetitle'>"._FAVUPDATE."</div>";
329
+		if(isset($_GET['install'])) {
330
+			include("../config.php");
331
+			$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
332
+			list($tableprefix) = dbrow($settings);
333
+			$favst = dbquery("INSERT INTO ".$tableprefix."fanfiction_favorites(uid, item, type) SELECT uid, sid, 'ST' FROM ".$tableprefix."fanfiction_favstor");
334
+			$output .= write_message(_FAV1.($favst ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
335
+			$favau = dbquery("INSERT INTO ".$tableprefix."fanfiction_favorites(uid, item, type) SELECT uid, favuid, 'AU' FROM ".$tableprefix."fanfiction_favauth");
336
+			$output .= write_message(_FAV3.($favau ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
337
+			$drop1 = dbquery("DROP TABLE `".$tableprefix."fanfiction_favstor`");
338
+			$output .= write_message(_FAV4.($drop1 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
339
+			$drop3 = dbquery("DROP TABLE `".$tableprefix."fanfiction_favauth`");
340
+			$output .= write_message(_FAV6.($drop3 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
341
+			$output .= write_message("<a href='upgrade11.php?step=14'>"._CONTINUE."</a>");		
342
+		}
343
+		else $output .= write_message(_FAVUPDATEINFO11."<br /><a href='upgrade11.php?step=13&amp;install=automatic'>"._CONTINUE."</a>");
344
+	break;
345
+	case "12":
346
+		$output .= "<div id='pagetitle'>"._UPDATESTORIES11."</div>";
347
+		if(isset($_GET['install'])) {
348
+			if($_GET['install'] == "automatic") {
349
+				include("../config.php");
350
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
351
+				list($tableprefix) = dbrow($settings);
352
+				$characters = dbquery("SELECT charid, charname FROM ".$tableprefix."fanfiction_characters");
353
+					while($char = dbassoc($characters)) {
354
+					$character[stripslashes($char[charname])] = $char[charid];
355
+				}
356
+				$ratlist = dbquery("SELECT * FROM ".$tableprefix."fanfiction_ratings");
357
+				while($rate = dbassoc($ratlist)) {
358
+					$ratingslist[$rate['rating']] = $rate['rid'];
359
+				}
360
+				$classresults = dbquery("SELECT * FROM ".$tableprefix."fanfiction_classes");
361
+				while($class = dbassoc($classresults)) {
362
+					$classlist[$class['class_name']] = array("id" => $class['class_id'], "type" => $class['class_type'], "name" => $class['class_name']);
363
+				}
364
+				$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
365
+				$stories = dbquery("SELECT s.*, AVG( re.rating ) AS rating, count( re.rating ) AS reviews FROM ".$tableprefix."fanfiction_stories AS s LEFT JOIN ".$tableprefix."fanfiction_reviews AS re ON s.sid = re.chapid GROUP BY s.sid LIMIT $offset, 200");
366
+				while($chapter = dbassoc($stories)) {
367
+					dbquery("INSERT INTO ".$tableprefix."fanfiction_chapters(`chapid` , `title` , `inorder` , `storytext` , `validated` , `wordcount` , `rating` , `reviews` , `sid` , `uid` ) VALUES('$chapter[sid]', '".addslashes($chapter[chapter])."', '".($chapter[inorder] + 1)."', '".addslashes($chapter[storytext])."', '$chapter[validated]', '$chapter[wordcount]', '".(empty($chapter[rating]) ? "0" : $chapter[rating])."', '$chapter[reviews]', '$chapter[psid]', '$chapter[uid]')");
368
+					if($chapter['sid'] == $chapter['psid']) {		
369
+						unset($genres, $warnings, $g, $w, $classes, $characters, $c, $clist, $rid);
370
+						$characters = explode(",", $chapter['charid']);
371
+						foreach($characters as $c) {
372
+							$clist[] = $character[$c];
373
+						}
374
+						$genres = explode(",", $chapter['gid']);
375
+						foreach($genres as $g) {
376
+							if($g && $g != " " && $classlist[$g]['type'] == 1) $classes[] = $classlist[$g]['id'];
377
+						}
378
+						$warnings = explode(",", $chapter['wid']);
379
+						foreach($warnings as $w) {
380
+							if($w && $w != " " && $classlist[$w]['type'] == 2) $classes[] = $classlist[$w]['id'];
381
+						}
382
+						$rid = $ratingslist[$chapter['rid']];
383
+						dbquery("UPDATE ".$tableprefix."fanfiction_stories SET rid = '$rid', classes = '".($classes ? implode(",", $classes) : "")."', charid = '".($clist ? implode(",", $clist) : "")."' WHERE sid = '$chapter[sid]'");
384
+					}
385
+				}
386
+				if(dbnumrows($stories)) $output .= write_message(_STORIES." ".($offset + 1)."-".($offset + dbnumrows($stories)).".<br /><a href='upgrade11.php?step=12&amp;install=automatic&amp;offset=".($offset+200)."'>"._CONTINUE."</a>");
387
+				else {
388
+					dbquery("DELETE FROM ".$tableprefix."fanfiction_stories WHERE sid != psid");
389
+					dbquery("ALTER TABLE `".$tableprefix."fanfiction_stories` CHANGE `featured` `featured` CHAR( 1 ) DEFAULT '0' NOT NULL ,
390
+CHANGE `validated` `validated` CHAR( 1 ) DEFAULT '0' NOT NULL ,
391
+CHANGE `rr` `rr` CHAR( 1 ) DEFAULT '0' NOT NULL, DROP `chapter`, 
392
+DROP `inorder`, 
393
+DROP `storytext`, 
394
+DROP `psid`,
395
+DROP `gid`,
396
+DROP `wid`,
397
+CHANGE `catid` `catid` VARCHAR( 100 ) DEFAULT '0' NOT NULL, 
398
+ADD `rating` TINYINT( 4 ) NOT NULL");
399
+	$stories = dbquery("SELECT AVG(rating) as average, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND rating != '-1' GROUP BY item");
400
+	while($s = dbassoc($stories)) {
401
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '".round($s['average'])."' WHERE sid = '".$s['item']."'");
402
+	}
403
+	$stories = dbquery("SELECT COUNT(reviewid) as count, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND review != 'No Review' GROUP BY item");
404
+	while($s = dbassoc($stories)) {
405
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET reviews = '".$s['count']."' WHERE sid = '".$s['item']."'");
406
+	}
407
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '0', reviews = '0'");
408
+	$chapters = dbquery("SELECT AVG(rating) as average, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND rating != '-1' GROUP BY chapid");
409
+	while($c = dbassoc($chapters)) {
410
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '".round($c['average'])."' WHERE chapid = '".$c['chapid']."'");
411
+	}
412
+	$chapters = dbquery("SELECT COUNT(reviewid) as count, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE type = 'ST' AND review != 'No Review' GROUP BY chapid");
413
+	while($c = dbassoc($chapters)) {
414
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET reviews = '".$c['count']."' WHERE chapid = '".$c['chapid']."'");
415
+	}					$output .= write_message(_STORIESUPDATED."<br /><br /><a href='upgrade11.php?step=13&amp;install=automatic'>"._CONTINUE."</a>");
416
+				}
417
+			}
418
+		}
419
+		else {
420
+			include("../config.php");
421
+			$output .= write_message(_UPDATESTORIES11INFO."<br /><br /> <a href='upgrade11.php?step=12&amp;install=automatic'>"._CONTINUE."</a>");
422
+		}
423
+	break;
424
+	case "11":
425
+		$output .= "<div id='pagetitle'>"._REVIEWUPDATE."</div>";
426
+		if(isset($_GET['install'])) {
427
+			include("../config.php");
428
+			$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
429
+			list($tableprefix) = dbrow($settings);
430
+			$alter = dbquery("ALTER TABLE `".$tableprefix."fanfiction_reviews` CHANGE `psid` `item` INT( 11 ) NOT NULL DEFAULT '0'");
431
+			$output .= write_message(_REVIEWALTER7.($alter ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
432
+			$alter2 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_reviews` ADD `type` VARCHAR( 2 ) NOT NULL DEFAULT 'ST'");
433
+			$output .= write_message(_REVIEWALTER2.($alter2 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
434
+			$alter3 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_reviews` CHANGE `member` `uid` INT( 11 ) NOT NULL DEFAULT '0'");
435
+			$output .= write_message(_REVIEWALTER3.($alter3 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
436
+			$alter4 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_reviews` ADD `respond` CHAR( 1 ) DEFAULT '0' NOT NULL");
437
+			$output .= write_message(_REVIEWALTER5.($alter4 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
438
+			$update1 = dbquery("UPDATE ".$tableprefix."fanfiction_reviews SET type = 'ST' WHERE item > 0");
439
+			$alter5 = dbquery("ALTER TABLE `".$tableprefix."fanfiction_reviews` CHANGE `sid` `chapid` INT( 11 ) NOT NULL DEFAULT '0'");
440
+			$output .= write_message(_REVIEWALTER6.($alter5 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
441
+
442
+			$output .= write_message(_REVIEWUPDATE1.($update1 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
443
+			$update3 = dbquery("UPDATE ".$tableprefix."fanfiction_reviews SET respond = 1 WHERE review LIKE \"%Author's Response:%\"");
444
+			$output .= write_message(_REVIEWUPDATE3.($update3 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
445
+			$output .= write_message("<a href='upgrade11.php?step=12'>"._CONTINUE."</a>");
446
+		}
447
+		else $output .= write_message(_REVIEWUPDATEINFO."<br /><a href='upgrade11.php?step=11&amp;install=automatic'>"._CONTINUE."</a>");
448
+
449
+	break;
450
+	case "10":
451
+		$output .= "<div id='pagetitle'>"._UPDATESTORIESTABLE11."</div>";
452
+		if(isset($_GET['install'])) {
453
+			if($_GET['install'] == "automatic") {
454
+				include("../config.php");
455
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
456
+				list($tableprefix) = dbrow($settings);
457
+				$result = dbquery("ALTER TABLE ".$tableprefix."fanfiction_stories ADD `classes` VARCHAR( 200 ) NULL AFTER `catid`;");
458
+				if($result) $result = dbquery("ALTER TABLE ".$tableprefix."fanfiction_stories CHANGE `summary` `summary` TEXT NULL");
459
+				if($result) $result = dbquery("ALTER TABLE ".$tableprefix."fanfiction_stories ADD `coauthors` tinyint(1) NULL AFTER `uid`");
460
+				if($result) $result = dbquery("ALTER TABLE ".$tableprefix."fanfiction_stories CHANGE `numreviews` `reviews` SMALLINT( 6 ) DEFAULT '0' NOT NULL");
461
+				if($result) $result = dbquery("ALTER TABLE ".$tableprefix."fanfiction_stories CHANGE `counter` `count` INT( 11 ) NOT NULL DEFAULT '0' AFTER `reviews`;");
462
+				if($result) $result = dbquery("ALTER TABLE ".$tableprefix."fanfiction_stories ADD `storynotes` TEXT NULL AFTER `summary`;");
463
+				if($result) $output .= write_message(_ACTIONSUCCESSFUL."<br /> <a href='upgrade11.php?step=11'>"._CONTINUE."</a>");
464
+			}
465
+			else if($_GET['install'] == "manual") {
466
+				$output .= write_message(_UPDATESTORIESTABLEMANUAL11."<br /> <a href='upgrade11.php?step=11'>"._CONTINUE."</a>");
467
+			}
468
+		}
469
+		else {
470
+			include("../config.php");
471
+			$output .= write_message(_UPDATESTORIESTABLEINFO11." <a href='upgrade11.php?step=10&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?step=10&amp;install=manual'>"._MANUAL2."</a>");
472
+		}
473
+	break;	case "9":
474
+		$output .= "<div id='pagetitle'>"._MOVECLASSES."</div>";
475
+		if(isset($_GET['install'])) {
476
+			include("../config.php");
477
+			$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
478
+			list($tableprefix) = dbrow($settings);
479
+			$newclass = dbquery("INSERT INTO ".$tableprefix."fanfiction_classtypes (`classtype_name`, `classtype_title`) VALUES('genres', 'Genres');");
480
+			$genres = dbquery("SELECT * FROM ".$tableprefix."fanfiction_genres");
481
+			$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>Genres</th><th>Result</th></tr>";
482
+			while($g = dbassoc($genres)) {
483
+				$result = dbquery("INSERT INTO ".$tableprefix."fanfiction_classes (`class_type`, `class_name`) VALUES('1', '".$g['genre']."')");
484
+				$output .= "<tr><td>".$g['genre']."</td><td align='center'>" . ($result ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
485
+			}
486
+			$output .= "</table>";
487
+			// Ditto with the warnings
488
+			$newclass = dbquery("INSERT INTO ".$tableprefix."fanfiction_classtypes (`classtype_name`, `classtype_title`) VALUES('warnings', 'Warnings');");
489
+			$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>Warnings</th><th>Result</th></tr>";
490
+			$warnings = dbquery("SELECT * FROM ".$tableprefix."fanfiction_warnings");
491
+			while($w = dbassoc($warnings)) {
492
+				$result = dbquery("INSERT INTO ".$tableprefix."fanfiction_classes (`class_type`, `class_name`) VALUES('2', '$w[warning]')");
493
+				$output .= "<tr><td>".$w['warning']."</td><td align='center'>" . ($result ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
494
+			}
495
+			$output .= "</table>";
496
+			$drop1 = dbquery("DROP TABLE `".$tableprefix."fanfiction_genres`");
497
+			$output .= write_message(_DROPGENRES.($drop1 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
498
+			$drop2 = dbquery("DROP TABLE `".$tableprefix."fanfiction_warnings`");
499
+			$output .= write_message(_DROPWARNINGS.($drop2 ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">"));
500
+			
501
+			$output .= write_message(_MOVECLASSFAIL."<br /><a href='upgrade11.php?step=10'>continue</a>");
502
+		}
503
+		else $output .= write_message(_MOVECLASSESINFO."<br /><a href='upgrade11.php?step=9&amp;install=automatic'>"._CONTINUE."</a>");
504
+	break;
505
+	case "8":
506
+		$output .= "<div id='pagetitle'>"._MESSAGEDATA."</div>";
507
+		if(isset($_GET['install'])) {
508
+			if($_GET['install'] == "automatic") {
509
+				include("../config.php");
510
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
511
+				list($tableprefix) = dbrow($settings);
512
+				$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>Message</th><th>Result</th></tr>";
513
+				$settings = dbquery("SELECT * FROM ".$tableprefix."fanfiction_settings_old");
514
+				if(!$settings) $settings = dbquery("SELECT * FROM ".$tableprefix."fanfiction_settings");
515
+				$messages = dbassoc($settings);
516
+				foreach($messages as $name => $text) {
517
+					
518
+					$msg = dbquery("INSERT INTO `".$tableprefix."fanfiction_messages` (`message_name`, `message_title`, `message_text`) VALUES ('$name', '".$defaulttitles[$name]."', '".addslashes($text)."');");
519
+					$output .= "<tr><td>".$defaulttitles[$name]."</td><td align='center'>" . ($msg ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
520
+				}
521
+				$msg = dbquery("INSERT INTO `".$tableprefix."fanfiction_messages`(`message_name`, `message_title`, `message_text`) VALUES ('printercopyright', '', '<u>Disclaimer:</u> All publicly recognizable characters and settings are the property of their respective owners. The original characters and plot are the property of the author. No money is being made from this work. No copyright infringement is intended.');");
522
+				$output .= "<tr><td>Printable Copyright</td><td align='center'>" . ($msg ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
523
+				$msg = dbquery("INSERT INTO `".$tableprefix."fanfiction_messages`(`message_name`, `message_title`, `message_text`) VALUES ('rules', 'Submission Rules', '<p align=\"center\"><strong>Submission Rules</strong></p>\r\n<ol>\r\n  <li>All submissions must be accompanied by a complete disclaimer. If a \r\n  suitable disclaimer is not included, the site administrators reserve the right \r\n  to add a disclaimer.&nbsp; Repeat offenders may be subject to further action \r\n  up to and including removal of stories and account.\r\n<div class=\"tblborder\" style=\"width: 400px; margin: 1em auto;\">\r\n<div style=\"background: #000; color: #FFF; padding: 5px; text-align: center; font-weight: bold;\">Sample Disclaimer</div>\r\n<div class=\"tblborder\" style=\"padding: 5px;\"><span style=\"text-decoration: underline;\">Disclaimer:</span>  All publicly recognizable characters, settings, etc. are the property of their respective owners.  The original characters and plot are the property of the author.&nbsp; \r\n        The author is in no way associated with the owners, creators, or producers of any media franchise.&nbsp;  No copyright infringement is intended.</div>\r\n  </div>\r\n  </li>\r\n  <li>Stories must be submitted to the proper category. &nbsp;If there is an appropriate sub-category, <strong>DO NOT</strong> add your story to the main category.&nbsp; The submission \r\n  form allows you to choose multiple categories for your story, and we worked very hard to add that functionality for you.&nbsp;&nbsp; <u><strong>So please \r\n  do NOT add your story multiple times!</strong></u></li>\r\n  <li>Titles and summaries must be kid friendly.&nbsp; No exceptions.&nbsp; </li>\r\n  <li>&quot;Please read&quot;, &quot;Untitled&quot;, etc. are not acceptable titles or summaries.</li>\r\n  <li>A number of authors have requested that fans refrain from writing fan \r\n  fiction based on their work.&nbsp; Therefore submissions will not be \r\n  accepted based on the works of P.N. Elrod, Raymond Feist, Terry Goodkind, \r\n  Laurell K. Hamilton, Anne McCaffrey, Robin McKinley, Irene Radford, Anne Rice, \r\n  and Nora Roberts/J.D. Robb.&nbsp; </li>\r\n  <li>Actor/actress stories are not permitted...not even if they\'re visiting an \r\n  alternate reality.</li>\r\n  <li>Correct grammar and spelling are expected of all stories submitted to this \r\n  site.&nbsp; The site administrators are not grammar Nazis.&nbsp; However, the \r\n  site administrators reserve the right to request corrections in submissions \r\n  with a multitude of grammar and/or spelling errors.&nbsp; If such a request is \r\n  ignored, the story will be deleted.</li>\r\n  <li>All stories must be rated correctly and have the appropriate warnings.&nbsp; \r\n  All adult rated stories are expected to have warnings.&nbsp; After all, they \r\n  wouldn\'t have that rating if there wasn\'t something to be warned about!&nbsp; The site administrators recognize \r\n  that there is an audience for these stories, but please respect those who do \r\n  not wish to read them by labeling them appropriately.&nbsp;\r\n  <u><strong>Please note: Stories containing adults having sex with minors are strictly forbidden.</strong></u>&nbsp; </li>\r\n  <li>Stories with multiple chapters should be archived as such and <span style=\"font-weight: bold; text-decoration: underline;\">NEVER</span> as \r\n  separate stories.&nbsp; Upload the first chapter of your story, then go to <a href=\"stories.php?action=viewstories\">Manage Stories</a> in \r\nyour account to add additional chapters.  If you have trouble with this, please contact the site administrator or ask a \r\n  friend to help you.</li>\r\n  <li>As much as possible, spoiler warnings are expected on all stories.  For categories with serialized content, such as series of books or television series, \r\n  spoilers are <strong>mandatory</strong> for the current season and/or most recent part.  An appropriate spoiler warning to place in your summary would be: Spoilers for <u>Star Trek II: The Wrath of Khan.</u> \r\n  <strong>DO NOT</strong> do anything like this: <u>Spoilers for the one where Spock dies.</u></li>\r\n</ol>\r\n  <p>Submissions found to be in violation of these rules may be removed and the \r\n  author\'s account suspended at the discretion of the site administrators and/or \r\n  moderators.&nbsp; The site administrators reserve the right to modify these \r\n  rules as needed.</p>');");
524
+				$output .= "<tr><td>Submission Rules</td><td align='center'>" . ($msg ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
525
+				$msg = dbquery("INSERT INTO `".$tableprefix."fanfiction_messages`(`message_name`, `message_title`, `message_text`) VALUES ('tos', 'Terms of Service', 'This is the Terms of Service for your site.  It will be displayed when a new member registers to the site.');");
526
+				$output .= "<tr><td>Terms of Service</td><td align='center'>" . ($msg ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
527
+				$msg = dbquery("INSERT INTO `".$tableprefix."fanfiction_messages`(`message_name`, `message_title`, `message_text`) VALUES('maintenance', 'Site Maintenance', '<p style=\"text-align: center;\">This site is currently undergoing maintenance.  Please check back soon.  Thank you.</p>');");
528
+				$output .= "<tr><td>Site Maintenance</td><td align='center'>" . ($msg ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
529
+				$output .= "</table>";
530
+				$output .= write_message(_MESSAGEAUTOFAILUPGRADE."<br /><a href='upgrade11.php?step=9'>continue</a>");
531
+			}
532
+		}
533
+		else $output .= write_message(_MESSAGEDATAUPGRADE."<br /><a href='upgrade11.php?step=8&amp;install=automatic'>"._CONTINUE."</a>");
534
+
535
+	break;
536
+	case "7":
537
+		$output .= "<div id='pagetitle'>"._BLOCKDATA."</div>";
538
+		if(isset($_GET['install'])) {
539
+			if($_GET['install'] == "automatic") {
540
+				include("../config.php");
541
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
542
+				list($tableprefix) = dbrow($settings);
543
+				$blocklist = array(
544
+					array("categories","Categories","categories/categories.php","1",""),
545
+					array("featured","Featured Stories","featured/featured.php","1",""),
546
+					array("info","Site Info","info/info.php","2",""),
547
+					array("login","Log In","login/login.php","1",""),
548
+					array("menu","Main Menu","menu/menu.php","1",""),
549
+					array("random","Random Story","random/random.php","2",""),
550
+					array("recent","Most Recent","recent/recent.php","2","a:1:{s:3:\"num\";s:1:\"1\";}"),
551
+					array("skinchange","Skin Change","skinchange/skinchange.php","1",""),
552
+					array("news","Site News","news/news.php","1","a:1:{s:3:\"num\";s:1:\"1\";}")
553
+				);
554
+				$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>"._BLOCK."</th><th>"._RESULT."</th></tr>";
555
+				foreach($blocklist as $block) {
556
+					$b = dbquery("INSERT INTO `".$tableprefix."fanfiction_blocks` (`block_name`, `block_title`, `block_file`, `block_status`, `block_variables`) VALUES('".$block[0]."', '".$block[1]."', '".$block[2]."', '".$block[3]."', '".escapestring($block[4])."');");
557
+					$output .= "<tr><td>".$block[1]."</td><td align='center'>" . ($b ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
558
+				}
559
+				$output .= "</table>";
560
+				$output .= write_message(_BLOCKDATAFAILUPGRADE."<br /><br /><a href='upgrade11.php?step=8'>"._CONTINUE."</a>");
561
+			}
562
+			else {
563
+				$output .= write_message(_BLOCKDATAMANUAL."<br /><br /><a href='upgrade11.php?step=7'>"._CONTINUE."</a>");
564
+			}
565
+		}
566
+		else $output .= write_message(_BLOCKDATANEW."<br /><br /><a href='upgrade11.php?step=7&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='iupgrade11.php?step=7&amp;install=manual'>"._MANUAL2."</a>");
567
+	break;
568
+	case "6":
569
+		$output .= "<div id='pagetitle'>"._LINKDATA."</div>";
570
+		if(isset($_GET['install'])) {
571
+			if($_GET['install'] == "automatic") {
572
+				include("../config.php");
573
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
574
+				list($tableprefix) = dbrow($settings);
575
+				$pagelist = array(
576
+					array("home","Home","index.php","0","0"),
577
+					array("recent","Most Recent","browse.php?type=recent","0","0"),
578
+					array("login","Login","user.php?action=login","0","0"),
579
+					array("adminarea","Admin","admin.php","0","2"),
580
+					array("logout","Logout","user.php?action=logout","0","1"),
581
+					array("featured","Featured Stories","browse.php?type=featured","0","0"),
582
+					array("catslink","Categories","browse.php?type=categories","0","0"),
583
+					array("members","Members","authors.php?action=list","0","0"),
584
+					array("authors","Authors","authors.php?list=authors","0","0"),
585
+					array("help","Help","viewpage.php?page=help","0","0"),
586
+					array("search","Search","search.php","0","0"),
587
+					array("series","Series","browse.php?type=series","0","0"),
588
+					array("tens","Top Tens","toplists.php","0","0"),
589
+					array("challenges","Challenges","modules/challenges/challenges.php","0","0"),
590
+					array("contactus","Contact Us","contact.php","0","0"),
591
+					array("rules","Rules","viewpage.php?page=rules","0","0"),
592
+					array("tos","Terms of Service","viewpage.php?page=tos","0","0"),
593
+					array("rss","<img src=\'images/xml.gif\' alt=\'RSS\' border=\'0\'>","rss.php","0","0"),
594
+					array("login","Account Info","user.php","0","1"),
595
+					array("titles","Titles","browse.php?type=titles","0","0"),
596
+					array("register","Register","user.php?action=register","0","0"),
597
+					array("lostpassword","Lost Password","user.php?action=lostpassword","0","0"),
598
+					array("newsarchive","News Archive","news.php","0","0"),
599
+					array("browse","Browse","browse.php","0","0"),
600
+					array("charslink", "Characters", "browse.php?type=characters","0","0"),
601
+					array("ratings", "Ratings", "browse.php?type=ratings", "0", "0"),
602
+					array("genres_link", "Genres", "browse.php?type=class&amp;type_id=1", "0", "0"),
603
+					array("warnings_link", "Warnings", "browse.php?type=class&amp;type_id=2", "0", "0")
604
+				);
605
+				$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>Pages</th><th>Result</th></tr>";
606
+				foreach($pagelist as $page) {
607
+					$pages = dbquery("INSERT INTO `".$tableprefix."fanfiction_pagelinks` (`link_name`, `link_text`, `link_url`, `link_target`, `link_access`) VALUES ('".$page[0]."', '".$page[1]."', '".$page[2]."', '".$page[3]."', '".$page[4]."');");
608
+					$output .= "<tr><td>".stripslashes($page[1])."</td><td align='center'>" . ($pages ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
609
+				}
610
+
611
+				$output .= "</table>";
612
+				$output .= write_message(_LINKAUTOFAIL."<br /><a href='upgrade11.php?step=7'>"._CONTINUE."</a>");
613
+			}
614
+			else {
615
+				$output .= write_message(_LINKMANUAL."<br /><a href='upgrade11.php?step=7'>"._CONTINUE."</a>");
616
+			}
617
+		}
618
+		else $output .= write_message(_LINKDATAINFO." "._LINKSETUP." <a href='upgrade11.php?step=6&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?step=6&amp;install=manual'>"._MANUAL2."</a>");
619
+	break;
620
+	case "5":
621
+		$output .= "<div id='pagetitle'>"._PANELDATA."</div>";
622
+		if(isset($_GET['install'])){
623
+			if($_GET['install'] == "automatic") {
624
+				include("../config.php");
625
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
626
+				list($tableprefix) = dbrow($settings);
627
+				$panellist = array(
628
+					array("submitted","Submissions", "","3","5","0","A"),
629
+					array("versioncheck", "Version Check", "", "3", "7", "0", "A"),
630
+					array("newstory","Add New Story","stories.php?action=newstory&admin=1","3","3","0","A"),
631
+					array("addseries","Add New Series","series.php?action=add","3","3","0","A"),
632
+					array("news","News","","3","5","0","A"),
633
+					array("featured","Featured Stories","","3","5","0","A"),
634
+					array("characters","Characters","","2","2","0","A"),
635
+					array("ratings","Ratings","","2","3","0","A"),
636
+					array("members","Members","","2","5","0","A"),
637
+					array("mailusers","Mail Users","","2","6","0","A"),
638
+					array("settings","Settings","","1","2","0","A"),
639
+					array("blocks","Blocks","","1","3","0","A"),
640
+					array("censor","Censor","","1","0","1","A"),
641
+					array("admins","Admins","","1","6","0","A"),
642
+					array("classifications","Classifications","","2","4","0","A"),
643
+					array("categories","Categories","","2","1","0","A"),
644
+					array("custpages","Custom Pages","","1","4","0","A"),
645
+					array("validate","Validate Submission","","3","0","1","A"),
646
+					array("yesletter","Validation Letter","","3","0","1","A"),
647
+					array("noletter","Rejection Letter","","3","0","1","A"),
648
+					array("links","Page Links","","1","5","0","A"),
649
+					array("messages","Message Settings","","2","0","1","A"),
650
+					array("login","Login","","0","0","1","U"),
651
+					array("logout","Logout","","1","5","0","U"),
652
+					array("revreceived","Reviews Received","","1","0","1","U"),
653
+					array("editprefs","Edit Preferences","","1","2","0","U"),
654
+					array("lostpassword","Lost Password","","0","0","1","U"),
655
+					array("editbio","Edit Bio","","1","1","0","U"),
656
+					array("register","Register","","0","0","1","U"),
657
+					array("manageimages","Manage Images","","1","5","0","S"),
658
+					array("manfavs","Manage Favorites","","1","2","0","F"),
659
+					array("revres","Review Response","","1","0","1","U"),
660
+					array("stats","View Your Statistics","","1","3","0","U"),
661
+					array("newstory","Add New Story","stories.php?action=newstory","1","1","0","S"),
662
+					array("newseries","Add New Series","series.php?action=add","1","3","0","S"),
663
+					array("managestories","Manage Stories","stories.php?action=viewstories","1","2","0","S"),
664
+					array("manageseries","Manage Series","series.php?action=manage","1","4","0","S"),
665
+					array("reviewsby","Your Reviews","","1","0","1","U"),
666
+					array("storiesby","Stories by {author}","","0","1","0","P"),
667
+					array("seriesby","Series by {author}","","0","2","0","P"),
668
+					array("reviewsby","Reviews by {author}","","0","3","0","P"),
669
+					array("categories","Categories","","0","1","0","B"),
670
+					array("characters","Characters","","0","2","0","B"),
671
+					array("ratings","Ratings","","0","3","0","B"),
672
+					array("titles","Titles","","0","5","0","B"),
673
+					array("class","Classes","","0","0","1","B"),
674
+					array("recent","Most Recent","","0","0","1","B"),
675
+					array("featured","Featured Stories","","0","0","1","B"),
676
+					array("panels","Panels","","1","1","0","A"),
677
+					array("phpinfo","PHP Info","","1","7","0","A"),
678
+					array("contact","Contact","","0","0","1","P"),
679
+					array("series", "Series", "", "0", "4", "0", "B"),
680
+					array("viewlog", "Action Log", "", "1", "8", "0", "A"),
681
+					array("shortstories","10 Shortest Stories","toplists/default.php","0","6","0","L"), 
682
+					array("longstories","10 Longest Stories","toplists/default.php","0","5","0","L"), 
683
+					array("largeseries","10 Largest Series","toplists/default.php","0","1","0","L"), 
684
+					array("smallseries","10 Smallest Series","toplists/default.php","0","2","0","L"), 
685
+					array("reviewedseries","10 Most Reviewed Series","toplists/default.php","0","4","0","L"), 
686
+					array("prolificauthors","10 Most Prolific Authors","toplists/default.php","0","10","0","L"), 
687
+					array("prolificreviewers","10 Most Prolific Reviewers","toplists/default.php","0","12","0","L"), 
688
+					array("reviewedstories","10 Most Reviewed Stories","toplists/default.php","0","8","0","L"), 
689
+					array("readstories","10 Most Read Stories","toplists/default.php","0","9","0","L"),
690
+					array("favstories","10 Most Favorite Stories","toplists/default.php","0","7","0","L"), 
691
+					array("favauthors","10 Most Favorite Authors","toplists/default.php","0","11","0","L"), 
692
+					array("favseries","10 Most Favorite Series","toplists/default.php","0","3","0","L"), 
693
+					array("favst","Favorite Stories","","0","0","1","F"),
694
+					array("favse","Favorite Series","","0","0","1","F"),
695
+					array("favau","Favorite Authors","","0","0","1","F"),
696
+					array("favst","Favorite Stories","","0","0","1","U"),
697
+					array("favse","Favorite Series","","0","0","1","U"),
698
+					array("favau","Favorite Authors","","0","0","1","U"),
699
+					array("favlist","{author}\'s Favorites","viewuser.php?action=manfavs","0","5","0","F"),
700
+					array("skins", "Skins", "", "3", "6", "0", "A"),
701
+					array("authorfields", "Profile Information", "", "1", "9", "0", "A"),
702
+					array("maintenance", "Archive Maintenance", "", "1", "10", "0", "A"),
703
+					array("manual", "Admin Manual", "", "3", "6", "0", "A"),
704
+					array('modules', 'Modules', '', 1, "11", 0, 'A')
705
+
706
+				);
707
+				$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>Panel</th><th>Result</th></tr>";
708
+				foreach($panellist as $panel) {
709
+					unset($panels);
710
+					$panels = dbquery("INSERT INTO `".$tableprefix."fanfiction_panels` (`panel_name`, `panel_title`, `panel_url`, `panel_level`, `panel_order`, `panel_hidden`, `panel_type`) VALUES ('".$panel[0]."', '".$panel[1]."', '".$panel[2]."', '".$panel[3]."', '".$panel[4]."', '".$panel[5]."', '".$panel[6]."');");
711
+					$output .= "<tr><td>".stripslashes($panel[1])."</td><td align='center'>" . ($panels ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
712
+				}
713
+				$output .= "</table>";
714
+				$output .= write_message(_PANELAUTOFAIL."<br /> <a href='upgrade11.php?step=6'>"._CONTINUE."</a>");
715
+			}
716
+			else {
717
+				$output .= write_message(_PANELMANUAL."<br /> <a href='upgrade11.php?step=6'>"._CONTINUE."</a>");
718
+			}
719
+		}
720
+		else $output .= write_message(_PANELDATAINFO." "._PANELSETUP." <a href='upgrade11.php?step=5&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?step=5&amp;install=manual'>"._MANUAL2."</a>");
721
+	break;
722
+	case "4":
723
+		$output .= "<div id='pagetitle'>"._INSTALLTABLES."</div>";
724
+		if(isset($_GET['install'])) {
725
+			if($_GET['install'] == "automatic") {
726
+				include("../config.php");
727
+				$settings = dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
728
+				list($tableprefix) = dbrow($settings);
729
+				$output .= "<table class='tblborder' style='margin: 1em auto; padding: 1em;' cellpadding='5'><tr><th>Table</th><th>Result</th></tr>";
730
+				$authorfields = dbquery("CREATE TABLE `".$tableprefix."fanfiction_authorfields` (
731
+  `field_id` int(11) NOT NULL AUTO_INCREMENT,
732
+  `field_type` tinyint(4) NOT NULL default '0',
733
+  `field_name` varchar(30) NOT NULL default ' ',
734
+  `field_title` varchar(255) NOT NULL default ' ',
735
+  `field_options` text,
736
+  `field_code_in` text,
737
+  `field_code_out` text,
738
+  `field_on` tinyint(1) NOT NULL default '0',
739
+  PRIMARY KEY  (`field_id`)
740
+) TYPE=MyISAM;");
741
+$output .= "<tr><td>".$tableprefix."fanfiction_authorfields</td><td align='center'>" . ($authorfields ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
742
+				$authorinfo = dbquery("CREATE TABLE `".$tableprefix."fanfiction_authorinfo` (
743
+  `uid` int(11) NOT NULL default '0',
744
+  `field` int(11) NOT NULL default '0',
745
+  `info` varchar(255) NOT NULL default ' ',
746
+  KEY `uid` (`uid`)
747
+) TYPE=MyISAM;");
748
+$output .= "<tr><td>".$tableprefix."fanfiction_authorinfo</td><td align='center'>" . ($authorinfo ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
749
+				$authorprefs = dbquery("
750
+CREATE TABLE `".$tableprefix."fanfiction_authorprefs` (
751
+  `uid` int(11) NOT NULL default '0',
752
+  `newreviews` tinyint(1) NOT NULL default '0',
753
+  `newrespond` tinyint(1) NOT NULL default '0',
754
+  `ageconsent` tinyint(1) NOT NULL default '0',
755
+  `alertson` tinyint(1) NOT NULL default '0',
756
+  `tinyMCE` tinyint(1) NOT NULL default '0',
757
+  `sortby` tinyint(1) NOT NULL default '0',
758
+  `storyindex` tinyint(1) NOT NULL default '0',
759
+  `validated` tinyint(1) NOT NULL default '0',
760
+  `userskin` varchar(60) NOT NULL default 'default',
761
+  `level` tinyint(1) NOT NULL default '0',
762
+  `categories` varchar(200) NOT NULL default '0',
763
+  `contact` tinyint(1) NOT NULL default '0',
764
+  `stories` int(11) NOT NULL default '0',
765
+   PRIMARY KEY  (`uid`)
766
+) TYPE=MyISAM;");
767
+$output .= "<tr><td>".$tableprefix."fanfiction_authorprefs</td><td align='center'>" . ($authorprefs ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
768
+				$blocks = dbquery("CREATE TABLE `".$tableprefix."fanfiction_blocks` (
769
+  `block_id` int(11) NOT NULL auto_increment,
770
+  `block_name` varchar(30) NOT NULL default '',
771
+  `block_title` varchar(150) NOT NULL default '',
772
+  `block_file` varchar(200) NOT NULL default '',
773
+  `block_status` tinyint(1) NOT NULL default '0',
774
+  `block_variables` text NOT NULL,
775
+  PRIMARY KEY  (`block_id`),
776
+  KEY `block_name` (`block_name`)
777
+) TYPE=MyISAM;");
778
+$output .= "<tr><td>".$tableprefix."fanfiction_blocks</td><td align='center'>" . ($blocks ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
779
+				$chapters = dbquery("CREATE TABLE `".$tableprefix."fanfiction_chapters` (
780
+  `chapid` int(11) NOT NULL auto_increment,
781
+  `title` varchar(250) NOT NULL default '',
782
+  `inorder` int(11) NOT NULL default '0',
783
+  `notes` text NULL,
784
+  `storytext` text NULL,
785
+  `endnotes` text NULL,
786
+  `validated` char(1) NOT NULL default '0',
787
+  `wordcount` int(11) NOT NULL default '0',
788
+  `rating` tinyint(4) NOT NULL default '0',
789
+  `reviews` smallint(6) NOT NULL default '0',
790
+  `sid` int(11) NOT NULL default '0',
791
+  `uid` int(11) NOT NULL default '0',
792
+  `count` int(11) NOT NULL default '0',
793
+  PRIMARY KEY  (`chapid`),
794
+  KEY `sid` (`sid`),
795
+  KEY `uid` (`uid`),
796
+  KEY `inorder` (`inorder`),
797
+  KEY `title` (`title`),
798
+  KEY `validated` (`validated`)
799
+) TYPE=MyISAM;");
800
+$output .= "<tr><td>".$tableprefix."fanfiction_chapters</td><td align='center'>" . ($chapters ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
801
+				$classes = dbquery("CREATE TABLE `".$tableprefix."fanfiction_classes` (
802
+  `class_id` int(11) NOT NULL auto_increment,
803
+  `class_type` int(11) NOT NULL default '0',
804
+  `class_name` varchar(100) NOT NULL default '',
805
+  PRIMARY KEY  (`class_id`)
806
+) TYPE=MyISAM;");
807
+
808
+$output .= "<tr><td>".$tableprefix."fanfiction_classes</td><td align='center'>" . ($classes ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
809
+				$classtypes = dbquery("CREATE TABLE `".$tableprefix."fanfiction_classtypes` (
810
+  `classtype_id` int(11) NOT NULL auto_increment,
811
+  `classtype_name` varchar(50) NOT NULL default '',
812
+  `classtype_title` varchar(50) NOT NULL default '',
813
+  PRIMARY KEY  (`classtype_id`),
814
+  KEY `classtype_title` (`classtype_title`)
815
+) TYPE=MyISAM;");
816
+$output .= "<tr><td>".$tableprefix."fanfiction_classtypes</td><td align='center'>" . ($classtypes ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
817
+$coauthors = dbquery("CREATE TABLE `".TABLEPREFIX."fanfiction_coauthors` (
818
+  `sid` int(11) NOT NULL default '0',
819
+  `uid` int(11) NOT NULL default '0',
820
+  PRIMARY KEY  (`sid`,`uid`)
821
+) TYPE=MyISAM;");
822
+$output .= "<tr><td>".$tableprefix."fanfiction_coauthors</td><td align='center'>" . ($coauthors ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
823
+				$codeblocks = dbquery("CREATE TABLE `".$tableprefix."fanfiction_codeblocks` (
824
+  `code_id` int(11) NOT NULL auto_increment,
825
+  `code_text` text NOT NULL,
826
+  `code_type` varchar(20) default NULL,
827
+  `code_module` varchar(60) default NULL,
828
+  PRIMARY KEY  (`code_id`)
829
+) TYPE=MyISAM;");
830
+$output .= "<tr><td>".$tableprefix."fanfiction_codeblocks</td><td align='center'>" . ($codeblocks ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
831
+				$favorites = dbquery("CREATE TABLE `".$tableprefix."fanfiction_favorites` (
832
+  `uid` int(11) NOT NULL default '0',
833
+  `item` int(11) NOT NULL default '0',
834
+  `type` char(2) NOT NULL default '',
835
+  `comments` text NULL,
836
+  KEY `uid` (`uid`)
837
+) TYPE=MyISAM;");
838
+$output .= "<tr><td>".$tableprefix."fanfiction_favorites</td><td align='center'>" . ($favorites ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
839
+				$inseries = dbquery("CREATE TABLE `".$tableprefix."fanfiction_inseries` (
840
+  `seriesid` int(11) NOT NULL default '0',
841
+  `sid` int(11) NOT NULL default '0',
842
+  `subseriesid` int(11) NOT NULL default '0',
843
+  `confirmed` int(11) NOT NULL default '0',
844
+  `inorder` int(11) NOT NULL default '0',
845
+   PRIMARY KEY  (`sid`,`seriesid`, `subseriesid`),
846
+   KEY `seriesid` (`seriesid`,`inorder`)
847
+) TYPE=MyISAM;");
848
+$output .= "<tr><td>".$tableprefix."fanfiction_inseries</td><td align='center'>" . ($inseries ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
849
+				$logs = dbquery("CREATE TABLE `".$tableprefix."fanfiction_log` (
850
+  `log_id` int(11) NOT NULL auto_increment,
851
+  `log_action` varchar(255) default NULL,
852
+  `log_uid` int(11) NOT NULL,
853
+  `log_ip` int(11) UNSIGNED default NULL,
854
+  `log_timestamp` timestamp NOT NULL,
855
+  `log_type` varchar(2) NOT NULL,
856
+  PRIMARY KEY  (`log_id`)
857
+) TYPE=MyISAM");
858
+$output .= "<tr><td>".$tableprefix."fanfiction_log</td><td align='center'>" . ($logs ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
859
+				$messages = dbquery("CREATE TABLE `".$tableprefix."fanfiction_messages` (
860
+  `message_id` int(11) NOT NULL auto_increment,
861
+  `message_name` varchar(50) NOT NULL default '',
862
+  `message_title` varchar(200) NOT NULL default '',
863
+  `message_text` text NULL,
864
+  PRIMARY KEY  (`message_id`)
865
+) TYPE=MyISAM;");
866
+$output .= "<tr><td>".$tableprefix."fanfiction_messages</td><td align='center'>" . ($messages ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
867
+				$modules = dbquery("
868
+CREATE TABLE `".$tableprefix."fanfiction_modules` (
869
+  `id` int(11) NOT NULL auto_increment,
870
+  `name` varchar(100) NOT NULL default 'Test Module',
871
+  `version` varchar(10) NOT NULL default '1.0',
872
+  PRIMARY KEY  (`id`),
873
+  KEY `name_version` (`name`,`version`)
874
+)");
875
+$output .= "<tr><td>".$tableprefix."fanfiction_modules</td><td align='center'>" . ($modules ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
876
+				$pagelinks = dbquery("CREATE TABLE `".$tableprefix."fanfiction_pagelinks` (
877
+  `link_id` int(11) NOT NULL auto_increment,
878
+  `link_name` varchar(50) NOT NULL default '',
879
+  `link_text` varchar(100) NOT NULL default '',
880
+  `link_key` CHAR( 1 ) NULL,
881
+  `link_url` varchar(250) NOT NULL default '',
882
+  `link_target` char(1) NOT NULL default '0',
883
+  `link_access` tinyint(4) NOT NULL default '0',
884
+  PRIMARY KEY  (`link_id`),
885
+  KEY `link_text` (`link_text`),
886
+  KEY `link_name` (`link_name`)
887
+) TYPE=MyISAM;");
888
+$output .= "<tr><td>".$tableprefix."fanfiction_pagelinks</td><td align='center'>" . ($pagelinks ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
889
+				$panels = dbquery("CREATE TABLE `".$tableprefix."fanfiction_panels` (
890
+  `panel_id` int(11) NOT NULL auto_increment,
891
+  `panel_name` varchar(50) NOT NULL default 'unknown',
892
+  `panel_title` varchar(100) NOT NULL default 'Unnamed Panel',
893
+  `panel_url` varchar(100) default NULL,
894
+  `panel_level` tinyint(4) NOT NULL default '3',
895
+  `panel_order` tinyint(4) NOT NULL default '0',
896
+  `panel_hidden` tinyint(1) NOT NULL default '0',
897
+  `panel_type` varchar(20) NOT NULL default 'A',
898
+  PRIMARY KEY  (`panel_id`),
899
+  KEY `panel_hidden` (`panel_hidden`),
900
+  KEY `panel_type` (`panel_type`)
901
+) TYPE=MyISAM;");
902
+$output .= "<tr><td>".$tableprefix."fanfiction_panels</td><td align='center'>" . ($panels ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
903
+				$series = dbquery("CREATE TABLE `".$tableprefix."fanfiction_series` (
904
+  `seriesid` int(11) NOT NULL auto_increment,
905
+  `title` varchar(200) NOT NULL default '',
906
+  `summary` text NOT NULL,
907
+  `uid` int(11) NOT NULL default '0',
908
+  `isopen` tinyint(4) NOT NULL default '0',
909
+  `catid` varchar(200) NOT NULL default '0',
910
+  `rating` tinyint(4) NOT NULL default '0',
911
+  `classes` varchar(200) NOT NULL default '',
912
+  `characters` varchar(250) NOT NULL default '',
913
+  `reviews` smallint(6) NOT NULL default '0',
914
+  `numstories` INT NOT NULL DEFAULT '0',
915
+  PRIMARY KEY  (`seriesid`),
916
+  KEY `catid` (`catid`),
917
+  KEY `characters` (`characters`),
918
+  KEY `classes` (`classes`),
919
+  KEY `owner` (`uid`,`title`)
920
+) TYPE=MyISAM;");
921
+$output .= "<tr><td>".$tableprefix."fanfiction_series</td><td align='center'>" . ($series ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
922
+	$stats = dbquery("CREATE TABLE `".$tableprefix."fanfiction_stats` (
923
+  `sitekey` varchar(50) NOT NULL default '0',
924
+  `stories` int(11) NOT NULL default '0',
925
+  `chapters` int(11) NOT NULL default '0',
926
+  `series` int(11) NOT NULL default '0',
927
+  `reviews` int(11) NOT NULL default '0',
928
+  `wordcount` int(11) NOT NULL default '0',
929
+  `authors` int(11) NOT NULL default '0',
930
+  `members` int(11) NOT NULL default '0',
931
+  `reviewers` int(11) NOT NULL default '0',
932
+  `newestmember` int(11) NOT NULL default '0'
933
+) TYPE=MyISAM");
934
+	dbquery("INSERT INTO ".$tableprefix."fanfiction_stats(`sitekey`) VALUES('".$sitekey."')");
935
+$output .= "<tr><td>".$tableprefix."fanfiction_stats</td><td align='center'>" . ($stats ? "<img src=\"../images/check.gif\">" : "<img src=\"../images/X.gif\">") ."</td></tr>";
936
+$output .= "</table>";
937
+$output .= write_message(_NEWTABLEAUTOFAIL11."<br /> <a href='upgrade11.php?step=5'>"._CONTINUE."</a>");
938
+			}
939
+			else if($_GET['install'] == "manual") {
940
+				$output .= write_message(_NEWTABLESSETUP."<br /> <a href='upgrade11.php?step=5'>"._CONTINUE."</a>");
941
+			}
942
+		}
943
+		else {
944
+			include("../config.php");
945
+			$output .= write_message(_NEWTABLESSETUP." <a href='upgrade11.php?step=4&amp;install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?step=4&amp;install=manual'>"._MANUAL2."</a>");
946
+		}
947
+	break;
948
+	case "3":			
949
+		define ("_BASEDIR", "../");
950
+		include("../config.php");
951
+		define("SITEKEY", $sitekey);
952
+		if(!$_GET['sect']) $sect = "main";
953
+		else $sect = $_GET['sect'];
954
+		$settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
955
+		if(dbnumrows($settingsresults) == 0) {
956
+			dbquery("INSERT INTO ".$settingsprefix."fanfiction_settings (`sitekey`) VALUES('".$sitekey."');");
957
+			$settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
958
+		}
959
+		$settings = dbassoc($settingsresults);
960
+			foreach($settings as $var => $val) {
961
+			$$var = stripslashes($val);
962
+		}
963
+		define("TABLEPREFIX", $tableprefix);
964
+		if((empty($sect) || $sect == "main") && !isset($_POST['submit'])) $output .= write_message(_SKINWARNING);
965
+		if($sect == "submissions") {
966
+			if($_POST['submit']) {
967
+				$storiespath = descript($_POST['newstoriespath']);
968
+				if(!file_exists($storiespath) && !file_exists("../".$storiespath)) {
969
+					if(!strrchr($storiespath, "/") && !strrchr($storiespath, "\\")) $storiespath = "../$storiespath";
970
+					mkdir("$storiespath", 0755);
971
+					chmod("$storiespath", 0777);
972
+				}
973
+			}
974
+		}
975
+		if($sect == "email" && $_POST['submit']) {
976
+			$output .= "<div id=\"pagetitle\">"._SETTINGS."</div>";
977
+			$smtp_host = $_POST['newsmtp_host'];
978
+			$smtp_username = $_POST['newsmtp_username'];
979
+			$smtp_password = $_POST['newsmtp_password'];
980
+			$result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET smtp_host = '$smtp_host', smtp_username = '$smtp_username', smtp_password = '$smtp_password' WHERE sitekey = '".$sitekey."'");
981
+			if($result) {
982
+				$output .= write_message(_ACTIONSUCCESSFUL);
983
+				$output .= write_message("<a href='upgrade11.php?step=4'>"._CONTINUE."</a>");
984
+			}
985
+			else include("../admin/settings.php");
986
+		}
987
+		else include("../admin/settings.php");
988
+	break;
989
+	case "2":
990
+		$output .= "<div id='pagetitle'>"._CONFIGDATA."</div>";
991
+		define ("_BASEDIR", "../");		
992
+		include("../config.php");
993
+		if(isset($_POST['sitekey'])) {
994
+			// relative path
995
+			if(file_exists("../".$databasepath."/dbconfig.php")) include("../".$databasepath."/dbconfig.php");
996
+			// absolute path
997
+			else if(file_exists($databasepath."/dbconfig.php")) include($databasepath."/dbconfig.php");
998
+			include_once("../includes/dbfunctions.php");
999
+			$dbconnect = dbconnect($dbhost, $dbuser, $dbpass, $dbname );
1000
+			$sitekey = !empty($_POST['sitekey']) ? descript($_POST['sitekey']) : random_string($randomcharset, 10);
1001
+			$settingsprefix = descript($_POST['settingsprefix']);
1002
+			$sitesettings = dbquery("INSERT INTO ".$settingsprefix."fanfiction_settings(
1003
+			`sitename`, `slogan`, `url`, `siteemail`, `store`, `autovalidate`, `multiplecats`, `reviewsallowed`, `ratings`, `roundrobins`, 
1004
+			`submissionsoff`, `anonreviews`, `itemsperpage`, `imageupload`, `imageheight`, `imagewidth`, `skin`) 
1005
+			VALUES('$sitename', '$slogan', '$url', '$siteemail', '$store', '$autovalidate', '$numcats', '$reviewsallowed', '$ratings', '$roundrobins',
1006
+			'$submissionsoff', '$anonreviews', '$itemsperpage', '$imageupload', '$imageheight', '$imagewidth', '$skin')");
1007
+			if($sitesettings) $output .= write_message("<img src=\"../images/check.gif\">"._SITESETTINGSMOVED);
1008
+			$handle = fopen("../config.php", 'w');
1009
+			if(!$handle) {
1010
+				chmod("../config.php", 0666);
1011
+				$handle = fopen("../config.php", 'w');
1012
+			}
1013
+			if ($handle) {
1014
+				$text = "<?php 
1015
+\$dbhost = \"$dbhost\";
1016
+\$dbname = \"$dbname\";
1017
+\$dbuser= \"$dbuser\";
1018
+\$dbpass = \"$dbpass\";
1019
+\$sitekey = \"$sitekey\";
1020
+\$settingsprefix = \"$settingsprefix\";
1021
+
1022
+include_once(\"includes/dbfunctions.php\");
1023
+if(!empty(\$sitekey)) \$dbconnect = dbconnect(\$dbhost, \$dbuser,\$dbpass, \$dbname);
1024
+
1025
+?>";
1026
+				fwrite($handle, $text);
1027
+				fclose($handle);
1028
+				@chmod("../config.php", 0644);
1029
+				$output .= write_message("<img src=\"../images/check.gif\">"._CONFIG_WRITTEN."<br /><a href='upgrade11.php?step=3'>"._CONTINUE."</a>");
1030
+			}
1031
+			else $output .= write_message(_ERROR_CONFIGWRITE);						
1032
+		}
1033
+		else {
1034
+			$output .=  
1035
+				"<form method='POST' enctype='multipart/form-data' action='upgrade11.php?step=2' class='tblborder' style='width: 325px; margin: 1em auto;'>
1036
+						<label for='sitekey'>"._SITEKEY."</label><input type='text' name='sitekey' value='".random_string($randomcharset, 10)."' id='sitekey'><br />
1037
+						<input type='hidden' name='settingsprefix' value='".$_GET['settingsprefix']."'>
1038
+						<div style='text-align: center; margin: 1em;'><INPUT type=\"submit\"class=\"button\" name=\"submit\" value=\"submit\"></div>
1039
+					</form>";
1040
+			$output .= write_message(_HELP_SITEKEY." "._SITEKEYNOTE);
1041
+		}
1042
+	break;
1043
+	default:
1044
+		$output .= "<div id='pagetitle'>Create Settings Table</div>";
1045
+		include("../config.php");
1046
+		if(isset($_POST['submit'])) {
1047
+			// relative path
1048
+			if(file_exists("../".$databasepath."/dbconfig.php")) include("../".$databasepath."/dbconfig.php");
1049
+			// absolute path
1050
+			else if(file_exists($databasepath."/dbconfig.php")) include($databasepath."/dbconfig.php");
1051
+			include("../includes/dbfunctions.php");
1052
+			$dbconnect = dbconnect($dbhost, $dbuser, $dbpass, $dbname );
1053
+			$settings = dbquery("SHOW TABLES LIKE '".$tableprefix."fanfiction_settings'");
1054
+			if($settings) dbquery("RENAME TABLE ".$tableprefix."fanfiction_settings TO ".$tableprefix."fanfiction_settings_old");
1055
+								$settings = dbquery("CREATE TABLE IF NOT EXISTS`".$_POST['settingsprefix']."fanfiction_settings` (
1056
+  `sitekey` varchar(50) NOT NULL default '1',
1057
+  `sitename` varchar(200) NOT NULL default 'Your Site',
1058
+  `slogan` varchar(200) NOT NULL default 'It''s a cool site!',
1059
+  `url` varchar(200) NOT NULL default 'http://www.yoursite.com',
1060
+  `siteemail` varchar(200) NOT NULL default 'you@yoursite.com',
1061
+  `tableprefix` varchar(50) NOT NULL default '',
1062
+  `skin` varchar(50) NOT NULL default 'default',
1063
+  `hiddenskins` varchar(255) default '',
1064
+  `language` varchar(10) NOT NULL default 'en',
1065
+  `submissionsoff` tinyint(1) NOT NULL default '0',
1066
+  `storiespath` varchar(20) NOT NULL default 'stories',
1067
+  `store` varchar(5) NOT NULL default 'files',
1068
+  `autovalidate` tinyint(1) NOT NULL default '0',
1069
+  `coauthallowed` int(1) NOT NULL default '0',
1070
+  `maxwords` int(11) NOT NULL default '0',
1071
+  `minwords` int(11) NOT NULL default '0',
1072
+  `imageupload` tinyint(1) NOT NULL default '0',
1073
+  `imageheight` int(11) NOT NULL default '200',
1074
+  `imagewidth` int(11) NOT NULL default '200',
1075
+  `roundrobins` tinyint(1) NOT NULL default '0',
1076
+  `allowseries` tinyint(4) NOT NULL default '2',
1077
+  `tinyMCE` tinyint(1) NOT NULL default '0',
1078
+  `allowed_tags` varchar(200) NOT NULL default '<b><i><u><center><hr><p><br /><br><blockquote><ol><ul><li><img><strong><em>',
1079
+  `favorites` tinyint(1) NOT NULL default '0',
1080
+  `multiplecats` tinyint(1) NOT NULL default '0',
1081
+  `newscomments` tinyint(1) NOT NULL default '0',
1082
+  `logging` tinyint(1) NOT NULL default '0',
1083
+  `maintenance` tinyint(1) NOT NULL default '0',
1084
+  `debug` tinyint(1) NOT NULL default '0',
1085
+  `captcha` tinyint(1) NOT NULL default '0',
1086
+  `dateformat` varchar(20) NOT NULL default 'd/m/y',
1087
+  `timeformat` varchar(20) NOT NULL default '- h:i a',
1088
+  `recentdays` tinyint(2) NOT NULL default '7',
1089
+  `displaycolumns` tinyint(1) NOT NULL default '1',
1090
+  `itemsperpage` tinyint(2) NOT NULL default '25',
1091
+  `extendcats` tinyint(1) NOT NULL default '0',
1092
+  `displayindex` tinyint(1) NOT NULL default '0',
1093
+  `defaultsort` tinyint(1) NOT NULL default '0',
1094
+  `displayprofile` tinyint(1) NOT NULL default '0',
1095
+  `linkstyle` tinyint(1) NOT NULL default '0',
1096
+  `linkrange` tinyint(2) NOT NULL default '5',
1097
+  `reviewsallowed` tinyint(1) NOT NULL default '0',
1098
+  `ratings` tinyint(1) NOT NULL default '0',
1099
+  `anonreviews` tinyint(1) NOT NULL default '0',
1100
+  `revdelete` tinyint(1) NOT NULL default '0',
1101
+  `rateonly` tinyint(1) NOT NULL default '0',
1102
+  `pwdsetting` tinyint(1) NOT NULL default '0',
1103
+  `alertson` tinyint(1) NOT NULL default '0',
1104
+  `disablepopups` tinyint(1) NOT NULL default '0',
1105
+  `agestatement` tinyint(1) NOT NULL default '0',
1106
+  `words` text,
1107
+  `version` varchar(10) NOT NULL default '".$version."',
1108
+  `smtp_host` varchar(200) default NULL,
1109
+  `smtp_username` varchar(50) default NULL,
1110
+  `smtp_password` varchar(50) default NULL,
1111
+  PRIMARY KEY  (`sitekey`)
1112
+) TYPE=MyISAM;");
1113
+if($settings) $output .= write_message("<img src=\"../images/check.gif\"> "._SETTINGSTABLESUCCESS." <br /><a href='upgrade11.php?step=2&amp;settingsprefix=".$_POST['settingsprefix']."'>"._CONTINUE."</a>");
1114
+else $output .= write_message(_SETTINGSTABLEAUTOFAIL." <br /><a href='upgrade11.php?step=2&amp;settingsprefix=".$_POST['settingsprefix']."'>"._CONTINUE."</a> ");
1115
+		}
1116
+		else {
1117
+			$install = isset($_GET['install']) ? $_GET['install'] : false;
1118
+			if($install == "manual") {
1119
+				$output .= write_message(_SETTINGSTABLEMANUAL."<br /><a href='upgrade11.php?step=2'>"._CONTINUE."</a>");
1120
+			}
1121
+			else if($install == "automatic") {
1122
+				$output .=  
1123
+					"<form method='POST' enctype='multipart/form-data' action='upgrade11.php?step=1' class='tblborder' style='width: 325px; margin: 1em auto;'>
1124
+						<label for='settingsprefix'>"._SETTINGSPREFIX."</label><input type='text' name='settingsprefix' id='settingsprefix' value='".$tableprefix."'><br />
1125
+						<div style='text-align: center; margin: 1em;'><INPUT type=\"submit\"class=\"button\" name=\"submit\" value=\"submit\"></div>
1126
+					</form>";
1127
+				$output .= write_message(_SETTINGSTABLENOTE);
1128
+			}
1129
+			else { 
1130
+				$output .= write_message(_SETTINGSTABLESETUP." <a href='upgrade11.php?install=automatic'>"._AUTO."</a> "._OR." <a href='upgrade11.php?install=manual'>"._MANUAL2."</a>");
1131
+			}
1132
+		}
1133
+}
1134
+$tpl->assign("output", $output);
1135
+
1136
+$tpl->printToScreen();
1137
+if($step > 1) dbclose( );
1138
+?>
0 1139
\ No newline at end of file