Browse code

version 3.5.7

Jimako authored on 2024/04/08 12:21:57
Showing 33 changed files
... ...
@@ -396,3 +396,6 @@ FodyWeavers.xsd
396 396
 
397 397
 # JetBrains Rider
398 398
 *.sln.iml
399
+languages/sk.php
400
+languages/sk_admin.php
401
+/modules/storybanner
... ...
@@ -1,3 +1,21 @@
1
+# efiction v3.5.7
2
+
3
+minimum requirements:  MySQL 5.6.3  or MariaDB 10.5.0 
4
+
5
+
6
+### Database changes:
7
+
8
+- all IP adress fields - from integer to 46 chars
9
+
10
+### Other changes:
11
+
12
+- tinymce4 settings fix
13
+- INET6 support needed
14
+- file uploading fixed for PHP 8.1
15
+- national characters fix in search form 
16
+
17
+
18
+
1 19
 # efiction v3.5.6
2 20
 
3 21
 non official version of 3.5.x efiction software
... ...
@@ -78,7 +78,7 @@ function datadump ($table) {
78 78
 			datadump(current($table));
79 79
 	}
80 80
 
81
- 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_BACKUP, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
81
+ 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_BACKUP, USERPENNAME, USERUID))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
82 82
 	exit( );
83 83
 
84
-?>
85 84
\ No newline at end of file
85
+?>
... ...
@@ -80,7 +80,7 @@ function datadump ($table) {
80 80
 			datadump(current($table));
81 81
 	}
82 82
 
83
- 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_BACKUP, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
83
+ 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_BACKUP, USERPENNAME, USERUID))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
84 84
 	exit( );
85 85
 
86
-?>
87 86
\ No newline at end of file
87
+?>
... ...
@@ -59,7 +59,7 @@ if($maint == "reviews") {
59 59
 	while($code = dbassoc($codequery)) {
60 60
 		$eval($code['code_text']);
61 61
 	}
62
-	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_RECALCREVIEWS, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
62
+	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_RECALCREVIEWS, USERPENNAME, USERUID))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
63 63
 	$output .= write_message(_ACTIONSUCCESSFUL);
64 64
 }
65 65
 else if($maint == "stories") {
... ...
@@ -97,7 +97,7 @@ else if($maint == "categories") {
97 97
 		list($count) = dbrow($countquery);
98 98
 		dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET numitems = $count WHERE catid = $cat[0]");
99 99
 	}
100
-	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_CATCOUNTS, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
100
+	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_CATCOUNTS, USERPENNAME, USERUID))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
101 101
 	$output .= write_message(_CATCOUNTSUPDATED);
102 102
 }
103 103
 else if($maint == "categories2") {
... ...
@@ -192,7 +192,7 @@ else if($maint == "optimize") {
192 192
 			dbquery("OPTIMIZE TABLE `".$tablename."`");
193 193
 		}
194 194
 	}
195
- 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_OPTIMIZE, USERPENNAME, USERUID))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
195
+ 	if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_OPTIMIZE, USERPENNAME, USERUID))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'AM', " . time() . ")");
196 196
 	$output .= write_message(_ACTIONSUCCESSFUL);
197 197
 }
198 198
 else if($maint == "backup") {
... ...
@@ -212,4 +212,4 @@ else {
212 212
 	<li><a href='admin.php?action=maintenance&amp;maint=update'>"._UPDATE."</a>  <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_UPDATE."</span></A></li>
213 213
 </ul>";
214 214
 }
215
-?>
216 215
\ No newline at end of file
216
+?>
... ...
@@ -168,7 +168,7 @@ $confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
168 168
 			if(preg_match("!^[a-z0-9_ ]{3,30}$!i", $_POST['penname'])) {
169 169
 				dbquery("INSERT INTO ".substr(_AUTHORTABLE, 0, strpos(_AUTHORTABLE, "as author"))."(penname, realname, email, admincreated, date) VALUES ('".escapestring(descript($_POST['penname']))."', '".escapestring(descript($_POST['realname']))."', '".escapestring(descript($_POST['email']))."', '1', now())");
170 170
 				$newuid = dbinsertid( );
171
-				if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_REG, descript($_POST['penname']), $newuid, USERPENNAME, USERUID, $_SERVER['REMOTE_ADDR']))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
171
+				if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_REG, descript($_POST['penname']), $newuid, USERPENNAME, USERUID, $_SERVER['REMOTE_ADDR']))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
172 172
 				if(!$skin) {
173 173
 					$skinquery = dbquery("SELECT skin FROM ".$settingsprefix."fanfiction_settings WHERE sitekey ='".SITEKEY."'");
174 174
 					list($skin) = dbrow($skinquery);
... ...
@@ -269,4 +269,4 @@ $confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
269 269
 		else $output .= write_message("<a href=\"admin.php?action=members&do=add\">"._ADDAUTHOR."</a>");
270 270
 		if(isset($message)) $output .= $message;
271 271
 	}
272
-?>
273 272
\ No newline at end of file
273
+?>
... ...
@@ -42,7 +42,7 @@ $chapid = isset($_GET['chapid']) && isNumber($_GET['chapid']) ? $_GET['chapid']
42 42
 		if($logging) {
43 43
 			$storyquery = dbquery("SELECT story.title, chapter.title as chapter, author.email, author.penname, chapter.uid, chapter.inorder FROM ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters as chapter, ".TABLEPREFIX."fanfiction_authors as author WHERE chapter.uid = author.uid AND chapter.chapid = '$chapid' AND chapter.sid = story.sid LIMIT 1");
44 44
 			$story = dbassoc($storyquery);
45
-			dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REJECTION, USERPENNAME, USERUID, $title, $sid, $uid, $penname, $inorder, $letter))."', '".USERUID."', INET_ATON('".$_ENV['REMOTE_ADDR']."'), 'RJ', ". time() . ")");
45
+			dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REJECTION, USERPENNAME, USERUID, $title, $sid, $uid, $penname, $inorder, $letter))."', '".USERUID. "', INET6_ATON('".$_ENV['REMOTE_ADDR']."'), 'RJ', ". time() . ")");
46 46
 		}
47 47
 
48 48
 	}
... ...
@@ -64,4 +64,4 @@ $chapid = isset($_GET['chapid']) && isNumber($_GET['chapid']) ? $_GET['chapid']
64 64
 				<textarea class=\"textbox\" name=\"letter\" cols=\"40\" rows=\"7\">$letter</TEXTAREA><br /><INPUT type=\"submit\" style=\"margin: 10px;\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></form></div></body></html>";
65 65
 		exit( );
66 66
 	}
67
-?>
68 67
\ No newline at end of file
68
+?>
... ...
@@ -108,7 +108,7 @@ function preview_story($stories) {
108 108
 						sendemail($favuser['penname'], $favuser['email'], $sitename, $siteemail, $subject, $mailtext, "html");
109 109
 					}				
110 110
 				}
111
-				if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_VALIDATE_STORY, USERPENNAME, USERUID, $title, $sid, $author, $authoruid))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'VS', " . time() . ")");
111
+				if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_VALIDATE_STORY, USERPENNAME, USERUID, $title, $sid, $author, $authoruid))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'VS', " . time() . ")");
112 112
 				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET stories = stories + 1");
113 113
 			}
114 114
 			else if($alertson) {
... ...
@@ -122,7 +122,7 @@ function preview_story($stories) {
122 122
 				while($favuser = dbassoc($favorites)) { 
123 123
 					sendemail($favuser['penname'], $favuser['email'], $sitename, $siteemail, $subject, $mailtext, "html");
124 124
 				}
125
-				if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_VALIDATE_CHAPTER, USERPENNAME, USERUID, $title, $sid, $author, $authoruid, $inorder))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'VS', " . time() . ")");
125
+				if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_VALIDATE_CHAPTER, USERPENNAME, USERUID, $title, $sid, $author, $authoruid, $inorder))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'VS', " . time() . ")");
126 126
 			}
127 127
 			dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET validated = '1' WHERE chapid = '$_GET[chapid]'");
128 128
 			dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET updated = '" . time() . "' WHERE sid = '$sid'");
... ...
@@ -148,4 +148,4 @@ function preview_story($stories) {
148 148
 
149 149
 		}
150 150
 	}
151
-?>
152 151
\ No newline at end of file
152
+?>
... ...
@@ -46,7 +46,7 @@ $output .= "</select></form></div>";
46 46
 $countquery = dbquery("SELECT COUNT(log_id) FROM ".TABLEPREFIX."fanfiction_log".($type ? " WHERE log_type = '$type'" : ""));
47 47
 list($count) = dbrow($countquery);
