diff --git a/controllers/admin/AdminHomeController.php b/controllers/admin/AdminHomeController.php
index 5f7eeb75c..bb1393892 100644
--- a/controllers/admin/AdminHomeController.php
+++ b/controllers/admin/AdminHomeController.php
@@ -59,16 +59,16 @@ class AdminHomeControllerCore extends AdminController
{
$stat = stat(dirname(__FILE__).'/../../.htaccess');
$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;
$dateUpdate = Configuration::get('PS_LAST_SHOP_UPDATE');
- if ($dateUpdate AND strtotime($dateUpdate) > $stat['mtime'])
+ if ($dateUpdate && strtotime($dateUpdate) > $stat['mtime'])
$htaccessAfterUpdate = 0;
}
$indexRebuiltAfterUpdate = 0;
- $needRebuild=Configuration::get('PS_NEED_REBUILD_INDEX');
- if($needRebuild !='0');
+ $needRebuild = Configuration::get('PS_NEED_REBUILD_INDEX');
+ if ($needRebuild != '0');
$indexRebuiltAfterUpdate = 2;
$smartyOptimized = 0;
@@ -77,10 +77,10 @@ class AdminHomeControllerCore extends AdminController
if (Configuration::get('PS_SMARTY_CACHE'))
++$smartyOptimized;
- $cccOptimized = Configuration::get('PS_CSS_THEME_CACHE')
- + Configuration::get('PS_JS_THEME_CACHE')
- + Configuration::get('PS_HTML_THEME_COMPRESSION')
- + Configuration::get('PS_JS_HTML_THEME_COMPRESSION');
+ $cccOptimized = Configuration::get('PS_CSS_THEME_CACHE');
+ $cccOptimized += Configuration::get('PS_JS_THEME_CACHE');
+ $cccOptimized += Configuration::get('PS_HTML_THEME_COMPRESSION');
+ $cccOptimized += Configuration::get('PS_JS_HTML_THEME_COMPRESSION');
if ($cccOptimized == 4)
$cccOptimized = 2;
else
@@ -96,7 +96,7 @@ class AdminHomeControllerCore extends AdminController
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(
'title' => $this->l('URL rewriting'),
'href' => $link->getAdminLink('AdminGenerator'),
@@ -146,8 +146,8 @@ class AdminHomeControllerCore extends AdminController
'image' => $lights[$htaccessAfterUpdate]['image'],
);
}
- $this->context->smarty->assign('opti_list',$opti_list);
- $this->context->smarty->assign('content',$content);
+ $this->context->smarty->assign('opti_list', $opti_list);
+ $this->context->smarty->assign('content', $content);
$template = $this->createTemplate('optimizationTips.tpl');
return $template->fetch();
}
@@ -155,14 +155,14 @@ class AdminHomeControllerCore extends AdminController
public function setMedia()
{
parent::setMedia();
- if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== false)
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
$this->addJqueryPlugin('excanvas');
$this->addJqueryPlugin('flot');
}
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:').' '.$_SERVER['HTTP_HOST'].'
'.
$this->l('This one is different from the main shop domain name set in "Preferences > SEO & URLs":').' '.Configuration::get('PS_SHOP_DOMAIN').'
'.
@@ -351,7 +351,7 @@ class AdminHomeControllerCore extends AdminController
$orders = Order::getOrdersWithInformations(10);
$i = 0;
- foreach ($orders AS $order)
+ foreach ($orders as $order)
{
$currency = Currency::getCurrency((int)$order['id_currency']);
$content .= '
@@ -536,17 +536,16 @@ class AdminHomeControllerCore extends AdminController
$this->warnDomainName();
$protocol = Tools::usingSecureMode()?'https':'http';
- $smarty->assign('protocol',$protocol);
+ $smarty->assign('protocol', $protocol);
$isoUser = $this->context->language->iso_code;
- $smarty->assign('isoUser',$isoUser);
+ $smarty->assign('isoUser', $isoUser);
$upgrade = null;
$tpl_vars['refresh_check_version'] = 0;
if (@ini_get('allow_url_fopen'))
{
$upgrade = new Upgrader(true);
// if this information is outdated, the version will be checked after page loading
- if (Configuration::get('PS_LAST_VERSION_CHECK')
- < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
+ if (Configuration::get('PS_LAST_VERSION_CHECK') < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
$tpl_vars['refresh_check_version'] = 1;
}
@@ -560,8 +559,8 @@ class AdminHomeControllerCore extends AdminController
$tpl_vars['monthly_statistics'] = $this->getMonthlyStatistics();
$tpl_vars['customers_service'] = $this->getCustomersService();
$tpl_vars['stats_sales'] = $this->getStatsSales();
- $tpl_vars['last_orders'] =$this->getLastOrders();
- $tpl_vars['tips_optimization'] = $this->_displayOptimizationTips();
+ $tpl_vars['last_orders'] = $this->getLastOrders();
+ $tpl_vars['tips_optimization'] = $this->_displayOptimizationTips();
$smarty->assign($tpl_vars);
}
diff --git a/controllers/admin/AdminImagesController.php b/controllers/admin/AdminImagesController.php
index c06b40c75..a04b62827 100644
--- a/controllers/admin/AdminImagesController.php
+++ b/controllers/admin/AdminImagesController.php
@@ -254,7 +254,7 @@ class AdminImagesControllerCore extends AdminController
{
if ($this->tabAccess['edit'] === '1')
{
- if($this->_moveImagesToNewFileSystem())
+ if ($this->_moveImagesToNewFileSystem())
Tools::redirectAdmin(self::$currentIndex.'&conf=25'.'&token='.$this->token);
}
else
@@ -286,7 +286,7 @@ class AdminImagesControllerCore extends AdminController
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.');
}
@@ -322,9 +322,9 @@ class AdminImagesControllerCore extends AdminController
if (!is_dir($dir))
return false;
$toDel = scandir($dir);
- foreach ($toDel AS $d)
- foreach ($type AS $imageType)
- if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) OR preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d))
+ foreach ($toDel as $d)
+ foreach ($type as $imageType)
+ if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) || preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d))
if (file_exists($dir.$d))
unlink($dir.$d);
@@ -332,15 +332,15 @@ class AdminImagesControllerCore extends AdminController
if ($product)
{
$productsImages = Image::getAllImages();
- foreach ($productsImages AS $k => $image)
+ foreach ($productsImages as $image)
{
$imageObj = new Image($image['id_image']);
$imageObj->id_product = $image['id_product'];
if (file_exists($dir.$imageObj->getImgFolder()))
{
$toDel = scandir($dir.$imageObj->getImgFolder());
- foreach ($toDel AS $d)
- foreach ($type AS $imageType)
+ foreach ($toDel as $d)
+ foreach ($type as $imageType)
if (preg_match('/^[0-9]+\-'.$imageType['name'].'\.jpg$/', $d))
if (file_exists($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)
{
if (!is_dir($dir))
@@ -358,9 +365,9 @@ class AdminImagesControllerCore extends AdminController
$toRegen = scandir($dir);
if (!$productsImages)
{
- foreach ($toRegen AS $image)
+ foreach ($toRegen as $image)
if (preg_match('/^[0-9]*\.jpg$/', $image))
- foreach ($type AS $k => $imageType)
+ foreach ($type as $k => $imageType)
{
// Customizable writing dir
$newDir = $dir;
@@ -378,11 +385,11 @@ class AdminImagesControllerCore extends AdminController
else
{
$productsImages = Image::getAllImages();
- foreach ($productsImages AS $k => $image)
+ foreach ($productsImages as $image)
{
$imageObj = new Image($image['id_image']);
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 (!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;
}
- // Regenerate no-pictures images
+ /**
+ * Regenerate no-pictures images
+ *
+ * @param $dir
+ * @param $type
+ * @param $languages
+ * @return bool
+ */
protected function _regenerateNoPictureImages($dir, $type, $languages)
{
$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';
if (!file_exists($file))
@@ -415,7 +429,7 @@ class AdminImagesControllerCore extends AdminController
return $errors;
}
- // Hook watermark optimization
+ /* Hook watermark optimization */
protected function _regenerateWatermark($dir)
{
$result = Db::getInstance()->executeS('
@@ -433,7 +447,7 @@ class AdminImagesControllerCore extends AdminController
if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg'))
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));
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';
@@ -460,10 +474,10 @@ class AdminImagesControllerCore extends AdminController
);
// Launching generation process
- foreach ($process AS $k => $proc)
+ foreach ($process as $proc)
{
if ($type != 'all' && $type != $proc['type'])
- continue ;
+ continue;
// Getting format generation
$formats = ImageType::getImagesTypes($proc['type']);
@@ -471,7 +485,7 @@ class AdminImagesControllerCore extends AdminController
{
$format = strval(Tools::getValue('format_'.$type));
if ($format != 'all')
- foreach ($formats AS $k => $form)
+ foreach ($formats as $k => $form)
if ($form['id_image_type'] != $format)
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.');
}
}
- 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()
{
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
{
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');
$result = Image::moveToNewFileSystem($this->max_execution_time);
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)
- $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()
diff --git a/controllers/admin/AdminLanguagesController.php b/controllers/admin/AdminLanguagesController.php
index 60748aa68..5f40aeba3 100644
--- a/controllers/admin/AdminLanguagesController.php
+++ b/controllers/admin/AdminLanguagesController.php
@@ -488,22 +488,22 @@ class AdminLanguagesControllerCore extends AdminController
public function ajaxProcessCheckLangPack()
{
$this->json = true;
- if(empty($_GET['iso_lang']))
+ if (empty($_GET['iso_lang']))
{
$this->status = 'error';
$this->errors[] = '[TECHNICAL ERROR] iso_lang not set or empty';
}
- if(empty($_GET['ps_version']))
+ if (empty($_GET['ps_version']))
{
$this->status = 'error';
$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
$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->content = $lang_packs;
diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php
index 4b8cc66a7..2500b11f7 100755
--- a/controllers/admin/AdminLoginController.php
+++ b/controllers/admin/AdminLoginController.php
@@ -50,13 +50,13 @@ class AdminLoginControllerCore extends AdminController
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
// header('HTTP/1.1 301 Moved Permanently');
// header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
// 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 ($clientIsMaintenanceOrLocal)
$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')
- || (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(
array(
'randomNb' => rand(100, 999),
'wrong_folder_name' => true)
);
- if ($nbErrors = sizeof($this->errors))
+ if ($nbErrors = count($this->errors))
$this->context->smarty->assign(
array(
'errors' => $this->errors,
@@ -132,7 +131,7 @@ class AdminLoginControllerCore extends AdminController
else if (!Validate::isPasswd($passwd))
$this->errors[] = Tools::displayError('Invalid password');
- if (!sizeof($this->errors))
+ if (!count($this->errors))
{
/* Seeking for employee */
$employee = new Employee();
@@ -181,15 +180,15 @@ class AdminLoginControllerCore extends AdminController
else
{
$employee = new Employee();
- if (!$employee->getByemail($email) OR !$employee)
+ if (!$employee->getByemail($email) || !$employee)
$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)');
}
if (_PS_MODE_DEMO_)
$errors[] = Tools::displayError('This functionnality has been disabled.');
- if(!sizeof($this->errors))
+ if (!count($this->errors))
{
$pwd = Tools::passwdGen();
$employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd));
diff --git a/controllers/admin/AdminMetaController.php b/controllers/admin/AdminMetaController.php
index f7376c553..e0d0a2e2e 100644
--- a/controllers/admin/AdminMetaController.php
+++ b/controllers/admin/AdminMetaController.php
@@ -188,11 +188,11 @@ class AdminMetaControllerCore extends AdminController
}
else
{ // index.php can have empty rewrite rule
- $defaultLangIsValidated = !Tools::getValue('url_rewrite_'.$default_language) OR Validate::isLinkRewrite(Tools::getValue('url_rewrite_'.$default_language));
- $englishLangIsValidated = !Tools::getValue('url_rewrite_1') OR Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
+ $defaultLangIsValidated = !Tools::getValue('url_rewrite_'.$default_language) || Validate::isLinkRewrite(Tools::getValue('url_rewrite_'.$default_language));
+ $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.');
return false;
@@ -214,7 +214,7 @@ class AdminMetaControllerCore extends AdminController
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));
}
@@ -228,13 +228,13 @@ class AdminMetaControllerCore extends AdminController
{
$default_routes = Dispatcher::getInstance()->default_routes;
if (!isset($default_routes[$routeID]))
- return ;
+ return;
$rule = Tools::getValue('PS_ROUTE_'.$routeID);
if (!$rule || $rule == $default_routes[$routeID]['rule'])
{
Configuration::updateValue('PS_ROUTE_'.$routeID, '');
- return ;
+ return;
}
$errors = array();