Browse code

smtp fix + tester

Jimako authored on 2026/07/10 14:03:10
Showing 1 changed files
... ...
@@ -73,6 +73,17 @@ else {
73 73
 		dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.6' WHERE sitekey = '" . SITEKEY . "'");
74 74
 		$settings['version'] = '3.5.6';
75 75
 	}
76
+ 
77
+	else {
78
+		$set_359 = do_version_check_359();
79
+	
80
+		if ($set_359)
81
+		{
82
+			$output .= write_message("Table <b>" . $set_359 . "</b> needs a update.");
83
+			dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.8' WHERE sitekey = '" . SITEKEY . "'");
84
+			$settings['version'] = '3.5.8';
85
+		}
86
+	}
76 87
 }
77 88
 
78 89
 $oldVersion = explode(".", $settings['version']);
... ...
@@ -271,6 +282,30 @@ elseif ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 8))  //3.
271 282
 
272 283
 }
273 284
 
285
+elseif ($oldVersion[0] == 3 && $oldVersion[1] == 5 && $oldVersion[2] < 9)  // 3.5.8 -> 3.5.9
286
+{
287
+	if ($confirm == "yes")
288
+	{
289
+		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'smtp_port'")))
290
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `smtp_port` varchar(5) NOT NULL DEFAULT ''");
291
+		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'smtp_secure'")))
292
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `smtp_secure` varchar(3) NOT NULL DEFAULT ''");
293
+
294
+		$set_359 = do_version_check_359();
295
+		if ($set_359)
296
+		{
297
+			$output .= write_error(_ERROR);   // migration not confirmed -> DO NOT bump version
298
+		}
299
+		else
300
+		{
301
+			$update = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET version = '".$version."' WHERE sitekey = '".SITEKEY."'");
302
+			if ($update) $output .= write_message(_ACTIONSUCCESSFUL);
303
+		}
304
+	}
305
+	else if ($confirm == "no") $output .= write_message(_ACTIONCANCELLED);
306
+	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>");
307
+}
308
+
274 309
 else $output .= write_message(_ALREADYUPDATED);
275 310
 
276 311
 /* until database is fully fixed, not update efiction version */
... ...
@@ -381,6 +416,23 @@ function do_version_check_356()
381 416
 	return $check_356;
382 417
 }
383 418
 
419
+function do_version_check_359()
420
+{
421
+	$check_359 = false;
422
+
423
+	$required = array('smtp_port', 'smtp_secure');
424
+	foreach ($required as $f)
425
+	{
426
+		if (!dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_settings LIKE '{$f}'")))
427
+		{
428
+			$check_359 = "fanfiction_settings - field: " . $f;
429
+			return $check_359;
430
+		}
431
+	}
432
+
433
+	return $check_359;
434
+}
435
+
384 436
 $tpl->assign("output", $output);
385 437
 $tpl->printToScreen();
386 438
 dbclose();
Browse code

special fix for date fields

Jimako authored on 2024/09/29 15:27:47
Showing 1 changed files
... ...
@@ -150,8 +150,16 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
150 150
 								dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` ADD `{$f}_tmp` int(10) unsigned NOT NULL default '0' ");
151 151
 							}
152 152
 
153
+							$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}_backup'"));
154
+							if (!$updated)
155
+							{
156
+								dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` ADD `{$f}_backup` datetime  ");
157
+							}
158
+
159
+							dbquery("UPDATE `" . TABLEPREFIX . $t .  "` SET `{$f}_backup` =  `{$f}`  ");
153 160
 							dbquery("UPDATE `" . TABLEPREFIX . $t .  "` SET `{$f}_tmp` = UNIX_TIMESTAMP( `{$f}` )");
