22
33class Unzipper
44{
5- public $ localdir = '. ' ;
5+ public $ localdir = 'files ' ;
66 public $ zipfiles = array ();
77 public function __construct ()
88 {
@@ -85,10 +85,10 @@ public static function extractZipArchive($archive, $destination)
8585 }
8686 $ zip = new ZipArchive ();
8787 // Check if archive is readable.
88- if ($ zip ->open ($ archive ) === true ) {
88+ if ($ zip ->open ($ destination . ' / ' . $ archive ) === true ) {
8989 // Check if destination is writable
90- if (is_writeable ($ destination .'/ ' )) {
91- $ zip ->extractTo ($ destination );
90+ if (is_writeable ($ destination .'/ ' . $ archive )) {
91+ $ zip ->extractTo ($ destination. ' / ' );
9292 $ zip ->close ();
9393 $ _SESSION ['status ' ] = array ('success ' => 'Dateien erfolgreich entpackt! ' );
9494 } else {
@@ -113,15 +113,16 @@ public static function extractGzipFile($archive, $destination)
113113 return ;
114114 }
115115 $ filename = pathinfo ($ archive , PATHINFO_FILENAME );
116- $ gzipped = gzopen ($ archive , 'rb ' );
117- $ file = fopen ($ filename , 'w ' );
116+ echo $ filename ;
117+ $ gzipped = gzopen ($ destination .'/ ' .$ archive , 'rb ' );
118+ $ file = fopen ($ destination .'/ ' .$ filename , 'w ' );
118119 while ($ string = gzread ($ gzipped , 4096 )) {
119120 fwrite ($ file , $ string , strlen ($ string ));
120121 }
121122 gzclose ($ gzipped );
122123 fclose ($ file );
123124 // Check if file was extracted.
124- if (file_exists ($ destination .'/ ' .$ filename )) {
125+ if (file_exists ($ destination .'/ ' .$ archive )) {
125126 $ _SESSION ['status ' ] = array ('success ' => 'Datei erfolgreich entpackt. ' );
126127 } else {
127128 $ _SESSION ['status ' ] = array ('error ' => 'Fehler beim entpacken der Datei. ' );
@@ -144,10 +145,10 @@ public static function extractRarArchive($archive, $destination)
144145 // Check if archive is readable.
145146 if ($ rar = RarArchive::open ($ archive )) {
146147 // Check if destination is writable
147- if (is_writeable ($ destination .'/ ' )) {
148+ if (is_writeable ($ destination .'/ ' . $ archive )) {
148149 $ entries = $ rar ->getEntries ();
149150 foreach ($ entries as $ entry ) {
150- $ entry ->extract ($ destination );
151+ $ entry ->extract ($ destination. ' / ' . $ archive );
151152 }
152153 $ rar ->close ();
153154 $ _SESSION ['status ' ] = array ('success ' => 'Datei erfolreich entpackt. ' );
0 commit comments