Minor fixes (#686)

This commit is contained in:
Roman Kelesidis 2023-04-30 17:46:19 +07:00 committed by GitHub
commit ca4bc04902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 20 deletions

View file

@ -76,7 +76,7 @@ if (file_exists(__DIR__ . '/library/config.local.php')) {
* Progressive error reporting * Progressive error reporting
*/ */
define('DBG_USER', (isset($_COOKIE[COOKIE_DBG]))); define('DBG_USER', (isset($_COOKIE[COOKIE_DBG])));
\TorrentPier\Dev::debug_init(); \TorrentPier\Dev::initDebug();
$server_protocol = $bb_cfg['cookie_secure'] ? 'https://' : 'http://'; $server_protocol = $bb_cfg['cookie_secure'] ? 'https://' : 'http://';
$server_port = in_array((int)$bb_cfg['server_port'], array(80, 443), true) ? '' : ':' . $bb_cfg['server_port']; $server_port = in_array((int)$bb_cfg['server_port'], array(80, 443), true) ? '' : ':' . $bb_cfg['server_port'];

View file

@ -98,41 +98,31 @@ class Ajax
// Auth check // Auth check
switch ($action_params[0]) { switch ($action_params[0]) {
// GUEST case 'guest': // GUEST
case 'guest':
break; break;
case 'user': // USER
// USER
case 'user':
if (IS_GUEST) { if (IS_GUEST) {
$this->ajax_die($lang['NEED_TO_LOGIN_FIRST']); $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']);
} }
break; break;
case 'mod': // MOD
// MOD
case 'mod':
if (!IS_AM) { if (!IS_AM) {
$this->ajax_die($lang['ONLY_FOR_MOD']); $this->ajax_die($lang['ONLY_FOR_MOD']);
} }
$this->check_admin_session(); $this->check_admin_session();
break; break;
case 'admin': // ADMIN
// ADMIN
case 'admin':
if (!IS_ADMIN) { if (!IS_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_ADMIN']); $this->ajax_die($lang['ONLY_FOR_ADMIN']);
} }
$this->check_admin_session(); $this->check_admin_session();
break; break;
case 'super_admin': // SUPER_ADMIN
// SUPER_ADMIN
case 'super_admin':
if (!IS_SUPER_ADMIN) { if (!IS_SUPER_ADMIN) {
$this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']); $this->ajax_die($lang['ONLY_FOR_SUPER_ADMIN']);
} }
$this->check_admin_session(); $this->check_admin_session();
break; break;
default: default:
trigger_error("invalid auth type for $action", E_USER_ERROR); trigger_error("invalid auth type for $action", E_USER_ERROR);
} }

View file

@ -34,7 +34,7 @@ class Dev
* *
* @return void * @return void
*/ */
public static function debug_init(): void public static function initDebug(): void
{ {
global $bb_cfg; global $bb_cfg;
@ -88,7 +88,7 @@ class Dev
$log = ''; $log = '';
foreach ($DBS->srv as $srv_name => $db_obj) { foreach ($DBS->srv as $srv_name => $db_obj) {
$log .= !empty($db_obj) ? self::get_sql_log_html($db_obj, "$srv_name [MySQL]") : ''; $log .= !empty($db_obj) ? self::get_sql_log_html($db_obj, "database: $srv_name [{$db_obj->engine}]") : '';
} }
foreach ($CACHES->obj as $cache_name => $cache_obj) { foreach ($CACHES->obj as $cache_name => $cache_obj) {

View file

@ -10,7 +10,6 @@
namespace TorrentPier\Legacy; namespace TorrentPier\Legacy;
use mysqli_result; use mysqli_result;
use TorrentPier\Common\Http;
use TorrentPier\Dev; use TorrentPier\Dev;
/** /**
@ -26,6 +25,7 @@ class SqlDb
public $db_server = ''; public $db_server = '';
public $selected_db; public $selected_db;
public $inited = false; public $inited = false;
public string $engine = 'MySQL';
public $locked = false; public $locked = false;
public $locks = []; public $locks = [];
@ -993,7 +993,7 @@ class SqlDb
<table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0;"> <table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0;">
<tr> <tr>
<th style="height: 22px; cursor: pointer;" align="left">&nbsp;' . $dbg['src'] . '&nbsp; [' . sprintf('%.4f', $dbg['time']) . ' s]&nbsp; <i>' . $dbg['info'] . '</i></th> <th style="height: 22px; cursor: pointer;" align="left">&nbsp;' . $dbg['src'] . '&nbsp; [' . sprintf('%.4f', $dbg['time']) . ' s]&nbsp; <i>' . $dbg['info'] . '</i></th>
<th class="copyElement" data-clipboard-target="#' . $htid . '" style="height: 22px; cursor: pointer;" align="right" title="' . $lang['COPY_TO_CLIPBOARD'] . '">' . "$this->db_server.$this->selected_db" . ' :: Query #' . ($this->num_queries + 1) . '&nbsp;</th> <th class="copyElement" data-clipboard-target="#' . $htid . '" style="height: 22px; cursor: pointer;" align="right" title="' . $lang['COPY_TO_CLIPBOARD'] . '">' . "[$this->engine] $this->db_server.$this->selected_db" . ' :: Query #' . ($this->num_queries + 1) . '&nbsp;</th>
</tr> </tr>
<tr><td colspan="2">' . $this->explain_hold . '</td></tr> <tr><td colspan="2">' . $this->explain_hold . '</td></tr>
</table> </table>