HTTP_SERVER_VARS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
triplemaya
Forum Newbie
Posts: 5
Joined: Sat Dec 09, 2006 3:51 am

HTTP_SERVER_VARS

Post by triplemaya »

Hi. I need to change the php code which tells my new installation of oscommerce which directory the code is stored in. As far as I can tell, this is set by the line

define('DIR_FS_CATALOG', dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/');

I can find many references to the value of HTTP_SERVER_VARS['SCRIPT_FILENAME'], and other HTTP_SERVER_VARS values, but no trace of where it is set.

I have searched the tutorials for HTTP_SERVER_VARS but come up blank. I've posted on the oscommerce site, but no one is answering, so I thought I'd try here. In case it is not self evident, I am a total noobie to php and oscommerce, and databases of any kind come to that!

Help much appreciated.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

HTTP_SERVER_VARS is the old (and deprecated) form of $_SERVER. $_SERVER is a superglobal and should be the one used, however if OSCommerce is altering the contents, it may be good to track that down first before you get a nasty surprise later on. ;)
triplemaya
Forum Newbie
Posts: 5
Joined: Sat Dec 09, 2006 3:51 am

Post by triplemaya »

Hi. Thanks for replying. The problem is that the original installation has all of the code files thrown into the top level directory, which is where I want to put the guts of the site, and I don't want the whole thing clutttered up with dozens of files, and the potential for name conflicts. What I am trying to do is to get the installation to look in the catalog directory, where the code usually goes, instead of the top level directory. What I need to know is how to set the variable. Cheers.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I could guess adding "catalog/" immediately after the "/" in that line should alter the location.
triplemaya
Forum Newbie
Posts: 5
Joined: Sat Dec 09, 2006 3:51 am

Post by triplemaya »

Yup, thanks spidermoddy, that certainly ought to do it. The big question is, where is the file where it is set? I guess this really is an oscommerce question, or at least a webserver question. I've grep'd every file in the installation, and I can't find where the variable is set. Loads of files read it, which of course means that the file where it is set doesn't stand out!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

SCRIPT_FILENAME is set by PHP prior to the script being run. It is the full system level path to the script that is being run. It is one of several ways to find out where the root directory for an installation is quite often.
triplemaya
Forum Newbie
Posts: 5
Joined: Sat Dec 09, 2006 3:51 am

Post by triplemaya »

Thanks again, and sorry if I am being dense, but where would I find the code which actually sets it? Or how would I find out where the file is where it is set?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

feyd wrote:SCRIPT_FILENAME is set by PHP prior to the script being run. It is the full system level path to the script that is being run. It is one of several ways to find out where the root directory for an installation is quite often.
In other words, it is automatically set for you. It is a server environment variable. Although if it is being overwritten, I'd use dreamweaver to scan all source files within a directory for $_SERVER['SCRIPT_FILENAME'] =
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's set before any PHP code executes. Unless you want to dig into the source code behind PHP's own core engine there's no place you can look for it being set.

$_SERVER['SCRIPT_FILENAME'] is the full system path to the file that is being requested by the user-agent (browser.)

var_export($_SERVER) to see what it is.
triplemaya
Forum Newbie
Posts: 5
Joined: Sat Dec 09, 2006 3:51 am

Post by triplemaya »

Well then, I guess, given my level of expertise I'll just have to live with what I've got! Many thanks for your time.
Post Reply