* Errors before the database connection has been made
*/
function startUpError($msg, $title) {
+ if (!defined('_CHARSET')) {
+ define('_CHARSET', 'UTF-8');
+ }
+ if (!defined('_HTML_XML_NAME_SPACE_AND_LANG_CODE')) {
+ define('_HTML_XML_NAME_SPACE_AND_LANG_CODE', 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us"');
+ }
+ sendContentType('text/html','',_CHARSET);
?>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head><title><?php echo htmlspecialchars($title)?></title></head>
- <body>
- <h1><?php echo htmlspecialchars($title)?></h1>
- <?php echo $msg?>
- </body>
- </html>
- <?php exit;
+<html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
+ <head><meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET?>" />
+ <title><?php echo htmlspecialchars($title,ENT_QUOTES)?></title></head>
+ <body>
+ <h1><?php echo htmlspecialchars($title,ENT_QUOTES)?></h1>
+ <?php echo $msg?>
+ </body>
+</html>
+<?php
+ exit;
}
/**
// <add for garble measure>
if (strpos($MYSQL_HANDLER[1], 'mysql') === 0) {
- $resource = $SQL_DBH->query("show variables LIKE 'character_set_database'");
- $resource->bindColumn('Value', $charset);
- $resource->fetchAll();
- $SQL_DBH->exec("SET CHARACTER SET " . $charset);
+ if (defined(_CHARSET)){
+ $charset = _CHARSET;
+ }else{
+ $resource = $SQL_DBH->query("show variables LIKE 'character_set_database'");
+ $resource->bindColumn('Value', $charset);
+ $resource->fetchAll();
+ // in trouble of encoding,uncomment the following line.
+ // $charset = "ujis";
+ // $charset = "utf8";
+ }
+ sql_set_charset_jp($charset);
}
// </add for garble measure>*/
} catch (PDOException $e) {
*******************************************************************/
- /**
- * for JP installer only
- */
- function at_sql_query($query,$dbh=NULL) {
- global $SQLCount,$SQL_DBH;
- $SQLCount++;
- if (is_null($dbh)) $res = $SQL_DBH->query($query);
- else $res = $dbh->query($query);
-/* if ($res->errorCode() != '00000') {
- $errors = $res->errorInfo();
- print("SQL error with query $query: " . $errors[0].'-'.$errors[1].' '.$errors[2] . '<p />');
+ /*
+ * for preventing I/O strings from auto-detecting the charactor encodings by MySQL
+ * since 3.62_beta-jp
+ * Jan.20, 2011 by kotorisan and cacher
+ * refering to their conversation below,
+ * http://japan.nucleuscms.org/bb/viewtopic.php?p=26581
+ *
+ * NOTE: shift_jis is only supported for output. Using shift_jis in DB is prohibited.
+ * NOTE: iso-8859-x,windows-125x if _CHARSET is unset.
+ */
+ function sql_set_charset_jp($charset) {
+ global $MYSQL_HANDLER,$SQL_DBH;
+ if (strpos($MYSQL_HANDLER[1], 'mysql') === 0) {
+ switch(strtolower($charset)){\r
+ case 'utf-8':\r
+ $charset = 'utf8';\r
+ break;\r
+ case 'euc-jp':\r
+ $charset = 'ujis';\r
+ break;\r
+ case 'gb2312':\r
+ $charset = 'gb2312';\r
+ break;\r
+ case 'shift_jis':\r
+ $charset = 'sjis';\r
+ break;\r
+ default:\r
+ break;\r
+ }
+ $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));
+ if (version_compare($mySqlVer, '4.1.0', '>=')) {
+ $res = $SQL_DBH->exec("SET CHARACTER SET " . $charset);
+ }
}
-*/
return $res;
}
}