From f02e902691923845af0f2d9b9e7b4d2863185a12 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 22 Oct 2023 21:29:09 +0700 Subject: [PATCH] Minor improvements (#982) * Minor improvements * Apply fixes from StyleCI (#981) Co-authored-by: StyleCI Bot --------- Co-authored-by: Yury Pikhtarev Co-authored-by: StyleCI Bot --- library/includes/ucp/bonus.php | 4 +-- library/includes/ucp/topic_watch.php | 2 +- src/Legacy/Cache/Common.php | 14 ++++++++-- src/Legacy/Cache/Sqlite.php | 8 +++--- src/Legacy/Common/Html.php | 1 + src/Legacy/Datastore/Common.php | 14 ++++++++-- src/Legacy/SqlDb.php | 11 ++++---- styles/templates/default/terms.tpl | 38 +++++++++++++------------- styles/templates/default/viewforum.tpl | 6 ++-- 9 files changed, 60 insertions(+), 38 deletions(-) diff --git a/library/includes/ucp/bonus.php b/library/includes/ucp/bonus.php index d172b7e6b..6298c4b2c 100644 --- a/library/includes/ucp/bonus.php +++ b/library/includes/ucp/bonus.php @@ -30,7 +30,7 @@ if (isset($_POST['bonus_id'])) { $points = $price_row[$id]; if ($userdata['user_points'] < $points) { - meta_refresh('index.php', 5); + meta_refresh('index.php', 10); $message = $lang['BONUS_NOT_SUCCES'] . '

' . $lang['BONUS_RETURN'] . '

' . $lang['RETURN_PROFILE'] . '

' . sprintf($lang['CLICK_RETURN_INDEX'], '', ''); @@ -47,7 +47,7 @@ if (isset($_POST['bonus_id'])) { "); \TorrentPier\Sessions::cache_rm_user_sessions($user_id); - meta_refresh(BONUS_URL, 5); + meta_refresh(BONUS_URL, 10); $message = sprintf($lang['BONUS_SUCCES'], humn_size($upload_row[$id] * 1024 * 1024 * 1024)); $message .= '

' . $lang['BONUS_RETURN'] . '

' . $lang['RETURN_PROFILE'] . '

' . sprintf($lang['CLICK_RETURN_INDEX'], '', ''); diff --git a/library/includes/ucp/topic_watch.php b/library/includes/ucp/topic_watch.php index 679b161e3..37c27bed5 100644 --- a/library/includes/ucp/topic_watch.php +++ b/library/includes/ucp/topic_watch.php @@ -95,7 +95,7 @@ if ($watch_count > 0) { } DB()->sql_freeresult($result); } else { - meta_refresh('index.php', 3); + meta_refresh('index.php'); bb_die($lang['NO_WATCHED_TOPICS']); } diff --git a/src/Legacy/Cache/Common.php b/src/Legacy/Cache/Common.php index 088ce6d76..41acaa66d 100644 --- a/src/Legacy/Cache/Common.php +++ b/src/Legacy/Cache/Common.php @@ -87,10 +87,20 @@ class Common } } - public function debug_find_source($mode = '') + /** + * Find caller source + * + * @param string $mode + * + * @return string + */ + public function debug_find_source(string $mode = ''): string { + if (!SQL_PREPEND_SRC_COMM) { + return 'src disabled'; + } foreach (debug_backtrace() as $trace) { - if ($trace['file'] !== __FILE__) { + if (!empty($trace['file']) && $trace['file'] !== __FILE__) { switch ($mode) { case 'file': return $trace['file']; diff --git a/src/Legacy/Cache/Sqlite.php b/src/Legacy/Cache/Sqlite.php index e88457fc1..b4cfc46c8 100644 --- a/src/Legacy/Cache/Sqlite.php +++ b/src/Legacy/Cache/Sqlite.php @@ -52,8 +52,8 @@ class Sqlite extends Common } $this->db->shard($name); $cached_items = []; - $this->prefix_len = \strlen($this->prefix); - $this->prefix_sql = SQLite3::escapeString($this->prefix); + $prefix_len = \strlen($this->prefix); + $prefix_sql = SQLite3::escapeString($this->prefix); $name_ary = $name_sql = (array)$name; array_deep($name_sql, 'SQLite3::escapeString'); @@ -62,13 +62,13 @@ class Sqlite extends Common $rowset = $this->db->fetch_rowset(" SELECT cache_name, cache_value FROM " . $this->cfg['table_name'] . " - WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . " + WHERE cache_name IN('$prefix_sql" . implode("','$prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . " LIMIT " . \count($name_sql) . " "); $this->db->debug('start', 'unserialize()'); foreach ($rowset as $row) { - $cached_items[substr($row['cache_name'], $this->prefix_len)] = unserialize($row['cache_value']); + $cached_items[substr($row['cache_name'], $prefix_len)] = unserialize($row['cache_value']); } $this->db->debug('stop'); diff --git a/src/Legacy/Common/Html.php b/src/Legacy/Common/Html.php index 58fe5d2c6..15fe47eb6 100644 --- a/src/Legacy/Common/Html.php +++ b/src/Legacy/Common/Html.php @@ -16,6 +16,7 @@ namespace TorrentPier\Legacy\Common; class Html { public $options = ''; + public $out = ''; public $attr = []; public $cur_attr; public $max_length = HTML_SELECT_MAX_LENGTH; diff --git a/src/Legacy/Datastore/Common.php b/src/Legacy/Datastore/Common.php index b759c1a55..9cea545bc 100644 --- a/src/Legacy/Datastore/Common.php +++ b/src/Legacy/Datastore/Common.php @@ -161,10 +161,20 @@ class Common } } - public function debug_find_source($mode = '') + /** + * Find caller source + * + * @param string $mode + * + * @return string + */ + public function debug_find_source(string $mode = ''): string { + if (!SQL_PREPEND_SRC_COMM) { + return 'src disabled'; + } foreach (debug_backtrace() as $trace) { - if ($trace['file'] !== __FILE__) { + if (!empty($trace['file']) && $trace['file'] !== __FILE__) { switch ($mode) { case 'file': return $trace['file']; diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index b0668f56e..46b92a864 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -128,9 +128,7 @@ class SqlDb if (\is_array($query)) { $query = $this->build_sql($query); } - if (SQL_PREPEND_SRC_COMM) { - $query = '/* ' . $this->debug_find_source() . ' */ ' . $query; - } + $query = '/* ' . $this->debug_find_source() . ' */ ' . $query; $this->cur_query = $query; $this->debug('start'); @@ -850,8 +848,11 @@ class SqlDb * * @return string */ - public function debug_find_source($mode = '') + public function debug_find_source(string $mode = ''): string { + if (!SQL_PREPEND_SRC_COMM) { + return 'src disabled'; + } foreach (debug_backtrace() as $trace) { if (!empty($trace['file']) && $trace['file'] !== __FILE__) { switch ($mode) { @@ -864,7 +865,7 @@ class SqlDb } } } - return ''; + return 'src not found'; } /** diff --git a/styles/templates/default/terms.tpl b/styles/templates/default/terms.tpl index 8a278f63c..7d2152e6f 100644 --- a/styles/templates/default/terms.tpl +++ b/styles/templates/default/terms.tpl @@ -1,21 +1,21 @@ - - - - - - - - - - - - - + + + + + + + + + + + + +
{L_TERMS}
-
- {TERMS_HTML} -
-
- {TERMS_EDIT} -
{L_TERMS}
+
+ {TERMS_HTML} +
+
+ {TERMS_EDIT} +
diff --git a/styles/templates/default/viewforum.tpl b/styles/templates/default/viewforum.tpl index 3c5083bd8..c68761eb2 100644 --- a/styles/templates/default/viewforum.tpl +++ b/styles/templates/default/viewforum.tpl @@ -165,11 +165,11 @@ ajax.callback.mod_action = function(data) {
- +  · - +  · - +  ·