Simple Download Monitor problems

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

Previous topic - Next topic

Piet

OK you can forget about both my posts above, for some *magical* reason all of a sudden it is working.

Still don't know why it wasn't before, but it is now, so all good.

pepak

One thing to keep in mind whenever you encounter a problem with SDMon: First thing to try is a "direct" link in the form of mywebsite.com/index.php?sdmon=files/path/name.zip. If it works, then the problem is with the .htaccess file. If it doesn't work, the problem is with SDMon configuration.

Carsten Lippert

Hello,

when I try the direct-link http://www.1050-jahre-eilenburg.de/index.php?sdmon=files/logo_4c.zip I get the following output:

Warning: finfo_open() expects parameter 1 to be long, string given in /home/www/kunden/buergerhaus-eilenburg.de/1050/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 329

Warning: finfo_file(): supplied argument is not a valid file_info resource in /home/www/kunden/buergerhaus-eilenburg.de/1050/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 330

Warning: Cannot modify header information - headers already sent by (output started at /home/www/kunden/buergerhaus-eilenburg.de/1050/wp-content/plugins/simple-download-monitor/simple-download-monitor.php:329) in /home/www/kunden/buergerhaus-eilenburg.de/1050/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 253

and three more more Warnings "Cannot modify header information" and then the binary content of that file.

I am not sure what is wrong.
In my .htaccess the following is written:

  Order Allow,Deny
  Deny from all



  SetHandler x-httpd-php5



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


The SetHandler I need for PHP5 (I use Wordpress 3.0.1, which need PHP5).

Do you have any idea?

Thanks a lot.

cl

pepak

Quote from: Carsten LippertHello,

Warning: finfo_open() expects parameter 1 to be long, string given in /home/www/kunden/buergerhaus-eilenburg.de/1050/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 329

[...]

Do you have any idea?
My guess is that you use a very new or a very old PHP version, or it's configured in an unusual way: I am calling finfo_open() with a FILEINFO_MIME_TYPE constant, which should translate to a number as per PHP's requirements. But apparently it translates to a string instead. That almost certainly means that the constant is not defined at all, and PHP treats undefined constants as if they were strings instead. You could use a script like this to confirm this theory:


I have no idea how it could happen for this constant to be undefined - perhaps finfo functions are not compiled into your PHP? You'll need to inquire with your webhoster about that.

Carsten Lippert

Hello,

I put this code

in a file and the output is
Value of constant FILEINFO_MIME_TYPE is: FILEINFO_MIME_TYPE

So I dont know, if this is right. I think it isnt.

Look at http://www.carli.de/temp.php

hg Carsten Lippert

pepak

That confirms my suspicion. For some reason, FILEINFO_MIME_TYPE constant is not defined on your server.

And the look into the PHP documentation reveals that this constant is available for PHP 5.3.0 and newer. I will write some workaround. Until that is done, you can comment-out lines 329 and 330 in simple_download_monitor.php (version 0.17).

Carsten Lippert


Raffaele Gambelli

Hi,
i installed your plugin and initially it worked fine, after some minutes I tried again doing a download and the following message appeared:



Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 41318401 bytes) in /web/htdocs/www.mysite.it/home/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 258


From that, no download works anymore and so I removed the "magic" line from .httaccess restoring the normal download...

Is it possible that a cms like wordpress hasn't a good plugin for download monitoring, I tried all of them, found one or more bug after some minutes from their activation, incredible...

thanks and best regards
Raffaele

pepak

It seems it may be a problem with your webserver's configuration and/or PHP. There is a tip in the PHP documentation that may work - try to change line 258 in simple-download-monitor.php file from
readfile($filename);
to:
ob_end_flush(); readfile($filename);

If it works, I will add it to the official version.

hnrch

Well finally I got this plugin working correctly, the current environment is:

- My website is installed at  /wordpress/ (as you can see, is not "root path")
- I used .htaccess to open my web at www.domain.com instead of www.domain.com/wordpress/
- I'm using permalinks like this: www.domain.com/%postname%/
- My downloads folder is at /files/ (outside of wordpress installation)

