From df70fa0ea904e3c696559ca178099b86e80c091a Mon Sep 17 00:00:00 2001 From: sakamocchi Date: Thu, 13 Jan 2011 15:03:27 +0000 Subject: [PATCH 1/1] Update install process according to Cacher's work. Now the auto-detecting function (3 ways) of install script does not generate error messages if failed. git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@1087 1ca29b6e-896d-4ea0-84a5-967f57386b96 --- utf8/install/index.php | 48 ++++++++++++++++++--------------- utf8/install/install_lang_japanese.php | 12 ++++----- utf8/nucleus/language/english-utf8.php | 4 +-- utf8/nucleus/language/english.php | 4 +-- utf8/nucleus/language/japanese-euc.php | 4 +-- utf8/nucleus/language/japanese-utf8.php | 4 +-- utf8/nucleus/libs/sql/mysql.php | 17 +++++++++--- utf8/nucleus/libs/sql/pdo.php | 20 +++++++++++--- 8 files changed, 71 insertions(+), 42 deletions(-) diff --git a/utf8/install/index.php b/utf8/install/index.php index 4352010..16df611 100755 --- a/utf8/install/index.php +++ b/utf8/install/index.php @@ -1,7 +1,7 @@
If you see this text in your browser when you open install.php, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there.
If you see this text in your browser when you open /install/, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there.
' . _TEXT2_WARN3 . ''; } - - echo "\n"; - /* +?> + + +
  • MySQL: + +MySQL\n"; $conn = sql_connect_args('localhost','',''); - $result = @sql_query('SELECT VERSION() AS version', $conn); - + $result = @at_sql_query('SELECT VERSION() AS version', $conn); if ($result != FALSE && sql_num_rows($result) > 0) { $row = sql_fetch_array($result); $match = explode('.', $row['version']); } else { - $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn); - + $result = @at_sql_query('SHOW VARIABLES LIKE \'version\'', $conn); if ($result != FALSE && @sql_num_rows($result) > 0) { $row = sql_fetch_row($result); $match = explode('.', $row[1]); @@ -202,22 +202,27 @@ function showInstallForm() { } } } + sql_disconnect($conn); $mysqlVersion = implode($match, '.'); $minVersion = '3.23'; + if ($mysqlVersion == '0.0.0') { echo _NOTIFICATION1; } else { echo $mysqlVersion; } + if ($mysqlVersion < $minVersion) { echo ' ' . sprintf(_TEXT2_WARN2, $minVersion) . ''; } - echo "
  • \n"; - */ - echo "\n"; +?> + + + + @@ -591,12 +596,13 @@ function doInstall() { // // 2-2. set DEFAULT CHARSET and COLLATE $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info($MYSQL_CONN)))); - if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') { +// if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {//} + if ($mySqlVer >= '5.0.7' && function_exists('mysql_set_charset')) { mysql_set_charset($charset); } elseif ($mySqlVer >= '4.1.0') { - sql_query("SET NAMES " . $charset); + sql_query("SET CHARACTER SET " . $charset); } - $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci'; + $collation = ($charset == 'utf8') ? 'utf8_general_ci' : 'ujis_japanese_ci'; // */ // 3. try to create database (if needed) @@ -695,7 +701,7 @@ function doInstall() { } // 5a make first post - if ($charset == 'ujis') { + if (strtoupper(_CHARSET) != 'UTF-8') { $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8'); $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8'); $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8'); @@ -752,7 +758,7 @@ function doInstall() { sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) ); // 8-2. update category settings - if ($charset == 'ujis') { + if (strtoupper(_CHARSET) != 'UTF-8') { $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8'); $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8'); } else { diff --git a/utf8/install/install_lang_japanese.php b/utf8/install/install_lang_japanese.php index 8cd5646..a6b11e5 100644 --- a/utf8/install/install_lang_japanese.php +++ b/utf8/install/install_lang_japanese.php @@ -1,7 +1,7 @@ ウェブサーバから /install/ ディレクトリを削除してください:

    '); define('_TEXT15_L1', 'install/install.sql:テーブルの構造を内包するファイル'); define('_TEXT15_L2', 'install/index.php:このファイル'); - -define('_TEXT15_L3', 'install_lang_japanese.php:インストーラの言語ファイル'); +//define('_TEXT15_L3', 'install_lang_japanese.php:インストーラの言語ファイル'); +define('_TEXT15_L3', 'install/install_lang_japanese.php:インストーラの言語ファイル'); define('_TEXT16', '

    もしこのディレクトリを削除していなければ、管理領域を開くことができません。

    '); define('_HEADER11', 'ウェブサイトの確認'); @@ -161,8 +161,8 @@ define('_BUTTON1', 'インストールを実行する'); // General category define('_GENERALCAT_NAME', '総合'); define('_GENERALCAT_DESC', '投稿した記事に合うカテゴリが無い時にこのカテゴリを使用すると良いでしょう'); - -define('_1ST_POST_TITLE', 'Nucleus CMS バージョン3.51へようこそ'); +//define('_1ST_POST_TITLE', 'Nucleus CMS バージョン3.51へようこそ'); +define('_1ST_POST_TITLE', 'Nucleus CMS バージョン3.62へようこそ'); define('_1ST_POST', 'ウェブサイトの作成を補助する積み木がここにあります。それは心躍るブログになるかもしれませんし、見る人を和ませる家族のサイトになるかもしれませんし、実り多い趣味のサイトになるかもしれません。あるいは現在のあなたには想像がつかないものになることだってあるでしょう。

    用途が思いつきませんでしたか? それならここへ来て正解です。なぜならあなた同様私たちにもわからないのですから。'); define('_1ST_POST2', 'これはサイトにおける最初のエントリーです。スタートを切りやすいように、リンクと情報を入れておきました。
    diff --git a/utf8/nucleus/language/english-utf8.php b/utf8/nucleus/language/english-utf8.php index 48a9020..54d7e38 100644 --- a/utf8/nucleus/language/english-utf8.php +++ b/utf8/nucleus/language/english-utf8.php @@ -206,9 +206,9 @@ define('_ITEM_ADDEDITTEMPLATE_HOUR', 'Hour'); define('_ITEM_ADDEDITTEMPLATE_MINUTE', 'Minute'); // Errors -define('_ERRORS_INSTALLSQL', 'install.sql should be deleted'); +define('_ERRORS_INSTALLSQL', 'install/install.sql should be deleted'); define('_ERRORS_INSTALLDIR', 'install directory should be deleted'); // -define('_ERRORS_INSTALLPHP', 'install.php should be deleted'); +define('_ERRORS_INSTALLPHP', 'install/index.php should be deleted'); define('_ERRORS_UPGRADESDIR', 'nucleus/upgrades directory should be deleted'); define('_ERRORS_CONVERTDIR', 'nucleus/convert directory should be deleted'); define('_ERRORS_CONFIGPHP', 'config.php should be non-writable (chmod to 444)'); diff --git a/utf8/nucleus/language/english.php b/utf8/nucleus/language/english.php index 1b59ef8..28e4476 100755 --- a/utf8/nucleus/language/english.php +++ b/utf8/nucleus/language/english.php @@ -212,9 +212,9 @@ define('_ITEM_ADDEDITTEMPLATE_HOUR', 'Hour'); define('_ITEM_ADDEDITTEMPLATE_MINUTE', 'Minute'); // Errors -define('_ERRORS_INSTALLSQL', 'install.sql should be deleted'); +define('_ERRORS_INSTALLSQL', 'install/install.sql should be deleted'); define('_ERRORS_INSTALLDIR', 'install directory should be deleted'); // -define('_ERRORS_INSTALLPHP', 'install.php should be deleted'); +define('_ERRORS_INSTALLPHP', 'install/index.php should be deleted'); define('_ERRORS_UPGRADESDIR', 'nucleus/upgrades directory should be deleted'); define('_ERRORS_CONVERTDIR', 'nucleus/convert directory should be deleted'); define('_ERRORS_CONFIGPHP', 'config.php should be non-writable (chmod to 444)'); diff --git a/utf8/nucleus/language/japanese-euc.php b/utf8/nucleus/language/japanese-euc.php index dfad4c3..87e947d 100644 --- a/utf8/nucleus/language/japanese-euc.php +++ b/utf8/nucleus/language/japanese-euc.php @@ -208,9 +208,9 @@ define('_ITEM_ADDEDITTEMPLATE_HOUR', ' define('_ITEM_ADDEDITTEMPLATE_MINUTE', 'ʬ'); // Errors -define('_ERRORS_INSTALLSQL', 'Ž¢install.sqlŽ£¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); +define('_ERRORS_INSTALLSQL', 'Ž¢install/install.sqlŽ£¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); define('_ERRORS_INSTALLDIR', 'Ž¢installŽ£¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); // -define('_ERRORS_INSTALLPHP', 'Ž¢install.phpŽ£¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); +define('_ERRORS_INSTALLPHP', 'Ž¢install/index.phpŽ£¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); define('_ERRORS_UPGRADESDIR', 'Ž¢nucleus/upgradesŽ£¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); define('_ERRORS_CONVERTDIR', 'Ž¢nucleus/convertŽ£¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤'); define('_ERRORS_CONFIGPHP', 'Ž¢config.phpŽ£¥Õ¥¡¥¤¥ë¤òÆɤ߼è¤êÀìÍÑ(Ž¢chmod 444Ž£Åù)¤Ë¤·¤Æ¤¯¤À¤µ¤¤'); diff --git a/utf8/nucleus/language/japanese-utf8.php b/utf8/nucleus/language/japanese-utf8.php index f1e75b6..21f5fee 100755 --- a/utf8/nucleus/language/japanese-utf8.php +++ b/utf8/nucleus/language/japanese-utf8.php @@ -214,9 +214,9 @@ define('_ITEM_ADDEDITTEMPLATE_HOUR', '時'); define('_ITEM_ADDEDITTEMPLATE_MINUTE', '分'); // Errors -define('_ERRORS_INSTALLSQL', 'ï½¢install.sql」ファイルを削除してください'); +define('_ERRORS_INSTALLSQL', 'ï½¢install/install.sql」ファイルを削除してください'); define('_ERRORS_INSTALLDIR', 'ï½¢install」ディレクトリを削除してください'); // -define('_ERRORS_INSTALLPHP', 'ï½¢install.php」ファイルを削除してください'); +define('_ERRORS_INSTALLPHP', 'ï½¢install/index.php」ファイルを削除してください'); define('_ERRORS_UPGRADESDIR', 'ï½¢nucleus/upgrades」ディレクトリを削除してください'); define('_ERRORS_CONVERTDIR', 'ï½¢nucleus/convert」ディレクトリを削除してください'); define('_ERRORS_CONFIGPHP', 'ï½¢config.php」ファイルを読み取り専用(ï½¢chmod 444」等)にしてください'); diff --git a/utf8/nucleus/libs/sql/mysql.php b/utf8/nucleus/libs/sql/mysql.php index a9fdc4c..f41b601 100755 --- a/utf8/nucleus/libs/sql/mysql.php +++ b/utf8/nucleus/libs/sql/mysql.php @@ -2,7 +2,7 @@ /* * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) - * Copyright (C) 2002-2010 The Nucleus Group + * Copyright (C) 2002-2011 The Nucleus Group * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -12,7 +12,7 @@ */ /** * @license http://nucleuscms.org/license.txt GNU General Public License - * @copyright Copyright (C) 2002-2010 The Nucleus Group + * @copyright Copyright (C) 2002-2011 The Nucleus Group * @version $Id$ */ @@ -68,7 +68,7 @@ if (function_exists('mysql_query') && !function_exists('sql_fetch_assoc')) $fetchDat = sql_fetch_assoc($resource); $charset = $fetchDat['Value']; $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info($MYSQL_CONN)))); - if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') { + if ($mySqlVer >= '5.0.7' && function_exists('mysql_set_charset')) { mysql_set_charset($charset); } elseif ($mySqlVer >= '4.1.0') { sql_query("SET CHARACTER SET " . $charset); @@ -335,6 +335,15 @@ if (function_exists('mysql_query') && !function_exists('sql_fetch_assoc')) *******************************************************************/ - + /** + * for JP installer only + */ + function at_sql_query($query, $conn = false) { + global $SQLCount,$MYSQL_CONN; + if (!$conn) $conn = $MYSQL_CONN; + $SQLCount++; + $res = mysql_query($query,$conn); + return $res; + } } ?> \ No newline at end of file diff --git a/utf8/nucleus/libs/sql/pdo.php b/utf8/nucleus/libs/sql/pdo.php index 69e3ca9..8d47de2 100755 --- a/utf8/nucleus/libs/sql/pdo.php +++ b/utf8/nucleus/libs/sql/pdo.php @@ -2,7 +2,7 @@ /* * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) - * Copyright (C) 2002-2010 The Nucleus Group + * Copyright (C) 2002-2011 The Nucleus Group * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -12,7 +12,7 @@ */ /** * @license http://nucleuscms.org/license.txt GNU General Public License - * @copyright Copyright (C) 2002-2010 The Nucleus Group + * @copyright Copyright (C) 2002-2011 The Nucleus Group * @version $Id$ */ @@ -581,6 +581,20 @@ if (!function_exists('sql_fetch_assoc')) *******************************************************************/ - + /** + * 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] . '

    '); + } +*/ + return $res; + } } ?> \ No newline at end of file -- 2.11.0