瀏覽代碼

Upload files to 'Install'

Yeung Alan 5 年之前
父節點
當前提交
388725c3f0
共有 8 個文件被更改,包括 176 次插入37 次删除
  1. 57 0
      Install/cmd.php
  2. 13 3
      Install/config.php
  3. 41 0
      Install/download.php
  4. 1 1
      Install/index.php
  5. 6 1
      Install/info.php
  6. 40 28
      Install/ip.php
  7. 5 4
      Install/version.php
  8. 13 0
      Install/wconfig.php

+ 57 - 0
Install/cmd.php

@@ -0,0 +1,57 @@
+<?php
+$config = include 'config.php';
+$result = file_get_contents("https://api.alanyeung.co/ArOZ/install/?accesskey=".$config["accesskey"]);
+$jresult = json_decode($result,true);
+if($_GET["step"] == 1){
+	if($jresult["vaild"]){
+		echo "true";
+	}else{
+		echo "false";
+		$config["step"] = "2";
+		file_put_contents('config.php', '<?php return ' . var_export($config, true) . ';');
+	}
+}else if($_GET["step"] == 2){
+	file_put_contents("../msb.zip", fopen($jresult["msb"], 'r'));
+	$zip = new ZipArchive;
+	$res = $zip->open('../msb.zip');
+	if ($res === TRUE) {
+	  $zip->extractTo('../');
+	  $zip->close();
+	  echo 'true';
+	} else {
+	  echo 'false';
+	}
+	unlink("../msb.zip");
+	
+}else if($_GET["step"] == 3){
+	file_put_contents("../AOB.zip", fopen($jresult["aob"], 'r'));
+	$zip = new ZipArchive;
+	$res = $zip->open('../AOB.zip');
+	if ($res === TRUE) {
+	  $zip->extractTo('../');
+	  $zip->close();
+	  echo 'true';
+	} else {
+	  echo 'false';
+	}
+	unlink("../AOB.zip");
+	
+}else if($_GET["step"] == 4){
+	shell_exec('sudo chmod -R 777 /var/www/html/AOB');
+	
+	shell_exec('sudo hostnamectl set-hostname '.$config["FQDN"]);
+	shell_exec('echo "127.0.0.1 '.$config["FQDN"].'" > /etc/hosts');
+	
+	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+		$rootPath = "C:/AOB/";
+	}else{
+		$rootPath = "/etc/AOB/";
+	}
+	$databasePath = $rootPath . "whitelist.config";
+	$newusername = $config["admin_name"];
+	$encodedpw = hash('sha512',$config["admin_pwd"]);
+	file_put_contents($databasePath,$newusername . "," . $encodedpw . PHP_EOL,FILE_APPEND);
+	sleep(3);
+	echo "true";
+}
+?>

+ 13 - 3
Install/config.php

@@ -1,3 +1,13 @@
-<?php
-return array();
-?>
+<?php return array (
+  'FQDN' => 'windows-server',
+  'admin_name' => 'newuser',
+  'admin_pwd' => '123456',
+  'step' => '3',
+  'IP' => 'DHCP',
+  'ipaddr' => '',
+  'subnet' => '',
+  'dgateway' => '',
+  'pdns' => '',
+  'sdns' => '',
+  'accesskey' => 'SMTEJ-CWTOX-XCGBY-1CYQF-FLESZ',
+);

+ 41 - 0
Install/download.php

@@ -33,5 +33,46 @@
 			</div>
 			<p>We are starting to configruate your system, it should takes about 10-15 minutes to install, depends on your system configration it may longer or shorter.</p>
     </div>
+<script>
+$.get( "cmd.php?step=1", function( data ) {
+	if(data == "false"){
+		window.location = "version.php?invaild=true";
+	}else{
+		$(".ts.indeterminate.progress").attr("class","ts active progress");
+		$(".bar").animate({width:"10%"},3000);
+		step2();
+	}
+});
+
+function step2(){
+	$.get( "cmd.php?step=2", function( data ) {
+	if(data == "true"){
+		$(".bar").animate({width:"30%"},5000);
+		step3();
+	}else{
+	}
+});
+}
+
+function step3(){
+	$.get( "cmd.php?step=3", function( data ) {
+	if(data == "true"){
+		$(".bar").animate({width:"70%"},8000);
+		step4();
+	}else{
+	}
+});
+}
+
+function step4(){
+	$.get( "cmd.php?step=4", function( data ) {
+	if(data == "true"){
+		$(".bar").width("100%");
+		finish();
+	}else{
+	}
+});
+}
+</script>
 </body>
 </html>

+ 1 - 1
Install/index.php

@@ -29,7 +29,7 @@
     <div class="ts very narrow container">
         <br>
 			<form class="ts relaxed form">
-				<button class="ts fluid primary button" type="button" onclick="location.href = 'info.php';">Next</button>
+				<button class="ts fluid primary button" type="button" onclick="location.href = 'wconfig.php';">Next</button>
 				<div class="ts center aligned mini basic fitted message">
 					When clicking start, which means you understand the EULA and License agreement.
 				</div>

+ 6 - 1
Install/info.php

@@ -1,3 +1,7 @@
+<?php
+
+
+?>
 <html>
 <head>
 <meta name="apple-mobile-web-app-capable" content="yes" />
@@ -44,7 +48,8 @@
 					<input name="admin_pwd" type="password">
 					<small>Password must only contains alphabets</small>
 				</div>
-				<button class="ts fluid primary button" type="button" onclick="location.href = 'ip.php';">Next</button>
+				<input type="hidden" name="step" value="1">
+				<button class="ts fluid primary button" type="submit">Next</button>
 			</form>
     </div>
 </body>

+ 40 - 28
Install/ip.php

@@ -28,47 +28,59 @@
     </div>
     <div class="ts very narrow container">
         <br>
-			<form class="ts relaxed form">
+			<form class="ts relaxed form" action="wconfig.php" method="POST">
                 <div class="field">
                     <label>IP Settings</label>
                     <div class="ts center aligned compact horizontal checkboxes">
                         <div class="ts radio checkbox">
-                            <input type="radio" name="IP" id="DHCP" checked="checked">
+                            <input type="radio" name="IP" id="DHCP" value="DHCP" checked="checked">
                             <label for="DHCP">Obtain IP address automatically (DHCP)</label>
                         </div>
                         <div class="ts radio checkbox">
-                            <input type="radio" name="IP" id="Static">
+                            <input type="radio" name="IP" id="Static" value="STATIC" disabled>
                             <label for="Static">Use static IP address</label>
                         </div>
                     </div>
                 </div>
-			    <div class="field">
-					<label>IP Address</label>
-					<input type="name">
-					<small>The format should be like 0.0.0.0</small>
+				<div id="staticf">
+					<div class="field">
+						<label>IP Address</label>
+						<input type="name" name="ipaddr">
+						<small>The format should be like 0.0.0.0</small>
+					</div>
+					<div class="field">
+						<label>Subnet mask</label>
+						<input type="name" name="subnet">
+						<small>The format should be like 0.0.0.0</small>
+					</div>
+					<div class="field">
+						<label>Default Gateway</label>
+						<input type="name" name="dgateway">
+						<small>The format should be like 0.0.0.0</small>
+					</div>
+					<div class="field">
+						<label>Primary Domain Name Services(DNS)</label>
+						<input type="name" name="pdns">
+						<small>The format should be like 0.0.0.0</small>
+					</div>	
+					<div class="field">
+						<label>Secondary Domain Name Services(DNS)</label>
+						<input type="name" name="sdns">
+						<small>The format should be like 0.0.0.0</small>
+					</div>
 				</div>
-			    <div class="field">
-					<label>Subnet mask</label>
-					<input type="name">
-					<small>The format should be like 0.0.0.0</small>
-				</div>
-			    <div class="field">
-					<label>Default Gateway</label>
-					<input type="name">
-					<small>The format should be like 0.0.0.0</small>
-				</div>
-			    <div class="field">
-					<label>Primary Domain Name Services(DNS)</label>
-					<input type="password">
-					<small>The format should be like 0.0.0.0</small>
-				</div>	
-			    <div class="field">
-					<label>Secondary Domain Name Services(DNS)</label>
-					<input type="password">
-					<small>The format should be like 0.0.0.0</small>
-				</div>					
-				<button class="ts fluid primary button" type="button" onclick="location.href = 'version.php';">Next</button>
+				<input type="hidden" name="step" value="2">				
+				<button class="ts fluid primary button" type="submit">Next</button>
 			</form>
     </div>
+<script>
+$("#staticf").attr("style","display:none");
+$('#DHCP').change(function () {
+	$("#staticf").attr("style","display:none");
+});
+$('#Static').change(function () {
+	$("#staticf").attr("style","");
+});
+</script>
 </body>
 </html>

+ 5 - 4
Install/version.php

@@ -28,13 +28,14 @@
     </div>
     <div class="ts very narrow container">
         <br>
-			<form class="ts relaxed form">
+			<form class="ts relaxed form" action="wconfig.php" method="POST">
 			    <div class="field">
 					<label>Please enter your access key to obtain the installer</label>
-					<input type="password">
+					<input type="name" name="accesskey">
 					<small>The access key is 25-Digit and should be find on your invitation letter.</small>
-				</div>				
-				<button class="ts fluid primary button" type="button" onclick="location.href = 'download.php';">Next</button>
+				</div>
+				<input type="hidden" name="step" value="3">
+				<button class="ts fluid primary button" type="submit">Next</button>
 			</form>
     </div>
 </body>

+ 13 - 0
Install/wconfig.php

@@ -4,4 +4,17 @@ foreach($_POST as $key => $val){
 	$config[$key] = $val;
 }
 file_put_contents('config.php', '<?php return ' . var_export($config, true) . ';');
+
+sleep(3);
+
+if(!isset($config["step"])){
+	header('Location: info.php');
+}else if($config["step"] == 1){
+	header('Location: ip.php');
+}else if($config["step"] == 2){
+	header('Location: version.php');
+}else if($config["step"] == 3){
+	header('Location: download.php');
+}
+
 ?>