change install in vps

pull/41/head
qkqpttgf 2020-03-22 10:19:59 +08:00 committed by GitHub
parent 1c78642962
commit dd54c94d54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 49 additions and 14 deletions

View File

@ -115,7 +115,7 @@ function setConfig($arr, $disktag = '')
function install() function install()
{ {
global $constStr; global $constStr;
if ($_GET['install1']) { if ($_GET['install2']) {
if ($_POST['admin']!='') { if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
$tmp['language'] = $_POST['language']; $tmp['language'] = $_POST['language'];
@ -129,27 +129,70 @@ function install()
} }
} }
} }
if ($_GET['install0']) { if ($_GET['install1']) {
if (!ConfigWriteable()) { if (!ConfigWriteable()) {
$html .= getconstStr('MakesuerWriteable'); $html .= getconstStr('MakesuerWriteable');
$title = 'Error'; $title = 'Error';
return message($html, $title, 201); return message($html, $title, 201);
} }
if (!RewriteEngineOn()) { /*if (!RewriteEngineOn()) {
$html .= getconstStr('MakesuerRewriteOn'); $html .= getconstStr('MakesuerRewriteOn');
$title = 'Error'; $title = 'Error';
return message($html, $title, 201); return message($html, $title, 201);
}*/
$html .= '<button id="checkrewritebtn" onclick="checkrewrite();">'.getconstStr('MakesuerRewriteOn').'</button>
<div id="formdiv" style="display: none">
<form action="?install2" method="post" onsubmit="return notnull(this);">
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'" disabled>
</form>
</div>
<script>
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\''.getconstStr('SetAdminPassword').'\');
return false;
} }
return true;
}
function checkrewrite()
{
url=location.protocol + "//" + location.host;
if (location.port!="") url += ":" + location.port;
url += location.pathname;
if (url.substr(-1)!="/") url += "/";
url += "config.php";
//alert(url);
var xhr4 = new XMLHttpRequest();
xhr4.open("GET", url);
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
xhr4.send(null);
xhr4.onload = function(e){
console.log(xhr4.responseText+","+xhr4.status);
//filename = JSON.parse(xhr4.responseText);
if (xhr4.status==201) {
document.getElementById("checkrewritebtn").style.display = "none";
document.getElementById("submitbtn").disabled = false;
document.getElementById("formdiv").style.display = "";
} else {
alert(xhr4.status);
}
}
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
}
if ($_GET['install0']) {
$html .= ' $html .= '
<form action="?install1" method="post" onsubmit="return notnull(this);"> <form action="?install1" method="post">
language:<br>'; language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) { foreach ($constStr['languages'] as $key1 => $value1) {
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
$html .= ' $html .= '
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
<script> <script>
@ -158,14 +201,6 @@ language:<br>';
document.cookie=\'language=\'+str+\'; path=/\'; document.cookie=\'language=\'+str+\'; path=/\';
location.href = location.href; location.href = location.href;
} }
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}
return true;
}
</script>'; </script>';
$title = getconstStr('SelectLanguage'); $title = getconstStr('SelectLanguage');
return message($html, $title, 201); return message($html, $title, 201);