Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Potential issue with DIR_FS_DOCUMENT_ROOT config setup


surfalot

Recommended Posts

I was looking at using DIR_FS_DOCUMENT_ROOT in a contrib and notice a little discrepancy in the configure.php for the admin. In the default freshly unpacked configure.php on the admin side, the example for this constant does not have a trailing slash. After running the install, the constant does have a trailing slash. I was wondering which is right?

 

In the file: \admin\manufacturers.php

Line 77: $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image'];

 

This tells me that there should not be a trailing slash in DIR_FS_DOCUMENT_ROOT since the setup for DIR_WS_CATALOG_IMAGES includes a slash at the beginning as shown below. Obviously Line 77 of \admin\manufacturers.php should not get the correct path if the installer add a slash to the end of DIR_FS_DOCUMENT_ROOT.

 

define('DIR_WS_CATALOG', '/');

define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . 'images/');

 

Can I get some clarification as to which is officially correct for DIR_FS_DOCUMENT_ROOT? Slash at the end or not?

Link to comment
Share on other sites

This setting (below):

define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT);

is part of the uninstalled configure.php files. Once the install has been completed it should show the actual folder pathway to the root of your web e.g.

define('DIR_FS_DOCUMENT_ROOT', '/var/www/html/);

and in this case it does have a trailing slash.

 

If you have the unmodified file then it means that your install did not write to the configure.php file.

 

Vger

Link to comment
Share on other sites

This setting (below):

define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT);

is part of the uninstalled configure.php files. Once the install has been completed it should show the actual folder pathway to the root of your web e.g.

define('DIR_FS_DOCUMENT_ROOT', '/var/www/html/);

and in this case it does have a trailing slash.

 

If you have the unmodified file then it means that your install did not write to the configure.php file.

 

Vger

 

Yup, understand that. Please note what I said initially. after you run the install, there is a trailing slash in this constant. with trailing slash in this constant line 77 of \admin\manufacturers.php will produce a path with a double slash in it. I don't need help fixing anything. I don't even know it anything is broken. I want to start some dialog that will produce an answer to which it OFFICIALLY correct. with a trailing slash or not. The configure.php (uninstalled, fresh from a unpack) has an example that shows no trailing slash. Infact the suggestion by Matti is the default configuration before an install is performed. This constant using $DOCUMENT_ROOT will also produce a constant that has no trailing slash. so is the install correct and thus the file \admin\manufacturers.php is using these wrong or is the example in the uninstalled configure.php correct and the file \admin\manufacturers.php is correct. I don't know. I was hoping this would have been s "oh yeah, yadda yadda is wrong, this is the official configuration for DIR_FS_DOCUMENT_ROOT is...

Link to comment
Share on other sites

Just think about the way the FS paths are built or sketch it out on a piece of paper.

 

So a

 

define('DIR_FS_CATALOG', '/var/www/html/catalog/);

 

Tells the server to start looking at

 

/var/www/html/catalog/ then add (from the WS defines) includes/

 

so, for example, includes are found at:

 

/var/www/html/catalog/includes/

 

Rinse and repeat for all the other paths and you'll see the final slash needs to be there in the doc root definition.

 

(I'm actually looking at the catalog folder where only the define('DIR_FS_CATALOG' exists, but the rule is the same)

Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux

Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)

Link to comment
Share on other sites

yup, no problem there. I really don't have any problem figuring out what works. I'm still kinda just looking for an official word as to whether the preinstall configure.php is correct or the post install configure.php is correct. only one of them can be what was intended by the coders. once that is determined then line 77 of \admin\manufacturers.php can be determine correct or not and it's usage in the file manager.

Link to comment
Share on other sites

First, thanks to all that responded. But I'm not sure anyone has actually confirmed there is a problem. My path-math says there is. I think this is a bug report issue. Maybe that's where I should have started.

 

I guess at least one thing came from this... and that's that DIR_FS_DOCUMENT_ROOT in the admin configure.php should never be used in a contrib since the official release of osC shows the example one way and the installer installs it another. And the usage in line 77 of \admin\manufacturers.php indicates the installer is wrong. So any contrib that uses it would probably have support issues galore!

 

It sure would have been nice to have someone look into and actually confirm or dispute the actual issue I initially posted. (again, not trying to get help, just trying to discuss and issue)

 

BTW AlanR, your example is right on the mark, but not the constant I'm discussing.

Link to comment
Share on other sites

I hope you didn't lose too much sleep over it. It's only used in three files.

 

admin/includes/configure.php itself (3 times)

admin/file_manager.php

admin/manufacturers.php (once)

 

In all important cases it's concatenated with a string containing a leading / (DIR_WS_CATALOG)

 

/catalog/admin/file_manager.php:16: $current_path = DIR_FS_DOCUMENT_ROOT;

/catalog/admin/file_manager.php:25: if (strstr($current_path, '..')) $current_path = DIR_FS_DOCUMENT_ROOT;

/catalog/admin/file_manager.php:27: if (!is_dir($current_path)) $current_path = DIR_FS_DOCUMENT_ROOT;

/catalog/admin/file_manager.php:29: if (!ereg('^' . DIR_FS_DOCUMENT_ROOT, $current_path)) $current_path = DIR_FS_DOCUMENT_ROOT;

/catalog/admin/file_manager.php:29: if (!ereg('^' . DIR_FS_DOCUMENT_ROOT, $current_path)) $current_path = DIR_FS_DOCUMENT_ROOT;

/catalog/admin/file_manager.php:96: $in_directory = substr(substr(DIR_FS_DOCUMENT_ROOT, strrpos(DIR_FS_DOCUMENT_ROOT, '/')), 1);

/catalog/admin/file_manager.php:96: $in_directory = substr(substr(DIR_FS_DOCUMENT_ROOT, strrpos(DIR_FS_DOCUMENT_ROOT, '/')), 1);

/catalog/admin/file_manager.php:98: $document_root_array = explode('/', DIR_FS_DOCUMENT_ROOT);

/catalog/admin/file_manager.php:99: $goto_array = array(array('id' => DIR_FS_DOCUMENT_ROOT, 'text' => $in_directory));

/catalog/admin/file_manager.php:180: if ( ($file != '.') && ($file != 'CVS') && ( ($file != '..') || ($current_path != DIR_FS_DOCUMENT_ROOT) ) ) {

/catalog/admin/includes/configure.php:21: define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT); // where your pages are located on the server. if $DOCUMENT_ROOT doesnt suit you, replace with your local path. (eg, /usr/local/apache/htdocs)

/catalog/admin/includes/configure.php:23: define('DIR_FS_ADMIN', DIR_FS_DOCUMENT_ROOT . DIR_WS_ADMIN);

/catalog/admin/includes/configure.php:25: define('DIR_FS_CATALOG', DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG);

/catalog/admin/manufacturers.php:77: $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image'];

Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux

Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)

Link to comment
Share on other sites

So the osC installer is erroneously adding a trailing slash to DIR_FS_DOCUMENT_ROOT.

 

Not point in being neurotic over it. I just wanted to make sure that I wasn't the only one that could see it. :rolleyes: I was really beginning to wonder.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...