So- I’m finally putting up an EE website and as I was screwing with the CSS for the billionth time and concluding the site really was that butt ugly I decided it would be much more fun to write a module to handle my downloads. Basically I wanted something simple- require membership (or specified group) to download, hide the actual folder holding the downloads and maybe keep some basic stats. NOTE- right now, it’s only designed to handle zip files- if somebody ends up wanting it to force media downloads, I’d have to dink with it. But honestly- I figure it will mostly used by folks like me who want to keep track of scripts being downloaded.
Anyway, only took 2 days to write it and another 2 for the stupid documentation. Still beat screwing with css for another minute. You’ll find the download here- er, but you’ll have to be logged in to see the link (course, I did that bit with pure EE conditionals). And don’t worry- I made membership with no confirmation, so if you want the module you won’t have to jump through hoops for it.
If you WERE logged in, you’d see a link with this url: http://media-cow.com/?ACT=27&ID=2 - basically, it’s passing the entry_id, then using that to grab the filename from a custom field in the weblog entry, then serving up the file from its ‘secret location’. If you aren’t logged in or don’t meet the membership requirements, you get served with an error and a link to the main site.
And then I added a little htaccess file to the download folder- which if it works on your server means that even if they know the ‘secret folder’ and/or true url- which in this case would be http://media-cow.com/d-stuff/mod.download_lock.zip, it can’t be accessed via http anyway. So- should be pretty secure. Especially if you don’t go around posting the url of your secret folder.
Which is all rather moot as any software worth stealing can be easily had anyway. But hey- it’s still cool. I would kind of like to at least halfway keep track of who is downloading what.
Anyway- it’s in beta. The first step of which is seeing if the download works for you- but only when it should.
Also- have you noticed nobody sees stuff posted below the fold? Including me. That sucks. Somebody go try it out. Should be maintained as I’m actively using it. Not really planning to add much to it as it does what I need- but if folks need stuff, can’t hurt to ask. A license ‘confirm’ form wouldn’t be a bad idea. But then I’d have to write a license. Er- a different license. Anyway- put it to the test, let me know where it breaks.
I can already think of several neat little uses for this. Thanks, rob1! I’ll download it, play with it, and let you know my thoughts. I may not be able to do serious testing of this until next weekend, though, but this is definitely attractive.
thank you for your hard work. i think this is a great addition to EE.
i will like to make a request. i like to add other file types (with a user’s choice, if possible), including .jpg, .gif, .bmp, .png, .rar, .txt, .mp3. i will also like to have this feature cover user-selected directories (as these files can be stored across multiple directories and subdirectories).
Thanks for this Rob it looks like it’ll do just what I want it to but can I make a request for pdf support? I want to protect and log document downloads.
Also, does the logging functionality store references to the individual members that downloaded a file with relevant time and date information?
Sorry if this is obvious from reading the php source… I’m just learning php… slowly!
Thanks again for this module,
Rob
Man- I really don’t look below the fold much. I’ll see what I can do about adding the other file types. On the one hand, it’s easy to do. On the other hand, it’s one of those things where you run into browser specific differences, which can make it a pain to test and get working correctly on EVERYTHING.
As to user-selected directories, that will take more thought. I had considered allowing different directories with different config options (x group can download from this directory, y group can download from another)- but it adds an extra layer and more overhead, which I didn’t need, so I avoided. Anyway- that bit will take more time as if I do it, I want to be sure there’s a simple mode that avoids the extra overhead.
As to stats- it does record the date of the last download a person made and how many times they’ve downloaded (though an interrupted download will get counted twice). Would be pretty easy to add an extra column and keep both the date of the first and last download. And I don’t think the stats tag actually shows the individual level data, but it would be easy enough to add it in- probably via another tag.
Anyway- will dink with adding the other file types today.
OK- got a v2 up for testing- and I’d advise testing before downloading. New script same place as the old- download and instructions here (no alterations to the db, so if you’ve already installed it, all you really need to do is replace mod.download_lock.php with the new file.
Also- before doing so, I’d suggest/request you burn some of my bandwidth on this page- I’ve got txt, pdf, jpg, gif, wmv, mp3 and bmp files up. They all download fine for me, but this is definitely one of those things where browser issues can crop up. So- I’ll say downloads look good in IE on pc. If you run into a problem with any, let me know here. If you download them all/whatever you want and are using a different browser, chime in and let folks know it’s all good.
File types that SHOULD work (but haven’t all been tested): txt, pdf, gif, png, bmp, jpg, mp3, wmv, zip, exe, qt/mov, doc, xls, ppt, avi.
I’m still doing this using readfile()- and I really didn’t think the 40mb file would work (er- it’s Hellsing- don’t download it if you aren’t into anime and vampires and on bb- I needed something big but not too big a pain to upload- you guys missed out on the Blake’s 7 option!). But it did, so I didn’t go with my other option. However- if you’re using this for a lot of REALLY large files, it’s possible you’ll run into memory problems. If so, let me know. I’ve got a different approach I could try.
Next version I’d like to add in an option for a TOS confirmation and tweak the stats a bit. I may dink with multiple folder options, but that’s expanding the script beyond what it was really intended to do.
I can’t find the RSS feed for your site. It would be great to be able to follow any changes or additions you make. Will be installing EZ rate later this week.
First of all a massive thank you for all the hard work that you must have put in to get this module working. Thanks for that.
I am just about to install the module now and test it out but what I would really love to have is a download module that can achieve the following :
1 - Offer users downloads based upon the group(s) they are allowed access to.
For example if you have say three groups in EE called :
Group 1 - PDF Downloads
Group 2 - Audio Downloads
Group 3 - Text Downloads
Of course they do not have to be named like this, just an example. If then a user belonged to ‘Group 1’ they could then see a list of files that they could download.
I don’t know if this is possible at all but would make the start of great workings for a kind of e-commerce come downloads module.
OK- I was using this on a client site, which inspired some tweaking. So- new version is up.
The big improvements-
* It will automatically figure out the path based on standard EE inserted {file_x} file browser specification- meaning as long as you are using the EE syntax, you can use mulitple folders and it will pick them up automatically.
* I also added the ability to pass the custom field id in the link- that means you can ‘protect’ a link in any field, not just one specified field.
* Also added 2 hooks- one takes over statistics functions- so you could write an extension to insert counts in a weblog custom field, making it easy to show the number of downloads on a multi-entry page. You could do this before by tweaking the code, but now it’s simple to do, no tweaking involved. If there’s an extension to take advantage of it. I wrote just such an extension.
* The other hook takes over permissions- I added it so I could integrate the module with the simple commerce module. I’ve also written a the extension to take advantage of that hook. I think that extension will probably be a pro one- and I’ll be asking for beta testers in another thread.
* Added the ability to NOT require membership- so you can use it to simply force downloads and keep track of the number of downloads.
In short- just made the whole thing more flexible. You can download the latest version here, just replace the existing files with the new ones. It’s currently powering downloads on that site, so shouldn’t be too buggy.
And EE Lover- no telling what was up with not counting you. I’m always dinking with stuff on that site- which means breaking it routinely.
Thanks a lot Robin for this module.
I’ve used version 0.1 until now and it worked fine so far.
Robin Sowell - 16 November 2006 03:11 PM
* It will automatically figure out the path based on standard EE inserted {file_x} file browser specification- meaning as long as you are using the EE syntax, you can use mulitple folders and it will pick them up automatically.
Wow! This is a great feature!
As I’m not an ee expert, I’m not sure how to set it up.
Could you just give an example how to configure path file and write file name?
Lets say, I had two download folders as subfolders of a “top_download_folder” at the root
and expression_engine installed in an extra folder (not directly at the root):
How would configure than the pathfile in mod.download_lock.php
and how would I have to enter the file name (with what kind of ee_code)
in my created_file_download_custom_field?
So- that’s all you’d have in whatever custom field(s) hold your download. Say I put that in a custom field with a shortname of ‘download’. Then, in my template- if I want the module to automatically figure out the path, it will. (Be sure to use full paths in your file browser settings.)
So basically- that’s what the ‘download’ field holds if I look at it in the ‘edit’ page- and on the template, I just put:
It will generate the proper ‘fake’ link- and what happens, when the link is clicked, the module pulls up the contents of the download field- figures out the file browser- does a query to see the path for that file browser- and uses that path to find the file and serve it up.
You don’t have to specify the field_name parameter- if it’s not there, it will use the default. But you can- which means you can put a downloadable file in any custom field. If it’s not specified, then EE uses the default. Same deal with the path to the image- if you don’t use the {filedir_x} tag in the custom field, EE will fall back on the one specified in the default.
OK- just a ‘heads up’ that I’ve started a private beta on the Download lock pro extension- it integrates the Download lock module with the simple commerce module. Meaning- it checks whether the file has been purchased before allowing the download.
The extension will be a ‘pro’ extension, the module stays free. I’m looking for beta testers- and folks who already use the module are probably the best qualified. Drop me an email if you want in on the beta (I’m only taking 4-5 folks).
Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /usr/www/users/ingmar/system/modules/download_lock/mcp.download_lock.php on line 26
This is 1.5.1. I will try on a different install tomorrow, I’d really like to test the Pro Extension, going to sell E-books with the simple e-commerce module.
Hm- let me try de-installing mine and making an install from the downloadable version.
Did you edit the mod.download_lock.php file at all? There are some config options in there I always set, so it’s possible that a purely unedited version might goober.