Browse code

includes/userlist.php: Fix Uncaught TypeError in PHP 8 for the Co-Authors field when you use a starting character that yields no results

Clarissa Walker authored on 2026/09/05 18:58:51
Showing 1 changed files
... ...
@@ -21,7 +21,7 @@ echo "var element = '".$_GET['element']."';\n";
21 21
 while($u = dbassoc($users)) {
22 22
 	$userlist[$u['uid']] = $u['username'];
23 23
 }
24
-if(count($userlist) > 0) {
24
+if(is_countable($userlist) > 0) {
25 25
 	$x = 0;
26 26
 	foreach($userlist as $k => $v) {
27 27
 		echo "userList[$x] =  new Array('$k','$v');\n";
Browse code

Relocate CHARSET definition back to the languages/en.php file - this makes some legacy modules work without adding a charset definition

Clarissa Walker authored on 2026/09/05 15:43:38
Showing 1 changed files
... ...
@@ -4,7 +4,7 @@ ini_set('display_startup_errors', 0);
4 4
 error_reporting(-1);
5 5
 
6 6
 define("_BASEDIR", "../");
7
-define("_CHARSET", "utf-8");
7
+define("_USERCHARSET", "utf-8");
8 8
 
9 9
 include("../config.php");
10 10
 list($tableprefix, $language) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
... ...
@@ -13,7 +13,7 @@ if(file_exists(_BASEDIR."languages/{$language}.php")) include (_BASEDIR."languag
13 13
 else include (_BASEDIR."languages/en.php");
14 14
 include("../includes/queries.php");
15 15
 
16
-header("Content-Type: text/html; charset="._CHARSET);
16
+header("Content-Type: text/html; charset="._USERCHARSET);
17 17
 
18 18
 $users = dbquery("SELECT "._UIDFIELD." as uid, "._PENNAMEFIELD." as username FROM "._AUTHORTABLE." WHERE LOWER(".
19 19
 	_PENNAMEFIELD.") LIKE \"".escapestring($_GET['str'])."%\" ORDER BY username ASC limit 10");
Browse code

Add includes/dbfunctions.php include back to config.php, but leave the actual dbconnect in the includes/dbfunctions.php file where it belongs - this makes legacy modules work without adding another include

Clarissa Walker authored on 2026/09/05 13:38:28
Showing 1 changed files
... ...
@@ -7,7 +7,6 @@ define("_BASEDIR", "../");
7 7
 define("_CHARSET", "utf-8");
8 8
 
9 9
 include("../config.php");
10
-include("../includes/dbfunctions.php");
11 10
 list($tableprefix, $language) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
12 11
 define("TABLEPREFIX", $tableprefix);
13 12
 if(file_exists(_BASEDIR."languages/{$language}.php")) include (_BASEDIR."languages/{$language}.php");
... ...
@@ -29,4 +28,4 @@ if(count($userlist) > 0) {
29 28
 		$x++;
30 29
 	}
31 30
 }
32
-?>
33 31
\ No newline at end of file
32
+?>
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,32 @@
1
+<?php
2
+ini_set('display_errors', 0);
3
+ini_set('display_startup_errors', 0);
4
+error_reporting(-1);
5
+
6
+define("_BASEDIR", "../");
7
+define("_CHARSET", "utf-8");
8
+
9
+include("../config.php");
10
+include("../includes/dbfunctions.php");
11
+list($tableprefix, $language) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
12
+define("TABLEPREFIX", $tableprefix);
13
+if(file_exists(_BASEDIR."languages/{$language}.php")) include (_BASEDIR."languages/{$language}.php");
14
+else include (_BASEDIR."languages/en.php");
15
+include("../includes/queries.php");
16
+
17
+header("Content-Type: text/html; charset="._CHARSET);
18
+
19
+$users = dbquery("SELECT "._UIDFIELD." as uid, "._PENNAMEFIELD." as username FROM "._AUTHORTABLE." WHERE LOWER(".
20
+	_PENNAMEFIELD.") LIKE \"".escapestring($_GET['str'])."%\" ORDER BY username ASC limit 10");
21
+echo "var element = '".$_GET['element']."';\n";
22
+while($u = dbassoc($users)) {
23
+	$userlist[$u['uid']] = $u['username'];
24
+}
25
+if(count($userlist) > 0) {
26
+	$x = 0;
27
+	foreach($userlist as $k => $v) {
28
+		echo "userList[$x] =  new Array('$k','$v');\n";
29
+		$x++;
30
+	}
31
+}
32
+?>
0 33
\ No newline at end of file