OSDN Git Service

Remove a needless variable from "sql_set_charset_jp " function in ./install/index...
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / install / index.php
index 16df611..9ea855a 100755 (executable)
@@ -8,8 +8,9 @@
  * as published by the Free Software Foundation; either version 2\r
  * of the License, or (at your option) any later version.\r
  * (see nucleus/documentation/index.html#license for more info)\r
- * This script will install the Nucleus tables in your SQL-database, and initialize the data in\r
- * those tables.\r
+ * \r
+ * This script will install the Nucleus tables in your SQL-database, \r
+ * and initialize the data in those tables.\r
  *\r
  * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.\r
  * ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>/install/</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php\r
@@ -71,6 +72,8 @@ if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
        $CONF['installscript'] = 1;\r
 }\r
 \r
+// compatibility script for php < 4.1.0\r
+// ToDo: remove this here and from the core\r
 if (phpversion() >= '4.1.0') {\r
        include_once('../nucleus/libs/vars4.1.0.php');\r
 } else {\r
@@ -103,6 +106,9 @@ if (postVar('action') == 'go') {
 \r
 exit;\r
 \r
+/*\r
+ * Show the form for the installation settings\r
+ */\r
 function showInstallForm() {\r
        // 0. pre check if all necessary files exist\r
        doCheckFiles();\r
@@ -131,7 +137,7 @@ function showInstallForm() {
                --></script>\r
        </head>\r
        <body>\r
-               <div style="text-align:center"><img src="../nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->\r
+               <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->\r
                <form method="post" action="index.php">\r
                \r
                <h1><?php echo _HEADER1; ?></h1>\r
@@ -163,36 +169,30 @@ function showInstallForm() {
                \r
                <ul>\r
                        <li>PHP:\r
-\r
 <?php\r
        echo phpversion();\r
-       $minVersion = '4.0.6';\r
-\r
-       if (phpversion() < $minVersion) {\r
-               echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN, $minVersion) . '</span>';\r
-       } elseif (phpversion() < '5') {\r
-               echo ' <span class="warning" style="display:block">' . _TEXT2_WARN3 . '</span>';\r
-       }\r
 ?>\r
-\r
                        </li>\r
                        <li>MySQL:\r
-\r
 <?php\r
+       // Turn on output buffer\r
+       // Needed to repress the output of the sql function that are\r
+       // not part of php (in this case the @ operator doesn't work) \r
+       ob_start();\r
        // note: this piece of code is taken from phpMyAdmin\r
        $conn   = sql_connect_args('localhost','','');\r
-       $result = @at_sql_query('SELECT VERSION() AS version', $conn);\r
+       $result = @sql_query('SELECT VERSION() AS version', $conn);\r
        if ($result != FALSE && sql_num_rows($result) > 0) {\r
                $row   = sql_fetch_array($result);\r
                $match = explode('.', $row['version']);\r
        } else {\r
-               $result = @at_sql_query('SHOW VARIABLES LIKE \'version\'', $conn);\r
+               $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);\r
                if ($result != FALSE && @sql_num_rows($result) > 0) {\r
                        $row   = sql_fetch_row($result);\r
                        $match = explode('.', $row[1]);\r
                } else {\r
                        $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';\r
-                       preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);\r
+                       preg_match('#[0-9]+\.[0-9]+\.[0-9]+#', $output, $version);\r
                        $match = explode('.', $version[0]);\r
 \r
                        if ($match[0] == '') {\r
@@ -202,27 +202,36 @@ function showInstallForm() {
                        }\r
                }\r
        }\r
-\r
-       sql_disconnect($conn);\r
-       $mysqlVersion = implode($match, '.');\r
+       @sql_disconnect($conn);\r
+       //End and clean output buffer\r
+       ob_end_clean();\r
+       $mySqlVersion = implode($match, '.');\r
        $minVersion   = '3.23';\r
-\r
-       if ($mysqlVersion == '0.0.0') {\r
+       \r
+       if (version_compare($mySqlVersion, '0.0.0', '==')) {\r
                echo _NOTIFICATION1;\r
        }\r
        else {\r
-               echo $mysqlVersion;\r
+               echo $mySqlVersion;\r
        }\r
 \r
-       if ($mysqlVersion < $minVersion) {\r
-               echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN2, $minVersion) . '</span>';\r
+       if (version_compare($mySqlVersion, $minVersion, '<')) {\r
+               echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN1, $minVersion) . '</span>';\r
        }\r
 ?>\r
-\r
                        </li>\r
                </ul>\r
-\r
 <?php\r
+       if (phpversion() < '5.0.0') {\r
+               echo ' <p class="deprecated">' . _TEXT2_WARN2 . '</p>';\r
+?>\r
+</form>\r
+</body>\r
+</html>\r
+<?php\r
+               exit;\r
+       }\r
+\r
        // tell people how they can have their config file filled out automatically\r
        if (@file_exists('../config.php') && @!is_writable('../config.php')) {\r
 ?>\r
@@ -241,20 +250,20 @@ function showInstallForm() {
                        <legend><?php echo _TEXT4_TAB_HEAD; ?></legend>\r
                        <table>\r
                                <tr>\r
-                                       <td><?php echo _TEXT4_TAB_FIELD1; ?></td>\r
-                                       <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" tabindex="10010" /></td>\r
+                                       <td><label for="if_mySQL_host"><?php echo _TEXT4_TAB_FIELD1; ?>:</label></td>\r
+                                       <td><input id="if_mySQL_host" name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" tabindex="10010" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT4_TAB_FIELD2; ?></td>\r
-                                       <td><input name="mySQL_user" tabindex="10020" /></td>\r
+                                       <td><label for="if_mySQL_user"><?php echo _TEXT4_TAB_FIELD2; ?>:</label></td>\r
+                                       <td><input id="if_mySQL_user" name="mySQL_user" tabindex="10020" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT4_TAB_FIELD3; ?></td>\r
-                                       <td><input name="mySQL_password" type="password" tabindex="10030" /></td>\r
+                                       <td><label for="if_mySQL_password"><?php echo _TEXT4_TAB_FIELD3; ?>:</label></td>\r
+                                       <td><input id="if_mySQL_password" name="mySQL_password" type="password" tabindex="10030" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT4_TAB_FIELD4; ?></td>\r
-                                       <td><input name="mySQL_database" tabindex="10040" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create" tabindex="10050" /><label for="mySQL_create"><?php echo _TEXT4_TAB_FIELD4_ADD; ?></label>)</td>\r
+                                       <td><label for="if_mySQL_database"><?php echo _TEXT4_TAB_FIELD4; ?>:</label></td>\r
+                                       <td><input id="if_mySQL_database" name="mySQL_database" tabindex="10040" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create" tabindex="10050" /><label for="mySQL_create"><?php echo _TEXT4_TAB_FIELD4_ADD; ?></label>)</td>\r
                                </tr>\r
                        </table>\r
                </fieldset>\r
@@ -263,7 +272,7 @@ function showInstallForm() {
                        <legend><?php echo _TEXT4_TAB2_HEAD; ?></legend>\r
                        <table>\r
                                <tr>\r
-                                       <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix" tabindex="10060" /><label for="mySQL_usePrefix"><?php echo _TEXT4_TAB2_FIELD; ?></label></td>\r
+                                       <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix" tabindex="10060" /><label for="mySQL_usePrefix"><?php echo _TEXT4_TAB2_FIELD; ?>:</label></td>\r
                                        <td><input name="mySQL_tablePrefix" value="" tabindex="10070" /></td>\r
                                </tr>\r
                        </table>\r
@@ -304,8 +313,8 @@ function showInstallForm() {
                        <legend><?php echo _TEXT5_TAB_HEAD; ?></legend>\r
                        <table>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD1; ?></td>\r
-                                       <td><input name="IndexURL" size="60" value="<?php\r
+                                       <td><label for="if_IndexURL"><?php echo _TEXT5_TAB_FIELD1;?>:</label></td>\r
+                                       <td><input id="if_IndexURL" name="IndexURL" size="60" value="<?php\r
                                                $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');\r
                                                $url = str_replace('install/index.php', '', $url);\r
                                                $url = replaceDoubleBackslash($url);\r
@@ -318,36 +327,36 @@ function showInstallForm() {
                                                echo $url; ?>" tabindex="10080" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD2; ?></td>\r
-                                       <td><input name="AdminURL" size="60" value="<?php\r
+                                       <td><label for="if_AdminURL"><?php echo _TEXT5_TAB_FIELD2;?>:</label></td>\r
+                                       <td><input id="if_AdminURL" name="AdminURL" size="60" value="<?php\r
                                                if ($url) {\r
                                                        echo $url . 'nucleus/';\r
                                                } ?>" tabindex="10090" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD3; ?></td>\r
-                                       <td><input name="AdminPath" size="60" value="<?php\r
+                                       <td><label for="if_AdminPath"><?php echo _TEXT5_TAB_FIELD3;?>:</label></td>\r
+                                       <td><input id="if_AdminPath" name="AdminPath" size="60" value="<?php\r
                                                if($basePath) {\r
                                                        echo $basePath . 'nucleus/';\r
                                                } ?>" tabindex="10100" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD4; ?></td>\r
-                                       <td><input name="MediaURL" size="60" value="<?php\r
+                                       <td><label for="if_MediaURL"><?php echo _TEXT5_TAB_FIELD4;?>:</label></td>\r
+                                       <td><input id="if_MediaURL" name="MediaURL" size="60" value="<?php\r
                                                if ($url) {\r
                                                        echo $url . 'media/';\r
                                                } ?>" tabindex="10110" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD5; ?></td>\r
-                                       <td><input name="MediaPath" size="60" value="<?php\r
+                                       <td><label for="if_MediaPath"><?php echo _TEXT5_TAB_FIELD5;?>:</label></td>\r
+                                       <td><input id="if_MediaPath" name="MediaPath" size="60" value="<?php\r
                                                if ($basePath) {\r
                                                        echo $basePath . 'media/';\r
                                                } ?>" tabindex="10120" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD6; ?></td>\r
-                                       <td><input name="SkinsURL" size="60" value="<?php\r
+                                       <td><label for="if_SkinsURL"><?php echo _TEXT5_TAB_FIELD6;?>:</label></td>\r
+                                       <td><input id="if_SkinsURL" name="SkinsURL" size="60" value="<?php\r
                                                if ($url) {\r
                                                        echo $url . 'skins/';\r
                                                } ?>" tabindex="10130" />\r
@@ -355,8 +364,8 @@ function showInstallForm() {
                                        </td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD7; ?></td>\r
-                                       <td><input name="SkinsPath" size="60" value="<?php\r
+                                       <td><label for="if_SkinsPath"><?php echo _TEXT5_TAB_FIELD7;?>:</label></td>\r
+                                       <td><input id="if_SkinsPath" name="SkinsPath" size="60" value="<?php\r
                                                if ($basePath) {\r
                                                        echo $basePath . 'skins/';\r
                                                } ?>" tabindex="10140" />\r
@@ -364,15 +373,15 @@ function showInstallForm() {
                                        </td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD8; ?></td>\r
-                                       <td><input name="PluginURL" size="60" value="<?php\r
+                                       <td><label for="if_PluginURL"><?php echo _TEXT5_TAB_FIELD8;?>:</label></td>\r
+                                       <td><input id="if_PluginURL" name="PluginURL" size="60" value="<?php\r
                                                if ($url) {\r
                                                        echo $url . 'nucleus/plugins/';\r
                                                } ?>" tabindex="10150" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT5_TAB_FIELD9; ?></td>\r
-                                       <td><input name="ActionURL" size="60" value="<?php\r
+                                       <td><label for="if_ActionURL"><?php echo _TEXT5_TAB_FIELD9;?>:</label></td>\r
+                                       <td><input id="if_ActionURL" name="ActionURL" size="60" value="<?php\r
                                                if ($url) {\r
                                                        echo $url . 'action.php';\r
                                                } ?>" tabindex="10160" />\r
@@ -384,7 +393,7 @@ function showInstallForm() {
 \r
                <?php echo _TEXT5_2; ?>\r
 \r
-               <h1><? echo _HEADER6; ?></h1>\r
+               <h1><?php echo _HEADER6; ?></h1>\r
 \r
                <?php echo _TEXT6; ?>\r
 \r
@@ -392,24 +401,24 @@ function showInstallForm() {
                        <legend><?php echo _TEXT6_TAB_HEAD; ?></legend>\r
                        <table>\r
                                <tr>\r
-                                       <td><?php echo _TEXT6_TAB_FIELD1; ?></td>\r
-                                       <td><input name="User_name" value="" tabindex="10170" /> (<?php echo _TEXT6_TAB_FIELD1_2; ?>)</td>\r
+                                       <td><label for="if_User_name"><?php echo _TEXT6_TAB_FIELD1; ?>:</label></td>\r
+                                       <td><input id="if_User_name" name="User_name" value="" tabindex="10170" /> <small>(<?php echo _TEXT6_TAB_FIELD1_2; ?>)</small></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT6_TAB_FIELD2; ?></td>\r
-                                       <td><input name="User_realname" value="" tabindex="10180" /></td>\r
+                                       <td><label for="if_User_realname"><?php echo _TEXT6_TAB_FIELD2; ?>:</label></td>\r
+                                       <td><input id="if_User_realname" name="User_realname" value="" tabindex="10180" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT6_TAB_FIELD3; ?></td>\r
-                                       <td><input name="User_password" type="password" value="" tabindex="10190" /></td>\r
+                                       <td><label for="if_User_password"><?php echo _TEXT6_TAB_FIELD3; ?>:</label></td>\r
+                                       <td><input id="if_User_password" name="User_password" type="password" value="" tabindex="10190" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT6_TAB_FIELD4; ?></td>\r
-                                       <td><input name="User_password2" type="password" value="" tabindex="10200" /></td>\r
+                                       <td><label for="if_User_password2"><?php echo _TEXT6_TAB_FIELD4; ?>:</label></td>\r
+                                       <td><input id="if_User_password2" name="User_password2" type="password" value="" tabindex="10200" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT6_TAB_FIELD5; ?></td>\r
-                                       <td><input name="User_email" value="" tabindex="10210" /> (<?php echo _TEXT6_TAB_FIELD5_2; ?>)</td>\r
+                                       <td><label for="if_User_email"><?php echo _TEXT6_TAB_FIELD5; ?>:</label></td>\r
+                                       <td><input id="if_User_email" name="User_email" value="" tabindex="10210" /> <small>(<?php echo _TEXT6_TAB_FIELD5_2; ?>)</small></td>\r
                                </tr>\r
                        </table>\r
                </fieldset>\r
@@ -422,12 +431,12 @@ function showInstallForm() {
                        <legend><?php echo _TEXT7_TAB_HEAD; ?></legend>\r
                        <table>\r
                                <tr>\r
-                                       <td><?php echo _TEXT7_TAB_FIELD1; ?></td>\r
-                                       <td><input name="Blog_name" size="60" value="My Nucleus CMS" tabindex="10220" /></td>\r
+                                       <td><label for="if_Blog_name"><?php echo _TEXT7_TAB_FIELD1; ?>:</label></td>\r
+                                       <td><input id="if_Blog_name" name="Blog_name" size="60" value="My Nucleus CMS" tabindex="10220" /></td>\r
                                </tr>\r
                                <tr>\r
-                                       <td><?php echo _TEXT7_TAB_FIELD2; ?></td>\r
-                                       <td><input name="Blog_shortname" value="mynucleuscms" tabindex="10230" /> (<?php echo _TEXT7_TAB_FIELD2_2; ?>)</td>\r
+                                       <td><label for="if_Blog_shortname"><?php echo _TEXT7_TAB_FIELD2; ?>:</label></td>\r
+                                       <td><input id="if_Blog_shortname" name="Blog_shortname" value="mynucleuscms" tabindex="10230" /> <small>(<?php echo _TEXT7_TAB_FIELD2_2; ?>)</small></td>\r
                                </tr>\r
                        </table>\r
                </fieldset>\r
@@ -438,7 +447,7 @@ function showInstallForm() {
                        <legend><?php echo _TEXT8_TAB_HEADER; ?></legend>\r
                        <table>\r
                                <tr>\r
-                                       <td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" tabindex="10240" /><?php echo _TEXT8_TAB_FIELD1; ?></td>\r
+                                       <td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" tabindex="10240" /><label for="Weblog_ping"><?php echo _TEXT8_TAB_FIELD1; ?></label></td>\r
                                </tr>\r
                        </table>\r
                </fieldset>\r
@@ -458,6 +467,12 @@ function showInstallForm() {
 \r
 <?php }\r
 \r
+/*\r
+ * Add a table prefix if it is used\r
+ * \r
+ * @param      $unPrefixed\r
+ *                     table name with prefix\r
+ */\r
 function tableName($unPrefixed) {\r
        global $mysql_usePrefix, $mysql_prefix;\r
 \r
@@ -468,6 +483,9 @@ function tableName($unPrefixed) {
        }\r
 }\r
 \r
+/*\r
+ * The installation process itself\r
+ */\r
 function doInstall() {\r
        global $mysql_usePrefix, $mysql_prefix, $weblog_ping;\r
 \r
@@ -499,20 +517,9 @@ function doInstall() {
        $config_adminemail = $user_email;\r
        $config_sitename   = $blog_name;\r
        $weblog_ping       = postVar('Weblog_ping');\r
-\r
+       \r
        $_POST = array();\r
-       if (!extension_loaded('mbstring')) {\r
-               include('../nucleus/libs/mb_emulator/mb-emulator.php');\r
-       }\r
-       if ($charset == 'ujis') {\r
-               define('_CHARSET', 'EUC-JP');\r
-               $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');\r
-               $user_realname  = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');\r
-               $blog_name        = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');\r
-       } else {\r
-               define('_CHARSET', 'UTF-8');\r
-       }\r
-\r
+       \r
        $config_indexurl   = replaceDoubleBackslash($config_indexurl);\r
        $config_adminurl   = replaceDoubleBackslash($config_adminurl);\r
        $config_mediaurl   = replaceDoubleBackslash($config_mediaurl);\r
@@ -523,6 +530,29 @@ function doInstall() {
        $config_skinspath  = replaceDoubleBackslash($config_skinspath);\r
        $config_mediapath  = replaceDoubleBackslash($config_mediapath);\r
 \r
+/**\r
+ * Include and initialize multibyte functions as a replacement for mbstring extension\r
+ *  if mbstring extension is not loaded.\r
+ * Jan.28, 2011. Japanese Package Release Team\r
+ */ \r
+       if (!function_exists('mb_convert_encoding')){\r
+               global $mbemu_internals;\r
+               include_once($config_adminpath.'libs/mb_emulator/mb-emulator.php');\r
+       }\r
+       if (function_exists('date_default_timezone_set')){\r
+                @date_default_timezone_set((function_exists('date_default_timezone_get')) ? @date_default_timezone_get() : 'UTC');\r
+       }\r
+       \r
+       if ($charset == 'ujis') {\r
+               define('_CHARSET', 'EUC-JP');\r
+               $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');\r
+               $user_realname  = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');\r
+               $blog_name        = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');\r
+       } else {\r
+               define('_CHARSET', 'UTF-8');\r
+       }\r
+       \r
+       \r
        // 1. check all the data\r
        $errors = array();\r
 \r
@@ -534,7 +564,7 @@ function doInstall() {
                array_push($errors, _ERROR3);\r
        }\r
 \r
-       if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {\r
+       if (($mysql_usePrefix == 1) && (!preg_match('#^[a-zA-Z0-9_]+$#', $mysql_prefix) ) ) {\r
                array_push($errors, _ERROR4);\r
        }\r
 \r
@@ -583,7 +613,7 @@ function doInstall() {
                showErrorMessages($errors);\r
        }\r
 \r
-       // 2-1. try to log in to mySQL\r
+       // 2. try to log in to mySQL\r
 \r
        global $MYSQL_CONN;\r
        // this will need to be changed if we ever allow\r
@@ -593,24 +623,14 @@ function doInstall() {
                _doError(_ERROR15 . ': ' . sql_error() );\r
        }\r
 \r
-// <add for garble measure>\r
-       // 2-2. set DEFAULT CHARSET and COLLATE\r
-       $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info($MYSQL_CONN))));\r
-//     if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {//}\r
-       if ($mySqlVer >= '5.0.7' && function_exists('mysql_set_charset')) {\r
-               mysql_set_charset($charset);\r
-       } elseif ($mySqlVer >= '4.1.0') {\r
-               sql_query("SET CHARACTER SET " . $charset);\r
-       }\r
-       $collation = ($charset == 'utf8') ? 'utf8_general_ci' : 'ujis_japanese_ci';\r
-// </add for garble measure>*/\r
-\r
        // 3. try to create database (if needed)\r
+       $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));\r
+       $collation = ($charset == 'utf8') ? 'utf8_general_ci' : 'ujis_japanese_ci';\r
        if ($mysql_create == 1) {\r
                $sql = 'CREATE DATABASE '\r
                         .       $mysql_database;\r
 // <add for garble measure>\r
-       if ($mySqlVer >= '4.1.0') {\r
+       if (version_compare($mySqlVer, '4.1.0', '>=')) {\r
                $sql .= ' DEFAULT CHARACTER SET '\r
                          .      $charset\r
                          . ' COLLATE '\r
@@ -623,6 +643,13 @@ function doInstall() {
        // 4. try to select database\r
        sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17);\r
 \r
+       /*\r
+        * 4.5. set character set to this database in MySQL server\r
+        * This processing is added by Nucleus CMS Japanese Package Release Team as of Mar.30, 2011\r
+       */\r
+       sql_set_charset_jp($charset);\r
+       \r
+\r
        // 5. execute queries\r
        $filename = 'install.sql';\r
        $fd = fopen($filename, 'r');\r
@@ -691,7 +718,7 @@ function doInstall() {
                                        $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);\r
                        }\r
 // <add for garble measure>\r
-                       if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0 && $mySqlVer >= '4.1.0') {\r
+                       if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0 && version_compare($mySqlVer, '4.1.0', '>=')) {\r
                                $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;\r
                        }\r
 // </add for garble measure>*/\r
@@ -841,7 +868,7 @@ function doInstall() {
                $config_data .= "   \$MYSQL_DATABASE = '" . $mysql_database . "';\n";\r
                $config_data .= "   \$MYSQL_PREFIX   = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";\r
                $config_data .= "   // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";\r
-               $config_data .= "   // default is \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
+               $config_data .= "   // default is \$MYSQL_HANDLER = array('mysql','');\n";\r
                $config_data .= "   //\$MYSQL_HANDLER = array('mysql','mysql');\n";\r
                $config_data .= "   //\$MYSQL_HANDLER = array('pdo','mysql');\n";\r
                $config_data .= "   \$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";\r
@@ -863,9 +890,6 @@ function doInstall() {
                $config_data .= "\n";\r
                $config_data .= "   // include libs\n";\r
                $config_data .= "   include(\$DIR_LIBS . 'globalfunctions.php');\n";\r
-               $config_data .= "   if (!extension_loaded('mbstring')) {\n";\r
-               $config_data .= "          include(\$DIR_LIBS . 'mb_emulator/mb-emulator.php');\n";\r
-               $config_data .= "   }\n";\r
                $config_data .= "?" . ">";\r
 \r
                $result = @fputs($fp, $config_data, strlen($config_data) );\r
@@ -885,7 +909,7 @@ function doInstall() {
        <style>@import url('../nucleus/styles/manual.css');</style>\r
 </head>\r
 <body>\r
-       <div style='text-align:center'><img src='../nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
+       <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->\r
 \r
 <?php\r
        $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);\r
@@ -898,7 +922,7 @@ function doInstall() {
        if (!$bConfigWritten) { ?>\r
                <h1><?php echo _TITLE3; ?></h1>\r
 \r
-               <? echo _TEXT10; ?>\r
+               <?php echo _TEXT10; ?>\r
 \r
                <pre><code>&lt;?php\r
        // mySQL connection information\r
@@ -908,6 +932,10 @@ function doInstall() {
        $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';\r
        $MYSQL_PREFIX   = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';\r
 \r
+       // new in 3.50. first element is db handler, the second is the db driver used by the handler\r
+       // default is $MYSQL_HANDLER = array('mysql','');\r
+       $MYSQL_HANDLER = array('<?php echo $MYSQL_HANDLER[0];?>','<?php echo $MYSQL_HANDLER[1];?>');\r
+\r
        // main nucleus directory\r
        $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';\r
 \r
@@ -925,9 +953,6 @@ function doInstall() {
 \r
        // include libs\r
        include($DIR_LIBS . 'globalfunctions.php');\r
-       if (!extension_loaded('mbstring')) {\r
-               include($DIR_LIBS . 'mb_emulator/mb-emulator.php');\r
-       }\r
 ?&gt;</code></pre>\r
 \r
        <?php echo _TEXT11; ?>\r
@@ -980,6 +1005,9 @@ function doInstall() {
 <?php\r
 }\r
 \r
+/**\r
+ *  Install custom plugins\r
+ */\r
 function installCustomPlugs(&$manager) {\r
        global $aConfPlugsToInstall, $DIR_LIBS;\r
 \r
@@ -1034,6 +1062,10 @@ function installCustomPlugs(&$manager) {
        return $aErrors;\r
 }\r
 \r
+/**\r
+ *  Install custom skins\r
+ *  Prepares the installation of custom skins\r
+ */\r
 function installCustomSkins(&$manager) {\r
        global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;\r
 \r
@@ -1079,7 +1111,10 @@ function installCustomSkins(&$manager) {
        return $aErrors;\r
 }\r
 \r
-// give an error if one or more nucleus are not accessible\r
+/**\r
+ *  Check if some important files of the Nucleus CMS installation are available\r
+ *  Give an error if one or more files are not accessible\r
+ */\r
 function doCheckFiles() {\r
        $missingfiles = array();\r
        $files = array(\r
@@ -1109,17 +1144,19 @@ function doCheckFiles() {
                }\r
        }\r
 \r
-// The above code replaces several if statements of the form:\r
-\r
-//     if (!is_readable('install.sql') ) {\r
-//             array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');\r
-//     }\r
-\r
        if (count($missingfiles) > 0) {\r
                showErrorMessages($missingfiles);\r
        }\r
 }\r
 \r
+/**\r
+ *  Updates the configuration in the database\r
+ * \r
+ *  @param     $name\r
+ *                     name of the config var\r
+ *  @param     $val\r
+ *                     new value of the config var\r
+ */\r
 function updateConfig($name, $val) {\r
        global $MYSQL_CONN;\r
        $name = addslashes($name);\r
@@ -1133,49 +1170,81 @@ function updateConfig($name, $val) {
        return sql_insert_id($MYSQL_CONN);\r
 }\r
 \r
+/**\r
+ *  Replaces doubled backslashs\r
+ * \r
+ *  @param     $input\r
+ *                     string that could have double backslashs\r
+ */\r
 function replaceDoubleBackslash($input) {\r
        return str_replace('\\', '/', $input);\r
 }\r
 \r
+/**\r
+ * Checks if a string ends with a slash \r
+ * \r
+ *  @param     $s\r
+ *                     string\r
+ */\r
 function endsWithSlash($s) {\r
        return (strrpos($s, '/') == strlen($s) - 1);\r
 }\r
 \r
 /**\r
  * Checks if email address is valid\r
+ * \r
+ *  @param     $address\r
+ *                     address which should be tested\r
  */\r
 function _isValidMailAddress($address) {\r
-       if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {\r
+       if (preg_match("#^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$#", $address) ) {\r
                return 1;\r
        } else {\r
                return 0;\r
        }\r
 }\r
 \r
-// returns true if the given string is a valid shortname\r
-// (to check short blog names and nicknames)\r
-// logic: starts and ends with a non space, can contain spaces in between\r
-//             min 2 chars\r
+/*\r
+ * Check if short blog names and nicknames are allowed\r
+ * Returns true if the given string is a valid shortname\r
+ * logic: only letters and numbers are allowed, no spaces allowed\r
+ * \r
+ * FIX: function eregi is deprecated since PHP 5.3.0\r
+ * \r
+ * @param      $name\r
+ *                     name which should be tested     \r
+ */\r
 function _isValidShortName($name) {\r
-       if (eregi("^[a-z0-9]+$", $name) ) {\r
+       if (preg_match("#^[a-zA-Z0-9]+$#", $name) ) {\r
                return 1;\r
        } else {\r
                return 0;\r
        }\r
 }\r
 \r
-\r
-\r
-// returns true if the given string is a valid display name\r
-// (to check nicknames)\r
+/*\r
+ * Check if a display name is allowed\r
+ * Returns true if the given string is a valid display name\r
+ * \r
+ * FIX: function eregi is deprecated since PHP 5.3.0\r
+ * \r
+ * @param      $name\r
+ *                     name which should be tested\r
+ */\r
 function _isValidDisplayName($name) {\r
-       if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {\r
+       if (preg_match("#^[a-zA-Z0-9]+[a-zA-Z0-9 ]*[a-zA-Z0-9]+$#", $name) ) {\r
                return 1;\r
        } else {\r
                return 0;\r
        }\r
 }\r
 \r
+/*\r
+ * Shows error message\r
+ * \r
+ * @param      $msg\r
+ *                     error message\r
+ */\r
 function _doError($msg) {\r
        ?>\r
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
@@ -1186,12 +1255,12 @@ function _doError($msg) {
        <style>@import url('../nucleus/styles/manual.css');</style>\r
 </head>\r
 <body>\r
-       <div style='text-align:center'><img src='../nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
+       <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->\r
        <h1><?php echo _ERROR27; ?></h1>\r
 \r
        <p><?php echo _ERROR28; ?> "<?php echo $msg; ?>";</p>\r
 \r
-       <p><a href="index.php" onclick="history.back();"><?php echo _TEXT17; ?></a></p>\r
+       <p><a href="index.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>\r
 </body>\r
 </html>\r
 \r
@@ -1199,6 +1268,12 @@ function _doError($msg) {
        exit;\r
 }\r
 \r
+/*\r
+ * Shows error messages\r
+ * \r
+ * @param      $errors\r
+ *                     array with error messages\r
+ */\r
 function showErrorMessages($errors) {\r
        ?>\r
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
@@ -1209,7 +1284,7 @@ function showErrorMessages($errors) {
        <style>@import url('../nucleus/styles/manual.css');</style>\r
 </head>\r
 <body>\r
-       <div style='text-align:center'><img src='../nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
+       <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->\r
        <h1><?php echo _ERROR27; ?></h1>\r
 \r
        <p><?php echo _ERROR29; ?>:</p>\r