From 595117e6e34ac307d98e2a8ae526693cee5887ea Mon Sep 17 00:00:00 2001 From: sakamocchi Date: Fri, 13 Apr 2012 22:11:52 +0900 Subject: [PATCH] =?utf8?q?MERGE:=20=E3=83=AA=E3=83=93=E3=82=B8=E3=83=A7?= =?utf8?q?=E3=83=B31747=E3=81=AE=E3=83=9E=E3=83=BC=E3=82=B8=E3=80=82./inst?= =?utf8?q?all/index.php=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 上流/master/skinnable-masterの差分を埋めるためにコミット。 Revision 1747: minor updates for install/index.php http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1747 --- install/index.php | 168 +++++++++++++++++++++++++----------------------------- 1 file changed, 78 insertions(+), 90 deletions(-) diff --git a/install/index.php b/install/index.php index 3171aa5..1f93430 100644 --- a/install/index.php +++ b/install/index.php @@ -16,7 +16,7 @@ /** * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2012 The Nucleus Group - * @version $Id$ + * @version $Id: index.php 1745 2012-04-12 23:45:47Z sakamocchi $ */ /* global values initialize */ @@ -25,15 +25,15 @@ $CONF = array(); /* reporting all errors for support */ error_reporting(E_ALL); -$minimum_php_version = '5.0.6'; -$minimum_mysql_version = '3.23'; +$minimum_php_version = '5.0.6'; +$minimum_mysql_version = '3.23'; -$page_footer_copyright = '© 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00'; +$page_footer_copyright = '© 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00'; // begin if: server's PHP version is below the minimum; halt installation if ( version_compare(PHP_VERSION, $minimum_php_version, '<') ) { - exit('
Nucleus requires at least PHP version '. $minimum_php_version .'
'); + exit('
Nucleus requires at least PHP version ' . $minimum_php_version . '
'); } // make sure there's no unnecessary escaping: # set_magic_quotes_runtime(0); @@ -43,8 +43,8 @@ if ( version_compare(PHP_VERSION, '5.3.0', '<') ) } /* default installed plugins and skins */ -$aConfPlugsToInstall = array('NP_SecurityEnforcer', 'NP_SkinFiles', 'NP_Text'); -$aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default'); +$aConfPlugsToInstall = array('NP_SecurityEnforcer', 'NP_SkinFiles', 'NP_Text'); +$aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default'); // Check if some important files do_check_files(); @@ -113,7 +113,6 @@ else } exit; - /** * installer action */ @@ -212,7 +211,6 @@ function show_header() header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header('Content-Type: text/html; charset=' . i18n::get_current_charset()); - ?> @@ -244,35 +242,35 @@ function show_header() @@ -302,7 +300,7 @@ function show_select_locale_form() // Get the browser language that can be displayed // TODO: default locale select simple implementation $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); - foreach ($languages as $language) + foreach ( $languages as $language ) { $language = preg_replace('#([\w]+).*#', '$1', $language); break; @@ -352,7 +350,7 @@ function show_database_setting_form($isPostback) $config_writable = canConfigFileWritable(); $mysql_version = getMySqlVersion(); - ?> +?>

', sprintf(_DBVERSION_TOOLOW , $minimum_mysql_version), ''; + echo '', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), ''; } ?>