48 48
 if($count > 0) {
49
-	$result = dbquery("SELECT log_action, INET_NTOA(log_ip) as log_ip,  log_timestamp as log_timestamp FROM ".TABLEPREFIX."fanfiction_log".($type ? " WHERE log_type = '$type'" : "")." ORDER BY log_timestamp DESC LIMIT $offset, $itemsperpage");
49
+	$result = dbquery("SELECT log_action, INET6_NTOA(log_ip) as log_ip,  log_timestamp as log_timestamp FROM ".TABLEPREFIX."fanfiction_log".($type ? " WHERE log_type = '$type'" : "")." ORDER BY log_timestamp DESC LIMIT $offset, $itemsperpage");
50 50
 	$output .= "<table class=\"tblborder\" cellspacing=\"0\" cellpadding=\"3\" style=\"width: 90%; margin: 0 auto;\"><tr class=\"tblborder\"><th>"._ACTION."</th><th>"._IP."</th><th>"._DATE."</th></tr>";
51 51
 	while ($item = dbassoc($result)) {
52 52
 			$output .= "<tr class=\"tblborder\">
... ...
@@ -61,4 +61,4 @@ if($count > 0) {
61 61
 }
62 62
 else $output .= write_message(_NORESULTS);
63 63
 $output .= write_message("<a href='admin.php?action=viewlog&amp;purge=1'>"._PURGELOG."</a>");
64
-?>
65 64
\ No newline at end of file
65
+?>
... ...
@@ -27,9 +27,9 @@ if(!defined("_CHARSET")) exit( );
27 27
 
28 28
 
29 29
 dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_blocks(`block_name`, `block_title`, `block_status`, `block_file`, `block_variables`) VALUES('online', 'Who\'s Online', '0', 'online/online.php', '');");
30
-dbquery("CREATE TABLE IF NOT EXISTS `".TABLEPREFIX."fanfiction_online` (
30
+dbquery("CREATE TABLE IF NOT EXISTS `".TABLEPREFIX. "fanfiction_online` (
31 31
   `online_uid` int(11) NOT NULL default '0',
32
-  `online_ip` int(11) NOT NULL default '0',
32
+  `online_ip` VARBINARY(16) NOT NULL default '0',
33 33
   `online_timestamp` int(11) NOT NULL default '0'
34 34
 ) ENGINE=MyISAM;");
35
-?>
36 35
\ No newline at end of file
36
+?>
... ...
@@ -5,7 +5,7 @@ if(!defined("_CHARSET")) exit( );
5 5
 	if(file_exists(_BASEDIR."blocks/online/{$language}.php")) include(_BASEDIR."blocks/online/{$language}.php");
6 6
 	else include(_BASEDIR."blocks/online/en.php");
7 7
 
8
-	$where = "online_uid=" . (USERUID ? USERUID : "0 AND online_ip = INET_ATON('" . $_SERVER['REMOTE_ADDR'] . "')");
8
+	$where = "online_uid=" . (USERUID ? USERUID : "0 AND online_ip = INET6_ATON('" . $_SERVER['REMOTE_ADDR'] . "')");
9 9
  
10 10
 	$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_online WHERE $where");
11 11
  
... ...
@@ -24,7 +24,7 @@ if(!defined("_CHARSET")) exit( );
24 24
 		}
25 25
 		
26 26
 		dbquery("INSERT INTO " . TABLEPREFIX . "fanfiction_online(online_uid, online_ip, online_timestamp)
27
-		 VALUES('" . (USERUID ? USERUID : 0) . "', INET_ATON('" . $ip . "'), '" . time() . "')");
27
+		 VALUES('" . (USERUID ? USERUID : 0) . "', INET6_ATON('" . $ip . "'), '" . time() . "')");
28 28
 	} 
29 29
  
30 30
 	$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_online WHERE online_timestamp < ".(time()-60));
... ...
@@ -40,4 +40,4 @@ if(!defined("_CHARSET")) exit( );
40 40
 	$tpl->assignGlobal("onlinemembers", count($omlist) ? implode(", ", $omlist) : "");
41 41
 	$content = "<div id='who_online'><span class='label'>"._GUESTS.":</span> ".($guests ? $guests : 0)."<br />\n
42 42
 		<span class='label'>"._MEMBERS.":</span> ".(count($omlist) ? implode(", ", $omlist) : "")."</div>";
43
-?>
44 43
\ No newline at end of file
44
+?>
... ...
@@ -3,7 +3,7 @@
3 3
 <!-- START BLOCK : seriesblock -->
4 4
 <div class="listbox {oddeven}">
5 5
 <div class="title">{title} by {author}{score} [{reviews} - {numreviews}]</div>
6
-<div class="content"><span class="label">Summary: </span>{summary}<br />
6
+<div class="content listing"><span class="label">Summary: </span>{summary}<br />
7 7
 <span class="label">Parent Series:</span> {parentseries}<br />
8 8
 <span class="label">Categories:</span> {category}<br />
9 9
  <span class="label">Characters: </span>{characters}<br />
... ...
@@ -32,4 +32,4 @@
32 32
 {comment}
33 33
 <!-- END BLOCK : storyblock -->
34 34
 {pagelinks}
35
-<!-- END BLOCK : listings -->
36 35
\ No newline at end of file
36
+<!-- END BLOCK : listings -->
... ...
@@ -26,4 +26,4 @@
26 26
 <div class='toplink'>{back2top}</div>
27 27
 <!-- END BLOCK : chapterblock -->
28 28
 <div id="copyright">{copyright}</div>
29
-<div id="archivedat">{archivedat}</div>
30 29
\ No newline at end of file
30
+<div id="archivedat">{archivedat}</div>
... ...
@@ -32,6 +32,9 @@ $headerSent = false;
32 32
 // Defines the character set for your language/location
33 33
 define ("_CHARSET", "utf-8");
34 34
 
35
+//default values to avoid ajax issue when notice error are on
36
+$allowed_tags = '';
37
+
35 38
 // Prevent possible XSS attacks via $_GET.
36 39
 foreach ($_GET as $v) {
37 40
 	if(preg_match('@<script[^>]*?>.*?</script>@si', $v) ||
... ...
@@ -101,10 +104,10 @@ if(isset($globalskin)) $skin = $globalskin;
101 104
 
102 105
 if(isset($_GET['action'])) $action = strip_tags($_GET['action']);
103 106
 else $action = false;
104
-
107
+ 
105 108
 if(file_exists(_BASEDIR."languages/{$language}.php")) include (_BASEDIR."languages/{$language}.php");
106 109
 else include (_BASEDIR."languages/en.php");
107
-
110
+ 
108 111
 include_once(_BASEDIR."includes/queries.php");
109 112
 include_once(_BASEDIR."includes/corefunctions.php");
110 113
 
... ...
@@ -189,8 +192,7 @@ if(isset($_SESSION[SITEKEY."_viewed"])) $viewed = $_SESSION[SITEKEY."_viewed"];
189 192
 if(isset($_GET['ageconsent'])) $_SESSION[SITEKEY."_ageconsent"] = 1;
190 193
 if(isset($_GET['warning'])) $_SESSION[SITEKEY."_warned"][$_GET['warning']] = 1;
191 194
 
192
-if(file_exists("languages/{$language}.php")) require_once ("languages/{$language}.php");
193
-else require_once ("languages/en.php");
195
+
194 196
 if(is_dir(_BASEDIR."skins/$siteskin")) $skindir = _BASEDIR."skins/$siteskin";
195 197
 else if(is_dir(_BASEDIR."skins/".$settings['skin'])) $skindir = _BASEDIR."skins/".$defaultskin;
196 198
 else $skindir = _BASEDIR."default_tpls";
... ...
@@ -228,7 +230,7 @@ if($current == "viewuser" && isNumber($uid)) {
228 230
 	list($penname) = dbrow($author);
229 231
 	$titleinfo = "$sitename :: $penname";
230 232
 }
231
-echo _DOCTYPE."<html><head>";
233
+echo _DOCTYPE."<html lang={$language}><head>";
232 234
 echo "<meta charset='utf-8' />";
233 235
 if(!isset($titleinfo)) $titleinfo = "$sitename :: $slogan";
234 236
 if(isset($metaDesc)) echo "<meta name='description' content='$metaDesc'>";
... ...
@@ -240,10 +242,11 @@ if (file_exists(_BASEDIR."favicon.ico"))
240 242
 	echo "<link rel='icon' href='"._BASEDIR."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='"._BASEDIR."favicon.ico' type='image/xicon' />\n";
241 243
 }
242 244
  
243
-echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CHARSET."\">";
245
+//A document must not include both a “meta” element with an “http-equiv” attribute whose value is “content-type”, and a “meta” element with a “charset” attribute.
246
+//echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CHARSET."\">";
244 247
 if (!isset($_GET['action']) || $_GET['action'] != "printable")
245 248
 {
246
-	echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _BASEDIR . "includes/javascript.js\"></script>
249
+	echo "<script  src=\"" . _BASEDIR . "includes/javascript.js\"></script>
247 250
 <link rel=\"alternate\" type=\"application/rss+xml\" title=\"$sitename RSS Feed\" href=\"" . _BASEDIR . "rss.php\">";
248 251
 }
249 252
 
... ...
@@ -252,18 +255,18 @@ if (!isset($_GET['action']) || $_GET['action'] != "printable")
252 255
 	if (!empty($tinyMCE))
253 256
 	{
254 257
 		if($tinyMCE == 1) {
255
-			echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _BASEDIR . "tinymce/jscripts/tiny_mce/tiny_mce.js\"></script>";
258
+			echo "<script src=\"" . _BASEDIR . "tinymce/jscripts/tiny_mce/tiny_mce.js\"></script>";
256 259
 			include(_BASEDIR . "tinymce/init.php");
257 260
 		}
258 261
 		else {
259
-			echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _BASEDIR . "tinymce4/js/tinymce/tinymce.min.js\"></script>";
262
+			echo "<script src=\"" . _BASEDIR . "tinymce4/js/tinymce/tinymce.min.js\"></script>";
260 263
 			include(_BASEDIR . "tinymce4/init.php");		
261 264
 		}
262 265
 	}
263 266
 }
264 267
 if(isset($displayform) && $displayform == 1) {
265
-echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._BASEDIR."includes/xmlhttp.js\"></script>";
266
-echo "<script language=\"javascript\" type=\"text/javascript\">
268
+echo "<script src=\""._BASEDIR."includes/xmlhttp.js\"></script>";
269
+echo "<script>
267 270
 lang = new Array( );
268 271
 
269 272
 lang['Back2Cats'] = '"._BACK2CATS."';
... ...
@@ -301,9 +304,9 @@ if(file_exists("$skindir/extra_header.php")) include_once("$skindir/extra_header
301 304
 if(!$displaycolumns) $displaycolumns = 1;
302 305
 $colwidth = floor(100/$displaycolumns);
303 306
 if(!empty($_GET['action']) && $_GET['action'] == "printable") {
304
-	if(file_exists("$skindir/printable.css")) echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$skindir/printable.css\">";
305
-	else echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"default_tpls/printable.css\">";
306
-	echo "<script type='text/javascript'>
307
+	if(file_exists("$skindir/printable.css")) echo "<link rel=\"stylesheet\"  href=\"$skindir/printable.css\">";
308
+	else echo "<link rel=\"stylesheet\"  href=\"default_tpls/printable.css\">";
309
+	echo "<script>
307 310
 <!--
308 311
 if (window.print) {
309 312
     window.print() ;  
... ...
@@ -316,7 +319,7 @@ document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
316 319
 </script>";
317 320
 }
318 321
 else {
319
-echo "<style type=\"text/css\">
322
+echo "<style>
320 323
 #columncontainer { margin: 1em auto; width: auto; padding: 5%;}
321 324
 #browseblock, #memberblock { width: 100%; padding: 0; margin: 0; float: left; border: 0px solid transparent; }
322 325
 .column { float: left; width: ".($colwidth - 1)."%; }
... ...
@@ -28,6 +28,7 @@ if(!defined("_CHARSET")) exit( );
28 28
 if(!isset($catid)) $catid = array( );
29 29
 
30 30
 $output .= "<div style='width: 99.9%; float: left;'>\r\n
31
+<div style=\"text-align: center;\"><b>"._MULTIPLESELECT."</b></div>\r\n
31 32
 		<div style='width: 40%; float: left;'><label for='catoptions'>"._CATOPTIONS."</label> <br />
32 33
 		<select name='catoptions' id='catoptions' multiple='multiple' size='8' onchange='resetCats(\"catoptions\");' style='width: 100%;'>";
33 34
 $selectedCats = "";
... ...
@@ -51,4 +52,4 @@ $output .= "</select></div>
51 52
 			(!empty($selectedCats) ? $selectedCats : "")."</select></div>
52 53
 		</div>
53 54
 		<input type='hidden' name='catid' id='catid' value='".(isset($cats) ? implode(",", $cats) : "")."'>";
54
-?>
55 55
\ No newline at end of file
56
+?>
... ...
@@ -1,10 +1,14 @@
1 1
 <?php
2 2
 define("_BASEDIR", "../");
3
+define("_CHARSET", "utf-8");
4
+
3 5
 include("../config.php");
4 6
 include("../includes/dbfunctions.php");
7
+ 
8
+
5 9
 list($tableprefix, $lang) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
6 10
 define("TABLEPREFIX", $tableprefix);
7
-include(_BASEDIR."languages/$lang.php");
11
+ 
8 12
 header("Content-Type: text/javascript; charset="._CHARSET,true);
9 13
 include("../includes/queries.php");
10 14
 
... ...
@@ -15,7 +19,7 @@ $x = 0;
15 19
 $find = array ('"', chr(150), chr(147), chr(148), chr(146));
16 20
 $replace = array ('\"', "-", "\"", "\"", "'");
17 21
 while($category = dbassoc($cats)) {
18
-	echo "categories[$x] = new category(".$category['parentcatid'].", ".$category['catid'].", \"".urlencode(str_replace($find, $replace, stripslashes($category['category'])))."\", ".$category['locked'].", ".$category['displayorder'].");\r\n";
22
+	echo "categories[$x] = new category(".$category['parentcatid'].", ".$category['catid'].", \"". str_replace($find, $replace, stripslashes($category['category']))."\", ".$category['locked'].", ".$category['displayorder'].");\r\n";
19 23
 	$x++;
20 24
 }
21
-?>
22 25
\ No newline at end of file
26
+?>
... ...
@@ -21,7 +21,7 @@ $x = 0;
21 21
 $find = array ('"', chr(150), chr(147), chr(148), chr(146));
22 22
 $replace = array ('\"', "-", "\"", "\"", "'");
23 23
 while($char = dbassoc($characters)) {
24
-	echo "characters[$x] = new Array(".$char['charid'].", \"".urlencode(str_replace($find, $replace, stripslashes($char['charname'])))."\");\r\n";
24
+	echo "characters[$x] = new Array(".$char['charid'].", \"". str_replace($find, $replace, stripslashes($char['charname'])) ."\");\r\n";
25 25
 	$x++;
26 26
 }
27
-?>
28 27
\ No newline at end of file
28
+?>
... ...
@@ -42,7 +42,7 @@ function deleteStory($story) {
42 42
 	if($logging) {
43 43
 		$authorquery = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '".$story['uid']."' LIMIT 1");
44 44
 		list($penname) = dbrow($authorquery);
45
-		dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_DEL, USERPENNAME, USERUID, $story['title'], $sid, $penname, $story['uid']))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR'].
45
+		dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_DEL, USERPENNAME, USERUID, $story['title'], $sid, $penname, $story['uid']))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR'].
46 46
 		"'), 'DL', " . time() . ")");
47 47
 	}
48 48
 	dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$sid' LIMIT 1");
... ...
@@ -193,7 +193,7 @@ function deleteSeries($seriesid) {
193 193
 			eval($code['code_text']);
194 194
 	}
195 195
 	if($logging && isADMIN) {
196
-		if($uid != USERUID) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_DEL_SERIES, USERPENNAME, USERUID, $title))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'DL', " . time() . ")");
196
+		if($uid != USERUID) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_DEL_SERIES, USERPENNAME, USERUID, $title))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'DL', " . time() . ")");
197 197
 	}
