chapter storytext: text -> mediumtext support
chapter storytext: text -> mediumtext support

--- a/admin/convert_mod.php
+++ b/admin/convert_mod.php
@@ -41,6 +41,11 @@
 		if (!dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = 'convert' AND panel_title = 'Archive Conversion';"))) {
 			dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
 			dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_panels`(`panel_name`, `panel_title`, `panel_url`, `panel_level`, `panel_hidden`, `panel_type`, `panel_order`) VALUES( 'convert', 'Archive Conversion', '', '1', '0', 'A', '11')");
+		}
+		$field_info = dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_chapters LIKE 'storytext'"));
+		if (strtolower($field_info['Type']) != 'mediumtext')
+		{
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_chapters` MODIFY `storytext` MEDIUMTEXT NULL");
 		}
 		// initial UTF-8 conversion
 		dbquery("ALTER DATABASE $dbname DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");

--- a/admin/convert_mod_0900.php
+++ b/admin/convert_mod_0900.php
@@ -41,6 +41,11 @@
 		if (!dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = 'convert' AND panel_title = 'Archive Conversion';"))) {
 			dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
 			dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_panels`(`panel_name`, `panel_title`, `panel_url`, `panel_level`, `panel_hidden`, `panel_type`, `panel_order`) VALUES( 'convert', 'Archive Conversion', '', '1', '0', 'A', '11')");
+		}
+		$field_info = dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_chapters LIKE 'storytext'"));
+		if (strtolower($field_info['Type']) != 'mediumtext')
+		{
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_chapters` MODIFY `storytext` MEDIUMTEXT NULL");
 		}
 		// initial UTF-8 conversion
 		dbquery("ALTER DATABASE $dbname DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_0900_bin;");

--- a/docs/settingstable.sql
+++ b/docs/settingstable.sql
@@ -56,7 +56,7 @@
   `disablepopups` tinyint(1) NOT NULL default '0',
   `agestatement` tinyint(1) NOT NULL default '0',
   `words` text,
-  `version` varchar(10) NOT NULL default '3.5.9',
+  `version` varchar(10) NOT NULL default '0.9.3',
   `smtp_host` varchar(200) default NULL,
   `smtp_username` varchar(50) default NULL,
   `smtp_password` varchar(50) default NULL,

--- a/docs/tables.sql
+++ b/docs/tables.sql
@@ -122,7 +122,7 @@
   `title` varchar(250) NOT NULL default '',
   `inorder` int(11) NOT NULL default '0',
   `notes` text NOT NULL,
-  `storytext` text NOT NULL,
+  `storytext` mediumtext NOT NULL,
   `endnotes` text,
   `validated` tinyint(4) NOT NULL default '0',
   `wordcount` int(11) NOT NULL default '0',
