if (0) {
             // kick the PHP watchdog and make sure we can run for a long time at the same time:
             set_time_limit(0);
             $fileContents = file_get_contents(BASE_PATH . '/' . $dir);
             if (false === $createZip->addFile($fileContents, $basename)) {
                 throw new FbX($ccms['lang']['system']['error_write'] . ": " . $fileName);
             }
         }
     }
 } else {
     if ($scantype != 'file') {
         $basename .= substr($basename, -1, 1) != '/' ? '/' : '';
         $file_collection[] = array('dir' => $basename);
         log_current_backup_state($progressfile, $file_collection);
         if (0) {
             $createZip->addDirectory($basename);
         }
         $files = directoryToArray(BASE_PATH . '/' . $dir, $scantype == 'tree', $regex_to_match);
         /*
          * opendir+readdir deliver the file set in arbitrary order.
          *
          * In order for this code to work, we'll need a known order of the files.
          */
         sort($files, SORT_STRING);
         foreach ($files as $file) {
             $zipPath = explode(BASE_PATH . '/' . $dir, $file, 2);
             $zipPath = $zipPath[1];
             if (is_dir($file)) {
                 $file_collection[] = array('dir' => $basename . $zipPath);
                 log_current_backup_state($progressfile, $file_collection);
                 if (0) {
Esempio n. 2
0
// Put in a email ID if you want the backup emailed
$configEmail = '';
// Include backup functions file
include 'includes/backup_functions.php';
$backupName = "backup-" . date('d-m-y') . '-' . date('H-i-s') . '.zip';
$createZip = new createZip();
if (isset($configBackup) && is_array($configBackup) && count($configBackup) > 0) {
    // Lets backup any files or folders if any
    foreach ($configBackup as $dir) {
        $basename = basename($dir);
        // dir basename
        if (is_file($dir)) {
            $fileContents = file_get_contents($dir);
            $createZip->addFile($fileContents, $basename);
        } else {
            $createZip->addDirectory($basename . "/");
            $files = directoryToArray($dir, true);
            $files = array_reverse($files);
            foreach ($files as $file) {
                $zipPath = explode($dir, $file);
                $zipPath = $zipPath[1];
                // skip any if required
                $skip = false;
                foreach ($configSkip as $skipObject) {
                    if (strpos($file, $skipObject) === 0) {
                        $skip = true;
                        break;
                    }
                }
                if ($skip) {
                    continue;
/* Save archivetime */
//date_default_timezone_set('America/Los_Angeles');
$ob_file = fopen('include/archive.inc', 'w');
ob_start('ob_file_callback');
$d = date('Y-m-d');
echo "<?php\n";
echo '$archivetime="' . $d . '";';
echo "\n?>";
ob_end_flush();
/* Zip the offline doc */
if (!is_dir('archives')) {
    mkdir('archives');
    copy('include/index.html', 'archives/index.html');
}
$zip = new createZip();
$zip->addDirectory("images/");
if ($dh = opendir('offline')) {
    while (($file = readdir($dh)) !== false) {
        if (is_file('offline/' . $file)) {
            $fileContents = file_get_contents('offline/' . $file);
            $zip->addFile($fileContents, $file);
        }
    }
    closedir($dh);
}
if ($dh = opendir('offline/images')) {
    while (($file = readdir($dh)) !== false) {
        if (is_file('offline/images/' . $file)) {
            $fileContents = file_get_contents('offline/images/' . $file);
            $zip->addFile($fileContents, 'images/' . $file);
        }