"; if ($query) { if ($mysql_usePrefix == 1) { $query = str_replace($aTableNames, $aTableNamesPrefixed, $query); } mysql_query($query) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . mysql_error() ); } } // 5a make first post $newpost = "INSERT INTO " . tableName('nucleus_item') . " VALUES (1, '" . _1ST_POST_TITLE . "', '" . _1ST_POST . "', '" . _1ST_POST2 . "', 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); // 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 $query = 'UPDATE ' . tableName('nucleus_category') . " SET cname = '" . addslashes(_GENERALCAT_NAME) . "'," . " cdesc = '" . addslashes(_GENERALCAT_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; } } ?>
<?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');
}
?>
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; } $plugin->install(); } // 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') ); while($o = mysql_fetch_object($res) ) { $pid = $o->pid; $plug =& $manager->getPlugin($o->pfile); if ($plug) { $eventList = $plug->getEventList(); foreach ($eventList as $eventName) { sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')'); } } } return $aErrors; } function installCustomSkins(&$manager) { global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS; $aErrors = array(); if (count($aConfSkinsToImport) == 0) { return $aErrors; } // load skinie class include_once($DIR_LIBS . 'skinie.php'); $importer = new SKINIMPORT(); foreach ($aConfSkinsToImport as $skinName) { $importer->reset(); $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml'; if (!@file_exists($skinFile) ) { array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2); continue; } $error = $importer->readFile($skinFile); if ($error) { array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error); continue; } $error = $importer->writeToDatabase(1); if ($error) { array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error); continue; } } 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); } } // The above code replaces several if statements of the form: // if (!is_readable('install.sql') ) { // array_push($missingfiles, 'File install.sql is missing or not readable'); // } if (count($missingfiles) > 0) { showErrorMessages($missingfiles); } } function updateConfig($name, $val) { $name = addslashes($name); $val = trim(addslashes($val) ); $query = 'UPDATE ' . tableName('nucleus_config') . " SET value = '$val'" . " WHERE name = '$name'"; mysql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() ); return mysql_insert_id(); } function replaceDoubleBackslash($input) { return str_replace('\\', '/', $input); } function endsWithSlash($s) { 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; } } // returns true if the given string is a valid shortname // (to check short blog names and nicknames) // 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; } } // 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; } } function _doError($msg) { ?>
: "";
: