From 3b8ee4c4d3ab4631425fbe44f197b6a9bd7d158c Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 2 Mar 2025 14:15:41 +0700 Subject: [PATCH] misc: Some minor improvements (#1829) --- ajax.php | 2 +- src/Legacy/Attach.php | 4 ++-- src/Legacy/BBCode.php | 4 +--- src/Legacy/Common/Upload.php | 7 +++++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ajax.php b/ajax.php index dad885165..abe638c8e 100644 --- a/ajax.php +++ b/ajax.php @@ -41,5 +41,5 @@ $ajax->exec(); /** * @deprecated ajax_common * Dirty class removed from here since 2.2.0 - * To add new actions see at src/Legacy/Ajax.php + * To add new actions see at src/Ajax.php */ diff --git a/src/Legacy/Attach.php b/src/Legacy/Attach.php index c85593abb..3123a2aa5 100644 --- a/src/Legacy/Attach.php +++ b/src/Legacy/Attach.php @@ -67,7 +67,7 @@ class Attach $this->attachment_extension_list = get_var('extension_list', ['']); $this->attachment_mimetype_list = get_var('mimetype_list', ['']); - $this->filename = (isset($_FILES['fileupload'], $_FILES['fileupload']['name']) && $_FILES['fileupload']['name'] !== 'none') ? trim(stripslashes($_FILES['fileupload']['name'])) : ''; + $this->filename = (isset($_FILES['fileupload']['name']) && $_FILES['fileupload']['name'] !== 'none') ? trim(stripslashes($_FILES['fileupload']['name'])) : ''; $this->attachment_list = get_var('attachment_list', ['']); $this->attachment_thumbnail_list = get_var('attach_thumbnail_list', [0]); @@ -431,7 +431,7 @@ class Attach } } - // Get current informations to delete the Old Attachment + // Get current information to delete the Old Attachment $sql = 'SELECT physical_filename, comment, thumbnail FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int)$attachment_id; diff --git a/src/Legacy/BBCode.php b/src/Legacy/BBCode.php index 06efda6eb..622718974 100644 --- a/src/Legacy/BBCode.php +++ b/src/Legacy/BBCode.php @@ -9,8 +9,6 @@ namespace TorrentPier\Legacy; -use function in_array; - /** * Class BBCode * @package TorrentPier\Legacy @@ -388,7 +386,7 @@ class BBCode { global $bb_cfg; - if (in_array(parse_url($href, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) { + if (\in_array(parse_url($href, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) { $link = "$name"; } else { $link = "$name"; diff --git a/src/Legacy/Common/Upload.php b/src/Legacy/Common/Upload.php index 858b59fc7..685614803 100644 --- a/src/Legacy/Common/Upload.php +++ b/src/Legacy/Common/Upload.php @@ -9,6 +9,9 @@ namespace TorrentPier\Legacy\Common; +use claviska\SimpleImage; +use Exception; + /** * Class Upload * @package TorrentPier\Legacy\Common @@ -165,14 +168,14 @@ class Upload if (($this->cfg['max_width'] && $width > $this->cfg['max_width']) || ($this->cfg['max_height'] && $height > $this->cfg['max_height'])) { for ($i = 0, $max_try = 3; $i <= $max_try; $i++) { try { - $image = new \claviska\SimpleImage(); + $image = new SimpleImage(); $image ->fromFile($this->file['tmp_name']) ->autoOrient() ->resize($this->cfg['max_width'], $this->cfg['max_height']) ->toFile($this->file['tmp_name']); break; - } catch (\Exception $e) { + } catch (Exception $e) { if ($i == $max_try) { $this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']); return false;