PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Allow access to a download protected file for anyone

s2Member Plugin. A Membership plugin for WordPress®.

Allow access to a download protected file for anyone

Postby StenCade » May 31st, 2011, 3:35 am

Hi there, awesome product, thank you!

I am trying to use s2member in conjunction with the NextGEN gallery plugin. What I want is for anyone to be able to access the public album page, which shows a thumbnail, description, etc of each protected photo gallery. This is easy to do by making the album page public and the gallery pages protected.

However, I would also like the added security of download protection. I moved the gallery files into the s2member-files folder and set protected jpgs to display inline. The galleries work as expected. However, this obviously means that the thumbnail images, which are generated and stored by NextGEN all in the same subfolder, no longer display on my public page.

It would be a serious pain to have to code the thumbnails in manually, not to mention a bit too much for my client to handle. Is there a way that I can allow a handful of specific files in the same folder as my protected files to be seen by anyone? The Key thing doesn't work because I need anyone to be able to see the images as many times as they load the album page.

Thanks!
Sten
User avatar
StenCade
Registered User
Registered User
 
Posts: 12
Joined: May 31, 2011

Re: Allow access to a download protected file for anyone

Postby Cristián Lávaque » May 31st, 2011, 1:29 pm

Hi Sten.

Why would the keys not work for that? They're not limited by number of downloads, they just have a 24 hour expiration, but the key gets generated each time the page is, thus starting a new 24 hrs before expiration.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Allow access to a download protected file for anyone

Postby StenCade » May 31st, 2011, 6:33 pm

Hm, I must be doing something wrong then. I'm having to do a bit of hacking to get NextGEN to print the image link for me so there's some room for error...

Let me mess with is a bit and see if I can't find my mistake. At least I know I'm on the right track!
User avatar
StenCade
Registered User
Registered User
 
Posts: 12
Joined: May 31, 2011

Re: Allow access to a download protected file for anyone

Postby StenCade » May 31st, 2011, 10:36 pm

OK! I got it working! I was giving s2member_file_download_key() the filename instead of the relative path AND filename.

Here's the code for anyone who needs this functionality.

NextGEN documentation will tell you how to edit the album-extend.php and where to put it and all that. So, in "album-extend.php" (or "album-compact.php"), just after the line
Code: Select all
<?php foreach ($galleries as $gallery) :

I inserted
Code: Select all
   /** Takes gallery thumbnail and edits the url so s2member will allow access by anyone **/
   $thumbfilename = "thumbs_".$gallery->previewname;
   $thumburl = $gallery->previewurl;
   //cut down to just the relative path
   $urlpieces = parse_url($thumburl);
   $thumbpath = $urlpieces['query'];
   //cut out the "s2member_file_download=" part
   $thumbpath = str_replace("s2member_file_download=", '', $thumbpath);
   //Make key
   $key = s2member_file_download_key("$thumbpath");
   //Add key
   $keystring = "&s2member_file_download_key=".$key;
   $keyedurl = $gallery->previewurl . $keystring;


Then just below that, in the "ngg-thumbnail" class, change
Code: Select all
src="<?php echo $gallery->previewurl ?>

into
Code: Select all
src="<?php /*Here's the part I changed*/ echo $keyedurl; ?>
User avatar
StenCade
Registered User
Registered User
 
Posts: 12
Joined: May 31, 2011

Re: Allow access to a download protected file for anyone

Postby Cristián Lávaque » May 31st, 2011, 10:57 pm

Thanks for the update! I'm very glad you solved and thanks a lot for sharing your solution with others here; very appreciated. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 3 guests

cron