Commit 3ea6c41cc404e944fc6d4f831083750e58d78d5e
1 parent
62797108
Use KTUtil::findCommand to find the unzip command.
Use pexec to execute the command. Use KTUtil::deleteDirectory to remove the traces during cleanup. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4433 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
8 additions
and
5 deletions
lib/import/zipimportstorage.inc.php
| ... | ... | @@ -43,22 +43,25 @@ class KTZipImportStorage extends KTFSImportStorage { |
| 43 | 43 | unlink($sTmpPath); |
| 44 | 44 | mkdir($sTmpPath, 0700); |
| 45 | 45 | $this->sBasePath = $sTmpPath; |
| 46 | + $sUnzipCommand = KTUtil::findCommand("import/unzip", "unzip"); | |
| 47 | + if (empty($sUnzipCommand)) { | |
| 48 | + return PEAR::raiseError("unzip command not found on system"); | |
| 49 | + } | |
| 46 | 50 | $aArgs = array( |
| 47 | - "unzip", | |
| 51 | + $sUnzipCommand, | |
| 48 | 52 | "-q", "-n", |
| 49 | 53 | "-d", $sTmpPath, |
| 50 | 54 | $this->sZipPath, |
| 51 | 55 | ); |
| 52 | - $sCommand = KTUtil::safeShellString($aArgs); | |
| 53 | - $res = system($sCommand); | |
| 56 | + $res = KTUtil::pexec($aArgs); | |
| 54 | 57 | if ($res === false) { |
| 55 | 58 | return PEAR::raiseError("Could not retrieve contents from zip storage"); |
| 56 | 59 | } |
| 57 | 60 | } |
| 61 | + | |
| 58 | 62 | function cleanup() { |
| 59 | 63 | if ($this->sBasePath && file_exists($this->sBasePath)) { |
| 60 | - // XXX: Only works on Unix-like systems for now. | |
| 61 | - system(KTUtil::safeShellString(array('/bin/rm', '-rf', $this->sBasePath))); | |
| 64 | + KTUtil::deleteDirectory($this->sBasePath); | |
| 62 | 65 | $this->sBasePath = null; |
| 63 | 66 | } |
| 64 | 67 | } | ... | ... |