homepage Welcome to WebmasterWorld Guest from 54.166.173.147
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Building Locally - How to Make Path Changes Easier
When uploading to the remote server...
Nick_W




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

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

 

dingman




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

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.

Nick_W




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

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

jarboy




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

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.

Nick_W




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

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

CoryZ




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

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

transistor




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved