📄 index.php
字号:
$showforceinstall = true;
}
}
mysql_close();
}
}
if(strpos($tablepre, '.') !== false) {
$error_config['tablepre'] = 'tablepre_invalid';
}
if(!is_writeable(DISCUZ_ROOT.'config.inc.php')) {
$error_config[] = 'config_unwriteable';
}
$username = getgpc('username', 'p');
$email = getgpc('email', 'p');
$password1 = getgpc('password1', 'p');
$password2 = getgpc('password2', 'p');
if($username && $email && $password1 && $password2) {
if($password1 != $password2) {
$error_admin['password2'] = 'admin_password_invalid';
} elseif(strlen($username) > 15 || preg_match("/^$|^c:\\con\\con$| |[,\"\s\t\<\>&]|^游客|^Guest/is", $username)) {
$error_admin['username'] = 'admin_username_invalid';
} elseif(!strstr($email, '@') || $email != stripslashes($email) || $email != htmlspecialchars($email)) {
$error_admin['email'] = 'admin_email_invalid';
} else {
$adminuser = check_adminuser($username, $password1, $email);
if($adminuser['uid'] < 1) {
$error_admin[] = $adminuser['error'];
}
}
} else {
empty($username) && $error_admin['username'] = 1;
empty($email) && $error_admin['email'] = 1;
empty($password1) && $error_admin['password1'] = 1;
$password1 != $password2 && $error_admin['password2'] = 1;
}
if(!$error_config){
$configfile = @file_get_contents(DISCUZ_ROOT.'./config.inc.php');
$configfile = trim($configfile);
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
$configfile = preg_replace("/[$]dbhost\s*\=\s*[\"'].*?[\"'];/is", "\$dbhost = '$dbhost';", $configfile);
$configfile = preg_replace("/[$]dbuser\s*\=\s*[\"'].*?[\"'];/is", "\$dbuser = '$dbuser';", $configfile);
$configfile = preg_replace("/[$]dbpw\s*\=\s*[\"'].*?[\"'];/is", "\$dbpw = '$dbpw';", $configfile);
$configfile = preg_replace("/[$]dbname\s*\=\s*[\"'].*?[\"'];/is", "\$dbname = '$dbname';", $configfile);
$configfile = preg_replace("/[$]adminemail\s*\=\s*[\"'].*?[\"'];/is", "\$adminemail = '$adminemail';", $configfile);
$configfile = preg_replace("/[$]tablepre\s*\=\s*[\"'].*?[\"'];/is", "\$tablepre = '$tablepre';", $configfile);
$configfile = preg_replace("/[$]cookiepre\s*\=\s*[\"'].*?[\"'];/is", "\$cookiepre = '".random(3)."_';", $configfile);
if(!$error_admin) {
$configfile = preg_replace("/[$]forumfounders\s*\=\s*[\"'].*?[\"'];/is", "\$forumfounders = '$adminuser[uid]';", $configfile);
}
@file_put_contents(DISCUZ_ROOT.'./config.inc.php', $configfile);
}
if(!$error_config && !$error_admin){
$step ++;
redirect("$self?step=$step&uid=$adminuser[uid]&username=".rawurlencode($username)."&email=".rawurlencode($email)."&password=".md5($password1));
}
} else {
$email = 'admin@admin.com';
$username = 'admin';
$password = $password2 = '';
}
if(!$error_config) {
show_tips('tips_db_config');
} else {
show_error('tips_db_config', $error_config);
}
show_setting('start');
show_setting('dbhost', 'dbhost', $dbhost, 'text', $error_config['dbhost']);
show_setting('dbuser', 'dbuser', $dbuser, 'text', $error_config['dbuser']);
show_setting('dbpw', 'dbpw', $dbpw, 'password', $error_config['dbpw']);
show_setting('dbname', 'dbname', stripslashes($dbname), 'text', $error_config['dbname']);
show_setting('adminemail', 'adminemail', $adminemail, 'text');
show_setting('tablepre', 'tablepre', $tablepre, 'text', $error_config['tablepre']);
if(!empty($forceinstall)) {
$showforceinstall = true;
$showforceinstallcheck = 'checked';
}
if($showforceinstall) {
show_setting('forceinstall', '', '<input type="checkbox" name="forceinstall" value="1" '.$showforceinstallcheck.'> '.lang('agree_forceinstall'), 'custum', true);
}
echo '</table>';
if(!$error_admin) {
show_tips('tips_admin_config');
} else {
show_error('tips_admin_config', $error_admin);
}
echo '<table class="tb2">';
show_setting('username', 'username', $username, 'text', $error_admin['username']);
show_setting('email', 'email', $email, 'text', $error_admin['email']);
show_setting('password', 'password1', $password1, 'password', $error_admin['password1']);
show_setting('repeat_password', 'password2', $password2, 'password', $error_admin['password2']);
show_setting('hidden', 'step', $step);
show_setting('', 'boardsubmit', $lang['new_step'], 'submit');
show_setting('end');
show_footer();
} elseif($step == 3) {
$uid = getgpc('uid');
$username = getgpc('username');
$password = md5(getgpc('password'));
$email = getgpc('email');
if(empty($uid) || empty($username) || empty($password) || empty($email)) {
$step --;
redirect("$self?step=$step");
}
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
show_tips('tips_install_process');
echo '<div class="btnbox"><textarea name="notice" style="width: 80%;" readonly id="notice"></textarea></div>';
echo '<div class="btnbox marginbot"><input type="button" name="submit" value="'.lang('install_in_processed').'" onclick="return false" id="laststep"></div>';
show_footer(FALSE);
@flush();
$sql = file_get_contents($sqlfile);
runquery($sql);
runquery($extrasql);
$timestamp = time();
$backupdir = substr(md5($_SERVER['SERVER_ADDR'].$_SERVER['HTTP_USER_AGENT'].substr($timestamp, 0, 4)), 8, 6);
@mkdir('forumdata/backup_'.$backupdir, 0777);
$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);
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$siteuniqueid = $chars[date('y')%60].$chars[date('n')].$chars[date('j')].$chars[date('G')].$chars[date('i')].$chars[date('s')].substr(md5($onlineip.$timestamp), 0, 4).random(6);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('authkey', '$authkey')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('siteuniqueid', '$siteuniqueid')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('backupdir', '".$backupdir."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('extcredits', '".addslashes(serialize($extcredits))."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('attachdir', '$attachdir')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('attachurl', '$attachurl')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('videoinfo', '".addslashes(serialize($videoinfo))."')");
$db->query("DELETE FROM {$tablepre}members");
$db->query("DELETE FROM {$tablepre}memberfields");
$db->query("INSERT INTO {$tablepre}members (uid, username, password, secques, adminid, groupid, regip, regdate, lastvisit, lastpost, email, dateformat, timeformat, showemail, newsletter, timeoffset) VALUES ('$uid', '$username', '$password', '', '1', '1', 'hidden', '".time()."', '".time()."', '".time()."', '$email', '', '0', '1', '1', '9999');");
$db->query("INSERT INTO {$tablepre}memberfields (uid) VALUES ('$uid')");
$db->query("UPDATE {$tablepre}crons SET lastrun='0', nextrun='".($timestamp + 3600)."'");
foreach($request_data as $k => $v) {
$variable = $k;
$type = $v['type'];
$value = addslashes(serialize($v));
$db->query("REPLACE INTO {$tablepre}request (variable, value, type) VALUES ('$variable', '$value', '$type')");
}
if(is_writeable(DISCUZ_ROOT.'./config.inc.php')) {
$configfile = @file_get_contents(DISCUZ_ROOT.'./config.inc.php');
$configfile = trim($configfile);
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
$configfile = preg_replace("/[$]forumfounders\s*\=\s*[\"'].*?[\"'];/is", "\$forumfounders = '$uid';", $configfile);
@file_put_contents(DISCUZ_ROOT.'./config.inc.php', $configfile);
}
foreach($optionlist as $optionid => $option) {
$db->query("INSERT INTO {$tablepre}typeoptions VALUES ('$optionid', '$option[classid]', '$option[displayorder]', '$option[title]', '', '$option[identifier]', '$option[type]', '".addslashes(serialize($option['rules']))."');");
}
$db->query("ALTER TABLE {$tablepre}typeoptions AUTO_INCREMENT=3001");
$yearmonth = date('Ym_', time());
loginit($yearmonth.'ratelog');
loginit($yearmonth.'illegallog');
loginit($yearmonth.'modslog');
loginit($yearmonth.'cplog');
loginit($yearmonth.'errorlog');
loginit($yearmonth.'banlog');
dir_clear(DISCUZ_ROOT.'./forumdata/templates');
dir_clear(DISCUZ_ROOT.'./forumdata/cache');
dir_clear(DISCUZ_ROOT.'./forumdata/threadcaches');
dir_clear(DISCUZ_ROOT.'./uc_client/data');
dir_clear(DISCUZ_ROOT.'./uc_client/data/cache');
$step ++;
echo '<iframe width="0" height="0" src="../index.php" style="display:none;"></iframe>';
redirect("$self?step=$step");
} elseif($step == 4) {
@touch($lockfile);
show_tips('install_finished');
echo '<div class="btnbox margintop marginbot"><input type="button" value="'.lang('install_succeed').'" onclick="window.location=\'../index.php\'; return false"></div>
<iframe width="0" height="0" src="../index.php" style="display:none;"></iframe>
';
show_footer();
} else {
redirect('index.php');
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -