Browse code

update355.php: add ip2long() patch for 32-bit PHP builds from @ariadoss - This use will be very uncommon, but I've seen worse: I have actually recently seen eFiction 2.x builds still live in the wild... that was during my usual attempts of finding more historical eFiction files for collation

Clarissa Walker authored on 2026/11/16 18:45:15
Showing 1 changed files
... ...
@@ -112,6 +112,15 @@ CREATE TABLE `".TABLEPREFIX."fanfiction_stats` (
112 112
 		dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_series` ADD `numstories` INT NOT NULL DEFAULT '0'");
113 113
 		dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_pagelinks` ADD `link_key` CHAR( 1 ) NULL AFTER `link_text`");
114 114
 		if(!isset($allowseries)) dbquery("ALTER TABLE `".$settingsprefix."fanfiction_settings` ADD `allowseries` TINYINT NOT NULL DEFAULT '2' AFTER `roundrobins`");
115
+		// A signed log_ip column can hold negative values: 32-bit PHP builds
116
+		// return negative ip2long() results for addresses at or above 128.0.0.0.
117
+		// On strict-mode servers the direct signed-to-unsigned CHANGE fails with
118
+		// error 1264 while any negative row remains, dbquery() dies, and the
119
+		// whole update strand stops with the version row untouched. Walk the
120
+		// conversion through BIGINT and lift the negatives into their unsigned
121
+		// equivalents so every stored address survives.
122
+		dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_log` CHANGE `log_ip` `log_ip` BIGINT NULL DEFAULT NULL");
123
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_log SET log_ip = log_ip + 4294967296 WHERE log_ip < 0");
115 124
 		dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_log` CHANGE `log_ip` `log_ip` INT( 11 ) UNSIGNED NULL DEFAULT NULL");
116 125
 		dbquery("UPDATE ".TABLEPREFIX."fanfiction_inseries SET confirmed = 1");
117 126
 		$serieslist = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_series");
... ...
@@ -340,4 +349,4 @@ else {
340 349
 $tpl->assign( "output", $output );
341 350
 $tpl->printToScreen();
342 351
 dbclose( );
343
-?>
344 352
\ No newline at end of file
353
+?>