Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Commit 4000240

Browse files
updating the classes to use relative a relative path
1 parent 77d21a3 commit 4000240

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

resources/classes/unzip.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class 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.');

resources/classes/uploader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Uploader
33
{
44
public function doUpload()
55
{
6-
$directory = 'upload/';
6+
$directory = 'files/';
77
if (strlen(pathinfo($_FILES['uploaded']['name'], PATHINFO_FILENAME)) == 0) {
88
$_SESSION['status'] = array('error' => 'Fehler: Sie müssen eine Datei zum hochladen auswählen!');
99
} else {
@@ -17,7 +17,7 @@ public function doUpload()
1717
mkdir($directory, 0755);
1818
}
1919

20-
$upload_folder = 'upload/'; //Das Upload-Verzeichnis
20+
$upload_folder = 'files/'; //Das Upload-Verzeichnis
2121
$filename = pathinfo($_FILES['uploaded']['name'], PATHINFO_FILENAME);
2222
$extension = strtolower(pathinfo($_FILES['uploaded']['name'], PATHINFO_EXTENSION));
2323
// $max_size = 10000 * 1024; //10 MB

0 commit comments

Comments
 (0)