Browse code

admin/backup.php, admin/backup_utf8.php, includes/get_session_vars.php: changes to database backup behavior - deprecations fix, revert encode in utf8 variant... also apparently get_session_vars fatals with the backup tools when using isNumber, so is_int is used instead

Clarissa Walker authored on 2026/11/07 12:50:22
Showing 3 changed files
... ...
@@ -28,8 +28,8 @@ include("../config.php");
28 28
 $settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
29 29
 $settings = dbassoc($settingsresults);
30 30
 foreach($settings as $var => $val) {
31
-	$$var = stripslashes($val);
32
-	$settings[$var] = htmlspecialchars($val);
31
+	$$var = stripslashes(isset($val) ? $val : '');
32
+	$settings[$var] = htmlspecialchars(isset($val) ? $val : '');
33 33
 }
34 34
 if(!defined("SITEKEY")) define("SITEKEY", $settings['sitekey']);
35 35
 unset($settings['sitekey']);
... ...
@@ -30,8 +30,8 @@ include("../config.php");
30 30
 $settingsresults = dbquery("SELECT * FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
31 31
 $settings = dbassoc($settingsresults);
32 32
 foreach($settings as $var => $val) {
33
-	$$var = stripslashes($val);
34
-	$settings[$var] = htmlspecialchars($val);
33
+	$$var = stripslashes(isset($val) ? $val : '');
34
+	$settings[$var] = htmlspecialchars(isset($val) ? $val : '');
35 35
 }
36 36
 if(!defined("SITEKEY")) define("SITEKEY", $settings['sitekey']);
37 37
 unset($settings['sitekey']);
... ...
@@ -63,7 +63,8 @@ function datadump ($table) {
63 63
 		echo "INSERT INTO ".$table." ";
64 64
 		$row = array( );
65 65
 		foreach($t AS $field => $value) {
66
-			$value = utf8_encode (escapestring($value) );
66
+			$value = escapestring($value);
67
+			$value = mb_convert_encoding($value, 'UTF-8');
67 68
 			$value = str_replace("\n","\\n",$value);
68 69
 			if (isset($value)) $row[$field] = "\"$value\"";
69 70
 			else $row[$field] = "\"\"";
... ...
@@ -25,7 +25,7 @@
25 25
 if(!defined("_CHARSET")) exit( );
26 26
 // Get session variables from cookie data if not logged in.
27 27
 // To bridge to another program replace (or add to) this information with the bridge to your other script.  See examples in the includes/bridges/ folder.
28
-if (!empty($_COOKIE[$sitekey."_useruid"]) && isNumber($_COOKIE[$sitekey."_useruid"])) {
28
+if (!empty($_COOKIE[$sitekey."_useruid"]) && (is_int($_COOKIE[$sitekey."_useruid"]))) {
29 29
 	$userdata = dbassoc(dbquery("SELECT ap.*, "._UIDFIELD." as uid, "._PENNAMEFIELD." as penname, "._EMAILFIELD." as email, "._PASSWORDFIELD." as password FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '".$_COOKIE[$sitekey."_useruid"]."'"));
30 30
 	if($userdata && $userdata['level'] != -1 && $_COOKIE[$sitekey.'_salt'] == md5($userdata['email'] . $userdata['password'])) {
31 31
 		define("USERUID", $userdata['uid']);