Fix ZIP viewer

Support Zip extension viewer for php versions 8.0.0 above.
This commit is contained in:
Sharon Rotgaizer 2023-07-15 22:10:39 +03:00 committed by GitHub
parent eb8f3d80bc
commit a6781936da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2693,22 +2693,23 @@ function fm_get_directorysize($directory) {
* @return array|bool * @return array|bool
*/ */
function fm_get_zif_info($path, $ext) { function fm_get_zif_info($path, $ext) {
if ($ext == 'zip' && function_exists('zip_open')) { if ($ext == 'zip' && class_exists('ZipArchive')) {
$arch = @zip_open($path); $arch = new ZipArchive;
if ($arch) { if ($arch->open($path)) {
$filenames = array(); $filenames = array();
while ($zip_entry = @zip_read($arch)) {
$zip_name = @zip_entry_name($zip_entry); for($i = 0; $i < $arch->numFiles; $i++ ){
$zip_folder = substr($zip_name, -1) == '/'; $stat = $arch->statIndex($i);
$filenames[] = array( $zip_folder = substr($stat['name'], -1) == '/';
'name' => $zip_name, $filenames[] = array(
'filesize' => @zip_entry_filesize($zip_entry), 'name' => $stat['name'],
'compressed_size' => @zip_entry_compressedsize($zip_entry), 'filesize' => $stat['size'],
'compressed_size' => $stat['comp_size'],
'folder' => $zip_folder 'folder' => $zip_folder
//'compression_method' => zip_entry_compressionmethod($zip_entry), //'compression_method' => $stat['comp_method'],
); );
} }
@zip_close($arch); $arch->close();
return $filenames; return $filenames;
} }
} elseif($ext == 'tar' && class_exists('PharData')) { } elseif($ext == 'tar' && class_exists('PharData')) {