I uploaded a pdf file through CCK filefield, I got the (0) next to the file name (no file size) so I guess the pubdlcnt registered it but I try to download the file it gives me a Page not found.
1) absolute path of the drupal root directory in the server
/home/prkos/public_html/drupal/
2) absolute path of the public download count installed directory
/home/prkos/public_html/drupal/sites/all/modules/pubdlcnt
3) absolute path of a file that does not count (this url works ok when I enter it in browser)
http://www.obiteljskizivot.com/sites/obiteljskizivot.com/files/obiteljsk...
4) URL of the file (see the status bar when you move mouse over to the file download link).
http://www.obiteljskizivot.com/sites/all/modules/pubdlcnt/pubdlcnt.php?f...
It's working fine on my local drupal
1) absolute path of the drupal root directory in the server
/var/www/drupal/
2) absolute path of the public download count installed directory
/var/www/drupal/sites/all/modules/pubdlcnt
3) absolute path of a file that does !!! count
http://oz.local/sites/oz.local/files/UVOD%20CCC-kon.zip
4) URL of the file (see the status bar when you move mouse over to the file download link).
http://oz.local/sites/all/modules/pubdlcnt/pubdlcnt.php?file=http://oz.l...
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | files_pubdlcnt.zip | 8.19 KB | mario_prkos |
| #10 | pubdlcnt-debug.php.txt | 7.4 KB | pixture |
| #7 | pubdlcnt.php.txt | 7.22 KB | pixture |
Comments
Comment #1
portulacaActually it's not only the CCk field where this happens, I also get Page not found when the file is attached. And again it happens on my host but on local drupal installation.
Comment #2
portulacaI have tried to debug this but I'm not an expert. When playing with the url I always get a warning concerning Headers being already sent. I checked the script and it doesn't seem to have extra spaces in the beginning or end of the document, this seems to be common cause for such warnings.
I also tried with output_buffering "On". Now if I enter this url (I changed it to relative from /sites....):
http://www.obiteljskizivot.com/sites/all/modules/pubdlcnt/pubdlcnt.php?f...
I get this:
When I go back to the node the counter is incremented, I can see the report on the report page, but still when I click on the file to download I get Page not found. (The counter isn't incremented if output_buffering is "Off". )
If I go with (no "/" in front of sites):
http://www.obiteljskizivot.com/sites/all/modules/pubdlcnt/pubdlcnt.php?f...
I get this:
But the counter isn't incremented when I go back to the node page.
It's puzzling why it works on my local installation but not on host.
Can you give me any instructions how to debug this, what steps and information do you need?
Comment #3
pixture commentedportulaca,
First of all, can you tell me the version of the PHP does your server has? Is your server uses PHP safe mode?
Next, please use the full URL for the anchor tag. Actually, I never tested the situations where the file link anchor URL has partial path which does not start with http: or ftp:. Right now, the public download count module is not designed to handle partial path. I do not think that the current version of module can handle such partial URL.
I still do not know why "Page not found" error happens. Does this always happen with all the file download links? or does it happen occasionally? or does it always happen with certain files? If it does not always occurs but occurs occasionally, could it possibly be a timeout of PHP or apache server ?
I will keep looking into it.
Comment #4
portulacaPHP 5.2.4
safe_mode Off Off
I understand about the full/partial path issue, I only used partial path when trying to debug to figure out why it happens. I thought it might be significant that the /sites.... path increments the counter so you might easily figure out where the problem is.
It always happens on my host, with both CCK fields and attachments, I just can't get it to work. I'l have to keep Public dl counter disabled so people could download the files if I don't find out why this happens. So far I tested it with pdf, zip and doc files.
We tried to figure out how this works but it's very hard to debug.
Can you explain how this script works in more detail? The whole concept actually, because it seems it's not the script but how this is all put together (the link to file).
Comment #5
pixture commentedThis is how the public download module works:
1) when the node is loaded from DB for viewing, the public downlaod module checks the anchor tag and convert them as follows:
From:
To:
pubdlcnt.php is an external PHP script (CGI) to handle file download and count incrementation. As you can see above, this script takes two parameters:
(1) file=[URL of download file]
(2) nid=[node ID where the file is downloaded from]
When a user clicked this anchor tag, pubdlcnt.php script is invoked. Then pubdlcnt.php script
obtain the full URL of the download file and the node ID. The script does some security checking
and then it checks if the specified download file really exists or not. If it exists, then
the script increase the download counter and then jump to the download file using PHP's
header("location: [URL of download file]") function, which just redirect to the URL of
the download file.
In the example above, the header("Location: http://www.example.com/files/sample1.zip") is called by the script, which is same as you type "http://www.example.com/files/sample1.zip" from the address bar of the Web browser.
Please check if you type the URL of the download file from the address bar of the web browser and see if you can download the file or not.
Another thing I want you to check is the permission of the directory where you place download files.
/sites/obiteljskizivot.com/files/obiteljskizivot/
What is the permission of this directory and who is the owner of this directory?
I guess the problem could be the permission of the files directory. The pubdlcnt.php script is not a part of the drupal and it is invoked directory by the Apache(Web) server. So in order for pubdlcnt.php script work, the files directory (actually obiteljskizivot directory in your case) has to have a permission that Apache can browese and read the contents there.
Could you please check these?
Comment #6
portulacaThe permissions on /sites/obiteljskizivot.com/files/obiteljskizivot/ are 755, how can see who the owners? I don't have shell access.
The direct link to the file works fine so I guess apache can get to it without problems (you can check yourself with the link from my first post).
Comment #7
pixture commentedPlease use the attached pubdlcnt.php.txt instead of the original pubdlcnt.php. (Please keep the original file so that you can restore it once the test is done).
The attached pubdlcnt.php file has added debug code which will produce the output like follows:
Array (
[0] => getcwd() returned [/www/pixture/html/drupal/sites/all/modules/pubdlcnt]
[1] => module seems to be installed to the (drupal-root)/sites/(site)/modules directory
[2] => including bootstrap.inc and other necessary drupal files
[3] => calling drupal_bootstrap()
[4] => chdir(/www/pixture/html/drupal/sites/all/modules/pubdlcnt) to return to the original directory
[5] => getting parameters...
[6] => file [http://www.pixture.com/drupal/sites/default/files/forum-icon-2-D.tar.gz]
[7] => nid [92]
[8] => calling is_valid_file_url(http://www.pixture.com/drupal/sites/default/files/forum-icon-2-D.tar.gz)
[9] => URL is valid. Let's update the download counter for
[10] => OK, let's jump to the original file URL
[11] => calling header('Location: http://www.pixture.com/drupal/sites/default/files/forum-icon-2-D.tar.gz')
)
Above is the test result at my web site. Please test it with your server and let me know what you get. This debug output tells what's going on inside the pubdlcnt.php script.
Thanks,
Comment #8
atiras commentedI am having this problem as well -- the relevant files are accessible on my local site with pubdlcnt enabled or disabled, but only accessible on my hosted site if public download count is disabled. I've tried the debug code above, but don't get any output such as you show -- where should I be looking for it? (I'm not experienced at this!)
Comment #9
portulacaHere's what I did:
On my host I still get a Page not found :( :(
I also tried it on my local installation and I got the debug info, I'll copy it here just in case
Array (
[0] => getcwd() returned [/var/www/drupal/sites/all/modules/pubdlcnt]
[1] => module seems to be installed to the (drupal-root)/sites/(site)/modules directory
[2] => including bootstrap.inc and other necessary drupal files
[3] => calling drupal_bootstrap()
[4] => chdir(/var/www/drupal/sites/all/modules/pubdlcnt) to return to the original directory
[5] => getting parameters...
[6] => file [http://oz.local/sites/oz.local/files/Brosura 2008a.zip]
[7] => nid [210]
[8] => calling is_valid_file_url(http://oz.local/sites/oz.local/files/Brosura 2008a.zip)
[9] => URL is valid. Let's update the download counter for
[10] => OK, let's jump to the original file URL
[11] => calling header('Location: http://oz.local/sites/oz.local/files/Brosura 2008a.zip') )
Does this mean that your script isn't executed at all for some reason, and that the reason must be somewhere else? We're looking into possible POST and GET holes.
Comment #10
pixture commentedAs you said, it sounds like that the pubdlcnt.php script is not found for some reasons.
Please check the permission of the directory where the Public Download Count module is installed
/home/prkos/public_html/drupal/sites/all/modules/pubdlcnt
Also please check the permission of the file pubdlcnt.php script.
/home/prkos/public_html/drupal/sites/all/modules/pubdlcnt/pubdlcnt.php
Are the permissions 755 for both directory and file?
Next, please try the attached pubdlcnt-debug.php.txt instead of pubdlcnt.php just like you did it today. It seems that the function chdir() or getcwd() may have failed for some reasons.
I have added some additional debug code with this attached one. Please try it to see what you will get.
Thanks,
Comment #11
pixture commentedportulaca,
Please create a following script and save it as a file named phpinfo.php under /home/prkos/public_html/drupal/sites/all/modules/pubdlcnt directory, and then execute this script from the broweser and give me the result. (make sure to set the permission to 755 before executing).
This will shows the PHP environment information on your server which may help to troubleshoot the problem you are having now.
Thanks,
Comment #12
portulacaI already have phpinfo on http://prkos.hr/phpinfo.php this is my main account, and also you can see http://www.obiteljskizivot.com/phpinfo.php I think it's the same settings.
pubdlcount/ folder is 755
The script is 644
But I also tried making the script 755 and it wouldn't work, I then gave everything 777 (the whole pubdlcnt folder and files) but still I get Page not found. I tried this with your latest debug script.
Comment #13
pixture commentedAlthough I am not confident, I found the possible cause of this problem.
_SERVER["DOCUMENT_ROOT"] /home/prkos/public_html/obiteljskizivot.com
1) absolute path of the drupal root directory in the server
/home/prkos/public_html/drupal/
2) absolute path of the public download count installed directory
/home/prkos/public_html/drupal/sites/all/modules/pubdlcnt
If above is true, the PHP script file pubdlcnt.php is outside of the DOCUMENT_ROOT tree, and Drupal is also the outside of DOCUMENT_ROOT tree. I guess you put .htaccess in the DOCUMENT_ROOT directory for the URL
rewrite. This .htaccess could be a cause of the problem.
Other possibility is that your web server (Apache) uses CGI mode PHP and most probably, the CGI mode PHP is executed under SuExec. If so, the CGI script outside of the DOCUMENT_ROOT directory tree can not be executed unless it is specified in httpd.conf (or .htaccess file).
Please check your Apache server settings (httpd.conf and .htaccess files) to see if there's anything that prevents from pubdlcnt.php script being executed properly.
Comment #14
atiras commentedI have:
DOCUMENT_ROOT /home/tanjenja/public_html
Drupal is in /home/tanjenja/public_html/drupal
public download count installed directory is /home/tanjenja/public_html/drupal/sites/all/modules/pubdlcnt
My drupal installation is multi-site, and the files to be downloaded are in /home/tanjenja/public_html/drupal/sites/arkessian/files/novels.
so the script and the files are within the DOCUMENT_ROOT tree, and problem cause is either not this, or there is another problem too.
All the .htaccess files in my DOCUMENT_ROOT tree are the standard drupal ones - I have made no changes.
Comment #15
mario_prkos commentedsubscribe
Comment #16
portulacaIf I understood this correctly this has to do with the fact that the domain in question is an addon domain on my hosting account. The addon domains have subfolders in public_html, but in multisite drupal installation that "folder" is redirected to drupal/.
In my .htaccess I have RewriteBase set to /. If I set it to drupal the site doesn't work. What else can I try?
How do I allow script to be executed through .htaccess? I don't have access to httpd.conf on my host but I can make a request to hosts support.
I don't know much about CGI but I'll look into it.
We found AcceptPathInfo http://httpd.apache.org/docs/2.0/mod/core.html it kinda sounds like it might have something to do with it?
I think we're on the right path here, lolz
Comment #17
portulacaHere's what we found and think is significant; we have been testing access that the script has, we moved the script around different folders to see if it would be allowed to execute;
if we call the script alone without the query (http://prkos.hr/drupal/sites/all/modules/pubdlcnt/pubdlcnt.php) the script gets executed and I get this:
if I call it with the query http://prkos.hr/drupal/sites/all/modules/pubdlcnt/pubdlcnt.php?file=http... I get:
so this means that this script isn't allowed to get documents. What do you think? How to fix this?
Comment #18
pixture commentedThis could do nothing to do with this problem but is Clean URL enabled at your server?
(because the other issue http://drupal.org/node/515074 is the issue of Clean URL, I just want to make sure if clean URL does somethig to do with this issue or not).
Comment #19
portulacaYes I have Clean URLs but I also have them on my local installation, so it's probably not that
Comment #20
atiras commentedI also have clean URLS enabled.
Also, the problem exists whether pubdlcnt is in sites/all/modules or sites/arkessian.com/modules.
Comment #21
mario_prkos commentedConfiguration:
drupal with multisite configuration where sites are addon domains
htaccess file:
I find one way for override this problem. It seems that problem lies in rewrite engine in .htaccess file. If link with http://something used we immediately get page not found and script will not run. If link //something used (without http:) script will run but will not produce
correct results. So I delete http from links produced by module and left it without http then I again added http in pubdlcnt.php.
I also disabled header check and changing relative path to absolute path int pubdlcnt.php file because there were problems about that.
After all this actions I checked some links and they worked fine. I am still seek right explanation for this problem if some one has good
ideas please post it.
Also I attached files I changed in pubdlcnt module.
Mario
Comment #22
pixture commentedI compared .htacess with my server and found that I am not using the following line.
I guess this does something to do with this problem, although I am not sure exactly what does this do.
FYI,
Comment #23
mario_prkos commentedThis problem is not easy one because problem can lay almost anywhere and isolate it was very difficult.
In my opinion problem is in lines :
In those condition we can see rewriting of everything whati s not file or directory. So if request file is not recognize as directory
or file rewrite will be done, otherwise not. When I experimented with that feature I saw that this really affected usage of pubdlcnt.php
script. Then I made a script which only print $_GET['file'] and study behavior under different kind of queries.I put script in /drupal/sites/all/models/pubdlcnt/ folder with permissions 755. After some experimenting I relies if I use queries without http:/ (like script.php?file=something) script work fine but if I use something like script.php?file=http://... I get page not found. I guess in that case REQUEST_FILENAME not recognize as file or directory and rewrite engine rewrite request and link is not valid any more and we get page not found. I am not expert in apache server and rewrite engine is very complex so I am not sure if I am right about this conclusions but everything what I saw about this issue point in that direction.
I will appreciate any further informations and explanations about this quite difficult problem.
thx, Mario
Comment #24
eoneillPPH commentedTried the modified files in #21, but no joy.
Comment #25
mario_prkos commented@eoneillPPH can you be more specific about your problem
Comment #26
Golem07 commentedI am having the the same problem as well (page not found). Tried the new file from #10 but it didn't change anything. Would love to give additional info but since I am not very experienced I am not sure what info exactly is needed.
Comment #27
portulacaGolem07 have you tried the one from #21? This one works for me.
Comment #28
arrays commentedHi,
I have read this whole thread and i tried #21 solution (with the zipped files).
My problem is, it is giving me 500 internal server error and if i use http:// in my anchor tags, it gives me 403 access forbidden error.
I am not able to understand what is the issue. Please help.
Thanks
Comment #29
1sp commented@arrays can you tell me what gets in your apache's error log file when you get 500 internal server error ?
thanks
Comment #30
SilvioTO commentedThe module work well on my website except the "detail" and "restore" links in the report page; when clic a "page not found" error show up.
An error example code:
The page "/it/admin/reports/pubdlcnt/counter/Radio%20UFOcast%2039%20-%2023-12-2011%20%5BTempo%20di%20Semina%5D.torrent" not found.