Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: Amigamerlin on September 25, 2012, 20:43:46

Title: Nautilus Donwload plugin error
Post by: Amigamerlin on September 25, 2012, 20:43:46
Hello Datahell,
Just installed download plugin and published it.
I create a new article and using plugin I uploaded a PDF file. All went ok but when I try to download the file inside the article I get an "Invalid request!".
and no error in log files.

Apache log, no error too.
Apache acces log :

"GET /nautilus/components/com_content/plugins/download/includes/dl.php?m=0&c=UmEHLV5mB34EPgcuU2JadltpUjFQPwA0UGwKYAMzAWwJOg== HTTP/1.1" 1 36 "http://localhost/nautilus/index.php/elxis/test-upload.html" "Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1"

I hope this can help you .

Spec:
Apache 2.2.17
MySQL 5.1.53-community
PHP 5.3.4

Elxis Nautilus Beta 1297

Let me know.

Thank you

Title: Re: Nautilus Donwload plugin error
Post by: datahell on September 25, 2012, 22:17:23
The download plugin uses a system to prevent direct linking from external sites.
For some reason the validation fails.

Try this: refresh the page and click again. Still the same error? Do this 2-3 times.

If this doesn't work you need to debug the plugin.
Here is how you will do it.

Open file components/com_content/plugins/download/includes/dl.php
Find all occurrences of "invalid request" string and append a unique integer next to it.
Example:
dlend('Invalid request! 1');
....
dlend('Invalid request! 2');
...etc

Now click again the download link and see the message. It will display something like Invalid request! X, where X the integer you wrote.
Copy-paste me the source code around this message, or write me the source line number, to see what the download script does there in order to understand why the validation fails.

Note: the download plugin links expire after 30 minutes ! So always refresh the page before testing. If the page is cached it is normal to get invalid request response due to expired links...
Title: Re: Nautilus Donwload plugin error
Post by: Amigamerlin on September 25, 2012, 22:37:26
The download plugin uses a system to prevent direct linking from external sites.
For some reason the validation fails.

Try this: refresh the page and click again. Still the same error? Do this 2-3 times.

If this doesn't work you need to debug the plugin.
Here is how you will do it.

Open file components/com_content/plugins/download/includes/dl.php
Find all occurrences of "invalid request" string and append a unique integer next to it.
Example:
dlend('Invalid request! 1');
....
dlend('Invalid request! 2');
...etc

Now click again the download link and see the message. It will display something like Invalid request! X, where X the integer you wrote.
Copy-paste me the source code around this message, or write me the source line number, to see what the download script does there in order to understand why the validation fails.

Note: the download plugin links expire after 30 minutes ! So always refresh the page before testing. If the page is cached it is normal to get invalid request response due to expired links...


done as you described above .
Got "Invalid request!4"

line 50 to 54
Code: [Select]
$c = isset($_GET['c']) ? trim(urlencode($_GET['c'])) : '';
if ($c == '') { dlend('Invalid request!3'); }
$c2 = preg_replace("/[^a-zA-Z0-9\s\+\=\-\!\/]/", '', $c);
if ($c2 != $c) { dlend('Invalid request!4'); }

Ciao
Title: Re: Nautilus Donwload plugin error
Post by: datahell on September 25, 2012, 23:25:35
It can't be that...
the characters preg_replace removes are not in $_GET['c'] variable.
Quote
c=UmEHLV5mB34EPgcuU2JadltpUjFQPwA0UGwKYAMzAWwJOg==

Do this, replace:
$c = isset($_GET['c']) ? trim(urlencode($_GET['c'])) : '';
with this:
$c = isset($_GET['c']) ? trim($_GET['c']) : '';

and retry
Title: Re: Nautilus Donwload plugin error
Post by: Amigamerlin on September 26, 2012, 01:21:31
It can't be that...
the characters preg_replace removes are not in $_GET['c'] variable.
Quote
c=UmEHLV5mB34EPgcuU2JadltpUjFQPwA0UGwKYAMzAWwJOg==

Do this, replace:
$c = isset($_GET['c']) ? trim(urlencode($_GET['c'])) : '';
with this:
$c = isset($_GET['c']) ? trim($_GET['c']) : '';

and retry

done ...
Get invalid Request! 5

Line 60 - 69
Code: [Select]
if ($m > 0) {
$confpath = ELXIS_PATH.'/configuration.php';
} else {
$confpath = ELXIS_PATH.'/config'.$m.'.php';
}
if (!file_exists($confpath)) { dlend('Invalid request!5'); }

include($confpath);
if (!class_exists('elxisConfig', false)) { dlend('Invalid request!6'); }



Title: Re: Nautilus Donwload plugin error
Post by: datahell on September 26, 2012, 10:55:17
Oooooops, my mistake! I have the if stament reversed. Sorry!

Please replace this:
if ($m > 0) {
   $confpath = ELXIS_PATH.'/configuration.php';
} else {
   $confpath = ELXIS_PATH.'/config'.$m.'.php';
}
With this:
if ($m > 0) {
   $confpath = ELXIS_PATH.'/config'.$m.'.php';
} else {
   $confpath = ELXIS_PATH.'/configuration.php';
}

The listing on EDC was updated, thanks for the bug report!
Title: Re: Nautilus Donwload plugin error
Post by: Amigamerlin on September 26, 2012, 22:47:57
Thank you to you Datahell for Nautilus, this amazing cms !!!