本文整理汇总了PHP中Tools::getProtocol方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::getProtocol方法的具体用法?PHP Tools::getProtocol怎么用?PHP Tools::getProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::getProtocol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canonicalRedirection
public function canonicalRedirection()
{
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
if (Validate::isLoadedObject($this->cms) and $canonicalURL = self::$link->getCMSLink($this->cms)) {
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
header('Cache-Control: no-cache');
if (_PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
if (Validate::isLoadedObject($this->cms_category) and $canonicalURL = self::$link->getCMSCategoryLink($this->cms_category)) {
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
header('Cache-Control: no-cache');
if (_PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
}
}
示例2: preProcess
public function preProcess()
{
if ($id_category = (int) Tools::getValue('id_category')) {
$this->category = new Category($id_category, self::$cookie->id_lang);
}
if (!Validate::isLoadedObject($this->category)) {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
} else {
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
$currentURL = self::$link->getCategoryLink($this->category);
$currentURL = preg_replace('/[?&].*$/', '', $currentURL);
if (!preg_match('/^' . Tools::pRegexp($currentURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $currentURL . '">' . $currentURL . '</a>');
}
Tools::redirectLink($currentURL);
}
}
parent::preProcess();
if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
if ($id_category = (int) Tools::getValue('id_category')) {
$rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
$default_rewrite = array();
foreach ($rewrite_infos as $infos) {
$default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
}
self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
}
}
}
示例3: assign
/**
* Assign wishlist template
*/
public function assign()
{
$errors = array();
if ($this->context->customer->isLogged()) {
$add = Tools::getIsset('add');
$add = empty($add) === false ? 1 : 0;
$delete = Tools::getIsset('deleted');
$delete = empty($delete) === false ? 1 : 0;
$id_wishlist = Tools::getValue('id_wishlist');
if (Tools::isSubmit('submitWishlist')) {
if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 and strcmp(Tools::getToken(), Tools::getValue('token'))) {
$errors[] = $this->module->l('Invalid token', 'mywishlist');
}
if (!sizeof($errors)) {
$name = Tools::getValue('name');
if (empty($name)) {
$errors[] = $this->module->l('You must specify a name.', 'mywishlist');
}
if (WishList::isExistsByNameForUser($name)) {
$errors[] = $this->module->l('This name is already used by another list.', 'mywishlist');
}
if (!sizeof($errors)) {
$wishlist = new WishList();
$wishlist->id_shop = $this->context->shop->id;
$wishlist->id_shop_group = $this->context->shop->id_shop_group;
$wishlist->name = $name;
$wishlist->id_customer = (int) $this->context->customer->id;
list($us, $s) = explode(' ', microtime());
srand($s * $us);
$wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $this->context->customer->id), 0, 16));
$wishlist->add();
Mail::Send($this->context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $this->context->language->id), array('{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist->token), $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, $this->module->getLocalPath() . 'mails/');
}
}
} else {
if ($add) {
WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id);
} else {
if ($delete and empty($id_wishlist) === false) {
$wishlist = new WishList((int) $id_wishlist);
if (Validate::isLoadedObject($wishlist)) {
$wishlist->delete();
} else {
$errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist');
}
}
}
}
$this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id));
$this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id));
} else {
Tools::redirect('index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist')));
}
$this->context->smarty->assign(array('id_customer' => (int) $this->context->customer->id, 'errors' => $errors, 'form_link' => $errors));
$this->setTemplate('mywishlist.tpl');
}
示例4: canonicalRedirection
public function canonicalRedirection()
{
if (Validate::isLoadedObject($this->manufacturer) && Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
$canonicalURL = self::$link->getManufacturerLink($this->manufacturer);
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
}
示例5: canonicalRedirection
public function canonicalRedirection()
{
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if (Validate::isLoadedObject($this->product) && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
$canonicalURL = self::$link->getProductLink($this->product);
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
}
示例6: __construct
function __construct()
{
$this->name = 'socolissimo';
$this->tab = 'shipping_logistics';
$this->version = '2.3';
$this->author = 'PrestaShop';
$this->limited_countries = array('fr');
parent::__construct();
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('So Colissimo');
$this->description = $this->l('Offer your customers, different delivery methods with LaPoste.');
$this->url = Tools::getProtocol() . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/' . $this->name . '/validation.php';
/** Backward compatibility */
require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
if (self::isInstalled($this->name)) {
$ids = array();
$warning = array();
$soCarrier = new Carrier(Configuration::get('SOCOLISSIMO_CARRIER_ID'));
if (Validate::isLoadedObject($soCarrier)) {
if (!$this->checkZone((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier Zone(s)\'') . ' ';
}
if (!$this->checkGroup((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier Group\'') . ' ';
}
if (!$this->checkRange((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier Range(s)\'') . ' ';
}
if (!$this->checkDelivery((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier price delivery\'') . ' ';
}
}
//Check config and display warning
if (!Configuration::get('SOCOLISSIMO_ID')) {
$warning[] .= $this->l('\'Id FO\'') . ' ';
}
if (!Configuration::get('SOCOLISSIMO_KEY')) {
$warning[] .= $this->l('\'Key\'') . ' ';
}
if (!Configuration::get('SOCOLISSIMO_URL')) {
$warning[] .= $this->l('\'Url So\'') . ' ';
}
if (count($warning)) {
$this->warning .= implode(' , ', $warning) . $this->l('must be configured to use this module correctly') . ' ';
}
}
$this->errorMessage = array('998' => $this->l('Invalid key'), '999' => $this->l('Error occurred during shipping step.'), '001' => $this->l('Login FO missing'), '002' => $this->l('Login FO incorrect'), '003' => $this->l('Customer unauthorized'), '004' => $this->l('Required field missing'), '006' => $this->l('Missing signature'), '007' => $this->l('Invalid signature'), '008' => $this->l('Invalid Zip/ Postal code'), '009' => $this->l('Incorrect url format return validation.'), '010' => $this->l('Incorrect url format return error.'), '011' => $this->l('Invalid transaction ID.'), '012' => $this->l('Format incorrect shipping costs.'), '015' => $this->l('Socolissimo server unavailable.'), '016' => $this->l('Socolissimo server unavailable.'), '004' => $this->l('Required field missing'), '004' => $this->l('Required field missing'));
}
示例7: __construct
function __construct()
{
$this->name = 'socolissimo';
$this->tab = 'shipping_logistics';
$this->version = '2.7.6';
$this->author = 'PrestaShop';
$this->limited_countries = array('fr');
$this->module_key = 'faa857ecf7579947c8eee2d9b3d1fb04';
parent::__construct();
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('So Colissimo');
$this->description = $this->l('Offer your customer 5 different delivery methods with LaPoste.');
$this->url = Tools::getProtocol() . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/' . $this->name . '/validation.php';
/** Backward compatibility */
require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
if (self::isInstalled($this->name)) {
$warning = array();
$soCarrier = new Carrier(Configuration::get('SOCOLISSIMO_CARRIER_ID'));
if (Validate::isLoadedObject($soCarrier)) {
if (!$this->checkZone((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier Zone(s)\'') . ' ';
}
if (!$this->checkGroup((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier Group\'') . ' ';
}
if (!$this->checkRange((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier Range(s)\'') . ' ';
}
if (!$this->checkDelivery((int) $soCarrier->id)) {
$warning[] .= $this->l('\'Carrier price delivery\'') . ' ';
}
}
//Check config and display warning
if (!Configuration::get('SOCOLISSIMO_ID')) {
$warning[] .= $this->l('\'Id FO\'') . ' ';
}
if (!Configuration::get('SOCOLISSIMO_KEY')) {
$warning[] .= $this->l('\'Key\'') . ' ';
}
if (!Configuration::get('SOCOLISSIMO_URL')) {
$warning[] .= $this->l('\'Url So\'') . ' ';
}
if (count($warning)) {
$this->warning .= implode(' , ', $warning) . $this->l('must be configured to use this module correctly') . ' ';
}
}
}
示例8: preProcess
public function preProcess()
{
if ($id_cms = (int) Tools::getValue('id_cms')) {
$this->cms = new CMS($id_cms, self::$cookie->id_lang);
} elseif ($id_cms_category = (int) Tools::getValue('id_cms_category')) {
$this->cms_category = new CMSCategory($id_cms_category, self::$cookie->id_lang);
}
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if ($this->cms and $canonicalURL = self::$link->getCMSLink($this->cms)) {
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
if (defined(_PS_MODE_DEV_) and _PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
if ($this->cms_category and $canonicalURL = self::$link->getCMSCategoryLink($this->cms_category)) {
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) {
header('HTTP/1.0 301 Moved');
if (_PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
parent::preProcess();
/* assignCase (1 = CMS page, 2 = CMS category) */
if (Validate::isLoadedObject($this->cms) and ($this->cms->active or Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS' . $this->cms->id) and file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php'))) {
$this->assignCase = 1;
} elseif (Validate::isLoadedObject($this->cms_category)) {
$this->assignCase = 2;
} else {
Tools::redirect('404.php');
}
if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
$rewrite_infos = (isset($id_cms) and !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
$default_rewrite = array();
foreach ($rewrite_infos as $infos) {
$arr_link = (isset($id_cms) and !isset($id_cms_category)) ? self::$link->getCMSLink($id_cms, $infos['link_rewrite'], $this->ssl, $infos['id_lang']) : self::$link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
$default_rewrite[$infos['id_lang']] = $arr_link;
}
self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
}
}
示例9: getContent
public function getContent()
{
if (Tools::isSubmit('submitLiveZilla')) {
Configuration::updateValue('LIVEZILLA_URL', Tools::getValue('LIVEZILLA_URL_TYPE') . Tools::getValue('LIVEZILLA_URL'));
Configuration::updateValue('LIVEZILLA_SCRIPT', Tools::getValue('LIVEZILLA_SCRIPT'), true);
echo $this->displayConfirmation($this->l('Settings updated'));
}
$html = '<h2>' . $this->displayName . '</h2>
<fieldset><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('How-to') . '</legend>
<img src="../modules/' . $this->name . '/lz_package.gif" style="float:right;margin-left:10px" />
' . $this->l('LiveZilla is not a hosted solution, which means that LiveZilla needs to be installed on your local computer (step 1) and on your webserver (step 2) as well.') . '
' . $this->l('The LiveZilla installation on your webserver is called the LiveZilla Server.') . '
<br /><br />
' . $this->l('Once you have finished step 1 & 2, you must fill in the URL of your LiveZilla installation below or directly copy / paste the script in the text area. This will integrate LiveZilla with your website (step 3).') . '
<br /><br />
' . $this->l('The full installation guide is available on') . ' <a href="http://www.livezilla.net/installation/" style="text-decoration:underline">' . $this->l('the official LiveZilla website') . '</a>.
<br /><br />
<a href="https://www.livezilla.net/downloads/" style="font-weight:700"><img src="../modules/' . $this->name . '/lz_download.gif" style="vertical-align:middle" /> ' . $this->l('Download LiveZilla now!') . '</a>
</fieldset>
<div class="clear"> </div>
<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post">
<fieldset><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Configuration') . '</legend>
<label>' . $this->l('Enter the URL to your LiveZilla installation') . '</label>
<div class="margin-form">
<select name="LIVEZILLA_URL_TYPE">
<option ' . (Tools::getValue('LIVEZILLA_URL_TYPE') == 'http://' ? ' selected="selected" ' : '') . ' value="http://">http://</option>
<option ' . (Tools::getValue('LIVEZILLA_URL_TYPE') == 'https://' ? ' selected="selected" ' : '') . ' value="https://">https://</option>
</select>
<input type="text" name="LIVEZILLA_URL" style="width:300px" value="' . Tools::htmlentitiesUTF8(Tools::getValue('LIVEZILLA_URL', Configuration::get('LIVEZILLA_URL'))) . '" />
<p>' . $this->l('Absolute URL with the trailing slash, e.g.,') . ' ' . Tools::getProtocol() . Tools::htmlentitiesUTF8($_SERVER['HTTP_HOST']) . '/LiveZilla/</p>
</div>
<div class="clear"> </div>
<div style="font-size:1.2em;font-weight:700;text-align:center">' . $this->l('-- OR --') . '</div>
<div class="clear"> </div>
<label>' . $this->l('Copy / paste the script given by LiveZilla') . '</label>
<div class="margin-form">
<textarea name="LIVEZILLA_SCRIPT" style="width:600px;height:200px" />' . Tools::htmlentitiesUTF8(Tools::getValue('LIVEZILLA_SCRIPT', Configuration::get('LIVEZILLA_SCRIPT'))) . '</textarea>
</div>
<div class="clear"> </div>
<input type="submit" name="submitLiveZilla" value="' . $this->l('Update settings') . '" class="button" />
</fieldset>
</form>';
return $html;
}
示例10: logHttpReferer
public static function logHttpReferer(Cookie $cookie = null)
{
if (!$cookie) {
$cookie = Context::getContext()->cookie;
}
if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections)) {
return false;
}
// If the referrer is not correct, we drop the connection
if (isset($_SERVER['HTTP_REFERER']) && !Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
return false;
}
// If there is no referrer and we do not want to save direct traffic (as opposed to referral traffic), we drop the connection
if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
return false;
}
$source = new ConnectionsSource();
// There are a few more operations if there is a referrer
if (isset($_SERVER['HTTP_REFERER'])) {
// If the referrer is internal (i.e. from your own website), then we drop the connection
$parsed = parse_url($_SERVER['HTTP_REFERER']);
$parsed_host = parse_url(Tools::getProtocol() . Tools::getHttpHost(false, false) . __PS_BASE_URI__);
if (!isset($parsed['host']) || (!isset($parsed['path']) || !isset($parsed_host['path']))) {
return false;
}
if (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__))) {
return false;
}
$source->http_referer = substr($_SERVER['HTTP_REFERER'], 0, ConnectionsSource::$uri_max_size);
$source->keywords = substr(trim(SearchEngine::getKeywords($_SERVER['HTTP_REFERER'])), 0, ConnectionsSource::$uri_max_size);
}
$source->id_connections = (int) $cookie->id_connections;
$source->request_uri = Tools::getHttpHost(false, false);
if (isset($_SERVER['REQUEST_URI'])) {
$source->request_uri .= $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['REDIRECT_URL'])) {
$source->request_uri .= $_SERVER['REDIRECT_URL'];
}
if (!Validate::isUrl($source->request_uri)) {
$source->request_uri = '';
}
$source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
return $source->add();
}
示例11: __construct
public function __construct()
{
$this->name = 'dibs';
$this->tab = 'payments_gateways';
$this->version = '1.2.2';
$this->author = 'PrestaShop';
parent::__construct();
$this->displayName = $this->l('DIBS');
$this->description = $this->l('DIBS payment API');
if ($this->active) {
if (self::$site_url === NULL) {
if (method_exists('Tools', 'getProtocol')) {
self::$site_url = Tools::htmlentitiesutf8(Tools::getProtocol() . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
} else {
self::$site_url = Tools::htmlentitiesutf8((!is_null($use_ssl) && $use_ssl ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
}
}
self::$ID_MERCHANT = Configuration::get('DIBS_ID_MERCHANT');
self::$ACCEPTED_URL = Configuration::get('DIBS_ACCEPTED_URL');
self::$CANCELLED_URL = Configuration::get('DIBS_CANCELLED_URL');
self::$TESTING = (int) Configuration::get('DIBS_TESTING');
self::$MORE_SETTINGS = Configuration::get('DIBS_MORE_SETTINGS') != '' ? unserialize(Tools::htmlentitiesDecodeUTF8(Configuration::get('DIBS_MORE_SETTINGS'))) : array();
if (!isset(self::$MORE_SETTINGS['k1']) or isset(self::$MORE_SETTINGS['k1']) and (self::$MORE_SETTINGS['k1'] === '' or self::$MORE_SETTINGS['k2'] === '')) {
$this->warning = $this->l('For security reasons, you must set key #1 and key #2 used by MD5 control of DIBS API.');
}
if (!self::$ID_MERCHANT or self::$ID_MERCHANT === '') {
$this->warning = $this->l('You have to set your merchant ID to use DIBS API.');
}
/* For 1.4.3 and less compatibility */
$updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT');
if (!Configuration::get('PS_OS_PAYMENT')) {
foreach ($updateConfig as $u) {
if (!Configuration::get($u) && defined('_' . $u . '_')) {
Configuration::updateValue($u, constant('_' . $u . '_'));
}
}
}
/** Backward compatibility */
require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
}
}
示例12: logHttpReferer
public static function logHttpReferer(Cookie $cookie = null)
{
if (!$cookie) {
$cookie = Context::getContext()->cookie;
}
if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections)) {
return false;
}
if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
return false;
}
$source = new ConnectionsSource();
if (isset($_SERVER['HTTP_REFERER']) && Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
$parsed = parse_url($_SERVER['HTTP_REFERER']);
$parsed_host = parse_url(Tools::getProtocol() . Tools::getHttpHost(false, false) . __PS_BASE_URI__);
if (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__))) {
return false;
}
if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER']))) {
$source->http_referer = substr(strval($_SERVER['HTTP_REFERER']), 0, ConnectionsSource::$uri_max_size);
$source->keywords = trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER'])));
if (!Validate::isMessage($source->keywords)) {
return false;
}
}
}
$source->id_connections = (int) $cookie->id_connections;
$source->request_uri = Tools::getHttpHost(false, false);
if (isset($_SERVER['REDIRECT_URL'])) {
$source->request_uri .= strval($_SERVER['REDIRECT_URL']);
} elseif (isset($_SERVER['REQUEST_URI'])) {
$source->request_uri .= strval($_SERVER['REQUEST_URI']);
}
if (!Validate::isUrl($source->request_uri)) {
$source->request_uri = '';
}
$source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
return $source->add();
}
示例13: displayForm
public function displayForm($order_states, $features, $attribute_groups, $neteven_feature_categories)
{
$customizable_fields = array();
if (Gateway::getConfig('CUSTOMIZABLE_FIELDS')) {
foreach (explode('¤', Gateway::getConfig('CUSTOMIZABLE_FIELDS')) as $customizable_field) {
$customizable_fields[] = explode('|', $customizable_field);
}
}
$carriers = Carrier::getCarriers((int) $this->context->cookie->id_lang);
$this->context->smarty->assign(array('SHIPPING_CARRIER_FRANCE' => Tools::safeOutput(Tools::getValue('SHIPPING_CARRIER_FRANCE', Gateway::getConfig('SHIPPING_CARRIER_FRANCE'))), 'SHIPPING_ZONE_FRANCE' => Tools::safeOutput(Tools::getValue('SHIPPING_ZONE_FRANCE', Gateway::getConfig('SHIPPING_ZONE_FRANCE'))), 'SHIPPING_CARRIER_INTERNATIONAL' => Tools::safeOutput(Tools::getValue('SHIPPING_CARRIER_INTERNATIONAL', Gateway::getConfig('SHIPPING_CARRIER_INTERNATIONAL'))), 'SHIPPING_ZONE_INTERNATIONAL' => Tools::safeOutput(Tools::getValue('SHIPPING_ZONE_INTERNATIONAL', Gateway::getConfig('SHIPPING_ZONE_INTERNATIONAL'))), 'carriers' => $carriers, 'order_states' => $order_states, 'features' => $features, 'module_path' => $this->_path, 'module_display_name' => $this->displayName, 'attribute_groups' => $attribute_groups, 'neteven_feature_categories' => $neteven_feature_categories, 'default_currency' => new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT')), 'format_images' => ImageType::getImagesTypes('products'), 'cron_feature_url' => Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . $this->feature_url, 'cron_order_url' => Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . $this->order_url, 'cron_product_url' => Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . $this->product_url, 'customizable_fields' => $customizable_fields, 'neteven_token' => Tools::encrypt(Configuration::get('PS_SHOP_NAME')), 'NETEVEN_LOGIN' => Tools::safeOutput(Tools::getValue('NETEVEN_LOGIN', Gateway::getConfig('NETEVEN_LOGIN'))), 'NETEVEN_PASSWORD' => Tools::safeOutput(Tools::getValue('NETEVEN_PASSWORD', Gateway::getConfig('NETEVEN_PASSWORD'))), 'SYNCHRONISATION_ORDER' => (int) Gateway::getConfig('SYNCHRONISATION_ORDER'), 'SYNCHRONISATION_PRODUCT' => (int) Gateway::getConfig('SYNCHRONISATION_PRODUCT'), 'DEFAULT_BRAND' => Tools::safeOutput(Tools::getValue('DEFAULT_BRAND', Gateway::getConfig('DEFAULT_BRAND'))), 'SHIPPING_DELAY' => Tools::safeOutput(Tools::getValue('SHIPPING_DELAY', Gateway::getConfig('SHIPPING_DELAY'))), 'IMAGE_TYPE_NAME' => Gateway::getConfig('IMAGE_TYPE_NAME'), 'COMMENT' => Tools::safeOutput(Tools::getValue('COMMENT', Gateway::getConfig('COMMENT'))), 'SHIPPING_PRICE_LOCAL' => Tools::safeOutput(Tools::getValue('SHIPPING_PRICE_LOCAL', Gateway::getConfig('SHIPPING_PRICE_LOCAL'))), 'SHIPPING_PRICE_INTERNATIONAL' => Tools::safeOutput(Tools::getValue('SHIPPING_PRICE_INTERNATIONAL', Gateway::getConfig('SHIPPING_PRICE_INTERNATIONAL'))), 'SHIPPING_BY_PRODUCT' => (int) Gateway::getConfig('SHIPPING_BY_PRODUCT'), 'SHIPPING_BY_PRODUCT_FIELDNAME' => Tools::safeOutput(Tools::getValue('SHIPPING_BY_PRODUCT_FIELDNAME', Gateway::getConfig('SHIPPING_BY_PRODUCT_FIELDNAME'))), 'ID_ORDER_STATE_NETEVEN' => (int) Gateway::getConfig('ID_ORDER_STATE_NETEVEN'), 'NETEVEN_URL' => Tools::safeOutput(Tools::getValue('NETEVEN_URL', Gateway::getConfig('NETEVEN_URL'))), 'NETEVEN_NS' => Tools::safeOutput(Tools::getValue('NETEVEN_NS', Gateway::getConfig('NETEVEN_NS'))), 'MAIL_LIST_ALERT' => Tools::safeOutput(Tools::getValue('MAIL_LIST_ALERT', Gateway::getConfig('MAIL_LIST_ALERT'))), 'DEBUG' => (int) Gateway::getConfig('DEBUG'), 'SEND_REQUEST_BY_EMAIL' => (int) Gateway::getConfig('SEND_REQUEST_BY_EMAIL'), 'TYPE_SKU' => (int) (Gateway::getConfig('TYPE_SKU') !== false) ? Gateway::getConfig('TYPE_SKU') : 'reference'));
return $this->display(__FILE__, 'views/templates/admin/nqgatewayneteven.tpl');
}
示例14: preProcess
public function preProcess()
{
if ((int) Tools::getValue('pp') == 1) {
$intime = time();
echo 'intime: ' . $intime;
}
if ($id_product = (int) Tools::getValue('id_product')) {
$this->product = new Product($id_product, true, self::$cookie->id_lang);
//if((int)Tools::getValue('pp') == 1){
// print_r($this->product->getPrice(false, null, 2));
//}
$id_product = (int) Tools::getValue('id_product');
$productsViewed = (isset(self::$cookie->viewed) and !empty(self::$cookie->viewed)) ? array_slice(explode(',', self::$cookie->viewed), 0, 12) : array();
if (sizeof($productsViewed)) {
if ($id_product and !in_array($id_product, $productsViewed)) {
array_unshift($productsViewed, $id_product);
}
} else {
$productsViewed[] = $id_product;
}
self::$cookie->viewed = implode(',', $productsViewed);
}
if (!Validate::isLoadedObject($this->product)) {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
} else {
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if (Validate::isLoadedObject($this->product)) {
$canonicalURL = self::$link->getProductLink($this->product);
if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) && !Tools::getValue('adtoken')) {
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) {
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>');
}
Tools::redirectLink($canonicalURL);
}
}
}
parent::preProcess();
if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
if ($id_product = (int) Tools::getValue('id_product')) {
$rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
$default_rewrite = array();
foreach ($rewrite_infos as $infos) {
$default_rewrite[$infos['id_lang']] = self::$link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
}
self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
}
}
//get categories
$categories = $this->product->getCategories();
if (in_array(CAT_SAREE, $categories)) {
if (in_array(CAT_BOLLYWOOD_SAREE, $categories)) {
self::$smarty->assign('bollywood', true);
}
$this->is_saree = true;
} else {
if (in_array(CAT_SKD, $categories)) {
if (in_array(CAT_BOLLYWOOD_SKD, $categories)) {
self::$smarty->assign('bollywood', true);
}
if ($this->product->is_rts) {
$this->is_skd_rts = true;
if (in_array(CAT_PAKISTANI_SKD, $categories)) {
$this->is_pakistani_rts = true;
}
if ($this->product->has_bottom) {
$this->has_bottom = true;
}
} else {
$this->is_skd = true;
}
} else {
if (in_array(CAT_KURTI, $categories)) {
//replace 4 with constant from defines later
if ($this->product->is_rts) {
$this->is_skd_rts = true;
} else {
$this->is_skd = true;
}
if ($this->product->has_bottom) {
$this->has_bottom = true;
}
} else {
if (in_array(CAT_LEHENGA, $categories)) {
if (in_array(CAT_BOLLYWOOD_LEHENGA, $categories)) {
self::$smarty->assign('bollywood', true);
}
$this->is_lehenga = true;
} else {
if (in_array(CAT_GIFTCARD, $categories)) {
$this->is_giftcard = true;
} else {
if (in_array(CAT_JEWELRY, $categories)) {
$this->is_jewelry = true;
} else {
if (in_array(CAT_KIDS, $categories)) {
$this->is_kids = true;
} else {
//.........这里部分代码省略.........
示例15: getContent
//.........这里部分代码省略.........
$message = $this->displayConfirmation($this->l('Filter template deleted, categories updated (reverted to default Filter template).'));
} else {
$message = $this->displayError($this->l('Filter template not found'));
}
}
}
}
$category_box = array();
$attribute_groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT ag.id_attribute_group, ag.is_color_group, agl.name, COUNT(DISTINCT(a.id_attribute)) n
FROM ' . _DB_PREFIX_ . 'attribute_group ag
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_group_lang agl ON (agl.id_attribute_group = ag.id_attribute_group)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = ag.id_attribute_group)
WHERE agl.id_lang = ' . (int) $cookie->id_lang . '
GROUP BY ag.id_attribute_group');
$features = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT fl.id_feature, fl.name, COUNT(DISTINCT(fv.id_feature_value)) n
FROM ' . _DB_PREFIX_ . 'feature_lang fl
LEFT JOIN ' . _DB_PREFIX_ . 'feature_value fv ON (fv.id_feature = fl.id_feature)
WHERE (fv.custom IS NULL OR fv.custom = 0) AND fl.id_lang = ' . (int) $cookie->id_lang . '
GROUP BY fl.id_feature');
if (Shop::isFeatureActive() && count(Shop::getShops(true, null, true)) > 1) {
$helper = new HelperForm();
$helper->id = Tools::getValue('id_layered_filter', null);
$helper->table = 'layered_filter';
$helper->identifier = 'id_layered_filter';
$this->context->smarty->assign('asso_shops', $helper->renderAssoShop());
}
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$tree_categories_helper = new HelperTreeCategories('categories-treeview');
$tree_categories_helper->setRootCategory(Shop::getContext() == Shop::CONTEXT_SHOP ? Category::getRootCategory()->id_category : 0)->setUseCheckBox(true);
} else {
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
$root_category = Category::getRootCategory();
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
} else {
$root_category = array('id_category' => '0', 'name' => $this->l('Root'));
}
$tree_categories_helper = new Helper();
}
$module_url = Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . $this->getPathUri();
if (method_exists($this->context->controller, 'addJquery')) {
$this->context->controller->addJS($this->_path . 'js/blocklayered_admin.js');
if (version_compare(_PS_VERSION_, '1.6.0.3', '>=') === true) {
$this->context->controller->addjqueryPlugin('sortable');
} elseif (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/jquery.sortable.js');
} else {
$this->context->controller->addJS($this->_path . 'js/jquery.sortable.js');
}
}
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$this->context->controller->addCSS($this->_path . 'css/blocklayered_admin_1.6.css');
} else {
$this->context->controller->addCSS($this->_path . 'css/blocklayered_admin.css');
}
if (Tools::getValue('add_new_filters_template')) {
$this->context->smarty->assign(array('current_url' => $this->context->link->getAdminLink('AdminModules') . '&configure=blocklayered&tab_module=front_office_features&module_name=blocklayered', 'uri' => $this->getPathUri(), 'id_layered_filter' => 0, 'template_name' => sprintf($this->l('My template - %s'), date('Y-m-d')), 'attribute_groups' => $attribute_groups, 'features' => $features, 'total_filters' => 6 + count($attribute_groups) + count($features)));
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$this->context->smarty->assign('categories_tree', $tree_categories_helper->render());
} else {
$this->context->smarty->assign('categories_tree', $tree_categories_helper->renderCategoryTree($root_category, array(), 'categoryBox'));
}
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
return $this->display(__FILE__, 'views/templates/admin/add_1.6.tpl');
} else {
return $this->display(__FILE__, 'views/templates/admin/add.tpl');
}
} else {
if (Tools::getValue('edit_filters_template')) {
$template = Db::getInstance()->getRow('
SELECT *
FROM `' . _DB_PREFIX_ . 'layered_filter`
WHERE id_layered_filter = ' . (int) Tools::getValue('id_layered_filter'));
$filters = unserialize($template['filters']);
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
$tree_categories_helper->setSelectedCategories($filters['categories']);
$this->context->smarty->assign('categories_tree', $tree_categories_helper->render());
} else {
$this->context->smarty->assign('categories_tree', $tree_categories_helper->renderCategoryTree($root_category, $filters['categories'], 'categoryBox'));
}
$select_shops = $filters['shop_list'];
unset($filters['categories']);
unset($filters['shop_list']);
$this->context->smarty->assign(array('current_url' => $this->context->link->getAdminLink('AdminModules') . '&configure=blocklayered&tab_module=front_office_features&module_name=blocklayered', 'uri' => $this->getPathUri(), 'id_layered_filter' => (int) Tools::getValue('id_layered_filter'), 'template_name' => $template['name'], 'attribute_groups' => $attribute_groups, 'features' => $features, 'filters' => Tools::jsonEncode($filters), 'total_filters' => 6 + count($attribute_groups) + count($features)));
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
return $this->display(__FILE__, 'views/templates/admin/add_1.6.tpl');
} else {
return $this->display(__FILE__, 'views/templates/admin/add.tpl');
}
} else {
$this->context->smarty->assign(array('message' => $message, 'uri' => $this->getPathUri(), 'PS_LAYERED_INDEXED' => Configuration::getGlobalValue('PS_LAYERED_INDEXED'), 'current_url' => Tools::safeOutput(preg_replace('/&deleteFilterTemplate=[0-9]*&id_layered_filter=[0-9]*/', '', $_SERVER['REQUEST_URI'])), 'id_lang' => Context::getContext()->cookie->id_lang, 'token' => substr(Tools::encrypt('blocklayered/index'), 0, 10), 'base_folder' => urlencode(_PS_ADMIN_DIR_), 'price_indexer_url' => $module_url . 'blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10), 'full_price_indexer_url' => $module_url . 'blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&full=1', 'attribute_indexer_url' => $module_url . 'blocklayered-attribute-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10), 'url_indexer_url' => $module_url . 'blocklayered-url-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&truncate=1', 'filters_templates' => Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'layered_filter ORDER BY date_add DESC'), 'hide_values' => Configuration::get('PS_LAYERED_HIDE_0_VALUES'), 'show_quantities' => Configuration::get('PS_LAYERED_SHOW_QTIES'), 'full_tree' => Configuration::get('PS_LAYERED_FULL_TREE'), 'category_depth' => Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH'), 'price_use_tax' => Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX'), 'index_cdt' => Configuration::get('PS_LAYERED_FILTER_INDEX_CDT'), 'index_qty' => Configuration::get('PS_LAYERED_FILTER_INDEX_QTY'), 'index_mnf' => Configuration::get('PS_LAYERED_FILTER_INDEX_MNF'), 'index_cat' => Configuration::get('PS_LAYERED_FILTER_INDEX_CAT'), 'limit_warning' => $this->displayLimitPostWarning(21 + count($attribute_groups) * 3 + count($features) * 3)));
if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
return $this->display(__FILE__, 'views/templates/admin/view_1.6.tpl');
} else {
return $this->display(__FILE__, 'views/templates/admin/view.tpl');
}
}
}
}