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
* 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_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;

View file

@ -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 = "<a href=\"$href\" class=\"postLink\">$name</a>";
} else {
$link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>";

View file

@ -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;