Browse Source

Installer self removes

Nathaniel van Diepen 10 years ago
parent
commit
2f16e25877
4 changed files with 22 additions and 4 deletions
  1. 4 0
      index.php
  2. 5 0
      install/api.php
  3. 1 1
      install/index.php
  4. 12 3
      install/install.js

+ 4 - 0
index.php

@@ -1,4 +1,8 @@
 <?php
+	if(!file_exists('config.json')){
+		header('Location: install');
+		die();
+	}
 	session_start();
 	require_once('php/include.php');
 	if(isset($_GET['get'])){

+ 5 - 0
install/api.php

@@ -135,6 +135,11 @@
 						}
 					}elseif($id=='config'){
 						echo file_get_contents('index.template.html');
+					}elseif($id='cleanup'){
+						$files = scandir(realpath(dirname(__FILE__)));
+						foreach($file in $files){
+							unlink($file);
+						}
 					}else{
 						die('Invalid id');
 					}

+ 1 - 1
install/index.php

@@ -7,7 +7,7 @@
 		<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
 		<script src="../js/jquery.mCustomScrollbar.concat.min.js"></script>
 		<script src="../js/jquery.history.js"></script>
-		<script src="../js/install.js"></script>
+		<script src="install.js"></script>
 		<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/black-tie/jquery-ui.css"/>
 		<link href="../css/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
 	</head>

+ 12 - 3
js/install.js → install/install.js

@@ -1,5 +1,9 @@
 (function($,History){
-	var State = History.getState();
+	var State = History.getState(),
+		returnToIndex = function(){
+			History.replaceState({},'Bugs','..');
+			location = '..';
+		};
 	$(document).ready(function(){
 		if($.isEmptyObject(State.data)){
 			History.replaceState({
@@ -18,8 +22,13 @@
 							alert(d);
 							$('#install').removeAttr('disabled');
 						}else{
-							alert('Installation successful!');
-							location = '..';
+							if(confirm("Installation successful!\nDo you want to delete the installation files?")){
+								$.get('api.php?&dbtemplate=install&type=install&id=cleanup',function(d){
+									returnToIndex();
+								});
+							}else{
+								returnToIndex();
+							}
 						}
 					},'text');
 					return false;