Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Core/Business/Email/Core_Business_Email_EmailLister.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getAvailableMails($dir)

// Remove unwanted .html / .txt / .tpl / .php / . / ..
foreach ($mail_directory as $mail) {
if (strpos($mail->getFilename(), '.') !== false) {
if (str_contains($mail->getFilename(), '.')) {
$tmp = explode('.', $mail->getFilename());

// Check for filename existence (left part) and if extension is html (right part)
Expand All @@ -76,7 +76,7 @@ public function getAvailableMails($dir)
*/
public function getCleanedMailName($mail_name)
{
if (strpos($mail_name, '.') !== false) {
if (str_contains($mail_name, '.')) {
$tmp = explode('.', $mail_name);

if ($tmp === false || !isset($tmp[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public function __construct(

public function __call($method, $arguments)
{
if (0 === strpos($method, 'findOneBy')) {
if (str_starts_with($method, 'findOneBy')) {
$one = true;
$by = substr($method, 9);
} elseif (0 === strpos($method, 'findBy')) {
} elseif (str_starts_with($method, 'findBy')) {
$one = false;
$by = substr($method, 6);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Core/Foundation/IoC/Core_Foundation_IoC_Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function makeInstanceFromClassName($className, array $alreadySeen)

try {
$refl = new ReflectionClass($className);
} catch (ReflectionException $re) {
} catch (ReflectionException) {
throw new Core_Foundation_IoC_Exception(sprintf('This doesn\'t seem to be a class name: `%s`.', $className));
}

Expand Down
4 changes: 2 additions & 2 deletions admin/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
die(Tools::dieOrLog('The backup file does not exist.'));
}

if (substr($backupfile, -4) == '.bz2') {
if (str_ends_with($backupfile, '.bz2')) {
$contentType = 'application/x-bzip2';
} elseif (substr($backupfile, -3) == '.gz') {
} elseif (str_ends_with($backupfile, '.gz')) {
$contentType = 'application/x-gzip';
} else {
$contentType = 'text/x-sql';
Expand Down
4 changes: 2 additions & 2 deletions admin/filemanager/ajax_calls.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if (preg_match('/\.{1,2}[\/|\\\]/', $path_pos) !== 0
|| $filename !== fix_filename($filename, $transliteration)
|| !in_array(strtolower($info['extension']), array('jpg', 'jpeg', 'png'))
|| strpos($_POST['url'], 'http://featherfiles.aviary.com/') !== 0
|| !str_starts_with($_POST['url'], 'http://featherfiles.aviary.com/')
|| !isset($info['extension'])

) {
Expand Down Expand Up @@ -78,7 +78,7 @@
}*/
break;
case 'extract':
if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
if (str_starts_with($_POST['path'], '/') || str_contains($_POST['path'], '../') || str_starts_with($_POST['path'], './')) {
die('wrong path');
}
$path = $current_path.$_POST['path'];
Expand Down
16 changes: 8 additions & 8 deletions admin/filemanager/dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
}

//remember last position
setcookie('last_position', $subdir, time() + (86400 * 7));
setcookie('last_position', $subdir, ['expires' => time() + (86400 * 7)]);

if ($subdir == '') {
if (!empty($_COOKIE['last_position'])
&& strpos($_COOKIE['last_position'], '.') === false
&& !str_contains($_COOKIE['last_position'], '.')
) {
$subdir = trim($_COOKIE['last_position']);
}
Expand All @@ -42,9 +42,9 @@
$_SESSION['subfolder'] = '';
}
$subfolder = '';
if (!empty($_SESSION['subfolder']) && strpos($_SESSION['subfolder'], '../') === false
&& strpos($_SESSION['subfolder'], './') === false && strpos($_SESSION['subfolder'], '/') !== 0
&& strpos($_SESSION['subfolder'], '.') === false
if (!empty($_SESSION['subfolder']) && !str_contains($_SESSION['subfolder'], '../')
&& !str_contains($_SESSION['subfolder'], './') && !str_starts_with($_SESSION['subfolder'], '/')
&& !str_contains($_SESSION['subfolder'], '.')
) {
$subfolder = $_SESSION['subfolder'];
}
Expand Down Expand Up @@ -794,7 +794,7 @@ function extensionSort($x, $y)
);
foreach ($files as $file_array) {
$file = $file_array['file'];
if ($file == '.' || (isset($file_array['extension']) && $file_array['extension'] != lang_Type_dir) || ($file == '..' && $subdir == '') || in_array($file, $hidden_folders) || ($filter != '' && $file != ".." && strpos($file, $filter) === false)) {
if ($file == '.' || (isset($file_array['extension']) && $file_array['extension'] != lang_Type_dir) || ($file == '..' && $subdir == '') || in_array($file, $hidden_folders) || ($filter != '' && $file != ".." && !str_contains($file, $filter))) {
continue;
}
$new_name = fix_filename($file, $transliteration);
Expand Down Expand Up @@ -925,7 +925,7 @@ function extensionSort($x, $y)
foreach ($files as $nu => $file_array) {
$file = $file_array['file'];

if ($file == '.' || $file == '..' || is_dir($current_path.$subfolder.$subdir.$file) || in_array($file, $hidden_files) || !in_array(fix_strtolower($file_array['extension']), $ext) || ($filter != '' && strpos($file, $filter) === false)) {
if ($file == '.' || $file == '..' || is_dir($current_path.$subfolder.$subdir.$file) || in_array($file, $hidden_files) || !in_array(fix_strtolower($file_array['extension']), $ext) || ($filter != '' && !str_contains($file, $filter))) {
continue;
}

Expand Down Expand Up @@ -971,7 +971,7 @@ function extensionSort($x, $y)
try {
create_img_gd($file_path, $src_thumb, 122, 91);
new_thumbnails_creation($current_path.$subfolder.$subdir, $file_path, $file, $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height);
} catch (Exception $e) {
} catch (Exception) {
$src_thumb = $mini_src = "";
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin/filemanager/execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

if (preg_match('/\.{1,2}[\/|\\\]/', $_POST['path_thumb']) !== 0
|| preg_match('/\.{1,2}[\/|\\\]/', $_POST['path']) !== 0
|| ($realPath && strpos($realPath, realpath($current_path)) !== 0)
|| ($realPathThumb && strpos($realPathThumb, realpath($thumbs_base_path)) !== 0)
|| ($realPath && !str_starts_with($realPath, realpath($current_path)))
|| ($realPathThumb && !str_starts_with($realPathThumb, realpath($thumbs_base_path)))
) {
die('wrong path');
}
Expand Down
2 changes: 1 addition & 1 deletion admin/filemanager/force_download.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
die('wrong path');
}

if (strpos($_POST['name'], '/') !== false || strpos($_POST['name'], '\\') !== false) {
if (str_contains($_POST['name'], '/') || str_contains($_POST['name'], '\\')) {
die('wrong path');
}

Expand Down
14 changes: 7 additions & 7 deletions admin/filemanager/include/php_image_magician.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ function __construct($fileName)

private function initialise()
{
$this->psdReaderPath = dirname(__FILE__) . '/classPhpPsdReader.php';
$this->filterOverlayPath = dirname(__FILE__) . '/filters';
$this->psdReaderPath = __DIR__ . '/classPhpPsdReader.php';
$this->filterOverlayPath = __DIR__ . '/filters';

// *** Set if image should be interlaced or not.
$this->isInterlace = false;
Expand Down Expand Up @@ -315,7 +315,7 @@ public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false
$cropPos = 'm';
if (is_array($option) && fix_strtolower($option[0]) == 'crop') {
$cropPos = $option[1]; # get the crop option
} elseif (strpos($option, '-') !== false) {
} elseif (str_contains($option, '-')) {
// *** Or pass in a hyphen seperated option
$optionPiecesArray = explode('-', $option);
$cropPos = end($optionPiecesArray);
Expand Down Expand Up @@ -873,7 +873,7 @@ private function prepOption($option)
} else {
throw new Exception('Crop resize option array is badly formatted.');
}
} elseif (strpos($option, 'crop') !== false) {
} elseif (str_contains($option, 'crop')) {
return 'crop';
}

Expand Down Expand Up @@ -983,7 +983,7 @@ public function greyScaleEnhanced()
imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 2);
$this->sharpen($this->width);
$this->sharpen();
}
}

Expand Down Expand Up @@ -2169,7 +2169,7 @@ public function addText($text, $pos = '20x20', $padding = 0, $fontColor='#fff',
private function getTextFont($font)
{
// *** Font path (shou
$fontPath = dirname(__FILE__) . '/' . $this->fontDir;
$fontPath = __DIR__ . '/' . $this->fontDir;


// *** The below is/may be needed depending on your version (see ref)
Expand Down Expand Up @@ -3049,7 +3049,7 @@ private function transparentImage($src)
function checkStringStartsWith($needle, $haystack)
# Check if a string starts with a specific pattern
{
return (substr($haystack, 0, strlen($needle))==$needle);
return (str_starts_with($haystack, $needle));
}


Expand Down
5 changes: 2 additions & 3 deletions admin/filemanager/include/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function fix_filename($str, $transliteration)
// Empty or incorrectly transliterated filename.
// Here is a point: a good file UNKNOWN_LANGUAGE.jpg could become .jpg in previous code.
// So we add that default 'file' name to fix that issue.
if (strpos($str, '.') === 0) {
if (str_starts_with($str, '.')) {
$str = 'file'.$str;
}

Expand Down Expand Up @@ -291,7 +291,7 @@ function image_check_memory_usage($img, $max_breedte, $max_hoogte)

function endsWith($haystack, $needle)
{
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
return $needle === "" || str_ends_with($haystack, $needle);
}

function new_thumbnails_creation($targetPath, $targetFile, $name, $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height)
Expand Down Expand Up @@ -352,7 +352,6 @@ function get_file_by_url($url)
curl_setopt($ch, CURLOPT_URL, $url);

$data = curl_exec($ch);
curl_close($ch);

return $data;
}
Expand Down
4 changes: 2 additions & 2 deletions admin/filemanager/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
$storeFolder = $_POST['path'];
$storeFolderThumb = $_POST['path_thumb'];

$path_pos = strpos($storeFolder, $current_path);
$thumb_pos = strpos($_POST['path_thumb'], $thumbs_base_path);
$path_pos = strpos($storeFolder, (string) $current_path);
$thumb_pos = strpos($_POST['path_thumb'], (string) $thumbs_base_path);

if ($path_pos === false || $thumb_pos === false
|| preg_match('/\.{1,2}[\/|\\\]/', $_POST['path_thumb']) !== 0
Expand Down
8 changes: 4 additions & 4 deletions admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,11 @@ function runAdminTab($tab, $ajax_mode = false)
foreach ($_POST as $key => $value) {
if (is_array($admin_obj->table)) {
foreach ($admin_obj->table as $table) {
if (strncmp($key, $table.'Filter_', 7) === 0 || strncmp($key, 'submitFilter', 12) === 0) {
if (strncmp($key, $table.'Filter_', 7) === 0 || str_starts_with($key, 'submitFilter')) {
$cookie->$key = !is_array($value) ? $value : json_encode($value);
}
}
} elseif (strncmp($key, $admin_obj->table.'Filter_', 7) === 0 || strncmp($key, 'submitFilter', 12) === 0) {
} elseif (strncmp($key, $admin_obj->table.'Filter_', 7) === 0 || str_starts_with($key, 'submitFilter')) {
$cookie->$key = !is_array($value) ? $value : json_encode($value);
}
}
Expand Down Expand Up @@ -515,7 +515,7 @@ function runAdminTab($tab, $ajax_mode = false)

// ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17)
$url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$admin_obj->token.'$2', $_SERVER['REQUEST_URI']);
if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) {
if (!str_contains($url, '?token=') && !str_contains($url, '&token=')) {
$url .= '&token='.$admin_obj->token;
}

Expand All @@ -530,7 +530,7 @@ function runAdminTab($tab, $ajax_mode = false)

// ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17)
$url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$admin_obj->token.'$2', $_SERVER['REQUEST_URI']);
if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) {
if (!str_contains($url, '?token=') && !str_contains($url, '&token=')) {
$url .= '&token='.$admin_obj->token;
}

Expand Down
22 changes: 12 additions & 10 deletions classes/AdminTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function __construct()
{
$this->context = Context::getContext();

$this->id = Tab::getIdFromClassName(get_class($this));
$this->id = Tab::getIdFromClassName(static::class);
$this->_conf = array(
1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'),
3 => $this->l('Creation successful'), 4 => $this->l('Update successful'),
Expand All @@ -225,7 +225,7 @@ public function __construct()
if (!$this->_defaultOrderBy) {
$this->_defaultOrderBy = $this->identifier;
}
$className = get_class($this);
$className = static::class;
// if ($className == 'AdminCategories' OR $className == 'AdminProducts')
// $className = 'AdminCatalog';
$this->token = Tools::getAdminToken($className.(int)$this->id.(int)$this->context->employee->id);
Expand All @@ -247,19 +247,19 @@ public function __construct()
protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true)
{
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
$current_class = get_class($this);
$current_class = static::class;
if (Module::getModuleNameFromClass($current_class)) {
$string = str_replace('\'', '\\\'', $string);
return Translate::getModuleTranslation(Module::$classInModule[$current_class], $string, $current_class);
}
global $_LANGADM;

if ($class == __CLASS__) {
if ($class == self::class) {
$class = 'AdminTab';
}

$key = md5(str_replace('\'', '\\\'', $string));
$str = (array_key_exists(get_class($this).$key, $_LANGADM)) ? $_LANGADM[get_class($this).$key] : ((array_key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : $string);
$str = (array_key_exists(static::class.$key, $_LANGADM)) ? $_LANGADM[static::class.$key] : ((array_key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : $string);
$str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str)));
}
Expand Down Expand Up @@ -1189,7 +1189,7 @@ protected function copyFromPost(&$object, $table)
}

/* Multilingual fields */
$rules = call_user_func(array(get_class($object), 'getValidationRules'), get_class($object));
$rules = call_user_func(array($object::class, 'getValidationRules'), $object::class);
if (count($rules['validateLang'])) {
$language_ids = Language::getIDs(false);
foreach ($language_ids as $id_lang) {
Expand Down Expand Up @@ -1673,7 +1673,9 @@ public function displayListContent($token = null)

$irow = 0;
if ($this->_list && isset($this->fieldsDisplay['position'])) {
$positions = array_map(create_function('$elem', 'return (int)$elem[\'position\'];'), $this->_list);
$positions = array_map(function ($elem) {
return (int) $elem['position'];
}, $this->_list);
sort($positions);
}
if ($this->_list) {
Expand Down Expand Up @@ -1805,7 +1807,7 @@ protected function _displayEnableLink($token, $id, $value, $active, $id_category
protected function _displayDuplicate($token, $id)
{
$_cacheLang['Duplicate'] = $this->l('Duplicate');
$_cacheLang['Copy images too?'] = $this->l('This will copy the images too. If you wish to proceed, click "OK". If not, click "Cancel".', __CLASS__, true, false);
$_cacheLang['Copy images too?'] = $this->l('This will copy the images too. If you wish to proceed, click "OK". If not, click "Cancel".', self::class, true, false);
$duplicate = Tools::safeOutput(self::$currentIndex.'&'.$this->identifier.'='.$id.'&duplicate'.$this->table.'&token='.($token != null ? $token : $this->token));

echo '<a class="pointer" onclick="if (confirm(\''.$_cacheLang['Copy images too?'].'\')) document.location = \''.$duplicate.'\'; else document.location = \''.$duplicate.'&noimage=1\';">
Expand Down Expand Up @@ -1833,7 +1835,7 @@ protected function _displayEditLink($token, $id)
protected function _displayDeleteLink($token, $id)
{
$_cacheLang['Delete'] = $this->l('Delete');
$_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, true, false);
$_cacheLang['DeleteItem'] = $this->l('Delete item #', self::class, true, false);
$href = Tools::safeOutput(self::$currentIndex.'&'.$this->identifier.'='.(int)$id.'&delete'.$this->table.'&token='.($token != null ? $token : $this->token));

echo '<a href="'.$href.'" onclick="return confirm(\''.$_cacheLang['DeleteItem'].(int)$id.' ?'.
Expand All @@ -1848,7 +1850,7 @@ public function displayListFooter($token = null)
{
echo '</table>';
if ($this->delete) {
echo '<p><input type="submit" class="button" name="submitDel'.$this->table.'" value="'.$this->l('Delete selection').'" onclick="return confirm(\''.$this->l('Delete selected items?', __CLASS__, true, false).'\');" /></p>';
echo '<p><input type="submit" class="button" name="submitDel'.$this->table.'" value="'.$this->l('Delete selection').'" onclick="return confirm(\''.$this->l('Delete selected items?', self::class, true, false).'\');" /></p>';
}
echo '
</td>
Expand Down
Loading