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
*/
define('DBG_USER', (isset($_COOKIE[COOKIE_DBG])));
\TorrentPier\Dev::debug_init();
\TorrentPier\Dev::initDebug();
$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'];

View file

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

View file

@ -34,7 +34,7 @@ class Dev
*
* @return void
*/
public static function debug_init(): void
public static function initDebug(): void
{
global $bb_cfg;
@ -88,7 +88,7 @@ class Dev
$log = '';
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) {

View file

@ -10,7 +10,6 @@
namespace TorrentPier\Legacy;
use mysqli_result;
use TorrentPier\Common\Http;
use TorrentPier\Dev;
/**
@ -26,6 +25,7 @@ class SqlDb
public $db_server = '';
public $selected_db;
public $inited = false;
public string $engine = 'MySQL';
public $locked = false;
public $locks = [];
@ -993,7 +993,7 @@ class SqlDb
<table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0;">
<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 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><td colspan="2">' . $this->explain_hold . '</td></tr>
</table>