Welcome to WebmasterWorld Guest from 54.205.75.60

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Building Locally - How to Make Path Changes Easier

When uploading to the remote server...

   
6:43 pm on Jan 25, 2003 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi all,

If I build a site on my home machine, it means changing:

[pre]
require("/var/www/site.com/includes/setup.inc");[/pre]

on every page when it comes to uploading to the ISP.

I thought maybe I could inlude a file from the http root that just used ini_set('include_path', 'path/to/includes'); and then I'd only have one file to edit before uploading.

I can't spot any security issues but, am wary of putting such stuff in the public_html/ without first checking to see what you guys think ;)

Thoughts?

Nick

6:55 pm on Jan 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I usually try to do things like that by using relative paths in the require statements, though there are situations where that doesn't work. (In the case of nested require()s, for example) It's nice and straigforward when it works at all, though. Zero edits :)

Your ini_set() approach looks OK to me at first glance, though I would probably feel more comfortable with the idea if the directory it was set to were outside of the web space.

6:58 pm on Jan 25, 2003 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thats the trouble dingman, it can't be set outside or I have the same issue. The host has a setup where the public_html/ is a link? to another place and using relative urls don't work and an absolute is of course waaay different from my home set up.

Cheers

Nick

7:06 pm on Jan 25, 2003 (gmt 0)

10+ Year Member



If your include file is parsed by php it's a safe as any other file on your server

You have to be sure that files ending in .inc are parsed. Why not call your file something.php - that way you know it'll be parsed.

You could try using a file called setup.php with all of the data in it that relates to where files are etc. and including it at the top of every page where you need it. Then when you upload to server you only need to change that 1 file.

7:09 pm on Jan 25, 2003 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You could try using a file called setup.php with all of the data in it that relates to where files are etc. and including it at the top of every page where you need it. Then when you upload to server you only need to change that 1 file.

Yes, that's exactly what I do. In this case though, I would have to change the include call to that file on every page when I upload.

Setting the include_path in something.php sorts that out.

Thanks all....

Nick

1:44 am on Jan 29, 2003 (gmt 0)

10+ Year Member



For my scripts, I check the hostname of the machine that I am on and then a simple if/case statement allows me to select the correct paths.

Pseudo Code:
Check Hostname
Case
dev_machine: use path_1
test_machine: use path_2
default: use path3
End Case

5:07 am on Jan 29, 2003 (gmt 0)

10+ Year Member



Hey Nick,

What I do is setup php.ini on:
server 1:

include_path="/path/to/include";
and on
server 2:
include_path="/other/path/to/include";

Then a file that contains:

include ("site/file.php");

will always get the includes right, that is assuming that the directory and file structure underneath are kept the same on both servers.

Hope this helps.