Compare commits

..

5 Commits

Author SHA1 Message Date
Michael RICOIS
c0e474e35e trailer for content 2018-03-20 12:26:10 +01:00
Michael RICOIS
d30b3717fd Simplified sitemap 2018-03-20 12:10:23 +01:00
Michael RICOIS
25c1ae725b Test with cat and products 2018-03-20 12:07:55 +01:00
Michael RICOIS
0b451e2fc2 Mask all pages 2018-03-19 11:57:01 +01:00
Michael RICOIS
3fa1118554 CS 2018-03-19 11:47:59 +01:00
6 changed files with 148 additions and 536 deletions

View File

@ -79,16 +79,7 @@ class AdminImport extends AdminTab
public function __construct()
{
$this->entities = array_flip(array(
$this->l('Categories'),
$this->l('Products'),
$this->l('Combinations'),
$this->l('Customers'),
$this->l('Addresses'),
$this->l('Manufacturers'),
$this->l('Suppliers'),
$this->l('Pack'),
));
$this->entities = array_flip(array($this->l('Categories'), $this->l('Products'), $this->l('Combinations'), $this->l('Customers'), $this->l('Addresses'), $this->l('Manufacturers'), $this->l('Suppliers')));
switch ((int)(Tools::getValue('entity')))
{
@ -289,19 +280,7 @@ class AdminImport extends AdminTab
'meta_keywords' => array('label' => $this->l('Meta-keywords')),
'meta_description' => array('label' => $this->l('Meta-description')));
break;
case $this->entities[$this->l('Pack')]:
self::$required_fields = array('id_product_item', 'qty', 'id');
$this->available_fields = array(
'id_product_item' => array('label' => $this->l('ID Item')),
'qty' => array('label' => $this->l('Quantity Item')),
'id' => array('label' => $this->l('ID Pack')),
);
break;
}
parent::__construct();
}
@ -1313,51 +1292,6 @@ class AdminImport extends AdminTab
}
$this->closeCsvFile($handle);
}
public function packImport()
{
$this->receiveTab();
$handle = $this->openCsvFile();
self::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++)
{
if (Tools::getValue('convert')) {
$line = $this->utf8_encode_array($line);
}
$info = self::getMaskedRow($line);
self::setDefaultValues($info);
// Is product a pack
if (array_key_exists('id', $info) && (int)($info['id']) && Pack::isPack((int)($info['id']))) {
$pack = new Pack((int)($info['id']));
}
else {
$pack = new Pack();
}
self::array_walk($info, array('AdminImport', 'fillInfo'), $pack);
if (($fieldError = $pack->validateFields(UNFRIENDLY_ERROR, true)) === true && is_numeric($info['qty']))
{
$res = false;
// Is product item in pack
if ($pack->isPacked($info['id_product_item'])) {
$res = $pack->updateItem($info['id'], $info['id_product_item'], $info['qty']);
}
// Insert
if (!$res) {
$res = $pack->addItem($info['id'], $info['id_product_item'], $info['qty']);
}
if (!$res) {
$this->_errors[] = mysql_error().' '.$info['id_product_item'].(isset($info['id']) ? ' (ID '.$info['id'].')' : '').' '.Tools::displayError('Cannot be saved');
}
}
else {
$this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '');
}
}
$this->closeCsvFile($handle);
}
public function display()
{
@ -1890,9 +1824,6 @@ class AdminImport extends AdminTab
case $this->entities[$this->l('Suppliers')]:
$this->supplierImport();
break;
case $this->entities[$this->l('Pack')]:
$this->packImport();
break;
default:
$this->_errors[] = $this->l('no entity selected');
}

View File

