public function get_file_list($zip_file) { $file_list = array(); $result = false; $za = NULL; $stat = array(); // This should give us a new archive object, of not catch it and bail out try { $za = new pluginbuddy_PclZip($zip_file); $result = true; } catch (Exception $e) { // Something fishy - the methods indicated pclzip but we couldn't find the class $error_string = $e->getMessage(); pb_backupbuddy::status('details', sprintf(__('pclzip indicated as available method but error reported: %1$s', 'it-l10n-backupbuddy'), $error_string)); $result = false; } // Only continue if we have a valid archive object if (true === $result) { // Make sure we opened the zip ok and it has content if (0 !== ($content_list = $za->listContent())) { // How many files - must be >0 to have got here $file_count = sizeof($content_list); // Get each file in sequence by index and get the properties for ($i = 0; $i < $file_count; $i++) { $stat = $content_list[$i]; // Assume all these keys do exist (consider testing) $file_list[] = array($stat['filename'], $stat['size'], $stat['compressed_size'], $stat['mtime']); } pb_backupbuddy::status('details', sprintf(__('pclzip listed file contents (%1$s)', 'it-l10n-backupbuddy'), $zip_file)); $this->log_archive_file_stats($zip_file); $result =& $file_list; } else { // Couldn't open archive - will return for maybe another method to try $error_string = $za->errorInfo(true); pb_backupbuddy::status('details', sprintf(__('pclzip failed to open file to list contents (%1$s) - Error Info: %2$s.', 'it-l10n-backupbuddy'), $zip_file, $error_string)); // Return an error code and a description - this needs to be handled more generically //$result = array( 1, "Unable to get archive contents" ); // Currently as we are returning an array as a valid result we just return false on failure $result = false; } } if (NULL != $za) { unset($za); } return $result; }