198 198
 }
199
-?>
200 199
\ No newline at end of file
200
+?>
... ...
@@ -306,4 +306,3 @@ function displayTypeOpts() {
306 306
 	document.getElementById('opt_' + type).style.display = 'block';
307 307
 	if(window.tinyMCE) tinyMCE.execCommand('mceResetDesignMode'); 
308 308
 }
309
-
... ...
@@ -34,11 +34,12 @@ if(!defined("_CHARSET")) exit( );
34 34
 		$stories['coauthors'] = $array_coauthors;
35 35
 		unset($array_coauthors);
36 36
 	}
37
-	else if(empty($stories['coauthors'])) $stories['coauthors'] = array( );	
37
+	else  $stories['coauthors'] = array( );	
38
+ 
38 39
 	$tpl->assign("title"   , stripslashes(title_link($stories)) );
39 40
 	$tpl->assign("author"   , author_link($stories));
40 41
 	$tpl->assign("summary", stripslashes($stories['summary']) );
41
-	$tpl->assign("rating"   , !empty($ratingslist) ? $ratingslist[$stories['rid']]['name'] : "");
42
+    $tpl->assign("rating"   , !empty($ratingslist) &&  !empty($stories['rid'] && key_exists('name', $ratingslist) )  ? $ratingslist[$stories['rid']]['name'] : "");
42 43
 	$tpl->assign("score", ratingpics($stories['rating']) );
43 44
 	$tpl->assign("count", $stories['count'] ? $stories['count'] : "0");
44 45
 	$allclasslist = "";
... ...
@@ -128,4 +129,4 @@ if(!defined("_CHARSET")) exit( );
128 129
 	if(isADMIN && uLEVEL < 4) $tpl->assign("adminlinks", "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> ".$adminlinks."</div>");
129 130
 	else if(isMEMBER && (USERUID == $stories['uid'] || array_key_exists(USERUID, $stories['coauthors']))) $tpl->assign("adminlinks", "<div class=\"adminoptions\"><span class='label'>"._OPTIONS.":</span> ".$adminlinks."</div>");
130 131
 	$count++;
131
-?>
132 132
\ No newline at end of file
133
+?>
... ...
@@ -38,7 +38,7 @@ class file_upload {
38 38
 	var $message = array();
39 39
 	var $create_directory = true;
40 40
 	
41
-	function file_upload() {
41
+	function __construct() {
42 42
 		$this->language = "en"; // choice of en, nl, es
43 43
 		$this->rename_file = false;
44 44
 		$this->ext_string = "";
... ...
@@ -233,4 +233,4 @@ class file_upload {
233 233
 		return $error[$err_num];
234 234
 	}
235 235
 }
236
-?>
237 236
\ No newline at end of file
237
+?>
... ...
@@ -650,7 +650,7 @@ CREATE TABLE IF NOT EXISTS `" . $tableprefix . "fanfiction_authorprefs` (
650 650
   `log_id` int(11) NOT NULL auto_increment,
651 651
   `log_action` varchar(255) default NULL,
652 652
   `log_uid` int(11) NOT NULL,
653
-  `log_ip` int(11) UNSIGNED default NULL,
653
+  `log_ip` VARBINARY(16) NOT NULL,
654 654
   `log_timestamp` int(10) unsigned NOT NULL default '0',
655 655
   `log_type` varchar(2) NOT NULL,
656 656
   PRIMARY KEY  (`log_id`)
... ...
@@ -219,8 +219,8 @@ else if($action == "edit" || $action == "add") {
219 219
 					}
220 220
 				}
221 221
 				$reviewname = $reviewer."(".$_SERVER['REMOTE_ADDR'].")";
222
-				if($action == "add") dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REVIEW, $reviewname, truncate_text($review), $title))."', '0', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RE', " . time() . ")");
223
-				else dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_EDIT_REVIEW, USERPENNAME, USERUID, $title, $reviewid))."', '0', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RE', " . time() . ")");
222
+				if($action == "add") dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REVIEW, $reviewname, truncate_text($review), $title)). "', '0', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RE', " . time() . ")");
223
+				else dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_EDIT_REVIEW, USERPENNAME, USERUID, $title, $reviewid)). "', '0', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RE', " . time() . ")");
224 224
 			}
225 225
 		}
226 226
 	}
... ...
@@ -418,4 +418,4 @@ else {
418 418
 }
419 419
 $tpl->assign("output", $output);
420 420
 $tpl->printToScreen( );
421
-?>
422 421
\ No newline at end of file
422
+?>
... ...
@@ -265,7 +265,7 @@ else {
265 265
 		<div style=\"font-size: 8pt; text-align: right;\"><a href=\"search.php?searchtype=advanced\">"._ADVANCED."</a></div></div></form></div>";
266 266
 	}
267 267
 	else {
268
-		$output .= "<div id=\"pagetitle\">"._ADVANCED."</div><div>
268
+		$output .= "<div id=\"pagetitle\">"._ADVANCED. "</div><div>
269 269
 			<form method=\"POST\" name=\"form\" enctype=\"multipart/form-data\" action=\"search.php?searchtype=advanced\">
270 270
 			<div class=\"tblborder\" style=\"width: 90%; margin: 0 auto; padding: 10px;\">";
271 271
 		if($multiplecats) {
... ...
@@ -292,7 +292,6 @@ else {
292 292
 			$output .= "</select></div>";
293 293
 		}
294 294
 		$output .= "<div style=\"clear: both;\">&nbsp;</div>";
295
-		$output .= " <div style=\"text-align: center;\">"._MULTIPLESELECT."</div>";
296 295
 		$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_classtypes ORDER BY classtype_name");
297 296
 		while($type = dbassoc($result)) {
298 297
 			$result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_classes WHERE class_type = '".$type['classtype_id']."' ORDER BY class_name");
... ...
@@ -336,4 +335,4 @@ $output .= "<div id='submitdiv'><input name=\"submit\" id=\"submit\" value=\""._
336 335
 $tpl->assign("output", $output);
337 336
 $tpl->printToScreen();
338 337
 dbclose( );
339
-?>
340 338
\ No newline at end of file
339
+?>
... ...
@@ -121,7 +121,7 @@ if($add == "series" || ($action == "add" && !$add) || $action == "edit") {
121 121
 				if($logging && $admin) {
122 122
 					$seriesinfo = dbquery("SELECT title, uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$seriesid'");
123 123
 					list($title, $uid) = dbrow($seriesinfo);
124
-					if($uid != USERUID) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_SERIES, USERPENNAME, USERUID, $title, $seriesid))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
124
+					if($uid != USERUID) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_SERIES, USERPENNAME, USERUID, $title, $seriesid))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
125 125
 				}
126 126
 				$output = write_message(_ACTIONSUCCESSFUL."<br />"._BACK2ACCT);
127 127
 			}
... ...
@@ -375,4 +375,4 @@ if($showlist) {
375 375
 }
376 376
 $tpl->assign("output", $output);
377 377
 $tpl->printToScreen( );
378
-?>
379 378
\ No newline at end of file
379
+?>
... ...
@@ -281,6 +281,7 @@ function newstory( ) {
281 281
 			}
282 282
 			$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'addstory'");
283 283
 			while($code = dbassoc($codequery)) {
284
+				
284 285
 				eval($code['code_text']);
285 286
 			}
286 287
 		}
... ...
@@ -412,7 +413,7 @@ function newstory( ) {
412 413
 
413 414
 	$submit = isset($_POST['submit']) ? $_POST['submit'] : false;
414 415
 	if(!$submit) $submit = _PREVIEW;
415
-	$output .= "<div class=\"tblborder\" style=\"width: 500px; padding: 10px; margin: 1em auto;\">
416
+	$output .= "<div class=\"tblborder\" style=\" padding: 10px; margin: 1em auto;\">
416 417
 	<form METHOD=\"POST\" name=\"form\" enctype=\"multipart/form-data\" action='stories.php?action=$action".($newchapter ? "&amp;sid=$sid&amp;inorder=$inorder" : "").($admin == 1 ? "&amp;admin=1&amp;uid=$uid" : "")."'>";
417 418
 	if(!$newchapter) $output .= storyform($stories, $submit);
418 419
 	$output .= chapterform($inorder, $notes, $endnotes, $storytext, $chaptertitle, $uid);
... ...
@@ -558,7 +559,7 @@ function editchapter( $chapid ) {
558 559
 			if($admin && $logging && USERUID != $uid) {
559 560
 				$storyinfo = dbquery("SELECT story.title, story.sid, chapter.uid, chapter.inorder, "._PENNAMEFIELD." as penname FROM ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters as chapter, "._AUTHORTABLE." WHERE "._UIDFIELD." = chapter.uid AND story.sid = chapter.sid AND chapter.chapid = $chapid");
560 561
 				list($title, $sid, $chapuid, $inorder, $chappenname) = dbrow($storyinfo);
561
-				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_CHAPTER, USERPENNAME, USERUID, $title, $sid, $chappenname, $chapuid, $inorder))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
562
+				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_CHAPTER, USERPENNAME, USERUID, $title, $sid, $chappenname, $chapuid, $inorder))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
562 563
 			}
