echo "<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"" . 'index.php?mode=migrate&step=4' . '&language=' . $installer->getLanguage() . '&site_url=' . $_REQUEST['site_url'] . '&site_admin_url=' . $_REQUEST['site_admin_url'] . "\";',3000);</script>\n"; } else { if ($delayPerSession != 0) { echo '<p><b>' . $LANG_BIGDUMP[24] . $delayPerSession . $LANG_BIGDUMP[25] . PHP_EOL; } // Go to the next step echo '<script language="JavaScript" type="text/javascript">window.setTimeout(\'location.href="' . $_SERVER['PHP_SELF'] . '?start=' . $lineNumber . '&fn=' . urlencode($currentFileName) . '&foffset=' . $fOffset . '&totalqueries=' . $totalQueries . '&db_connection_charset=' . $db_connection_charset . '&language=' . $installer->getLanguage() . '&site_url=' . $site_url . '&site_admin_url=' . $site_admin_url . '";\',500+' . $delayPerSession . ');</script>' . PHP_EOL . '<noscript>' . PHP_EOL . ' <p><a href="' . $_SERVER['PHP_SELF'] . '?start=' . $lineNumber . '&fn=' . urlencode($currentFileName) . '&foffset=' . $fOffset . '&totalqueries=' . $totalQueries . '&db_connection_charset=' . $db_connection_charset . '&language=' . $installer->getLanguage() . '&site_url=' . $site_url . '&site_admin_url=' . $site_admin_url . '">Continue from the line ' . $lineNumber . '</a></p>' . PHP_EOL . '</noscript>' . PHP_EOL . '<p><b><a href="' . $_SERVER['PHP_SELF'] . '">' . $LANG_BIGDUMP[26] . '</a></b> ' . $LANG_BIGDUMP[27] . ' <b>' . $LANG_BIGDUMP[28] . '</b></p>' . PHP_EOL; } } else { echo $installer->getAlertMsg($LANG_BIGDUMP[29]); } } } if ($error) { $backUrl = 'index.php?mode=migrate'; $language = $installer->getLanguage(); if (!empty($language)) { $backUrl .= '&language=' . $language; } echo '<p><a href="' . $backUrl . '">' . $LANG_BIGDUMP[30] . '</a> ' . $LANG_BIGDUMP[31] . '</p>' . PHP_EOL; } if ($dbConnection) { Geeklog\Db::disconnect(); $dbConnection = null; } if ($file && !$gzipMode) { fclose($file); } elseif ($file && $gzipMode) { gzclose($file); } echo Installer::getFooter();
/** * Modify db-config.php * * @param string $dbConfigFilePath Full path to db-config.php * @param array $db Database information to save * @return bool True if successful, false if not */ private function writeConfig($dbConfigFilePath, array $db) { // We may have included db-config.php elsewhere already, in which case // all of these variables need to be imported from the global namespace global $_DB_host, $_DB_name, $_DB_user, $_DB_pass, $_DB_table_prefix, $_DB_dbms, $_DB_charset; require_once $dbConfigFilePath; // Grab the current DB values $isUtf8 = false; if (!empty($_DB_charset)) { $isUtf8 = $_DB_charset === 'utf8' || $_DB_charset === 'utf8mb4'; } elseif (isset($db['utf8'])) { $isUtf8 = $db['utf8']; } $db = array('host' => isset($db['host']) ? $db['host'] : $_DB_host, 'name' => isset($db['name']) ? $db['name'] : $_DB_name, 'user' => isset($db['user']) ? $db['user'] : $_DB_user, 'pass' => isset($db['pass']) ? $db['pass'] : $_DB_pass, 'table_prefix' => isset($db['table_prefix']) ? $db['table_prefix'] : $_DB_table_prefix, 'type' => isset($db['type']) ? $db['type'] : $_DB_dbms); if ($db['type'] === 'mysql-innodb') { $db['type'] = 'mysql'; } // Read in db-config.php so we can insert the DB information clearstatcache(); $dbConfigData = @file_get_contents($dbConfigFilePath); // Replace the values with the new ones $dbConfigData = str_replace("\$_DB_host = '" . $_DB_host . "';", "\$_DB_host = '" . $db['host'] . "';", $dbConfigData); // Host $dbConfigData = str_replace("\$_DB_name = '" . $_DB_name . "';", "\$_DB_name = '" . $db['name'] . "';", $dbConfigData); // Database $dbConfigData = str_replace("\$_DB_user = '******';", "\$_DB_user = '******'user'] . "';", $dbConfigData); // Username $dbConfigData = str_replace("\$_DB_pass = '******';", "\$_DB_pass = '******'pass'] . "';", $dbConfigData); // Password $dbConfigData = str_replace("\$_DB_table_prefix = '" . $_DB_table_prefix . "';", "\$_DB_table_prefix = '" . $db['table_prefix'] . "';", $dbConfigData); // Table prefix $dbConfigData = str_replace("\$_DB_dbms = '" . $_DB_dbms . "';", "\$_DB_dbms = '" . $db['type'] . "';", $dbConfigData); // Database type ('mysql' or 'pgsql') if ($db['type'] === 'mysql' && $isUtf8 && version_compare(self::GL_VERSION, '2.1.2', '>=') && (!empty($_DB_charset) || $this->env['mode'] === 'install')) { if (!empty($_DB_charset)) { $db['charset'] = $_DB_charset; } else { require_once __DIR__ . '/db.class.php'; $dbTypes = Geeklog\Db::getDrivers(); if (in_array(Geeklog\Db::DB_MYSQLI, $dbTypes)) { $driver = Geeklog\Db::connect(Geeklog\Db::DB_MYSQLI, $db); } else { $driver = Geeklog\Db::connect(Geeklog\Db::DB_MYSQL, $db); } $db['charset'] = $driver->getVersion() >= 50503 ? 'utf8mb4' : 'utf8'; } $dbConfigData = str_replace("\$_DB_charset = '" . $_DB_charset . "';", "\$_DB_charset = '" . $db['charset'] . "';", $dbConfigData); // Charset } // Write our changes to db-config.php $result = @file_put_contents($dbConfigFilePath, $dbConfigData) !== false; return $result; }