X-Git-Url: http://git.sourceforge.jp/view?p=nucleus-jp%2Fnucleus-jp-ancient.git;a=blobdiff_plain;f=utf8%2Finstall.php;h=951b573aae07aca37b1110d5845caa10d57ea846;hp=8aab67194248d5ba2a388e809c962f19d59c809a;hb=82bbdee2ebc5f80f1f40a3434852a431f2c0a9e9;hpb=d7e9d7a179c4f3e48bbc4684546845d36457fdca diff --git a/utf8/install.php b/utf8/install.php index 8aab671..951b573 100755 --- a/utf8/install.php +++ b/utf8/install.php @@ -23,11 +23,11 @@ */ /* - This part of the install.php code allows for customization of the install process. - When distributing plugins or skins together with a Nucleus installation, the - configuration below will instruct to install them + This part of the install.php code allows for customization of the install process. + When distributing plugins or skins together with a Nucleus installation, the + configuration below will instruct to install them - -- Start Of Configurable Part -- + -- Start Of Configurable Part -- */ include('./install_lang_japanese.php'); @@ -37,7 +37,11 @@ include('./install_lang_japanese.php'); // // example: // array('NP_TrackBack', 'NP_MemberGoodies') -$aConfPlugsToInstall = array('NP_SkinFiles'); +$aConfPlugsToInstall = array( + 'NP_SkinFiles', + 'NP_SecurityEnforcer', + 'NP_Text' +); // array with skins to install. skins must be present under the skins/ directory with @@ -45,10 +49,15 @@ $aConfPlugsToInstall = array('NP_SkinFiles'); // // example: // array('base','rsd') -$aConfSkinsToImport = array('default'); +$aConfSkinsToImport = array( + 'atom', + 'rss2.0', + 'rsd', + 'default', +); /* - -- End Of Configurable Part -- + -- End Of Configurable Part -- */ // don't give warnings for uninitialized vars @@ -60,566 +69,585 @@ set_magic_quotes_runtime(0); // if there are some plugins or skins to import, do not include vars // in globalfunctions.php again... so set a flag if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) { - global $CONF; - $CONF['installscript'] = 1; + global $CONF; + $CONF['installscript'] = 1; } if (phpversion() >= '4.1.0') { - include_once('nucleus/libs/vars4.1.0.php'); + include_once('nucleus/libs/vars4.1.0.php'); } else { - include_once('nucleus/libs/vars4.0.6.php'); + 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 - if (!function_exists('mysql_query') ) { - _doError(_ERROR1); - } +// this check may not make sense, as is, in a version past 3.5x + if (!function_exists('mysql_query') ) { + _doError(_ERROR1); + } - if (postVar('action') == 'go') { - doInstall(); - } else { - showInstallForm(); - } + if (postVar('action') == 'go') { + doInstall(); + } else { + showInstallForm(); + } exit; function showInstallForm() { - // 0. pre check if all necessary files exist - doCheckFiles(); - - ?> - - - - - <?php echo _TITLE; ?> - - - - -
-
- -

- - - -

- - - -
- - - - - - -
- -
-
- -

- - - - -

+

- -

- - - -
- - - - - - - - - - - - - - - - - - -
()
-
- -
- - - - - - -
- - - -
- -

- - +

+ + + +
+ + + + + + + + + + + + + + + + + + +
()
+
+ +
+ + + + + + +
+ + + +
+ +

+ + -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
() -
-
() -
-
() -
-
- - - -

- - - -
- - - - - - - - - - - - - - - - - - - - - - -
()
()
-
- -

- - - -
- - - - - - - - - - -
()
-
- -

- -
- - - - - -
-
- -

- - - -

- -
- +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
() +
+
() +
+
() +
+
+ + + +

+ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
()
()
+
+ +

+ + + +
+ + + + + + + + + + +
()
+
+ +

+ +
+ + + + + +
+
+ +

+ + + +

