4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Mystic on October 26, 2005, 06:11:12 AM

Title: Download Button to External Site Zip or Html Page ?
Post by: Mystic on October 26, 2005, 06:11:12 AM
 I have looked through all the posts and saw a couple about the download button, but nothing specifically to what I am looking for. I would like the visitor to be able to upload a thumbnail and the larger image, but then I would like the Download button to point to the zip file on their site or to an Html webpage on their site, whichever they choose.

In the Admin Panel under "Add Images" there is a field for Download Url. What would be the coding to add that to the member_uploadform. I tested it in the Admin panel and it worked with the zip file, but doesn't work if add a url like http://somesite.com  or  http://somesite.com/somepage.html. It tries to zip the url. What coding could be used so the download button could go to a plain html page?

I suppose also I could just delete the Download button icons and add a text field below for the Download Url, but the the Download stats would not increment. Thanks for any ideas.
Title: Re: Download Button to External Site Zip or Html Page ?
Post by: V@no on October 26, 2005, 02:56:55 PM
what if you replace in download.php:
Code: [Select]
    if (is_remote_file($image_row['image_download_url']) || is_local_file($image_row['image_download_url'])) {
      ereg("(.+)\.(.+)", basename($image_row['image_download_url']), $regs);
      $file_name = $regs[1];
      $file_extension = $regs[2];

      $file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
      $file['file_path'] = dirname($image_row['image_download_url'])."/".$file['file_name'];
    }
    else {
      $file['file_path'] = $image_row['image_download_url'];
      $remote_url = 1;
    }
with this:
Code: [Select]
/*
    if (is_remote_file($image_row['image_download_url']) || is_local_file($image_row['image_download_url'])) {
      ereg("(.+)\.(.+)", basename($image_row['image_download_url']), $regs);
      $file_name = $regs[1];
      $file_extension = $regs[2];

      $file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
      $file['file_path'] = dirname($image_row['image_download_url'])."/".$file['file_name'];
    }
    else {
*/
      $file['file_path'] = $image_row['image_download_url'];
      $remote_url = 1;
//    }
Title: Re: Download Button to External Site Zip or Html Page ?
Post by: Mystic on October 27, 2005, 02:06:31 AM
Thanks that code worked perfectly. I also modified the member_uploadform and added another row for the Download Url. I checked Member.php and it looked like the coding is already there for it. I added {image_download_url} on the member_upload form.

Edited:

I then modified admin/validateimages.php to get the the URL to show up when I go to validate the image. That way if they provide a link to a website I can check it out before I approve the post.

Old code around line 213 in admin/validateimages.php
Quote
  show_input_row($lang['field_download_url'].$lang['download_url_desc'], "image_download_url", "", $textinput_size);

Change to this so the url shows when validating:
Quote
  show_input_row($lang['field_download_url'].$lang['download_url_desc'], "image_download_url", $image_row['image_download_url'], $textinput_size);

By the way, this a great script you have here.
Title: Re: Download Button to External Site Zip or Html Page ?
Post by: Mystic on October 27, 2005, 03:11:37 AM
One more question. I have looked in download.php. When they click on the download button where do I add coding to get it to open in a new browser window using  target="_blank"

Thanks
Title: Re: Download Button to External Site Zip or Html Page ?
Post by: V@no on October 27, 2005, 03:16:06 AM
its in includes/functions.php:
Code: [Select]
    $target = (!empty($image_row['image_download_url']) && !is_remote_file($image_row['image_download_url']) && !is_local_file($image_row['image_download_url'])) ? "target=\"_blank\"" : "";
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
    $download_zip_button = ($target == "" && function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
Title: Re: Download Button to External Site Zip or Html Page ?
Post by: binuj01 on February 26, 2006, 09:14:17 AM
its in includes/functions.php:
Code: [Select]
    $target = (!empty($image_row['image_download_url']) && !is_remote_file($image_row['image_download_url']) && !is_local_file($image_row['image_download_url'])) ? "target=\"_blank\"" : "";
    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
    $download_zip_button = ($target == "" && function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";


I have exactly the same as above in functions.php, but still when I press the download button, it opens in the same window.
Any advice?

Thanks
Binu
Title: Re: Download Button to External Site Zip or Html Page ?
Post by: gamersp on January 11, 2009, 04:52:18 PM
Hello

I have this problem with 1.7.6, i want to link one picture to a extern zip file, but i cant.

can help me?

thanks!