Example #1
0
                    if ($file === "." || $file == "..") {
                        continue;
                    }
                    $file_list3[] = $dir_name . "/{$file}";
                }
                $zip_file_name = $site_name . "_" . $timestamp . ".zip";
                $result = create_zip($file_list1, $file_list2, $file_list3, $zip_file_name, true, $lab_config_id);
            }
        }
    }
    # Send file stream to user for download
    $file = $zip_file_name;
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    unlink($file);
}
#
# Execution begins here
#
$lab_config_id = $_REQUEST['id'];
create_backup($lab_config_id);
echo "hiral";
function ftp_backup_callback($data)
{
    global $ftpHost, $ftpPort, $ftpUser, $ftpPass, $activeMode, $local_media_dir, $remote_media_dir, $local_theme_dir, $remote_theme_dir, $local_plugin_dir, $remote_plugin_dir;
    // start session
    session_start();
    $type = sanitize_text_field($_POST['type']);
    switch ($type) {
        case "theme":
            $name = "Theme";
            $local_dir = $local_theme_dir;
            $remote_dir = $remote_theme_dir;
            break;
        case "media":
            $name = "Media";
            $local_dir = $local_media_dir;
            $remote_dir = $remote_media_dir;
            break;
        case "plugin":
            $name = "Plugin";
            $local_dir = $local_plugin_dir;
            $remote_dir = $remote_plugin_dir;
            break;
        default:
            break;
    }
    $step = sanitize_text_field($_POST['step']);
    switch ($step) {
        case 1:
            $html = "<p><strong>{$name} Files</strong></p>Testing FTP Connection... ";
            $step++;
            break;
        case 2:
            $result = get_ftp_connection($ftpHost, $ftpPort, $ftpUser, $ftpPass, $activeMode, true);
            $html = $result[1];
            if ($result[0]) {
                $step++;
            } else {
                $step = false;
            }
            break;
        case 3:
            $html = "Verifying remote {$type} directory... ";
            $step++;
            break;
        case 4:
            $verified = verify_remote_dir($remote_dir);
            if ($verified) {
                $html = "OK<br/>";
                $step++;
            } else {
                $html = "<br/>ERROR: <strong>{$remote_dir}</strong> does not exist on the server<br/>";
                $step = false;
            }
            break;
        case 5:
            $html = "Creating a backup of your remote {$type} files... ";
            $step++;
            break;
        case 6:
            $ftp = get_ftp_connection($ftpHost, $ftpPort, $ftpUser, $ftpPass, $activeMode, false);
            $html = create_backup($ftp, $local_dir, $remote_dir, $type, $activeMode);
            ftp_close($ftp);
            $step++;
            break;
        default:
            $_SESSION = array();
            // get rid of all session data for next sync
            $step = false;
            break;
    }
    echo json_encode(array('step' => $step, 'html' => $html, 'type' => $type));
    die;
    // this is required to return a proper result
}
Example #3
0
    if (count($files) == BACKUP_COUNT) {
        // Remove first backup
        $command = "rm -rf " . LOCKED_PATH . "/" . $files[0];
        exec($command);
        // Rename files -1
        foreach ($files as $file) {
            $command = "mv " . LOCKED_PATH . "/" . $file . " " . LOCKED_PATH . "/" . ($file - 1);
            exec($command);
        }
        // Run Backup
        $backup_file = end($files);
        create_backup($backup_file, LOCKED_PATH);
    } else {
        // Run Backup
        $backup_file = end($files);
        create_backup($backup_file + 1, LOCKED_PATH);
    }
    // All done, just copy to real path and remove the locked dir!
    closedir($handle);
    $command = "cp -r " . LOCKED_PATH . " " . PATH;
    exec($command);
    if (file_exists(PATH)) {
        $command = "rm -rf " . LOCKED_PATH;
        exec($command);
    }
}
function create_backup($backup_file, $path)
{
    // Create directory to put the backup in
    $command = "mkdir " . $path . "/" . $backup_file;
    exec($command);
Example #4
0
 *
 */
$f = new formular();
$f->fieldset('Datenbankzeilen sichern', 'db_sich');
$ccyymmddhhmmss = date("Ymd-His");
$sql_file = BERLUS_PATH . "/backup/backup" . $ccyymmddhhmmss . ".sql";
$tar_file = BERLUS_PATH . "/backup/backup" . $ccyymmddhhmmss . ".tar.gz";
if (!file_exists(BERLUS_PATH . "/backup")) {
    if (!mkdir(BERLUS_PATH . "/backup", 0777)) {
        die("Kann Verzeichnis " . BERLUS_PATH . "/backup nicht anlegen!");
    }
} else {
    echo "Backupverzeichnis existiert!<br>";
    $file = fopen("{$sql_file}", "w") or exit("Kein Schreibzugriff auf Backupdatei {$sql_file}");
}
$line_count = create_backup($file);
fclose($file);
echo "Gespeicherte Zeilen: " . $line_count . "<br>";
if (BACKUP_COMPRESS == "0") {
    echo "Backupdatei <b>{$sql_file}</b> wurde erstellt.<br>";
} else {
    if (exec("tar -cvzf {$tar_file} {$sql_file}")) {
        echo "<br>Backupdatei <b>{$tar_file}</b> wurde erstellt.<br>";
        unlink($sql_file);
    } else {
        echo "Backupdatei <b>{$sql_file}</b> wurde erstellt.<br>";
        echo "Die Datei konnte nicht gepackt werden!";
    }
}
if (!FTP_SERVER == "") {
    $connection_id = ftp_connect(FTP_SERVER);