PageRenderTime 3ms CodeModel.GetById 66ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/config/config.inc.php

https://bitbucket.org/marcenuc/prestashop
PHP | 181 lines | 109 code | 25 blank | 47 comment | 30 complexity | ce4987217c4344b33abb3315ee3ef801 MD5 | raw file
  1<?php
  2/*
  3* 2007-2012 PrestaShop
  4*
  5* NOTICE OF LICENSE
  6*
  7* This source file is subject to the Open Software License (OSL 3.0)
  8* that is bundled with this package in the file LICENSE.txt.
  9* It is also available through the world-wide-web at this URL:
 10* http://opensource.org/licenses/osl-3.0.php
 11* If you did not receive a copy of the license and are unable to
 12* obtain it through the world-wide-web, please send an email
 13* to license@prestashop.com so we can send you a copy immediately.
 14*
 15* DISCLAIMER
 16*
 17* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 18* versions in the future. If you wish to customize PrestaShop for your
 19* needs please refer to http://www.prestashop.com for more information.
 20*
 21*  @author PrestaShop SA <contact@prestashop.com>
 22*  @copyright  2007-2012 PrestaShop SA
 23*  @version  Release: $Revision: 7331 $
 24*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25*  International Registered Trademark & Property of PrestaShop SA
 26*/
 27
 28require_once(dirname(__FILE__).'/defines.inc.php');
 29$start_time = microtime(true);
 30
 31/* SSL configuration */
 32define('_PS_SSL_PORT_', 443);
 33
 34/* Improve PHP configuration to prevent issues */
 35ini_set('upload_max_filesize', '100M');
 36ini_set('default_charset', 'utf-8');
 37ini_set('magic_quotes_runtime', 0);
 38
 39/* correct Apache charset (except if it's too late */
 40if (!headers_sent())
 41	header('Content-Type: text/html; charset=utf-8');
 42
 43/* No settings file? goto installer... */
 44if (!file_exists(dirname(__FILE__).'/settings.inc.php'))
 45{
 46	$dir = ((substr($_SERVER['REQUEST_URI'], -1) == '/' || is_dir($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : dirname($_SERVER['REQUEST_URI']).'/');
 47	if (!file_exists(dirname(__FILE__).'/../install'))
 48		die('Error: "install" directory is missing');
 49	header('Location: install/');
 50	exit;
 51}
 52
 53require_once(dirname(__FILE__).'/settings.inc.php');
 54
 55require_once(dirname(__FILE__).'/autoload.php');
 56
 57if (_PS_DEBUG_PROFILING_)
 58{
 59	include_once(_PS_TOOL_DIR_.'profiling/Controller.php');
 60	include_once(_PS_TOOL_DIR_.'profiling/ObjectModel.php');
 61	include_once(_PS_TOOL_DIR_.'profiling/Hook.php');
 62	include_once(_PS_TOOL_DIR_.'profiling/Db.php');
 63}
 64
 65/* Redefine REQUEST_URI if empty (on some webservers...) */
 66if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
 67{
 68	if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME']))
 69		$_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
 70	if (isset($_SERVER['SCRIPT_NAME']))
 71	{
 72		if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING']))
 73			$_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
 74		else
 75		{
 76			$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
 77			if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
 78				$_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
 79		}
 80	}
 81}
 82
 83/* Trying to redefine HTTP_HOST if empty (on some webservers...) */
 84if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
 85	$_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
 86
 87/* Initialize the current Shop */
 88Context::getContext()->shop = Shop::initialize();
 89define('_THEME_NAME_', Context::getContext()->shop->getTheme());
 90define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
 91
 92/* Include all defines related to base uri and theme name */
 93require_once(dirname(__FILE__).'/defines_uri.inc.php');
 94
 95global $_MODULES;
 96$_MODULES = array();
 97
 98/* Load configuration */
 99Configuration::loadConfiguration();
100
101/* Load all languages */
102Language::loadLanguages();
103
104/* Loading default country */
105$defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
106Context::getContext()->country = $defaultCountry;
107
108/* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
109@date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
110
111/* Instantiate cookie */
112$cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : 1)* 3600));
113if (defined('_PS_ADMIN_DIR_'))
114	$cookie = new Cookie('psAdmin', '', $cookieLifetime);
115else
116{
117	if (Context::getContext()->shop->getGroup()->share_order)
118		$cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime, Context::getContext()->shop->getUrlsSharedCart());
119	else
120		$cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);
121}
122
123Context::getContext()->cookie = $cookie;
124/* Create employee if in BO, customer else */
125if (defined('_PS_ADMIN_DIR_'))
126{
127	$employee = new Employee($cookie->id_employee);
128	Context::getContext()->employee = $employee;
129
130	/* Auth on shops are recached after employee assignation */
131	if ($employee->id_profile != _PS_ADMIN_PROFILE_)
132		Shop::cacheShops(true);
133
134	$cookie->id_lang = (int)$employee->id_lang;
135}
136else
137{
138	if (isset($cookie->id_customer) && (int)$cookie->id_customer)
139	{
140		$customer = new Customer($cookie->id_customer);
141		$customer->logged = $cookie->logged;
142	}
143	else
144	{
145		$customer = new Customer();
146		
147		// Change the default group 
148		if (Group::isFeatureActive())
149			$customer->id_default_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
150	}
151	$customer->id_guest = $cookie->id_guest;
152	Context::getContext()->customer = $customer;
153}
154
155/* if the language stored in the cookie is not available language, use default language */
156if (isset($cookie->id_lang) && $cookie->id_lang)
157	$language = new Language($cookie->id_lang);
158if (!isset($language) || !Validate::isLoadedObject($language))
159	$language = new Language(Configuration::get('PS_LANG_DEFAULT'));
160Context::getContext()->language = $language;
161
162/**
163 * @deprecated : these defines are going to be deleted on 1.6 version of Prestashop
164 * USE : Configuration::get() method in order to getting the id of order state
165 */
166define('_PS_OS_CHEQUE_',      Configuration::get('PS_OS_CHEQUE'));
167define('_PS_OS_PAYMENT_',     Configuration::get('PS_OS_PAYMENT'));
168define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
169define('_PS_OS_SHIPPING_',    Configuration::get('PS_OS_SHIPPING'));
170define('_PS_OS_DELIVERED_',   Configuration::get('PS_OS_DELIVERED'));
171define('_PS_OS_CANCELED_',    Configuration::get('PS_OS_CANCELED'));
172define('_PS_OS_REFUND_',      Configuration::get('PS_OS_REFUND'));
173define('_PS_OS_ERROR_',       Configuration::get('PS_OS_ERROR'));
174define('_PS_OS_OUTOFSTOCK_',  Configuration::get('PS_OS_OUTOFSTOCK'));
175define('_PS_OS_BANKWIRE_',    Configuration::get('PS_OS_BANKWIRE'));
176define('_PS_OS_PAYPAL_',      Configuration::get('PS_OS_PAYPAL'));
177define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
178
179/* Get smarty */
180require_once(dirname(__FILE__).'/smarty.config.inc.php');
181Context::getContext()->smarty = $smarty;