We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Download Lock Module- members only download protection...

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

Well, I solved two of my problems today.

1. Counting individual stats. I added a function to the download lock module that will output single stats for an entry (rather then the list). It doesn’t do last download because I couldn’t make heads or tails of those lines! I’ll just post that function here, if that’s cool. NOTE: I’m not releasing anything! Or re-releasing someone else’s work! Back off, Lisa! 🐛

function solo_stats()
{
global $DB, $TMPL, $LANG;
$entry_id = ( ! $TMPL->fetch_param('entry_id')) ? '' : $TMPL->fetch_param('entry_id');
$type    = ($TMPL->fetch_param('type'))    ? $TMPL->fetch_param('type') : 'total';
if ($entry_id == '') 
    { 
     return $LANG->line('no_entry_specified');        
   }
$getstats = $DB->query("SELECT COUNT(entry_id) AS unique_downloads, SUM(total_down) 
AS total_downloads FROM exp_d_lock_stats WHERE entry_id = $entry_id");
   
if ($getstats->num_rows == 0)
{
return;
}

$total  = $getstats->row['total_downloads'];
$unique = $getstats->row['unique_downloads'];

if ($total == 0) {
$tagdata = "0";
    $this->return_data = $tagdata;
return $this->return_data;
}

if ($type == "total") {
    $tagdata = $total;
} elseif ($type == "unique") {
    $tagdata = $unique;
}
$this->return_data = $tagdata;
return $this->return_data;

} // END solo_stats

That might be ugly as sin, but it’s working. It defaults to showing total downloads. Usage:

{exp:download_lock:solo_stats entry_id="{entry_id}" type="unique"}
{exp:download_lock:solo_stats entry_id="{entry_id}"}

2. Filesize I found that Andy (aka ExpressionEngineer) had already written a plugin for this called Filesizer. I just modified it a bit to automatically go from kb to MB if needed, output a file extension if desired, and to better work with Mark Huot’s File module. (But I’ll post details about that in a Filesizer Thread.)

I’ve attached a pic to show you what this is looking like when outputting unique and total counts and using the filesizer plugin.

       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

So where are we on the gallery protection and can someone repackage this module for others to use?

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

@stimhambo: I need to protect images as well, but I think I’ll be doing this through a regular weblog, and usung phpThumb to generate thumbnails. I think the path can be hidden on those thumbs too by enabling “high security” mode in phpThumb. My dev page seems to be working right now.

I think I read somewhere where this can’t work with the gallery module? I agree, It would be nice.

       
jtnt's avatar
jtnt
137 posts
17 years ago
jtnt's avatar jtnt

I’m having an issue when using Safari with this. The downloaded file’s name is coming through as my domain name plus the file extension, not the proper filename. e.g. It comes in as expressionengine.pdf, instead of my_resume.pdf. It works fine using Firefox.

The thing is, this only happens on my server. e.g. I downloaded the module zip from the developer’s site and it came through with the proper file name.

So, is there a server/PHP setting I need to tweak for Safari?

       
jschutt's avatar
jschutt
452 posts
17 years ago
jschutt's avatar jschutt

Robin,

Have you or anyone you know of used this module with Amazon S3? I am getting

Notice: Undefined property: download_path in /xxxxxxxxx/modules/download_lock/mod.download_lock.php on line 172

Any ideas?

Jesse

       
jschutt's avatar
jschutt
452 posts
17 years ago
jschutt's avatar jschutt

Anything?

       
jschutt's avatar
jschutt
452 posts
17 years ago
jschutt's avatar jschutt

Aw gosh Robin! I’m being very patient :red:

       
Habenix's avatar
Habenix
41 posts
17 years ago
Habenix's avatar Habenix

Hi Robin,

i´ve registered on your site but when i want to log in i keep getting this message: “Your membership account has not been activated yet.” So far i can tell , i didn´t receive any email for activating my account. Can you help me out pls?

Thx

Chris

       
Habenix's avatar
Habenix
41 posts
about 17 years ago
Habenix's avatar Habenix

Hello Robin,

unfortunately i didn´t get any answer from you but the issue with the registration still persists. Please tell us if you like to share your extensions/plugins with the community again.

Chris

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
about 17 years ago
Robin Sowell's avatar Robin Sowell

Hm- wonder if I’ve buggered it up somehow. That’s the site I mostly test on. Try to login now- manually activated the pending account- think it was the right one.

       
Habenix's avatar
Habenix
41 posts
about 17 years ago
Habenix's avatar Habenix

Hi Robin,

thank you for activating my account. I could download and install the file but i keep getting this error:

Download error Incorrect download link Return to main page

The settins in the module are as follows:

var $field_id = '13';
var $download_path = '/home/www/htdocs/www.mydomain/downloads/';

and this is my template code:

{exp:weblog:entries}
<h3>{title}</h3>
<a href="http://{exp:download_lock:link">Download</a>
{/exp:weblog:entries}

Can you give me a hand with this? Thank you so much.

Chris

       
Michael Prell's avatar
Michael Prell
39 posts
about 17 years ago
Michael Prell's avatar Michael Prell

Robin,

I’m looking for a way to track which members downloaded individual PDF files. Does the stats package provide this information?

Thanks!

       
NKT com's avatar
NKT com
124 posts
16 years ago
NKT com's avatar NKT com

Any idea how to make this work when using exclude method to remove www. from URLs.

Love, Robin

       
Macrike's avatar
Macrike
137 posts
16 years ago
Macrike's avatar Macrike

Any chance of getting this to work with Amazone S3?

       
Jacob Graf's avatar
Jacob Graf
163 posts
16 years ago
Jacob Graf's avatar Jacob Graf

Robin,

How goes it? I just came across your Download Lock Module and love it! I did come across an issue though and wanted to get your take on it.

First a little background. I am using Mark Huot’s File Extension to convert two custom fields into Files. There is only one entry in that weblog so the client can just edit that one entry to update one or both of the files.

Everything works GREAT, except if I remove one file (also deleted from server via File Extension) and then re-upload a new file and click Submit, one of the download links pulls up index.php and tries to download it.

I dug deep into those custom fields of that entry in the database and it looks like there were two line breaks after the URL for the file that was trying to download index.php. I removed those extra spaces using phpMyAdmin and saved it and it works great.

But everytime I delete/update a file, it adds another line break to the field. Any ideas? Or is this an issue with the File Extension? Thanks for your help!

       
1 2 3 4

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.