Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

"File is in wrong directory"

Quote Reply
"File is in wrong directory"
I've been successfully running Links SQL in cgi mode for a while now, with no difficulties. I want to start running it in PHP mode, however, and I'm getting some strange errors. Basically, it's claiming that several of the include files are in the wrong directory. As far as I can tell, though, they're all exactly where they're supposed to be:

........../admin/Links/PHP/Authenticate.inc.php
........../admin/Links/PHP/Links.inc.php
........../admin/templates/default_php/home.html

It's still running fine in cgi mode, so it's not like the admin path changed or anything. Does this sound familiar to anyone?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] "File is in wrong directory" In reply to
All those dots don't look too correct. Are you sure you have your admin_root_path setup correctly?

Adrian
Quote Reply
Re: [brewt] "File is in wrong directory" In reply to
Sorry - that was just me trying to be succinct. The full path is there. Besides, wouldn't the admin path have to be correct, or else the cgi script wouldn't function properly, would it?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [brewt] "File is in wrong directory" In reply to
Okay - I was being lazy before. I just reread the full error message, and I think I misrepresented it slightly.

Here's what I'm getting:

Warning: open_basedir restriction in effect. File is in wrong directory in PATH/TO/admin/Links/PHP/Links.inc.php on line 433

Warning: open_basedir restriction in effect. File is in wrong directory in /PATH/TO/admin/Links/PHP/Links.inc.php on line 336

Warning: open_basedir restriction in effect. File is in wrong directory in /PATH/TO/admin/templates/default_php/home.html on line 20

Warning: open_basedir restriction in effect. File is in wrong directory in /PATH/TO/admin/Links/PHP/Links.inc.php on line 237

More or less a bunch of those all over the place, with some actual information scattered in between the error messages.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] "File is in wrong directory" In reply to
Hi,

This is a problem with your php config. See:

http://www.php.net/...atures.safe-mode.php

You have safe_mode turned on, with an open_basedir set to a directory that does not include your Links SQL admin area.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "File is in wrong directory" In reply to
Thanks for the tip. I'm on a virtual host, so there's not much I can do to change those settings. Any thoughts on why the links admin area would be outside of the open_basedir area set by the webhost? I routinely use PHP to include and require files from various different places on the server, and I've never encountered this error before. The only thing I can think of is that maybe PHP has been configured to not allow includes of files that are in .htaccess password protected directories (which the links admin area is, of course). Either that or the fact that it's in a cgi-bin?? I've sent an email to the hosting company - maybe they'll have an answer.

Would it be a fool's crusade to attempt moving those files to a directory that I know works for PHP includes? I haven't looked too closely at the script files, but from my experience with other GT scripts, I'm hesitant to try moving around directories, since I know there are lots of files that are all dependent on each other, and their locations are typically determined by a single $admin_path variable...

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] "File is in wrong directory" In reply to
Hmm, one thing to test is to create a file test.php with:

<?phpinfo()?>

in it and see what it displays for 'open_basedir'. Can you confirm that it doesn't include your Links SQL admin area?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "File is in wrong directory" In reply to
Cool function! And I can in fact confirm that the open_basedir settings definitely SHOULD be permitting that links admin area. In fact, they appear to allow everything in my entire user directory. Very odd. Any other thoughts?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] "File is in wrong directory" In reply to
Hmm, this is strange. So your saying that what you see in the warning, matches exactly for what you see in phpinfo()? i.e.:

warning: /PATH/TO/admin/Links/PHP/Links.inc.php

phpinfo: /PATH/TO/

That's one for your host I think.

On a side note, are you sure it's the cgi scripts causing the mysql connection errors? Do a `mysqladmin proc` or from your control panel: `show processlist` to see a list of running processes.

If you are on a shared server, it could well be another site using all the available mysql connections and have nothing to do with your site.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "File is in wrong directory" In reply to
Yeah. One of several prefixes specified in open_basedir is:

/home/USERFOLDER

In the "USERFOLDER" directory (not really named "USERFOLDER" of course) is the public_html directory that houses my entire site. So any file I can upload, I should be able to include. I guess I'll see what my host has to say.

As for the mysql connection issues... I haven't actually gotten any errors. But my hosting package permits a certain number of connections/queries each month. (Actually, they permit 25 million "conueries" - where each query equals 1 "conuery" and each connection equals 25 "conueries".) I recently received a warning notice that I'm on track to exceed my limit this month. Since I've started running a mod_rewrite enhanced Links SQL in dynamic mode with data from a top-level DMOZ category, I've gotten a ludicrous amount of traffic from the major search engines. Which is great, of course, except for that warning about too many mysql connections... I'd build static pages, but unfortunately I don't have 6GB of space to house the 300,000 that would have to be built.

Anyway - thanks for all your help. If my host has anything useful to say, I'll be sure to post it here.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [Alex] "File is in wrong directory" In reply to
If anyone stumbles across this post or is having similar problems in the future, I finally figured out a solution to the issue, though I'm not sure how universal it might be.

This from the PHP guru at my hosting company:

"PHP is sometimes completely idiotic. It sometimes throws open_basedir errors (ahem) erroneously. Bugs have been filed, nothing comes of it. I do not have the highest opinion of PHP."

So there you have it. Nothing he was able to do, really.

HOWEVER... The server I'm on happens also to provide the option of running PHP scripts as CGI's. I don't know how common of a feature that is, or if there is any kind of standard implementation. But in my case it was as simple as adding a .htaccess file to my links cgi-bin directory with the line:

AddType php-cgi .php

This basically tells Apache to run all php scripts in that directory (of which there is only one - page.php) as cgi's, outside of Apache. The open_basedir settings which were causing such headaches are no longer needed, since the script has my user permissions, not Apache's permissions.

Anyway, so far so good - this appears to have solved the problem completely.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] "File is in wrong directory" In reply to
Heh, although if you run it as a CGI script, then you aren't using persistent connections and back to square 1. =)

It could be a symlink issue, perhaps your home directory is symlinked (i.e. it's really /usr/home/domain, not /home/domain as /home is a symlink to /usr/home). Not sure what else, but those errors are definitely php not able to access a file it needs.

You could also try installing Links SQL completely within the document root, may be something with being in cgi-bin.

I really can't understand ISP's who enable this "feature" which is generally a hinderance rather then any sort of real security.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "File is in wrong directory" In reply to
Ugh. That hadn't occurred to me, but it makes perfect sense. So the reason PHP and mod_perl can do persistent connections but cgi applications can't is that the former are run as Apache and the latter are run outside of Apache? I know that's not the most technical explanation, but is that the ballpark idea?

Re: symlink - I don't think it's a symlink issue. I've got enough experience successfully including and requiring files from all over the place that I think I would have encountered it before.

Re: cgi-bin - That's about the only idea that makes sense to me at this point, albeit without any real understanding of why that might be a problem.

Surely you know a lot more about security and server configurations, but it seems like a perfectly reasonable "feature" to me (although it would certainly be better if it worked properly). I mean, the intent behind open_basedir restrictions is that I shouldn't be able to write a script that accesses files owned by any other user on the same server. But maybe I'm missing something - you think it's a less-than-ideal way of accomplishing those security requirements?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] "File is in wrong directory" In reply to
In Reply To:
This from the PHP guru at my hosting company:

"PHP is sometimes completely idiotic. It sometimes throws open_basedir errors (ahem) erroneously. Bugs have been filed, nothing comes of it. I do not have the highest opinion of PHP."
That's a pretty sketchy excuse, er, explanation... I've yet to see or hear of any such problems myself, which would imply an improperly configured server on the part of your hosting company.

Dan