mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
Fix bugs thorugh tests
This commit is contained in:
parent
b6680a6d1b
commit
5a878e30f6
|
|
@ -67,12 +67,14 @@ class Zip implements ArchiveInterface
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = realpath($file);
|
$absolute = realpath($file);
|
||||||
|
$absolute = str_replace('\\', '/', $absolute);
|
||||||
|
$dir = str_replace($source . '/', '', $relative . '/' . $absolute);
|
||||||
|
|
||||||
if (is_dir($file)) {
|
if (is_dir($absolute)) {
|
||||||
$zip->addEmptyDir(str_replace($relative . '/', '', $file . '/'));
|
$zip->addEmptyDir($dir . '/');
|
||||||
} elseif (is_file($file)) {
|
} elseif (is_file($absolute)) {
|
||||||
$zip->addFile(str_replace($relative . '/', '', $file), $file);
|
$zip->addFile($absolute, $dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (is_file($source)) {
|
} elseif (is_file($source)) {
|
||||||
|
|
@ -88,18 +90,19 @@ class Zip implements ArchiveInterface
|
||||||
*/
|
*/
|
||||||
public static function unpack(string $source, string $destination) : bool
|
public static function unpack(string $source, string $destination) : bool
|
||||||
{
|
{
|
||||||
$destination = str_replace('\\', '/', realpath($destination));
|
if(!file_exists($source)) {
|
||||||
|
|
||||||
if (file_exists($destination)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$destination = str_replace('\\', '/', $destination);
|
||||||
|
$destination = rtrim($destination, '/');
|
||||||
|
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
if (!$zip->open($destination)) {
|
if (!$zip->open($source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip->extractTo($destination);
|
$zip->extractTo($destination . '/');
|
||||||
|
|
||||||
return $zip->close();
|
return $zip->close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,6 @@ class DateTime
|
||||||
$startDate = strtotime($start);
|
$startDate = strtotime($start);
|
||||||
$endDate = strtotime($end);
|
$endDate = strtotime($end);
|
||||||
|
|
||||||
return new \DateTime(date('Y-m-d H:i:s', rand($startDate, $endDate)));
|
return new \DateTime(date('Y-m-d H:i:s', mt_rand($startDate, $endDate)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user