563 564
 			unset($_POST['submit']);
564 565
 			$output = write_message(_STORYUPDATED).editstory($sid);
... ...
@@ -568,7 +569,7 @@ function editchapter( $chapid ) {
568 569
 			exit( );
569 570
 		}
570 571
 	}
571
-	$output .= "<div class=\"tblborder\" style=\"width: 550px; margin: 0 auto; padding: 5px;\">
572
+	$output .= "<div class=\"tblborder\" style=\"margin: 0 auto; padding: 5px;\">
572 573
 		<form METHOD=\"POST\"  enctype=\"multipart/form-data\" name=\"form\" action=\"stories.php?action=editchapter&amp;chapid=$chapid".($admin ? "&amp;admin=1" : "")."\">";
573 574
 	if(!isset($_POST['submit']) || $_POST['submit'] != _PREVIEW) {
574 575
 		$storyquery = dbquery("SELECT title, inorder, notes, endnotes, uid, storytext, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE chapid = '$chapid' LIMIT 1");
... ...
@@ -698,7 +699,7 @@ function editstory($sid) {
698 699
 						list($oldpenname) = dbrow($authorquery);
699 700
 						$author2query = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
700 701
 						list($newpenname) = dbrow($author2query);
701
-						dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_AUTHOR, USERPENNAME, USERUID, $title, $sid, $newpenname, $uid, $oldpenname, $olduid))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
702
+						dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_AUTHOR, USERPENNAME, USERUID, $title, $sid, $newpenname, $uid, $oldpenname, $olduid))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
702 703
 					}
703 704
 				}
704 705
 
... ...
@@ -812,14 +813,16 @@ function editstory($sid) {
812 813
 				}		
813 814
 			}
814 815
 			$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'editstory'");
816
+
815 817
 			while($code = dbassoc($codequery)) {
818
+			 
816 819
 				eval($code['code_text']);
817 820
 			}
818 821
 			if($logging && $admin) {
819 822
 				if(USERUID != $uid) { // If you're editing your own story, don't log it.
820 823
 					$authorquery = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
821 824
 					list($penname) = dbrow($authorquery);
822
-					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT, USERPENNAME, USERUID, $title, $sid, $penname, $uid))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
825
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT, USERPENNAME, USERUID, $title, $sid, $penname, $uid))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED', " . time() . ")");
823 826
 				}
824 827
 			}
825 828
 			$output .= write_message(_STORYUPDATED."  ".($admin ? _BACK2ADMIN : _BACK2ACCT));
... ...
@@ -831,7 +834,7 @@ function editstory($sid) {
831 834
 	}
832 835
 	$query = dbquery("SELECT DATE_FORMAT(FROM_UNIXTIME(date), '$dateformat') as date, wordcount, uid FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$sid' LIMIT 1");
833 836
 	list($published, $wordcount, $storyuid) = dbrow($query);
834
-	$formbegin = "<div class=\"tblborder\" style=\"margin: 10px auto; width: 550px; padding: 10px;\">
837
+	$formbegin = "<div class=\"tblborder\" style=\"margin: 10px auto; padding: 10px;\">
835 838
 		<form METHOD=\"POST\" name=\"form\" action=\"stories.php?action=editstory".($admin ? "&amp;admin=1" : "")."&amp;sid=$sid\">";
836 839
 
837 840
 	if(isset($_POST['submit']) && $_POST['submit'] != _PREVIEW) {
... ...
@@ -875,7 +878,7 @@ function editstory($sid) {
875 878
 	$chapquery = dbquery("SELECT chapid, title, inorder, rating, reviews, validated, uid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '$sid' ORDER BY inorder");
876 879
 	$chapters = dbnumrows($chapquery);
877 880
 	$output .= "<p><input type=\"submit\" class=\"button\" value=\"$submit\" name=\"submit\">&nbsp; <input type=\"submit\" class=\"button\" value=\""._ADDSTORY."\" name=\"submit\"></p></form></div>";
878
-	$output .= "<br><table class=\"tblborder\" style=\"margin: 0 auto; width: 500px;\"><tr><th>"._CHAPTER."</th>".($chapters > 1 ? "<th>"._MOVE."</th>" : "")."<th>"._OPTIONS."</th></tr>";
881
+	$output .= "<br><table class=\"tblborder\" style=\"margin: 0 auto;  \"><tr><th>"._CHAPTER."</th>".($chapters > 1 ? "<th>"._MOVE."</th>" : "")."<th>"._OPTIONS."</th></tr>";
879 882
 			while($chapter = dbassoc($chapquery)) {
880 883
 				$output .="<tr><td class=\"tblborder\"><a href=\"viewstory.php?sid=$sid&amp;chapter=".$chapter['inorder']."\">".$chapter['title']."</a></td>";
881 884
 				if($chapters > 1) $output .= "<td align=\"center\" class=\"tblborder\">".($chapter['inorder'] == 1 ? "" : "<a href=\"stories.php?action=viewstories&amp;go=up&amp;sid=$sid&amp;chapid=".$chapter['chapid']."&amp;inorder=".$chapter['inorder']."\">$up</a>").
... ...
@@ -931,7 +934,7 @@ function delete( ) {
931 934
 			if($logging && $admin) {
932 935
 				$authorquery = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
933 936
 				list($penname) = dbrow($authorquery);
934
-				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_DEL_CHAPTER, USERPENNAME, USERUID, $story['title'], $sid, $penname, $uid, $inorder))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'DL', " . time() . ")");
937
+				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_ADMIN_DEL_CHAPTER, USERPENNAME, USERUID, $story['title'], $sid, $penname, $uid, $inorder))."', '".USERUID. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'DL', " . time() . ")");
935 938
 			}
936 939
 			return "<center>"._ACTIONSUCCESSFUL."</center>".editstory( $sid );
937 940
 		}
... ...
@@ -982,4 +985,4 @@ switch($action) {
982 985
 	$tpl->assign( "output", $output );
983 986
 	$tpl->printToScreen();
984 987
 	dbclose( );
985
-?>
986 988
\ No newline at end of file
989
+?>
... ...
@@ -1,5 +1,12 @@
1 1
 <?php
2
-
2
+$image_list_path = STORIESPATH . "/" . USERUID . "/images/imagelist.js";
3
+$image_list_exists = file_exists($image_list_path); 
4
+ 
5
+if (USERUID && $image_list_exists)
6
+{
7
+echo "
8
+<script src='".STORIESPATH . "/" . USERUID . "/images/imagelist.js"."'></script>";
9
+} 
3 10
 echo "
4 11
 	<script language=\"javascript\" type=\"text/javascript\"><!--";
5 12
 	$tinylanguage = $language;
... ...
@@ -19,30 +26,28 @@ echo "
19 26
   		menubar: false,
20 27
 		language: '$tinylanguage',
21 28
   		theme: 'modern',
29
+		invalid_styles: 'color,font-size,margin,line-height,font-family,margin-top,margin-bottom',
30
+		plugins: 'wordcount emoticons fullscreen anchor code hr image link paste ',
22 31
 		skin: 'lightgray',
23 32
 		min_height: 200,
24
-		plugins: [
25
-		    'autolink lists link image charmap paste preview hr anchor pagebreak',
26
-		    'searchreplace wordcount visualblocks visualchars code fullscreen',
27
-		    'insertdatetime media nonbreaking save table contextmenu directionality',
28
-		    'emoticons template textcolor colorpicker textpattern imagetools toc textcolor table'
29
-		],
33
+	    browser_spellcheck: true,
34
+		relative_urls: false,
35
+		remove_script_host: false,
36
+    	convert_urls: true,
30 37
 		paste_word_valid_elements: 'b,strong,i,em,h1,h2,u,p,ol,ul,li,a[href],span,color,font-size,font-color,font-family,mark,table,tr,td',
31
-		paste_retain_style_properties : 'all',
32
-		paste_strip_class_attributes: 'none',
33
-		toolbar1: 'undo redo | insert styleselect | bold italic underline strikethrough | link image | alignleft aligncenter alignright alignjustify code pastetext',
34
-		toolbar2: 'preview | bullist numlist | forecolor backcolor emoticons | fontselect |  fontsizeselect wordcount', 
35
-		image_advtab: true,
36
-		templates: [
37
-		    { title: 'Test template 1', content: 'Test 1' },
38
-		    { title: 'Test template 2', content: 'Test 2' }
39
-		],
40
-		content_css: [
41
-		    '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
42
-		    '//www.tinymce.com/css/codepen.min.css'
43
-		],";
44
-		if(USERUID) 
45
-			echo "		external_image_list_url : '".STORIESPATH."/".USERUID."/images/imagelist.js',";
38
+		toolbar1: 'bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist | undo redo | fullscreen code | link unlink | emoticons image anchor hr ',	image_advtab: true,
39
+     	paste_word_valid_elements: 'b,strong,i,em,p,span,u,strike,br',
40
+    	paste_retain_style_properties: 'text-decoration,text-align',
41
+	    menu: {
42
+			file: { title: 'File', items: 'newdocument' },
43
+			edit: { title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall' },
44
+			insert: { title: 'Insert', items: 'link media | template hr' },
45
+			view: { title: 'View', items: 'visualaid' },
46
+			table: { title: 'Table', items: 'inserttable tableprops deletetable | cell row column' },
47
+			tools: { title: 'Tools', items: '' }
48
+    	},";
49
+		if (USERUID && $image_list_exists)
50
+			echo "	image_list: tinyMCE4ImageList ,";
46 51
 		echo "
47 52
 		theme_modern_resizing: true,".($current == "adminarea" ? "\n\t\tentity_encoding: 'raw'" : "\n\t\tinvalid_elements: 'script,object,applet,iframe'")."
48 53
    });
