From 762acba0306b46489fcde49e26c0faf6880f8dc2 Mon Sep 17 00:00:00 2001 From: Tomasz Date: Thu, 20 Jan 2022 00:10:55 +0100 Subject: [PATCH] Remove install dir after install and update DXCC, all automatically. --- install/index.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/install/index.php b/install/index.php index e88b9a4d..55d2ecdf 100644 --- a/install/index.php +++ b/install/index.php @@ -5,8 +5,20 @@ $db_config_path = '../application/config/'; $db_file_path = $db_config_path."database.php"; +function delDir($dir) { + $files = glob( $dir . '*', GLOB_MARK ); + foreach( $files as $file ){ + if( substr( $file, -1 ) == '/' ) + delDir( $file ); + else + unlink( $file ); + } + rmdir( $dir ); +} + if (file_exists($db_file_path)) { - echo "Cloudlog is already installed, please delete the /install folder."; + delDir(getcwd()); + header("../"); exit; } @@ -40,11 +52,23 @@ if($_POST) { // If no errors, redirect to registration page if(!isset($message)) { + sleep(1); + $ch = curl_init(); + $protocol=((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http"; + list($realHost,)=explode(':',$_SERVER['HTTP_HOST']); + $cloudlog_url=$protocol."://".$realHost.":".$_SERVER['SERVER_PORT']; + curl_setopt($ch, CURLOPT_URL,$cloudlog_url); + curl_setopt($ch, CURLOPT_VERBOSE, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($ch); + curl_setopt($ch, CURLOPT_URL,$cloudlog_url."/index.php/update/dxcc"); + $result = curl_exec($ch); + delDir(getcwd()); + header('Location: '.$protocol."://".$_SERVER['HTTP_HOST'].$_POST['directory']); echo "

Install successful

"; echo "

Please delete the install folder"; exit; } - } else { $message = $core->show_message('error','Not all fields have been filled in correctly. The host, username, password, and database name are required.'); @@ -139,4 +163,3 @@ if($_POST) { -