OSDN Git Service

PDO対応
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / install.php
index 19b5eb5..7060b23 100755 (executable)
@@ -70,9 +70,17 @@ if (phpversion() >= '4.1.0') {
        include_once('nucleus/libs/vars4.0.6.php');\r
 }\r
 \r
        include_once('nucleus/libs/vars4.0.6.php');\r
 }\r
 \r
-include_once('nucleus/libs/mysql.php');\r
+// include core classes that are needed for login & plugin handling\r
+// added for 3.5 sql_* wrapper\r
+global $MYSQL_HANDLER;\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
+// end new for 3.5 sql_* wrapper\r
+include_once(str_replace("install.php", "", __FILE__) . '/nucleus/libs/mysql.php');\r
 \r
 // check if mysql support is installed\r
 \r
 // check if mysql support is installed\r
+// this check may not make sense, as is, in a version past 3.5x\r
        if (!function_exists('mysql_query') ) {\r
                _doError(_ERROR1);\r
        }\r
        if (!function_exists('mysql_query') ) {\r
                _doError(_ERROR1);\r
        }\r
@@ -162,16 +170,16 @@ function showInstallForm() {
 \r
 <?php\r
        // note: this piece of code is taken from phpMyAdmin\r
 \r
 <?php\r
        // note: this piece of code is taken from phpMyAdmin\r
-       $result = @mysql_query('SELECT VERSION() AS version');\r
+       $result = @sql_query('SELECT VERSION() AS version');\r
 \r
 \r
-       if ($result != FALSE && @mysql_num_rows($result) > 0) {\r
-               $row   = mysql_fetch_array($result);\r
+       if ($result != FALSE && @sql_num_rows($result) > 0) {\r
+               $row   = sql_fetch_array($result);\r
                $match = explode('.', $row['version']);\r
        } else {\r
                $match = explode('.', $row['version']);\r
        } else {\r
-               $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');\r
+               $result = @sql_query('SHOW VARIABLES LIKE \'version\'');\r
 \r
 \r
-               if ($result != FALSE && @mysql_num_rows($result) > 0) {\r
-                       $row   = mysql_fetch_row($result);\r
+               if ($result != FALSE && @sql_num_rows($result) > 0) {\r
+                       $row   = sql_fetch_row($result);\r
                        $match = explode('.', $row[1]);\r
                } else {\r
                        $output = shell_exec('mysql -V');\r
                        $match = explode('.', $row[1]);\r
                } else {\r
                        $output = shell_exec('mysql -V');\r
@@ -564,11 +572,13 @@ function doInstall() {
        }\r
 \r
        // 2-1. try to log in to mySQL\r
        }\r
 \r
        // 2-1. try to log in to mySQL\r
+\r
        global $MYSQL_CONN;\r
        global $MYSQL_CONN;\r
-       $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);\r
+       // this will need to be changed if we ever allow\r
+       $MYSQL_CONN = @sql_connect_args($mysql_host, $mysql_user, $mysql_password);\r
 \r
        if ($MYSQL_CONN == false) {\r
 \r
        if ($MYSQL_CONN == false) {\r
-               _doError(_ERROR15 . ': ' . mysql_error() );\r
+               _doError(_ERROR15 . ': ' . sql_error() );\r
        }\r
 \r
 // <add for garble measure>\r
        }\r
 \r
 // <add for garble measure>\r
@@ -577,7 +587,7 @@ function doInstall() {
        if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {\r
                mysql_set_charset($charset);\r
        } elseif ($mySqlVer >= '4.1.0') {\r
        if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {\r
                mysql_set_charset($charset);\r
        } elseif ($mySqlVer >= '4.1.0') {\r
-               mysql_query("SET NAMES " . $charset);\r
+               sql_query("SET NAMES " . $charset);\r
        }\r
        $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci';\r
 // </add for garble measure>*/\r
        }\r
        $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci';\r
 // </add for garble measure>*/\r
@@ -594,11 +604,11 @@ function doInstall() {
                          .     $collation;\r
        }\r
 // </add for garble measure>*/\r
                          .     $collation;\r
        }\r
 // </add for garble measure>*/\r
-               mysql_query($sql) or _doError(_ERROR16 . ': ' . mysql_error());\r
+               sql_query($sql) or _doError(_ERROR16 . ': ' . sql_error());\r
        }\r
 \r
        // 4. try to select database\r
        }\r
 \r
        // 4. try to select database\r
-       mysql_select_db($mysql_database) or _doError(_ERROR17);\r
+       sql_select_db($mysql_database) or _doError(_ERROR17);\r
 \r
        // 5. execute queries\r
        $filename = 'install.sql';\r
 \r
        // 5. execute queries\r
        $filename = 'install.sql';\r
@@ -673,7 +683,7 @@ function doInstall() {
                        }\r
 // </add for garble measure>*/\r
 \r
                        }\r
 // </add for garble measure>*/\r
 \r
-                       mysql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );\r
+                       sql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . sql_error() );\r
                }\r
        }\r
 \r
                }\r
        }\r
 \r
@@ -695,7 +705,7 @@ function doInstall() {
                         . " '" . $itm_body . "',"\r
                         . " '" . $itm_more . "',"\r
                         . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";\r
                         . " '" . $itm_body . "',"\r
                         . " '" . $itm_more . "',"\r
                         . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";\r
-       mysql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . mysql_error() );\r
+       sql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . sql_error() );\r
 \r
        // 6. update global settings\r
        updateConfig('IndexURL',   $config_indexurl);\r
 \r
        // 6. update global settings\r
        updateConfig('IndexURL',   $config_indexurl);\r
