PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, LGPL-3.0
  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. require_once(dirname(__FILE__).'/defines.inc.php');
  28. $start_time = microtime(true);
  29. /* SSL configuration */
  30. define('_PS_SSL_PORT_', 443);
  31. /* Improve PHP configuration to prevent issues */
  32. ini_set('upload_max_filesize', '100M');
  33. ini_set('default_charset', 'utf-8');
  34. ini_set('magic_quotes_runtime', 0);
  35. /* correct Apache charset (except if it's too late */
  36. if (!headers_sent())
  37. header('Content-Type: text/html; charset=utf-8');
  38. /* No settings file? goto installer... */
  39. if (!file_exists(dirname(__FILE__).'/settings.inc.php'))
  40. {
  41. $dir = ((substr($_SERVER['REQUEST_URI'], -1) == '/' || is_dir($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : dirname($_SERVER['REQUEST_URI']).'/');
  42. if (!file_exists(dirname(__FILE__).'/../install'))
  43. die('Error: "install" directory is missing');
  44. header('Location: install/');
  45. exit;
  46. }
  47. require_once(dirname(__FILE__).'/settings.inc.php');
  48. require_once(dirname(__FILE__).'/autoload.php');
  49. if (_PS_DEBUG_PROFILING_)
  50. {
  51. include_once(_PS_TOOL_DIR_.'profiling/Controller.php');
  52. include_once(_PS_TOOL_DIR_.'profiling/ObjectModel.php');
  53. include_once(_PS_TOOL_DIR_.'profiling/Hook.php');
  54. include_once(_PS_TOOL_DIR_.'profiling/Db.php');
  55. }
  56. /* Redefine REQUEST_URI if empty (on some webservers...) */
  57. if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
  58. {
  59. if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME']))
  60. $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
  61. if (isset($_SERVER['SCRIPT_NAME']))
  62. {
  63. if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING']))
  64. $_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
  65. else
  66. {
  67. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
  68. if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
  69. $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
  70. }
  71. }
  72. }
  73. /* Trying to redefine HTTP_HOST if empty (on some webservers...) */
  74. if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
  75. $_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
  76. /* Initialize the current Shop */
  77. Context::getContext()->shop = Shop::initialize();
  78. define('_THEME_NAME_', Context::getContext()->shop->getTheme());
  79. define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
  80. /* Include all defines related to base uri and theme name */
  81. require_once(dirname(__FILE__).'/defines_uri.inc.php');
  82. global $_MODULES;
  83. $_MODULES = array();
  84. /* Load configuration */
  85. Configuration::loadConfiguration();
  86. /* Load all languages */
  87. Language::loadLanguages();
  88. /* Loading default country */
  89. $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
  90. Context::getContext()->country = $defaultCountry;
  91. /* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
  92. @date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
  93. /* Instantiate cookie */
  94. $cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : 1)* 3600));
  95. if (defined('_PS_ADMIN_DIR_'))
  96. $cookie = new Cookie('psAdmin', '', $cookieLifetime);
  97. else
  98. {
  99. if (Context::getContext()->shop->getGroup()->share_order)
  100. $cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime, Context::getContext()->shop->getUrlsSharedCart());
  101. else
  102. $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);
  103. }
  104. Context::getContext()->cookie = $cookie;
  105. /* Create employee if in BO, customer else */
  106. if (defined('_PS_ADMIN_DIR_'))
  107. {
  108. $employee = new Employee($cookie->id_employee);
  109. Context::getContext()->employee = $employee;
  110. /* Auth on shops are recached after employee assignation */
  111. if ($employee->id_profile != _PS_ADMIN_PROFILE_)
  112. Shop::cacheShops(true);
  113. $cookie->id_lang = (int)$employee->id_lang;
  114. }
  115. else
  116. {
  117. if (isset($cookie->id_customer) && (int)$cookie->id_customer)
  118. {
  119. $customer = new Customer($cookie->id_customer);
  120. $customer->logged = $cookie->logged;
  121. }
  122. else
  123. {
  124. $customer = new Customer();
  125. // Change the default group
  126. if (Group::isFeatureActive())
  127. $customer->id_default_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
  128. }
  129. $customer->id_guest = $cookie->id_guest;
  130. Context::getContext()->customer = $customer;
  131. }
  132. /* if the language stored in the cookie is not available language, use default language */
  133. if (isset($cookie->id_lang) && $cookie->id_lang)
  134. $language = new Language($cookie->id_lang);
  135. if (!isset($language) || !Validate::isLoadedObject($language))
  136. $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
  137. Context::getContext()->language = $language;
  138. /**
  139. * @deprecated : these defines are going to be deleted on 1.6 version of Prestashop
  140. * USE : Configuration::get() method in order to getting the id of order state
  141. */
  142. define('_PS_OS_CHEQUE_', Configuration::get('PS_OS_CHEQUE'));
  143. define('_PS_OS_PAYMENT_', Configuration::get('PS_OS_PAYMENT'));
  144. define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
  145. define('_PS_OS_SHIPPING_', Configuration::get('PS_OS_SHIPPING'));
  146. define('_PS_OS_DELIVERED_', Configuration::get('PS_OS_DELIVERED'));
  147. define('_PS_OS_CANCELED_', Configuration::get('PS_OS_CANCELED'));
  148. define('_PS_OS_REFUND_', Configuration::get('PS_OS_REFUND'));
  149. define('_PS_OS_ERROR_', Configuration::get('PS_OS_ERROR'));
  150. define('_PS_OS_OUTOFSTOCK_', Configuration::get('PS_OS_OUTOFSTOCK'));
  151. define('_PS_OS_BANKWIRE_', Configuration::get('PS_OS_BANKWIRE'));
  152. define('_PS_OS_PAYPAL_', Configuration::get('PS_OS_PAYPAL'));
  153. define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
  154. /* Get smarty */
  155. require_once(dirname(__FILE__).'/smarty.config.inc.php');
  156. Context::getContext()->smarty = $smarty;