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
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

--- a/docs/config.php
+++ b/docs/config.php
@@ -6,5 +6,6 @@
 $sitekey = "";
 $settingsprefix = "settings";
 
+include("includes/dbfunctions.php");
 ?>
 

--- a/includes/browsecategories.php
+++ b/includes/browsecategories.php
@@ -1,7 +1,6 @@
 <?php
 define("_BASEDIR", "../");
 include("../config.php");
-include("../includes/dbfunctions.php");
 list($tableprefix) = dbrow(dbquery("SELECT tableprefix FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
 define("TABLEPREFIX", $tableprefix);
 include("../includes/queries.php");
@@ -23,3 +22,4 @@
 	$x++;
 }
 ?>
+

--- a/includes/categorylist.php
+++ b/includes/categorylist.php
@@ -3,7 +3,6 @@
 define("_CHARSET", "utf-8");
 
 include("../config.php");
-include("../includes/dbfunctions.php");
  
 
 list($tableprefix, $lang) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));

--- a/includes/characterlist.php
+++ b/includes/characterlist.php
@@ -1,7 +1,6 @@
 <?php
 define("_BASEDIR", "../");
 include("../config.php");
-include("../includes/dbfunctions.php");
 list($tableprefix, $lang) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
 define("TABLEPREFIX", $tableprefix);
 include(_BASEDIR."languages/$lang.php");

--- a/includes/userlist.php
+++ b/includes/userlist.php
@@ -7,7 +7,6 @@
 define("_CHARSET", "utf-8");
 
 include("../config.php");
-include("../includes/dbfunctions.php");
 list($tableprefix, $language) = dbrow(dbquery("SELECT tableprefix, language FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'"));
 define("TABLEPREFIX", $tableprefix);
 if(file_exists(_BASEDIR."languages/{$language}.php")) include (_BASEDIR."languages/{$language}.php");
@@ -30,3 +29,4 @@
 	}
 }
 ?>
+

--- a/install/install.php
+++ b/install/install.php
@@ -112,7 +112,6 @@
 else
 {
 	include("../config.php");
-	include("../includes/dbfunctions.php");
 
 	$dbconnect = dbconnect($dbhost, $dbuser, $dbpass, $dbname);
 	$settings = dbquery("SELECT tableprefix, language FROM " . $settingsprefix . "fanfiction_settings WHERE sitekey = '" . $sitekey . "'");
@@ -849,11 +848,8 @@
 
 	case "2";
 		include("../config.php");
-		include("../includes/dbfunctions.php");
 		if (dbnumrows(dbquery("SHOW TABLES LIKE '" . $settingsprefix . "fanfiction_settings'")))
 		{
-			//include("../config.php");
-			//include("../includes/dbfunctions.php");
 			$dbconnect = dbconnect($dbhost, $dbuser, $dbpass, $dbname);
 			$settings = dbquery("SELECT tableprefix, language FROM " . $settingsprefix . "fanfiction_settings WHERE sitekey = '" . $sitekey . "'");
 			list($tableprefix, $language) = dbrow($settings);
@@ -1037,6 +1033,7 @@
 \$sitekey = \"$sitekey\";
 \$settingsprefix = \"$settingsprefix\";
 
+include(\"includes/dbfunctions.php\");
 ?>";
 
 /* removed in 3.5.8 and moved to file: 
@@ -1055,7 +1052,6 @@
 		{
 			if (file_exists("../config.php") && !isset($mysqli_access)) {
 				include("../config.php");
-				include("../includes/dbfunctions.php");
 			}
 			if (isset($tinyMCE)) $output .= write_message(_CONFIG2DETECTED);
 			else if (isset($sitename) && $sitename) $output .= write_message(_CONFIG1DETECTED);

--- a/user/login.php
+++ b/user/login.php
@@ -26,7 +26,6 @@
 		if(!defined("_LOGINCHECK")) exit( );
 		define("_BASEDIR", "");
 		include_once("config.php");
-		include(_BASEDIR . "includes/dbfunctions.php");
 		$settings = dbquery("SELECT tableprefix, maintenance, sitekey, debug FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
 		list($tableprefix, $maintenance, $sitekey, $debug) = dbrow($settings);
 		$tempdebug = $debug;