Fix db encoding and setting it to UTF-8 (#112 #116)

This commit is contained in:
Tobias Reich 2014-04-06 15:11:55 +02:00
parent 44d44e04fd
commit 0059f5910f
4 changed files with 5 additions and 4 deletions

View File

@ -11,4 +11,4 @@ CREATE TABLE IF NOT EXISTS `lychee_albums` (
`visible` tinyint(1) NOT NULL DEFAULT '1',
`password` varchar(100) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

View File

@ -26,4 +26,4 @@ CREATE TABLE IF NOT EXISTS `lychee_photos` (
`album` varchar(30) NOT NULL DEFAULT '0',
`import_name` varchar(100) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

View File

@ -5,4 +5,4 @@
CREATE TABLE IF NOT EXISTS `lychee_settings` (
`key` varchar(50) NOT NULL DEFAULT '',
`value` varchar(200) DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

View File

@ -19,8 +19,9 @@ class Database extends Module {
# Check connection
if ($database->connect_errno) exit('Error: ' . $database->connect_error);
# Avoid sql injection on older MySQL versions
# Avoid sql injection on older MySQL versions by using GBK
if ($database->server_version<50500) $database->set_charset('GBK');
else $database->set_charset("utf8");
# Check database
if (!$database->select_db($name))