Update compile_database.php

This commit is contained in:
jakani24
2024-04-01 12:07:46 +02:00
parent ce175afcb6
commit 50c1285b6b

View File

@@ -111,6 +111,35 @@ function unzip($zipFile, $destination) {
} }
} }
function remove_directory($dir) {
if (!is_dir($dir)) {
return false;
}
// Open the directory
$handle = opendir($dir);
// Loop through the directory
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filePath = $dir . DIRECTORY_SEPARATOR . $file;
// Check if the current item is a directory
if (is_dir($filePath)) {
// Recursively call the function for subdirectories
removeDirectory($filePath);
} else {
// Delete the file
unlink($filePath);
}
}
}
// Close the directory handle
closedir($handle);
// Remove the directory itself
return rmdir($dir);
}
include "../../../config.php"; include "../../../config.php";
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE); $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
@@ -156,7 +185,7 @@ foreach ($files as $file) {
if (is_file($file)) { if (is_file($file)) {
unlink($file); unlink($file);
}else{ }else{
rmdir($file); remove_directory($file);
} }
} }
set_time_limit(0); set_time_limit(0);