Ejemplo n.º 1
0
$smarty->register_function('convertPriceWithoutDisplay', array('Product', 'productPriceWithoutDisplay'));
$smarty->register_function('convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
$smarty->register_function('displayWtPrice', array('Product', 'displayWtPrice'));
$smarty->register_function('displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
$smarty->register_function('displayPrice', array('Tools', 'displayPriceSmarty'));
$smarty->assign(Tools::getMetaTags(intval($cookie->id_lang)));
$smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
/* Breadcrumb */
$navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
$smarty->assign('navigationPipe', $navigationPipe);
/* Server Params */
$server_host = Tools::getHttpHost(false, true);
$protocol = 'http://';
$protocol_ssl = 'https://';
$protocol_link = Configuration::get('PS_SSL_ENABLED') ? $protocol_ssl : $protocol;
$protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol;
define('_PS_BASE_URL_', $protocol . $server_host);
Product::initPricesComputation();
if (!Configuration::get('PS_THEME_V11')) {
    define('_PS_BASE_URL_SSL_', $protocol_ssl . $server_host);
    $smarty->assign(array('base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . $server_host . __PS_BASE_URI__, 'content_dir' => $protocol_content . $server_host . __PS_BASE_URI__, 'img_ps_dir' => $protocol_content . $server_host . _PS_IMG_, 'img_cat_dir' => $protocol_content . $server_host . _THEME_CAT_DIR_, 'img_lang_dir' => $protocol_content . $server_host . _THEME_LANG_DIR_, 'img_prod_dir' => $protocol_content . $server_host . _THEME_PROD_DIR_, 'img_manu_dir' => $protocol_content . $server_host . _THEME_MANU_DIR_, 'img_sup_dir' => $protocol_content . $server_host . _THEME_SUP_DIR_, 'img_ship_dir' => $protocol_content . $server_host . _THEME_SHIP_DIR_, 'img_col_dir' => $protocol_content . $server_host . _THEME_COL_DIR_, 'img_dir' => $protocol_content . $server_host . _THEME_IMG_DIR_, 'css_dir' => $protocol_content . $server_host . _THEME_CSS_DIR_, 'js_dir' => $protocol_content . $server_host . _THEME_JS_DIR_, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'pic_dir' => $protocol_content . $server_host . _THEME_PROD_PIC_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . htmlentities($_SERVER['REQUEST_URI']), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'cart_qties' => intval($cart->nbProducts()), 'cart' => $cart, 'currencies' => Currency::getCurrencies(), 'id_currency_cookie' => intval($currency->id), 'currency' => $currency, 'cookie' => $cookie, 'languages' => Language::getLanguages(), 'logged' => $cookie->isLogged(), 'page_name' => $page_name, 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false, 'priceDisplay' => intval($cookie->id_customer ? Group::getPriceDisplayMethod(intval($cookie->id_customer)) : Group::getDefaultPriceDisplayMethod()), 'roundMode' => intval(Configuration::get('PS_PRICE_ROUND_MODE'))));
} else {
    $protocol = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
    $smarty->assign(array('base_dir' => __PS_BASE_URI__, 'base_dir_ssl' => Tools::getHttpHost(true, true) . __PS_BASE_URI__, 'content_dir' => __PS_BASE_URI__, 'protocol' => $protocol, 'img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . htmlentities($_SERVER['REQUEST_URI']), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'cart_qties' => intval($cart->nbProducts()), 'cart' => $cart, 'currencies' => Currency::getCurrencies(), 'id_currency_cookie' => intval($currency->id), 'currency' => $currency, 'cookie' => $cookie, 'languages' => Language::getLanguages(), 'logged' => $cookie->isLogged(), 'priceDisplay' => intval($cookie->id_customer ? Group::getPriceDisplayMethod(intval($cookie->id_customer)) : Group::getDefaultPriceDisplayMethod()), 'page_name' => $page_name, 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false, 'roundMode' => intval(Configuration::get('PS_PRICE_ROUND_MODE'))));
}
/* Display a maintenance page if shop is closed */
if (isset($maintenance) and (!isset($_SERVER['REMOTE_ADDR']) or !in_array($_SERVER['REMOTE_ADDR'], explode(',', Configuration::get('PS_MAINTENANCE_IP'))))) {
    header('HTTP/1.1 503 temporarily overloaded');
    $smarty->display(_PS_THEME_DIR_ . 'maintenance.tpl');
    exit;
}
Ejemplo n.º 2
0
 public function init()
 {
     global $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     $css_files = array();
     $js_files = array();
     if ($this->ssl and (empty($_SERVER['HTTPS']) or strtolower($_SERVER['HTTPS']) == 'off') and Configuration::get('PS_SSL_ENABLED')) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
         exit;
     }
     ob_start();
     /* Loading default country */
     $defaultCountry = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
     $cookie = new Cookie('ps');
     $link = new Link();
     if ($this->auth and !$cookie->isLogged($this->guestAllowed)) {
         Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
     }
     /* Theme is missing or maintenance */
     if (!is_dir(_PS_THEME_DIR_)) {
         die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
     } elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' and !(int) Configuration::get('PS_SHOP_ENABLE')) {
         $this->maintenance = true;
     } elseif (Configuration::get('PS_GEOLOCATION_ENABLED')) {
         if (!isset($cookie->iso_code_country)) {
             if ($cookie->logged) {
                 $id_country = Customer::getCurrentCountry((int) $cookie->id_customer);
                 $cookie->iso_code_country = Country::getIsoById($id_country);
             } else {
                 $this->geolocationManagement();
             }
         }
         if (!isset($cookie->iso_code_country)) {
             $current_country_id = Customer::getCurrentCountry((int) $cookie->id_customer);
         } else {
             $current_country_id = Country::getByIso($cookie->iso_code_country);
         }
         $current_country = new Country($current_country_id, 1);
         $cookie->id_country = $current_country->id;
         $smarty->assign('current_country', $current_country->name);
         $smarty->assign('current_country_id', $current_country->id);
         if ($cookie->id_country == 110 && !isset($cookie->id_currency)) {
             $cookie->id_currency = 4;
         }
     }
     //set imagesize if not set
     if (!isset($cookie->image_size)) {
         $cookie->image_size = IMAGE_SIZE_LARGE;
         $cookie->write();
     }
     if (!isset($cookie->greetings) && !$cookie->logged) {
         $cookie->greetings = 1;
         $cookie->write();
         $smarty->assign('show_greetings', 1);
     }
     //echo $cookie->image_size;
     if ($image_size = Tools::getValue("is")) {
         if ($image_size == "s" && $cookie->image_size == IMAGE_SIZE_LARGE) {
             $cookie->image_size = IMAGE_SIZE_SMALL;
             $cookie->write();
         } else {
             if ($image_size == "l" && $cookie->image_size == IMAGE_SIZE_SMALL) {
                 $cookie->image_size = IMAGE_SIZE_LARGE;
                 $cookie->write();
             }
         }
     }
     // Switch language if needed and init cookie language
     if ($iso = Tools::getValue('isolang') and Validate::isLanguageIsoCode($iso) and $id_lang = (int) Language::getIdByIso($iso)) {
         $_GET['id_lang'] = $id_lang;
     }
     Tools::switchLanguage();
     Tools::setCookieLanguage();
     /* attribute id_lang is often needed, so we create a constant for performance reasons */
     if (!defined('_USER_ID_LANG_')) {
         define('_USER_ID_LANG_', (int) $cookie->id_lang);
     }
     if (isset($_GET['logout']) or $cookie->logged and Customer::isBanned((int) $cookie->id_customer)) {
         $cookie->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
     } elseif (isset($_GET['mylogout'])) {
         $this->logoutFacebook();
         $cookie->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
     }
     if ($source = Tools::getValue('utm_source')) {
         $cookie->last_source = $source;
         $cookie->write();
     }
     if ($ref_source = Tools::getValue('vbref')) {
         $cookie->last_ref_source = $ref_source;
         $cookie->write();
     }
     /*else 
     		{
     			if(!isset($cookie->last_ref_source))
     			{
     				$cookie->last_ref_source = 0;
     				$cookie->write();
     			}
     		}*/
     global $currency;
     $currency = Tools::setCurrency();
     $_MODULES = array();
     /* Cart already exists */
     if ((int) $cookie->id_cart) {
         $cart = new Cart((int) $cookie->id_cart);
         if ($cart->OrderExists()) {
             unset($cookie->id_cart, $cart, $cookie->checkedTOS);
         } elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) and !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) and $cart->nbProducts() and intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 and !self::isInWhitelistForGeolocation()) {
             unset($cookie->id_cart, $cart);
         } elseif ($cookie->id_customer != $cart->id_customer or $cookie->id_lang != $cart->id_lang or $cookie->id_currency != $cart->id_currency) {
             if ($cookie->id_customer) {
                 $cart->id_customer = (int) $cookie->id_customer;
             }
             $cart->id_lang = (int) $cookie->id_lang;
             $cart->id_currency = (int) $cookie->id_currency;
             $cart->update();
         }
         /* Select an address if not set */
         if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $cookie->id_customer) {
             $to_update = false;
             if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
                 $to_update = true;
                 $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
                 $to_update = true;
                 $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if ($to_update) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) or !$cart->id) {
         $this->checkIDS();
         $cart = new Cart();
         $cart->id_lang = (int) $cookie->id_lang;
         $cart->id_currency = (int) $cookie->id_currency;
         $cart->id_guest = (int) $cookie->id_guest;
         if ($cookie->id_customer) {
             $cart->id_customer = (int) $cookie->id_customer;
             $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             $cart->id_address_invoice = $cart->id_address_delivery;
         } else {
             $cart->id_address_delivery = 0;
             $cart->id_address_invoice = 0;
         }
     }
     if (!$cart->nbProducts()) {
         $cart->id_carrier = NULL;
     }
     $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')) . '_' . strtoupper(Configuration::get('PS_LOCALE_COUNTRY') . '.UTF-8');
     setlocale(LC_COLLATE, $locale);
     setlocale(LC_CTYPE, $locale);
     setlocale(LC_TIME, $locale);
     setlocale(LC_NUMERIC, 'en_US.UTF-8');
     if (Validate::isLoadedObject($currency)) {
         $smarty->ps_currency = $currency;
     }
     if (Validate::isLoadedObject($ps_language = new Language((int) $cookie->id_lang))) {
         $smarty->ps_language = $ps_language;
     }
     /* get page name to display it in body id */
     $pathinfo = pathinfo(__FILE__);
     $page_name = basename($_SERVER['PHP_SELF'], '.' . $pathinfo['extension']);
     $page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
     $smarty->assign(Tools::getMetaTags($cookie->id_lang, $page_name));
     $smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
     /* Breadcrumb */
     $navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
     $smarty->assign('navigationPipe', $navigationPipe);
     $protocol_link = (Configuration::get('PS_SSL_ENABLED') or !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
     $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED') or !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
     if (!defined('_PS_BASE_URL_')) {
         define('_PS_BASE_URL_', Tools::getShopDomain(true));
     }
     if (!defined('_PS_BASE_URL_SSL_')) {
         define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
     }
     $link->preloadPageLinks();
     $this->canonicalRedirection();
     Product::initPricesComputation();
     $display_tax_label = $defaultCountry->display_tax_label;
     if ($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) {
         $infos = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
         $country = new Country((int) $infos['id_country']);
         if (Validate::isLoadedObject($country)) {
             $display_tax_label = $country->display_tax_label;
         }
     }
     global $isBetaUser, $conversion_rate_inr;
     $conversion_rate_inr = 55;
     if (!$cookie->isLogged()) {
         $this->initFacebook();
     } else {
         $customer_groups = Customer::getGroupsStatic((int) $cookie->id_customer);
         if (in_array(2, $customer_groups)) {
             $smarty->assign('internal_vb_user', 1);
         }
         if (in_array(3, $customer_groups)) {
             $isBetaUser = true;
         } else {
             $isBetaUser = false;
         }
         /*$reward_points = VBRewards::getCustomerPoints($cookie->id_customer);
         		$can_redeem = VBRewards::checkPointsValidity($cookie->id_customer, 0);
         		if($can_redeem)
                                    $smarty->assign('can_redeem_points', 1);
         		$smarty->assign('balance_points', $reward_points);*/
     }
     $smarty->assign('img_version', IMG_VERSION);
     $this->setRecaptchaHTML();
     if ($page_name === "index") {
         $sql = "select title,image_path,url from ps_banner where is_active = 1 order by display_order asc";
         $home_banners = Db::getInstance()->ExecuteS($sql);
         $smarty->assign("home_banners", $home_banners);
     }
     $smarty->assign(array('lazy' => 1, 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $cookie, 'page_name' => $page_name, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getShopDomain() . __PS_BASE_URI__, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => Language::getLanguages(), 'priceDisplay' => Product::getTaxCalculationMethod(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE'), 'conversion_rate' => $conversion_rate_inr));
     // Deprecated
     $smarty->assign(array('id_currency_cookie' => (int) $currency->id, 'logged' => $cookie->isLogged(), 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false));
     // TODO for better performances (cache usage), remove these assign and use a smarty function to get the right media server in relation to the full ressource name
     $assignArray = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_);
     foreach ($assignArray as $assignKey => $assignValue) {
         if (substr($assignValue, 0, 1) == '/' or $protocol_content == 'https://') {
             $smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue);
         } else {
             $smarty->assign($assignKey, $assignValue);
         }
     }
     // setting properties from global var
     self::$cookie = $cookie;
     self::$cart = $cart;
     self::$smarty = $smarty;
     self::$link = $link;
     if ($this->maintenance) {
         $this->displayMaintenancePage();
     }
     if ($this->restrictedCountry) {
         $this->displayRestrictedCountryPage();
     }
     //live edit
     if (Tools::isSubmit('live_edit') and $ad = Tools::getValue('ad') and Tools::getValue('liveToken') == sha1(Tools::getValue('ad') . _COOKIE_KEY_)) {
         if (!is_dir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $ad)) {
             die(Tools::displayError());
         }
     }
     $this->iso = $iso;
     $this->setMedia();
     //For sokrati pixel
     self::$smarty->assign("new_customer_regd", false);
     if ((int) self::$cookie->new_reg === 1) {
         self::$smarty->assign("new_customer_regd", true);
         unset(self::$cookie->new_reg);
     }
     if (self::$cookie->id_customer) {
         self::$smarty->assign("balance_points", VBRewards::getCustomerPoints(self::$cookie->id_customer));
     }
 }
Ejemplo n.º 3
0
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 6594 $
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/init.php';
$cookie = new Cookie('ps');
if (!$cookie->isLogged()) {
    Tools::redirect('authentication.php?back=order-follow.php');
}
if (isset($_GET['id_order_slip']) and Validate::isUnsignedId($_GET['id_order_slip'])) {
    $orderSlip = new OrderSlip((int) $_GET['id_order_slip']);
}
if (!isset($orderSlip) or !Validate::isLoadedObject($orderSlip)) {
    die(Tools::displayError('Order return not found'));
} elseif ($orderSlip->id_customer != $cookie->id_customer) {
    die(Tools::displayError('Order return not found'));
}
$order = new Order((int) $orderSlip->id_order);
if (!Validate::isLoadedObject($order)) {
    die(Tools::displayError('Order not found'));
}
$order->products = OrderSlip::getOrdersSlipProducts((int) $orderSlip->id, $order);
Ejemplo n.º 4
0
define('_COOKIE_KEY_', 'MeUFIDgbWnPp7Ffj708TG40Jj7TNBLvoEOa0ZhQFKBvzGV2MbRMHScUn');
define('_COOKIE_IV_', '5DvPoNt2');
/*基本设置*/
@ini_set('display_errors', 'on');
date_default_timezone_set('PRC');
define('_TM_MODE_DEV_', false);
require dirname(__FILE__) . '/init.php';
Db::getInstance();
Configuration::loadConfiguration();
if (Configuration::get('TM_SHOP_DOMAIN') != $_SERVER['HTTP_HOST']) {
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
    exit;
}
$cookie = new Cookie();
$cookie->isLogged();
if (isset($cookie->id_cart) && !Cart::cartIsOrder($cookie->id_cart)) {
    $cart = new Cart((int) $cookie->id_cart);
    if (!Validate::isLoadedObject($cart)) {
        unset($cart);
        unset($cookie->id_cart);
    }
}
if ($id_currency = Tools::getRequest('id_currency')) {
    $currency = new Currency((int) $id_currency);
    $cookie->id_currency = $id_currency;
    $cookie->write();
    if (isset($cart) && Validate::isLoadedObject($cart)) {
        $cart->id_currency = (int) $id_currency;
        $cart->update();
    }
Ejemplo n.º 5
0
        if (!empty($newFileName)) {
            $filename = Tools::getValue('filename');
        } else {
            $filename = 'file';
        }
    }
    if (!file_exists($file)) {
        Tools::redirect('index.php');
    }
} else {
    if (!($key = Tools::getValue('key'))) {
        displayError('Invalid key.');
    }
    $cookie = new Cookie('ps');
    Tools::setCookieLanguage();
    if (!$cookie->isLogged() and !Tools::getValue('secure_key') and !Tools::getValue('id_order')) {
        Tools::redirect('authentication.php?back=get-file.php&key=' . $key);
    } elseif (!$cookie->isLogged() and Tools::getValue('secure_key') and Tools::getValue('id_order')) {
        $order = new Order((int) Tools::getValue('id_order'));
        if (!Validate::isLoadedObject($order)) {
            displayError('Invalid key.');
        }
        if ($order->secure_key != Tools::getValue('secure_key')) {
            displayError('Invalid key.');
        }
    }
    /* Key format: <sha1-filename>-<hashOrder> */
    $tmp = explode('-', $key);
    if (sizeof($tmp) != 2) {
        displayError('Invalid key.');
    }
Ejemplo n.º 6
0
 public function init()
 {
     global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     // If current URL use SSL, set it true (used a lot for module redirect)
     if (Tools::usingSecureMode()) {
         $useSSL = $this->ssl = true;
     }
     $css_files = array();
     $js_files = array();
     if ($this->ssl && !Tools::usingSecureMode() && _PS_SSL_ENABLED_) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Cache-Control: no-cache');
         header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
         exit;
     } elseif (_PS_SSL_ENABLED_ && Tools::usingSecureMode() && !$this->ssl) {
         header('HTTP/1.1 301 Moved Permanently');
         header('Cache-Control: no-cache');
         header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
         exit;
     }
     ob_start();
     /* Loading default country */
     $defaultCountry = new Country((int) _PS_COUNTRY_DEFAULT_, (int) _PS_LANG_DEFAULT_);
     $cookie = new Cookie('ps', '', time() + ((int) Configuration::get('PS_COOKIE_LIFETIME_FO') > 0 ? (int) Configuration::get('PS_COOKIE_LIFETIME_FO') : 1) * 3600);
     $link = new Link();
     if ($this->auth && !$cookie->isLogged($this->guestAllowed)) {
         Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
     }
     /* Theme is missing or maintenance */
     if (!file_exists(_PS_THEME_DIR_)) {
         die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
     } elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' && !(int) Configuration::get('PS_SHOP_ENABLE')) {
         $this->maintenance = true;
     } elseif (_PS_GEOLOCATION_ENABLED_) {
         $this->geolocationManagement();
     }
     // Switch language if needed and init cookie language
     $iso = Tools::getValue('isolang');
     if ($iso && Validate::isLanguageIsoCode($iso)) {
         $id_lang = (int) Language::getIdByIso($iso);
         if ($id_lang) {
             $_GET['id_lang'] = $id_lang;
         }
     }
     Tools::switchLanguage();
     Tools::setCookieLanguage();
     /* attribute id_lang is often needed, so we create a constant for performance reasons */
     if (!defined('_USER_ID_LANG_')) {
         define('_USER_ID_LANG_', (int) $cookie->id_lang);
     }
     if (isset($_GET['logout']) || $cookie->logged && Customer::isBanned((int) $cookie->id_customer)) {
         $cookie->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $cookie->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     global $currency;
     $currency = Tools::setCurrency();
     /* Cart already exists */
     if ((int) $cookie->id_cart) {
         $cart = new Cart((int) $cookie->id_cart);
         if ($cart->OrderExists()) {
             unset($cookie->id_cart, $cart, $cookie->checkedTOS);
         } elseif (_PS_GEOLOCATION_ENABLED_ && !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && (int) Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') != -1 && !self::isInWhitelistForGeolocation()) {
             unset($cookie->id_cart, $cart);
         } elseif ($cookie->id_customer != $cart->id_customer || $cookie->id_lang != $cart->id_lang || $cookie->id_currency != $cart->id_currency) {
             if ($cookie->id_customer) {
                 $cart->id_customer = (int) $cookie->id_customer;
             }
             $cart->id_lang = (int) $cookie->id_lang;
             $cart->id_currency = (int) $cookie->id_currency;
             $cart->update();
         }
         /* Select an address if not set */
         if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $cookie->id_customer) {
             $to_update = false;
             if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
                 $to_update = true;
                 $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
                 $to_update = true;
                 $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if ($to_update) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) || !$cart->id) {
         $cart = new Cart();
         $cart->id_lang = (int) $cookie->id_lang;
         $cart->id_currency = (int) $cookie->id_currency;
         $cart->id_guest = (int) $cookie->id_guest;
         if ($cookie->id_customer) {
             $cart->id_customer = (int) $cookie->id_customer;
             $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             $cart->id_address_invoice = $cart->id_address_delivery;
         } else {
             $cart->id_address_delivery = 0;
             $cart->id_address_invoice = 0;
         }
     }
     if (!$cart->nbProducts()) {
         $cart->id_carrier = null;
     }
     $locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')) . '_' . strtoupper(Configuration::get('PS_LOCALE_COUNTRY') . '.UTF-8');
     setlocale(LC_COLLATE, $locale);
     setlocale(LC_CTYPE, $locale);
     setlocale(LC_TIME, $locale);
     setlocale(LC_NUMERIC, 'en_US.UTF-8');
     if (Validate::isLoadedObject($currency)) {
         $smarty->ps_currency = $currency;
     }
     if (Validate::isLoadedObject($ps_language = new Language((int) $cookie->id_lang))) {
         $smarty->ps_language = $ps_language;
     }
     /* get page name to display it in body id */
     $page_name = isset($this->php_self) ? preg_replace('/\\.php$/', '', $this->php_self) : '';
     if (preg_match('#^' . __PS_BASE_URI__ . '(|' . ((int) Configuration::get('PS_REWRITING_SETTINGS') && isset($smarty->ps_language) && !empty($smarty->ps_language) ? $smarty->ps_language->iso_code . '/' : '') . ')modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
         $page_name = 'module-' . $m[2] . '-' . str_replace(array('.php', '/'), array('', '-'), $m[3]);
     }
     $smarty->assign(Tools::getMetaTags($cookie->id_lang, $page_name));
     $protocol_link = _PS_SSL_ENABLED_ || Tools::usingSecureMode() ? 'https://' : 'http://';
     $useSSL = isset($this->ssl) && $this->ssl && _PS_SSL_ENABLED_ || Tools::usingSecureMode();
     $protocol_content = $useSSL ? 'https://' : 'http://';
     if (!defined('_PS_BASE_URL_')) {
         define('_PS_BASE_URL_', Tools::getShopDomain(true));
     }
     if (!defined('_PS_BASE_URL_SSL_')) {
         define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
     }
     $link->preloadPageLinks();
     $this->canonicalRedirection();
     Product::initPricesComputation();
     $display_tax_label = $defaultCountry->display_tax_label;
     if (Validate::isLoadedObject($cart) && ($tmp = (int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})) {
         $infos = Address::getCountryAndState($tmp);
         $country = new Country((int) $infos['id_country']);
         if (Validate::isLoadedObject($country)) {
             $display_tax_label = $country->display_tax_label;
         }
     }
     $smarty->assign(array('request_uri' => Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])), 'navigationPipe' => Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>', 'link' => $link, 'cart' => $cart, 'currency' => $currency, 'cookie' => $cookie, 'page_name' => $page_name, 'base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__, 'content_dir' => $protocol_content . Tools::getHttpHost() . __PS_BASE_URI__, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'cart_qties' => (int) $cart->nbProducts(), 'currencies' => Currency::getCurrencies(), 'languages' => Language::getLanguages(), 'priceDisplay' => Product::getTaxCalculationMethod(), 'add_prod_display' => (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'roundMode' => (int) Configuration::get('PS_PRICE_ROUND_MODE'), 'use_taxes' => (int) Configuration::get('PS_TAX'), 'display_tax_label' => (bool) $display_tax_label, 'vat_management' => (int) Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool) Configuration::get('PS_CATALOG_MODE'), 'id_currency_cookie' => (int) $currency->id, 'logged' => $cookie->isLogged(), 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false));
     // TODO for better performances (cache usage), remove these assign and use a smarty function to get the right media server in relation to the full ressource name
     $assignArray = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_);
     foreach ($assignArray as $assignKey => $assignValue) {
         if (substr($assignValue, 0, 1) == '/' || $protocol_content == 'https://') {
             $smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue);
         } else {
             $smarty->assign($assignKey, $assignValue);
         }
     }
     // setting properties from global var
     self::$cookie = $cookie;
     self::$cart = $cart;
     self::$smarty = $smarty;
     self::$link = $link;
     if ($this->maintenance) {
         $this->displayMaintenancePage();
     }
     if ($this->restrictedCountry) {
         $this->displayRestrictedCountryPage();
     }
     /* Check Live Edit parameters */
     if (Tools::isSubmit('live_edit')) {
         $ad = Tools::getValue('ad');
         if (!$ad || Tools::getValue('liveToken') != sha1($ad . _COOKIE_KEY_) || !is_dir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $ad)) {
             die(Tools::displayError());
         }
     }
     $this->iso = $iso;
     $this->setMedia();
 }
