Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Download and Alternate File Loading  (Read 64012 times)

0 Members and 1 Guest are viewing this topic.

jjhat1

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 17
Download and Alternate File Loading
« on: June 06, 2006, 11:48:27 pm »

This plugin serves two very connected purposes.  First of it provides a download link directly above the filename.  The link can be left clicked on and a save as dialogue box appears because the file is transferred through a PHP script.

This leads me to the scripts next functionality that requires a small mod to make it fully functional.  The plugin explains the modification of adding a single line of code.  This script changes all of the file's URLs so that they load through a PHP script.  Now I have not gotten around to adding the security features that I want but it does help with the web server logs.  The plugin simply loads the pictures using the PID and the version that was requested.  This plugin does sacrifice speed because there are two additional queries for each picture that is displayed.  One to lookup the PID and one to look up the file path with the first being part of the page and the second being part of each image.

The modification that goes along with this plugin is as follows:

Find The Line:
return $pic_row['url'];

Place This Line of Code Immediately Before It:
$pic_row = CPGPluginAPI::filter('picture_url',$pic_row);

Be aware that without the modification no error message will be given and the pictures will simply not load through the script.

I hope this helps.  It is a straight forward script and includes some comments about the code.

I do know that there are other similar scripts but I have not seen one yet in the form of a plugin.  The plugin feature allows for very easy installation (besides the fact there is one very small mod).  In my personal opinion this plugin hook would be one that would be very convient in the next version of Coppermine, but I am not a developer. ;)

Additionally, this plugin may not work on versions of Coppermine that have been modified but the placement of the hook ensures that all files will be loaded through the script, with the exception of those that are file type specific.

Version 1.1: Added security that used MD5 to prevent someone from just changing the PID in the URL to access the next picture.
Version 1.2: Fixed an error with the download link caused by the MD5 security.
Version 1.3: Extensive rewrite that changed the way the plugin determines the PID for each image.  Optimized some code that determines which file to load through the script.
« Last Edit: June 09, 2006, 06:33:33 am by GauGau »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Download and Alternate File Loading
« Reply #1 on: June 07, 2006, 12:12:19 am »

When I tested this plugin, the pid GET variable was not set in the URL created by this plugin to download the file - i.e. index.php?file=download/picture&pid=&method=dl.  I haven't looked to see why.

Also, I wonder why you don't use the 'file_data' plugin hook in themes.inc.php.  Yes, someone might remove this plugin hook by accident when modifying theme_html_picture(), but most likely they will not.  I used this plugin hook for "Full-Size Photos Access Control" to remove the full-size photo link.  Yes, with this hook, you'll have to modify $cpicdata['html'] instead of the URL itself, but this allows it to work without the mod.  There might be confounding details to this suggestion as I haven't tried it myself.

We are considering new plugin hooks for 1.5 and if you find that your added plugin hook is vital, please say so and we will consider it.
Logged

jjhat1

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 17
Re: Download and Alternate File Loading
« Reply #2 on: June 07, 2006, 12:23:13 am »

I did spend about two hours working on using both the hooks for the thumbnails, intermediate pictures, and full resolution pictures but still I did not manage to convert all of the links.  I do know using those would in fact prevent a query by already having the PID but there were just random instances where it was incontinent.

First, the slide show feature never seemed to change with any of the hooks and the only way was to use the modification which is truly all encompassing.

Additionally, it became very confusing when I was dealing with intermediate files that were not pictures.  For example, they should display their appropriate file type image but I only seemed to break the link even if I set it to ignore these files.

Lastly, movies seem to be dealt with in a special way that just makes it too difficult to get it to point to the given path.

I may hunt down that code that I wrote and post it here as well but the biggest nail in the coffin for me was the slide show not modifying the URL at all.

On a side note, I planned on adding security to my script by having the MD5 version of the path included in the URL.  This would prevent people from just cycling through the pictures to view the entire gallery without regard to weather they are in a hidden album.  Pretty much, I WANT the pid in the URL but it just gives me the creeps that a person with out much effort could access every picture through a single script.

EDIT: I did manage to get a version that used MD5 to perfent someone from just changing the PID.  In the URL is the file path in MD5 that can not be used to locate the file but can still be authenticated before the picture is sent to the user.
« Last Edit: June 07, 2006, 12:50:26 am by jjhat1 »
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Download and Alternate File Loading
« Reply #3 on: June 08, 2006, 05:03:43 pm »

I have tried this plugin, 2 problems when I tried:

1. With the edited code in function.inc.php it removes all the thumbs, normal & full size pics.

2. Without the edited code in functions.inc.php the picture doesn't download when you click download original file.

Any help ;D
Logged

jjhat1

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 17
Re: Download and Alternate File Loading
« Reply #4 on: June 08, 2006, 06:06:17 pm »

This is somewhat of a work in progress.  ;D I will look into the problem.  The mod to the functions is to create the hook for the plugin to function.  This is not dependent on any way for the download link so that is fishy.  It might have something to do with the way I load the file through the PHP script.  It is not fully compatable if you use a non default albums folder.  I will work on this. 

What version of Coppermine are you using? 

I think I did my testing on a slightly older version but I am upgrading today.

Thanks
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Download and Alternate File Loading
« Reply #5 on: June 08, 2006, 06:13:07 pm »

Well I have a modded version with Stramm's Mod Pack and I am using 1.4.6 ;D
Logged

jjhat1

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 17
Re: Download and Alternate File Loading
« Reply #6 on: June 08, 2006, 06:36:56 pm »

