PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/config/config.inc.php

https://bitbucket.org/enurkov/prestashop
PHP | 197 lines | 120 code | 30 blank | 47 comment | 32 complexity | 46db5fdee6058cbcf2f5002ef5eb6323 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. * @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. }
  55. /* Redefine REQUEST_URI if empty (on some webservers...) */
  56. if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
  57. {
  58. if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME']))
  59. $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
  60. if (isset($_SERVER['SCRIPT_NAME']))
  61. {
  62. if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING']))
  63. $_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
  64. else
  65. {
  66. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
  67. if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
  68. $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
  69. }
  70. }
  71. }
  72. /* Trying to redefine HTTP_HOST if empty (on some webservers...) */
  73. if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
  74. $_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
  75. /* Initialize the current Shop */
  76. Context::getContext()->shop = Shop::initialize();
  77. define('_THEME_NAME_', Context::getContext()->shop->getTheme());
  78. define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
  79. /* Include all defines related to base uri and theme name */
  80. require_once(dirname(__FILE__).'/defines_uri.inc.php');
  81. global $_MODULES;
  82. $_MODULES = array();
  83. /* Load configuration */
  84. Configuration::loadConfiguration();
  85. /* Load all languages */
  86. Language::loadLanguages();
  87. /* Loading default country */
  88. $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
  89. Context::getContext()->country = $defaultCountry;
  90. /* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
  91. @date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
  92. /* Set locales */
  93. $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')).'_'.strtoupper(Configuration::get('PS_LOCALE_COUNTRY').'.UTF-8');
  94. setlocale(LC_COLLATE, $locale);
  95. setlocale(LC_CTYPE, $locale);
  96. setlocale(LC_TIME, $locale);
  97. setlocale(LC_NUMERIC, 'en_US.UTF-8');
  98. /* Instantiate cookie */
  99. $cookie_lifetime = (int)(defined('_PS_ADMIN_DIR_') ? Configuration::get('PS_COOKIE_LIFETIME_BO') : Configuration::get('PS_COOKIE_LIFETIME_FO'));
  100. $cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600);
  101. if (defined('_PS_ADMIN_DIR_'))
  102. $cookie = new Cookie('psAdmin', '', $cookie_lifetime);
  103. else
  104. {
  105. if (Context::getContext()->shop->getGroup()->share_order)
  106. $cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookie_lifetime, Context::getContext()->shop->getUrlsSharedCart());
  107. else
  108. {
  109. $domains = null;
  110. if (Context::getContext()->shop->domain != Context::getContext()->shop->domain_ssl)
  111. $domains = array(Context::getContext()->shop->domain_ssl, Context::getContext()->shop->domain);
  112. $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookie_lifetime, $domains);
  113. }
  114. }
  115. Context::getContext()->cookie = $cookie;
  116. /* Create employee if in BO, customer else */
  117. if (defined('_PS_ADMIN_DIR_'))
  118. {
  119. $employee = new Employee($cookie->id_employee);
  120. Context::getContext()->employee = $employee;
  121. /* Auth on shops are recached after employee assignation */
  122. if ($employee->id_profile != _PS_ADMIN_PROFILE_)
  123. Shop::cacheShops(true);
  124. $cookie->id_lang = (int)$employee->id_lang;
  125. }
  126. else
  127. {
  128. if (isset($cookie->id_customer) && (int)$cookie->id_customer)
  129. {
  130. $customer = new Customer($cookie->id_customer);
  131. $customer->logged = $cookie->logged;
  132. }
  133. else
  134. {
  135. $customer = new Customer();
  136. // Change the default group
  137. if (Group::isFeatureActive())
  138. $customer->id_default_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
  139. }
  140. $customer->id_guest = $cookie->id_guest;
  141. Context::getContext()->customer = $customer;
  142. }
  143. /* if the language stored in the cookie is not available language, use default language */
  144. if (isset($cookie->id_lang) && $cookie->id_lang)
  145. $language = new Language($cookie->id_lang);
  146. if (!isset($language) || !Validate::isLoadedObject($language))
  147. $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
  148. Context::getContext()->language = $language;
  149. /**
  150. * @deprecated : these defines are going to be deleted on 1.6 version of Prestashop
  151. * USE : Configuration::get() method in order to getting the id of order state
  152. */
  153. define('_PS_OS_CHEQUE_', Configuration::get('PS_OS_CHEQUE'));
  154. define('_PS_OS_PAYMENT_', Configuration::get('PS_OS_PAYMENT'));
  155. define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
  156. define('_PS_OS_SHIPPING_', Configuration::get('PS_OS_SHIPPING'));
  157. define('_PS_OS_DELIVERED_', Configuration::get('PS_OS_DELIVERED'));
  158. define('_PS_OS_CANCELED_', Configuration::get('PS_OS_CANCELED'));
  159. define('_PS_OS_REFUND_', Configuration::get('PS_OS_REFUND'));
  160. define('_PS_OS_ERROR_', Configuration::get('PS_OS_ERROR'));
  161. define('_PS_OS_OUTOFSTOCK_', Configuration::get('PS_OS_OUTOFSTOCK'));
  162. define('_PS_OS_BANKWIRE_', Configuration::get('PS_OS_BANKWIRE'));
  163. define('_PS_OS_PAYPAL_', Configuration::get('PS_OS_PAYPAL'));
  164. define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
  165. /* Get smarty */
  166. require_once(dirname(__FILE__).'/smarty.config.inc.php');
  167. Context::getContext()->smarty = $smarty;