[OSM-Devserver] allokierbarer Speicher für PHP

Holger Neubert Martin.Dornfelder at gmx.de
Fr Okt 15 11:29:45 CEST 2010


> Das geht z.B. recht flott:
> 7za a -bd -mx0 -tzip test0.zip
> /osm/luftbilder/wwwroot/Cottbus20/R00248*.JPG

Ok, aber das müsste dann schon das Skript erzeugen. Weißt Du, wie das hier einzubauen ist?:

<?php
include_once("createZip.inc.php");

class createDirZip extends createZip {

	function get_files_from_folder($directory, $put_into) {
		if ($handle = opendir($directory)) {
			while (false !== ($file = readdir($handle))) {
				if (is_file($directory.$file )) {
					$fileContents = file_get_contents($directory.$file);
					if (filesize($file) > 100000){
					$this->addFile($fileContents, $put_into.$file);}
				} elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
					$this->addDirectory($put_into.$file.'/');
					$this->get_files_from_folder($directory.$file.'/', $put_into.$file.'/');
				}
			}
		}
		closedir($handle);
	}
}


$dirName = 'pirna/';
$createZip = new createDirZip;
$createZip->addDirectory($dirName);
$createZip->get_files_from_folder("./", $dirName);

$fileName = '../archive/archive.zip';
$fd = fopen ($fileName, 'wb');
$out = fwrite ($fd, $createZip->getZippedfile());
$createZip->forceDownload($fileName);
@unlink($fileName);

fclose ($fd);

?>