@@ -722,7 +732,7 @@ function doInstall() {
                   . " WHERE"\r
                   . " mnumber       = 1";\r
 \r
                   . " WHERE"\r
                   . " mnumber       = 1";\r
 \r
-       mysql_query($query) or _doError(_ERROR19 . ': ' . mysql_error() );\r
+       sql_query($query) or _doError(_ERROR19 . ': ' . sql_error() );\r
 \r
        // 8. update weblog settings\r
        $query = 'UPDATE ' . tableName('nucleus_blog')\r
 \r
        // 8. update weblog settings\r
        $query = 'UPDATE ' . tableName('nucleus_blog')\r
@@ -732,7 +742,7 @@ function doInstall() {
                   . " WHERE"\r
                   . " bnumber    = 1";\r
 \r
                   . " WHERE"\r
                   . " bnumber    = 1";\r
 \r
-       mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );\r
+       sql_query($query) or _doError(_ERROR20 . ': ' . sql_error() );\r
 \r
        // 8-2. update category settings\r
        if ($charset == 'ujis') {\r
 \r
        // 8-2. update category settings\r
        if ($charset == 'ujis') {\r
@@ -748,14 +758,14 @@ function doInstall() {
                   . " WHERE"\r
                   . " catid      = 1";\r
 \r
                   . " WHERE"\r
                   . " catid      = 1";\r
 \r
-       mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );\r
+       sql_query($query) or _doError(_ERROR20 . ': ' . sql_error() );\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
 \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
-       mysql_query($query) or _doError(_ERROR21 . ': ' . mysql_error() );\r
+       sql_query($query) or _doError(_ERROR21 . ': ' . sql_error() );\r
 \r
        global $aConfPlugsToInstall, $aConfSkinsToImport;\r
        $aSkinErrors = array();\r
 \r
        global $aConfPlugsToInstall, $aConfSkinsToImport;\r
        $aSkinErrors = array();\r
@@ -781,7 +791,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
                $DIR_LIBS    = $DIR_NUCLEUS . 'libs/';\r
 \r
                // close database connection (needs to be closed if we want to include globalfunctions.php)\r
-               mysql_close();\r
+               sql_close();\r
 \r
                $manager = '';\r
                include_once($DIR_LIBS . 'globalfunctions.php');\r
 \r
                $manager = '';\r
                include_once($DIR_LIBS . 'globalfunctions.php');\r
@@ -811,6 +821,10 @@ function doInstall() {
                $config_data .= "       \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";\r
                $config_data .= "       \$MYSQL_DATABASE = '" . $mysql_database . "';\n";\r
                $config_data .= "       \$MYSQL_PREFIX   = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";\r
                $config_data .= "       \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";\r
                $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 .= "       \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
+               $config_data .= "       //\$MYSQL_HANDLER = array('pdo','mysql');\n";\r
                $config_data .= "\n";\r
                $config_data .= "       // main nucleus directory\n";\r
                $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
                $config_data .= "\n";\r
                $config_data .= "       // main nucleus directory\n";\r
                $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
@@ -929,11 +943,11 @@ function doInstall() {
                <li><?php echo _TEXT15_L3; ?></li>\r
                </ul>\r
 \r
                <li><?php echo _TEXT15_L3; ?></li>\r
                </ul>\r
 \r
-       <?php echo _TEXT15_EX; ?>\r
+       <?php echo _TEXT16; ?>\r
 \r
        <h1><?php echo _HEADER11; ?></h1>\r
 \r
 \r
        <h1><?php echo _HEADER11; ?></h1>\r
 \r
-       <p><?php echo _TEXT16; ?>\r
+       <p><?php echo _TEXT16_H; ?>\r
                <ul>\r
                        <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>\r
                        <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>\r
                <ul>\r
                        <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>\r
                        <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>\r
@@ -956,7 +970,7 @@ function installCustomPlugs(&$manager) {
        }\r
 \r
        $res = sql_query('SELECT * FROM ' . sql_table('plugin') );\r
        }\r
 \r
        $res = sql_query('SELECT * FROM ' . sql_table('plugin') );\r
-       $numCurrent = mysql_num_rows($res);\r
+       $numCurrent = sql_num_rows($res);\r
 \r
        foreach ($aConfPlugsToInstall as $plugName) {\r
                // do this before calling getPlugin (in case the plugin id is used there)\r
 \r
        foreach ($aConfPlugsToInstall as $plugName) {\r
                // do this before calling getPlugin (in case the plugin id is used there)\r
@@ -984,7 +998,7 @@ function installCustomPlugs(&$manager) {
        // loop over all installed plugins\r
        $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );\r
 \r
        // loop over all installed plugins\r
        $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );\r
 \r
-       while($o = mysql_fetch_object($res) ) {\r
+       while($o = sql_fetch_object($res) ) {\r
                $pid  =  $o->pid;\r
                $plug =& $manager->getPlugin($o->pfile);\r
 \r
                $pid  =  $o->pid;\r
                $plug =& $manager->getPlugin($o->pfile);\r
 \r
@@ -1090,8 +1104,8 @@ function updateConfig($name, $val) {
                   . " SET   value = '$val'"\r
                   . " WHERE name  = '$name'";\r
 \r
                   . " SET   value = '$val'"\r
                   . " WHERE name  = '$name'";\r
 \r
-       mysql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );\r
-       return mysql_insert_id();\r
+       sql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );\r
+       return sql_insert_id();\r
 }\r
 \r
 function replaceDoubleBackslash($input) {\r
 }\r
 \r
 function replaceDoubleBackslash($input) {\r