Browse code

Mod conversion rewrite - expand mod conversion help popup - add Unicode 5.2 support

Clarissa Walker authored on 2026/09/18 17:02:34
Showing 4 changed files
... ...
@@ -34,6 +34,9 @@ if($convert == "convert_mod") {
34 34
 if($convert == "convert_utf") {
35 35
 	if(file_exists("admin/convert_utf.php")) include_once("admin/convert_utf.php");
36 36
 }
37
+if($convert == "convert_0520") {
38
+	if(file_exists("admin/convert_0520.php")) include_once("admin/convert_0520.php");
39
+}
37 40
 if($convert == "convert_0900") {
38 41
 	if(file_exists("admin/convert_0900.php")) include_once("admin/convert_0900.php");
39 42
 }
... ...
@@ -44,6 +47,7 @@ $output .= "
44 47
 <ul>
45 48
 	<li><a href='admin.php?action=convert&amp;conv=convert_mod'>"._CONVERT_MOD."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CONVERTMOD."</span></A></li>
46 49
 	<li><a href='admin.php?action=convert&amp;conv=convert_utf'>"._CONVERT_UTF."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CONVERTUTF."</span></A></li>
50
+	<li><a href='admin.php?action=convert&amp;conv=convert_0520'>"._CONVERT_0520."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CONVERT0520."</span></A></li>
47 51
 	<li><a href='admin.php?action=convert&amp;conv=convert_0900'>"._CONVERT_0900."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CONVERT0900."</span></A></li>
48 52
 	<li><a href='admin.php?action=convert&amp;conv=convert_1400'>"._CONVERT_1400."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CONVERT1400."</span></A></li>
49 53
 </ul>";
50 54
new file mode 100644
... ...
@@ -0,0 +1,64 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.0
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+$expVer = explode(".", $version);
27
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
28
+
29
+// silly converted update script... just to further convert collation in some tables
30
+
31
+// messy version check, starting with version 3.5.9
32
+if($expVer[0] == 3 && ($expVer[1] == 5 || $expVer[1] >=6 && (!isset($expVer[2]) || $expVer[2] == 9 || $expVer[2] > 0))) {
33
+if($confirm == "yes") {
34
+	// For converting certain fields to a chosen collation, starting with versions 3.5.9
35
+    if($expVer[0] == 3 && ($expVer[1] == 5 || $expVer[1] >=6 && (!isset($expVer[2]) || $expVer[2] == 9 || $expVer[2] > 0))) {
36
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authors CHANGE `penname` `penname` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '', CHANGE `realname` `realname` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '';");
37
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_categories CHANGE `category` `category` VARCHAR(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '';");
38
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_characters CHANGE `charname` `charname` VARCHAR(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '';");
39
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_favorites CHANGE `type` `type` CHAR(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL;");
40
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_ratings CHANGE `rating` `rating` VARCHAR(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '';");
41
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_series CHANGE `title` `title` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '', CHANGE `summary` `summary` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL;");
42
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_stories CHANGE `title` `title` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'Untitled', CHANGE `summary` `summary` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NULL DEFAULT NULL;");
43
+		$alltables = dbquery("SHOW TABLES");
44
+	}
45
+	$update = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET version = '$version' WHERE sitekey ='".SITEKEY."'");
46
+	$alltables = dbquery("SHOW TABLES");
47
+	while ($table = dbassoc($alltables)) {
48
+		foreach ($table as $db => $tablename) {
49
+			dbquery("OPTIMIZE TABLE `".$tablename."`");
50
+		}
51
+	}
52
+	if($update) $output .= write_message(_ACTIONSUCCESSFUL);
53
+	else $output .= write_error(_ERROR);
54
+}
55
+else if($confirm == "no") {
56
+	$output .= write_message(_ACTIONCANCELLED);
57
+}
58
+else {
59
+  	$output .= write_message("Some fields in this setup will be converted to Unicode 5.2.  You should run the eFiction 3 Mod conversion first.  You are advised to back up your database before starting! <br />
60
+Are you ready to convert to Unicode 5.2? <a href='admin.php?action=convert&conv=convert_0520&amp;confirm=yes'>"._YES."</a> "._OR." <a href='admin.php?action=convert&conv=convert_0520&amp;confirm=no'>"._NO."</a>");
61
+}
62
+}
63
+else $output .= write_message(_ALREADYUPDATED);
64
+?>
... ...
@@ -40,7 +40,7 @@ if($confirm == "yes") {
40 40
 			dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
41 41
 			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')");
42 42
 		}
43
-		// rest of the conversion
43
+		// initial UTF-8 conversion
44 44
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authorfields ENGINE=INNODB, DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");
45 45
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authorinfo ENGINE=INNODB, DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");
46 46
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authorprefs ENGINE=INNODB, DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");
... ...
@@ -68,6 +68,35 @@ if($confirm == "yes") {
68 68
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_settings ENGINE=INNODB, DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");
69 69
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_stats ENGINE=INNODB, DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");
70 70
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_stories ENGINE=INNODB, DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin;");
71
+		// phase two of UTF-8 conversion
72
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authorfields CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
73
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authorinfo CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
74
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authorprefs CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
75
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authors CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
76
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_blocks CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
77
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_categories CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
78
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_chapters CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
79
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_characters CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
80
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_classes CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
81
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_classtypes CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
82
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_coauthors CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
83
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_codeblocks CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
84
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_comments CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
85
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_favorites CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
86
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_inseries CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
87
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_log CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
88
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_messages CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
89
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_modules CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
90
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_news CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
91
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_pagelinks CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
92
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_panels CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
93
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_ratings CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
94
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_reviews CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
95
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_series CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
96
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_settings CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
97
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_stats CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
98
+		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_stories CONVERT TO CHARSET utf8mb4 COLLATE utf8mb4_bin;");
99
+		// change collation of certain tables
71 100
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_authors CHANGE `penname` `penname` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', CHANGE `realname` `realname` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';");
72 101
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_categories CHANGE `category` `category` VARCHAR(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';");
73 102
 		dbquery("ALTER TABLE ".TABLEPREFIX."fanfiction_characters CHANGE `charname` `charname` VARCHAR(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';");
... ...
@@ -81,6 +81,7 @@ define ("_CONFIRMVALREVOKE", "Are you sure you want to revoke this author's vali
81 81
 define ("_CONFIRMVALIDATE", "Are you sure you want to validate this author?");
82 82
 define ("_CONVERT_MOD", "Convert to eFiction 3 Mod");
83 83
 define ("_CONVERT_UTF", "Convert back to Unicode 4.0");
84
+define ("_CONVERT_0520", "Convert to Unicode 5.2");
84 85
 define ("_CONVERT_0900", "Convert to Unicode 9.0");
85 86
 define ("_CONVERT_1400", "Convert to Unicode 14.0");
86 87
 define ("_COPYRIGHT", "Copyright Footer");
... ...
@@ -393,8 +394,9 @@ define ("_HELP_UPDATE", "After uploading eFiction script updates to your archive
393 394
 define ("_HELP_CATORDER", "This option will fix errors in the numbering of the category order saved in the database.  This will <strong>not</strong> change the order of your categories only correct errors in the database numbering.");
394 395
 define ("_HELP_PANELORDER", "This option will fix errors in the numbering of the panel order saved in the database.  This will <strong>not</strong> change the order of your panels only correct errors in the database numbering.");
395 396
 define ("_HELP_RECALCSTORIES", "Click here to fix the story count for authors.");
396
-define("_HELP_CONVERTMOD", "This converts your current eFiction install to eFiction 3 Mod.");
397
+define("_HELP_CONVERTMOD", "This converts your current eFiction install to eFiction 3 Mod. This will work to some extent in the latin1 collation as long as you are not using any multibyte characters.");
397 398
 define("_HELP_CONVERTUTF", "This converts your current eFiction 3 Mod install back to supporting Unicode 4.0.");
399
+define("_HELP_CONVERT0520", "This converts your current eFiction 3 Mod install to support Unicode 5.2.");
398 400
 define("_HELP_CONVERT0900", "This converts your current eFiction 3 Mod install to support Unicode 9.0.");
399 401
 define("_HELP_CONVERT1400", "This converts your current eFiction 3 Mod install to support Unicode 14.0.");
400 402