Sincerely I tried lot's of  combinations in configuration, option values etc etc etc, that I can't remember what I have done, but I will share the two changes I have done in simple-download-monitor.php:

- First Change: In function Download(), ABSPATH was pointing inside /wordpress/ so realpath() was returning false, so I added the following code after the $fullfilename and $relfilename value assignation.

if ( ! $fullfilename ) { // If WP installation is not at root    
    $fullfilename = realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $filename);
    $relfilename = substr($fullfilename, strlen($_SERVER['DOCUMENT_ROOT']));
}

and now that section looks like this;

// Normalize the filename
$fullfilename = realpath(ABSPATH . '/' . $filename);
$relfilename = substr($fullfilename, strlen(ABSPATH));
if ( ! $fullfilename ) { // If WP installation is not at root    
    $fullfilename = realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $filename);
    $relfilename = substr($fullfilename, strlen($_SERVER['DOCUMENT_ROOT']));
}
$relfilename = strtr($relfilename, '\\', '/');
$exists = (file_exists($fullfilename) AND !is_dir($fullfilename)) ? 1 : 0;

- Second Change: I just modified the regular expression in the $dirregexp value assignation, replacing '^' with '^\/?', so the code looks like this:

// Make sure it is a valid request
$dirregexp = self::PREG_DELIMITER . '^\/?' . get_option(self::PREFIX . 'directories') . self::PREG_DELIMITER;
$extregexp = self::PREG_DELIMITER . '\\.' . get_option(self::PREFIX . 'extensions') . '$' . self::PREG_DELIMITER;
$valid = (preg_match($dirregexp, $relfilename) AND preg_match($extregexp, $relfilename)) ? 1 : 0;

This is because relative path might start with or without a slash.

Well I hope this helps to somebody else, and I suggest this to be added in the next versions of the plugin, by the way just want to say that is a nice plugin. :)

P.D. Sorry for my bad english, I'm mexican.

pepak

Quote from: hnrch- My downloads folder is at /files/ (outside of wordpress installation)
Yeah, this would be a problem.

Quote- First Change: In function Download(), ABSPATH was pointing inside /wordpress/ so realpath() was returning false, so I added the following code after the $fullfilename and $relfilename value assignation.
Seems reasonable.

Quote- Second Change: I just modified the regular expression in the $dirregexp value assignation, replacing '^' with '^\/?', so the code looks like this:
I will need to think about this change a little. It seems to me it may be a better idea to have $relfilename always without the leading slash.

Thanks for the improvement. I'll add it to SDMon.

Malcev

Hi!
Thank You for this plugin.
I use this plugin to get information how many people watch my video (flv format)
But I have PHP/5.2.6
And I get those errors

Warning:  Cannot modify header information - headers already sent in /home/zvezdole/zvezdolet.lv/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 257



Warning:  Cannot modify header information - headers already sent in /home/zvezdole/zvezdolet.lv/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 258



Warning:  Cannot modify header information - headers already sent in /home/zvezdole/zvezdolet.lv/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 259



Warning:  Cannot modify header information - headers already sent in /home/zvezdole/zvezdolet.lv/wp-content/plugins/simple-download-monitor/simple-download-monitor.php on line 261


What can I do to make this work
My be I can write something in php.ini?
Thank You!

pepak

It seems some other plugin interferes with SDMon by writing output first. It's hard to suggest a fix without knowing which plugin is the culprit (you can find it by deactivating plugins one after another until the messages stop appearing), but it is likely that activating a cache plugin such as W3 Total Cache would help.

Malcev

Thank You!
You are right.
I disable WP Super Cache and your plugin starts to work.
As I understand they can not work together?

pepak

They should. I specifically added some code in the last version which should make it compatible with caching plugins, and SDMon if fact does work with W3 Total Cache. As I don't use WP Super Cache, I didn't test it, but I thought my fix is pretty universal. At the moment I don't know what else to do to improve the compatibility. (More exactly: I know what to do in theory, but I don't know how to do it...) Just one possible thing: Try to remove /index.php from caching. I believe W3 Total Cache does that automatically.

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