make your Zen-Cart 1.5.0+ configuration.php files flexible

September 28, 2012

On you backup or testing server, for development, (not your live, commercial, site!!) you can create a fake SSL certificate (for free, of course!) officially called a “Self Signed Certificate” and operate with SSL turned on everywhere.

Regardless! In your zen-cart configuration files,
do not hard-code any settings that might be different on your backup or testing server or that you might want to change.

includes/configuration.php

In your store/includes/configuration.php file,

@date_default_timezone_set(date_default_timezone_get() );
#
// Define the webserver and path parameters
// HTTP_SERVER is your Main webserver: eg-http://www.your_domain.com
// HTTPS_SERVER is your Secure webserver: eg-https://www.your_domain.com
# ************************************************************
define( 'HTTP_SERVER', 'http://'.$_SERVER["HTTP_HOST"] );
define('HTTPS_SERVER', 'https://'.$_SERVER["HTTP_HOST"] );
# ************************************************************

. . .

// * DIR_WS_* = Webserver directories (virtual/URL)
// these paths are relative to top of your webspace ...
// (ie: under the public_html or httpdocs folder)
#
# define('DIR_WS_CATALOG', '/store/');
# define('DIR_WS_HTTPS_CATALOG', '/store/');
define('DIR_WS_CATALOG', str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname(dirname(__file__)).'/' ) );
define('DIR_WS_HTTPS_CATALOG', str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname(dirname(__file__)).'/' ) );
# ************************************************************

. . .

// * DIR_FS_* = Filesystem directories (local/physical)
// the following path is a COMPLETE path to your Zen Cart files.
// eg: /var/www/html/store/
# *************************************************************
define('DIR_FS_CATALOG', dirname(dirname(__file__)).'/' );
# *************************************************************

 

admin configuration.php

In your store/admin.xxxxx/includes/configuration.php file:


@date_default_timezone_set(date_default_timezone_get() );
#
/**
* WE RECOMMEND THAT YOU USE SSL PROTECTION FOR YOUR ENTIRE ADMIN:
* To do that, make sure you use a "https:" URL for all 4 of the following,
* including the HTTP_ entries:
*/
# ************************************************************
define( 'HTTP_SERVER', 'https://'.$_SERVER["HTTP_HOST"] ); # to set payment modules
define('HTTPS_SERVER', 'https://'.$_SERVER["HTTP_HOST"] );
define( 'HTTP_CATALOG_SERVER', 'http://'.$_SERVER["HTTP_HOST"] );
define('HTTPS_CATALOG_SERVER', 'https://'.$_SERVER["HTTP_HOST"] );
# ************************************************************
// secure webserver for admin? Valid choices are 'true' or 'false' (including quotes).
define('ENABLE_SSL_CATALOG', 'true');
define('ENABLE_SSL_ADMIN', 'true');
#
// NOTE: be sure to leave the trailing '/' at the end of these lines!
// * DIR_WS_* = Webserver directories (virtual/URL)
// these paths are relative to top of your webspace ...
// (ie: under the public_html or httpdocs folder)
# define('DIR_WS_ADMIN', '/website/store/admin*whatever/');
# define('DIR_WS_CATALOG', '/store/');
# ***************************************************************
define('DIR_WS_ADMIN', dirname($_SERVER['SCRIPT_NAME']).'/');
define('DIR_WS_CATALOG',
str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname(dirname(dirname(__file__))).'/' ) );
# ***************************************************************

Leave a Reply

We try to post all comments within 1 business day