Any easiest way to do "download count"?
Is there any easiest way to do download count?
In both Modx way or the common JS/CGI way is OK for me.
I’m not familiar with PHP, but I know much of Perl.
I found the FileDownload snippet, but seems it’s for download list,
not suit my requirement.
My requirements:
1, The link to the file to be downloaded must be plain, that’s to say,
http://mysite.com/somefile.zip is prefered,
http://mysite.com/somescript.php?blahblah is not acceptable.
2, I can add the download link anywhere, maybe in an article, maybe in
a download page.
3, Download count is a must. I prefer the counter stored in a plain
text, but database is OK too.
4, I can display/hide the counter beside the link.
What I’ve thought to do is,
1, Put an "onclick" event handler for the download link. The download
link is really plain and not rewritten.
2, In "onclick", send a request to a server side script to increase
the counter and continue the download.
3, For displaying counter in the web page, put some placeholder tag
and use JavaScript to get and display the counter.
This method heavily depends on JavaScript, so it’s not very accurate
when the JS broken (due to the web browser or bad net connection, etc)
Is there any better or simpler solution. It will be good if I don’t
need to make this from scratch. Indeed I have very few web development
experience.
Any advice?