|  | |  |
04-09-2005, 10:18 AM
|
#1 (permalink)
| | Registered User
Join Date: Apr 2005
Posts: 2
| How to get the name of parent page ? hi,
Newbie here.
I'd like to have php return the name of the page that is loaded, e.g.,
in a parent document, 'example.php' I do a <include("body.inc";> and then I'd like to put some code in 'body.inc' that can fetch the name of the parent, in this case, 'example.php'
Appreciate your help.
robert |
| |
04-09-2005, 10:35 AM
|
#2 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
| use variable: $_SERVER['PHP_SELF']
you should really name all of your includes with a .php extention. since most web servers are not setup to parse .inc files in php, then someone could view your source code in case you are using php code in your .inc file.
if you must name it with a .inc, then name it body.inc.php. it is good practice and more secure.
__________________ Mike |
| |
04-09-2005, 10:59 AM
|
#3 (permalink)
| | Registered User
Join Date: Apr 2005
Posts: 2
| thanks thanks a lot,
it works great
robert |
| |
04-09-2005, 12:48 PM
|
#4 (permalink)
| | Jack of all trades
Join Date: Feb 2005 Location: Los Angeles
Posts: 598
| Lot's of servers support .phps, though. There's also a .htaccess directive you can use on apache based servers. |
| |
04-09-2005, 01:42 PM
|
#5 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
| still very bad practice IMO. there is absolutely no good reason why you should name files like that in the first place.
__________________ Mike |
| |
04-09-2005, 01:55 PM
|
#6 (permalink)
| | Senior Contributor
Join Date: Mar 2005
Posts: 745
| a) prevent execution by using .inc extension (just shows source)
b) they must be loaded thru another php file
Showing the source of a .inc file is nothing bad.
If it's OS code i don't care a thing actualy.
If you have a bug in your OS file and it's .php instead of .inc then people can try to hack in (especialy when register_globals is on)
So i use .inc and untill my script becomes commercial i change. |
| |
04-09-2005, 05:25 PM
|
#7 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
| what do you mean by "OS code" ? Quote: |
So i use .inc and untill my script becomes commercial i change.
| sounds like just an extra piece of work to me. when you eventually change the file name, won't you have to test for the "hacking" you are using .inc files for in the first place?
b) you mean primarily for database security? if your connect script is not in the file you're concerned about, then they probably can't do much to your db by calling it by itself. on the other hand, a .inc file would give someone a good idea of what your db structure looks like if you're working with a db.
to each his own. however, considering this guy is "NEW" to php, you gotta agree it is definately not a good habbit for a newbie. there are books out there that tell you to make a db connection include named "connect.inc" .. really nice way to expose your db login info to the world.
__________________ Mike |
| |
04-09-2005, 08:49 PM
|
#8 (permalink)
| | Newbie
Join Date: Jun 2002 Location: Denmark
Posts: 1,726
| when using .inc anybody can view your source. if they encounter an error saying:
Error found in /web_space_user/include/my_php.inc they can try to fetch it directly,m viewing it as clear text, giving them a view in to your coding habit. If you like to use md5sum() or what ever...
It is very unsecure to call your include files .inc. or anything else that isn't executed by teh web server. |
| |
04-09-2005, 08:51 PM
|
#9 (permalink)
| | Newbie
Join Date: Jun 2002 Location: Denmark
Posts: 1,726
| ****, i'm drunk now, but I still stand by my expression in the earlier post. |
| |
04-09-2005, 08:57 PM
|
#10 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
| Quote: |
Originally Posted by redhead ****, i'm drunk now, but I still stand by my expression in the earlier post. |  have one for me 2, cheers
__________________ Mike |
| |
04-10-2005, 08:35 AM
|
#11 (permalink)
| | Senior Contributor
Join Date: Mar 2005
Posts: 745
| Agreed that newbies should use .php as extension epecialy when it comes to sensitive information.
OS = OpenSource
OSS = OpenSource Software |
| |
04-10-2005, 09:56 AM
|
#12 (permalink)
| | Jack of all trades
Join Date: Feb 2005 Location: Los Angeles
Posts: 598
| I feel like a different extension is clarifying as to the purpose of the file, but you should not use a different extension if the server isn't set up to process it as php.
here is the apache code to execute .inc as php files Code: <IfModule mod_mime.c>
AddType application/x-httpd-php .inc
</IfModule> Alternatively apache also recognizes application/x-httpd-php-source . |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -8. The time now is 11:02 PM. |
Copyright © 2000-2008, Milano Interactive Web Hosting provided by Portal 360 Web Hosting |  | |