php includes error
page: http://24.91.157.113/findyourdesire/phpTest/faq.php
errors:
Warning: Failed opening '/home/joshua/includes/fyd.incs.inc' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/findyourdesire/phpTest/faq.php on line 2
Fatal error: Call to undefined function: bgnpg() in /var/www/html/findyourdesire/phpTest/faq.php on line 17
the second one is the result of the first one.
the first one i don't get. i gave the include command the FULL path name. so what do i need to edit in php.ini to get it working right?
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
necrotic posted this at 21:32 — 30th July 2003.
He has: 296 posts
Joined: May 2002
Are you 100% sure the path is correct? why don't just just put fyd.incs.inc in /var/www/html/findyourdesire/phpTest?
Mark Hensler posted this at 21:34 — 30th July 2003.
He has: 4,048 posts
Joined: Aug 2000
Are you absolutely sure that is the correct path?
You're request_uri is in /var/www/html, but you're trying to pull an include from /home/joshua.
If the paths are correct, then check permissions. Make sure the user that the web server is running as has read access to the fyd.inc.inc file, and permission to the directory it's in.
Mark Hensler
If there is no answer on Google, then there is no question.
m3rajk posted this at 22:31 — 30th July 2003.
They have: 461 posts
Joined: Jul 2003
the file has one include. all the files for the site have one include file. the include directory is outside of the web tree for security. the main include file is actually a list of include files, including the one with all the database passwords in it, which will be changed from 444 to 400 once i have everything running and know i wont need to change it. i also plan on chowning and chgrping it to apache (user the webserver runs as).
i figure at that point if anyone can crack into the db by using that file i have much bigger problems than stupidity in my code. and if i'm allowed to do that when i find a real host for it, it helps security there... well helps me know the site's more secure.
right now all the files in the include directory are 644 so that i may modify them, and apache may read them
the include direcotry itself is 775
my home directory is probably the issue. if that's not the case i'll let you know
nope. i set my home directory to 744 and /home is actually 775
so....
/home/joshua/includes/fyd.incs.inc
has permissions
/775/744/775/644
the files it includes are also 644
overview for those unfamilliar with chmod and numerical permissions:
4=read
5=read/execute
6=read/write
7=read/write/execute
which means that the everyone can read the directory and files (for now)
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Mark Hensler posted this at 01:57 — 31st July 2003.
He has: 4,048 posts
Joined: Aug 2000
First off, to you not want to chown/chgrp any files to the apache user. You will have a heck of a time editing (or even removing) them down the line.
As for moving files outside DOCUMENT_ROOT... I do this too, but I wouldn't say it's more secure. Having file extensions of .inc is what causes the security problem while within DOCUMENT_ROOT. Had you used .php file extensions, the contents would never be shown to the user.
Directory permissions are a tad different than file permissions. If I remember correctly, +RX is necessary to list the contents of a directory. +R may suffice for accessing a known file within the directory, but I'm not certain. You may want to try setting you're /home/joshua to 755.
Mark Hensler
If there is no answer on Google, then there is no question.
m3rajk posted this at 03:19 — 31st July 2003.
They have: 461 posts
Joined: Jul 2003
i'm also root on this particular server, so while it's here i dont have to worry about future access
however, if you could explain to me why a .php file would never be shown to a user yet a .inc file could be, i'd love to hear it, since the very reason i have for doing that is to make it so people cannot see the contents of the file with the db pws as well as two otoher things i haven't finished masking all of it yet
btw: you were right. needed to be 755 instead of 744
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Mark Hensler posted this at 04:22 — 31st July 2003.
He has: 4,048 posts
Joined: Aug 2000
I'm speaking from experience with Apache, though I would assume most other web servers would be configured the same.
.php extensions are associated with the "application/x-httpd-php" mime type.
.inc extensions are usually not associated with any mime type, so fall under the default mime type of "text/plain".
"application/x-httpd-php" mime types are first parsed by the PHP interpreter, and only the output from the interpreter is sent to the requesting host.
"text/plain" mime types are not passed through any interpreters, and so, are sent to the requesting host in their entirety.
Mark Hensler
If there is no answer on Google, then there is no question.
Suzanne posted this at 04:34 — 31st July 2003.
She has: 5,507 posts
Joined: Feb 2000
There is a suggestion from Kevin Yank (and probably many other more knowledgeable than I PHP programmers) to put .inc files in non-public directories so they cannot be viewed.
Specifically he says:
m3rajk posted this at 16:09 — 31st July 2003.
They have: 461 posts
Joined: Jul 2003
so since this is out of the web directory the include file wont be seen.. right?
Suzanne posted this at 17:26 — 31st July 2003.
She has: 5,507 posts
Joined: Feb 2000
Hypothetically, yes. Test!
Mark Hensler posted this at 17:52 — 31st July 2003.
He has: 4,048 posts
Joined: Aug 2000
Being outside of DOCUMENT_ROOT simply means that you cannot point your browser to that file directly. Which is not a problem for files with a .php extensions on a properly configured web server.
Think of all those those scripts on HotScripts.com with their config files within DOCUMENT_ROOT. Heck, even vBulletin. How many of them have you copy files outside of DOCUMENT_ROOT?
Like I said earlier, I do this as well. But I do this for convenience, not security. For one of my current projects, several sub-domains require the same library files, includes, and config files. Instead of keeping X copies (one for each sub-domain), I have one copy outside DOCUMENT_ROOT and use .htaccess to include the directory in PHP's include_path.
Mark Hensler
If there is no answer on Google, then there is no question.
m3rajk posted this at 19:27 — 31st July 2003.
They have: 461 posts
Joined: Jul 2003
suzanne: the only browser i can get to open it are mozille, galeon and konqueror .... but only when i'm caling them FROM that computer using the internal address
mark: so theoretically, if i have it as a .php i can have it IN the webtree and unless i'm at the computer pulling it up in an editor i wont see the code? and will it act like a .inc file where the functions are responded to as if i wrote them in that file? or is the behavior different?
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Mark Hensler posted this at 23:52 — 31st July 2003.
He has: 4,048 posts
Joined: Aug 2000
.inc files are not magical. Files being included into a PHP file can have any extension, or no extension at all. What causes the contents of the included file to be parsed as PHP, are the PHP tags (
<?php
?>
Yes. If you have include files with a .php extension within the webtree, you will see no php source code when viewing them directly from a browser.
Mark Hensler
If there is no answer on Google, then there is no question.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.