Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

PHP-Fusion doesn't set character set in MySQL

PHP-Fusion is not setting character set in MySQL which is resulting in non-working unicode characters. You can reproduce problem easily:
1.) Set your default character set in MySQL to, for example, UTF-8
2.) Create database for PHP-Fusion in encoding different from UTF-8 (for example, cp1250)
3.) Install PHP-Fusion useing locale with encoding different from UTF-8 (for example, cp1250)
4.) You will get PHP-Fusion installation with broken unicode.

This bug can be very easily fixed by calling this SQL query right after mysql_select_db():
$result = @mysql_query("SET CHARACTER SET 'cp1250'"wink;

Of course you need to set right encoding depending on locale encoding.
Sending patch for maincore.php for PHP-Fusion version 6.01.15 :


--- maincore.php 2007-10-31 19:39:00.000000000 +0100
+++ maincore.php_ok 2008-05-21 21:52:12.000000000 +0200
@@ -132,6 +132,7 @@
}

function dbconnect($db_host, $db_user, $db_pass, $db_name) {
+ global $locale;
$db_connect = @mysql_connect($db_host, $db_user, $db_pass);
$db_select = @mysql_select_db($db_name);
if (!$db_connect) {
@@ -141,11 +142,23 @@
}
}

+function dbset_charset($charset) {
+ $charset = strtolower($charset);
+ // We need to do some conversions, just add new if needed
+ if ($charset == 'windows-1250'wink {
+ $charset = 'cp1250';
+ }
+ dbquery("SET CHARACTER SET '" . $charset . "'"wink;
+}
+
// Initialise the $locale array
$locale = array();
// Load the Global language file
include LOCALE.LOCALESET."global.php";

+// Setting the database character set
+dbset_charset($locale['charset']);
+
// Check if users full or partial ip is blacklisted
$sub_ip1 = substr(USER_IP,0,strlen(USER_IP)-strlen(strrchr(USER_IP,"."wink));
$sub_ip2 = substr($sub_ip1,0,strlen($sub_ip1)-strlen(strrchr($sub_ip1,"."wink));
@@ -632,4 +645,4 @@
define("iAUTH", substr($userdata['user_password'],16,32));
$aidlink = "?aid=".iAUTH;
}
-?>
\ No newline at end of file
+?>
Sending patch for setup.php for PHP-Fusion version 6.01.15 :

--- setup.php 2008-04-21 22:29:00.000000000 +0200
+++ setup.php_ok 2008-05-21 21:54:53.000000000 +0200
@@ -86,15 +86,29 @@
}

function dbconnect($db_host, $db_user, $db_pass, $db_name) {
+ global $locale;
$db_connect = @mysql_connect($db_host, $db_user, $db_pass);
$db_select = @mysql_select_db($db_name);
if (!$db_connect) {
die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to establish connection to MySQL</b><br>".mysql_errno()." : ".mysql_error()."</div>"wink;
} elseif (!$db_select) {
die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to select MySQL database</b><br>".mysql_errno()." : ".mysql_error()."</div>"wink;
+ } else {
+ // Setting the database character set
+ dbset_charset($locale['charset']);
}
}

+function dbset_charset($charset) {
+ $charset = strtolower($charset);
+ // We need to do some conversions, just add new if needed
+ if ($charset == 'windows-1250'wink {
+ $charset = 'cp1250';
+ }
+ dbquery("SET CHARACTER SET '" . $charset . "'"wink;
+}
+
+
// Strip Input Function, prevents HTML in unwanted places
function stripinput($text) {
if (ini_get('magic_quotes_gpc'wink) $text = stripslashes($text);
@@ -881,4 +895,4 @@
}

echo "</table>\n</body>\n</html>\n";
-?>
\ No newline at end of file
+?>
Sorry for posting them here but i wasn't able to add them as attachment. When they will be included ? Thnaks.
it's really sad that no one is interested in fixing this serious bug. i even created and post patches..
Thread Information
Author
Replies
5 posts
Views
3245 times
Last Post
Last updated on 12 years ago
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.