@@ -427,7 +425,6 @@ function show_database_setting_form($isPostback) function show_blog_setting_form($isPostback) { global $param; - ?>

@@ -538,7 +535,7 @@ function show_detail_setting_form($isPostback) echo ($mysql_version == '0.0.0') ? _DBVERSION_UNKOWN : $mysql_version; if ( version_compare($mysql_version, $minimum_mysql_version, '<') ) { - echo '', sprintf(_DBVERSION_TOOLOW , $minimum_mysql_version), ''; + echo '', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), ''; } ?> @@ -757,7 +754,7 @@ function show_install_complete_form() { echo '', _INST_TEXT4, ''; ?> - + mysql_host; - $MYSQL_USER = $param->mysql_user; - $MYSQL_PASSWORD = $param->mysql_password; - $MYSQL_DATABASE = $param->mysql_database; - $MYSQL_PREFIX = $param->mysql_tablePrefix; - - $DIR_NUCLEUS = $param->AdminPath; - $DIR_MEDIA = $param->MediaPath; - $DIR_SKINS = $param->SkinsPath; - $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/'; - $DIR_LOCALES = $DIR_NUCLEUS . 'locales/'; - $DIR_LIBS = $DIR_NUCLEUS . 'libs/'; + $MYSQL_HOST = $param->mysql_host; + $MYSQL_USER = $param->mysql_user; + $MYSQL_PASSWORD = $param->mysql_password; + $MYSQL_DATABASE = $param->mysql_database; + $MYSQL_PREFIX = $param->mysql_tablePrefix; + + $DIR_NUCLEUS = $param->AdminPath; + $DIR_MEDIA = $param->MediaPath; + $DIR_SKINS = $param->SkinsPath; + $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/'; + $DIR_LOCALES = $DIR_NUCLEUS . 'locales/'; + $DIR_LIBS = $DIR_NUCLEUS . 'libs/'; /* * 2.open mySQL connection @@ -893,7 +890,7 @@ function do_install() // table exists check $result = sql_query('SHOW TABLES'); - while ($row = mysql_fetch_array($result, MYSQL_NUM)) + while ( $row = mysql_fetch_array($result, MYSQL_NUM) ) { if ( in_array($row[0], $prefixed_table_names) ) { @@ -908,7 +905,7 @@ function do_install() $filename = 'install.sql'; $fd = fopen($filename, 'r'); - $queries = fread($fd, filesize($filename) ); + $queries = fread($fd, filesize($filename)); fclose($fd); $queries = preg_split('#(;\n|;\r)#', $queries); @@ -1010,11 +1007,11 @@ function do_install() array_merge($errors, $aSkinErrors); } - $query = "SELECT sdnumber FROM %s WHERE sdname='default'"; - $query = sprintf($query, tableName('nucleus_skin_desc')); - $res = sql_query($query); - $obj = sql_fetch_assoc($res); - $defSkinID = (integer) $obj['sdnumber']; + $query = "SELECT sdnumber FROM %s WHERE sdname='default'"; + $query = sprintf($query, tableName('nucleus_skin_desc')); + $res = sql_query($query); + $obj = sql_fetch_assoc($res); + $defSkinID = (integer) $obj['sdnumber']; $query = "UPDATE %s SET bdefskin=%d WHERE bnumber=1"; $query = sprintf($query, tableName('nucleus_blog'), $defSkinID); @@ -1044,7 +1041,7 @@ function do_install() $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 .= "\$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n"; $config_data .= "\n"; $config_data .= "// main nucleus directory\n"; $config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n"; @@ -1070,7 +1067,7 @@ function do_install() { if ( $fp = @fopen('../config.php', 'w') ) { - $result = @fwrite($fp, $config_data, i18n::strlen($config_data) ); + $result = @fwrite($fp, $config_data, i18n::strlen($config_data)); fclose($fp); } } @@ -1078,7 +1075,7 @@ function do_install() if ( $result ) { // try to change the read-only permission. - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' ) + if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' ) { @chmod('../config.php', 0444); } @@ -1100,7 +1097,7 @@ function canConfigFileWritable() if ( @file_exists('../config.php') && @!is_writable('../config.php') ) { // try to change the read-write permission. - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' ) + if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' ) { @chmod('../config.php', 0666); } @@ -1132,7 +1129,7 @@ function getMySqlVersion() if ( $result != FALSE && sql_num_rows($result) > 0 ) { $row = sql_fetch_array($result); - $match = i18n::explode('.', $row['version']); + $match = preg_split('#\.#', $row['version']); } else { @@ -1141,14 +1138,13 @@ function getMySqlVersion() if ( $result != FALSE && @sql_num_rows($result) > 0 ) { $row = sql_fetch_row($result); - $match = i18n::explode('.', $row[1]); + $match = preg_split('#\.#', $row[1]); } else { - //$output = shell_exec('mysql -V'); - $output = ( function_exists('shell_exec') ) ? @shell_exec('mysql -V') : '0.0.0'; + $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0'; preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version); - $match = i18n::explode('.', $version[0]); + $match = preg_split('#\.#', $version[0]); if ( $match[0] == '' ) { @@ -1197,7 +1193,7 @@ function installCustomPlugs() return $aErrors; } - $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin') ); + $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin')); $numCurrent = sql_num_rows($res); foreach ( $aConfPlugsToInstall as $plugName ) @@ -1213,14 +1209,14 @@ function installCustomPlugs() { sql_query('DELETE FROM ' . tableName('nucleus_plugin') . " WHERE pfile = '" . sql_real_escape_string($plugName) . "'"); $numCurrent--; - array_push($aErrors, sprintf(_INST_ERROR9 ,$plugName)); + array_push($aErrors, sprintf(_INST_ERROR9, $plugName)); continue; } $plugin->install(); } - sql_query('DELETE FROM ' . tableName('nucleus_plugin_event') ); - $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin') ); + sql_query('DELETE FROM ' . tableName('nucleus_plugin_event')); + $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin')); while ( $o = sql_fetch_object($res) ) { @@ -1285,7 +1281,6 @@ function installCustomSkins() return $aErrors; } - /** * Check if some important files of the Nucleus CMS installation are available * Give an error if one or more files are not accessible @@ -1340,17 +1335,16 @@ function do_check_files() { if ( !is_readable($files[$i]) ) { - array_push( $missingfiles, 'File ' . $files[$i] . ' is missing or not readable.
'); + array_push($missingfiles, 'File ' . $files[$i] . ' is missing or not readable.
'); } } if ( count($missingfiles) > 0 ) { - exit(implode( "\n", $missingfiles)); + exit(implode("\n", $missingfiles)); } } - /** * Updates the configuration in the database * @@ -1362,7 +1356,7 @@ function updateConfig($name, $value) { $errors = array(); $name = sql_real_escape_string($name); - $value = trim(sql_real_escape_string($value) ); + $value = trim(sql_real_escape_string($value)); $query = "UPDATE %s SET value = '%s' WHERE name = '%s'"; $query = sprintf($query, tableName('nucleus_config'), $value, $name); @@ -1374,7 +1368,6 @@ function updateConfig($name, $value) return $errors; } - class ParamManager { /* process parameter */ @@ -1433,8 +1426,8 @@ class ParamManager $this->blog_shortname = 'mynucleuscms'; /* root path */ -// $this->root_path = realpath(dirname(__FILE__) . '/..'); - $this->root_path = implode('/', i18n::explode(DIRECTORY_SEPARATOR, realpath(dirname(__FILE__) . '/..'))); + $directory_separator = preg_quote(DIRECTORY_SEPARATOR, '|'); + $this->root_path = implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__) . '/..'))); if ( substr($this->root_path, -1, 1) !== '/' ) { $this->root_path .= '/'; @@ -1442,7 +1435,7 @@ class ParamManager $base_path_pcre = preg_quote($this->root_path, '|'); /* current directry name */ - $directory_name = preg_replace("|$base_path_pcre|", '', implode('/', i18n::explode(DIRECTORY_SEPARATOR, realpath(dirname(__FILE__))))); + $directory_name = preg_replace("#{$base_path_pcre}#", '', implode('/', preg_split("#{$directory_separator}#", realpath(dirname(__FILE__))))); $directory_name_pcre = preg_quote($directory_name, '|'); /* root uri */ @@ -1513,11 +1506,6 @@ class ParamManager $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD2); } -// if ( $this->mysql_password == '' ) -// { -// $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD3); -// } - if ( $this->mysql_database == '' ) { $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD4); -- 2.11.0