Added mr folder cleaner

This commit is contained in:
Arturo Gonzalez 2017-03-21 14:48:12 +01:00
parent 0b564c2866
commit 8ae921402c
2 changed files with 47 additions and 0 deletions

View File

@ -19,6 +19,7 @@ if (is_ajax ()) {
$updare_rr = get_parameter('updare_rr', 0); $updare_rr = get_parameter('updare_rr', 0);
$remove_rr = get_parameter('remove_rr', 0); $remove_rr = get_parameter('remove_rr', 0);
$$remove_rr_extras = get_parameter('remove_rr_extras', 0);
if ($updare_rr) { if ($updare_rr) {
$number = get_parameter('number'); $number = get_parameter('number');
@ -150,6 +151,32 @@ if (is_ajax ()) {
return; return;
} }
if ($remove_rr_extras) {
$dir = $config["homedir"] . "/extras/mr/";
if (file_exists($dir) && is_dir($dir)) {
if (is_readable($dir)) {
$files = scandir($dir); // Get all the files from the directory ordered by asc
if ($files !== false) {
$pattern = "/^\d+\.sql$/";
$sqlfiles = preg_grep($pattern, $files); // Get the name of the correct files
$files = null;
$pattern = "/\.sql$/";
$replacement = "";
$sqlfiles_num = preg_replace($pattern, $replacement, $sqlfiles); // Get the number of the file
foreach ($sqlfiles_num as $num) {
$file = $dir . "$num.sql";
if (file_exists($file)) {
unlink($file);
}
}
}
}
}
}
} }
?> ?>

View File

@ -705,6 +705,8 @@ function install_package (package, homeurl) {
// Check the status of the update // Check the status of the update
check_install_package(package, homeurl); check_install_package(package, homeurl);
remove_rr_file_to_extras();
} }
} }
}); });
@ -1281,6 +1283,8 @@ function install_free_package_prev_step(package, version, homeurl) {
}, },
"json" "json"
); );
remove_rr_file_to_extras();
} }
} }
); );
@ -1537,6 +1541,22 @@ function remove_rr_file (number) {
params["number"] = number; params["number"] = number;
params["page"] = "include/ajax/rolling_release.ajax"; params["page"] = "include/ajax/rolling_release.ajax";
jQuery.ajax ({
data: params,
async: false,
dataType: "html",
type: "POST",
url: "ajax.php",
success: function (data) {
}
});
}
function remove_rr_file_to_extras () {
var params = {};
params["remove_rr_extras"] = 1;
params["page"] = "include/ajax/rolling_release.ajax";
jQuery.ajax ({ jQuery.ajax ({
data: params, data: params,
async: false, async: false,