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