154
-							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` CHANGE `{$f}` `{$f}` DATETIME NOT NULL)");
161
+							dbquery("UPDATE `" . TABLEPREFIX . $t .  "` SET `{$f}` =  '' ");
162
+						//	dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` CHANGE `{$f}` `{$f}` DATETIME NOT NULL)");  this is needed on some servers
155 163
 							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` CHANGE `{$f}` `{$f}` INT NOT NULL"); 
156 164
 							dbquery("UPDATE  `" . TABLEPREFIX . $t .  "` set {$f} = {$f}_tmp");
157 165
 							dbquery("ALTER TABLE  `" . TABLEPREFIX . $t .  "` DROP `{$f}_tmp`");
Browse code

FINALLY - fixed datetime field update issue on some server

Jimako authored on 2024/05/22 15:50:44
Showing 1 changed files
... ...
@@ -151,6 +151,7 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
151 151
 							}
152 152
 
153 153
 							dbquery("UPDATE `" . TABLEPREFIX . $t .  "` SET `{$f}_tmp` = UNIX_TIMESTAMP( `{$f}` )");
154
+							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` CHANGE `{$f}` `{$f}` DATETIME NOT NULL)");
154 155
 							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` CHANGE `{$f}` `{$f}` INT NOT NULL"); 
155 156
 							dbquery("UPDATE  `" . TABLEPREFIX . $t .  "` set {$f} = {$f}_tmp");
156 157
 							dbquery("ALTER TABLE  `" . TABLEPREFIX . $t .  "` DROP `{$f}_tmp`");
Browse code

3.5.8.1 warnings, dbconnect, install changes

Jimako authored on 2024/05/09 06:30:39
Showing 1 changed files
... ...
@@ -202,7 +202,7 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
202 202
 		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>");
203 203
 	}
204 204
 }
205
-elseif ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 7))  //3.5.6
205
+elseif ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 8))  //3.5.6 + 3.5.7
206 206
 {
207 207
 	if ($confirm == "yes")
208 208
 	{
... ...
@@ -261,6 +261,7 @@ elseif ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 7))  //3.
261 261
 	}
262 262
 
263 263
 }
264
+
264 265
 else $output .= write_message(_ALREADYUPDATED);
265 266
 
266 267
 /* until database is fully fixed, not update efiction version */
Browse code

update fix - more fields in the same table

Jimako authored on 2024/04/13 03:29:20
Showing 1 changed files
... ...
@@ -94,27 +94,53 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
94 94
 		{
95 95
 
96 96
 			// List of DB tables (key) and field (value) which need changing to accommodate datetime field
97
+			// List of DB tables (key) and field (value) which need changing date from datetime/timestamp to int
97 98
 			$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',
99
+				array('table' => 'fanfiction_authors', 'field' => 'date'),
100
+				array(
101
+					'table' =>
102
+					'fanfiction_comments', 'field'  => 'time'
103
+				),
104
+				array(
105
+					'table' =>
106
+					'fanfiction_reviews', 'field' => 'date'
107
+				),
108
+				array(
109
+					'table' =>
110
+					'fanfiction_stories', 'field'  => 'date'
111
+				),
112
+				array(
113
+					'table' =>
114
+					'fanfiction_stories', 'field' => 'updated'
115
+				),
116
+				array(
117
+					'table' =>
118
+					'fanfiction_news', 'field' => 'time'
119
+				),
120
+				array(
121
+					'table' =>
122
+					'fanfiction_poll', 'field' => 'poll_start'
123
+				),
124
+				array(
125
+					'table' =>
126
+					'fanfiction_poll', 'field' => 'poll_end'
127
+				),
106 128
 			);
107 129
 
108 130
 			// Tables where IP address field needs updating to accommodate IPV6
109 131
 			// 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)
132
+			foreach ($date_upgrade as $tmp)
111 133
 			{
134
+
135
+				$t = $tmp['table'];
136
+				$f = $tmp['field'];
112 137
 				if (isTable($t))
113 138
 				{
114 139
 
115 140
 					// Check for table - might add some core plugin tables in here
116 141
 					if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
117 142
 					{ 
143
+
118 144
 						if (strtolower($field_info['Type']) == 'datetime')
119 145
 						{
120 146
 
... ...
@@ -244,27 +270,46 @@ function do_version_check_355() {
244 270
 	$check_355 = false;
245 271
 
246 272
 	// 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',
273
+	$date_upgrade = array(	
274
+		array('table'=>'fanfiction_authors', 'field' => 'date'),
275
+		array(
276
+			'table' =>
277
+			'fanfiction_comments', 'field'  => 'time'),
278
+			array(
279
+			'table' =>
280
+			'fanfiction_reviews', 'field' => 'date'),
281
+				array(
282
+			'table' =>
283
+			'fanfiction_stories', 'field'  => 'date'),
284
+					array(
285
+			'table' =>
286
+			'fanfiction_stories', 'field' => 'updated'),
287
+						array(
288
+			'table' =>
289
+			'fanfiction_news', 'field' => 'time'),
290
+							array(
291
+			'table' =>
292
+			'fanfiction_poll', 'field' => 'poll_start'),
293
+								array(
294
+			'table' =>
295
+			'fanfiction_poll', 'field' => 'poll_end'),
256 296
 	);
257 297
 
258
-	foreach ($date_upgrade as $t => $f)
298
+	foreach ($date_upgrade as $tmp)
259 299
 	{
260 300
 
301
+		$t = $tmp['table'];
302
+		$f = $tmp['field'];
261 303
 		if (isTable($t))
262 304
 		{
263 305
 
264 306
 			// Check for table - might add some core plugin tables in here
265 307
 			if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
266 308
 			{
267
-
309
+				// echo "<pre>";
310
+				// print_r($t);
311
+				// print_r($field_info);
312
+				// echo "</pre>";
268 313
 				if (strtolower($field_info['Type']) != 'int' 
269 314
 				&& strtolower($field_info['Type']) != 'int(10)'
270 315
 				&& strtolower($field_info['Type']) != 'int(11)' 
Browse code

fix for default value of IP fields (localhost)

Jimako authored on 2024/04/09 08:01:51
Showing 1 changed files
... ...
@@ -202,7 +202,7 @@ elseif ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 7))  //3.
202 202
 						if (strtolower($field_info['Type']) != 'VARBINARY(16)')
203 203
 						{
204 204
 
205
-							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` MODIFY `$f` VARBINARY(16) NOT NULL DEFAULT '';");
205
+							dbquery("ALTER TABLE `" . TABLEPREFIX . $t .  "` MODIFY `$f` varbinary(16) DEFAULT NULL;");
206 206
  
