diff --git a/lib/import/zipimportstorage.inc.php b/lib/import/zipimportstorage.inc.php new file mode 100644 index 0000000..3677b89 --- /dev/null +++ b/lib/import/zipimportstorage.inc.php @@ -0,0 +1,64 @@ +sZipPath = $sZipPath; + } + + function init() { + $sTmpPath = tempnam('/tmp', 'zipimportstorage'); + if ($sTmpPath === false) { + return PEAR::raiseError("Could not create temporary directory for zip storage"); + } + unlink($sTmpPath); + mkdir($sTmpPath, 0700); + $this->sBasePath = $sTmpPath; + $aArgs = array( + "unzip", + "-q", "-n", + "-d", $sTmpPath, + $this->sZipPath + ); + $sCommand = KTUtil::safeShellString($aArgs); + $res = system($sCommand); + if ($res === false) { + return PEAR::raiseError("Could not retrieve contents from zip storage"); + } + } + function cleanup() { + if ($this->sBasePath && file_exists($this->sBasePath)) { + // XXX: Only works on Unix-like systems for now. + system(KTUtil::safeShellString(array('/bin/rm', '-rf', $this->sBasePath))); + $this->sBasePath = null; + } + } +} + +?>