I did find two bugs in the code.  I will update my first post to include my latest version.  I had a typo and a missing line of code that was causing the download link to choke.
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Download and Alternate File Loading
« Reply #7 on: June 08, 2006, 06:49:20 pm »

The download works now but I still get no thumbs, normal & full pics with the editing to functions.inc.php ???

And is there a way of taking out Download: Download Original File and replacing it with an image ;D
« Last Edit: June 08, 2006, 07:10:08 pm by will »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Download and Alternate File Loading
« Reply #8 on: June 08, 2006, 07:47:03 pm »

Threads like this one on the plugin contributions board are meant to just announce the contribution and let the contributor add updates and so on.  Bug reports have generally been allowed as well since they deal directly with the contribution as it is.

Feature requests or support using the contribution (non-bug-report) should go on the parent board: cpg1.4 plugins, with reference to this thread.

This is the rule on all contributions boards on this forum.  It's related to the rule: "one issue per thread".

This keeps the contribution announcement thread clean and easy to read for someone first coming to check out the plugin.  It also keeps support issues in separate threads, so they can be discussed, worked out, and marked "solved".

I know in my plugin threads I didn't obey this rule at first, but I strongly recommend following this rule from now on.
Logged

dolph

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Bug
« Reply #9 on: August 30, 2006, 09:13:28 pm »

Running:
Coppermine 1.4.9
Download and Alternate File Loading 1.3

This plugin must be uninstalled temporarily in order to edit picture/movie details/info.
With it installed I get a Forbidden File Extension...without it I don't.
Logged

dolph

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Download and Alternate File Loading
« Reply #10 on: September 08, 2006, 10:04:19 pm »

Also, clicking 'Download Original File' works instantly with images but with video sometimes it takes forever for the download dialog box to pop up.

I'm noticing that with large videos (~250MB) it doesn't work?
Does the entire file have to be downloaded before it will work?

I think I'd rather just have it link directly to the file in it's directory.
Logged

NetWhiz

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Download and Alternate File Loading
« Reply #11 on: September 14, 2006, 02:07:58 am »

The "Last Additions" thumbnails and intermediate pics are not able to be displayed with the edit to the functions.inc.php. When I disable the manual edit to that file, the "Last Additions" thumbnails and intermediate pictures work. If I click on the image through its respective album directly, then the thumbnails and intermediate files show correctly. Anyone else seen this issue?
Logged

LnQ

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 38
Re: Download and Alternate File Loading
« Reply #12 on: October 21, 2006, 01:16:20 pm »

have anyone got this plugin to work with 1.4.9...tryed it but got the same ting no trumbs and normail_* when I modified the function??
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Download and Alternate File Loading
« Reply #13 on: November 04, 2006, 07:29:51 am »

I've put together a simpler plugin that uses Jared's picture.php and doesn't require any mods.

It only adds a link to the intermediate image page to download the full size picture.  It doesn't do the rest of what THIS thread's plugin does and is not meant as a direct replacement.

You can get the download link off of the CPG-contrib support board for CPGPicdownload.

To avoid confusion of these plugins please limit your posts in this thread to jjhat1's plugin.

To talk about CPGPicdownload, which only is about adding a link on the intermediate image page, please take your post over to the cpg-contrib boards.

http://cpg-contrib.org/board/index.php?board=29.0
« Last Edit: November 08, 2006, 06:23:17 pm by donnoman »
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Download and Alternate File Loading
« Reply #14 on: November 07, 2006, 03:21:25 pm »

Can this plugin be edited to only allow registered users a download link of the fullsize picture ?

Cheers!
Hein
Logged

jjhat1

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 17
Re: Download and Alternate File Loading
« Reply #15 on: November 08, 2006, 02:59:42 pm »

This plugin was designed to be very comprehensive.  I have not been able to develop this because of a change in priorities, but I have another reason to keep developing this plugin so there may be updates in the not to near future.
Logged

Go_on

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Download and Alternate File Loading
« Reply #16 on: November 08, 2006, 03:08:54 pm »

wow! this is just wat i needed  ;D

so cool! thx for making this! :D
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Download and Alternate File Loading
« Reply #17 on: November 08, 2006, 05:27:02 pm »

I went ahead and installed the plugin to see what effect it would have on my CPG.
Turns out i too have the flaw where it does not display any picture anymore but instead only
displays the alt text to click on to see the intermediate or fullsize image.

I do however think this plugin has potential so i'll be watching this thread. Keep up the good work!

Cheers!
Hein
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: Download and Alternate File Loading
« Reply #18 on: February 20, 2007, 09:02:53 pm »

I've put together a simpler plugin that uses Jared's picture.php and doesn't require any mods.

It only adds a link to the intermediate image page to download the full size picture.  It doesn't do the rest of what THIS thread's plugin does and is not meant as a direct replacement.

You can get the download link off of the CPG-contrib support board for CPGPicdownload.

To avoid confusion of these plugins please limit your posts in this thread to jjhat1's plugin.

To talk about CPGPicdownload, which only is about adding a link on the intermediate image page, please take your post over to the cpg-contrib boards.

http://cpg-contrib.org/board/index.php?board=29.0

Is there anyway of adding this download link to the file information block, thanks
Logged

akhlan

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 42
  • Breizh power...
    • Akhlan Pics
Re: Download and Alternate File Loading
« Reply #19 on: July 04, 2007, 08:26:40 am »

Hi,

where do you put the 3 files codebase.php, configuration.php and picture.php and I don't find "return $pic_row['url']; " in my functions.inc.php file :-(

I used Copermine 1.4.12 and ChaoticSoul theme

Tks
Akhlan
Logged
Pages: [1] 2   Go Up
 

Page created in 0.029 seconds with 20 queries.