Simple Download Monitor problems

Started by pepak, November 04, 2009, 11:46:40 AM

Previous topic - Next topic

pepak

I see what's the problem: The code you have
...is intended for linking to documents and clicks usually result in a browser offering an action (download, open, etc.). The "inline" function of SDM is intended for codes such as

These are intended for display within the HTML page itself.

MixMan

Hi Pepak and thanks for the useful plugin!

In the allowed directories I have put:

 "wp-content/uploads/"

In the allowed extensions:

 "mp3"

In the .htaccess file:

RewriteRule ^(wp-content/uploads/.*) /index.php?sdmon=$1 [L]

Everything works, but the plugin gives me stats for all kind of files, not just .MP3 (jpg, rar, ...)

What's my mistake?

pepak

Interesting. I never thought of it, but I have just tried it and you are correct.

I am at a loss what to do with it - it's not a bug per se, but a rather strange (though logical) behavior. What happens is:

1) User tries to access a file with other than allowed extension.
2) SDMON processes the requests, checks for the existence of file and correctly logs a download attempt.
3) SDMON then checks permissions and because the file doesn't have a permitted extension, it refuses to download it, reporting a "Not found" error instead.

Now the question is, what is the correct behavior? The current one is actually OK, because there was an attempt to download that file and that files did exist. Two alternatives I can think of are:
1) Not log anything because the download didn't even start - it was just an unsuccessful attempt.
2) Log the attempt but put it among the nonexistent files. Which would hide the attempt from main view while still keeping it for tracking purposes, but at the cost of some confusion (why is the access stored among nonexistent files wjhen the file exists?)

Maybe I should change the boolean flag (exists/doesn't exist) to an enumerated type (exist and valid/exists and invalid/doesn't exist)? I'll need to think about it. I'd appreciate an input.

MixMan

You got me quite confused. I just want to have stats for only mp3 files, isn't the "Allowed extensions" option just for that?

The option doesn't seems to work.

pepak

Quote from: MixManYou got me quite confused. I just want to have stats for only mp3 files, isn't the "Allowed extensions" option just for that?

The option doesn't seems to work.
The main purpose of the option is to prevent access to files not designated for download.

As I said, I'll need to think about it and about ways of fixing it, if I decide it needs fixing (which it probably does).

MixMan_

I thought it was for restricting the stat processing to certain file types.

"Only files with extensions matching this regular expressions will be processed."

Sorry, I am not aware of how it actually works, don't have coding abilities.

I just don't want to see statistics for let's say images in my site, although they are actually downloaded on everybody's PC, when they load the page in their browser.

pepak

It was a reasonable assumption and I will need to do something about it. But the primary purpose was security, not file selection - that is done by the .htaccess.

MixMan

I see. Hm, do you think there's another solution for now? Like altering the .htaccess file to "process" only the desired file types? Or I am dreaming?

pepak

For now? Change the .htaccess line from
RewriteRule ^(wp-content/uploads/.*) /index.php?sdmon=$1 [L]to
RewriteRule ^(wp-content/uploads/.*\.(pdf|gif|jpe?g|png)$ /index.php?sdmon=$1 [L]That should work.

MixMan

I changed it and the site started giving me:

INTERNAL SERVER ERROR.

Also, I noticed that when I am using this line in .htaccess:

RewriteRule ^(wp-content/uploads/.*) /index.php?sdmon=$1 [L]
the images in my site stopped to show up. So now not only I am getting stats for all these other than MP3 files too (that I don't need, but my images don't work. I think I did a total mess with the settings :)

Switched off the plugin for now.

pepak

Quote from: MixManI changed it and the site started giving me:

INTERNAL SERVER ERROR.
I forgot to add an ending parenthesis:
RewriteRule ^(wp-content/uploads/.*\.(pdf|gif|jpe?g|png))$ /index.php?sdmon=$1 [L]
Quote from: MixManthe images in my site stopped to show up. So now not only I am getting stats for all these other than MP3 files too (that I don't need, but my images don't work. I think I did a total mess with the settings :)
That is the expected behavior: You told SDMON to only allow files with mp3 extension, so it dutifully prevents access to files with other extensions. You need to expand the allowed extensions setting to allow for additional file types.

JKirkby

I'm having the same problem as 'MixMan'

I only want to track MP3 downloads, but if I only track MP3 downloads, images don't appear on my site. If I add images to the "Allowed extensions" section, then image downloads appear in the download stats.

Most images on my site are inside the tag.

I've also added:
RewriteRule ^(wp-content/uploads/.*\.(pdf|gif|jpe?g|png))$ /index.php?sdmon=$1 [L]
to my .htaccess file, but it hasn't made a difference.

Thanks



Sean

pepak -- great plug-in!!   Having slight difficulty getting it work.  

1) Using the 'www.mysite.com/index.php?sdmon=myfolder/myfile.zip' test works (file is registered as downloaded).  
2) Using 'www.mysite.com/myfolder/myfile.zip' doesn't.. file download is not registered.
3) I verified that my webhost supports both user-defined .htaccess files and mod_rewrite.
4) The relevant part of my .htaccess file looks like this:

---
RewriteEngine on
RewriteBase /
RewriteRule ^(myfolder/.*) /index.php?sdmon=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
-------

5) I verified that no other .htaccess files exists in any subs off the site root.
6) I verified that the extension for my downloadable filetypes (pdf) is included in the allowed extensions settings.
7) I'm puzzled!

Any advice is appreciated!

Sean

Quick Reply

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
Shortcuts: ALT+S post or ALT+P preview