PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/config/config.inc.php

https://gitlab.com/mtellezgalindo/PrestaShop
PHP | 250 lines | 164 code | 37 blank | 49 comment | 50 complexity | 4190d79d21d9482ffd204dbd9b26c6aa MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-3.0
  1. <?php
  2. /*
  3. * 2007-2014 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-2014 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('default_charset', 'utf-8');
  32. ini_set('magic_quotes_runtime', 0);
  33. ini_set('magic_quotes_sybase', 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(_PS_ROOT_DIR_.'/config/settings.inc.php'))
  39. {
  40. if (file_exists(dirname(__FILE__).'/../install'))
  41. header('Location: install/');
  42. elseif (file_exists(dirname(__FILE__).'/../install-dev'))
  43. header('Location: install-dev/');
  44. else
  45. die('Error: "install" directory is missing');
  46. exit;
  47. }
  48. /* include settings file only if we are not in multi-tenancy mode */
  49. require_once(_PS_ROOT_DIR_.'/config/settings.inc.php');
  50. require_once(_PS_CONFIG_DIR_.'autoload.php');
  51. if (_PS_DEBUG_PROFILING_)
  52. {
  53. include_once(_PS_TOOL_DIR_.'profiling/Controller.php');
  54. include_once(_PS_TOOL_DIR_.'profiling/ObjectModel.php');
  55. include_once(_PS_TOOL_DIR_.'profiling/Hook.php');
  56. include_once(_PS_TOOL_DIR_.'profiling/Db.php');
  57. include_once(_PS_TOOL_DIR_.'profiling/Tools.php');
  58. }
  59. if (Tools::convertBytes(ini_get('upload_max_filesize')) < Tools::convertBytes('100M'))
  60. ini_set('upload_max_filesize', '100M');
  61. if (Tools::isPHPCLI() && isset($argc) && isset($argv))
  62. Tools::argvToGET($argc, $argv);
  63. /* Redefine REQUEST_URI if empty (on some webservers...) */
  64. if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
  65. {
  66. if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME']))
  67. $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
  68. if (isset($_SERVER['SCRIPT_NAME']))
  69. {
  70. if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING']))
  71. $_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
  72. else
  73. {
  74. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
  75. if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
  76. $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
  77. }
  78. }
  79. }
  80. /* Trying to redefine HTTP_HOST if empty (on some webservers...) */
  81. if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
  82. $_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
  83. $context = Context::getContext();
  84. /* Initialize the current Shop */
  85. try
  86. {
  87. $context->shop = Shop::initialize();
  88. $context->theme = new Theme((int)$context->shop->id_theme);
  89. if ((Tools::isEmpty($theme_name = $context->shop->getTheme()) || !Validate::isLoadedObject($context->theme)) && !defined('_PS_ADMIN_DIR_'))
  90. throw new PrestaShopException(Tools::displayError('Current theme unselected. Please check your theme configuration.'));
  91. }
  92. catch (PrestaShopException $e)
  93. {
  94. $e->displayMessage();
  95. }
  96. define('_THEME_NAME_', $theme_name);
  97. define('__PS_BASE_URI__', $context->shop->getBaseURI());
  98. /* Include all defines related to base uri and theme name */
  99. require_once(dirname(__FILE__).'/defines_uri.inc.php');
  100. global $_MODULES;
  101. $_MODULES = array();
  102. define('_PS_PRICE_DISPLAY_PRECISION_', Configuration::get('PS_PRICE_DISPLAY_PRECISION'));
  103. define('_PS_PRICE_COMPUTE_PRECISION_', _PS_PRICE_DISPLAY_PRECISION_);
  104. if (Configuration::get('PS_USE_HTMLPURIFIER'))
  105. require_once (_PS_TOOL_DIR_.'htmlpurifier/HTMLPurifier.standalone.php');
  106. /* Load all languages */
  107. Language::loadLanguages();
  108. /* Loading default country */
  109. $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
  110. $context->country = $default_country;
  111. /* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
  112. @date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
  113. /* Set locales */
  114. $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')).'_'.strtoupper(Configuration::get('PS_LOCALE_COUNTRY'));
  115. /* Please do not use LC_ALL here http://www.php.net/manual/fr/function.setlocale.php#25041 */
  116. setlocale(LC_COLLATE, $locale.'.UTF-8', $locale.'.utf8');
  117. setlocale(LC_CTYPE, $locale.'.UTF-8', $locale.'.utf8');
  118. setlocale(LC_TIME, $locale.'.UTF-8', $locale.'.utf8');
  119. setlocale(LC_NUMERIC, 'en_US.UTF-8', 'en_US.utf8');
  120. /* Instantiate cookie */
  121. $cookie_lifetime = defined('_PS_ADMIN_DIR_') ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : (int)Configuration::get('PS_COOKIE_LIFETIME_FO');
  122. if ($cookie_lifetime > 0)
  123. $cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600);
  124. if (defined('_PS_ADMIN_DIR_'))
  125. $cookie = new Cookie('psAdmin', '', $cookie_lifetime);
  126. else
  127. {
  128. $force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE');
  129. if ($context->shop->getGroup()->share_order)
  130. $cookie = new Cookie('ps-sg'.$context->shop->getGroup()->id, '', $cookie_lifetime, $context->shop->getUrlsSharedCart(), false, $force_ssl);
  131. else
  132. {
  133. $domains = null;
  134. if ($context->shop->domain != $context->shop->domain_ssl)
  135. $domains = array($context->shop->domain_ssl, $context->shop->domain);
  136. $cookie = new Cookie('ps-s'.$context->shop->id, '', $cookie_lifetime, $domains, false, $force_ssl);
  137. }
  138. }
  139. $context->cookie = $cookie;
  140. /* Create employee if in BO, customer else */
  141. if (defined('_PS_ADMIN_DIR_'))
  142. {
  143. $employee = new Employee($cookie->id_employee);
  144. $context->employee = $employee;
  145. /* Auth on shops are recached after employee assignation */
  146. if ($employee->id_profile != _PS_ADMIN_PROFILE_)
  147. Shop::cacheShops(true);
  148. $cookie->id_lang = (int)$employee->id_lang;
  149. }
  150. /* if the language stored in the cookie is not available language, use default language */
  151. if (isset($cookie->id_lang) && $cookie->id_lang)
  152. $language = new Language($cookie->id_lang);
  153. if (!isset($language) || !Validate::isLoadedObject($language))
  154. $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
  155. $context->language = $language;
  156. if (!defined('_PS_ADMIN_DIR_'))
  157. {
  158. if (isset($cookie->id_customer) && (int)$cookie->id_customer)
  159. {
  160. $customer = new Customer($cookie->id_customer);
  161. if (!Validate::isLoadedObject($customer))
  162. $context->cookie->logout();
  163. else
  164. {
  165. $customer->logged = true;
  166. if ($customer->id_lang != $context->language->id)
  167. {
  168. $customer->id_lang = $context->language->id;
  169. $customer->update();
  170. }
  171. }
  172. }
  173. if (!isset($customer) || !Validate::isLoadedObject($customer))
  174. {
  175. $customer = new Customer();
  176. /* Change the default group */
  177. if (Group::isFeatureActive())
  178. $customer->id_default_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
  179. }
  180. $customer->id_guest = $cookie->id_guest;
  181. $context->customer = $customer;
  182. }
  183. /* Link should also be initialized in the context here for retrocompatibility */
  184. $https_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
  185. $context->link = new Link($https_link, $https_link);
  186. /**
  187. * @deprecated
  188. * USE : Configuration::get() method in order to getting the id of order status
  189. */
  190. define('_PS_OS_CHEQUE_', Configuration::get('PS_OS_CHEQUE'));
  191. define('_PS_OS_PAYMENT_', Configuration::get('PS_OS_PAYMENT'));
  192. define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
  193. define('_PS_OS_SHIPPING_', Configuration::get('PS_OS_SHIPPING'));
  194. define('_PS_OS_DELIVERED_', Configuration::get('PS_OS_DELIVERED'));
  195. define('_PS_OS_CANCELED_', Configuration::get('PS_OS_CANCELED'));
  196. define('_PS_OS_REFUND_', Configuration::get('PS_OS_REFUND'));
  197. define('_PS_OS_ERROR_', Configuration::get('PS_OS_ERROR'));
  198. define('_PS_OS_OUTOFSTOCK_', Configuration::get('PS_OS_OUTOFSTOCK'));
  199. define('_PS_OS_OUTOFSTOCK_PAID_', Configuration::get('PS_OS_OUTOFSTOCK_PAID'));
  200. define('_PS_OS_OUTOFSTOCK_UNPAID_', Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'));
  201. define('_PS_OS_BANKWIRE_', Configuration::get('PS_OS_BANKWIRE'));
  202. define('_PS_OS_PAYPAL_', Configuration::get('PS_OS_PAYPAL'));
  203. define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
  204. define('_PS_OS_COD_VALIDATION_', Configuration::get('PS_OS_COD_VALIDATION'));
  205. if (!defined('_MEDIA_SERVER_1_'))
  206. define('_MEDIA_SERVER_1_', Configuration::get('PS_MEDIA_SERVER_1'));
  207. if (!defined('_MEDIA_SERVER_2_'))
  208. define('_MEDIA_SERVER_2_', Configuration::get('PS_MEDIA_SERVER_2'));
  209. if (!defined('_MEDIA_SERVER_3_'))
  210. define('_MEDIA_SERVER_3_', Configuration::get('PS_MEDIA_SERVER_3'));
  211. /* Get smarty */
  212. require_once(dirname(__FILE__).'/smarty.config.inc.php');
  213. $context->smarty = $smarty;