• Different download options / Verschiedene Download Möglichkeiten 5 0 5 1
Currently:  

Author Topic: Different download options / Verschiedene Download Möglichkeiten  (Read 168542 times)

0 Members and 1 Guest are viewing this topic.

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichkeiten
« on: September 13, 2002, 09:00:13 AM »
Hi,

I'm planning to use 4images for an online image licensing system. The licenses and the pricing will be dependent on the resolution and the size of the images. Not all images will have a fitting license option. That means for my system I'll need 3 different download options (72dpi, 150dpi & 300dpi) and 3 different buttons showing the availability of the license.

The license types will be save in different directories (eg t1=72dpi, t2=150dpi, t3=300dpi). The download buttons will be shown in the detail.php.

What I need is a modified routine of download.php which does the following

1) checks to see if the user is logged in, if not shows the download button without a link (just like it already does by the standard version)

2) checks to see if the license type is available (what it actually does is looks up in the fitting directory to see if the file exists), if not shows a special download button (not available) without a link

I know this routine is simple for someone whos firm in php. Can anyone give me a hint how to do this?

Thanks in advance.
Steve
« Last Edit: August 30, 2006, 12:22:20 AM by Nicky »

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #1 on: September 13, 2002, 09:47:34 AM »
One question: Should point the download button for the 72dpi-image to the same file who is displayed on the details page?

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichke
« Reply #2 on: September 13, 2002, 10:41:59 AM »
Hi Jan,

No the download buttons should point to the same files in the appropriate directory. That means if there is a file (72dpi image) to download in the directory t1, then this file should be downloaded. The same goes for the files in the directories t2 (150dpi images) and t3 (300 dpi images). The files will all have the same name, just like the pic and thumbnail files. I figure that way, it will be easier.

Steve

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #3 on: September 13, 2002, 10:47:53 AM »
Ok, i just wanted to know if you want to add 3 new download buttons or only two, because you use the default button for 72dpi-downloads. Just give a little bit time, i will see what i can do.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichke
« Reply #4 on: September 13, 2002, 12:01:24 PM »
No problem!

Thanks again for taking your time.

Steve

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #5 on: September 13, 2002, 01:39:49 PM »
Ok, try this:

Open "includes/functions.php" and add after:
Code: [Select]
   $allow_download = 1;
  }

this:
Code: [Select]
 $additional_download_sizes = array(72, 150, 300);

  $register_array = array();
  foreach ($additional_download_sizes as $size) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file = ((is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/" : MEDIA_PATH."/".$image_row['cat_id']."/").$regs[1]."_".$size.".".$regs[2];
    if (!$allow_download || !get_file_path($file, "media", $image_row['cat_id'], 0, 0)) {
      $register_array['download_button_'.$size] = "<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
      $register_array['download_zip_button_'.$size] = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
    }
    else {
      $register_array['download_button_'.$size] = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']."&amp;size=".$size)."\"".$target."><img src=\"".get_gallery_image("download.gif")."\" border=\"0\" alt=\"\" /></a>";
      $register_array['download_zip_button_'.$size] = (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']."&amp;size=".$size)."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
    }
  }
  $site_template->register_vars($register_array);


You can add more sizes to $additional_download_sizes.
Now you can use in the template details.html the following tags:
Code: [Select]
{download_button_72}
{download_zip_button_72}

{download_button_150}
{download_zip_button_150}

{download_button_300
{download_zip_button_300}

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichke
« Reply #6 on: September 13, 2002, 05:37:43 PM »
Hi Jan,

I've implemented it into functions.php and the template details.html.

Heres are couple of questions just to see if I understand the code properly.

The files are found in the directory ../4images/data/media/categorie_id/. Is that right?

The name of the file will be like picture_72.jpg and picture_150.jpg and so forth. Am I on the right track?

Steve

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #7 on: September 13, 2002, 05:56:51 PM »
Uhh, sorry. I forgot to explain this. Yes, you are right.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichke
« Reply #8 on: September 13, 2002, 06:35:19 PM »
Thanks very much Jan. It works great  :D

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichke
« Reply #9 on: September 23, 2002, 12:36:08 AM »
Hi Jan,

I've just noticed that there is one mistake that happens with the script you posted. If a user is not registered, then no buttons are shown at all. I'd prefare it when guests would be able to see the buttons which show the availablity of the licenses. The buttons should be shown in the blured way they usually do, when there is no link behind them. This would be a great marketing option which would give unregistered users a reason to register.

Can you give me a hint on this one?

Thanks again for your great help.

Steve

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #10 on: September 23, 2002, 10:01:43 AM »
I don't know if i have understand your question correctly. But i think th code should work in the way you want. If there is no file available OR the user has not the permission to download, the button should be shown in the blured way. Are you sure that they do not?

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline skink

  • Newbie
  • *
  • Posts: 34
    • View Profile
Different download options / Verschiedene Download Möglichke
« Reply #11 on: September 23, 2002, 10:40:09 AM »
Hi Jan,

Well the script works fine, when the user ist logged on and there is no file available OR the user does not have the permission to download. As soon as they are logged off and have guest status no buttons are shown at all.

I tried to find the mistake, but my php skills are'nt good enough.  :cry:

Steve

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #12 on: September 23, 2002, 10:43:58 AM »
I tested it, for me it works. Can you give me a URL?

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #13 on: September 23, 2002, 03:30:04 PM »
Strange, can you send me your functions.php with the modifications.

Jan

P.S.: Ich brech' mir hier einen auf englisch ab und Deine Site ist auf deutsch ;)
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Different download options / Verschiedene Download Möglichke
« Reply #14 on: September 23, 2002, 11:45:36 PM »
You haven't inserted the code on the right place. Please note the } in my posting above:
Code: [Select]
 $allow_download = 1;
}

Please paste the code behind this!

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search