+ + + 0) { - showErrorMessages($errors); - } - - // 2-1. try to log in to mySQL - global $MYSQL_CONN; - $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password); - - if ($MYSQL_CONN == false) { - _doError(_ERROR15 . ': ' . mysql_error() ); - } - -/*/ - // 2-2. set DEFAULT CHARSET and COLLATE - $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); - } - $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci'; + global $mysql_usePrefix, $mysql_prefix, $weblog_ping; + + // 0. put all POST-vars into vars + $mysql_host = postVar('mySQL_host'); + $mysql_user = postVar('mySQL_user'); + $mysql_password = postVar('mySQL_password'); + $mysql_database = postVar('mySQL_database'); + $mysql_create = postVar('mySQL_create'); + $mysql_usePrefix = postVar('mySQL_usePrefix'); + $mysql_prefix = postVar('mySQL_tablePrefix'); + $config_indexurl = postVar('IndexURL'); + $config_adminurl = postVar('AdminURL'); + $config_adminpath = postVar('AdminPath'); + $config_mediaurl = postVar('MediaURL'); + $config_skinsurl = postVar('SkinsURL'); + $config_pluginurl = postVar('PluginURL'); + $config_actionurl = postVar('ActionURL'); + $config_mediapath = postVar('MediaPath'); + $config_skinspath = postVar('SkinsPath'); + $user_name = postVar('User_name'); + $user_realname = postVar('User_realname'); + $user_password = postVar('User_password'); + $user_password2 = postVar('User_password2'); + $user_email = postVar('User_email'); + $blog_name = postVar('Blog_name'); + $blog_shortname = postVar('Blog_shortname'); + $charset = postVar('charset'); + $config_adminemail = $user_email; + $config_sitename = $blog_name; + $weblog_ping = postVar('Weblog_ping'); + + $_POST = array(); + if (!extension_loaded('mbstring')) { + include('nucleus/libs/mb_emulator/mb-emulator.php'); + } + if ($charset == 'ujis') { + define('_CHARSET', 'EUC-JP'); + $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8'); + $user_realname = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8'); + $blog_name = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8'); + } else { + define('_CHARSET', 'UTF-8'); + } + + $config_indexurl = replaceDoubleBackslash($config_indexurl); + $config_adminurl = replaceDoubleBackslash($config_adminurl); + $config_mediaurl = replaceDoubleBackslash($config_mediaurl); + $config_skinsurl = replaceDoubleBackslash($config_skinsurl); + $config_pluginurl = replaceDoubleBackslash($config_pluginurl); + $config_actionurl = replaceDoubleBackslash($config_actionurl); + $config_adminpath = replaceDoubleBackslash($config_adminpath); + $config_skinspath = replaceDoubleBackslash($config_skinspath); + $config_mediapath = replaceDoubleBackslash($config_mediapath); + + // 1. check all the data + $errors = array(); + + if (!$mysql_database) { + array_push($errors, _ERROR2); + } + + if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) { + array_push($errors, _ERROR3); + } + + if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) { + array_push($errors, _ERROR4); + } + + // TODO: add action.php check + if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) { + array_push($errors, _ERROR5); + } + + if (!endsWithSlash($config_adminpath) ) { + array_push($errors, _ERROR6); + } + + if (!endsWithSlash($config_mediapath) ) { + array_push($errors, _ERROR7); + } + + if (!endsWithSlash($config_skinspath) ) { + array_push($errors, _ERROR8); + } + + if (!is_dir($config_adminpath) ) { + array_push($errors, _ERROR9); + } + + if (!_isValidMailAddress($user_email) ) { + array_push($errors, _ERROR10); + } + + if (!_isValidDisplayName($user_name) ) { + array_push($errors, _ERROR11); + } + + if (!$user_password || !$user_password2) { + array_push($errors, _ERROR12); + } + + if ($user_password != $user_password2) { + array_push($errors, _ERROR13); + } + + if (!_isValidShortName($blog_shortname) ) { + array_push($errors, _ERROR14); + } + + if (sizeof($errors) > 0) { + showErrorMessages($errors); + } + + // 2-1. try to log in to mySQL + + global $MYSQL_CONN; + // 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 . ': ' . sql_error() ); + } + +// + // 2-2. set DEFAULT CHARSET and COLLATE + $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info($MYSQL_CONN)))); + if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') { + mysql_set_charset($charset); + } elseif ($mySqlVer >= '4.1.0') { + sql_query("SET NAMES " . $charset); + } + $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci'; // */ - // 3. try to create database (if needed) - if ($mysql_create == 1) { - $sql = 'CREATE DATABASE ' - . $mysql_database -/*/ - . ' DEFAULT CHARACTER SET ' - . $charset - . ' COLLATE ' - . $collation + // 3. try to create database (if needed) + if ($mysql_create == 1) { + $sql = 'CREATE DATABASE ' + . $mysql_database; +// + if ($mySqlVer >= '4.1.0') { + $sql .= ' DEFAULT CHARACTER SET ' + . $charset + . ' COLLATE ' + . $collation; + } // */ - . ''; - mysql_query($sql) or _doError(_ERROR16 . ': ' . mysql_error()); - } - - // 4. try to select database - mysql_select_db($mysql_database) or _doError(_ERROR17); - - // 5. execute queries - $filename = 'install.sql'; - $fd = fopen($filename, 'r'); - $queries = fread($fd, filesize($filename) ); - fclose($fd); - - $queries = split("(;\n|;\r)", $queries); - - $aTableNames = array( - 'nucleus_actionlog', - 'nucleus_ban', - 'nucleus_blog', - 'nucleus_category', - 'nucleus_comment', - 'nucleus_config', - 'nucleus_item', - 'nucleus_karma', - 'nucleus_member', - 'nucleus_plugin', - 'nucleus_skin', - 'nucleus_template', - 'nucleus_team', - 'nucleus_activation', - 'nucleus_tickets' - ); + sql_query($sql,$MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN)); + } + + // 4. try to select database + sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17); + + // 5. execute queries + $filename = 'install.sql'; + $fd = fopen($filename, 'r'); + $queries = fread($fd, filesize($filename) ); + fclose($fd); + + $queries = split("(;\n|;\r)", $queries); + + $aTableNames = array( + 'nucleus_actionlog', + 'nucleus_ban', + 'nucleus_blog', + 'nucleus_category', + 'nucleus_comment', + 'nucleus_config', + 'nucleus_item', + 'nucleus_karma', + 'nucleus_member', + 'nucleus_plugin', + 'nucleus_skin', + 'nucleus_template', + 'nucleus_team', + 'nucleus_activation', + 'nucleus_tickets' + ); // these are unneeded (one of the replacements above takes care of them) // 'nucleus_plugin_event', // 'nucleus_plugin_option', @@ -627,23 +655,23 @@ function doInstall() { // 'nucleus_skin_desc', // 'nucleus_template_desc', - $aTableNamesPrefixed = array( - $mysql_prefix . 'nucleus_actionlog', - $mysql_prefix . 'nucleus_ban', - $mysql_prefix . 'nucleus_blog', - $mysql_prefix . 'nucleus_category', - $mysql_prefix . 'nucleus_comment', - $mysql_prefix . 'nucleus_config', - $mysql_prefix . 'nucleus_item', - $mysql_prefix . 'nucleus_karma', - $mysql_prefix . 'nucleus_member', - $mysql_prefix . 'nucleus_plugin', - $mysql_prefix . 'nucleus_skin', - $mysql_prefix . 'nucleus_template', - $mysql_prefix . 'nucleus_team', - $mysql_prefix . 'nucleus_activation', - $mysql_prefix . 'nucleus_tickets' - ); + $aTableNamesPrefixed = array( + $mysql_prefix . 'nucleus_actionlog', + $mysql_prefix . 'nucleus_ban', + $mysql_prefix . 'nucleus_blog', + $mysql_prefix . 'nucleus_category', + $mysql_prefix . 'nucleus_comment', + $mysql_prefix . 'nucleus_config', + $mysql_prefix . 'nucleus_item', + $mysql_prefix . 'nucleus_karma', + $mysql_prefix . 'nucleus_member', + $mysql_prefix . 'nucleus_plugin', + $mysql_prefix . 'nucleus_skin', + $mysql_prefix . 'nucleus_template', + $mysql_prefix . 'nucleus_team', + $mysql_prefix . 'nucleus_activation', + $mysql_prefix . 'nucleus_tickets' + ); // these are unneeded (one of the replacements above takes care of them) // $mysql_prefix . 'nucleus_plugin_event', // $mysql_prefix . 'nucleus_plugin_option', @@ -651,288 +679,298 @@ function doInstall() { // $mysql_prefix . 'nucleus_skin_desc', // $mysql_prefix . 'nucleus_template_desc', - $count = count($queries); + $count = count($queries); - for ($idx = 0; $idx < $count; $idx++) { - $query = trim($queries[$idx]); - // echo "QUERY = " . htmlspecialchars($query) . "

