goldsky / FileDownload-R

FileDownload snippet for MODX revolution
12 stars 7 forks source link

Problem counting file downloads #5

Closed kbender closed 11 years ago

kbender commented 12 years ago

Here is my resource

[[!FileDownloadLink? &getFile=download/version1.exe &userGroups=Userss &countDownloads=1 &tplCode=<a style="line-height:16px;" href="[[+link]]" title="[[+filename]]"> <img src="assets/template/style/exe-icon.gif" alt="" width="16" /> Descargar [[+filename]] ([[+count]] downloads)</a>]]

but the count always stays 0

PS: also, I suggest counting downloads by real name, no by hashed name, because its safer to provide a new link every time a user downloads the file (to force users to register on the site) and to prevent downloads by direct link outside the site.

Edit: Maybe the problem is here? (filedownloadlink.snippet.php) if (!empty($_GET['fdlfile'])) { if (!$fdl->checkHash($modx->context->key, $sanitizedGets['fdlfile'])) return FALSE; $downloadFile = $fdl->downloadFile($sanitizedGets['fdlfile']); if (!$downloadFile) { return ''; } return ''; } you are returning '' always

goldsky commented 11 years ago

@kbender

but the count always stays 0

It works on me.

@kbender

PS: also, I suggest counting downloads by real name, no by hashed name, because its safer to provide a new link every time a user downloads the file (to force users to register on the site) and to prevent downloads by direct link outside the site.

The prevention has been fixed on the next release, but this script is not designed to generate new random hash for each page visit. Interesting thought, though

@kbender

you are returning '' always

It is. Because it's a downloading state. It even supposed to be die();