X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=utf8%2Finstall.php;h=4de48d23e55a986422b12aa440f247912a3d57ef;hb=b4459361f8401257e902db6a1a4c1961d1276e2d;hp=4aef1e58a0cc2bf04ed61f7b3f457e109363dc4b;hpb=da0f16397fb741f2adf4280aa460682ef24e42f6;p=nucleus-jp%2Fnucleus-jp-ancient.git
diff --git a/utf8/install.php b/utf8/install.php
index 4aef1e5..4de48d2 100755
--- a/utf8/install.php
+++ b/utf8/install.php
@@ -70,9 +70,19 @@ if (phpversion() >= '4.1.0') {
include_once('nucleus/libs/vars4.0.6.php');
}
+// include core classes that are needed for login & plugin handling
+// added for 3.5 sql_* wrapper
+global $MYSQL_HANDLER;
+//set the handler if different from mysql (or mysqli)
+//$MYSQL_HANDLER = array('pdo','mysql');
+if (!isset($MYSQL_HANDLER))
+ $MYSQL_HANDLER = array('mysql','');
+include_once('nucleus/libs/sql/'.$MYSQL_HANDLER[0].'.php');
+// end new for 3.5 sql_* wrapper
include_once('nucleus/libs/mysql.php');
// check if mysql support is installed
+// this check may not make sense, as is, in a version past 3.5x
if (!function_exists('mysql_query') ) {
_doError(_ERROR1);
}
@@ -162,19 +172,21 @@ function showInstallForm() {
0) {
- $row = mysql_fetch_array($result);
+ if ($result != FALSE && @sql_num_rows($result) > 0) {
+ $row = sql_fetch_array($result);
$match = explode('.', $row['version']);
} else {
- $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
+ $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
- if ($result != FALSE && @mysql_num_rows($result) > 0) {
- $row = mysql_fetch_row($result);
+ if ($result != FALSE && @sql_num_rows($result) > 0) {
+ $row = sql_fetch_row($result);
$match = explode('.', $row[1]);
} else {
$output = shell_exec('mysql -V');
+ $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
$match = explode('.', $version[0]);
@@ -186,8 +198,9 @@ function showInstallForm() {
}
}
+ sql_disconnect($conn);
$mysqlVersion = implode($match, '.');
- $minVersion = '3.23';
+ $minVersion = '3.23';
if ($mysqlVersion == '0.0.0') {
echo _NOTIFICATION1;
@@ -563,11 +576,13 @@ function doInstall() {
}
// 2-1. try to log in to mySQL
+
global $MYSQL_CONN;
- $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
+ // this will need to be changed if we ever allow
+ $MYSQL_CONN = @sql_connect_args($mysql_host, $mysql_user, $mysql_password);
if ($MYSQL_CONN == false) {
- _doError(_ERROR15 . ': ' . mysql_error() );
+ _doError(_ERROR15 . ': ' . sql_error() );
}
//
@@ -575,8 +590,8 @@ function doInstall() {
$mySqlVer = implode('.', array_map('intval', explode('.', mysql_get_server_info($MYSQL_CONN))));
if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {
mysql_set_charset($charset);
- } else {
- mysql_query("SET NAMES " . $charset);
+ } elseif ($mySqlVer >= '4.1.0') {
+ sql_query("SET NAMES " . $charset);
}
$collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci';
// */
@@ -584,19 +599,20 @@ function doInstall() {
// 3. try to create database (if needed)
if ($mysql_create == 1) {
$sql = 'CREATE DATABASE '
- . $mysql_database
+ . $mysql_database;
//
- . ' DEFAULT CHARACTER SET '
- . $charset
- . ' COLLATE '
- . $collation
+ if ($mySqlVer >= '4.1.0') {
+ $sql .= ' DEFAULT CHARACTER SET '
+ . $charset
+ . ' COLLATE '
+ . $collation;
+ }
// */
- . '';
- mysql_query($sql) or _doError(_ERROR16 . ': ' . mysql_error());
+ sql_query($sql,$MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN));
}
// 4. try to select database
- mysql_select_db($mysql_database) or _doError(_ERROR17);
+ sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17);
// 5. execute queries
$filename = 'install.sql';
@@ -666,12 +682,12 @@ function doInstall() {
$query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
}
//
- if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0) {
+ if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0 && $mySqlVer >= '4.1.0') {
$query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
}
// */
- mysql_query($query) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . mysql_error() );
+ sql_query($query,$MYSQL_CONN) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . sql_error($MYSQL_CONN) );
}
}
@@ -693,7 +709,7 @@ function doInstall() {
. " '" . $itm_body . "',"
. " '" . $itm_more . "',"
. " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";
- mysql_query($newpost) or _doError(_ERROR18 . ' (' . htmlspecialchars($newpost) . '): ' . mysql_error() );
+ sql_query($newpost,$MYSQL_CONN) or _doError(_ERROR18 . ' (' . htmlspecialchars($newpost) . '): ' . sql_error($MYSQL_CONN) );
// 6. update global settings
updateConfig('IndexURL', $config_indexurl);
@@ -720,7 +736,7 @@ function doInstall() {
. " WHERE"
. " mnumber = 1";
- mysql_query($query) or _doError(_ERROR19 . ': ' . mysql_error() );
+ sql_query($query,$MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN) );
// 8. update weblog settings
$query = 'UPDATE ' . tableName('nucleus_blog')
@@ -730,7 +746,7 @@ function doInstall() {
. " WHERE"
. " bnumber = 1";
- mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );
+ sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );
// 8-2. update category settings
if ($charset == 'ujis') {
@@ -746,14 +762,14 @@ function doInstall() {
. " WHERE"
. " catid = 1";
- mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );
+ sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );
// 9. update item date
$query = 'UPDATE ' . tableName('nucleus_item')
. " SET itime = '" . date('Y-m-d H:i:s', time() ) ."'"
. " WHERE inumber = 1";
- mysql_query($query) or _doError(_ERROR21 . ': ' . mysql_error() );
+ sql_query($query,$MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN) );
global $aConfPlugsToInstall, $aConfSkinsToImport;
$aSkinErrors = array();
@@ -779,7 +795,7 @@ function doInstall() {
$DIR_LIBS = $DIR_NUCLEUS . 'libs/';
// close database connection (needs to be closed if we want to include globalfunctions.php)
- mysql_close();
+ sql_close($MYSQL_CONN);
$manager = '';
include_once($DIR_LIBS . 'globalfunctions.php');
@@ -809,6 +825,11 @@ function doInstall() {
$config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
$config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
$config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";
+ $config_data .= " // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
+ $config_data .= " // default is \$MYSQL_HANDLER = array('mysql','mysql');\n";
+ $config_data .= " //\$MYSQL_HANDLER = array('mysql','mysql');\n";
+ $config_data .= " //\$MYSQL_HANDLER = array('pdo','mysql');\n";
+ $config_data .= " \$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";
$config_data .= "\n";
$config_data .= " // main nucleus directory\n";
$config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
@@ -924,13 +945,14 @@ function doInstall() {
-
+
-
+
@@ -953,7 +975,7 @@ function installCustomPlugs(&$manager) {
}
$res = sql_query('SELECT * FROM ' . sql_table('plugin') );
- $numCurrent = mysql_num_rows($res);
+ $numCurrent = sql_num_rows($res);
foreach ($aConfPlugsToInstall as $plugName) {
// do this before calling getPlugin (in case the plugin id is used there)
@@ -981,7 +1003,7 @@ function installCustomPlugs(&$manager) {
// loop over all installed plugins
$res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
- while($o = mysql_fetch_object($res) ) {
+ while($o = sql_fetch_object($res) ) {
$pid = $o->pid;
$plug =& $manager->getPlugin($o->pfile);
@@ -1080,6 +1102,7 @@ function doCheckFiles() {
}
function updateConfig($name, $val) {
+ global $MYSQL_CONN;
$name = addslashes($name);
$val = trim(addslashes($val) );
@@ -1087,8 +1110,8 @@ function updateConfig($name, $val) {
. " SET value = '$val'"
. " WHERE name = '$name'";
- mysql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );
- return mysql_insert_id();
+ sql_query($query,$MYSQL_CONN) or _doError(_ERROR26 . ': ' . mysql_error($MYSQL_CONN) );
+ return sql_insert_id($MYSQL_CONN);
}
function replaceDoubleBackslash($input) {
@@ -1139,7 +1162,7 @@ function _doError($msg) {
-
+
@@ -1147,7 +1170,7 @@ function _doError($msg) {
- : "";
+ "";
@@ -1162,7 +1185,7 @@ function showErrorMessages($errors) {
-
+