@ -174,30 +174,18 @@ class PackCore extends Product
}
/**
* Add an item to the pack
* @param integer $id_product
* @param integer $id_item
* @param integer $qty
* @return boolean true if everything was fine
*/
* Add an item to the pack
*
* @param integer $id_product
* @param integer $id_item
* @param integer $qty
* @return boolean true if everything was fine
*/
public static function addItem($id_product, $id_item, $qty)
{
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'product SET cache_is_pack = 1 WHERE id_product = '.(int)($id_product).' LIMIT 1');
return Db::getInstance()->AutoExecute(_DB_PREFIX_.'pack', array('id_product_pack' => (int)($id_product), 'id_product_item' => (int)($id_item), 'quantity' => (int)($qty)), 'INSERT');
}
/**
* Update item and his pack association
* @param integer $id_product
* @param integer $id_item
* @param integer $qty
* @return boolean true if everything was fine
*/
public static function updateItem($id_product, $id_item, $qty)
{
return Db::getInstance()->AutoExecute(_DB_PREFIX_.'pack', array('quantity' => (int)($qty)),
'UPDATE', 'id_product_pack='.(int)($id_product).' AND id_product_item='.(int)($id_item));
}
public static function duplicate($id_product_old, $id_product_new)
{

View File

@ -1,12 +1,17 @@
<?php
if (!defined('_PS_VERSION_'))
if (!defined('_PS_VERSION_')) {
exit;
}
class GoogleSitemap extends Module {
require_once dirname(__FILE__).'/../privatesales/Sale.php';
class GoogleSitemap extends Module
{
private $_html = '';
private $_postErrors = array();
public function __construct() {
public function __construct()
{
$this->name = 'googlesitemap';
$this->tab = 'seo';
$this->version = '1.2';
@ -18,17 +23,18 @@ class GoogleSitemap extends Module {
$this->displayName = $this->l('Google sitemap with private sales support');
$this->description = $this->l('Generate your Google sitemap file');
if(!defined('GSITEMAP_FILE')) {
if (!defined('GSITEMAP_FILE')) {
define('GSITEMAP_FILE', dirname(__FILE__).'/../../sitemap.xml');
}
}
public function install() {
if(!parent::install()) {
public function install()
{
if (!parent::install()) {
return FALSE;
}
if(Module::isInstalled('privatesales')) {
if (Module::isInstalled('privatesales')) {
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'privatesale_module`
VALUES (
@ -41,31 +47,35 @@ class GoogleSitemap extends Module {
return TRUE;
}
public function uninstall() {
public function uninstall()
{
file_put_contents(GSITEMAP_FILE, '');
if(Module::isInstalled('privatesales')) {
if (Module::isInstalled('privatesales')) {
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'privatesale_module` WHERE `modulename` = "googlesitemap"');
}
return parent::uninstall();
}
private function _postValidation() {
private function _postValidation()
{
file_put_contents(GSITEMAP_FILE, '');
if(!($fp = fopen(GSITEMAP_FILE, 'w'))) {
if (!($fp = fopen(GSITEMAP_FILE, 'w'))) {
$this->_postErrors[] = $this->l('Cannot create').' '.realpath(dirname(__FILE__.'/../..')).'/'.$this->l('sitemap.xml file.');
} else {
fclose($fp);
}
}
public function generateSitemap() {
public function generateSitemap()
{
global $cookie;
$link = new Link();
$langs = Language::getLanguages();
$iso_code = Language::getIsoById((int) $cookie->id_lang);
$xmlString = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
@ -75,7 +85,7 @@ XML;
$xml = new SimpleXMLElement($xmlString);
if(Configuration::get('PS_REWRITING_SETTINGS') && sizeof($langs) > 1) {
if (Configuration::get('PS_REWRITING_SETTINGS') && sizeof($langs) > 1) {
foreach($langs as $lang) {
$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.$lang['iso_code'].'/', '1.00', 'daily', date('Y-m-d'));
}
@ -84,7 +94,7 @@ XML;
}
/* CMS Generator */
if(Configuration::get('GSITEMAP_ALL_CMS') || !Module::isInstalled('blockcms')) {
if (Configuration::get('GSITEMAP_ALL_CMS') || !Module::isInstalled('blockcms')) {
$sql_cms = '
SELECT DISTINCT '.(Configuration::get('PS_REWRITING_SETTINGS')? 'cl.id_cms, cl.link_rewrite, cl.id_lang': 'cl.id_cms').'
FROM `'._DB_PREFIX_.'cms_lang` cl
@ -108,27 +118,25 @@ XML;
$cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql_cms);
foreach($cmss as $cms) {
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS')? $link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], FALSE, (int) $cms['id_lang']): $link->getCMSLink((int)$cms['id_cms']);
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ?
$link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], FALSE, (int)$cms['id_lang']) :
$link->getCMSLink((int)$cms['id_cms']);
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'weekly');
}
/* Categories Generator */
$exclude_categories = array();
if(Module::isInstalled('privatesales')) {
include(dirname(__FILE__).'/../privatesales/Sale.php');
if (Module::isInstalled('privatesales')) {
$has_trailers = file_exists(dirname(__FILE__).'/../privatesales/trailer.php');
$sales = Sale::getSales(TRUE, NULL, NULL, 'not_ended');
$sales = Sale::getSales(true, null, null, 'all');
foreach($sales as $sale) {
$exclude_categories = array_merge($exclude_categories, Sale::getCategoriesFromCache($sale->id));
if($has_trailers) {
if ($has_trailers) {
$trailers_i18n = array(
'fr' => 'bande-annonce',
'en' => 'trailer',
);
if(Configuration::get('PS_REWRITING_SETTINGS')) {
if(count($langs) > 1) {
if (Configuration::get('PS_REWRITING_SETTINGS')) {
if (count($langs) > 1) {
$this->_addSitemapNode($xml, Tools::getShopDomain(TRUE, TRUE).__PS_BASE_URI__.$iso_code.'/'.(isset($trailers_i18n[$iso_code])? $trailers_i18n[$iso_code]: $trailers_i18n['en']).'/'.$sale->id.'-'.Tools::str2url($sale->title[$cookie->id_lang]), '0.8', 'weekly');
} else {
$this->_addSitemapNode($xml, Tools::getShopDomain(TRUE, TRUE).__PS_BASE_URI__.(isset($trailers_i18n[$iso_code])? $trailers_i18n[$iso_code]: $trailers_i18n['en']).'/'.$sale->id.'-'.Tools::str2url($sale->title[$cookie->id_lang]), '0.8', 'weekly');
@ -138,166 +146,58 @@ XML;
}
}
}
$ordering = (int) Configuration::get('PRIVATESALES_FEATURED_ORDER');
if($ordering == 0) {
if(Module::isInstalled('privatesales_brands')) {
$sales = Sale::getSales(TRUE, (int) Configuration::get('PRIVATESALES_FEATURED_IGNORE') == 1? NULL: !((bool) Configuration::get('PRIVATESALES_GUESTLIST')), TRUE, (bool) Configuration::get('PRIVATESALES_FEATURED_CURRENT'), TRUE);
$brands = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_brand`
FROM `'._DB_PREFIX_.'privatesale_brands`
WHERE `id_sale` IN ('.implode(', ', $sales).')
GROUP BY `id_brand`
') as $b) {
$brands[] = $b['id_brand'];
}
$manufacturers = Db::getInstance()->ExecuteS('
SELECT m.*, ml.`short_description`
FROM `'._DB_PREFIX_.'manufacturer` m
LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ml
ON (
m.`id_manufacturer` = ml.`id_manufacturer`
AND ml.`id_lang` = '.(int) $cookie->id_lang.'
)
WHERE m.`active` = 1
AND m.`id_manufacturer` IN ('.implode(', ', $brands).')
ORDER BY m.`name` ASC
');
} else {
$manufacturers = Manufacturer::getManufacturers(TRUE, (int) $cookie->id_lang, TRUE, FALSE, FALSE, TRUE);
}
// Liste des ventes actives
$sales = Sale::getSales(true, null, null, 'not_ended');
$products = array();
if (count($sales) > 0) {
foreach ($sales as $sale) {
$id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_category` FROM `'._DB_PREFIX_.'privatesale_category`
WHERE `id_sale`='.(int)$sale->id);
$category = new Category($id_category);
if (($priority = 0.9 - ($category->level_depth / 10)) < 0.1) {
$priority = 0.1;
}
$brands_i18n = array(
'fr' => 'marques',
'en' => 'brands',
);
foreach($manufacturers as $manufacturer) {
if(Configuration::get('PS_REWRITING_SETTINGS')) {
if(count($langs) > 1) {
$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.$iso_code.'/'.(isset($brands_i18n[$iso_code])? $brands_i18n[$iso_code]: $brands_i18n['en']).'/'.$manufacturer['id_manufacturer'].'-'.Tools::str2url($manufacturer['name']), '0.8', 'weekly');
} else {
$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.(isset($brands_i18n[$iso_code])? $brands_i18n[$iso_code]: $brands_i18n['en']).'/'.$manufacturer['id_manufacturer'].'-'.Tools::str2url($manufacturer['name']), '0.8', 'weekly');
}
} else {
$this->_addSitemapNode($xml, Tools::getShopDomain(true, true).__PS_BASE_URI__.'modules/privatesales/featured.php?id_brand='.$manufacturer['id_manufacturer'], '0.8', 'weekly');
}
}
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ?
$link->getCategoryLink((int)$category->id_category, $category->link_rewrite[1]) :
$link->getCategoryLink((int)$category->id_category);
$this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'daily', substr($category->date_upd, 0, 10));
}
}
if(Configuration::get('PS_REWRITING_SETTINGS')) {
$categories = Db::getInstance()->ExecuteS('
SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl
ON c.id_category = cl.id_category
LEFT JOIN '._DB_PREFIX_.'lang l
ON cl.id_lang = l.id_lang
WHERE l.`active` = 1
AND c.`active` = 1
AND c.id_category != 1
'.(count($exclude_categories) > 0? ' AND c.id_category NOT IN ('.implode(', ', $exclude_categories).')': '').'
ORDER BY cl.id_category, cl.id_lang ASC
');
} else {
$categories = Db::getInstance()->ExecuteS('
SELECT c.id_category, c.level_depth, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd
FROM '._DB_PREFIX_.'category c
'.(count($exclude_categories) > 0? ' AND c.id_category NOT IN ('.implode(', ', $exclude_categories).')': '').'
ORDER BY c.id_category ASC
');
}
foreach($categories as $category) {
if(($priority = 0.9 - ($category['level_depth'] / 10)) < 0.1) {
$priority = 0.1;
}
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS')? $link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']): $link->getCategoryLink((int)$category['id_category']);
$this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10));
}
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, (
SELECT MIN(level_depth)
FROM '._DB_PREFIX_.'product p2
LEFT JOIN '._DB_PREFIX_.'category_product cp2
ON p2.id_product = cp2.id_product
LEFT JOIN '._DB_PREFIX_.'category c2
ON cp2.id_category = c2.id_category
WHERE p2.id_product = p.id_product AND p2.`active` = 1
AND c2.`active` = 1
) AS level_depth
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl
ON (p.id_product = pl.id_product)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`)
LEFT JOIN '._DB_PREFIX_.'image i
ON p.id_product = i.id_product
LEFT JOIN `'._DB_PREFIX_.'image_lang` il
ON (i.`id_image` = il.`id_image`
AND pl.`id_lang` = il.`id_lang`)
LEFT JOIN '._DB_PREFIX_.'lang l
ON (pl.id_lang = l.id_lang)
WHERE l.`active` = 1
AND p.`active` = 1
'.(count($exclude_categories) > 0? ' AND p.id_category_default NOT IN ('.implode(', ', $exclude_categories).')': '').'
'.(Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL').'
ORDER BY pl.id_product, pl.id_lang ASC
');
$tmp = NULL;
$res = NULL;
foreach($products as $product) {
if($tmp == $product['id_product']) {
$res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']);
} else {
$tmp = $product['id_product'];
$res[$tmp] = $product;
unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']);
$res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']);
}
}
foreach($res as $product) {
if(($priority = 0.7 - ($product['level_depth'] / 10)) < 0.1) {
$priority = 0.1;
}
$tmpLink = $link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], (int) $product['id_lang']);
$sitemap = $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10));
$sitemap = $this->_addSitemapNodeImage($sitemap, $product);
}
/* Add classic pages (contact, best sales, new products...) */
$pages = array(
'authentication' => TRUE,
'best-sales' => FALSE,
'contact-form' => TRUE,
'discount' => FALSE,
'index' => FALSE,
'manufacturer' => FALSE,
'new-products' => FALSE,
'prices-drop' => FALSE,
'supplier' => FALSE,
'store' => FALSE,
'authentication' => true,
//'best-sales' => false,
'contact-form' => true,
//'discount' => false,
//'index' => true,
//'manufacturer' => false,
//'new-products' => false,
//'prices-drop' => false,
//'supplier' => false,
//'store' => false,
);
// Don't show suppliers and manufacturers if they are disallowed
if(!Module::getInstanceByName('blockmanufacturer')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) {
if (!Module::getInstanceByName('blockmanufacturer')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) {
unset($pages['manufacturer']);
}
if(!Module::getInstanceByName('blocksupplier')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) {
if (!Module::getInstanceByName('blocksupplier')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) {
unset($pages['supplier']);
}
// Generate nodes for pages
if(Configuration::get('PS_REWRITING_SETTINGS')) {
if (Configuration::get('PS_REWRITING_SETTINGS')) {
foreach($pages as $page => $ssl) {
foreach($langs as $lang) {
$this->_addSitemapNode($xml, $link->getPageLink($page.'.php', $ssl, $lang['id_lang']), '0.5', 'monthly');
@ -308,7 +208,7 @@ XML;
$this->_addSitemapNode($xml, $link->getPageLink($page.'.php', $ssl), '0.5', 'monthly');
}
}
$xmlString = $xml->asXML();
$fp = fopen(GSITEMAP_FILE, 'w');
@ -317,7 +217,8 @@ XML;
}
private function _postProcess() {
private function _postProcess()
{
Configuration::updateValue('GSITEMAP_ALL_CMS', (int) Tools::getValue('GSITEMAP_ALL_CMS'));
Configuration::updateValue('GSITEMAP_ALL_PRODUCTS', (int) Tools::getValue('GSITEMAP_ALL_PRODUCTS'));
@ -329,28 +230,31 @@ XML;
$this->_html .= '</h3>';
}
private function getUrlWith($url, $key, $value) {
if(empty($value)) {
private function getUrlWith($url, $key, $value)
{
if (empty($value)) {
return $url;
}
if(strpos($url, '?') !== FALSE) {
if (strpos($url, '?') !== FALSE) {
return $url.'&'.$key.'='.$value;
}
return $url.'?'.$key.'='.$value;
}
private function _addSitemapNode($xml, $loc, $priority, $change_freq, $last_mod=NULL) {
private function _addSitemapNode($xml, $loc, $priority, $change_freq, $last_mod=NULL)
{
$sitemap = $xml->addChild('url');
$sitemap->addChild('loc', $loc);
$sitemap->addChild('priority', $priority);
if($last_mod) {
if ($last_mod) {
$sitemap->addChild('lastmod', $last_mod);
}
$sitemap->addChild('changefreq', $change_freq);
return $sitemap;
}
private function _addSitemapNodeImage($xml, $product) {
private function _addSitemapNodeImage($xml, $product)
{
foreach($product['images'] as $img) {
$link = new Link();
$image = $xml->addChild('image', NULL, 'http://www.google.com/schemas/sitemap-image/1.1');
@ -362,8 +266,9 @@ XML;
}
}
private function _displaySitemap() {
if(file_exists(GSITEMAP_FILE) && filesize(GSITEMAP_FILE)) {
private function _displaySitemap()
{
if (file_exists(GSITEMAP_FILE) && filesize(GSITEMAP_FILE)) {
$fp = fopen(GSITEMAP_FILE, 'r');
$fstat = fstat($fp);
fclose($fp);
@ -380,7 +285,8 @@ XML;
}
}
private function _displayForm() {
private function _displayForm()
{
$this->_html .=
'<form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post">
<div style="margin:0 0 20px 0;">
@ -394,11 +300,12 @@ XML;
</form>';
}
public function getContent() {
public function getContent()
{
$this->_html .= '<h2>'.$this->l('Search Engine Optimization').'</h2>
'.$this->l('See').' <a href="https://www.google.com/webmasters/tools/docs/en/about.html" style="font-weight:bold;text-decoration:underline;" target="_blank">
'.$this->l('this page').'</a> '.$this->l('for more information').'<br /><br />';
if(Tools::isSubmit('btnSubmit')) {
if (Tools::isSubmit('btnSubmit')) {
$this->_postValidation();
if (!sizeof($this->_postErrors)) {
$this->_postProcess();

View File

@ -83,115 +83,15 @@ if($canSendInvitations) {
$friendsFirstName = Tools::getValue('friendsFirstName');
$mails_exists = array();
foreach ($friendsEmail AS $key => $friendEmail) {
$friendEmail = $emailOri = strtolower(trim(strval($friendEmail)));
// Prepare Check email
$domains = array(
/* Default domains included */
"aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
"google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk",
/* Other global domains */
"email.com", "fastmail.fm", "games.com" /* AOL */, "gmx.net", "hush.com", "hushmail.com", "icloud.com",
"iname.com", "inbox.com", "lavabit.com", "love.com" /* AOL */, "outlook.com", "pobox.com", "protonmail.com",
"rocketmail.com" /* Yahoo */, "safe-mail.net", "wow.com" /* AOL */, "ygm.com" /* AOL */,
"ymail.com" /* Yahoo */, "zoho.com", "yandex.com",
/* United States ISP domains */
"bellsouth.net", "charter.net", "cox.net", "earthlink.net", "juno.com",
/* British ISP domains */
"btinternet.com", "virginmedia.com", "blueyonder.co.uk", "freeserve.co.uk", "live.co.uk",
"ntlworld.com", "o2.co.uk", "orange.net", "sky.com", "talktalk.co.uk", "tiscali.co.uk",
"virgin.net", "wanadoo.co.uk", "bt.com",
/* Domains used in Asia */
"sina.com", "qq.com", "naver.com", "hanmail.net", "daum.net", "nate.com", "yahoo.co.jp", "yahoo.co.kr", "yahoo.co.id", "yahoo.co.in", "yahoo.com.sg", "yahoo.com.ph",
/* French ISP domains */
"hotmail.fr", "live.fr", "laposte.net", "yahoo.fr", "wanadoo.fr", "orange.fr", "gmx.fr", "sfr.fr", "neuf.fr", "free.fr",
/* German ISP domains */
"gmx.de", "hotmail.de", "live.de", "online.de", "t-online.de" /* T-Mobile */, "web.de", "yahoo.de",
/* Italian ISP domains */
"libero.it", "virgilio.it", "hotmail.it", "aol.it", "tiscali.it", "alice.it", "live.it", "yahoo.it", "email.it", "tin.it", "poste.it", "teletu.it",
/* Russian ISP domains */
"mail.ru", "rambler.ru", "yandex.ru", "ya.ru", "list.ru",
/* Belgian ISP domains */
"hotmail.be", "live.be", "skynet.be", "voo.be", "tvcablenet.be", "telenet.be",
/* Argentinian ISP domains */
"hotmail.com.ar", "live.com.ar", "yahoo.com.ar", "fibertel.com.ar", "speedy.com.ar", "arnet.com.ar",
/* Domains used in Mexico */
"yahoo.com.mx", "live.com.mx", "hotmail.es", "hotmail.com.mx", "prodigy.net.mx",
/* Domains used in Brazil */
"yahoo.com.br", "hotmail.com.br", "outlook.com.br", "uol.com.br", "bol.com.br", "terra.com.br", "ig.com.br", "itelefonica.com.br", "r7.com", "zipmail.com.br", "globo.com", "globomail.com", "oi.com.br"
);
// Real association
$replaceSLD = array(
'@hotmil.' => '@hotmail.',
'@htmail.' => '@hotmail.',
'@hotmal.' => '@hotmail.',
'@hotml.' => '@hotmail.',
'@hotmai.' => '@hotmail.',
'@gmal.' => '@gmail.',
'@gail.' => '@gmail.',
'@gml.' => '@gmail.',
'@gmai.' => '@gmail.',
'@gmil.' => '@gmail.',
);
$replaceGlobal = array(
'@gmailcom' => '@gmail.com',
'@hotmailcom' => '@hotmail.com',
'@hotmailfr' => '@hotmail.fr',
'@yahoocom' => '@yahoo.com',
'@yahoofr' => '@yahoo.fr',
);
// Real use case replacement
$friendEmail = strtr($friendEmail, $replaceGlobal);
// Check TLD
$atPos = strpos($friendEmail, '@');
$pointPos = strpos($friendEmail, '.', $atPos);
$tld = substr($friendEmail, $pointPos + 1);
$sld = substr($friendEmail, $atPos + 1, strlen($friendEmail) - ($atPos+1) - (strlen($tld)+1) );
if (empty($tld)) {
$errors[] = Tools::displayError('Invalid email');
$_POST['friendsEmail'] = '';
}
if (empty($errors)) {
// If you have a complete list of TLD, check it !
}
// Check SLD
if (empty($errors)) {
// Real use case replacement
$friendEmail = strtr($friendEmail, $replaceSLD);
// Levenhstein remplacement
if (count($domains) > 0 && $friendEmail == $emailOri) {
foreach ($domains as $d) {
$dpPos = strpos($d, '.');
$realDomain = substr($d, 0, $dpPos);
$lev = levenshtein($sld, $realDomain);
if ($lev == O) {
break;
}
elseif ($lev == 1 && $tld == substr($d, $dpPos+1)) {
$friendEmail = str_replace('@'.$sld.'.', '@'.$realDomain.'.', $friendEmail);
break;
}
}
}
}
$friendEmail = strval($friendEmail);
$friendEmail = trim($friendEmail);
/** @Override Antadis - mail fixing */
$friendEmail = str_replace(array('@hotmil.','@htmail.','@hotmal.','@hotml.','@hotmai.'),'@hotmail.',$friendEmail);
$friendEmail = str_replace(array('@gmal.','@gail.','@gml.','@gmai.','@gmil.'),'@gmail.',$friendEmail);
$friendEmail = str_replace('@gmailcom','@gmail.com',$friendEmail);
$friendEmail = str_replace('@hotmailcom','@hotmail.com',$friendEmail);
$friendEmail = str_replace('@hotmailfr','@hotmail.fr',$friendEmail);
/** @End Override Antadis - mail fixing */
if($askName) {
$friendLastName = strval($friendsLastName[$key]);
$friendFirstName = strval($friendsFirstName[$key]);

View File

@ -1,14 +1,13 @@
<?php
if (!defined('_PS_VERSION_')) {
if(!defined('_PS_VERSION_')) {
exit;
}
class Logistics extends Module
{
class Logistics extends Module {
public $_html = '';
public function __construct()
{
public function __construct() {
$this->name = 'logistics';
$this->tab = 'shipping_logistics';
$this->version = '2.0';
@ -21,8 +20,7 @@ class Logistics extends Module
$this->description = $this->l('Allows to manage parcels');
}
public function install()
{
public function install() {
# Add admin tabs
$tabs_i18n = array(
'fr' => 'Gestion des envois',
@ -35,8 +33,8 @@ class Logistics extends Module
$t->active = TRUE;
$t->module = 'logistics';
$t->class_name = 'AdminLogistics';
foreach (Language::getLanguages() as $lang) {
if (isset($tabs_i18n[$lang['iso_code']])) {
foreach(Language::getLanguages() as $lang) {
if(isset($tabs_i18n[$lang['iso_code']])) {
$t->name[$lang['id_lang']] = $tabs_i18n[$lang['iso_code']];
} else {
$t->name[$lang['id_lang']] = $tabs_i18n['en'];
@ -49,8 +47,7 @@ class Logistics extends Module
&& $this->registerHook('updateCarrier');
}
private function installCarriers()
{
private function installCarriers() {
return
// La Poste
Db::getInstance()->Execute('
@ -153,8 +150,7 @@ class Logistics extends Module
');
}
private function uninstallCarriers()
{
private function uninstallCarriers() {
/*Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews`');
Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews_pr`');
Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws`');
@ -165,16 +161,14 @@ class Logistics extends Module
return TRUE;
}
public function uninstall()
{
public function uninstall() {
return $this->uninstallCarriers() && parent::uninstall();
}
public function getContent()
{
public function getContent() {
global $cookie;
if (Tools::isSubmit('submitUpdate')) {
if(Tools::isSubmit('submitUpdate')) {
/* La Poste */
Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize(Tools::getValue('laposte_carriers', array())));
@ -332,13 +326,13 @@ class Logistics extends Module
Configuration::updateValue('MONDIALRELAYWS_FTP_LOGIN', Tools::getValue('mondialrelay_ftp_login'));
Configuration::updateValue('MONDIALRELAYWS_FTP_PASSWORD', Tools::getValue('mondialrelay_ftp_password'));
// Set print queue - employe : name
foreach (Tools::getValue('employee', array()) as $id_employee => $queue) {
Configuration::updateValue('LOGISTICS_QUEUE_'.(int)$id_employee, $queue);
}
// foreach(Tools::getValue('employee', array()) as $id_employee => $queue) {
// Configuration::updateValue('LOGISTICS_QUEUE_'.(int) $id_employee, $queue);
// }
$lock = array();
foreach (explode(', ', Tools::getValue('lock_products')) as $item) {
foreach(explode(', ', Tools::getValue('lock_products')) as $item) {
$lock[] = (int) $item;
}
Configuration::updateValue('LOGISTICS_LOCK', serialize(implode(',', $lock)));
@ -465,7 +459,7 @@ class Logistics extends Module
<label for="laposte_exp_country">'.$this->l('Country:').'</label>
<select name="laposte_exp_country">';
foreach (Country::getCountries((int) $cookie->id_lang) as $country) {
foreach(Country::getCountries((int) $cookie->id_lang) as $country) {
$this->_html .= '<option value="'.$country['id_country'].'"'.(Configuration::get('LAPOSTEWS_EXP_COUNTRY') == $country['id_country']? ' selected="selected"': '').'>'.$country['name'].'</option>';
}
@ -563,7 +557,7 @@ class Logistics extends Module
';
$laposte_carriers = unserialize(Configuration::get('LAPOSTEWS_CARRIERS', serialize(array())));
foreach (Db::getInstance()->ExecuteS('
foreach(Db::getInstance()->ExecuteS('
SELECT c.*
FROM `'._DB_PREFIX_.'carrier` c
') as $carrier) {
@ -609,7 +603,7 @@ class Logistics extends Module
<label for="exapaq_exp_country">'.$this->l('Country:').'</label>
<select name="exapaq_exp_country">';
foreach (Country::getCountries((int) $cookie->id_lang) as $country) {
foreach(Country::getCountries((int) $cookie->id_lang) as $country) {
$this->_html .= '<option value="'.$country['id_country'].'"'.(Configuration::get('EXAPAQWS_EXP_COUNTRY') == $country['id_country']? ' selected="selected"': '').'>'.$country['name'].'</option>';
}
@ -701,7 +695,7 @@ class Logistics extends Module
';
$exapaq_carriers = unserialize(Configuration::get('EXAPAQWS_CARRIERS', serialize(array())));
foreach (Db::getInstance()->ExecuteS('
foreach(Db::getInstance()->ExecuteS('
SELECT c.*
FROM `'._DB_PREFIX_.'carrier` c
') as $carrier) {
@ -749,7 +743,7 @@ class Logistics extends Module
<label for="mondialrelay_exp_country">'.$this->l('Country:').'</label>
<select name="mondialrelay_exp_country">';
foreach (Country::getCountries((int) $cookie->id_lang) as $country) {
foreach(Country::getCountries((int) $cookie->id_lang) as $country) {
$this->_html .= '<option value="'.$country['id_country'].'"'.(Configuration::get('MONDIALRELAY_EXP_COUNTRY') == $country['id_country']? ' selected="selected"': '').'>'.$country['name'].'</option>';
}
@ -810,7 +804,7 @@ class Logistics extends Module
';
$mondialrelay_carriers = unserialize(Configuration::get('MONDIALRELAYWS_CARRIERS', serialize(array())));
foreach (Db::getInstance()->ExecuteS('
foreach(Db::getInstance()->ExecuteS('
SELECT c.*
FROM `'._DB_PREFIX_.'carrier` c
') as $carrier) {
@ -826,9 +820,9 @@ class Logistics extends Module
<fieldset id="tab-4" style="line-height: 1.5em; display: none;">
';
foreach (Employee::getEmployees() as $employee) {
foreach(Employee::getEmployees() as $employee) {
$value = Configuration::get('LOGISTICS_QUEUE_'.(int) $employee['id_employee']);
// if ($value === FALSE) {
// if($value === FALSE) {
// $value = Configuration::get('LAPOSTEWS_EMPL_'.(int) $employee['id_employee']);
// }
@ -840,7 +834,7 @@ class Logistics extends Module
}
$lock = Configuration::get('LOGISTICS_LOCK');
if ($lock === false || empty($lock)) {
if($lock === FALSE || empty($lock)) {
$lock = serialize(array());
}
@ -868,21 +862,21 @@ class Logistics extends Module
$carriers = Configuration::get('LAPOSTEWS_CARRIERS');
if (in_array((int) $params['id_carrier'], $carriers)) {
if(in_array((int) $params['id_carrier'], $carriers)) {
$carriers[] = (int) $new_carrier_id;
Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize($carriers));
}
$carriers = Configuration::get('EXAPAQWS_CARRIERS');
if (in_array((int) $params['id_carrier'], $carriers)) {
if(in_array((int) $params['id_carrier'], $carriers)) {
$carriers[] = (int) $new_carrier_id;
Configuration::updateValue('EXAPAQWS_CARRIERS', serialize($carriers));
}
$carriers = Configuration::get('MONDIALRELAYWS_CARRIERS');
if (in_array((int) $params['id_carrier'], $carriers)) {
if(in_array((int) $params['id_carrier'], $carriers)) {
$carriers[] = (int) $new_carrier_id;
Configuration::updateValue('MONDIALRELAYWS_CARRIERS', serialize($carriers));
}

View File

@ -114,114 +114,15 @@ class AuthController extends AuthControllerCore
if (Tools::getValue('guest_email') !== false) {
$email = Tools::getValue('guest_email');
}
$email = $emailOri = strtolower(trim($email));
$email = strtolower(trim($email));
// Prepare Check email
$domains = array(
/* Default domains included */
"aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
"google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk",
/* Other global domains */
"email.com", "fastmail.fm", "games.com" /* AOL */, "gmx.net", "hush.com", "hushmail.com", "icloud.com",
"iname.com", "inbox.com", "lavabit.com", "love.com" /* AOL */, "outlook.com", "pobox.com", "protonmail.com",
"rocketmail.com" /* Yahoo */, "safe-mail.net", "wow.com" /* AOL */, "ygm.com" /* AOL */,
"ymail.com" /* Yahoo */, "zoho.com", "yandex.com",
/* United States ISP domains */
"bellsouth.net", "charter.net", "cox.net", "earthlink.net", "juno.com",
/* British ISP domains */
"btinternet.com", "virginmedia.com", "blueyonder.co.uk", "freeserve.co.uk", "live.co.uk",
"ntlworld.com", "o2.co.uk", "orange.net", "sky.com", "talktalk.co.uk", "tiscali.co.uk",
"virgin.net", "wanadoo.co.uk", "bt.com",
/* Domains used in Asia */
"sina.com", "qq.com", "naver.com", "hanmail.net", "daum.net", "nate.com", "yahoo.co.jp", "yahoo.co.kr", "yahoo.co.id", "yahoo.co.in", "yahoo.com.sg", "yahoo.com.ph",
/* French ISP domains */
"hotmail.fr", "live.fr", "laposte.net", "yahoo.fr", "wanadoo.fr", "orange.fr", "gmx.fr", "sfr.fr", "neuf.fr", "free.fr",
/* German ISP domains */
"gmx.de", "hotmail.de", "live.de", "online.de", "t-online.de" /* T-Mobile */, "web.de", "yahoo.de",
/* Italian ISP domains */
"libero.it", "virgilio.it", "hotmail.it", "aol.it", "tiscali.it", "alice.it", "live.it", "yahoo.it", "email.it", "tin.it", "poste.it", "teletu.it",
/* Russian ISP domains */
"mail.ru", "rambler.ru", "yandex.ru", "ya.ru", "list.ru",
/* Belgian ISP domains */
"hotmail.be", "live.be", "skynet.be", "voo.be", "tvcablenet.be", "telenet.be",
/* Argentinian ISP domains */
"hotmail.com.ar", "live.com.ar", "yahoo.com.ar", "fibertel.com.ar", "speedy.com.ar", "arnet.com.ar",
/* Domains used in Mexico */
"yahoo.com.mx", "live.com.mx", "hotmail.es", "hotmail.com.mx", "prodigy.net.mx",
/* Domains used in Brazil */
"yahoo.com.br", "hotmail.com.br", "outlook.com.br", "uol.com.br", "bol.com.br", "terra.com.br", "ig.com.br", "itelefonica.com.br", "r7.com", "zipmail.com.br", "globo.com", "globomail.com", "oi.com.br"
);
// Real association
$replaceSLD = array(
'@hotmil.' => '@hotmail.',
'@htmail.' => '@hotmail.',
'@hotmal.' => '@hotmail.',
'@hotml.' => '@hotmail.',
'@hotmai.' => '@hotmail.',
'@gmal.' => '@gmail.',
'@gail.' => '@gmail.',
'@gml.' => '@gmail.',
'@gmai.' => '@gmail.',
'@gmil.' => '@gmail.',
);
$replaceGlobal = array(
'@gmailcom' => '@gmail.com',
'@hotmailcom' => '@hotmail.com',
'@hotmailfr' => '@hotmail.fr',
'@yahoocom' => '@yahoo.com',
'@yahoofr' => '@yahoo.fr',
);
// Real use case replacement
$email = strtr($email, $replaceGlobal);
// Check TLD
$atPos = strpos($email, '@');
$pointPos = strpos($email, '.', $atPos);
$tld = substr($email, $pointPos + 1);
$sld = substr($email, $atPos + 1, strlen($email) - ($atPos+1) - (strlen($tld)+1) );
if (empty($tld)) {
$this->errors[] = Tools::displayError('Invalid email');
$_POST['email'] = '';
}
if (empty($this->errors)) {
// If you have a complete list of TLD, check it !
}
// Check SLD
if (empty($this->errors)) {
// Real use case replacement
$email = strtr($email, $replaceSLD);
// Levenhstein remplacement
if (count($domains) > 0 && $email == $emailOri) {
foreach ($domains as $d) {
$dpPos = strpos($d, '.');
$realDomain = substr($d, 0, $dpPos);
$lev = levenshtein($sld, $realDomain);
if ($lev == O) {
break;
}
elseif ($lev == 1 && $tld == substr($d, $dpPos+1)) {
$email = str_replace('@'.$sld.'.', '@'.$realDomain.'.', $email);
break;
}
}
}
}
/** @Override Antadis - mail fixing */
$email = str_replace(array('@hotmil.','@htmail.','@hotmal.','@hotml.','@hotmai.'),'@hotmail.', $email);
$email = str_replace(array('@gmal.','@gail.','@gml.','@gmai.','@gmil.'),'@gmail.', $email);
$email = str_replace('@gmailcom','@gmail.com', $email);
$email = str_replace('@hotmailcom','@hotmail.com', $email);
$email = str_replace('@hotmailfr','@hotmail.fr', $email);
/** @End Override Antadis - mail fixing */
/* Preparing customer */
$customer = new Customer();
@ -239,16 +140,14 @@ class AuthController extends AuthControllerCore
$_POST['firstname'] = $firstnameAddress;
if (!sizeof($this->errors)) {
if (Customer::customerExists($email)) {
if(Customer::customerExists($email)) {
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
}
if (Tools::isSubmit('newsletter')) {
if(Tools::isSubmit('newsletter')) {
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
}
$customer->email = $_POST['email'] = $email;
$customer->birthday = (empty($_POST['years'])? '': (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']));
if (!sizeof($this->errors)) {
@ -259,20 +158,13 @@ class AuthController extends AuthControllerCore
} else {
$customer->is_guest = 0;
}
if (!$customer->add()) {
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
} else {
if (!$customer->is_guest) {
if(!$customer->is_guest) {
if(!Mail::Send((int)(self::$cookie->id_lang), 'account', Mail::l('Welcome!'),
array(
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{email}' => $customer->email,
'{passwd}' => Tools::getValue('passwd')
), $customer->email, $customer->firstname.' '.$customer->lastname)) {
$this->errors[] = Tools::displayError('Cannot send email');
}
array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname.' '.$customer->lastname))
$this->errors[] = Tools::displayError('Cannot send email');
}
global $site_version_front;