... ...
@@ -1 +1,298 @@
1
-tinymce.PluginManager.add("image",function(e){function t(e,t){function n(e,n){r.parentNode&&r.parentNode.removeChild(r),t({width:e,height:n})}var r=document.createElement("img");r.onload=function(){n(Math.max(r.width,r.clientWidth),Math.max(r.height,r.clientHeight))},r.onerror=function(){n()};var i=r.style;i.visibility="hidden",i.position="fixed",i.bottom=i.left=0,i.width=i.height="auto",document.body.appendChild(r),r.src=e}function n(e,t,n){function r(e,n){return n=n||[],tinymce.each(e,function(e){var i={text:e.text||e.title};e.menu?i.menu=r(e.menu):(i.value=e.value,t(i)),n.push(i)}),n}return r(e,n||[])}function r(t){return function(){var n=e.settings.image_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(e){t(tinymce.util.JSON.parse(e))}}):"function"==typeof n?n(t):t(n)}}function i(r){function i(){var e,t,n,r;e=f.find("#width")[0],t=f.find("#height")[0],e&&t&&(n=e.value(),r=t.value(),f.find("#constrain")[0].checked()&&h&&g&&n&&r&&(h!=n?(r=Math.round(n/h*r),isNaN(r)||t.value(r)):(n=Math.round(r/g*n),isNaN(n)||e.value(n))),h=n,g=r)}function o(){function t(t){function n(){t.onload=t.onerror=null,e.selection&&(e.selection.select(t),e.nodeChanged())}t.onload=function(){y.width||y.height||!x||C.setAttribs(t,{width:t.clientWidth,height:t.clientHeight}),n()},t.onerror=n}var n,r;u(),i(),y=tinymce.extend(y,f.toJSON()),y.alt||(y.alt=""),y.title||(y.title=""),""===y.width&&(y.width=null),""===y.height&&(y.height=null),y.style||(y.style=null),y={src:y.src,alt:y.alt,title:y.title,width:y.width,height:y.height,style:y.style,caption:y.caption,"class":y["class"]},e.undoManager.transact(function(){function i(t){return e.schema.getTextBlockElements()[t.nodeName]}if(!y.src)return void(p&&(C.remove(p),e.focus(),e.nodeChanged()));if(""===y.title&&(y.title=null),p?C.setAttribs(p,y):(y.id="__mcenew",e.focus(),e.selection.setContent(C.createHTML("img",y)),p=C.get("__mcenew"),C.setAttrib(p,"id",null)),e.editorUpload.uploadImagesAuto(),y.caption===!1&&C.is(p.parentNode,"figure.image")&&(n=p.parentNode,C.insertAfter(p,n),C.remove(n)),y.caption!==!0)t(p);else if(!C.is(p.parentNode,"figure.image")){r=p,p=p.cloneNode(!0),n=C.create("figure",{"class":"image"}),n.appendChild(p),n.appendChild(C.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable=!1;var o=C.getParent(r,i);o?C.split(o,r,n):C.replace(n,r),e.selection.select(n)}})}function a(e){return e&&(e=e.replace(/px$/,"")),e}function s(n){var r,i,o,a=n.meta||{};v&&v.value(e.convertURL(this.value(),"src")),tinymce.each(a,function(e,t){f.find("#"+t).value(e)}),a.width||a.height||(r=e.convertURL(this.value(),"src"),i=e.settings.image_prepend_url,o=new RegExp("^(?:[a-z]+:)?//","i"),i&&!o.test(r)&&r.substring(0,i.length)!==i&&(r=i+r),this.value(r),t(e.documentBaseURI.toAbsolute(this.value()),function(e){e.width&&e.height&&x&&(h=e.width,g=e.height,f.find("#width").value(h),f.find("#height").value(g))}))}function l(e){e.meta=f.toJSON()}function c(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e}function u(){function t(e){return e.length>0&&/^[0-9]+$/.test(e)&&(e+="px"),e}if(e.settings.image_advtab){var n=f.toJSON(),r=C.parseStyle(n.style);r=c(r),n.vspace&&(r["margin-top"]=r["margin-bottom"]=t(n.vspace)),n.hspace&&(r["margin-left"]=r["margin-right"]=t(n.hspace)),n.border&&(r["border-width"]=t(n.border)),f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(r))))}}function d(){if(e.settings.image_advtab){var t=f.toJSON(),n=C.parseStyle(t.style);f.find("#vspace").value(""),f.find("#hspace").value(""),n=c(n),(n["margin-top"]&&n["margin-bottom"]||n["margin-right"]&&n["margin-left"])&&(n["margin-top"]===n["margin-bottom"]?f.find("#vspace").value(a(n["margin-top"])):f.find("#vspace").value(""),n["margin-right"]===n["margin-left"]?f.find("#hspace").value(a(n["margin-right"])):f.find("#hspace").value("")),n["border-width"]&&f.find("#border").value(a(n["border-width"])),f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(n))))}}var f,p,m,h,g,v,b,y={},C=e.dom,x=e.settings.image_dimensions!==!1;p=e.selection.getNode(),m=C.getParent(p,"figure.image"),m&&(p=C.select("img",m)[0]),p&&("IMG"!=p.nodeName||p.getAttribute("data-mce-object")||p.getAttribute("data-mce-placeholder"))&&(p=null),p&&(h=C.getAttrib(p,"width"),g=C.getAttrib(p,"height"),y={src:C.getAttrib(p,"src"),alt:C.getAttrib(p,"alt"),title:C.getAttrib(p,"title"),"class":C.getAttrib(p,"class"),width:h,height:g,caption:!!m}),r&&(v={type:"listbox",label:"Image list",values:n(r,function(t){t.value=e.convertURL(t.value||t.url,"src")},[{text:"None",value:""}]),value:y.src&&e.convertURL(y.src,"src"),onselect:function(e){var t=f.find("#alt");(!t.value()||e.lastControl&&t.value()==e.lastControl.text())&&t.value(e.control.text()),f.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){v=this}}),e.settings.image_class_list&&(b={name:"class",type:"listbox",label:"Class",values:n(e.settings.image_class_list,function(t){t.value&&(t.textStyle=function(){return e.formatter.getCssText({inline:"img",classes:[t.value]})})})});var w=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:s,onbeforecall:l},v];e.settings.image_description!==!1&&w.push({name:"alt",type:"textbox",label:"Image description"}),e.settings.image_title&&w.push({name:"title",type:"textbox",label:"Image Title"}),x&&w.push({type:"container",label:"Dimensions",layout:"flex",direction:"row",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:3,onchange:i,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:3,onchange:i,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}),w.push(b),e.settings.image_caption&&tinymce.Env.ceFalse&&w.push({name:"caption",type:"checkbox",label:"Caption"}),e.settings.image_advtab?(p&&(p.style.marginLeft&&p.style.marginRight&&p.style.marginLeft===p.style.marginRight&&(y.hspace=a(p.style.marginLeft)),p.style.marginTop&&p.style.marginBottom&&p.style.marginTop===p.style.marginBottom&&(y.vspace=a(p.style.marginTop)),p.style.borderWidth&&(y.border=a(p.style.borderWidth)),y.style=e.dom.serializeStyle(e.dom.parseStyle(e.dom.getAttrib(p,"style")))),f=e.windowManager.open({title:"Insert/edit image",data:y,bodyType:"tabpanel",body:[{title:"General",type:"form",items:w},{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:d},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,alignH:["left","right"],defaults:{type:"textbox",maxWidth:50,onchange:u},items:[{label:"Vertical space",name:"vspace"},{label:"Horizontal space",name:"hspace"},{label:"Border",name:"border"}]}]}],onSubmit:o})):f=e.windowManager.open({title:"Insert/edit image",data:y,body:w,onSubmit:o})}e.on("preInit",function(){function t(e){var t=e.attr("class");return t&&/\bimage\b/.test(t)}function n(e){return function(n){function r(t){t.attr("contenteditable",e?"true":null)}for(var i,o=n.length;o--;)i=n[o],t(i)&&(i.attr("contenteditable",e?"false":null),tinymce.each(i.getAll("figcaption"),r))}}e.parser.addNodeFilter("figure",n(!0)),e.serializer.addNodeFilter("figure",n(!1))}),e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:r(i),stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:r(i),context:"insert",prependToContext:!0}),e.addCommand("mceImage",r(i))});
2 1
\ No newline at end of file
2
+tinymce.PluginManager.add("image", function (e) {
3
+    function t(e, t) {
4
+        function n(e, n) {
5
+            r.parentNode && r.parentNode.removeChild(r), t({ width: e, height: n });
6
+        }
7
+        var r = document.createElement("img");
8
+        (r.onload = function () {
9
+            n(Math.max(r.width, r.clientWidth), Math.max(r.height, r.clientHeight));
10
+        }),
11
+            (r.onerror = function () {
12
+                n();
13
+            });
14
+        var i = r.style;
15
+        (i.visibility = "hidden"), (i.position = "fixed"), (i.bottom = i.left = 0), (i.width = i.height = "auto"), document.body.appendChild(r), (r.src = e);
16
+    }
17
+    function n(e, t, n) {
18
+        function r(e, n) {
19
+            return (
20
+                (n = n || []),
21
+                tinymce.each(e, function (e) {
22
+                    var i = { text: e.text || e.title };
23
+                    e.menu ? (i.menu = r(e.menu)) : ((i.value = e.value), t(i)), n.push(i);
24
+                }),
25
+                n
26
+            );
27
+        }
28
+        return r(e, n || []);
29
+    }
30
+    function r(t) {
31
+        return function () {
32
+            var n = e.settings.image_list;
33
+            "string" == typeof n
34
+                ? tinymce.util.XHR.send({
35
+                    url: n,
36
+                    success: function (e) {
37
+                        t(tinymce.util.JSON.parse(e));
38
+                    },
39
+                })
40
+                : "function" == typeof n
41
+                    ? n(t)
42
+                    : t(n);
43
+        };
44
+    }
45
+    function i(r) {
46
+        function i() {
47
+            var e, t, n, r;
48
+            (e = f.find("#width")[0]),
49
+                (t = f.find("#height")[0]),
50
+                e &&
51
+                t &&
52
+                ((n = e.value()),
53
+                    (r = t.value()),
54
+                    f.find("#constrain")[0].checked() && h && g && n && r && (h != n ? ((r = Math.round((n / h) * r)), isNaN(r) || t.value(r)) : ((n = Math.round((r / g) * n)), isNaN(n) || e.value(n))),
55
+                    (h = n),
56
+                    (g = r));
57
+        }
58
+        function o() {
59
+            function t(t) {
60
+                function n() {
61
+                    (t.onload = t.onerror = null), e.selection && (e.selection.select(t), e.nodeChanged());
62
+                }
63
+                (t.onload = function () {
64
+                    y.width || y.height || !x || C.setAttribs(t, { width: t.clientWidth, height: t.clientHeight }), n();
65
+                }),
66
+                    (t.onerror = n);
67
+            }
68
+            var n, r;
69
+            u(),
70
+                i(),
71
+                (y = tinymce.extend(y, f.toJSON())),
72
+                y.alt || (y.alt = ""),
73
+                y.title || (y.title = ""),
74
+                "" === y.width && (y.width = null),
75
+                "" === y.height && (y.height = null),
76
+                y.style || (y.style = null),
77
+                (y = { src: y.src, alt: y.alt, title: y.title, width: y.width, height: y.height, style: y.style, caption: y.caption, class: y["class"] }),
78
+                e.undoManager.transact(function () {
79
+                    function i(t) {
80
+                        return e.schema.getTextBlockElements()[t.nodeName];
81
+                    }
82
+                    if (!y.src) return void (p && (C.remove(p), e.focus(), e.nodeChanged()));
83
+                    if (
84
+                        ("" === y.title && (y.title = null),
85
+                            p ? C.setAttribs(p, y) : ((y.id = "__mcenew"), e.focus(), e.selection.setContent(C.createHTML("img", y)), (p = C.get("__mcenew")), C.setAttrib(p, "id", null)),
86
+                            e.editorUpload.uploadImagesAuto(),
87
+                            y.caption === !1 && C.is(p.parentNode, "figure.image") && ((n = p.parentNode), C.insertAfter(p, n), C.remove(n)),
88
+                            y.caption !== !0)
89
+                    )
90
+                        t(p);
91
+                    else if (!C.is(p.parentNode, "figure.image")) {
92
+                        (r = p), (p = p.cloneNode(!0)), (n = C.create("figure", { class: "image" })), n.appendChild(p), n.appendChild(C.create("figcaption", { contentEditable: !0 }, "Caption")), (n.contentEditable = !1);
93
+                        var o = C.getParent(r, i);
94
+                        o ? C.split(o, r, n) : C.replace(n, r), e.selection.select(n);
95
+                    }
96
+                });
97
+        }
98
+        function a(e) {
99
+            return e && (e = e.replace(/px$/, "")), e;
100
+        }
101
+        function s(n) {
102
+            var r,
103
+                i,
104
+                o,
105
+                a = n.meta || {};
106
+            v && v.value(e.convertURL(this.value(), "src")),
107
+                tinymce.each(a, function (e, t) {
108
+                    f.find("#" + t).value(e);
109
+                }),
110
+                a.width ||
111
+                a.height ||
112
+                ((r = e.convertURL(this.value(), "src")),
113
+                    (i = e.settings.image_prepend_url),
114
+                    (o = new RegExp("^(?:[a-z]+:)?//", "i")),
115
+                    i && !o.test(r) && r.substring(0, i.length) !== i && (r = i + r),
116
+                    this.value(r),
117
+                    t(e.documentBaseURI.toAbsolute(this.value()), function (e) {
118
+                        e.width && e.height && x && ((h = e.width), (g = e.height), f.find("#width").value(h), f.find("#height").value(g));
119
+                    }));
120
+        }
121
+        function l(e) {
122
+            e.meta = f.toJSON();
123
+        }
124
+        function c(e) {
125
+            if (e.margin) {
126
+                var t = e.margin.split(" ");
127
+                switch (t.length) {
128
+                    case 1:
129
+                        (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[0]), (e["margin-bottom"] = e["margin-bottom"] || t[0]), (e["margin-left"] = e["margin-left"] || t[0]);
130
+                        break;
131
+                    case 2:
132
+                        (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[1]), (e["margin-bottom"] = e["margin-bottom"] || t[0]), (e["margin-left"] = e["margin-left"] || t[1]);
133
+                        break;
134
+                    case 3:
135
+                        (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[1]), (e["margin-bottom"] = e["margin-bottom"] || t[2]), (e["margin-left"] = e["margin-left"] || t[1]);
136
+                        break;
137
+                    case 4:
138
+                        (e["margin-top"] = e["margin-top"] || t[0]), (e["margin-right"] = e["margin-right"] || t[1]), (e["margin-bottom"] = e["margin-bottom"] || t[2]), (e["margin-left"] = e["margin-left"] || t[3]);
139
+                }
140
+                delete e.margin;
141
+            }
142
+            return e;
143
+        }
144
+        function u() {
145
+            function t(e) {
146
+                return e.length > 0 && /^[0-9]+$/.test(e) && (e += "px"), e;
147
+            }
148
+            if (e.settings.image_advtab) {
149
+                var n = f.toJSON(),
150
+                    r = C.parseStyle(n.style);
151
+                (r = c(r)),
152
+                    n.vspace && (r["margin-top"] = r["margin-bottom"] = t(n.vspace)),
153
+                    n.hspace && (r["margin-left"] = r["margin-right"] = t(n.hspace)),
154
+                    n.border && (r["border-width"] = t(n.border)),
155
+                    f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(r))));
156
+            }
157
+        }
158
+        function d() {
159
+            if (e.settings.image_advtab) {
160
+                var t = f.toJSON(),
161
+                    n = C.parseStyle(t.style);
162
+                f.find("#vspace").value(""),
163
+                    f.find("#hspace").value(""),
164
+                    (n = c(n)),
165
+                    ((n["margin-top"] && n["margin-bottom"]) || (n["margin-right"] && n["margin-left"])) &&
166
+                    (n["margin-top"] === n["margin-bottom"] ? f.find("#vspace").value(a(n["margin-top"])) : f.find("#vspace").value(""),
167
+                        n["margin-right"] === n["margin-left"] ? f.find("#hspace").value(a(n["margin-right"])) : f.find("#hspace").value("")),
168
+                    n["border-width"] && f.find("#border").value(a(n["border-width"])),
169
+                    f.find("#style").value(C.serializeStyle(C.parseStyle(C.serializeStyle(n))));
170
+            }
171
+        }
172
+        var f,
173
+            p,
174
+            m,
175
+            h,
176
+            g,
177
+            v,
178
+            b,
179
+            y = {},
180
+            C = e.dom,
181
+            x = e.settings.image_dimensions !== !1;
182
+        (p = e.selection.getNode()),
183
+            (m = C.getParent(p, "figure.image")),
184
+            m && (p = C.select("img", m)[0]),
185
+            p && ("IMG" != p.nodeName || p.getAttribute("data-mce-object") || p.getAttribute("data-mce-placeholder")) && (p = null),
186
+            p &&
187
+            ((h = C.getAttrib(p, "width")),
188
+                (g = C.getAttrib(p, "height")),
189
+                (y = { src: C.getAttrib(p, "src"), alt: C.getAttrib(p, "alt"), title: C.getAttrib(p, "title"), class: C.getAttrib(p, "class"), width: h, height: g, caption: !!m })),
190
+            r &&
191
+            (v = {
192
+                type: "listbox",
193
+                label: "Image list",
194
+                values: n(
195
+                    r,
196
+                    function (t) {
197
+                        t.value = e.convertURL(t.value || t.url, "src");
198
+                    },
199
+                    [{ text: "None", value: "" }]
200
+                ),
201
+                value: y.src && e.convertURL(y.src, "src"),
202
+                onselect: function (e) {
203
+                    var t = f.find("#alt");
204
+                    (!t.value() || (e.lastControl && t.value() == e.lastControl.text())) && t.value(e.control.text()), f.find("#src").value(e.control.value()).fire("change");
205
+                },
206
+                onPostRender: function () {
207
+                    v = this;
208
+                },
209
+            }),
210
+            e.settings.image_class_list &&
211
+            (b = {
212
+                name: "class",
213
+                type: "listbox",
214
+                label: "Class",
215
+                values: n(e.settings.image_class_list, function (t) {
216
+                    t.value &&
217
+                        (t.textStyle = function () {
218
+                            return e.formatter.getCssText({ inline: "img", classes: [t.value] });
219
+                        });
220
+                }),
221
+            });
222
+        var w = [{ name: "src", type: "filepicker", filetype: "image", label: "Source", autofocus: !0, onchange: s, onbeforecall: l }, v];
223
+        e.settings.image_description !== !1 && w.push({ name: "alt", type: "textbox", label: "Image description" }),
224
+            e.settings.image_title && w.push({ name: "title", type: "textbox", label: "Image Title" }),
225
+            x &&
226
+            w.push({
227
+                type: "container",
228
+                label: "Dimensions",
229
+                layout: "flex",
230
+                direction: "row",
231
+                align: "center",
232
+                spacing: 5,
233
+                items: [
234
+                    { name: "width", type: "textbox", maxLength: 5, size: 3, onchange: i, ariaLabel: "Width" },
235
+                    { type: "label", text: "x" },
236
+                    { name: "height", type: "textbox", maxLength: 5, size: 3, onchange: i, ariaLabel: "Height" },
237
+                    { name: "constrain", type: "checkbox", checked: !0, text: "Constrain proportions" },
238
+                ],
239
+            }),
240
+            w.push(b),
241
+            e.settings.image_caption && tinymce.Env.ceFalse && w.push({ name: "caption", type: "checkbox", label: "Caption" }),
242
+            e.settings.image_advtab
243
+                ? (p &&
244
+                    (p.style.marginLeft && p.style.marginRight && p.style.marginLeft === p.style.marginRight && (y.hspace = a(p.style.marginLeft)),
245
+                        p.style.marginTop && p.style.marginBottom && p.style.marginTop === p.style.marginBottom && (y.vspace = a(p.style.marginTop)),
246
+                        p.style.borderWidth && (y.border = a(p.style.borderWidth)),
247
+                        (y.style = e.dom.serializeStyle(e.dom.parseStyle(e.dom.getAttrib(p, "style"))))),
248
+                    (f = e.windowManager.open({
249
+                        title: "Insert/edit image",
250
+                        data: y,
251
+                        bodyType: "tabpanel",
252
+                        body: [
253
+                            { title: "General", type: "form", items: w },
254
+                            {
255
+                                title: "Advanced",
256
+                                type: "form",
257
+                                pack: "start",
258
+                                items: [
259
+                                    { label: "Style", name: "style", type: "textbox", onchange: d },
260
+                                    {
261
+                                        type: "form",
262
+                                        layout: "grid",
263
+                                        packV: "start",
264
+                                        columns: 2,
265
+                                        padding: 0,
266
+                                        alignH: ["left", "right"],
267
+                                        defaults: { type: "textbox", maxWidth: 50, onchange: u },
268
+                                        items: [
269
+                                            { label: "Vertical space", name: "vspace" },
270
+                                            { label: "Horizontal space", name: "hspace" },
271
+                                            { label: "Border", name: "border" },
272
+                                        ],
273
+                                    },
274
+                                ],
275
+                            },
276
+                        ],
277
+                        onSubmit: o,
278
+                    })))
279
+                : (f = e.windowManager.open({ title: "Insert/edit image", data: y, body: w, onSubmit: o }));
280
+    }
281
+    e.on("preInit", function () {
282
+        function t(e) {
283
+            var t = e.attr("class");
284
+            return t && /\bimage\b/.test(t);
285
+        }
286
+        function n(e) {
287
+            return function (n) {
288
+                function r(t) {
289
+                    t.attr("contenteditable", e ? "true" : null);
290
+                }
291
+                for (var i, o = n.length; o--;) (i = n[o]), t(i) && (i.attr("contenteditable", e ? "false" : null), tinymce.each(i.getAll("figcaption"), r));
292
+            };
293
+        }
294
+        e.parser.addNodeFilter("figure", n(!0)), e.serializer.addNodeFilter("figure", n(!1));
295
+    }),
296
+        e.addButton("image", { icon: "image", tooltip: "Insert/edit image", onclick: r(i), stateSelector: "img:not([data-mce-object],[data-mce-placeholder]),figure.image" }),
297
+        e.addMenuItem("image", { icon: "image", text: "Image", onclick: r(i), context: "insert", prependToContext: !0 }),
298
+        e.addCommand("mceImage", r(i));
299
+});
... ...
@@ -47,61 +47,93 @@ location = \"maintenance.php\";
47 47
 	exit();
