Guest User

prestashop problem

a guest
Jun 7th, 2017
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.17 KB | None | 0 0
  1. <?php
  2. /*
  3. * 2007-2016 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 [email protected] 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 <[email protected]>
  22. *  @copyright  2007-2016 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. $currentDir = dirname(__FILE__);
  28.  
  29. /* Custom defines made by users */
  30. if (is_file($currentDir.'/defines_custom.inc.php')) {
  31.     include_once($currentDir.'/defines_custom.inc.php');
  32. }
  33. require_once($currentDir.'/defines.inc.php');
  34.  
  35. $start_time = microtime(true);
  36.  
  37. /* SSL configuration */
  38. define('_PS_SSL_PORT_', 443);
  39.  
  40. /* Improve PHP configuration to prevent issues */
  41. ini_set('default_charset', 'utf-8');
  42. ini_set('magic_quotes_runtime', 0);
  43. ini_set('magic_quotes_sybase', 0);
  44.  
  45. /* correct Apache charset (except if it's too late */
  46. if (!headers_sent()) {
  47.     header('Content-Type: text/html; charset=utf-8');
  48. }
  49.  
  50. /* No settings file? goto installer... */
  51. if (!file_exists(_PS_ROOT_DIR_.'/config/settings.inc.php')) {
  52.     if (file_exists($currentDir.'/../install')) {
  53.         header('Location: install/');
  54.     } elseif (file_exists($currentDir.'/../install-dev')) {
  55.         header('Location: install-dev/');
  56.     } else {
  57.         die('Error: "install" directory is missing');
  58.     }
  59.     exit;
  60. }
  61.  
  62. /* include settings file only if we are not in multi-tenancy mode */
  63. require_once(_PS_ROOT_DIR_.'/config/settings.inc.php');
  64. require_once(_PS_CONFIG_DIR_.'autoload.php');
  65.  
  66. require_once $currentDir . DIRECTORY_SEPARATOR . 'bootstrap.php';
  67.  
  68. /* Custom config made by users */
  69. if (is_file(_PS_CUSTOM_CONFIG_FILE_)) {
  70.     include_once(_PS_CUSTOM_CONFIG_FILE_);
  71. }
  72.  
  73. if (_PS_DEBUG_PROFILING_) {
  74.     include_once(_PS_TOOL_DIR_.'profiling/Controller.php');
  75.     include_once(_PS_TOOL_DIR_.'profiling/ObjectModel.php');
  76.     include_once(_PS_TOOL_DIR_.'profiling/Db.php');
  77.     include_once(_PS_TOOL_DIR_.'profiling/Tools.php');
  78. }
  79.  
  80. if (Tools::convertBytes(ini_get('upload_max_filesize')) < Tools::convertBytes('100M')) {
  81.     ini_set('upload_max_filesize', '100M');
  82. }
  83.  
  84. if (Tools::isPHPCLI() && isset($argc) && isset($argv)) {
  85.     Tools::argvToGET($argc, $argv);
  86. }
  87.  
  88. /* Redefine REQUEST_URI if empty (on some webservers...) */
  89. if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI'])) {
  90.     if (!isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['SCRIPT_FILENAME'])) {
  91.         $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
  92.     }
  93.     if (isset($_SERVER['SCRIPT_NAME'])) {
  94.         if (basename($_SERVER['SCRIPT_NAME']) == 'index.php' && empty($_SERVER['QUERY_STRING'])) {
  95.             $_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
  96.         } else {
  97.             $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
  98.             if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
  99.                 $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
  100.             }
  101.         }
  102.     }
  103. }
  104.  
  105. /* Trying to redefine HTTP_HOST if empty (on some webservers...) */
  106. if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) {
  107.     $_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
  108. }
  109.  
  110. $context = Context::getContext();
  111.  
  112. /* Initialize the current Shop */
  113. try {
  114.     $context->shop = Shop::initialize();
  115.     $context->theme = new Theme((int)$context->shop->id_theme);
  116.     if ((Tools::isEmpty($theme_name = $context->shop->getTheme()) || !Validate::isLoadedObject($context->theme)) && !defined('_PS_ADMIN_DIR_')) {
  117.         throw new PrestaShopException(Tools::displayError('Current theme unselected. Please check your theme configuration.'));
  118.     }
  119. } catch (PrestaShopException $e) {
  120.     $e->displayMessage();
  121. }
  122. define('_THEME_NAME_', $theme_name);
  123. define('__PS_BASE_URI__', $context->shop->getBaseURI());
  124.  
  125. /* Include all defines related to base uri and theme name */
  126. require_once($currentDir.'/defines_uri.inc.php');
  127.  
  128. global $_MODULES;
  129. $_MODULES = array();
  130.  
  131. define('_PS_PRICE_DISPLAY_PRECISION_', Configuration::get('PS_PRICE_DISPLAY_PRECISION'));
  132. define('_PS_PRICE_COMPUTE_PRECISION_', _PS_PRICE_DISPLAY_PRECISION_);
  133.  
  134. if (Configuration::get('PS_USE_HTMLPURIFIER')) {
  135.     require_once(_PS_TOOL_DIR_.'htmlpurifier/HTMLPurifier.standalone.php');
  136. }
  137.  
  138. /* Load all languages */
  139. Language::loadLanguages();
  140.  
  141. /* Loading default country */
  142. $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
  143. $context->country = $default_country;
  144.  
  145. /* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
  146. @date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
  147.  
  148. /* Set locales */
  149. $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')).'_'.strtoupper(Configuration::get('PS_LOCALE_COUNTRY'));
  150. /* Please do not use LC_ALL here http://www.php.net/manual/fr/function.setlocale.php#25041 */
  151. setlocale(LC_COLLATE, $locale.'.UTF-8', $locale.'.utf8');
  152. setlocale(LC_CTYPE, $locale.'.UTF-8', $locale.'.utf8');
  153. setlocale(LC_TIME, $locale.'.UTF-8', $locale.'.utf8');
  154. setlocale(LC_NUMERIC, 'en_US.UTF-8', 'en_US.utf8');
  155.  
  156. /* Instantiate cookie */
  157. $cookie_lifetime = defined('_PS_ADMIN_DIR_') ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : (int)Configuration::get('PS_COOKIE_LIFETIME_FO');
  158. if ($cookie_lifetime > 0) {
  159.     $cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600);
  160. }
  161.  
  162. if (defined('_PS_ADMIN_DIR_')) {
  163.     $cookie = new Cookie('psAdmin', '', $cookie_lifetime);
  164. } else {
  165.     $force_ssl = Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE');
  166.     if ($context->shop->getGroup()->share_order) {
  167.         $cookie = new Cookie('ps-sg'.$context->shop->getGroup()->id, '', $cookie_lifetime, $context->shop->getUrlsSharedCart(), false, $force_ssl);
  168.     } else {
  169.         $domains = null;
  170.         if ($context->shop->domain != $context->shop->domain_ssl) {
  171.             $domains = array($context->shop->domain_ssl, $context->shop->domain);
  172.         }
  173.  
  174.         $cookie = new Cookie('ps-s'.$context->shop->id, '', $cookie_lifetime, $domains, false, $force_ssl);
  175.     }
  176. }
  177.  
  178. $context->cookie = $cookie;
  179.  
  180. /* Create employee if in BO, customer else */
  181. if (defined('_PS_ADMIN_DIR_')) {
  182.     $employee = new Employee($cookie->id_employee);
  183.     $context->employee = $employee;
  184.  
  185.     /* Auth on shops are recached after employee assignation */
  186.     if ($employee->id_profile != _PS_ADMIN_PROFILE_) {
  187.         Shop::cacheShops(true);
  188.     }
  189.  
  190.     $cookie->id_lang = (int)$employee->id_lang;
  191. }
  192.  
  193. /* if the language stored in the cookie is not available language, use default language */
  194. if (isset($cookie->id_lang) && $cookie->id_lang) {
  195.     $language = new Language($cookie->id_lang);
  196. }
  197. if (!isset($language) || !Validate::isLoadedObject($language)) {
  198.     $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
  199. }
  200. $context->language = $language;
  201.  
  202. /* Get smarty */
  203. require_once($currentDir.'/smarty.config.inc.php');
  204. $context->smarty = $smarty;
  205.  
  206. if (!defined('_PS_ADMIN_DIR_')) {
  207.     if (isset($cookie->id_customer) && (int)$cookie->id_customer) {
  208.         $customer = new Customer($cookie->id_customer);
  209.         if (!Validate::isLoadedObject($customer)) {
  210.             $context->cookie->logout();
  211.         } else {
  212.             $customer->logged = true;
  213.             if ($customer->id_lang != $context->language->id) {
  214.                 $customer->id_lang = $context->language->id;
  215.                 $customer->update();
  216.             }
  217.         }
  218.     }
  219.  
  220.     if (!isset($customer) || !Validate::isLoadedObject($customer)) {
  221.         $customer = new Customer();
  222.  
  223.         /* Change the default group */
  224.         if (Group::isFeatureActive()) {
  225.             $customer->id_default_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
  226.         }
  227.     }
  228.     $customer->id_guest = $cookie->id_guest;
  229.     $context->customer = $customer;
  230. }
  231.  
  232. /* Link should also be initialized in the context here for retrocompatibility */
  233. $https_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
  234. $context->link = new Link($https_link, $https_link);
  235.  
  236. /**
  237.  * @deprecated
  238.  * USE : Configuration::get() method in order to getting the id of order status
  239.  */
  240.  
  241. define('_PS_OS_CHEQUE_', Configuration::get('PS_OS_CHEQUE'));
  242. define('_PS_OS_PAYMENT_', Configuration::get('PS_OS_PAYMENT'));
  243. define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
  244. define('_PS_OS_SHIPPING_', Configuration::get('PS_OS_SHIPPING'));
  245. define('_PS_OS_DELIVERED_', Configuration::get('PS_OS_DELIVERED'));
  246. define('_PS_OS_CANCELED_', Configuration::get('PS_OS_CANCELED'));
  247. define('_PS_OS_REFUND_', Configuration::get('PS_OS_REFUND'));
  248. define('_PS_OS_ERROR_', Configuration::get('PS_OS_ERROR'));
  249. define('_PS_OS_OUTOFSTOCK_', Configuration::get('PS_OS_OUTOFSTOCK'));
  250. define('_PS_OS_OUTOFSTOCK_PAID_', Configuration::get('PS_OS_OUTOFSTOCK_PAID'));
  251. define('_PS_OS_OUTOFSTOCK_UNPAID_', Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'));
  252. define('_PS_OS_BANKWIRE_', Configuration::get('PS_OS_BANKWIRE'));
  253. define('_PS_OS_PAYPAL_', Configuration::get('PS_OS_PAYPAL'));
  254. define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
  255. define('_PS_OS_COD_VALIDATION_', Configuration::get('PS_OS_COD_VALIDATION'));
  256.  
  257. if (!defined('_MEDIA_SERVER_1_')) {
  258.     define('_MEDIA_SERVER_1_', Configuration::get('PS_MEDIA_SERVER_1'));
  259. }
  260. if (!defined('_MEDIA_SERVER_2_')) {
  261.     define('_MEDIA_SERVER_2_', Configuration::get('PS_MEDIA_SERVER_2'));
  262. }
  263. if (!defined('_MEDIA_SERVER_3_')) {
  264.     define('_MEDIA_SERVER_3_', Configuration::get('PS_MEDIA_SERVER_3'));
  265. }
Advertisement
Add Comment
Please, Sign In to add comment