// Normalize

This commit is contained in:
rMalie
2012-01-25 16:48:14 +00:00
parent 22b0bd937d
commit 2ca3b2b029
5 changed files with 77 additions and 65 deletions
+19 -20
View File
@@ -59,16 +59,16 @@ class AdminHomeControllerCore extends AdminController
{ {
$stat = stat(dirname(__FILE__).'/../../.htaccess'); $stat = stat(dirname(__FILE__).'/../../.htaccess');
$dateUpdHtaccess = Db::getInstance()->getValue('SELECT date_upd FROM '._DB_PREFIX_.'configuration WHERE name = "PS_HTACCESS_CACHE_CONTROL"'); $dateUpdHtaccess = Db::getInstance()->getValue('SELECT date_upd FROM '._DB_PREFIX_.'configuration WHERE name = "PS_HTACCESS_CACHE_CONTROL"');
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL') AND strtotime($dateUpdHtaccess) > $stat['mtime']) if (Configuration::get('PS_HTACCESS_CACHE_CONTROL') && strtotime($dateUpdHtaccess) > $stat['mtime'])
$htaccessOptimized = 1; $htaccessOptimized = 1;
$dateUpdate = Configuration::get('PS_LAST_SHOP_UPDATE'); $dateUpdate = Configuration::get('PS_LAST_SHOP_UPDATE');
if ($dateUpdate AND strtotime($dateUpdate) > $stat['mtime']) if ($dateUpdate && strtotime($dateUpdate) > $stat['mtime'])
$htaccessAfterUpdate = 0; $htaccessAfterUpdate = 0;
} }
$indexRebuiltAfterUpdate = 0; $indexRebuiltAfterUpdate = 0;
$needRebuild=Configuration::get('PS_NEED_REBUILD_INDEX'); $needRebuild = Configuration::get('PS_NEED_REBUILD_INDEX');
if($needRebuild !='0'); if ($needRebuild != '0');
$indexRebuiltAfterUpdate = 2; $indexRebuiltAfterUpdate = 2;
$smartyOptimized = 0; $smartyOptimized = 0;
@@ -77,10 +77,10 @@ class AdminHomeControllerCore extends AdminController
if (Configuration::get('PS_SMARTY_CACHE')) if (Configuration::get('PS_SMARTY_CACHE'))
++$smartyOptimized; ++$smartyOptimized;
$cccOptimized = Configuration::get('PS_CSS_THEME_CACHE') $cccOptimized = Configuration::get('PS_CSS_THEME_CACHE');
+ Configuration::get('PS_JS_THEME_CACHE') $cccOptimized += Configuration::get('PS_JS_THEME_CACHE');
+ Configuration::get('PS_HTML_THEME_COMPRESSION') $cccOptimized += Configuration::get('PS_HTML_THEME_COMPRESSION');
+ Configuration::get('PS_JS_HTML_THEME_COMPRESSION'); $cccOptimized += Configuration::get('PS_JS_HTML_THEME_COMPRESSION');
if ($cccOptimized == 4) if ($cccOptimized == 4)
$cccOptimized = 2; $cccOptimized = 2;
else else
@@ -96,7 +96,7 @@ class AdminHomeControllerCore extends AdminController
if ($rewrite + $htaccessOptimized + $smartyOptimized + $cccOptimized + $shopEnabled + $htaccessAfterUpdate + $indexRebuiltAfterUpdate != 14) if ($rewrite + $htaccessOptimized + $smartyOptimized + $cccOptimized + $shopEnabled + $htaccessAfterUpdate + $indexRebuiltAfterUpdate != 14)
{ {
$this->context->smarty->assign('hide_tips',Configuration::get('PS_HIDE_OPTIMIZATION_TIPS')); $this->context->smarty->assign('hide_tips', Configuration::get('PS_HIDE_OPTIMIZATION_TIPS'));
$opti_list[] = array( $opti_list[] = array(
'title' => $this->l('URL rewriting'), 'title' => $this->l('URL rewriting'),
'href' => $link->getAdminLink('AdminGenerator'), 'href' => $link->getAdminLink('AdminGenerator'),
@@ -146,8 +146,8 @@ class AdminHomeControllerCore extends AdminController
'image' => $lights[$htaccessAfterUpdate]['image'], 'image' => $lights[$htaccessAfterUpdate]['image'],
); );
} }
$this->context->smarty->assign('opti_list',$opti_list); $this->context->smarty->assign('opti_list', $opti_list);
$this->context->smarty->assign('content',$content); $this->context->smarty->assign('content', $content);
$template = $this->createTemplate('optimizationTips.tpl'); $template = $this->createTemplate('optimizationTips.tpl');
return $template->fetch(); return $template->fetch();
} }
@@ -155,14 +155,14 @@ class AdminHomeControllerCore extends AdminController
public function setMedia() public function setMedia()
{ {
parent::setMedia(); parent::setMedia();
if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== false) if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
$this->addJqueryPlugin('excanvas'); $this->addJqueryPlugin('excanvas');
$this->addJqueryPlugin('flot'); $this->addJqueryPlugin('flot');
} }
protected function warnDomainName() protected function warnDomainName()
{ {
if ($_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') AND $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL')) if ($_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN') && $_SERVER['HTTP_HOST'] != Configuration::get('PS_SHOP_DOMAIN_SSL'))
$this->displayWarning($this->l('You are currently connected with the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />'. $this->displayWarning($this->l('You are currently connected with the following domain name:').' <span style="color: #CC0000;">'.$_SERVER['HTTP_HOST'].'</span><br />'.
$this->l('This one is different from the main shop domain name set in "Preferences > SEO & URLs":').' <span style="color: #CC0000;">'.Configuration::get('PS_SHOP_DOMAIN').'</span><br /> $this->l('This one is different from the main shop domain name set in "Preferences > SEO & URLs":').' <span style="color: #CC0000;">'.Configuration::get('PS_SHOP_DOMAIN').'</span><br />
<a href="index.php?tab=AdminMeta&token='.Tools::getAdminTokenLite('AdminMeta').'#SEO%20%26%20URLs">'. <a href="index.php?tab=AdminMeta&token='.Tools::getAdminTokenLite('AdminMeta').'#SEO%20%26%20URLs">'.
@@ -351,7 +351,7 @@ class AdminHomeControllerCore extends AdminController
$orders = Order::getOrdersWithInformations(10); $orders = Order::getOrdersWithInformations(10);
$i = 0; $i = 0;
foreach ($orders AS $order) foreach ($orders as $order)
{ {
$currency = Currency::getCurrency((int)$order['id_currency']); $currency = Currency::getCurrency((int)$order['id_currency']);
$content .= ' $content .= '
@@ -536,17 +536,16 @@ class AdminHomeControllerCore extends AdminController
$this->warnDomainName(); $this->warnDomainName();
$protocol = Tools::usingSecureMode()?'https':'http'; $protocol = Tools::usingSecureMode()?'https':'http';
$smarty->assign('protocol',$protocol); $smarty->assign('protocol', $protocol);
$isoUser = $this->context->language->iso_code; $isoUser = $this->context->language->iso_code;
$smarty->assign('isoUser',$isoUser); $smarty->assign('isoUser', $isoUser);
$upgrade = null; $upgrade = null;
$tpl_vars['refresh_check_version'] = 0; $tpl_vars['refresh_check_version'] = 0;
if (@ini_get('allow_url_fopen')) if (@ini_get('allow_url_fopen'))
{ {
$upgrade = new Upgrader(true); $upgrade = new Upgrader(true);
// if this information is outdated, the version will be checked after page loading // if this information is outdated, the version will be checked after page loading
if (Configuration::get('PS_LAST_VERSION_CHECK') if (Configuration::get('PS_LAST_VERSION_CHECK') < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
< time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
$tpl_vars['refresh_check_version'] = 1; $tpl_vars['refresh_check_version'] = 1;
} }
@@ -560,8 +559,8 @@ class AdminHomeControllerCore extends AdminController
$tpl_vars['monthly_statistics'] = $this->getMonthlyStatistics(); $tpl_vars['monthly_statistics'] = $this->getMonthlyStatistics();
$tpl_vars['customers_service'] = $this->getCustomersService(); $tpl_vars['customers_service'] = $this->getCustomersService();
$tpl_vars['stats_sales'] = $this->getStatsSales(); $tpl_vars['stats_sales'] = $this->getStatsSales();
$tpl_vars['last_orders'] =$this->getLastOrders(); $tpl_vars['last_orders'] = $this->getLastOrders();
$tpl_vars['tips_optimization'] = $this->_displayOptimizationTips(); $tpl_vars['tips_optimization'] = $this->_displayOptimizationTips();
$smarty->assign($tpl_vars); $smarty->assign($tpl_vars);
} }
+40 -26
View File
@@ -254,7 +254,7 @@ class AdminImagesControllerCore extends AdminController
{ {
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
if($this->_moveImagesToNewFileSystem()) if ($this->_moveImagesToNewFileSystem())
Tools::redirectAdmin(self::$currentIndex.'&conf=25'.'&token='.$this->token); Tools::redirectAdmin(self::$currentIndex.'&conf=25'.'&token='.$this->token);
} }
else else
@@ -286,7 +286,7 @@ class AdminImagesControllerCore extends AdminController
protected function _childValidation() protected function _childValidation()
{ {
if (!Tools::getValue('id_image_type') AND Validate::isImageTypeName($typeName = Tools::getValue('name')) AND ImageType::typeAlreadyExists($typeName)) if (!Tools::getValue('id_image_type') && Validate::isImageTypeName($typeName = Tools::getValue('name')) && ImageType::typeAlreadyExists($typeName))
$this->errors[] = Tools::displayError('This name already exists.'); $this->errors[] = Tools::displayError('This name already exists.');
} }
@@ -322,9 +322,9 @@ class AdminImagesControllerCore extends AdminController
if (!is_dir($dir)) if (!is_dir($dir))
return false; return false;
$toDel = scandir($dir); $toDel = scandir($dir);
foreach ($toDel AS $d) foreach ($toDel as $d)
foreach ($type AS $imageType) foreach ($type as $imageType)
if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) OR preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d)) if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) || preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d))
if (file_exists($dir.$d)) if (file_exists($dir.$d))
unlink($dir.$d); unlink($dir.$d);
@@ -332,15 +332,15 @@ class AdminImagesControllerCore extends AdminController
if ($product) if ($product)
{ {
$productsImages = Image::getAllImages(); $productsImages = Image::getAllImages();
foreach ($productsImages AS $k => $image) foreach ($productsImages as $image)
{ {
$imageObj = new Image($image['id_image']); $imageObj = new Image($image['id_image']);
$imageObj->id_product = $image['id_product']; $imageObj->id_product = $image['id_product'];
if (file_exists($dir.$imageObj->getImgFolder())) if (file_exists($dir.$imageObj->getImgFolder()))
{ {
$toDel = scandir($dir.$imageObj->getImgFolder()); $toDel = scandir($dir.$imageObj->getImgFolder());
foreach ($toDel AS $d) foreach ($toDel as $d)
foreach ($type AS $imageType) foreach ($type as $imageType)
if (preg_match('/^[0-9]+\-'.$imageType['name'].'\.jpg$/', $d)) if (preg_match('/^[0-9]+\-'.$imageType['name'].'\.jpg$/', $d))
if (file_exists($dir.$imageObj->getImgFolder().$d)) if (file_exists($dir.$imageObj->getImgFolder().$d))
unlink($dir.$imageObj->getImgFolder().$d); unlink($dir.$imageObj->getImgFolder().$d);
@@ -349,7 +349,14 @@ class AdminImagesControllerCore extends AdminController
} }
} }
// Regenerate images /**
* Regenerate images
*
* @param $dir
* @param $type
* @param bool $productsImages
* @return bool|string
*/
protected function _regenerateNewImages($dir, $type, $productsImages = false) protected function _regenerateNewImages($dir, $type, $productsImages = false)
{ {
if (!is_dir($dir)) if (!is_dir($dir))
@@ -358,9 +365,9 @@ class AdminImagesControllerCore extends AdminController
$toRegen = scandir($dir); $toRegen = scandir($dir);
if (!$productsImages) if (!$productsImages)
{ {
foreach ($toRegen AS $image) foreach ($toRegen as $image)
if (preg_match('/^[0-9]*\.jpg$/', $image)) if (preg_match('/^[0-9]*\.jpg$/', $image))
foreach ($type AS $k => $imageType) foreach ($type as $k => $imageType)
{ {
// Customizable writing dir // Customizable writing dir
$newDir = $dir; $newDir = $dir;
@@ -378,11 +385,11 @@ class AdminImagesControllerCore extends AdminController
else else
{ {
$productsImages = Image::getAllImages(); $productsImages = Image::getAllImages();
foreach ($productsImages AS $k => $image) foreach ($productsImages as $image)
{ {
$imageObj = new Image($image['id_image']); $imageObj = new Image($image['id_image']);
if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg')) if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg'))
foreach ($type AS $k => $imageType) foreach ($type as $imageType)
{ {
if (!file_exists($dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg')) if (!file_exists($dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg'))
if (!ImageManager::resize($dir.$imageObj->getExistingImgPath().'.jpg', $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height']))) if (!ImageManager::resize($dir.$imageObj->getExistingImgPath().'.jpg', $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height'])))
@@ -396,13 +403,20 @@ class AdminImagesControllerCore extends AdminController
return $errors; return $errors;
} }
// Regenerate no-pictures images /**
* Regenerate no-pictures images
*
* @param $dir
* @param $type
* @param $languages
* @return bool
*/
protected function _regenerateNoPictureImages($dir, $type, $languages) protected function _regenerateNoPictureImages($dir, $type, $languages)
{ {
$errors = false; $errors = false;
foreach ($type AS $k => $imageType) foreach ($type as $imageType)
{ {
foreach ($languages AS $language) foreach ($languages as $language)
{ {
$file = $dir.$language['iso_code'].'.jpg'; $file = $dir.$language['iso_code'].'.jpg';
if (!file_exists($file)) if (!file_exists($file))
@@ -415,7 +429,7 @@ class AdminImagesControllerCore extends AdminController
return $errors; return $errors;
} }
// Hook watermark optimization /* Hook watermark optimization */
protected function _regenerateWatermark($dir) protected function _regenerateWatermark($dir)
{ {
$result = Db::getInstance()->executeS(' $result = Db::getInstance()->executeS('
@@ -433,7 +447,7 @@ class AdminImagesControllerCore extends AdminController
if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg')) if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg'))
foreach ($result as $module) foreach ($result as $module)
{ {
if ($moduleInstance = Module::getInstanceByName($module['name']) AND is_callable(array($moduleInstance, 'hookwatermark'))) if ($moduleInstance = Module::getInstanceByName($module['name']) && is_callable(array($moduleInstance, 'hookwatermark')))
call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $imageObj->id, 'id_product' => $imageObj->id_product)); call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $imageObj->id, 'id_product' => $imageObj->id_product));
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
return 'timeout'; return 'timeout';
@@ -460,10 +474,10 @@ class AdminImagesControllerCore extends AdminController
); );
// Launching generation process // Launching generation process
foreach ($process AS $k => $proc) foreach ($process as $proc)
{ {
if ($type != 'all' && $type != $proc['type']) if ($type != 'all' && $type != $proc['type'])
continue ; continue;
// Getting format generation // Getting format generation
$formats = ImageType::getImagesTypes($proc['type']); $formats = ImageType::getImagesTypes($proc['type']);
@@ -471,7 +485,7 @@ class AdminImagesControllerCore extends AdminController
{ {
$format = strval(Tools::getValue('format_'.$type)); $format = strval(Tools::getValue('format_'.$type));
if ($format != 'all') if ($format != 'all')
foreach ($formats AS $k => $form) foreach ($formats as $k => $form)
if ($form['id_image_type'] != $format) if ($form['id_image_type'] != $format)
unset($formats[$k]); unset($formats[$k]);
} }
@@ -492,7 +506,7 @@ class AdminImagesControllerCore extends AdminController
$this->errors[] = Tools::displayError('Cannot write no-picture image to').' ('.$proc['type'].') '.Tools::displayError('images folder. Please check the folder\'s writing permissions.'); $this->errors[] = Tools::displayError('Cannot write no-picture image to').' ('.$proc['type'].') '.Tools::displayError('images folder. Please check the folder\'s writing permissions.');
} }
} }
return (sizeof($this->errors) > 0 ? false : true); return (count($this->errors) > 0 ? false : true);
} }
/** /**
@@ -512,18 +526,18 @@ class AdminImagesControllerCore extends AdminController
protected function _moveImagesToNewFileSystem() protected function _moveImagesToNewFileSystem()
{ {
if (!Image::testFileSystem()) if (!Image::testFileSystem())
$this->errors[] = Tools::displayError('Error: your server configuration is not compatible with the new image system. No images were moved'); $this->errors[] = Tools::displayError('Error: your server configuration is not compatible with the new image system. No images were moved');
else else
{ {
ini_set('max_execution_time', $this->max_execution_time); // ini_set may be disabled, we need the real value ini_set('max_execution_time', $this->max_execution_time); // ini_set may be disabled, we need the real value
$this->max_execution_time = (int)ini_get('max_execution_time'); $this->max_execution_time = (int)ini_get('max_execution_time');
$result = Image::moveToNewFileSystem($this->max_execution_time); $result = Image::moveToNewFileSystem($this->max_execution_time);
if ($result === 'timeout') if ($result === 'timeout')
$this->errors[] = Tools::displayError('Not all images have been moved, server timed out before finishing. Click on \"Move images\" again to resume moving images'); $this->errors[] = Tools::displayError('Not all images have been moved, server timed out before finishing. Click on \"Move images\" again to resume moving images');
else if ($result === false) else if ($result === false)
$this->errors[] = Tools::displayError('Error: some or all images could not be moved.'); $this->errors[] = Tools::displayError('Error: some or all images could not be moved.');
} }
return (sizeof($this->errors) > 0 ? false : true); return (count($this->errors) > 0 ? false : true);
} }
public function initContent() public function initContent()
@@ -488,22 +488,22 @@ class AdminLanguagesControllerCore extends AdminController
public function ajaxProcessCheckLangPack() public function ajaxProcessCheckLangPack()
{ {
$this->json = true; $this->json = true;
if(empty($_GET['iso_lang'])) if (empty($_GET['iso_lang']))
{ {
$this->status = 'error'; $this->status = 'error';
$this->errors[] = '[TECHNICAL ERROR] iso_lang not set or empty'; $this->errors[] = '[TECHNICAL ERROR] iso_lang not set or empty';
} }
if(empty($_GET['ps_version'])) if (empty($_GET['ps_version']))
{ {
$this->status = 'error'; $this->status = 'error';
$this->errors[] = '[TECHNICAL ERROR] ps_version not set or empty'; $this->errors[] = '[TECHNICAL ERROR] ps_version not set or empty';
} }
if(@fsockopen('api.prestashop.com', 80)) if (@fsockopen('api.prestashop.com', 80))
{ {
// Get all iso code available // Get all iso code available
$lang_packs = Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']); $lang_packs = Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']);
if ($lang_packs !== '' && Tools::jsonDecode($lang_packs) !== NULL) if ($lang_packs !== '' && Tools::jsonDecode($lang_packs) !== null)
{ {
$this->status = 'ok'; $this->status = 'ok';
$this->content = $lang_packs; $this->content = $lang_packs;
+8 -9
View File
@@ -50,13 +50,13 @@ class AdminLoginControllerCore extends AdminController
public function initContent() public function initContent()
{ {
if ((empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED')) if ((empty($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off') && Configuration::get('PS_SSL_ENABLED'))
{ {
// You can uncomment these lines if you want to force https even from localhost and automatically redirect // You can uncomment these lines if you want to force https even from localhost and automatically redirect
// header('HTTP/1.1 301 Moved Permanently'); // header('HTTP/1.1 301 Moved Permanently');
// header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); // header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
// exit(); // exit();
$clientIsMaintenanceOrLocal = in_array(Tools::getRemoteAddr(), array_merge(array('127.0.0.1'),explode(',', Configuration::get('PS_MAINTENANCE_IP')))); $clientIsMaintenanceOrLocal = in_array(Tools::getRemoteAddr(), array_merge(array('127.0.0.1'), explode(',', Configuration::get('PS_MAINTENANCE_IP'))));
// If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP // If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP
if ($clientIsMaintenanceOrLocal) if ($clientIsMaintenanceOrLocal)
$this->errors = Tools::displayError('SSL is activated. However, your IP is allowed to use unsecure mode (Maintenance or local IP).'); $this->errors = Tools::displayError('SSL is activated. However, your IP is allowed to use unsecure mode (Maintenance or local IP).');
@@ -71,15 +71,14 @@ class AdminLoginControllerCore extends AdminController
if (file_exists(_PS_ADMIN_DIR_.'/../install') || file_exists(_PS_ADMIN_DIR_.'/../admin') if (file_exists(_PS_ADMIN_DIR_.'/../install') || file_exists(_PS_ADMIN_DIR_.'/../admin')
|| (file_exists(_PS_ADMIN_DIR_.'/../install-new') && (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_)) || (file_exists(_PS_ADMIN_DIR_.'/../install-new') && (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_)))
)
$this->context->smarty->assign( $this->context->smarty->assign(
array( array(
'randomNb' => rand(100, 999), 'randomNb' => rand(100, 999),
'wrong_folder_name' => true) 'wrong_folder_name' => true)
); );
if ($nbErrors = sizeof($this->errors)) if ($nbErrors = count($this->errors))
$this->context->smarty->assign( $this->context->smarty->assign(
array( array(
'errors' => $this->errors, 'errors' => $this->errors,
@@ -132,7 +131,7 @@ class AdminLoginControllerCore extends AdminController
else if (!Validate::isPasswd($passwd)) else if (!Validate::isPasswd($passwd))
$this->errors[] = Tools::displayError('Invalid password'); $this->errors[] = Tools::displayError('Invalid password');
if (!sizeof($this->errors)) if (!count($this->errors))
{ {
/* Seeking for employee */ /* Seeking for employee */
$employee = new Employee(); $employee = new Employee();
@@ -181,15 +180,15 @@ class AdminLoginControllerCore extends AdminController
else else
{ {
$employee = new Employee(); $employee = new Employee();
if (!$employee->getByemail($email) OR !$employee) if (!$employee->getByemail($email) || !$employee)
$this->errors[] = Tools::displayError('This account does not exist'); $this->errors[] = Tools::displayError('This account does not exist');
else if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0 ) else if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0)
$this->errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)'); $this->errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)');
} }
if (_PS_MODE_DEMO_) if (_PS_MODE_DEMO_)
$errors[] = Tools::displayError('This functionnality has been disabled.'); $errors[] = Tools::displayError('This functionnality has been disabled.');
if(!sizeof($this->errors)) if (!count($this->errors))
{ {
$pwd = Tools::passwdGen(); $pwd = Tools::passwdGen();
$employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd)); $employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd));
+6 -6
View File
@@ -188,11 +188,11 @@ class AdminMetaControllerCore extends AdminController
} }
else else
{ // index.php can have empty rewrite rule { // index.php can have empty rewrite rule
$defaultLangIsValidated = !Tools::getValue('url_rewrite_'.$default_language) OR Validate::isLinkRewrite(Tools::getValue('url_rewrite_'.$default_language)); $defaultLangIsValidated = !Tools::getValue('url_rewrite_'.$default_language) || Validate::isLinkRewrite(Tools::getValue('url_rewrite_'.$default_language));
$englishLangIsValidated = !Tools::getValue('url_rewrite_1') OR Validate::isLinkRewrite(Tools::getValue('url_rewrite_1')); $englishLangIsValidated = !Tools::getValue('url_rewrite_1') || Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
} }
if (!$defaultLangIsValidated AND !$englishLangIsValidated) if (!$defaultLangIsValidated && !$englishLangIsValidated)
{ {
$this->errors[] = Tools::displayError('Url rewrite field must be filled at least in default or english language.'); $this->errors[] = Tools::displayError('Url rewrite field must be filled at least in default or english language.');
return false; return false;
@@ -214,7 +214,7 @@ class AdminMetaControllerCore extends AdminController
return parent::postProcess(); return parent::postProcess();
} }
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false) public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = false)
{ {
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->getID(true)); parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->getID(true));
} }
@@ -228,13 +228,13 @@ class AdminMetaControllerCore extends AdminController
{ {
$default_routes = Dispatcher::getInstance()->default_routes; $default_routes = Dispatcher::getInstance()->default_routes;
if (!isset($default_routes[$routeID])) if (!isset($default_routes[$routeID]))
return ; return;
$rule = Tools::getValue('PS_ROUTE_'.$routeID); $rule = Tools::getValue('PS_ROUTE_'.$routeID);
if (!$rule || $rule == $default_routes[$routeID]['rule']) if (!$rule || $rule == $default_routes[$routeID]['rule'])
{ {
Configuration::updateValue('PS_ROUTE_'.$routeID, ''); Configuration::updateValue('PS_ROUTE_'.$routeID, '');
return ; return;
} }
$errors = array(); $errors = array();