Jungbluth
Mitglied
Hallo,
ich möchte mir Zip-Archive erstellen und das funktioniert so weit auch ganz gut. Jetzt hab ich jedoch das Problem das diese nicht komprimiert werden.
ich möchte mir Zip-Archive erstellen und das funktioniert so weit auch ganz gut. Jetzt hab ich jedoch das Problem das diese nicht komprimiert werden.
PHP:
<?php
ini_set("memory_limit","1024M");
ini_set("max_execution_time","3000");
error_reporting(E_ALL);
$exp = strtoupper((string)$_GET["exp"]);
$file_get_contents = json_decode(file_get_contents("https://www.mtgjson.com/json/".$exp.".json"));
$cards = array();
mkdir($exp);
foreach ($file_get_contents->cards as $card){
if(isset($card->multiverseId)){
file_put_contents($exp."/".$card->name.".jpg", file_get_contents("https://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=".$card->multiverseId."&type=card"));
$cards[] = $card->name.".jpg";
}
}
$latest = new ZipArchive;
$res_latest = $latest->open("latest.zip", ZipArchive::CREATE);
if ($res_latest === TRUE) {
foreach ($cards as $card){
$latest->addFile($exp."/".$card);
}
$latest->setCompressionName($exp, ZipArchive::CM_DEFLATE);
}
$latest->close();
$allsets = new ZipArchive;
$res_allsets = $allsets->open("AllSets.zip");
if ($res_allsets === TRUE) {
foreach ($cards as $card){
$allsets->addFile($exp."/".$card);
}
$allsets->setCompressionName($exp, ZipArchive::CM_DEFLATE);
}
$allsets->close();
foreach ($cards as $card){
unlink($exp."/".$card);
}
rmdir($exp);