"; + for ($idx = 0; $idx < $count; $idx++) { + $query = trim($queries[$idx]); + // echo "QUERY = " . htmlspecialchars($query) . "

"; - if ($query) { + if ($query) { - if ($mysql_usePrefix == 1) { - $query = str_replace($aTableNames, $aTableNamesPrefixed, $query); - } -/*/ - if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0) { - $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation; - } + if ($mysql_usePrefix == 1) { + $query = str_replace($aTableNames, $aTableNamesPrefixed, $query); + } +// + 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() ); - } - } - - // 5a make first post - if ($charset == 'ujis') { - $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8'); - $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8'); - $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8'); - } else { - $itm_title = _1ST_POST_TITLE; - $itm_body = _1ST_POST; - $itm_more = _1ST_POST2; - } - $newpost = "INSERT INTO " - . tableName('nucleus_item') - . " VALUES (" - . "1, " - . "'" . $itm_title . "'," - . " '" . $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() ); - - // 6. update global settings - updateConfig('IndexURL', $config_indexurl); - updateConfig('AdminURL', $config_adminurl); - updateConfig('MediaURL', $config_mediaurl); - updateConfig('SkinsURL', $config_skinsurl); - updateConfig('PluginURL', $config_pluginurl); - updateConfig('ActionURL', $config_actionurl); - updateConfig('AdminEmail', $config_adminemail); - updateConfig('SiteName', $config_sitename); - if ($charset == 'ujis') { - updateConfig('Language', 'japanese-euc'); - } - - // 7. update GOD member - $query = 'UPDATE ' . tableName('nucleus_member') - . " SET mname = '" . addslashes($user_name) . "'," - . " mrealname = '" . addslashes($user_realname) . "'," - . " mpassword = '" . md5(addslashes($user_password) ) . "'," - . " murl = '" . addslashes($config_indexurl) . "'," - . " memail = '" . addslashes($user_email) . "'," - . " madmin = 1," - . " mcanlogin = 1" - . " WHERE" - . " mnumber = 1"; - - mysql_query($query) or _doError(_ERROR19 . ': ' . mysql_error() ); - - // 8. update weblog settings - $query = 'UPDATE ' . tableName('nucleus_blog') - . " SET bname = '" . addslashes($blog_name) . "'," - . " bshortname = '" . addslashes($blog_shortname) . "'," - . " burl = '" . addslashes($config_indexurl) . "'" - . " WHERE" - . " bnumber = 1"; - - mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() ); - - // 8-2. update category settings - if ($charset == 'ujis') { - $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8'); - $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8'); - } else { - $cat_name = _GENERALCAT_NAME; - $cat_desc = _GENERALCAT_DESC; - } - $query = 'UPDATE ' . tableName('nucleus_category') - . " SET cname = '" . $cat_name . "'," - . " cdesc = '" . $cat_desc . "'" - . " WHERE" - . " catid = 1"; - - mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() ); - - // 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() ); - - global $aConfPlugsToInstall, $aConfSkinsToImport; - $aSkinErrors = array(); - $aPlugErrors = array(); - - if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) { - // 10. set global variables - global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX; - - $MYSQL_HOST = $mysql_host; - $MYSQL_USER = $mysql_user; - $MYSQL_PASSWORD = $mysql_password; - $MYSQL_DATABASE = $mysql_database; - $MYSQL_PREFIX = ($mysql_usePrefix == 1) ? $mysql_prefix : ''; - - global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS; - - $DIR_NUCLEUS = $config_adminpath; - $DIR_MEDIA = $config_mediapath; - $DIR_SKINS = $config_skinspath; - $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/'; - $DIR_LANG = $DIR_NUCLEUS . 'language/'; - $DIR_LIBS = $DIR_NUCLEUS . 'libs/'; - - // close database connection (needs to be closed if we want to include globalfunctions.php) - mysql_close(); - - $manager = ''; - include_once($DIR_LIBS . 'globalfunctions.php'); - - // 11. install custom skins - $aSkinErrors = installCustomSkins($manager); - - // 12. install NP_Ping, if decided - if ($weblog_ping == 1) { - global $aConfPlugsToInstall; - array_push($aConfPlugsToInstall, "NP_Ping"); - } - - // 13. install custom plugins - $aPlugErrors = installCustomPlugs($manager); - } - - // 14. Write config file ourselves (if possible) - $bConfigWritten = 0; - - if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) { - $config_data = '<' . '?php' . "\n\n"; - //$config_data .= "\n"; (extraneous, just added extra \n to previous line - $config_data .= " // mySQL connection information\n"; - $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n"; - $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n"; - $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 .= "\n"; - $config_data .= " // main nucleus directory\n"; - $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n"; - $config_data .= "\n"; - $config_data .= " // path to media dir\n"; - $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n"; - $config_data .= "\n"; - $config_data .= " // extra skin files for imported skins\n"; - $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n"; - $config_data .= "\n"; - $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n"; - $config_data .= " // you can redefine them if you wish\n"; - $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n"; - $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n"; - $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n"; - $config_data .= "\n"; - $config_data .= " // include libs\n"; - $config_data .= " include(\$DIR_LIBS . 'globalfunctions.php');\n"; - $config_data .= " if (!extension_loaded('mbstring')) {\n"; - $config_data .= " include(\$DIR_LIBS . 'mb_emulator/mb-emulator.php');\n"; - $config_data .= " }\n"; - $config_data .= "?" . ">"; - - $result = @fputs($fp, $config_data, strlen($config_data) ); - fclose($fp); - - if ($result) { - $bConfigWritten = 1; - } - } + sql_query($query,$MYSQL_CONN) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . sql_error($MYSQL_CONN) ); + } + } + + // 5a make first post + if ($charset == 'ujis') { + $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8'); + $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8'); + $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8'); + } else { + $itm_title = _1ST_POST_TITLE; + $itm_body = _1ST_POST; + $itm_more = _1ST_POST2; + } + $newpost = "INSERT INTO " + . tableName('nucleus_item') + . " VALUES (" + . "1, " + . "'" . $itm_title . "'," + . " '" . $itm_body . "'," + . " '" . $itm_more . "'," + . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);"; + sql_query($newpost,$MYSQL_CONN) or _doError(_ERROR18 . ' (' . htmlspecialchars($newpost) . '): ' . sql_error($MYSQL_CONN) ); + + // 6. update global settings + updateConfig('IndexURL', $config_indexurl); + updateConfig('AdminURL', $config_adminurl); + updateConfig('MediaURL', $config_mediaurl); + updateConfig('SkinsURL', $config_skinsurl); + updateConfig('PluginURL', $config_pluginurl); + updateConfig('ActionURL', $config_actionurl); + updateConfig('AdminEmail', $config_adminemail); + updateConfig('SiteName', $config_sitename); + if ($charset == 'ujis') { + updateConfig('Language', 'japanese-euc'); + } + + // 7. update GOD member + $query = 'UPDATE ' . tableName('nucleus_member') + . " SET mname = '" . addslashes($user_name) . "'," + . " mrealname = '" . addslashes($user_realname) . "'," + . " mpassword = '" . md5(addslashes($user_password) ) . "'," + . " murl = '" . addslashes($config_indexurl) . "'," + . " memail = '" . addslashes($user_email) . "'," + . " madmin = 1," + . " mcanlogin = 1" + . " WHERE" + . " mnumber = 1"; + + sql_query($query,$MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN) ); + + // 8. update weblog settings + $query = 'UPDATE ' . tableName('nucleus_blog') + . " SET bname = '" . addslashes($blog_name) . "'," + . " bshortname = '" . addslashes($blog_shortname) . "'," + . " burl = '" . addslashes($config_indexurl) . "'" + . " WHERE" + . " bnumber = 1"; + + sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) ); + + // 8-2. update category settings + if ($charset == 'ujis') { + $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8'); + $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8'); + } else { + $cat_name = _GENERALCAT_NAME; + $cat_desc = _GENERALCAT_DESC; + } + $query = 'UPDATE ' . tableName('nucleus_category') + . " SET cname = '" . $cat_name . "'," + . " cdesc = '" . $cat_desc . "'" + . " WHERE" + . " catid = 1"; + + 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"; + + sql_query($query,$MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN) ); + + global $aConfPlugsToInstall, $aConfSkinsToImport; + $aSkinErrors = array(); + $aPlugErrors = array(); + + if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) { + // 10. set global variables + global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX; + + $MYSQL_HOST = $mysql_host; + $MYSQL_USER = $mysql_user; + $MYSQL_PASSWORD = $mysql_password; + $MYSQL_DATABASE = $mysql_database; + $MYSQL_PREFIX = ($mysql_usePrefix == 1) ? $mysql_prefix : ''; + + global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS; + + $DIR_NUCLEUS = $config_adminpath; + $DIR_MEDIA = $config_mediapath; + $DIR_SKINS = $config_skinspath; + $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/'; + $DIR_LANG = $DIR_NUCLEUS . 'language/'; + $DIR_LIBS = $DIR_NUCLEUS . 'libs/'; + + // close database connection (needs to be closed if we want to include globalfunctions.php) + sql_close($MYSQL_CONN); + + $manager = ''; + include_once($DIR_LIBS . 'globalfunctions.php'); + + // 11. install custom skins + $aSkinErrors = installCustomSkins($manager); + $defskinQue = 'SELECT `sdnumber` as result FROM ' . sql_table('skin_desc') . ' WHERE `sdname` = "default"'; + $defSkinID = quickQuery($defskinQue); + $updateQuery = 'UPDATE ' . sql_table('blog') . ' SET `bdefskin` = ' . intval($defSkinID) . ' WHERE `bnumber` = 1'; + sql_query($updateQuery); + + // 12. install NP_Ping, if decided + if ($weblog_ping == 1) { + global $aConfPlugsToInstall; + array_push($aConfPlugsToInstall, "NP_Ping"); + } + + // 13. install custom plugins + $aPlugErrors = installCustomPlugs($manager); + } + + // 14. Write config file ourselves (if possible) + $bConfigWritten = 0; + + if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) { + $config_data = '<' . '?php' . "\n\n"; + //$config_data .= "\n"; (extraneous, just added extra \n to previous line + $config_data .= " // mySQL connection information\n"; + $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n"; + $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n"; + $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"; + $config_data .= "\n"; + $config_data .= " // path to media dir\n"; + $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n"; + $config_data .= "\n"; + $config_data .= " // extra skin files for imported skins\n"; + $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n"; + $config_data .= "\n"; + $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n"; + $config_data .= " // you can redefine them if you wish\n"; + $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n"; + $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n"; + $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n"; + $config_data .= "\n"; + $config_data .= " // include libs\n"; + $config_data .= " include(\$DIR_LIBS . 'globalfunctions.php');\n"; + $config_data .= " if (!extension_loaded('mbstring')) {\n"; + $config_data .= " include(\$DIR_LIBS . 'mb_emulator/mb-emulator.php');\n"; + $config_data .= " }\n"; + $config_data .= "?" . ">"; + + $result = @fputs($fp, $config_data, strlen($config_data) ); + fclose($fp); + + if ($result) { + $bConfigWritten = 1; + } + } ?> - - <?php echo _TITLE; ?> - + + <?php echo _TITLE; ?> + -

