misc: Some minor improvements (#1829)

This commit is contained in:
Roman Kelesidis 2025-03-02 14:15:41 +07:00 committed by GitHub
parent 380c94ff07
commit 3b8ee4c4d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 8 deletions

View file

@ -41,5 +41,5 @@ $ajax->exec();
/** /**
* @deprecated ajax_common * @deprecated ajax_common
* Dirty class removed from here since 2.2.0 * 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
*/ */

View file

@ -67,7 +67,7 @@ class Attach
$this->attachment_extension_list = get_var('extension_list', ['']); $this->attachment_extension_list = get_var('extension_list', ['']);
$this->attachment_mimetype_list = get_var('mimetype_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_list = get_var('attachment_list', ['']);
$this->attachment_thumbnail_list = get_var('attach_thumbnail_list', [0]); $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 $sql = 'SELECT physical_filename, comment, thumbnail
FROM ' . BB_ATTACHMENTS_DESC . ' FROM ' . BB_ATTACHMENTS_DESC . '
WHERE attach_id = ' . (int)$attachment_id; WHERE attach_id = ' . (int)$attachment_id;

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy; namespace TorrentPier\Legacy;
use function in_array;
/** /**
* Class BBCode * Class BBCode
* @package TorrentPier\Legacy * @package TorrentPier\Legacy
@ -388,7 +386,7 @@ class BBCode
{ {
global $bb_cfg; 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 = "<a href=\"$href\" class=\"postLink\">$name</a>"; $link = "<a href=\"$href\" class=\"postLink\">$name</a>";
} else { } else {
$link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>"; $link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>";

View file

@ -9,6 +9,9 @@
namespace TorrentPier\Legacy\Common; namespace TorrentPier\Legacy\Common;
use claviska\SimpleImage;
use Exception;
/** /**
* Class Upload * Class Upload
* @package TorrentPier\Legacy\Common * @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'])) { 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++) { for ($i = 0, $max_try = 3; $i <= $max_try; $i++) {
try { try {
$image = new \claviska\SimpleImage(); $image = new SimpleImage();
$image $image
->fromFile($this->file['tmp_name']) ->fromFile($this->file['tmp_name'])
->autoOrient() ->autoOrient()
->resize($this->cfg['max_width'], $this->cfg['max_height']) ->resize($this->cfg['max_width'], $this->cfg['max_height'])
->toFile($this->file['tmp_name']); ->toFile($this->file['tmp_name']);
break; break;
} catch (\Exception $e) { } catch (Exception $e) {
if ($i == $max_try) { if ($i == $max_try) {
$this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']); $this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']);
return false; return false;