Example #1
0
/**
 * Download the configuration files and the templates as one zip file, for easy backup.
 */
function backup()
{
    global $Paths, $zipfile;
    // make the zipfile..
    include_once 'modules/zip.lib.php';
    $zipfile = new zipfile();
    // add some files
    addfiletozip('pv_cfg_settings.php');
    addfiletozip('pv_cfg_weblogs.php');
    $templatedir = str_replace($Paths['pivot_path'], "", $Paths['templates_path']);
    adddirtozip($templatedir);
    // get the zipp0red data..
    $zipped = $zipfile->file();
    // trigger a download.
    $basename = "pivot_config_" . date("Ymd") . ".zip";
    header("Content-disposition: attachment; filename={$basename}");
    header("Content-type: application/zip");
    header("Pragma: no-cache");
    header("Expires: 0");
    echo $zipped;
}
Example #2
0
/**
 * Function used by the 'backup db' option:
 * adds a directory (recursively) to the zip.
 *
 * @param string $dirname
 * @return void
 */
function adddirtozip($dirname)
{
    $d = dir($dirname);
    while (false !== ($entry = $d->read())) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($dirname . $entry)) {
                adddirtozip($dirname . $entry . "/");
            } else {
                addfiletozip($dirname . $entry);
            }
        }
    }
    $d->close();
}