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.
@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.
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?
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
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!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.