localdir)) { while (($file = readdir($dh)) !== FALSE) { if (pathinfo($file, PATHINFO_EXTENSION) === 'zip' || pathinfo($file, PATHINFO_EXTENSION) === 'gz' ) { $this->zipfiles[] = $file; } } closedir($dh); if(!empty($this->zipfiles)) { self::$status = '.zip or .gz files ditemukan, siap untuk membongkar'; } else { self::$status = 'Error: Tidak ada file .zip atau .gz ditemukan.'; } } //check file archive terlebih dahulu //check juga archive yang telah di pilih $input = ''; $input = strip_tags($_POST['zipfile']); //hanya mengizinkan arsip lokal untuk dibongkar if ($input !== '') { if (in_array($input, $this->zipfiles)) { self::extract($input, $this->localdir); } } } public static function extract($archive, $destination) { $ext = pathinfo($archive, PATHINFO_EXTENSION); if ($ext === 'zip') { self::extractZipArchive($archive, $destination); } else { if ($ext === 'gz') { self::extractGzipFile($archive, $destination); } } } /** * Decompress/extract a zip archive using ZipArchive. * * @param $archive * @param $destination */ public static function extractZipArchive($archive, $destination) { // Check if webserver supports unzipping. if(!class_exists('ZipArchive')) { self::$status = 'Error: Your PHP version does not support unzip functionality.'; return; } $zip = new ZipArchive; // Check if archive is readable. if ($zip->open($archive) === TRUE) { // Check if destination is writable if(is_writeable($destination . '/')) { $zip->extractTo($destination); $zip->close(); self::$status = 'Files unzipped successfully'; } else { self::$status = 'Error: Directory not writeable by webserver.'; } } else { self::$status = 'Error: Cannot read .zip archive.'; } } /** * Decompress a .gz File. * * @param $archive * @param $destination */ public static function extractGzipFile($archive, $destination) { // Check if zlib is enabled if(!function_exists('gzopen')) { self::$status = 'Error: Your PHP has no zlib support enabled.'; return; } $filename = pathinfo($archive, PATHINFO_FILENAME); $gzipped = gzopen($archive, "rb"); $file = fopen($filename, "w"); while ($string = gzread($gzipped, 4096)) { fwrite($file, $string, strlen($string)); } gzclose($gzipped); fclose($file); // Check if file was extracted. if(file_exists($destination . '/' . $filename)) { self::$status = 'File unzipped successfully.'; } else { self::$status = 'Error unzipping file.'; } } } ?> Draco File Unzipper

Draco Archive Unzipper

Pilih Arsip .zip atau .gz file yg ingin kamu extrack:


Status:
Processingtime: ms