+
0) { - echo '

' . _TITLE2 . '

'; - echo ''; - } - - if (!$bConfigWritten) { ?> -

- - - -
<?php
-	// mySQL connection information
-	$MYSQL_HOST     = '';
-	$MYSQL_USER     = '';
-	$MYSQL_PASSWORD = 'xxxxxxxxxxx';
-	$MYSQL_DATABASE = '';
-	$MYSQL_PREFIX   = '';
-
-	// main nucleus directory
-	$DIR_NUCLEUS = '';
-
-	// path to media dir
-	$DIR_MEDIA   = '';
-
-	// extra skin files for imported skins
-	$DIR_SKINS   = '';
-
-	// these dirs are normally sub dirs of the nucleus dir, but
-	// you can redefine them if you wish
-	$DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
-	$DIR_LANG    = $DIR_NUCLEUS . 'language/';
-	$DIR_LIBS    = $DIR_NUCLEUS . 'libs/';
-
-	// include libs
-	include($DIR_LIBS . 'globalfunctions.php');
-	if (!extension_loaded('mbstring')) {
-		include($DIR_LIBS . 'mb_emulator/mb-emulator.php');
-	}
+    $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
+
+    if (count($aAllErrors) > 0) {
+        echo '

' . _TITLE2 . '

'; + echo '
  • ' . implode('
  • ', $aAllErrors) . '
'; + } + + if (!$bConfigWritten) { ?> +

+ + + +
<?php
+    // mySQL connection information
+    $MYSQL_HOST     = '';
+    $MYSQL_USER     = '';
+    $MYSQL_PASSWORD = 'xxxxxxxxxxx';
+    $MYSQL_DATABASE = '';
+    $MYSQL_PREFIX   = '';
+
+    // main nucleus directory
+    $DIR_NUCLEUS = '';
+
+    // path to media dir
+    $DIR_MEDIA   = '';
+
+    // extra skin files for imported skins
+    $DIR_SKINS   = '';
+
+    // these dirs are normally sub dirs of the nucleus dir, but
+    // you can redefine them if you wish
+    $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
+    $DIR_LANG    = $DIR_NUCLEUS . 'language/';
+    $DIR_LIBS    = $DIR_NUCLEUS . 'libs/';
+
+    // include libs
+    include($DIR_LIBS . 'globalfunctions.php');
+    if (!extension_loaded('mbstring')) {
+        include($DIR_LIBS . 'mb_emulator/mb-emulator.php');
+    }
 ?>
- + -
- -
+
+ +
-

+

- + -

- - +

+ + -
    -
  • -
  • -
+
    +
  • +
  • +
-

+

- + -
    -
  • -
  • -
+
    +
  • +
  • +
  • +
- + -

+

-

-

    -
  • -
  • -
-

+

+

    +
  • +
  • +
+

@@ -941,129 +979,133 @@ function doInstall() { } function installCustomPlugs(&$manager) { - global $aConfPlugsToInstall, $DIR_LIBS; + global $aConfPlugsToInstall, $DIR_LIBS; - $aErrors = array(); + $aErrors = array(); - if (count($aConfPlugsToInstall) == 0) { - return $aErrors; - } + if (count($aConfPlugsToInstall) == 0) { + return $aErrors; + } - $res = sql_query('SELECT * FROM ' . sql_table('plugin') ); - $numCurrent = mysql_num_rows($res); + $res = sql_query('SELECT * FROM ' . sql_table('plugin') ); + $numCurrent = sql_num_rows($res); - foreach ($aConfPlugsToInstall as $plugName) { - // do this before calling getPlugin (in case the plugin id is used there) - $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")'; - sql_query($query); + foreach ($aConfPlugsToInstall as $plugName) { + // do this before calling getPlugin (in case the plugin id is used there) + $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")'; + sql_query($query); - // get and install the plugin - $manager->clearCachedInfo('installedPlugins'); - $plugin =& $manager->getPlugin($plugName); - $plugin->plugid = $numCurrent; + // get and install the plugin + $manager->clearCachedInfo('installedPlugins'); + $plugin =& $manager->getPlugin($plugName); + $plugin->plugid = $numCurrent; - if (!$plugin) { - sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\''); - $numCurrent--; - array_push($aErrors, _ERROR22 . $plugName); - continue; - } + if (!$plugin) { + sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\''); + $numCurrent--; + array_push($aErrors, _ERROR22 . $plugName); + continue; + } - $plugin->install(); - } + $plugin->install(); + } - // SYNC PLUGIN EVENT LIST - sql_query('DELETE FROM ' . sql_table('plugin_event') ); + // SYNC PLUGIN EVENT LIST + sql_query('DELETE FROM ' . sql_table('plugin_event') ); - // loop over all installed plugins - $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') ); + // loop over all installed plugins + $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') ); - while($o = mysql_fetch_object($res) ) { - $pid = $o->pid; - $plug =& $manager->getPlugin($o->pfile); + while($o = sql_fetch_object($res) ) { + $pid = $o->pid; + $plug =& $manager->getPlugin($o->pfile); - if ($plug) { - $eventList = $plug->getEventList(); + if ($plug) { + $eventList = $plug->getEventList(); - foreach ($eventList as $eventName) { - sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')'); - } - } - } + foreach ($eventList as $eventName) { + sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')'); + } + } + } - return $aErrors; + return $aErrors; } function installCustomSkins(&$manager) { - global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS; + global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS; $aErrors = array(); - - if (count($aConfSkinsToImport) == 0) { - return $aErrors; + global $manager; + if (empty($manager)) { + $manager = new MANAGER; } - // load skinie class - include_once($DIR_LIBS . 'skinie.php'); + if (count($aConfSkinsToImport) == 0) { + return $aErrors; + } - $importer = new SKINIMPORT(); + // load skinie class + include_once($DIR_LIBS . 'skinie.php'); - foreach ($aConfSkinsToImport as $skinName) { - $importer->reset(); - $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml'; + $importer = new SKINIMPORT(); - if (!@file_exists($skinFile) ) { - array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2); - continue; - } + foreach ($aConfSkinsToImport as $skinName) { + $importer->reset(); + $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml'; - $error = $importer->readFile($skinFile); + if (!@file_exists($skinFile) ) { + array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2); + continue; + } - if ($error) { - array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error); - continue; - } + $error = $importer->readFile($skinFile); - $error = $importer->writeToDatabase(1); + if ($error) { + array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error); + continue; + } - if ($error) { - array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error); - continue; - } - } + $error = $importer->writeToDatabase(1); + + if ($error) { + array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error); + continue; + } + } - return $aErrors; + return $aErrors; } // give an error if one or more nucleus are not accessible function doCheckFiles() { - $missingfiles = array(); - $files = array( - 'install.sql', - 'index.php', - 'action.php', - 'nucleus/index.php', - 'nucleus/libs/globalfunctions.php', - 'nucleus/libs/ADMIN.php', - 'nucleus/libs/BLOG.php', - 'nucleus/libs/COMMENT.php', - 'nucleus/libs/COMMENTS.php', - 'nucleus/libs/ITEM.php', - 'nucleus/libs/MEMBER.php', - 'nucleus/libs/SKIN.php', - 'nucleus/libs/TEMPLATE.php', - 'nucleus/libs/MEDIA.php', - 'nucleus/libs/ACTIONLOG.php', - 'nucleus/media.php' - ); - - $count = count($files); - - for ($i = 0; $i < $count; $i++) { - if (!is_readable($files[$i]) ) { - array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2); - } - } + $missingfiles = array(); + $files = array( + 'install.sql', + 'index.php', + 'action.php', + 'nucleus/index.php', + 'nucleus/libs/globalfunctions.php', + 'nucleus/libs/ADMIN.php', + 'nucleus/libs/BLOG.php', + 'nucleus/libs/COMMENT.php', + 'nucleus/libs/COMMENTS.php', + 'nucleus/libs/ITEM.php', + 'nucleus/libs/MEMBER.php', + 'nucleus/libs/SKIN.php', + 'nucleus/libs/TEMPLATE.php', + 'nucleus/libs/MEDIA.php', + 'nucleus/libs/ACTIONLOG.php', + 'nucleus/media.php' + ); + + $count = count($files); + + for ($i = 0; $i < $count; $i++) { + if (!is_readable($files[$i]) ) { + array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2); + } + } // The above code replaces several if statements of the form: @@ -1071,40 +1113,41 @@ function doCheckFiles() { // array_push($missingfiles, 'File install.sql is missing or not readable'); // } - if (count($missingfiles) > 0) { - showErrorMessages($missingfiles); - } + if (count($missingfiles) > 0) { + showErrorMessages($missingfiles); + } } function updateConfig($name, $val) { - $name = addslashes($name); - $val = trim(addslashes($val) ); + global $MYSQL_CONN; + $name = addslashes($name); + $val = trim(addslashes($val) ); - $query = 'UPDATE ' . tableName('nucleus_config') - . " SET value = '$val'" - . " WHERE name = '$name'"; + $query = 'UPDATE ' . tableName('nucleus_config') + . " 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 . ': ' . sql_error($MYSQL_CONN) ); + return sql_insert_id($MYSQL_CONN); } function replaceDoubleBackslash($input) { - return str_replace('\\', '/', $input); + return str_replace('\\', '/', $input); } function endsWithSlash($s) { - return (strrpos($s, '/') == strlen($s) - 1); + return (strrpos($s, '/') == strlen($s) - 1); } /** * Checks if email address is valid */ function _isValidMailAddress($address) { - if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) { - return 1; - } else { - return 0; - } + if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) { + return 1; + } else { + return 0; + } } // returns true if the given string is a valid shortname @@ -1112,11 +1155,11 @@ function _isValidMailAddress($address) { // logic: starts and ends with a non space, can contain spaces in between // min 2 chars function _isValidShortName($name) { - if (eregi("^[a-z0-9]+$", $name) ) { - return 1; - } else { - return 0; - } + if (eregi("^[a-z0-9]+$", $name) ) { + return 1; + } else { + return 0; + } } @@ -1124,67 +1167,67 @@ function _isValidShortName($name) { // returns true if the given string is a valid display name // (to check nicknames) function _isValidDisplayName($name) { - if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) { - return 1; - } else { - return 0; - } + if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) { + return 1; + } else { + return 0; + } } function _doError($msg) { - ?> + ?> - - <?php echo _TITLE; ?> - + + <?php echo _TITLE; ?> + -
-

+
+

-

: "";

+

"";

-

+

+ ?> - - <?php echo _TITLE; ?> - + + <?php echo _TITLE; ?> + -
-

+
+

-

:

+

:

-
    +
      ' . $msg . ''; - } + while($msg = array_shift($errors) ) { + echo '
    • ' . $msg . '
    • '; + } ?> -
    +
-

+