Advertisement
Guest User

Untitled

a guest
Mar 10th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.35 KB | None | 0 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. *  @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.  
  27. require_once(dirname(__FILE__).'/defines.inc.php');
  28. $start_time = microtime(true);
  29.  
  30. /* SSL configuration */
  31. define('_PS_SSL_PORT_', 443);
  32.  
  33. /* Improve PHP configuration to prevent issues */
  34. ini_set('upload_max_filesize', '100M');
  35. ini_set('default_charset', 'utf-8');
  36. ini_set('magic_quotes_runtime', 0);
  37.  
  38. /* correct Apache charset (except if it's too late */
  39. if (!headers_sent())
  40.     header('Content-Type: text/html; charset=utf-8');
  41.  
  42. /* No settings file? goto installer... */
  43. if (!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.  
  52. require_once(dirname(__FILE__).'/settings.inc.php');
  53.  
  54. require_once(dirname(__FILE__).'/autoload.php');
  55.  
  56. if (_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. }
  63.  
  64. /* Redefine REQUEST_URI if empty (on some webservers...) */
  65. if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
  66. {
  67.     if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME']))
  68.         $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
  69.     if (isset($_SERVER['SCRIPT_NAME']))
  70.     {
  71.         if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING']))
  72.             $_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
  73.         else
  74.         {
  75.             $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
  76.             if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
  77.                 $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
  78.         }
  79.     }
  80. }
  81.  
  82. /* Trying to redefine HTTP_HOST if empty (on some webservers...) */
  83. if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
  84.     $_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
  85.  
  86. /* Initialize the current Shop */
  87. Context::getContext()->shop = Shop::initialize();
  88. define('_THEME_NAME_', Context::getContext()->shop->getTheme());
  89. define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
  90.  
  91. /* Include all defines related to base uri and theme name */
  92. require_once(dirname(__FILE__).'/defines_uri.inc.php');
  93.  
  94. global $_MODULES;
  95. $_MODULES = array();
  96.  
  97. /* Load configuration */
  98. Configuration::loadConfiguration();
  99.  
  100. /* Load all languages */
  101. Language::loadLanguages();
  102.  
  103. /* Loading default country */
  104. $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
  105. Context::getContext()->country = $defaultCountry;
  106.  
  107. /* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
  108. @date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
  109.  
  110. /* Set locales */
  111. $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')).'_'.strtoupper(Configuration::get('PS_LOCALE_COUNTRY').'.UTF-8');
  112. setlocale(LC_COLLATE, $locale);
  113. setlocale(LC_CTYPE, $locale);
  114. setlocale(LC_TIME, $locale);
  115. setlocale(LC_NUMERIC, 'en_US.UTF-8');
  116.  
  117. /* Instantiate cookie */
  118.  
  119.  
  120. $cookie_lifetime = (int)(defined('_PS_ADMIN_DIR_') ? Configuration::get('PS_COOKIE_LIFETIME_BO') : Configuration::get('PS_COOKIE_LIFETIME_FO'));
  121. $cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600);
  122.  
  123. if (defined('_PS_ADMIN_DIR_'))
  124.     $cookie = new Cookie('psAdmin', '', $cookie_lifetime);
  125. else
  126. {
  127.     if (Context::getContext()->shop->getGroup()->share_order)
  128.         $cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookie_lifetime, Context::getContext()->shop->getUrlsSharedCart());
  129.     else
  130.     {
  131.         $domains = null;
  132.         if (Context::getContext()->shop->domain != Context::getContext()->shop->domain_ssl)
  133.           $domains = array(Context::getContext()->shop->domain_ssl, Context::getContext()->shop->domain);
  134.        
  135.         $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookie_lifetime, $domains);
  136.     }
  137. }
  138.  
  139. Context::getContext()->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::getContext()->employee = $employee;
  145.  
  146.     /* Auth on shops are recached after employee assignation */
  147.     if ($employee->id_profile != _PS_ADMIN_PROFILE_)
  148.         Shop::cacheShops(true);
  149.  
  150.     $cookie->id_lang = (int)$employee->id_lang;
  151. }
  152. else
  153. {
  154.     if (isset($cookie->id_customer) && (int)$cookie->id_customer)
  155.     {
  156.         $customer = new Customer($cookie->id_customer);
  157.         $customer->logged = $cookie->logged;
  158.     }
  159.     else
  160.     {
  161.         $customer = new Customer();
  162.        
  163.         // Change the default group
  164.         if (Group::isFeatureActive())
  165.             $customer->id_default_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
  166.     }
  167.     $customer->id_guest = $cookie->id_guest;
  168.     Context::getContext()->customer = $customer;
  169. }
  170.  
  171. /* if the language stored in the cookie is not available language, use default language */
  172. if (isset($cookie->id_lang) && $cookie->id_lang)
  173.     $language = new Language($cookie->id_lang);
  174. if (!isset($language) || !Validate::isLoadedObject($language))
  175.     $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
  176. Context::getContext()->language = $language;
  177.  
  178. /**
  179.  * @deprecated : these defines are going to be deleted on 1.6 version of Prestashop
  180.  * USE : Configuration::get() method in order to getting the id of order state
  181.  */
  182. define('_PS_OS_CHEQUE_',      Configuration::get('PS_OS_CHEQUE'));
  183. define('_PS_OS_PAYMENT_',     Configuration::get('PS_OS_PAYMENT'));
  184. define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
  185. define('_PS_OS_SHIPPING_',    Configuration::get('PS_OS_SHIPPING'));
  186. define('_PS_OS_DELIVERED_',   Configuration::get('PS_OS_DELIVERED'));
  187. define('_PS_OS_CANCELED_',    Configuration::get('PS_OS_CANCELED'));
  188. define('_PS_OS_REFUND_',      Configuration::get('PS_OS_REFUND'));
  189. define('_PS_OS_ERROR_',       Configuration::get('PS_OS_ERROR'));
  190. define('_PS_OS_OUTOFSTOCK_',  Configuration::get('PS_OS_OUTOFSTOCK'));
  191. define('_PS_OS_BANKWIRE_',    Configuration::get('PS_OS_BANKWIRE'));
  192. define('_PS_OS_PAYPAL_',      Configuration::get('PS_OS_PAYPAL'));
  193. define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
  194.  
  195. /* Get smarty */
  196. require_once(dirname(__FILE__).'/smarty.config.inc.php');
  197. Context::getContext()->smarty = $smarty;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement