PageRenderTime 44ms CodeModel.GetById 34ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/prestashop_1.5.6.2/prestashop/config/config.inc.php

https://gitlab.com/casiazul/colectivoweb
PHP | 231 lines | 145 code | 38 blank | 48 comment | 42 complexity | 78c0880a6dd0ffedaf850b9f5341e3e3 MD5 | raw file
  1<?php
  2/*
  3* 2007-2013 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-2013 PrestaShop SA
 23*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 24*  International Registered Trademark & Property of PrestaShop SA
 25*/
 26
 27require_once(dirname(__FILE__).'/defines.inc.php');
 28$start_time = microtime(true);
 29
 30/* SSL configuration */
 31define('_PS_SSL_PORT_', 443);
 32
 33/* Improve PHP configuration to prevent issues */
 34ini_set('upload_max_filesize', '100M');
 35ini_set('default_charset', 'utf-8');
 36ini_set('magic_quotes_runtime', 0);
 37
 38/* correct Apache charset (except if it's too late */
 39if (!headers_sent())
 40	header('Content-Type: text/html; charset=utf-8');
 41
 42/* No settings file? goto installer... */
 43if (!file_exists(dirname(__FILE__).'/settings.inc.php'))
 44{
 45	$dir = ((substr($_SERVER['REQUEST_URI'], -1) == '/' || is_dir($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : dirname($_SERVER['REQUEST_URI']).'/');
 46	if (!file_exists(dirname(__FILE__).'/../install'))
 47		die('Error: "install" directory is missing');
 48	header('Location: install/');
 49	exit;
 50}
 51
 52require_once(dirname(__FILE__).'/settings.inc.php');
 53
 54require_once(dirname(__FILE__).'/autoload.php');
 55
 56if (_PS_DEBUG_PROFILING_)
 57{
 58	include_once(_PS_TOOL_DIR_.'profiling/Controller.php');
 59	include_once(_PS_TOOL_DIR_.'profiling/ObjectModel.php');
 60	include_once(_PS_TOOL_DIR_.'profiling/Hook.php');
 61	include_once(_PS_TOOL_DIR_.'profiling/Db.php');
 62	include_once(_PS_TOOL_DIR_.'profiling/Tools.php');
 63}
 64
 65if (Tools::isPHPCLI())
 66	Tools::argvToGET($argc, $argv);
 67
 68/* Redefine REQUEST_URI if empty (on some webservers...) */
 69if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
 70{
 71	if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME']))
 72		$_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
 73	if (isset($_SERVER['SCRIPT_NAME']))
 74	{
 75		if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING']))
 76			$_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
 77		else
 78		{
 79			$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
 80			if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
 81				$_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
 82		}
 83	}
 84}
 85
 86/* Trying to redefine HTTP_HOST if empty (on some webservers...) */
 87if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
 88	$_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
 89	
 90$context = Context::getContext();
 91
 92/* Initialize the current Shop */
 93try 
 94{
 95	$context->shop = Shop::initialize();
 96	if (Tools::isEmpty($theme_name = $context->shop->getTheme()) && !defined('_PS_ADMIN_DIR_'))
 97 		throw new PrestaShopException(Tools::displayError('Current theme unselected. Please check your theme configuration.'));
 98}
 99catch (PrestaShopException $e)
100{
101	$e->displayMessage();
102}
103
104define('_THEME_NAME_', $theme_name);
105define('__PS_BASE_URI__', $context->shop->getBaseURI());
106
107/* Include all defines related to base uri and theme name */
108require_once(dirname(__FILE__).'/defines_uri.inc.php');
109
110global $_MODULES;
111$_MODULES = array();
112
113/* Load configuration */
114Configuration::loadConfiguration();
115
116/* Load all languages */
117Language::loadLanguages();
118
119/* Loading default country */
120$defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
121$context->country = $defaultCountry;
122
123/* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
124@date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
125
126/* Set locales */
127$locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')).'_'.strtoupper(Configuration::get('PS_LOCALE_COUNTRY').'.UTF-8');
128setlocale(LC_COLLATE, $locale);
129setlocale(LC_CTYPE, $locale);
130setlocale(LC_TIME, $locale);
131setlocale(LC_NUMERIC, 'en_US.UTF-8');
132
133/* Instantiate cookie */
134
135
136$cookie_lifetime = (int)(defined('_PS_ADMIN_DIR_') ? Configuration::get('PS_COOKIE_LIFETIME_BO') : Configuration::get('PS_COOKIE_LIFETIME_FO'));
137$cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600);
138
139if (defined('_PS_ADMIN_DIR_'))
140	$cookie = new Cookie('psAdmin', '', $cookie_lifetime);
141else
142{
143	if ($context->shop->getGroup()->share_order)
144		$cookie = new Cookie('ps-sg'.$context->shop->getGroup()->id, '', $cookie_lifetime, $context->shop->getUrlsSharedCart());
145	else
146	{
147		$domains = null;
148		if ($context->shop->domain != $context->shop->domain_ssl)
149		  $domains = array($context->shop->domain_ssl, $context->shop->domain);
150		
151		$cookie = new Cookie('ps-s'.$context->shop->id, '', $cookie_lifetime, $domains);
152	}
153}
154
155$context->cookie = $cookie;
156
157/* Create employee if in BO, customer else */
158if (defined('_PS_ADMIN_DIR_'))
159{
160	$employee = new Employee($cookie->id_employee);
161	$context->employee = $employee;
162
163	/* Auth on shops are recached after employee assignation */
164	if ($employee->id_profile != _PS_ADMIN_PROFILE_)
165		Shop::cacheShops(true);
166
167	$cookie->id_lang = (int)$employee->id_lang;
168}
169
170/* if the language stored in the cookie is not available language, use default language */
171if (isset($cookie->id_lang) && $cookie->id_lang)
172	$language = new Language($cookie->id_lang);
173if (!isset($language) || !Validate::isLoadedObject($language))
174	$language = new Language(Configuration::get('PS_LANG_DEFAULT'));
175$context->language = $language;
176
177if (!defined('_PS_ADMIN_DIR_'))
178{
179	if (isset($cookie->id_customer) && (int)$cookie->id_customer)
180	{
181		$customer = new Customer($cookie->id_customer);
182		if(!Validate::isLoadedObject($customer))
183			$customer->logout();
184		else
185		{
186			$customer->logged = $cookie->logged;
187
188			if ($customer->id_lang != $context->language->id)
189			{
190				$customer->id_lang = $context->language->id;
191				$customer->update();
192			}
193		}
194	}
195
196	if (!isset($customer) || !Validate::isLoadedObject($customer))
197	{
198		$customer = new Customer();
199		
200		// Change the default group
201		if (Group::isFeatureActive())
202			$customer->id_default_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
203	}
204	$customer->id_guest = $cookie->id_guest;
205	$context->customer = $customer;
206}
207
208/* Link should also be initialized in the context here for retrocompatibility */
209$https_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
210$context->link = new Link($https_link, $https_link);
211
212/**
213 * @deprecated : these defines are going to be deleted on 1.6 version of Prestashop
214 * USE : Configuration::get() method in order to getting the id of order state
215 */
216define('_PS_OS_CHEQUE_',      Configuration::get('PS_OS_CHEQUE'));
217define('_PS_OS_PAYMENT_',     Configuration::get('PS_OS_PAYMENT'));
218define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
219define('_PS_OS_SHIPPING_',    Configuration::get('PS_OS_SHIPPING'));
220define('_PS_OS_DELIVERED_',   Configuration::get('PS_OS_DELIVERED'));
221define('_PS_OS_CANCELED_',    Configuration::get('PS_OS_CANCELED'));
222define('_PS_OS_REFUND_',      Configuration::get('PS_OS_REFUND'));
223define('_PS_OS_ERROR_',       Configuration::get('PS_OS_ERROR'));
224define('_PS_OS_OUTOFSTOCK_',  Configuration::get('PS_OS_OUTOFSTOCK'));
225define('_PS_OS_BANKWIRE_',    Configuration::get('PS_OS_BANKWIRE'));
226define('_PS_OS_PAYPAL_',      Configuration::get('PS_OS_PAYPAL'));
227define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
228
229/* Get smarty */
230require_once(dirname(__FILE__).'/smarty.config.inc.php');
231$context->smarty = $smarty;