$12256 / $11500
I just wrote some custom download counter code, and it appears to be working fine. I've imported all of the data from the old counter into the new one (although I can't guarantee perfect accuracy of the old data, which was broken anyway).
The new counter uses javascript and ajax, which has the advantage of not requiring messy links (no more "/.../pubdlcnt.php" junk), but on the downside, it won't work on the off chance that someone isn't running JavaScript.
Comments
Thank you, it's working much better than the old one already!
Thanks for the improvement! :)
Nice, although a right-click on the link adds a download.
As a suggestion, maybe you could write a custom script, use mod-rewrite to hook any files to it, and count downloads through there instead? This will have the advantage of not having any weird scripts visible to the public, and will count the link rights (instead of relying on user click input).
In any case, nice work on this site! :)
Nice, although a right-click on the link adds a download.
Yeah, there isn't really a way to do this with javascript and avoid that. Unfortunately, javascript can't tell if you right click and hit "save as", so I have to detect right clicks when they happen and assume that they indicate an intent to download a file. It's not perfect, but since some file types require that they be right clicked to download them, I have to do it that way.
As a suggestion, maybe you could write a custom script, use mod-rewrite to hook any files to it, and count downloads through there instead? This will have the advantage of not having any weird scripts visible to the public, and will count the link rights (instead of relying on user click input).
It can't work quite like that, because I don't want to incur the processor overhead of streaming files through a download script. The best I could do is change the file download links to point to a script that counts the download and then redirects the browser to the actual download link, but the trouble there is that it would probably open a new page every time someone downloads a file, which is annoying from the user side. If I'm wrong and there's some way to do it without either of these problems (and without the downloader having to rename the file, which was really irritating), then I'm open to suggestions. :)
Hello!
Yeah I actually forgot that you had to stream files through PHP for it to work, silly me! You're probably right too.
The way I'd handle it is the way you had it before, with links to a PHP script that counts and redirects: download.php?id=file.mp3
Of course I'm assuming if you changed it is because it caused problems/you didn't like it?
In any case, I don't know. I don't really know of any other way than streaming the file (with a buffer of course~!) or redirecting :(
Good luck!
Any way to do it creatively on the back end with mod_perl? I'd think you could do something like this example, where you create a custom perl script to update the database, and then reference it with PerlLogHandler inside a Files or FilesMatch directive so it's only invoked for image files. No redirection or funky renaming on the browser side, and you avoid any overhead you may incur from streaming the download through PHP.
You could backtrack a access log file without feeding the download through php.