Minor improvements (#889)

This commit is contained in:
Roman Kelesidis 2023-09-07 00:44:28 +07:00 committed by GitHub
commit 339f0ef948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 22 deletions

View file

@ -163,6 +163,7 @@ require __DIR__ . '/includes/init_tr.php';
$seeder = ($left == 0) ? 1 : 0; $seeder = ($left == 0) ? 1 : 0;
$stopped = ($event === 'stopped'); $stopped = ($event === 'stopped');
$completed = ($event === 'completed');
// Stopped event // Stopped event
if ($stopped) { if ($stopped) {
@ -397,8 +398,7 @@ if (!$output) {
} }
} }
$seeders = 0; $seeders = $leechers = 0;
$leechers = 0;
if ($bb_cfg['tracker']['scrape']) { if ($bb_cfg['tracker']['scrape']) {
$row = DB()->fetch_row(" $row = DB()->fetch_row("

View file

@ -103,7 +103,6 @@ define('BB_BT_TRACKER_SNAP', 'bb_bt_tracker_snap');
define('BB_BT_USERS', 'bb_bt_users'); define('BB_BT_USERS', 'bb_bt_users');
define('BT_AUTH_KEY_LENGTH', 10); define('BT_AUTH_KEY_LENGTH', 10);
define('PEER_HASH_PREFIX', 'peer_'); define('PEER_HASH_PREFIX', 'peer_');
define('PEERS_LIST_PREFIX', 'peers_list_'); define('PEERS_LIST_PREFIX', 'peers_list_');
define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $bb_cfg['tracker']['expire_factor']))); // sec define('PEER_HASH_EXPIRE', round($bb_cfg['announce_interval'] * (0.85 * $bb_cfg['tracker']['expire_factor']))); // sec

View file

@ -232,7 +232,7 @@ if ($tor_reged && $tor_info) {
'TOR_SIZE' => humn_size($tor_size), 'TOR_SIZE' => humn_size($tor_size),
'TOR_LONGEVITY' => delta_time($tor_info['reg_time']), 'TOR_LONGEVITY' => delta_time($tor_info['reg_time']),
'TOR_COMPLETED' => declension($tor_info['complete_count'], 'times'), 'TOR_COMPLETED' => declension((int)$tor_info['complete_count'], 'times'),
]); ]);
} }

View file

@ -66,6 +66,7 @@ $bb_cfg['cache'] = [
'redis' => [ 'redis' => [
'host' => '127.0.0.1', 'host' => '127.0.0.1',
'port' => 6379, 'port' => 6379,
'pconnect' => true,
'con_required' => true, 'con_required' => true,
], ],
// Available cache types: filecache, memcache, sqlite, redis, apcu (filecache by default) // Available cache types: filecache, memcache, sqlite, redis, apcu (filecache by default)

View file

@ -27,7 +27,7 @@ class Memcache extends Common
public function __construct($cfg, $prefix = null) public function __construct($cfg, $prefix = null)
{ {
if (!$this->is_installed()) { if (!$this->is_installed()) {
die('Error: Memcached extension not installed'); die("Error: $this->engine extension not installed");
} }
$this->cfg = $cfg; $this->cfg = $cfg;
@ -48,7 +48,7 @@ class Memcache extends Common
} }
if (!$this->connected && $this->cfg['con_required']) { if (!$this->connected && $this->cfg['con_required']) {
die('Could not connect to memcached server'); die("Could not connect to $this->engine server");
} }
$this->debug('stop'); $this->debug('stop');

View file

@ -27,7 +27,7 @@ class Redis extends Common
public function __construct($cfg, $prefix = null) public function __construct($cfg, $prefix = null)
{ {
if (!$this->is_installed()) { if (!$this->is_installed()) {
die('Error: Redis extension not installed'); die("Error: $this->engine extension not installed");
} }
$this->cfg = $cfg; $this->cfg = $cfg;
@ -38,15 +38,17 @@ class Redis extends Common
public function connect() public function connect()
{ {
$this->cur_query = 'connect ' . $this->cfg['host'] . ':' . $this->cfg['port']; $connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
$this->cur_query = $connect_type . ' ' . $this->cfg['host'] . ':' . $this->cfg['port'];
$this->debug('start'); $this->debug('start');
if (@$this->redis->connect($this->cfg['host'], $this->cfg['port'])) { if (@$this->redis->$connect_type($this->cfg['host'], $this->cfg['port'])) {
$this->connected = true; $this->connected = true;
} }
if (!$this->connected && $this->cfg['con_required']) { if (!$this->connected && $this->cfg['con_required']) {
die('Could not connect to redis server'); die("Could not connect to $this->engine server");
} }
$this->debug('stop'); $this->debug('stop');

View file

@ -26,7 +26,7 @@ class Memcache extends Common
public function __construct($cfg, $prefix = null) public function __construct($cfg, $prefix = null)
{ {
if (!$this->is_installed()) { if (!$this->is_installed()) {
die('Error: Memcached extension not installed'); die("Error: $this->engine extension not installed");
} }
$this->cfg = $cfg; $this->cfg = $cfg;
@ -47,7 +47,7 @@ class Memcache extends Common
} }
if (!$this->connected && $this->cfg['con_required']) { if (!$this->connected && $this->cfg['con_required']) {
die('Could not connect to memcached server'); die("Could not connect to $this->engine server");
} }
$this->debug('stop'); $this->debug('stop');

View file

@ -26,7 +26,7 @@ class Redis extends Common
public function __construct($cfg, $prefix = null) public function __construct($cfg, $prefix = null)
{ {
if (!$this->is_installed()) { if (!$this->is_installed()) {
die('Error: Redis extension not installed'); die("Error: $this->engine extension not installed");
} }
$this->cfg = $cfg; $this->cfg = $cfg;
@ -45,7 +45,7 @@ class Redis extends Common
} }
if (!$this->connected && $this->cfg['con_required']) { if (!$this->connected && $this->cfg['con_required']) {
die('Could not connect to redis server'); die("Could not connect to $this->engine server");
} }
$this->debug('stop'); $this->debug('stop');