48 48
 }
49 49
 $oldVersion = explode(".", $settings['version']);
50
-
50
+ 
51 51
 if ($oldVersion[0] <= 3 && $oldVersion[1] <= 5 && $oldVersion[2] < 5)
52 52
 {
53 53
 	header("Location: update355.php");
54 54
 	exit();
55 55
 }
56
-
57
-$fanfiction_poll_exists = 0;  /* poll tables maybe be not installed */
58
-$fanfiction_poll_table = TABLEPREFIX . "fanfiction_poll";
59
-$fanfiction_poll_exists =  dbassoc(dbquery("
60
-			SELECT *
61
-			FROM information_schema.tables
62
-			WHERE table_schema = '{$dbname}'
63
-				AND table_name = '{$fanfiction_poll_table}'
64
-			;"));
65
-
56
+$set_355 = false;
57
+ 
66 58
 $set_355 = do_version_check_355();
59
+ 
67 60
 if($set_355) {
61
+	$output .= write_message("Table <b>" . $set_355 . "</b> needs a update.");
62
+
68 63
 	dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
64
+
69 65
 	$settings['version'] = '3.5.5';
70 66
 }
71
-$oldVersion = explode(".", $settings['version']);
67
+else {
68
+	$set_356 = do_version_check_356();
69
+ 
70
+	if ($set_356)
71
+	{
72
+		$output .= write_message("Table <b>" . $set_356 . "</b> needs a update.");
73
+		dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.6' WHERE sitekey = '" . SITEKEY . "'");
74
+		$settings['version'] = '3.5.6';
75
+	}
76
+}
72 77
 
78
+$oldVersion = explode(".", $settings['version']);
79
+ 
73 80
 $confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
74
-$oldconfirm = isset($_GET['oldconfirm']) ? $_GET['oldconfirm'] : false;
75
-
81
+ 
76 82
 if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 3))
