Beispiel #1
0
/**
 * Returns an array of backup files
 *
 * @todo use RecursiveDirectoryIterator
 * @return array $files
 */
function hmbkp_get_backups()
{
    $files = array();
    $hmbkp_path = hmbkp_path();
    if ($handle = @opendir($hmbkp_path)) {
        while (false !== ($file = readdir($handle))) {
            if (end(explode('.', $file)) == 'zip') {
                $files[@filemtime(trailingslashit($hmbkp_path) . $file)] = trailingslashit($hmbkp_path) . $file;
            }
        }
        closedir($handle);
    }
    // If there is a custom backups directory and it's not writable then include those backups as well
    if (defined('HMBKP_PATH') && HMBKP_PATH && is_dir(HMBKP_PATH) && !is_writable(HMBKP_PATH)) {
        if ($handle = opendir(HMBKP_PATH)) {
            while (false !== ($file = readdir($handle))) {
                if (strpos($file, '.zip') !== false) {
                    $files[@filemtime(trailingslashit(HMBKP_PATH) . $file)] = trailingslashit(HMBKP_PATH) . $file;
                }
            }
            closedir($handle);
        }
    }
    ksort($files);
    // Don't include the currently running backup
    if ($key = array_search(trailingslashit(hmbkp_path()) . hmbkp_in_progress(), $files)) {
        unset($files[$key]);
    }
    return $files;
}
<?php

if (hmbkp_in_progress()) {
    ?>

		<a id="hmbkp_backup" class="add-new-h2 hmbkp_running" href="tools.php?page=<?php 
    echo HMBKP_PLUGIN_SLUG;
    ?>
&amp;action=hmbkp_cancel"><?php 
    echo hmbkp_get_status();
    ?>
 [cancel]</a>

<?php 
} elseif (hmbkp_possible()) {
    ?>

		<a id="hmbkp_backup" class="add-new-h2" href="tools.php?page=<?php 
    echo HMBKP_PLUGIN_SLUG;
    ?>
&amp;action=hmbkp_backup_now"><?php 
    _e('Back Up Now', 'hmbkp');
    ?>
</a>

<?php 
}
Beispiel #3
0
/**
 * Display the running status via ajax
 *
 * @return void
 */
function hmbkp_ajax_is_backup_in_progress()
{
    if (!hmbkp_in_progress()) {
        echo 0;
    } else {
        include HMBKP_PLUGIN_PATH . '/admin.backup-button.php';
    }
    exit;
}