@@ -166,7 +166,7 @@
 CREATE TABLE `fanfiction_classes` (
   `class_id` int(11) NOT NULL auto_increment,
   `class_type` int(11) NOT NULL default '0',
-  `class_name` varchar(100) NOT NULL default '' COLLATE utf8mb4_unicode_ci,
+  `class_name` varchar(100) NOT NULL default '',
   PRIMARY KEY  (`class_id`),
   KEY `byname` (`class_type`,`class_name`,`class_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
@@ -179,8 +179,8 @@
 
 CREATE TABLE `fanfiction_classtypes` (
   `classtype_id` int(11) NOT NULL auto_increment,
-  `classtype_name` varchar(50) NOT NULL default '' COLLATE utf8mb4_unicode_ci,
-  `classtype_title` varchar(50) NOT NULL default '' COLLATE utf8mb4_unicode_ci,
+  `classtype_name` varchar(50) NOT NULL default '',
+  `classtype_title` varchar(50) NOT NULL default '',
   PRIMARY KEY  (`classtype_id`),
   UNIQUE KEY `classtype_name` (`classtype_name`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

--- a/install/install.php
+++ b/install/install.php
@@ -583,7 +583,7 @@
   `title` varchar(250) NOT NULL default '',
   `inorder` int(11) NOT NULL default '0',
   `notes` text NULL,
-  `storytext` text NULL,
+  `storytext` mediumtext NULL,
   `endnotes` text NULL,
   `validated` char(1) NOT NULL default '0',
   `wordcount` int(11) NOT NULL default '0',

file:a/update.php -> file:b/update.php
--- a/update.php
+++ b/update.php
@@ -68,6 +68,7 @@
 	$set_356 = do_version_check_356();
 	$set_359 = do_version_check_359();
 	$set_090 = do_version_check_090();
+	$set_093 = do_version_check_093();
 	$set_generic = do_version_check_generic();
  
 	if ($set_356)
@@ -96,6 +97,17 @@
 			$output .= write_message("Table <b>" . $set_090 . "</b> needs an update.");
 			dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '0.9.0' WHERE sitekey = '" . SITEKEY . "'");
 			$settings['version'] = '0.9.0';
+		}
+	}
+
+	else if ($set_093) {
+		$set_093 = do_version_check_093();
+	
+		if ($set_093)
+		{
+			$output .= write_message("Table <b>" . $set_093 . "</b> needs an update.");
+			dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '0.9.2' WHERE sitekey = '" . SITEKEY . "'");
+			$settings['version'] = '0.9.2';
 		}
 	}
 
@@ -162,8 +174,8 @@
 				),
 			);
 
-			// Tables where IP address field needs updating to accommodate IPV6
-			// Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
+			// Tables where datetime/timestamp field needs updating to int
+			// Set to int(10) - for storing Unix timestamp
 			foreach ($date_upgrade as $tmp)
 			{
 
@@ -392,7 +404,69 @@
 //	else $output .= write_message("Are you ready to update? <a href='update.php?confirm=yes'>"._YES."</a> "._OR." <a href='update.php?confirm=no'>"._NO."</a>");
 //}
 
-elseif ($oldVersion[0] == 0 && $oldVersion[1] == 9 && ($oldVersion[2] == 0 || $oldVersion[2] < 10))  // Mod 0.9.0 -> Mod 0.9.1 (and further within 0.9.x)
+elseif ($oldVersion[0] == 0 && $oldVersion[1] == 9 && $oldVersion[2] < 2)  // Mod 0.9.[0,1] -> Mod 0.9.2
+{
+	$set_generic = do_version_check_generic();
+	if (!$set_generic) {
+		$update = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET version = '".$version."' WHERE sitekey = '".SITEKEY."'");
+		if ($update) $output .= write_message("No database changes required; eFiction 3 Mod Version bumped to ".$version."! " ._ACTIONSUCCESSFUL);
+	}
+
+}
+
+elseif ($oldVersion[0] == 0 && $oldVersion[1] == 9 && $oldVersion[2] < 3)  // Mod 0.9.[0,1,2] -> Mod 0.9.3
+{
+	if ($confirm == "yes")
+	{
+		if ($oldVersion[0] == 0 &&  $oldVersion[1] == 9 && $oldVersion[2] < 3)
+		{
+			// List of DB tables (key) and field (value) which need changing text from text to mediumtext
+			$text_upgrade = array(
+				'fanfiction_chapters' => 'storytext'
+			);
+
+			foreach ($text_upgrade as $t => $f)
+			{
+				if (isTable($t))
+				{
+			 
+					// Check for table - might add some core plugin tables in here
+					if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
+					{
+						if (strtolower($field_info['Type']) != 'mediumtext')
+						{
+
+							dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_chapters` MODIFY `storytext` MEDIUMTEXT NULL");
+ 
+						}
+					}
+				}
+			}	 
+		}
+
+		$set_093 = false;
+		$set_093 = do_version_check_093();
+		if($set_093) {
+			$output .= write_error(_ERROR);
+		}
+		else {
+			$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '" . $version . "' WHERE sitekey = '" . SITEKEY . "'");
+			if ($update) $output .= write_message(_ACTIONSUCCESSFUL);
+			}
+		}
+	else if ($confirm == "no")
+	{
+		$output .= write_message(_ACTIONCANCELLED);
+	}
+	else
+	{
+		if ($oldVersion[0] == 0 && $oldVersion[1] == 9 && $oldVersion[2] < 3)
+			$output .= write_message(_CONFIRMUPDATE . "<br /> <a href='update.php?confirm=yes'>" . _YES . "</a> " . _OR . " <a href='update.php?confirm=no'>" . _NO . "</a>");
+		else $output .= write_message("Are you ready to update? <a href='update.php?confirm=yes'>" . _YES . "</a> " . _OR . " <a href='update.php?confirm=no'>" . _NO . "</a>");
+	}
+}
+
+elseif ($oldVersion[0] == 0 && $oldVersion[1] == 9 && $oldVersion[2] < 10)  // Mod 0.9.3 -> Mod 0.9.4 (and further within 0.9.x)
 {
 	$set_generic = do_version_check_generic();
 	if (!$set_generic) {
@@ -498,7 +572,7 @@
 			
 				if (strtolower($field_info['Type']) != 'varbinary(16)')
 				{
-					$check_356 = $t . " - field:  " . $f;;
+					$check_356 = $t . " - field:  " . $f;
 			 
 					return $check_356;	 
 				}
@@ -545,6 +619,40 @@
 	return $check_090;
 }
 
+function do_version_check_093()
+{
+	$check_093 = false;
+ 
+	// List of DB tables (key) and field (value) which need changing text from text to mediumtext
+	$text_upgrade = array(
+		'fanfiction_chapters' => 'storytext'
+	);
+
+	foreach ($text_upgrade as $t => $f)
+	{
+ 
+		if (isTable($t))
+		{
+			// Check for table - might add some core plugin tables in here
+			if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t ." LIKE '{$f}'")) )
+			{
+
+			
+				if (strtolower($field_info['Type']) != 'mediumtext')
+				{
+					$check_093 = $t . " - field:  " . $f;
+			 
+					return $check_093;	 
+				}
+			}
+	 
+		}
+		
+	}
+ 
+	return $check_093;
+}
+
 function do_version_check_generic()
 {
 	$check_generic = false;