77 83
 {
78 84
 	write_message("This version is working only for 3.5.5 database. If you have only database, there is way how to do it.");
79 85
 	exit;
80 86
 }
81
-
82
-
83
-
87
+ 
88
+ 
84 89
 if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
85 90
 {
86 91
 	if ($confirm == "yes")
87 92
 	{
88 93
 		if ($oldVersion[0] == 3 &&  $oldVersion[1] == 5 && $oldVersion[2] < 6)
89 94
 		{
90
-			/****************************************************************************************************************/
91
-			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_authors LIKE 'date'"));
92
-			if ($tmp['Type'] == "datetime")
93
-			{ 
94
-				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_authors LIKE 'date_tmp'"));
95
-				if (!$updated)
95
+
96
+			// List of DB tables (key) and field (value) which need changing to accommodate datetime field
97
+			$date_upgrade = array(
98
+				'fanfiction_authors' => 'date',
99
+				'fanfiction_comments'  => 'time',
100
+				'fanfiction_reviews' => 'date',
101
+				'fanfiction_stories'  => 'date',
102
+				'fanfiction_stories' => 'updated',
103
+				'fanfiction_news' => 'time',
104
+				'fanfiction_poll' => 'poll_start',
105
+				'fanfiction_poll' => 'poll_end',
106
+			);
107
+
108
+			// Tables where IP address field needs updating to accommodate IPV6
109
+			// Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
110
+			foreach ($date_upgrade as $t => $f)
111
+			{
112
+				if (isTable($t))
96 113
 				{
97
-					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_authors` ADD `date_tmp` int(10) unsigned NOT NULL default '0' ");
114
+
115
+					// Check for table - might add some core plugin tables in here
116
+					if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
117
+					{ 
118
+						if (strtolower($field_info['Type']) == 'datetime')
119
+						{
120
+
121
+							$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}_tmp'"));
122
+							if (!$updated)
123
+							{
124
+								dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` ADD `{$f}_tmp` int(10) unsigned NOT NULL default '0' ");
125
+							}
126
+
127
+							dbquery("UPDATE `" . TABLEPREFIX . $t .  "` SET `{$f}_tmp` = UNIX_TIMESTAMP( `{$f}` )");
128
+							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` CHANGE `{$f}` `{$f}` INT NOT NULL"); 
129
+							dbquery("UPDATE  `" . TABLEPREFIX . $t .  "` set {$f} = {$f}_tmp");
130
+							dbquery("ALTER TABLE  `" . TABLEPREFIX . $t .  "` DROP `{$f}_tmp`");
131
+						}
132
+					}
98 133
 				}
134
+			}	
99 135
 
100
-				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_authors` SET `date_tmp` = UNIX_TIMESTAMP( `date` )");
101
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_authors` CHANGE `date` `date` INT NOT NULL");
102
-				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_authors` set date = date_tmp");
103
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_authors` DROP `date_tmp`");
104
-			}
136
+ 
105 137
 			/****************************************************************************************************************/
106 138
 			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_log LIKE 'log_timestamp'"));
107 139
 
... ...
@@ -118,131 +150,78 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
118 150
 				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_log` set log_timestamp = log_timestamp_tmp");
119 151
 				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_log` DROP `log_timestamp_tmp`");
120 152
 			}
121
-			/****************************************************************************************************************/
122
-			/* fanfiction_comments   `time` datetime NOT NULL default '0000-00-00 00:00:00'  */
123
-			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_comments LIKE 'time'"));
124
-			if ($tmp['Type'] == "datetime")
125
-			{
126
-				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_comments LIKE 'time_tmp'"));
127
-				if (!$updated)
128
-				{
129
-					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_comments` ADD `time_tmp` int(10) unsigned NOT NULL default '0' ");
130
-				}
131 153
 
132
-				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_comments` SET `time_tmp` = UNIX_TIMESTAMP( `time` )");
133
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_comments` CHANGE `time` `time` INT NOT NULL");
134
-				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_comments` set time = time_tmp");
135
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_comments` DROP `time_tmp`");
154
+			$set_355 = false;
155
+			$set_355 = do_version_check_355();
156
+			if($set_355) {
157
+				$output .= write_error(_ERROR);
136 158
 			}
137
-			/****************************************************************************************************************/
138
-			/* fanfiction_reviews   `date` datetime NOT NULL default '0000-00-00 00:00:00', */
139
-			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_reviews LIKE 'date'"));
140
-			if ($tmp['Type'] == "datetime")
141
-			{
142
-				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_reviews LIKE 'date_tmp'"));
143
-				if (!$updated)
144
-				{
145
-					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_reviews` ADD `date_tmp` int(10) unsigned NOT NULL default '0' ");
146
-				}
147
-
148
-				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_reviews` SET `date_tmp` = UNIX_TIMESTAMP( `date` )");
149
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_reviews` CHANGE `date` `date` INT NOT NULL");
150
-				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_reviews` set date = date_tmp");
151
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_reviews` DROP `date_tmp`");
152
-			}
153
-			/****************************************************************************************************************/
154
-			/* fanfiction_stories `date` datetime NOT NULL default '0000-00-00 00:00:00',   */
155
-			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'date'"));
156
-			if($tmp['Type'] == "datetime") {
157
-				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'date_tmp'"));
158
-				if (!$updated)
159
-				{
160
-					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_stories` ADD `date_tmp` int(10) unsigned NOT NULL default '0' ");
161
-				}
162
-
163
-				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_stories` SET `date_tmp` = UNIX_TIMESTAMP( `date` )");
164
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_stories` CHANGE `date` `date` INT NOT NULL");
165
-				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_stories` set date = date_tmp");
166
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_stories` DROP `date_tmp`");
167
-			}
168
-
169
-			/****************************************************************************************************************/
170
-			/* fanfiction_stories `updated` datetime NOT NULL default '0000-00-00 00:00:00', */
171
-			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'updated'"));
172
-			if ($tmp['Type'] == "datetime")
173
-			{				
174
-				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'updated_tmp'"));
175
-				if (!$updated)
176
-				{
177
-					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_stories` ADD `updated_tmp` int(10) unsigned NOT NULL default '0' ");
178
-				}
179
-
180
-				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_stories` SET `updated_tmp` = UNIX_TIMESTAMP( `updated` )");
181
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_stories` CHANGE `updated` `updated` INT NOT NULL");
182
-				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_stories` set updated = updated_tmp");
183
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_stories` DROP `updated_tmp`");
184
-			}
185
-
186
-			/****************************************************************************************************************/
187
-			/* fanfiction_news `time` datetime default NULL,  */
188
-			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_news LIKE 'time'"));
189
-			
190
-			if ($tmp['Type'] == "datetime")
191
-			{		
192
-				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_news LIKE 'time_tmp'"));
193
-				if (!$updated)
194
-				{
195
-					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_news` ADD `time_tmp` int(10) unsigned NOT NULL default '0' ");
196
-				}
197
-
198
-				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_news` SET `time_tmp` = UNIX_TIMESTAMP( `time` )");
199
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_news` CHANGE `time` `time` INT NOT NULL");
200
-				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_news` set time = time_tmp");
201
-				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_news` DROP `time_tmp`");
159
+			else {
160
+				$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '" . $version . "' WHERE sitekey = '" . SITEKEY . "'");
161
+				if ($update) $output .= write_message(_ACTIONSUCCESSFUL);
202 162
 			}
163
+ 
164
+		}
165
+	
203 166
 
204
-			/****************************************************************************************************************/
205
-			if ($fanfiction_poll_exists)
167
+	}
168
+	else if ($confirm == "no")
169
+	{
170
+		$output .= write_message(_ACTIONCANCELLED);
171
+	}
172
+	else
173
+	{
174
+		if ($oldVersion[0] == 3 && ($oldVersion[1] < 4 || $oldVersion[1] == 4 && (!isset($oldVersion[2]) || $oldVersion[2] < 6)))
175
+			$output .= write_message(_CONFIRMUPDATE . "<br /> <a href='update.php?confirm=yes'>" . _YES . "</a> " . _OR . " <a href='update.php?confirm=no'>" . _NO . "</a>");
176
+		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>");
177
+	}
178
+}
179
+elseif ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 7))  //3.5.6
180
+{
181
+	if ($confirm == "yes")
182
+	{
183
+		if ($oldVersion[0] == 3 &&  $oldVersion[1] == 5 && $oldVersion[2] < 7)
184
+		{
185
+			// List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
186
+			$ip_upgrade = array(
187
+				'fanfiction_log' 	=> 'log_ip',
188
+				'fanfiction_online' => 'online_ip'
189
+			);
190
+
191
+			// Tables where IP address field needs updating to accommodate IPV6
192
+			// Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
193
+			foreach ($ip_upgrade as $t => $f)
206 194
 			{
207
-				$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_start'"));
208
-
209
-				if ($tmp['Type'] == "datetime")
195
+				if (isTable($t))
210 196
 				{
211
-					$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_start_tmp'"));
212
-					if (!$updated)
197
+			 
198
+					// Check for table - might add some core plugin tables in here
199
+					if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
213 200
 					{
214
-						dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_poll` ADD `poll_start_tmp` int(10) unsigned NOT NULL default '0' ");
215
-					}
201
+						//print_r($field_info);
202
+						if (strtolower($field_info['Type']) != 'VARBINARY(16)')
203
+						{
216 204
 
217
-					dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_poll` SET `poll_start_tmp` = UNIX_TIMESTAMP( `poll_start` )");
218
-					dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_poll` CHANGE `poll_start` `poll_start` INT NOT NULL");
219
-					dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_poll` set poll_start = poll_start_tmp");
220
-					dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_poll` DROP `poll_start_tmp`");
221
-				}
222
-
223
-				$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_end'"));
224
-
225
-				if ($tmp['Type'] == "datetime")
226
-				{
227
-					$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_end_tmp'"));
228
-					if (!$updated)
229
-					{
230
-						dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_poll` ADD `poll_end_tmp` int(10) unsigned NOT NULL default '0' ");
205
+							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` MODIFY `$f` VARBINARY(16) NOT NULL DEFAULT '';");
206
+ 
207
+						}
231 208
 					}
232 209
 
233
-					dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_poll` SET `poll_end_tmp` = UNIX_TIMESTAMP( `poll_end` )");
234
-					dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_poll` CHANGE `poll_end` `poll_end` INT NOT NULL");
235
-					dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_poll` set poll_end = poll_end_tmp");
236
-					dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_poll` DROP `poll_end_tmp`");
237 210
 				}
211
+			}	 
212
+		}
238 213
 
239
-			}	
240
-
214
+		$set_356 = false;
215
+		$set_356 = do_version_check_356();
216
+		if ($set_356)
217
+		{
218
+			$output .= write_error(_ERROR);
219
+		}
220
+		else
221
+		{
222
+			$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '" . $version . "' WHERE sitekey = '" . SITEKEY . "'");
223
+			if ($update) $output .= write_message(_ACTIONSUCCESSFUL);
241 224
 		}
242
-	
243
-		$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '" . $version . "' WHERE sitekey = '" . SITEKEY . "'");
244
-		if ($update) $output .= write_message(_ACTIONSUCCESSFUL);
245
-		else $output .= write_error(_ERROR);
246 225
 	}
247 226
 	else if ($confirm == "no")
248 227
 	{
... ...
@@ -250,10 +229,11 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
250 229
 	}
251 230
 	else
252 231
 	{
253
-		if ($oldVersion[0] == 3 && ($oldVersion[1] < 4 || $oldVersion[1] == 4 && (!isset($oldVersion[2]) || $oldVersion[2] < 6)))
254
-			$output .= write_message(_CONFIRMUPDATE . "<br /> <a href='update.php?confirm=yes'>" . _YES . "</a> " . _OR . " <a href='update.php?confirm=no'>" . _NO . "</a>");
232
+		if ($oldVersion[0] == 3 && ($oldVersion[1] < 4 || $oldVersion[1] == 4 && (!isset($oldVersion[2]) || $oldVersion[2] < 7)))
233
+		$output .= write_message(_CONFIRMUPDATE . "<br /> <a href='update.php?confirm=yes'>" . _YES . "</a> " . _OR . " <a href='update.php?confirm=no'>" . _NO . "</a>");
255 234
 		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>");
256 235
 	}
236
+
257 237
 }
258 238
 else $output .= write_message(_ALREADYUPDATED);
259 239
 
... ...
@@ -262,82 +242,115 @@ function do_version_check_355() {
262 242
 	global $fanfiction_poll_exists;
263 243
 
264 244
 	$check_355 = false;
265
- 
266
-	/* do double check or return version back if it is needed */
267
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_authors LIKE 'date'"));
268
-	if ($tmp['Type'] == "datetime")
269
-	{
270
-		$check_355 = true;
271
-		return $check_355;
272
-	}
273
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_log LIKE 'log_timestamp'"));
274 245
 
275
-	if ($tmp['Type'] == "timestamp")
246
+	// List of DB tables (key) and field (value) which need changing date from datetime/timestamp to int
247
+	$date_upgrade = array(
248
+		'fanfiction_authors' => 'date',
249
+		'fanfiction_comments'  => 'time',
250
+		'fanfiction_reviews' => 'date',
251
+		'fanfiction_stories'  => 'date',
252
+		'fanfiction_stories' => 'updated',
253
+		'fanfiction_news' => 'time',
254
+		'fanfiction_poll' => 'poll_start',
255
+		'fanfiction_poll' => 'poll_end',
256
+	);
257
+
258
+	foreach ($date_upgrade as $t => $f)
276 259
 	{
277
-		$check_355 = true;
278
-		return $check_355;
279
-	}
280 260
 
281
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_comments LIKE 'time'"));
282
-	if ($tmp['Type'] == "datetime")
283
-	{
284
-		$check_355 = true;
285
-		return $check_355;
286
-	}
261
+		if (isTable($t))
262
+		{
287 263
 
288
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_reviews LIKE 'date'"));
289
-	if ($tmp['Type'] == "datetime")
290
-	{
291
-		$check_355 = true;
292
-		return $check_355;
293
-	}
264
+			// Check for table - might add some core plugin tables in here
265
+			if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
266
+			{
294 267
 
295
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'date'"));
296
-	if ($tmp['Type'] == "datetime")
297
-	{
298
-		$check_355 = true;
299
-		return $check_355;
268
+				if (strtolower($field_info['Type']) != 'int' 
269
+				&& strtolower($field_info['Type']) != 'int(10)'
270
+				&& strtolower($field_info['Type']) != 'int(11)' 
271
+				&& strtolower($field_info['Type']) != 'int unsigned'
272
+				&& strtolower($field_info['Type']) != 'int(10) unsigned')
273
+				{
274
+					// echo "<pre>"; print_r($field_info); echo "</pre>";
275
+					$check_355 = $t . " - field:  " . $f;
276
+					return $check_355;
277
+				}
278
+			}
279
+		}
280
+		
300 281
 	}
301 282
 
302
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'updated'"));
303
-	if ($tmp['Type'] == "datetime")
283
+	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_log LIKE 'log_timestamp'"));
284
+
285
+	if ($tmp['Type'] == "timestamp")
304 286
 	{
305
-		$check_355 = true;
287
+		$check_355 = $t . " - field:  " . $f;;
306 288
 		return $check_355;
307 289
 	}
308 290
 
309
-	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_news LIKE 'time'"));
291
+	return $check_355;
292
+}
310 293
 
311
-	if ($tmp['Type'] == "datetime")
312
-	{
313
-			$check_355 = true;
314
-			return $check_355;
315
-	}
294
+function do_version_check_356()
295
+{
296
+	$check_356 = false;
297
+ 
298
+	// List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
299
+	$ip_upgrade = array(
300
+		'fanfiction_log' 	=> 'log_ip',
301
+		'fanfiction_online' => 'online_ip'
302
+	);
316 303
 
317
-	if ($fanfiction_poll_exists)
304
+	foreach ($ip_upgrade as $t => $f)
318 305
 	{
319
-		$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_start'"));
320
-
321
-		if ($tmp['Type'] == "datetime")
306
+ 
307
+		if (isTable($t))
322 308
 		{
323
-			$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
324
-		}
325
-
326
-
327
-		$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_end'"));
309
+			// Check for table - might add some core plugin tables in here
310
+			if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t ." LIKE '{$f}'")) )
311
+			{
328 312
 
329
-		if ($tmp['Type'] == "datetime")
330
-		{
331
-			$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
313
+			
314
+				if (strtolower($field_info['Type']) != 'varbinary(16)')
315
+				{
316
+					$check_356 = $t . " - field:  " . $f;;
317
+			 
318
+					return $check_356;	 
319
+				}
320
+			}
321
+	 
332 322
 		}
323
+		
333 324
 	}
334
-	
335
-
336
-	return $check_355;
337
-}
338 325
  
339
-
326
+	return $check_356;
327
+}
340 328
 
341 329
 $tpl->assign("output", $output);
342 330
 $tpl->printToScreen();
343 331
 dbclose();
332
+
333
+
334
+// new functions for easier db manipulation 3.6. 
335
+function db_mySQLtableList()
336
+{
337
+	global  $debug, $dbconnect, $dbname, $settingsprefix;
338
+
339
+	$table = array();
340
+
341
+	if ($res = dbquery("SHOW TABLES FROM " . $dbname . " LIKE '" . $settingsprefix . "%' "))
342
+
343
+		$length = strlen($settingsprefix);
344
+	while ($rows = dbrow($res))
345
+	{
346
+		$t = substr($rows[0], $length);
347
+		$table[] = $t;
348
+	}
349
+	return  $table;
350
+}
351
+
352
+function isTable($table)
353
+{
354
+	$mySQLtableList = db_mySQLtableList();
355
+	return in_array($table, $mySQLtableList);
356
+}
... ...
@@ -82,7 +82,7 @@ function random_string ($charset_string, $length)
82 82
 					}
83 83
 					dbquery("INSERT INTO ".substr(_AUTHORTABLE, 0, strpos(_AUTHORTABLE, "as author"))." (penname, realname, bio, email, date, password) VALUES ('".escapestring($penname)."', '".escapestring(strip_tags($_POST['realname']))."', '".strip_tags(escapestring($_POST['bio']), $allowed_tags)."', '$email', now(), '$encryppass')");
84 84
 					$useruid = dbinsertid();
85
-					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
85
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
86 86
 					if(empty($siteskin)) {
87 87
 						$skinquery = dbquery("SELECT skin FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".SITEKEY."'");
88 88
 						list($skin) = dbrow($skinquery);
... ...
@@ -132,7 +132,7 @@ function random_string ($charset_string, $length)
132 132
 				}
133 133
 				else {
134 134
 					dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
135
-					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
135
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
136 136
 				}
137 137
 			}
138 138
 /* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
... ...
@@ -212,4 +212,4 @@ function random_string ($charset_string, $length)
212 212
 	 	}
213 213
 	 	$output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
214 214
 	}
215
-?>
216 215
\ No newline at end of file
216
+?>
... ...
@@ -66,7 +66,7 @@ if(isMEMBER) accessDenied( );
66 66
 				}
67 67
 				else $output .=  write_message(_EMAILFAILED);
68 68
 				if($logging) 
69
-					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_LOST_PASSWORD, $penname, $uid, ($result ? _YES : _NO)))."', '$uid', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'LP', " . time() . ")");
69
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_LOST_PASSWORD, $penname, $uid, ($result ? _YES : _NO)))."', '$uid', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'LP', " . time() . ")");
70 70
 			}
71 71
 
72 72
 		}
... ...
@@ -80,4 +80,4 @@ if(isMEMBER) accessDenied( );
80 80
 		</td></tr></table>";
81 81
 	}
82 82
 
83
-?>
84 83
\ No newline at end of file
84
+?>
... ...
@@ -30,7 +30,11 @@ function buildImageList( ) {
30 30
 		$dir = opendir(STORIESPATH."/".USERUID."/images/");
31 31
 		while($file = readdir($dir)) {
32 32
 			if(!in_array($file, array(".", "..", "/", "index.php", "imagelist.js"))) {
33
-				$image_files[] = "[\"".STORIESPATH."/".USERUID."/images/$file\", \"".STORIESPATH."/".USERUID."/images/$file\"]";
33
+				$path =  STORIESPATH . "/" . USERUID . "/images/".$file;
34
+				$image_files[] = "[\"" . STORIESPATH . "/" . USERUID . "/images/$file\", \"" . STORIESPATH . "/" . USERUID . "/images/$file\"]";
35
+
36
+				$image4_files[] = '{ "title": "'. $file. '", "value": "'.$path.'" }';
37
+		 
34 38
 			}
35 39
 		}
36 40
 		if(isset($image_files)) {
... ...
@@ -39,6 +43,12 @@ function buildImageList( ) {
39 43
 			$text .= implode(", \n", $image_files);
40 44
 			$text .= ");\n\n";
41 45
 			fwrite($handle, $text);
46
+
47
+			$text = "var tinyMCE4ImageList = [\n";
48
+			$text .= implode(", \n", $image4_files);
49
+			$text .= "];\n\n";
50
+			fwrite($handle, $text);
51
+
42 52
 			fclose($handle);
43 53
 		}
44 54
 }
... ...
@@ -218,4 +228,4 @@ if($imageupload) {
218 228
 else { 
219 229
 	$output .= write_message(_NOTAUTHORIZED);
220 230
 }
221
-?>
222 231
\ No newline at end of file
232
+?>
... ...
@@ -1,6 +1,6 @@
1 1
 <?php
2 2
 if(!defined("_CHARSET")) exit( );
3
-$version = "3.5.6";
3
+$version = "3.5.7";
4 4
 
5 5
 /* shortcut 
6 6
 $tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'date'"));
... ...
@@ -16,4 +16,4 @@ if ($tmp['Type'] == "datetime")
16 16
     dbquery("UPDATE " . TABLEPREFIX . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
17 17
 }
18 18
 
19
-*/
20 19
\ No newline at end of file
20
+*/