From 5059c4dd3b122714b6ebe82810f01b08a3215947 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 1 Aug 2023 15:50:28 +0700 Subject: [PATCH] Update Software Script --- update.php | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 update.php diff --git a/update.php b/update.php new file mode 100644 index 00000000..a8b23dee --- /dev/null +++ b/update.php @@ -0,0 +1,221 @@ +open($file); + $zip->extractTo(pathFixer('system/cache/')); + $zip->close(); + if (file_exists($folder)){ + $step++; + }else{ + $msg = "Failed to extract update file"; + $msgType = "danger"; + $continue = false; + } + // remove downloaded zip + if (file_exists($file)) unlink($file); +}else if ($step == 3) { + copyFolder($folder, pathFixer('./')); + deleteFolder('install/'); + deleteFolder($folder); + if (!file_exists($folder.pathFixer('/system/'))){ + $step++; + }else{ + $msg = "Failed to install update file."; + $msgType = "danger"; + $continue = false; + } +} + +function pathFixer($path) +{ + return str_replace("/", DIRECTORY_SEPARATOR, $path); +} + +function r2($to, $ntype = 'e', $msg = '') +{ + if ($msg == '') { + header("location: $to"); + exit; + } + $_SESSION['ntype'] = $ntype; + $_SESSION['notify'] = $msg; + header("location: $to"); + exit; +} + +function copyFolder($from, $to, $exclude = []) +{ + $files = scandir($from); + print_r($files); + foreach ($files as $file) { + if (is_file($from . $file) && !in_array($file, $exclude)) { + if (file_exists($to . $file)) unlink($to . $file); + rename($from . $file, $to . $file); + } else if (is_dir($from . $file) && !in_array($file, ['.', '..'])) { + if (!file_exists($to . $file)) { + mkdir($to . $file); + } + copyFolder($from . $file . DIRECTORY_SEPARATOR, $to . $file . DIRECTORY_SEPARATOR); + } + } +} +function deleteFolder($path) +{ + $files = scandir($path); + foreach ($files as $file) { + if (is_file($path . $file)) { + unlink($path . $file); + } else if (is_dir($path . $file) && !in_array($file, ['.', '..'])) { + File::deleteFolder($path . $file . DIRECTORY_SEPARATOR); + rmdir($path . $file); + } + } + rmdir($path); +} + +?> + + + + + + + PHPNuxBill Updater + + + + + + + + + + + + + + + + + + +
+
+

+ Update PHP NuxBill +

+
+ +
+
+
+
+ + + + +
+
Step 1
+
+ Downloading update
+ Please wait.... +
+
+ +
+
Step 2
+
+ extracting
+ Please wait.... +
+
+ +
+
Step 3
+
+ Installing
+ Please wait.... +
+
+ +
+
+
+ +
+ + + \ No newline at end of file