Ejemplo n.º 7
0
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/init.php';
$cookie = new Cookie('ps');
if (!$cookie->isLogged() and !Tools::getValue('secure_key')) {
    Tools::redirect('authentication.php?back=pdf-invoice.php');
}
if (!(int) Configuration::get('PS_INVOICE')) {
    die(Tools::displayError('Invoices are disabled in this shop.'));
}
if (isset($_GET['id_order']) and Validate::isUnsignedId($_GET['id_order'])) {
    $order = new Order((int) $_GET['id_order']);
}
if (!isset($order) or !Validate::isLoadedObject($order)) {
    die(Tools::displayError('Invoice not found'));
} elseif (isset($cookie->id_customer) and $order->id_customer != $cookie->id_customer or Tools::isSubmit('secure_key') and $order->secure_key != Tools::getValue('secure_key')) {
    die(Tools::displayError('Invoice not found'));
} elseif (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number) {
    die(Tools::displayError('No invoice available'));
} else {
Ejemplo n.º 8
0
 public function init()
 {
     global $cookie, $smarty, $iso, $defaultCountry, $protocol_link, $protocol_content, $css_files, $js_files;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     $css_files = array();
     $js_files = array();
     ob_start();
     /* Loading default country */
     $cookieLifetime = time() + ((int) Configuration::get('TAS_COOKIE_LIFETIME_FO') > 0 ? (int) Configuration::get('TAS_COOKIE_LIFETIME_FO') : 1) * 3600;
     $cookie = new Cookie('tas', '', $cookieLifetime);
     //var_dump($cookie);
     if ($this->php_self != "login.php") {
         // If calling url is not login.php then check user is logged
         if ($this->auth and !$cookie->isLogged(false)) {
             //echo "test";die;
             $this->authRedirection = urlencode($_SERVER['REQUEST_URI']);
             Tools::redirect('login.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
         }
     }
     /* Theme is missing or maintenance */
     if (!is_dir(_TAS_THEME_DIR_)) {
         die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
     }
     Tools::setCookieLanguage();
     /* attribute LanguageID is often needed, so we create a constant for performance reasons */
     if (!defined('_USER_ID_LANG_')) {
         define('_USER_ID_LANG_', (int) $cookie->LanguageID);
     }
     if (isset($_GET['logout']) or $cookie->logged and Member::isBanned((int) $cookie->UserID)) {
         $cookie->logout();
         Tools::redirect("index.php");
     } elseif (isset($_GET['mylogout'])) {
         $cookie->mylogout();
         Tools::redirect("index.php");
     }
     if (Validate::isLoadedObject($tas_language = new Language((int) $cookie->LanguageID))) {
         $smarty->tas_language = $tas_language;
     }
     $iso = $tas_language->LanguageShortName;
     /* get page name to display it in body id */
     $page_name = isset($this->php_self) ? preg_replace('/\\.php$/', '', $this->php_self) : '';
     $smarty->assign(Tools::getMetaTags($cookie->LanguageID, $page_name));
     $smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
     $protocol_link = 'http://';
     $protocol_content = 'http://';
     $smarty->assign(array('cookie' => $cookie, 'page_name' => $page_name, 'base_dir' => __TAS_BASE_URI__, 'tpl_dir' => _TAS_THEME_DIR_, 'lang_iso' => $iso, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'languages' => Tools::getLanguages(), 'sl_lang' => $cookie->LanguageID, 'shop_name' => 'TAS'));
     // Deprecated
     $smarty->assign(array('logged' => $cookie->isLogged(), 'userName' => $cookie->logged ? $cookie->LoginUserName : false));
     // TODO for better performances (cache usage), remove these assign and use a smarty function to get the right media server in relation to the full ressource name
     $assignArray = array('img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_);
     foreach ($assignArray as $assignKey => $assignValue) {
         $smarty->assign($assignKey, $assignValue);
     }
     // setting properties from global var
     self::$cookie = $cookie;
     self::$smarty = $smarty;
     $this->iso = $iso == "" ? "en" : $iso;
     $this->setMedia();
 }
Ejemplo n.º 9
0
setlocale(LC_CTYPE, strtolower($ps_language->iso_code) . '_' . strtoupper($ps_language->iso_code) . '.UTF-8');
setlocale(LC_NUMERIC, 'en_EN.UTF-8');
if (is_object($currency)) {
    $smarty->ps_currency = $currency;
}
if (is_object($ps_language)) {
    $smarty->ps_language = $ps_language;
}
$smarty->register_function('dateFormat', array('Tools', 'dateFormat'));
$smarty->register_function('productPrice', array('Product', 'productPrice'));
$smarty->register_function('convertPrice', array('Product', 'convertPrice'));
$smarty->register_function('convertPriceWithoutDisplay', array('Product', 'productPriceWithoutDisplay'));
$smarty->register_function('convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
$smarty->register_function('displayWtPrice', array('Product', 'displayWtPrice'));
$smarty->register_function('displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
$smarty->register_function('displayPrice', array('Tools', 'displayPriceSmarty'));
$smarty->assign(Tools::getMetaTags(intval($cookie->id_lang)));
$smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
/* Breadcrumb */
$navigationPipe = Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>';
$smarty->assign('navigationPipe', $navigationPipe);
/* Server Params */
$server_host = htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8');
$protocol = 'http://';
$protocol_ssl = 'https://';
$protocol_link = Configuration::get('PS_SSL_ENABLED') ? $protocol_ssl : $protocol;
$protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol;
define('_PS_BASE_URL_', $protocol . $server_host);
define('_PS_BASE_URL_SSL_', $protocol_ssl . $server_host);
$smarty->assign(array('base_dir' => _PS_BASE_URL_ . __PS_BASE_URI__, 'base_dir_ssl' => $protocol_link . $server_host . __PS_BASE_URI__, 'content_dir' => $protocol_content . $server_host . __PS_BASE_URI__, 'img_ps_dir' => $protocol_content . $server_host . _PS_IMG_, 'img_cat_dir' => $protocol_content . $server_host . _THEME_CAT_DIR_, 'img_lang_dir' => $protocol_content . $server_host . _THEME_LANG_DIR_, 'img_prod_dir' => $protocol_content . $server_host . _THEME_PROD_DIR_, 'img_manu_dir' => $protocol_content . $server_host . _THEME_MANU_DIR_, 'img_sup_dir' => $protocol_content . $server_host . _THEME_SUP_DIR_, 'img_ship_dir' => $protocol_content . $server_host . _THEME_SHIP_DIR_, 'img_col_dir' => $protocol_content . $server_host . _THEME_COL_DIR_, 'img_dir' => $protocol_content . $server_host . _THEME_IMG_DIR_, 'css_dir' => $protocol_content . $server_host . _THEME_CSS_DIR_, 'js_dir' => $protocol_content . $server_host . _THEME_JS_DIR_, 'tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => _MODULE_DIR_, 'mail_dir' => _MAIL_DIR_, 'pic_dir' => $protocol_content . $server_host . _THEME_PROD_PIC_DIR_, 'lang_iso' => $ps_language->iso_code, 'come_from' => 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . htmlentities($_SERVER['REQUEST_URI']), 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'cart_qties' => intval($cart->nbProducts()), 'cart' => $cart, 'currencies' => Currency::getCurrencies(), 'id_currency_cookie' => intval($currency->id), 'currency' => $currency, 'cookie' => $cookie, 'languages' => Language::getLanguages(), 'logged' => $cookie->isLogged(), 'page_name' => $page_name, 'customerName' => $cookie->logged ? $cookie->customer_firstname . ' ' . $cookie->customer_lastname : false, 'priceDisplay' => intval(Configuration::get('PS_PRICE_DISPLAY'))));
Ejemplo n.º 10
0
        </p>
    </div>
    <div style="width:300px;float:left;margin-left:20px;">

        <table style="border-collapse: collapse;border-spacing: 0;width:100%" id="loyalty-activities" class="std">
            <thead>
                <tr style="border-bottom: 1px dashed #cacaca;padding:5px 0">
                    <th style="font-size:14px;text-align:left;text-transform:none;width:80%">Activity</th>
                    <th style="font-size:14px;text-align:center;text-transform:none;width:20%">Coins</th>
                </tr>
            </thead>
            <tbody>
                <tr class="first_item">
                    <?php 
$cookie = new Cookie('ps');
if ($cookie->isLogged(true)) {
    echo '<td>Sign-Up/Registration</td>';
} else {
    echo '<td><a rel="nofollow" id="login_link" class="fancybox login_link" href="#login_modal_panel">Sign-Up/Registration</a> </td>';
}
?>
                    <td> 50 </td>
                </tr>
                <?php 
$i = 2;
$count = count($activity_Coins);
foreach ($activity_Coins as $activity => $Coins) {
    $class = '';
    if ($i == 1) {
        $class = " first_item";
    }