$authkey = substr(md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $dbhost . $dbuser . $dbpw . $dbname . $username . $password . $pconnect . substr($timestamp, 0, 6)), 8, 6) . random(10); $_config['db'][1]['dbhost'] = $dbhost; $_config['db'][1]['dbname'] = $dbname; $_config['db'][1]['dbpw'] = $dbpw; $_config['db'][1]['dbuser'] = $dbuser; $_config['db'][1]['tablepre'] = $tablepre; $_config['admincp']['founder'] = (string) $uid; $_config['security']['authkey'] = $authkey; $_config['cookie']['cookiepre'] = random(4) . '_'; $_config['memory']['prefix'] = random(6) . '_'; save_config_file(ROOT_PATH . CONFIG, $_config, $default_config); $db = new dbstuff(); $db->connect($dbhost, $dbuser, $dbpw, $dbname, DBCHARSET); if (!VIEW_OFF) { show_header(); show_install(); } if (DZUCFULL) { install_uc_server(); } $sql = file_get_contents($sqlfile); $sql = str_replace("\r\n", "\n", $sql); runquery($sql); runquery($extrasql); $sql = file_get_contents(ROOT_PATH . './install/data/install_data.sql'); $sql = str_replace("\r\n", "\n", $sql); runquery($sql); $onlineip = $_SERVER['REMOTE_ADDR']; $timestamp = time(); $backupdir = substr(md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . substr($timestamp, 0, 4)), 8, 6); $ret = false;
function db_init() { global $sqlfile, $db, $multitable, $step, $lockfile; if (!isset($_SESSION['dbinfo'])) { header("location: index.php?step=2"); } $dbname = $_SESSION['dbinfo']['dbname']; $dbinfo = $_SESSION['dbinfo']; $adminpwd = $_SESSION['adminpwd']; $adminemail = $_SESSION['founderemail']; $multitable = $_SESSION['multitable']; $config = "<?php \r\ndefine('SSO_MODE', '{$_SESSION['sso_mode']}');\r\n"; $config .= "define('MULTI_TABLE', '{$_SESSION['multitable']}');\r\n"; $config .= '$GLOBALS ["gDataBase"] ["db"] = array ( "dbname" => "' . $dbname . '", "type" => "mysql", "host" => "' . $dbinfo['dbhost'] . '", "port" => 3306, "user" => "' . $dbinfo['dbuser'] . '", "passwd" => "' . $dbinfo['dbpw'] . '", "charset"=> "utf8", ); ?>'; $fp = fopen(CONFIG, 'w'); fwrite($fp, $config); fclose($fp); $db = new dbstuff(); $db->connect($dbinfo['dbhost'], $dbinfo['dbuser'], $dbinfo['dbpw'], $dbname, 'UTF8'); $sql = file_get_contents($sqlfile); $sql = str_replace("\r\n", "\n", $sql); if (!VIEW_OFF) { show_install(); } runquery($sql); $user['user'] = $adminemail; $user['user_email'] = $adminemail; $user['user_question'] = ''; $user['user_answer'] = ''; $user['user_password'] = md5(md5($adminpwd) . $user['user']); $user['user_nickname'] = 'administrator'; $user['user_sex'] = 1; $user['user_reg_ip'] = '127.0.0.1'; createNewUser($user); VIEW_OFF && show_msg('initdbresult_succ'); $step++; if (!VIEW_OFF) { echo '<script type="text/javascript">document.getElementById("laststep").disabled=false;document.getElementById("laststep").value = \'' . lang('install_succeed') . '\';</script>' . "\r\n"; } }