Beispiel #1
0
function PMBP_get_backup_files()
{
    global $CONF;
    $delete_files = FALSE;
    $all_files = FALSE;
    $result_files = FALSE;
    $handle = @opendir("./" . PMBP_EXPORT_DIR);
    $remove_time = time() - $CONF['del_time'] * 86400;
    while ($file = @readdir($handle)) {
        if ($file != "." && $file != ".." && preg_match("'\\.sql|\\.sql\\.gz|\\.sql\\.zip'", $file)) {
            // don't delete if del_time is not set
            if ($CONF['del_time']) {
                if (PMBP_file_info("time", $file) < $remove_time) {
                    $delete_files[] = $file;
                } else {
                    $all_files[] = $file;
                }
            } else {
                $all_files[] = $file;
            }
        }
    }
    // sort descending
    if (is_array($all_files)) {
        rsort($all_files);
    }
    // delete oldest backup files if there are to many for one db
    if (is_array($all_files)) {
        foreach ($all_files as $file) {
            if (!isset($counter[$db = PMBP_file_info("db", "./" . PMBP_EXPORT_DIR . $file)])) {
                $counter[$db] = 1;
            } else {
                $counter[$db]++;
            }
            if ($counter[$db] > $CONF['del_number']) {
                $delete_files[] = $file;
            } else {
                $result_files[] = $file;
            }
        }
    }
    // now delete the files
    if ($delete_files) {
        PMBP_delete_backup_files($delete_files);
    }
    // sort ascending
    if (is_array($result_files)) {
        sort($result_files);
    }
    return $result_files;
}
Beispiel #2
0
        foreach ($all_files as $filename) {
            if ($_GET['del_all'] == PMBP_file_info("db", PMBP_EXPORT_DIR . $filename)) {
                $del_files[] = $filename;
            }
        }
    }
    $result = PMBP_delete_backup_files($del_files);
    if (!$result) {
        echo PMBP_addOutput(B_DELETED_ALL, "green");
    } else {
        echo PMBP_addOutput($result, "red");
    }
}
// delete selected backup file if the link was clicked
if ($_GET['del']) {
    $out = PMBP_delete_backup_files($_GET['del']);
    if ($out) {
        echo $out;
    } else {
        echo PMBP_addOutput(B_DELETED, "green");
    }
}
// get new list of backup files
$all_files = PMBP_get_backup_files();
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n";
// list all backup files
if (is_array($all_files)) {
    $last_backup = 0;
    $size_sum = 0;
    // print html table
    foreach ($all_files as $filename) {