Minor improvements (#1523)

* Minor improvements

* Update CHANGELOG.md

* Update composer.lock

* Update User.php

* Updated

* Update Torrent.php

* Update Template.php

* Updated

* Update SqlDb.php

* Update Select.php

* Updated

* Updated

* Update viewtopic.tpl

* Updated

* Update viewforum.tpl
This commit is contained in:
Roman Kelesidis 2024-06-22 11:39:33 +07:00 committed by GitHub
commit b37f2d3666
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 116 additions and 240 deletions

View file

@ -15,7 +15,7 @@
- Some security enhancements (Part 2) [\#1505](https://github.com/torrentpier/torrentpier/pull/1505) ([belomaxorka](https://github.com/belomaxorka))
- Some improvements for integrity checker [\#1501](https://github.com/torrentpier/torrentpier/pull/1501) ([belomaxorka](https://github.com/belomaxorka))
- Hide vote button in topic if guest [\#1507](https://github.com/torrentpier/torrentpier/pull/1507) ([belomaxorka](https://github.com/belomaxorka))
- Minor improvements [\#1502](https://github.com/torrentpier/torrentpier/pull/1502), [\#1506](https://github.com/torrentpier/torrentpier/pull/1506), [\#1509](https://github.com/torrentpier/torrentpier/pull/1509), [\#1511](https://github.com/torrentpier/torrentpier/pull/1511), [\#1515](https://github.com/torrentpier/torrentpier/pull/1515), [\#1516](https://github.com/torrentpier/torrentpier/pull/1516), [\#1517](https://github.com/torrentpier/torrentpier/pull/1517), [\#1519](https://github.com/torrentpier/torrentpier/pull/1519) ([belomaxorka](https://github.com/belomaxorka))
- Minor improvements [\#1502](https://github.com/torrentpier/torrentpier/pull/1502), [\#1506](https://github.com/torrentpier/torrentpier/pull/1506), [\#1509](https://github.com/torrentpier/torrentpier/pull/1509), [\#1511](https://github.com/torrentpier/torrentpier/pull/1511), [\#1515](https://github.com/torrentpier/torrentpier/pull/1515), [\#1516](https://github.com/torrentpier/torrentpier/pull/1516), [\#1517](https://github.com/torrentpier/torrentpier/pull/1517), [\#1519](https://github.com/torrentpier/torrentpier/pull/1519), [\#1523](https://github.com/torrentpier/torrentpier/pull/1523) ([belomaxorka](https://github.com/belomaxorka))
- New Crowdin updates [\#1504](https://github.com/torrentpier/torrentpier/pull/1504), [\#1513](https://github.com/torrentpier/torrentpier/pull/1513) ([Exileum](https://github.com/Exileum))
## [v2.4.3](https://github.com/torrentpier/torrentpier/tree/v2.4.3) (2024-06-09)

View file

@ -52,7 +52,7 @@ $stat += DB()->fetch_row('SELECT COUNT(DISTINCT user_id) AS u_bt_active FROM ' .
// All bt-users
$stat += DB()->fetch_row('SELECT COUNT(*) AS u_bt_all FROM ' . BB_BT_USERS);
// All bb-users
$stat += DB()->fetch_row('SELECT COUNT(*) AS u_bb_all FROM ' . BB_USERS);
$stat += DB()->fetch_row('SELECT COUNT(*) AS u_bb_all FROM ' . BB_USERS . ' WHERE user_id != ' . BOT_UID);
// Active torrents
$stat += DB()->fetch_row('SELECT COUNT(DISTINCT topic_id) AS tor_active FROM ' . TMP_TRACKER_TABLE);
// With seeder
@ -70,7 +70,7 @@ foreach ($peers_in_last_minutes as $t) {
}
// Last xx seconds
$peers_in_last_sec = [];
$rowset = DB()->fetch_rowset('SELECT COUNT(*) AS peers FROM ' . TMP_TRACKER_TABLE . ' GROUP BY update_time ORDER BY update_time DESC LIMIT ' . $peers_in_last_sec_limit);
$rowset = DB()->fetch_rowset('SELECT COUNT(*) AS peers FROM ' . TMP_TRACKER_TABLE . ' ORDER BY update_time DESC LIMIT ' . $peers_in_last_sec_limit);
foreach ($rowset as $cnt => $row) {
$peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : '');
}

105
composer.lock generated
View file

@ -1521,16 +1521,16 @@
},
{
"name": "nikic/iter",
"version": "v2.4.0",
"version": "v2.4.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/iter.git",
"reference": "09cd930fa9ff55747f34c7184532a5a1bd2385b1"
"reference": "3f031ae08d82c4394410e76b88b441331a6fa15f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/iter/zipball/09cd930fa9ff55747f34c7184532a5a1bd2385b1",
"reference": "09cd930fa9ff55747f34c7184532a5a1bd2385b1",
"url": "https://api.github.com/repos/nikic/iter/zipball/3f031ae08d82c4394410e76b88b441331a6fa15f",
"reference": "3f031ae08d82c4394410e76b88b441331a6fa15f",
"shasum": ""
},
"require": {
@ -1567,9 +1567,9 @@
],
"support": {
"issues": "https://github.com/nikic/iter/issues",
"source": "https://github.com/nikic/iter/tree/v2.4.0"
"source": "https://github.com/nikic/iter/tree/v2.4.1"
},
"time": "2023-12-10T20:43:19+00:00"
"time": "2024-03-19T20:45:05+00:00"
},
{
"name": "phpoption/phpoption",
@ -2335,23 +2335,25 @@
},
{
"name": "symfony/filesystem",
"version": "v6.4.7",
"version": "v6.4.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4"
"reference": "4d37529150e7081c51b3c5d5718c55a04a9503f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/78dde75f8f6dbbca4ec436a4b0087f7af02076d4",
"reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/4d37529150e7081c51b3c5d5718c55a04a9503f3",
"reference": "4d37529150e7081c51b3c5d5718c55a04a9503f3",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.8",
"symfony/process": "^5.4|^6.4"
"symfony/polyfill-mbstring": "~1.8"
},
"require-dev": {
"symfony/process": "^5.4|^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -2379,7 +2381,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v6.4.7"
"source": "https://github.com/symfony/filesystem/tree/v6.4.8"
},
"funding": [
{
@ -2395,20 +2397,20 @@
"type": "tidelift"
}
],
"time": "2024-04-18T09:22:46+00:00"
"time": "2024-05-31T14:49:08+00:00"
},
{
"name": "symfony/finder",
"version": "v6.4.7",
"version": "v6.4.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "511c48990be17358c23bf45c5d71ab85d40fb764"
"reference": "3ef977a43883215d560a2cecb82ec8e62131471c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/511c48990be17358c23bf45c5d71ab85d40fb764",
"reference": "511c48990be17358c23bf45c5d71ab85d40fb764",
"url": "https://api.github.com/repos/symfony/finder/zipball/3ef977a43883215d560a2cecb82ec8e62131471c",
"reference": "3ef977a43883215d560a2cecb82ec8e62131471c",
"shasum": ""
},
"require": {
@ -2443,7 +2445,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.4.7"
"source": "https://github.com/symfony/finder/tree/v6.4.8"
},
"funding": [
{
@ -2459,7 +2461,7 @@
"type": "tidelift"
}
],
"time": "2024-04-23T10:36:43+00:00"
"time": "2024-05-31T14:49:08+00:00"
},
{
"name": "symfony/mailer",
@ -3103,67 +3105,6 @@
],
"time": "2024-01-29T20:11:03+00:00"
},
{
"name": "symfony/process",
"version": "v6.4.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "cdb1c81c145fd5aa9b0038bab694035020943381"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/cdb1c81c145fd5aa9b0038bab694035020943381",
"reference": "cdb1c81c145fd5aa9b0038bab694035020943381",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v6.4.7"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-04-18T09:22:46+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.5.0",
@ -3428,5 +3369,5 @@
"php": "^8.1"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.3.0"
}

View file

@ -693,6 +693,7 @@ $bb_cfg['tracker'] = [
'retracker_host' => 'http://retracker.local/announce',
'guest_tracker' => true,
'search_by_tor_status' => true,
'random_release_button' => true,
'freeleech' => false, // freeleech mode (If enabled, then disable "gold_silver_enabled")
'gold_silver_enabled' => true, // golden / silver days mode (If enabled, then disable "freeleech")
'hybrid_stat_protocol' => 1, // For hybrid torrents there are two identical requests sent by clients, for counting stats we gotta choose one, you can change this to '2' in future, when v1 protocol is outdated

View file

@ -61,6 +61,7 @@ $lang['DISABLED'] = 'Disabled';
$lang['ERROR'] = 'Error';
$lang['SELECT_ACTION'] = 'Select action';
$lang['CLEAR'] = 'Clear';
$lang['MOVE_TO_TOP'] = 'Move to top';
$lang['UNKNOWN'] = 'Unknown';
$lang['NEXT_PAGE'] = 'Next';

View file

@ -11,8 +11,6 @@ namespace TorrentPier\Helpers;
use Longman\IPTools\Ip;
use function strlen;
/**
* Class IPHelper
* @package TorrentPier\Helpers

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
/**
* Class APCu
* @package TorrentPier\Legacy\Cache

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
/**
* Class Common
* @package TorrentPier\Legacy\Cache

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
/**
* Class File
* @package TorrentPier\Legacy\Cache

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
/**
* Class Memcache
* @package TorrentPier\Legacy\Cache

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Cache;
use TorrentPier\Dev;
/**
* Class Redis
* @package TorrentPier\Legacy\Cache

View file

@ -10,7 +10,6 @@
namespace TorrentPier\Legacy\Cache;
use SQLite3;
use TorrentPier\Dev;
/**
* Class SqliteCommon

View file

@ -10,8 +10,11 @@
namespace TorrentPier\Legacy\Common;
use TorrentPier\Legacy\DateDelta;
use TorrentPier\Legacy\Torrent;
use TorrentPier\Sessions;
use Exception;
/**
* Class User
* @package TorrentPier\Legacy\Common
@ -161,8 +164,8 @@ class User
$ip_check_u = substr(USER_IP, 0, 6);
if ($ip_check_s == $ip_check_u) {
if ($this->data['user_id'] != GUEST_UID && \defined('IN_ADMIN')) {
\define('SID_GET', "sid={$this->data['session_id']}");
if ($this->data['user_id'] != GUEST_UID && defined('IN_ADMIN')) {
define('SID_GET', "sid={$this->data['session_id']}");
}
$session_id = $this->sessiondata['sid'] = $this->data['session_id'];
@ -200,13 +203,13 @@ class User
$this->session_create($userdata, true);
}
\define('IS_GUEST', !$this->data['session_logged_in']);
\define('IS_ADMIN', !IS_GUEST && (int)$this->data['user_level'] === ADMIN);
\define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD);
\define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER);
\define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER);
\define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']]));
\define('IS_AM', IS_ADMIN || IS_MOD);
define('IS_GUEST', !$this->data['session_logged_in']);
define('IS_ADMIN', !IS_GUEST && (int)$this->data['user_level'] === ADMIN);
define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER);
define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']]));
define('IS_AM', IS_ADMIN || IS_MOD);
$this->set_shortcuts();
@ -255,8 +258,8 @@ class User
$mod_admin_session = ((int)$this->data['user_level'] === ADMIN || (int)$this->data['user_level'] === MOD);
// Generate passkey
if (!\TorrentPier\Legacy\Torrent::getPasskey($this->data['user_id'])) {
if (!\TorrentPier\Legacy\Torrent::generate_passkey($this->data['user_id'], true)) {
if (!Torrent::getPasskey($this->data['user_id'])) {
if (!Torrent::generate_passkey($this->data['user_id'], true)) {
bb_simple_die('Could not generate passkey');
}
}
@ -289,7 +292,7 @@ class User
if (!$session_time = $this->data['user_session_time']) {
$last_visit = TIMENOW;
\define('FIRST_LOGON', true);
define('FIRST_LOGON', true);
} elseif ($session_time < (TIMENOW - $bb_cfg['last_visit_update_intrv'])) {
$last_visit = max($session_time, (TIMENOW - 86400 * $bb_cfg['max_last_visit_days']));
}
@ -329,8 +332,8 @@ class User
$this->set_session_cookies($user_id);
if ($login && (\defined('IN_ADMIN') || $mod_admin_session)) {
\define('SID_GET', "sid=$session_id");
if ($login && (defined('IN_ADMIN') || $mod_admin_session)) {
define('SID_GET', "sid=$session_id");
}
Sessions::cache_set_userdata($this->data);
@ -527,7 +530,7 @@ class User
* @param bool $create_new
*
* @return string
* @throws \Exception
* @throws Exception
*/
public function create_autologin_id(array $userdata, bool $create_new = true): string
{
@ -565,7 +568,7 @@ class User
{
global $bb_cfg, $theme, $source_lang, $DeltaTime;
if (\defined('LANG_DIR')) {
if (defined('LANG_DIR')) {
return;
} // prevent multiple calling
@ -576,13 +579,13 @@ class User
}
}
\define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
\define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/');
define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/');
if ($this->data['user_id'] != GUEST_UID) {
if ($this->data['user_lang'] && $this->data['user_lang'] != $bb_cfg['default_lang']) {
$bb_cfg['default_lang'] = basename($this->data['user_lang']);
\define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
}
if (isset($this->data['user_timezone'])) {
@ -593,8 +596,8 @@ class User
$this->data['user_lang'] = $bb_cfg['default_lang'];
$this->data['user_timezone'] = $bb_cfg['board_timezone'];
if (!\defined('LANG_DIR')) {
\define('LANG_DIR', DEFAULT_LANG_DIR);
if (!defined('LANG_DIR')) {
define('LANG_DIR', DEFAULT_LANG_DIR);
}
/** Temporary place source language to the global */
@ -663,7 +666,7 @@ class User
} elseif (!empty($_COOKIE['opt_js'])) {
$opt_js = json_decode($_COOKIE['opt_js'], true, 512, JSON_THROW_ON_ERROR);
if (\is_array($opt_js)) {
if (is_array($opt_js)) {
$this->opt_js = array_merge($this->opt_js, $opt_js);
}
}

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
/**
* Class APCu
* @package TorrentPier\Legacy\Datastore

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
/**
* Class Common
* @package TorrentPier\Legacy\Datastore

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
/**
* Class File
* @package TorrentPier\Legacy\Datastore

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
/**
* Class Memcache
* @package TorrentPier\Legacy\Datastore

View file

@ -9,8 +9,6 @@
namespace TorrentPier\Legacy\Datastore;
use TorrentPier\Dev;
/**
* Class Redis
* @package TorrentPier\Legacy\Datastore

View file

@ -10,7 +10,6 @@
namespace TorrentPier\Legacy\Datastore;
use SQLite3;
use TorrentPier\Dev;
/**
* Class SqliteCommon

View file

@ -20,13 +20,13 @@ class Select
*
* @param string $default_lang
* @param string $select_name
* @return string
*
* @return mixed
*/
public static function language(string $default_lang, string $select_name = 'language')
public static function language(string $default_lang, string $select_name = 'language'): mixed
{
global $bb_cfg;
$lang_default = reset($bb_cfg['lang']);
$lang_select = '<select name="' . $select_name . '">';
$x = 0;
foreach ($bb_cfg['lang'] as $key => $data) {
@ -38,7 +38,7 @@ class Select
$x++;
}
$lang_select .= '</select>';
return ($x > 1) ? $lang_select : $lang_default['name'];
return ($x > 1) ? $lang_select : reset($bb_cfg['lang']);
}
/**
@ -73,9 +73,9 @@ class Select
* @param string $default_style
* @param string $select_name
*
* @return string
* @return mixed
*/
public static function template(string $default_style, string $select_name = 'tpl_name')
public static function template(string $default_style, string $select_name = 'tpl_name'): mixed
{
global $bb_cfg;

View file

@ -11,8 +11,6 @@ namespace TorrentPier\Legacy;
use mysqli_result;
use TorrentPier\Dev;
/**
* Class SqlDb
* @package TorrentPier\Legacy
@ -125,7 +123,7 @@ class SqlDb
if (!$this->link) {
$this->init();
}
if (\is_array($query)) {
if (is_array($query)) {
$query = $this->build_sql($query);
}
$query = '/* ' . $this->debug_find_source() . ' */ ' . $query;
@ -191,43 +189,6 @@ class SqlDb
return mysqli_affected_rows($this->link);
}
/**
* Fetch current field
*
* @param $field
* @param int $rownum
* @param int $query_id
*
* @return bool
*/
public function sql_fetchfield($field, $rownum = -1, $query_id = 0)
{
$result = null;
if (!$query_id) {
$query_id = $this->query_result;
}
if ($query_id) {
if ($rownum > -1) {
$result = $this->sql_result($query_id, $rownum, $field);
} else {
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id])) {
if ($this->sql_fetchrow()) {
$result = $this->row[$query_id][$field];
}
} else {
if ($this->rowset[$query_id]) {
$result = $this->rowset[$query_id][0][$field];
} elseif ($this->row[$query_id]) {
$result = $this->row[$query_id][$field];
}
}
}
return $result;
}
return false;
}
/**
* @param mysqli_result $res
* @param $row
@ -324,23 +285,6 @@ class SqlDb
return $this->sql_fetchrowset($result, $field_name);
}
/**
* Fetch all rows WRAPPER (with error handling)
*
* @param $query
* @param string $field_name
*
* @return array
*/
public function fetch_all($query, $field_name = '')
{
if (!$result = $this->sql_query($query)) {
$this->trigger_error();
}
return $this->sql_fetchrowset($result, $field_name);
}
/**
* Get last inserted id after insert statement
*
@ -386,13 +330,13 @@ class SqlDb
}
switch (true) {
case \is_string($v):
case is_string($v):
return "'" . $this->escape_string($v) . "'";
case \is_int($v):
case is_int($v):
return (string)$v;
case \is_bool($v):
case is_bool($v):
return ($v) ? '1' : '0';
case \is_float($v):
case is_float($v):
return "'$v'";
case null === $v:
return 'NULL';
@ -434,7 +378,7 @@ class SqlDb
$dont_escape = $data_already_escaped;
$check_type = $check_data_type_in_escape;
if (empty($input_ary) || !\is_array($input_ary)) {
if (empty($input_ary) || !is_array($input_ary)) {
$this->trigger_error(__FUNCTION__ . ' - wrong params: $input_ary');
}
@ -764,8 +708,8 @@ class SqlDb
}
}
if (!\defined('IN_FIRST_SLOW_QUERY')) {
\define('IN_FIRST_SLOW_QUERY', true);
if (!defined('IN_FIRST_SLOW_QUERY')) {
define('IN_FIRST_SLOW_QUERY', true);
}
CACHE('bb_cache')->set('dont_log_slow_query', $new_priority, $ignoring_time);
@ -899,7 +843,7 @@ class SqlDb
$msg = implode(LOG_SEPR, $msg);
$msg .= ($info = $this->query_info()) ? ' # ' . $info : '';
$msg .= ' # ' . $this->debug_find_source() . ' ';
$msg .= \defined('IN_CRON') ? 'cron' : basename($_SERVER['REQUEST_URI']);
$msg .= defined('IN_CRON') ? 'cron' : basename($_SERVER['REQUEST_URI']);
bb_log($msg . LOG_LF, $log_file);
}
@ -910,7 +854,7 @@ class SqlDb
*/
public function log_slow_query($log_file = 'sql_slow_bb')
{
if (!\defined('IN_FIRST_SLOW_QUERY') && CACHE('bb_cache')->get('dont_log_slow_query')) {
if (!defined('IN_FIRST_SLOW_QUERY') && CACHE('bb_cache')->get('dont_log_slow_query')) {
return;
}
$this->log_query($log_file);

View file

@ -271,7 +271,7 @@ class Template
die("Template->loadfile(): No files found for handle $handle");
}
$this->xs_startup();
$force_recompile = empty($this->uncompiled_code[$handle]) ? false : true;
$force_recompile = !empty($this->uncompiled_code[$handle]);
// checking if php file exists.
if (!empty($this->files_cache[$handle]) && !$force_recompile) {
// php file exists - running it instead of tpl
@ -313,12 +313,12 @@ class Template
if (str_contains($blockname, '.')) {
// Nested block.
$blocks = explode('.', $blockname);
$blockcount = \count($blocks) - 1;
$blockcount = count($blocks) - 1;
$str = &$this->_tpldata;
for ($i = 0; $i < $blockcount; $i++) {
$str = &$str[$blocks[$i] . '.'];
$str = &$str[(is_countable($str) ? \count($str) : 0) - 1];
$str = &$str[(is_countable($str) ? count($str) : 0) - 1];
}
// Now we add the block that we're actually assigning to.
// We're adding a new iteration to this block with the given
@ -441,7 +441,7 @@ class Template
{
// Get an array of the blocks involved.
$blocks = explode('.', $blockname);
$blockcount = \count($blocks) - 1;
$blockcount = count($blocks) - 1;
if ($include_last_iterator) {
return '$' . $blocks[$blockcount] . '_item';
}
@ -467,7 +467,7 @@ class Template
// Break it up into lines and put " -->" back.
$code_lines = explode(' -->', $code);
$count = \count($code_lines);
$count = count($code_lines);
for ($i = 0; $i < ($count - 1); $i++) {
$code_lines[$i] .= ' -->';
}
@ -486,7 +486,7 @@ class Template
// replace all short php tags
$new_code = [];
$line_count = \count($code_lines);
$line_count = count($code_lines);
for ($i = 0; $i < $line_count; $i++) {
$line = $code_lines[$i];
$pos = strpos($line, '<?');
@ -509,7 +509,7 @@ class Template
$code_lines = $new_code;
// main loop
$line_count = \count($code_lines);
$line_count = count($code_lines);
for ($i = 0; $i < $line_count; $i++) {
$line = $code_lines[$i];
// reset keyword type
@ -571,7 +571,7 @@ class Template
*/
if ($keyword_type == XS_TAG_BEGIN) {
$params = explode(' ', $params_str);
$num_params = \count($params);
$num_params = count($params);
// get variable name
if ($num_params == 1) {
$var = $params[0];
@ -635,7 +635,7 @@ class Template
*/
if ($keyword_type == XS_TAG_END) {
$params = explode(' ', $params_str);
$num_params = \count($params);
$num_params = count($params);
if ($num_params == 1) {
$var = $params[0];
} elseif ($num_params == 2 && $params[0] === '') {
@ -678,7 +678,7 @@ class Template
*/
if ($keyword_type == XS_TAG_INCLUDE) {
$params = explode(' ', $params_str);
$num_params = \count($params);
$num_params = count($params);
if ($num_params != 1) {
$compiled[] = $keyword_str;
continue;
@ -743,14 +743,14 @@ class Template
*/
public function _compile_text($code)
{
if (\strlen($code) < 3) {
if (strlen($code) < 3) {
return $code;
}
// change template varrefs into PHP varrefs
// This one will handle varrefs WITH namespaces
$varrefs = [];
preg_match_all('#\{(([a-z0-9\-_]+?\.)+)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
$varcount = is_countable($varrefs[1]) ? \count($varrefs[1]) : 0;
$varcount = is_countable($varrefs[1]) ? count($varrefs[1]) : 0;
$search = [];
$replace = [];
for ($i = 0; $i < $varcount; $i++) {
@ -760,7 +760,7 @@ class Template
$search[] = $varrefs[0][$i];
$replace[] = $new;
}
if (\count($search) > 0) {
if (count($search) > 0) {
$code = str_replace($search, $replace, $code);
}
// This will handle the remaining root-level varrefs
@ -788,7 +788,7 @@ class Template
[^\s(),]+)/x', $tag_args, $match);
$tokens = $match[0];
$tokens_cnt = is_countable($tokens) ? \count($tokens) : 0;
$tokens_cnt = is_countable($tokens) ? count($tokens) : 0;
$is_arg_stack = [];
for ($i = 0; $i < $tokens_cnt; $i++) {
@ -845,11 +845,11 @@ class Template
case 'is':
$is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
$is_arg = implode(' ', \array_slice($tokens, $is_arg_start, $i - $is_arg_start));
$is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
$new_tokens = $this->_parse_is_expr($is_arg, \array_slice($tokens, $i + 1));
$new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
array_splice($tokens, $is_arg_start, is_countable($tokens) ? \count($tokens) : 0, $new_tokens);
array_splice($tokens, $is_arg_start, is_countable($tokens) ? count($tokens) : 0, $new_tokens);
$i = $is_arg_start;
break;
@ -995,7 +995,7 @@ class Template
// adding current template
$tpl = $this->root . '/';
if (str_starts_with($tpl, './')) {
$tpl = substr($tpl, 2, \strlen($tpl));
$tpl = substr($tpl, 2, strlen($tpl));
}
$this->vars['TEMPLATE'] ??= $tpl;
$this->vars['TEMPLATE_NAME'] ??= $this->tpl;

View file

@ -9,6 +9,10 @@
namespace TorrentPier\Legacy;
use Arokettu\Bencode\Bencode;
use Arokettu\Bencode\Bencode\Collection;
use Exception;
/**
* Class Torrent
* @package TorrentPier\Legacy
@ -318,15 +322,15 @@ class Torrent
$file_contents = file_get_contents($filename);
try {
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
} catch (\Exception $e) {
$tor = Bencode::decode($file_contents, dictType: Collection::ARRAY);
} catch (Exception $e) {
self::torrent_error_exit(htmlCHR("{$lang['TORFILE_INVALID']}: {$e->getMessage()}"));
}
if ($bb_cfg['bt_disable_dht']) {
$tor['info']['private'] = (int)1;
$fp = fopen($filename, 'wb+');
fwrite($fp, \Arokettu\Bencode\Bencode::encode($tor));
fwrite($fp, Bencode::encode($tor));
fclose($fp);
}
@ -337,7 +341,7 @@ class Torrent
$ann = $tor['announce'] ?? '';
$announce_urls['main_url'] = $bb_cfg['bt_announce_url'];
if (!$ann || !\in_array($ann, $announce_urls)) {
if (!$ann || !in_array($ann, $announce_urls)) {
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
self::torrent_error_exit($msg);
}
@ -371,14 +375,14 @@ class Torrent
// Getting info_hash v1
if (isset($bt_v1)) {
$info_hash = hash('sha1', \Arokettu\Bencode\Bencode::encode($info), true);
$info_hash = hash('sha1', Bencode::encode($info), true);
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$info_hash_where = "WHERE info_hash = '$info_hash_sql'";
}
// Getting info_hash v2
if (isset($bt_v2)) {
$info_hash_v2 = hash('sha256', \Arokettu\Bencode\Bencode::encode($info), true);
$info_hash_v2 = hash('sha256', Bencode::encode($info), true);
$info_hash_v2_sql = rtrim(DB()->escape($info_hash_v2), ' ');
$info_hash_where = "WHERE info_hash_v2 = '$info_hash_v2_sql'";
}
@ -398,7 +402,7 @@ class Torrent
if (isset($info['length'])) {
$totallen = (float)$info['length'];
} elseif (isset($bt_v1, $info['files']) && !isset($bt_v2) && \is_array($info['files'])) {
} elseif (isset($bt_v1, $info['files']) && !isset($bt_v2) && is_array($info['files'])) {
foreach ($info['files'] as $fn => $f) {
// Exclude padding files
if (!isset($f['attr']) || $f['attr'] !== 'p') {
@ -561,8 +565,8 @@ class Torrent
// Torrent decoding
$file_contents = file_get_contents($filename);
try {
$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY);
} catch (\Exception $e) {
$tor = Bencode::decode($file_contents, dictType: Collection::ARRAY);
} catch (Exception $e) {
bb_die(htmlCHR("{$lang['TORFILE_INVALID']}: {$e->getMessage()}"));
}
@ -639,13 +643,13 @@ class Torrent
unset($tor['comment.utf-8']);
// Send torrent
$output = \Arokettu\Bencode\Bencode::encode($tor);
$output = Bencode::encode($tor);
$dl_fname = html_entity_decode($topic_title, ENT_QUOTES, 'UTF-8') . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.' . TORRENT_EXT;
if (!empty($_COOKIE['explain'])) {
$out = "attach path: $filename<br /><br />";
$tor['info']['pieces'] = '[...] ' . \strlen($tor['info']['pieces']) . ' bytes';
$tor['info']['pieces'] = '[...] ' . strlen($tor['info']['pieces']) . ' bytes';
$out .= print_r($tor, true);
bb_die("<pre>$out</pre>");
}

View file

@ -79,7 +79,7 @@ class TorrentFileList
$info['name'] =& $info['name.utf-8'];
}
if (isset($info['files']) && \is_array($info['files'])) {
if (isset($info['files']) && is_array($info['files'])) {
$this->root_dir = isset($info['name']) ? clean_tor_dirname($info['name']) : '...';
$this->multiple = true;
@ -87,7 +87,7 @@ class TorrentFileList
if (isset($f['path.utf-8'])) {
$f['path'] =& $f['path.utf-8'];
}
if (!isset($f['path']) || !\is_array($f['path'])) {
if (!isset($f['path']) || !is_array($f['path'])) {
continue;
}
// Exclude padding files
@ -101,7 +101,7 @@ class TorrentFileList
}
$length = isset($f['length']) ? (float)$f['length'] : 0;
$subdir_count = \count($f['path']) - 1;
$subdir_count = count($f['path']) - 1;
if ($subdir_count > 0) {
$name = array_pop($f['path']);
@ -116,7 +116,7 @@ class TorrentFileList
$cur_files_ary =& $cur_files_ary[$subdir];
if ($j === $subdir_count) {
if (\is_string($cur_files_ary)) {
if (is_string($cur_files_ary)) {
$GLOBALS['bnc_error'] = 1;
break;
}

View file

@ -46,7 +46,7 @@ class WordsRate
$this->del_text_hl = $text;
// Long text
if (\strlen($text) > 600) {
if (strlen($text) > 600) {
return $this->words_rate;
}
// Crop quotes if contains +1

View file

@ -62,11 +62,11 @@ ajax.callback.view_post = function(data) {
<!-- ENDIF / AJAX_TOPICS -->
<a name="start"></a>
<h1 class="pagetitle">{PAGE_TITLE}&nbsp;&middot;&nbsp;<a href="{U_TRACKER}?random_release=1">{L_RANDOM_RELEASE}</a></h1>
<h1 class="pagetitle">{PAGE_TITLE}</h1>
<div class="nav">
<p class="floatL"><a href="{U_INDEX}">{T_INDEX}</a></p>
<!-- IF MATCHES --><p class="floatR">{MATCHES} {SERACH_MAX}</p><!-- ENDIF -->
<p class="floatR"><!-- IF $bb_cfg['tracker']['random_release_button'] --><a href="{U_TRACKER}?random_release=1">{L_RANDOM_RELEASE}</a><!-- ENDIF --><!-- IF MATCHES -->&nbsp;&middot;&nbsp;{MATCHES}{SERACH_MAX}<!-- ENDIF --></p>
<div class="clear"></div>
</div>

View file

@ -512,6 +512,9 @@ td.topic_id { cursor: pointer; }
<!-- ELSE -->
&nbsp;
<!-- ENDIF -->
<div style="margin-top: 5px;">
<a href="#" onclick="$.scrollTo('#forum-table', {duration: 200, axis: 'y'}); return false;">{L_MOVE_TO_TOP}</a>
</div>
</td>
</tr>
</table>

View file

@ -576,6 +576,9 @@ function build_poll_add_form (src_el)
{S_SELECT_POST_ORDER}&nbsp;
<input type="submit" value="{L_GO}" class="lite" name="submit" />
</form>
<div style="margin-top: 5px;">
<a href="#" onclick="$.scrollTo('#topic_main', {duration: 200, axis: 'y'}); return false;">{L_MOVE_TO_TOP}</a>
</div>
</td>
</tr>
</table>

View file

@ -299,7 +299,7 @@ if (isset($_GET[$user_releases_key])) {
}
// Random release
if (isset($_GET['random_release'])) {
if ($bb_cfg['tracker']['random_release_button'] && isset($_GET['random_release'])) {
if ($random_release = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE tor_status NOT IN(" . implode(', ', array_keys($bb_cfg['tor_frozen'])) . ") ORDER BY RAND() LIMIT 1")) {
redirect(TOPIC_URL . $random_release['topic_id']);
} else {