Author Topic: Download Button to External Site Zip or Html Page ?  (Read 9707 times)

0 Members and 1 Guest are viewing this topic.

Offline Mystic

  • Pre-Newbie
  • Posts: 3
    • View Profile
Download Button to External Site Zip or Html Page ?
« 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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Download Button to External Site Zip or Html Page ?
« Reply #1 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;
//    }
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Mystic

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Download Button to External Site Zip or Html Page ?
« Reply #2 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.

Offline Mystic

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Download Button to External Site Zip or Html Page ?
« Reply #3 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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Download Button to External Site Zip or Html Page ?
« Reply #4 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>" : "";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline binuj01

  • Newbie
  • *
  • Posts: 37
    • View Profile
    • Sourcestravel
Re: Download Button to External Site Zip or Html Page ?
« Reply #5 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
www.sourcestravel.com
See your travel destnations ahead.

Offline gamersp

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Download Button to External Site Zip or Html Page ?
« Reply #6 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!