207 207
 						}
208 208
 					}
Browse code

version 3.5.7

Jimako authored on 2024/04/08 12:21:57
Showing 1 changed files
... ...
@@ -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
+}
Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,343 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.0
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+$current = "update";
25
+
26
+include("header.php");
27
+
28
+$blocks['news']['status'] = 0;
29
+$blocks['info']['status'] = 0;
30
+
31
+//make a new TemplatePower object
32
+if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
33
+else $tpl = new TemplatePower("default_tpls/default.tpl");
34
+include("includes/pagesetup.php");
35
+if (file_exists("languages/" . $language . "_admin.php")) include_once("languages/" . $language . "_admin.php");
36
+else include_once("languages/en_admin.php");
37
+// end basic page setup
38
+
39
+if (!isADMIN)
40
+{
41
+	$output .= "<script language=\"javascript\" type=\"text/javascript\">
42
+location = \"maintenance.php\";
43
+</script>";
44
+	$tpl->assign("output", $output);
45
+	$tpl->printToScreen();
46
+	dbclose();
47
+	exit();
48
+}
49
+$oldVersion = explode(".", $settings['version']);
50
+
51
+if ($oldVersion[0] <= 3 && $oldVersion[1] <= 5 && $oldVersion[2] < 5)
52
+{
53
+	header("Location: update355.php");
54
+	exit();
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
+
66
+$set_355 = do_version_check_355();
67
+if($set_355) {
68
+	dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
69
+	$settings['version'] = '3.5.5';
70
+}
71
+$oldVersion = explode(".", $settings['version']);
72
+
73
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
74
+$oldconfirm = isset($_GET['oldconfirm']) ? $_GET['oldconfirm'] : false;
75
+
76
+if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 3))
77
+{
78
+	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
+	exit;
80
+}
81
+
82
+
83
+
84
+if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
85
+{
86
+	if ($confirm == "yes")
87
+	{
88
+		if ($oldVersion[0] == 3 &&  $oldVersion[1] == 5 && $oldVersion[2] < 6)
89
+		{
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)
96
+				{
97
+					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_authors` ADD `date_tmp` int(10) unsigned NOT NULL default '0' ");
98
+				}
99
+
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
+			}
105
+			/****************************************************************************************************************/
106
+			$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_log LIKE 'log_timestamp'"));
107
+
108
+			if ($tmp['Type'] == "timestamp")
109
+			{ 
110
+				$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_log LIKE 'log_timestamp_tmp'"));
111
+				if (!$updated)
112
+				{
113
+					dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_log` ADD `log_timestamp_tmp` int(10) unsigned NOT NULL default '0' ");
114
+				}
115
+
116
+				dbquery("UPDATE 		`" . TABLEPREFIX . "fanfiction_log` SET `log_timestamp_tmp` = UNIX_TIMESTAMP( `log_timestamp` )");
117
+				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_log` CHANGE `log_timestamp` `log_timestamp` INT NOT NULL");
118
+				dbquery("UPDATE `" . TABLEPREFIX . "fanfiction_log` set log_timestamp = log_timestamp_tmp");
119
+				dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_log` DROP `log_timestamp_tmp`");
120
+			}
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
+
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`");
136
+			}
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`");
202
+			}
203
+
204
+			/****************************************************************************************************************/
205
+			if ($fanfiction_poll_exists)
206
+			{
207
+				$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_start'"));
208
+
209
+				if ($tmp['Type'] == "datetime")
210
+				{
211
+					$updated = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_start_tmp'"));
212
+					if (!$updated)
213
+					{
214
+						dbquery("ALTER TABLE 	`" . TABLEPREFIX . "fanfiction_poll` ADD `poll_start_tmp` int(10) unsigned NOT NULL default '0' ");
215
+					}
216
+
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' ");
231
+					}
232
+
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
+				}
238
+
239
+			}	
240
+
241
+		}
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
+	}
247
+	else if ($confirm == "no")
248
+	{
249
+		$output .= write_message(_ACTIONCANCELLED);
250
+	}
251
+	else
252
+	{
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>");
255
+		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
+	}
257
+}
258
+else $output .= write_message(_ALREADYUPDATED);
259
+
260
+/* until database is fully fixed, not update efiction version */
261
+function do_version_check_355() {
262
+	global $fanfiction_poll_exists;
263
+
264
+	$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
+
275
+	if ($tmp['Type'] == "timestamp")
276
+	{
277
+		$check_355 = true;
278
+		return $check_355;
279
+	}
280
+
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
+	}
287
+
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
+	}
294
+
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;
300
+	}
301
+
302
+	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'updated'"));
303
+	if ($tmp['Type'] == "datetime")
304
+	{
305
+		$check_355 = true;
306
+		return $check_355;
307
+	}
308
+
309
+	$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_news LIKE 'time'"));
310
+
311
+	if ($tmp['Type'] == "datetime")
312
+	{
313
+			$check_355 = true;
314
+			return $check_355;
315
+	}
316
+
317
+	if ($fanfiction_poll_exists)
318
+	{
319
+		$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_poll LIKE 'poll_start'"));
320
+
321
+		if ($tmp['Type'] == "datetime")
322
+		{
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'"));
328
+
329
+		if ($tmp['Type'] == "datetime")
330
+		{
331
+			$update = dbquery("UPDATE " . $settingsprefix . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
332
+		}
333
+	}
334
+	
335
+
336
+	return $check_355;
337
+}
338
+ 
339
+
340
+
341
+$tpl->assign("output", $output);
342
+$tpl->printToScreen();
343
+dbclose();