The following code assumes zip_open exists, when for many servers it doesn't.

/**
 * hook_link() implementation.
 */
function filebrowser_link($type, $node= NULL, $teaser= FALSE) {
  if ($node->type == 'dir_listing' && !$teaser) {
    $links= array ();
    foreach ($node->file_listing as $file) {
      if ($file['kind'] == 0) {
        $links['file_browser_download_archive']= array (
          'href' => 'filebrowser_download/'.$node->nid.$node->relative_path. ($node->relative_path == '/' ? $node->title : basename($node->relative_path)).".zip",
          'title' => t("Download files as an Archive")
        );
        break;
      }
    }
    return $links;
  }
}

So we don't get a link to download all as a zip, when it isn't possible, please change it to:

/**
 * hook_link() implementation.
 */
function filebrowser_link($type, $node= NULL, $teaser= FALSE) {
  if ($node->type == 'dir_listing' && !$teaser && function_exists('zip_open')) {
    $links= array ();
    foreach ($node->file_listing as $file) {
      if ($file['kind'] == 0) {
        $links['file_browser_download_archive']= array (
          'href' => 'filebrowser_download/'.$node->nid.$node->relative_path. ($node->relative_path == '/' ? $node->title : basename($node->relative_path)).".zip",
          'title' => t("Download files as an Archive")
        );
        break;
      }
    }
    return $links;
  }
}
CommentFileSizeAuthor
#3 447618-filebrowser-drupal-6.patch1.73 KBlarskleiner

Comments

Yoran’s picture

Status: Active » Fixed

Thank you for this. Patch applied in RC10

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

larskleiner’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.73 KB

In addition to the link hook, _filebrowser_download_callback either opens the zip file if zip_open exists or displays an error message. Wouldn't it be better to just download the zip file if zip_open doesn't exists?

Yoran’s picture

Status: Needs review » Postponed (maintainer needs more info)

I think this is fixed with las dev version. But anyway I'm a bit confused with this PHP/Zip library as it don't handle correctly national characters. I wonder if we can't make this a bit more clever by first trying to find a zip utility on the server before trying with PHP/Zip broken library.

Yoran’s picture

Version: 6.x-2.0-rc9 » master
dead_account_kill_it_please’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)