diff --git a/common.php b/common.php
index b3455ce98..72cafbf27 100644
--- a/common.php
+++ b/common.php
@@ -190,11 +190,11 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac
$bytes_written = false;
clearstatcache();
- if (($max_size && file_exists($file) && is_file($file)) && filesize($file) >= $max_size) {
+ if (is_file($file) && ($max_size && filesize($file) >= $max_size)) {
$file_parts = pathinfo($file);
$new_name = ($file_parts['dirname'] . '/' . $file_parts['filename'] . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . '.' . $file_parts['extension']);
clearstatcache();
- if (!file_exists($new_name) && !is_file($new_name)) {
+ if (!is_file($new_name)) {
rename($file, $new_name);
}
}
@@ -269,6 +269,7 @@ function str_compact($str)
*
* @param int $length
* @return string
+ * @throws Exception
*/
function make_rand_str(int $length = 10): string
{
diff --git a/src/Legacy/BBCode.php b/src/Legacy/BBCode.php
index 9425ae0f8..b8af68f8b 100644
--- a/src/Legacy/BBCode.php
+++ b/src/Legacy/BBCode.php
@@ -16,13 +16,13 @@ namespace TorrentPier\Legacy;
class BBCode
{
/** @var array $tpl Replacements for some code elements */
- public $tpl = [];
+ public array $tpl = [];
/** @var array $smilies Replacements for smilies */
public $smilies;
/** @var array $tidy_cfg Tidy preprocessor configuration */
- public $tidy_cfg = [
+ public array $tidy_cfg = [
'drop-empty-paras' => false,
'fix-uri' => false,
'force-output' => true,
@@ -42,7 +42,7 @@ class BBCode
];
/** @var array $block_tags Define some elements as block-processed */
- public $block_tags = [
+ public array $block_tags = [
'align',
'br',
'clear',
@@ -142,7 +142,7 @@ class BBCode
*
* @return string
*/
- public function bbcode2html($text): string
+ public function bbcode2html(string $text): string
{
global $bb_cfg;
@@ -166,7 +166,7 @@ class BBCode
*
* @return string
*/
- private function parse($text): string
+ private function parse(string $text): string
{
// Tag parse
if (!str_contains($text, '[')) {
@@ -205,23 +205,22 @@ class BBCode
*
* @return string
*/
- public static function clean_up($text): string
+ public static function clean_up(string $text): string
{
$text = trim($text);
$text = str_replace("\r", '', $text);
$text = preg_replace('#[ \t]+$#m', '', $text);
- $text = preg_replace('#\n{3,}#', "\n\n", $text);
- return $text;
+ return preg_replace('#\n{3,}#', "\n\n", $text);
}
/**
* Callback to [code]
*
- * @param string $m
+ * @param array $m
*
* @return string
*/
- private function code_callback($m): string
+ private function code_callback(array $m): string
{
$code = trim($m[2]);
$code = str_replace(' ', ' ', $code);
@@ -234,11 +233,11 @@ class BBCode
/**
* Callback to [url]
*
- * @param string $m
+ * @param array $m
*
* @return string
*/
- private function url_callback($m): string
+ private function url_callback(array $m): string
{
global $bb_cfg;
@@ -261,11 +260,11 @@ class BBCode
/**
* Callback to escape titles in block elements
*
- * @param string $m
+ * @param array $m
*
* @return string
*/
- private function escape_titles_callback($m): string
+ private function escape_titles_callback(array $m): string
{
$title = substr($m[3], 0, 250);
$title = str_replace(['[', ']', ':', ')', '"'], ['[', ']', ':', ')', '"'], $title);
@@ -281,7 +280,7 @@ class BBCode
*
* @return string
*/
- private function make_clickable($text): string
+ private function make_clickable(string $text): string
{
$url_regexp = "#
(?smilies) {
$this->smilies = $datastore->get('smile_replacements');
@@ -364,11 +363,10 @@ class BBCode
*
* @return string
*/
- private function new_line2html($text): string
+ private function new_line2html(string $text): string
{
$text = preg_replace('#\n{2,}#', '
', $text);
- $text = str_replace("\n", '
', $text);
- return $text;
+ return str_replace("\n", '
', $text);
}
/**
@@ -378,9 +376,8 @@ class BBCode
*
* @return string
*/
- private function tidy($text): string
+ private function tidy(string $text): string
{
- $text = tidy_repair_string($text, $this->tidy_cfg, 'utf8');
- return $text;
+ return tidy_repair_string($text, $this->tidy_cfg, 'utf8');
}
}
diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php
index 2cb572651..2c3821c92 100644
--- a/src/Legacy/Common/User.php
+++ b/src/Legacy/Common/User.php
@@ -219,12 +219,12 @@ class User
// Initial ban check
if ($banInfo = getBanInfo((int)$this->id)) {
+ $this->session_end();
if (!empty($banInfo['ban_reason'])) {
- bb_die($lang['YOU_BEEN_BANNED'] . '
' . $banInfo['ban_reason']);
+ bb_die($lang['YOU_BEEN_BANNED'] . '
' . $lang['REASON'] . ': ' . '' . $banInfo['ban_reason'] . '');
} else {
bb_die($lang['YOU_BEEN_BANNED']);
}
- $this->session_end();
}
return $this->data;
diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php
index 428bbdb22..cbb6a6a85 100644
--- a/src/Legacy/SqlDb.php
+++ b/src/Legacy/SqlDb.php
@@ -939,7 +939,7 @@ class SqlDb
$msg[] = 'PID : ' . sprintf('%05d', getmypid());
$msg[] = 'Request : ' . trim(print_r($_REQUEST, true)) . str_repeat('_', 78) . LOG_LF;
$msg[] = '';
- bb_log($msg, IN_TRACKER ? SQL_TR_LOG_NAME : SQL_BB_LOG_NAME);
+ bb_log($msg, (defined('IN_TRACKER') ? SQL_TR_LOG_NAME : SQL_BB_LOG_NAME));
}
/**
diff --git a/styles/templates/admin/admin_attachments.tpl b/styles/templates/admin/admin_attachments.tpl
index b7578f27b..abbeb62a2 100644
--- a/styles/templates/admin/admin_attachments.tpl
+++ b/styles/templates/admin/admin_attachments.tpl
@@ -34,7 +34,7 @@