Code
$zipquelle = get_option('serverpfad') ;
$zieldatei="Datei.zip";
$pfad= plugin_dir_path( __FILE__ ) ."/tmp/";
if (!file_exists($pfad.$zieldatei)) {
//echo "Download wird von [$zipquelle] gestartet.<br><br>";
$ch = curl_init($zipquelle);
$handle = fopen($pfad.$zieldatei, "w");
curl_setopt($ch, CURLOPT_FILE, $handle);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
curl_exec($ch);
fclose($handle);
update_option( 'fb_Status_download', 'Download abgeschlossen.');
} else
update_option( 'fb_Status_download', 'Download nicht nötig. Datei bereits vorhanden!');
$zip = new ZipArchive;
$res = $zip->open($pfad.$zieldatei);
if ($res === TRUE) {
$zip->extractTo($pfad);
$zip->close();
update_option( 'fb_Status_entpackt','Die Datei wurde erfolgreich nach'. $pfad .'entpackt.');
unlink($pfad.$zieldatei);
} else {
update_option( 'fb_Status_entpackt','Die Datei ' .$file. ' konnte nicht gefunden/geöffnet werden.');
}
Alles anzeigen