OSDN Git Service

NP_Ping and related infrastructure changes. (admun)
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / install.php
index 7060b23..4de48d2 100755 (executable)
@@ -73,11 +73,13 @@ if (phpversion() >= '4.1.0') {
 // include core classes that are needed for login & plugin handling\r
 // added for 3.5 sql_* wrapper\r
 global $MYSQL_HANDLER;\r
+//set the handler if different from mysql (or mysqli)\r
+//$MYSQL_HANDLER = array('pdo','mysql');\r
 if (!isset($MYSQL_HANDLER))\r
        $MYSQL_HANDLER = array('mysql','');\r
-include_once(str_replace("install.php", "", __FILE__) . 'nucleus/libs/sql/'.$MYSQL_HANDLER[0].'.php');\r
+include_once('nucleus/libs/sql/'.$MYSQL_HANDLER[0].'.php');\r
 // end new for 3.5 sql_* wrapper\r
-include_once(str_replace("install.php", "", __FILE__) . '/nucleus/libs/mysql.php');\r
+include_once('nucleus/libs/mysql.php');\r
 \r
 // check if mysql support is installed\r
 // this check may not make sense, as is, in a version past 3.5x\r
@@ -170,13 +172,14 @@ function showInstallForm() {
 \r
 <?php\r
        // note: this piece of code is taken from phpMyAdmin\r
-       $result = @sql_query('SELECT VERSION() AS version');\r
+       $conn   = sql_connect_args('localhost','','');\r
+       $result = @sql_query('SELECT VERSION() AS version', $conn);\r
 \r
        if ($result != FALSE && @sql_num_rows($result) > 0) {\r
                $row   = sql_fetch_array($result);\r
                $match = explode('.', $row['version']);\r
        } else {\r
-               $result = @sql_query('SHOW VARIABLES LIKE \'version\'');\r
+               $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);\r
 \r
                if ($result != FALSE && @sql_num_rows($result) > 0) {\r
                        $row   = sql_fetch_row($result);\r
@@ -195,8 +198,9 @@ function showInstallForm() {
                }\r
        }\r
 \r
+       sql_disconnect($conn);\r
        $mysqlVersion = implode($match, '.');\r
-       $minVersion = '3.23';\r
+       $minVersion   = '3.23';\r
 \r
        if ($mysqlVersion == '0.0.0') {\r
                echo _NOTIFICATION1;\r
@@ -604,11 +608,11 @@ function doInstall() {
                          .     $collation;\r
        }\r
 // </add for garble measure>*/\r
-               sql_query($sql) or _doError(_ERROR16 . ': ' . sql_error());\r
+               sql_query($sql,$MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN));\r
        }\r
 \r
        // 4. try to select database\r
-       sql_select_db($mysql_database) or _doError(_ERROR17);\r
+       sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17);\r
 \r
        // 5. execute queries\r
        $filename = 'install.sql';\r
@@ -683,7 +687,7 @@ function doInstall() {
                        }\r
 // </add for garble measure>*/\r
 \r
-                       sql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . sql_error() );\r
+                       sql_query($query,$MYSQL_CONN) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . sql_error($MYSQL_CONN) );\r
                }\r
        }\r
 \r
@@ -705,7 +709,7 @@ function doInstall() {
                         . " '" . $itm_body . "',"\r
                         . " '" . $itm_more . "',"\r
                         . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";\r
-       sql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . sql_error() );\r
+       sql_query($newpost,$MYSQL_CONN) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . sql_error($MYSQL_CONN) );\r
 \r
        // 6. update global settings\r
        updateConfig('IndexURL',   $config_indexurl);\r
@@ -732,7 +736,7 @@ function doInstall() {
                   . " WHERE"\r
                   . " mnumber       = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR19 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        // 8. update weblog settings\r
        $query = 'UPDATE ' . tableName('nucleus_blog')\r
@@ -742,7 +746,7 @@ function doInstall() {
                   . " WHERE"\r
                   . " bnumber    = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR20 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        // 8-2. update category settings\r
        if ($charset == 'ujis') {\r
@@ -758,14 +762,14 @@ function doInstall() {
                   . " WHERE"\r
                   . " catid      = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR20 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        // 9. update item date\r
        $query = 'UPDATE ' . tableName('nucleus_item')\r
                   . " SET   itime   = '" . date('Y-m-d H:i:s', time() ) ."'"\r
                   . " WHERE inumber = 1";\r
 \r
-       sql_query($query) or _doError(_ERROR21 . ': ' . sql_error() );\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN) );\r
 \r
        global $aConfPlugsToInstall, $aConfSkinsToImport;\r
        $aSkinErrors = array();\r
@@ -791,7 +795,7 @@ function doInstall() {
                $DIR_LIBS    = $DIR_NUCLEUS . 'libs/';\r
 \r
                // close database connection (needs to be closed if we want to include globalfunctions.php)\r
-               sql_close();\r
+               sql_close($MYSQL_CONN);\r
 \r
                $manager = '';\r
                include_once($DIR_LIBS . 'globalfunctions.php');\r
@@ -823,8 +827,9 @@ function doInstall() {
                $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 .= "       \$MYSQL_HANDLER = array('mysql','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
                $config_data .= "\n";\r
                $config_data .= "       // main nucleus directory\n";\r
                $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
@@ -1097,6 +1102,7 @@ function doCheckFiles() {
 }\r
 \r
 function updateConfig($name, $val) {\r
+       global $MYSQL_CONN;\r
        $name = addslashes($name);\r
        $val  = trim(addslashes($val) );\r
 \r
@@ -1104,8 +1110,8 @@ function updateConfig($name, $val) {
                   . " SET   value = '$val'"\r
                   . " WHERE name  = '$name'";\r
 \r
-       sql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );\r
-       return sql_insert_id();\r
+       sql_query($query,$MYSQL_CONN) or _doError(_ERROR26 . ': ' . mysql_error($MYSQL_CONN) );\r
+       return sql_insert_id($MYSQL_CONN);\r
 }\r
 \r
 function replaceDoubleBackslash($input) {\r