Fixed formatting

This commit is contained in:
Roman Kelesidis 2023-08-10 14:13:43 +07:00
parent 3556a84711
commit e36af3e30e
16 changed files with 158 additions and 158 deletions

View File

@ -22,7 +22,7 @@ header('X-Powered-By: TorrentPier LTS');
// Cloudflare
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
// Get initial config

View File

@ -63,10 +63,10 @@ class cache_common
$dbg['time'] = $this->cur_query_time;
$id++;
}
else
{
trigger_error("[Cache] Invalid debug mode: $mode", E_USER_ERROR);
}
else
{
trigger_error("[Cache] Invalid debug mode: $mode", E_USER_ERROR);
}
}
function debug_find_source ($mode = '')

View File

@ -15,7 +15,7 @@ class cache_memcache extends cache_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->cfg = $cfg;
@ -39,13 +39,13 @@ class cache_memcache extends cache_common
if (!$this->connected && $this->cfg['con_required'])
{
$con_error = "Could not connect to {$this->engine} server";
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
}
$this->debug('stop');

View File

@ -15,7 +15,7 @@ class cache_redis extends cache_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->cfg = $cfg;
@ -37,13 +37,13 @@ class cache_redis extends cache_common
if (!$this->connected && $this->cfg['con_required'])
{
$con_error = "Could not connect to {$this->engine} server";
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
}
$this->debug('stop');

View File

@ -154,17 +154,17 @@ class sqlite_common extends cache_common
$this->connected = true;
}
if (!$this->connected && $this->cfg['con_required'])
{
$con_error = "Could not connect to {$this->engine}";
if (!$this->connected && $this->cfg['con_required'])
{
$con_error = "Could not connect to {$this->engine}";
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
}
die($con_error);
}
$this->debug('stop');
$this->cur_query = null;

View File

@ -12,7 +12,7 @@ class cache_xcache extends cache_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->dbg_enabled = sql_dbg_enabled();
$this->prefix = $prefix;

View File

@ -41,7 +41,7 @@ class DBS
// определение имени сервера
function get_srv_name ($name)
{
$srv_name = 'db1';
$srv_name = 'db1';
if (isset($this->alias[$name]))
{

View File

@ -103,10 +103,10 @@ class sql_db
$server = (DBG_USER) ? $this->cfg['dbhost'] : '';
header("HTTP/1.0 503 Service Unavailable");
$con_error = "Could not connect to {$this->engine} server $server";
if (DBG_USER)
{
dbg_log($con_error, "{$server}-DB-connect-FAIL_" . time());
}
if (DBG_USER)
{
dbg_log($con_error, "{$server}-DB-connect-FAIL_" . time());
}
die($con_error);
}
@ -732,10 +732,10 @@ class sql_db
}
}
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);
}
@ -924,84 +924,84 @@ class sql_db
switch ($mode)
{
case 'start':
$this->explain_hold = '';
// TODO: добавить поддержку многотабличных запросов
if (preg_match('#UPDATE ([a-z0-9_]+).*?WHERE(.*)/#', $query, $m))
{
$query = "SELECT * FROM $m[1] WHERE $m[2]";
}
else if (preg_match('#DELETE FROM ([a-z0-9_]+).*?WHERE(.*)#s', $query, $m))
{
$query = "SELECT * FROM $m[1] WHERE $m[2]";
}
case 'start':
$this->explain_hold = '';
// TODO: добавить поддержку многотабличных запросов
if (preg_match('#UPDATE ([a-z0-9_]+).*?WHERE(.*)/#', $query, $m))
{
$query = "SELECT * FROM $m[1] WHERE $m[2]";
}
else if (preg_match('#DELETE FROM ([a-z0-9_]+).*?WHERE(.*)#s', $query, $m))
{
$query = "SELECT * FROM $m[1] WHERE $m[2]";
}
if (preg_match('#^SELECT#', $query))
{
$html_table = false;
if (preg_match('#^SELECT#', $query))
{
$html_table = false;
if ($result = @mysql_query("EXPLAIN $query", $this->link))
{
while ($row = @mysql_fetch_assoc($result))
{
$html_table = $this->explain('add_explain_row', $html_table, $row);
}
}
if ($html_table)
{
$this->explain_hold .= '</table>';
}
}
break;
if ($result = @mysql_query("EXPLAIN $query", $this->link))
{
while ($row = @mysql_fetch_assoc($result))
{
$html_table = $this->explain('add_explain_row', $html_table, $row);
}
}
if ($html_table)
{
$this->explain_hold .= '</table>';
}
}
break;
case 'stop':
if (!$this->explain_hold) break;
case 'stop':
if (!$this->explain_hold) break;
$id = $this->dbg_id-1;
$htid = 'expl-'. intval($this->link) .'-'. $id;
$dbg = $this->dbg[$id];
$id = $this->dbg_id-1;
$htid = 'expl-'. intval($this->link) .'-'. $id;
$dbg = $this->dbg[$id];
$this->explain_out .= '
<table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0px;">
<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="right" title="Copy to clipboard" onclick="$(\'#'. $htid .'\').CopyToClipboard();">'. "[$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>
<div class="sqlLog"><div id="'. $htid .'" class="sqlLogRow sqlExplain" style="padding: 0px;">'. short_query($dbg['sql'], true) .'&nbsp;&nbsp;</div></div>
<br />';
break;
$this->explain_out .= '
<table width="98%" cellpadding="0" cellspacing="0" class="bodyline row2 bCenter" style="border-bottom: 0px;">
<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="right" title="Copy to clipboard" onclick="$(\'#'. $htid .'\').CopyToClipboard();">'. "[$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>
<div class="sqlLog"><div id="'. $htid .'" class="sqlLogRow sqlExplain" style="padding: 0px;">'. short_query($dbg['sql'], true) .'&nbsp;&nbsp;</div></div>
<br />';
break;
case 'add_explain_row':
if (!$html_table && $row)
{
$html_table = true;
$this->explain_hold .= '<table width="100%" cellpadding="3" cellspacing="1" class="bodyline" style="border-width: 0;"><tr>';
foreach (array_keys($row) as $val)
{
$this->explain_hold .= '<td class="row3 gensmall" align="center"><b>'. $val .'</b></td>';
}
$this->explain_hold .= '</tr>';
}
$this->explain_hold .= '<tr>';
foreach (array_values($row) as $i => $val)
{
$class = !($i % 2) ? 'row1' : 'row2';
$this->explain_hold .= '<td class="'. $class .' gen">'. str_replace(array("{$this->selected_db}.", ',', ';'), array('', ', ', ';<br />'), $val) .'</td>';
}
$this->explain_hold .= '</tr>';
case 'add_explain_row':
if (!$html_table && $row)
{
$html_table = true;
$this->explain_hold .= '<table width="100%" cellpadding="3" cellspacing="1" class="bodyline" style="border-width: 0;"><tr>';
foreach (array_keys($row) as $val)
{
$this->explain_hold .= '<td class="row3 gensmall" align="center"><b>'. $val .'</b></td>';
}
$this->explain_hold .= '</tr>';
}
$this->explain_hold .= '<tr>';
foreach (array_values($row) as $i => $val)
{
$class = !($i % 2) ? 'row1' : 'row2';
$this->explain_hold .= '<td class="'. $class .' gen">'. str_replace(array("{$this->selected_db}.", ',', ';'), array('', ', ', ';<br />'), $val) .'</td>';
}
$this->explain_hold .= '</tr>';
return $html_table;
break;
return $html_table;
break;
case 'display':
echo '<a name="explain"></a><div class="med">'. $this->explain_out .'</div>';
break;
case 'display':
echo '<a name="explain"></a><div class="med">'. $this->explain_out .'</div>';
break;
default:
die("Invalid {$this->engine} explain mode");
break;
default:
die("Invalid {$this->engine} explain mode");
break;
}
}
}

View File

@ -30,10 +30,10 @@ function cron_get_file_lock ()
function cron_track_running ($mode)
{
if (!defined('CRON_STARTMARK'))
{
define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid());
}
if (!defined('CRON_STARTMARK'))
{
define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid());
}
if ($mode == 'start')
{
@ -42,15 +42,15 @@ function cron_track_running ($mode)
}
elseif ($mode == 'end')
{
if (file_exists(CRON_STARTMARK))
{
unlink(CRON_STARTMARK);
}
if (file_exists(CRON_STARTMARK))
{
unlink(CRON_STARTMARK);
}
}
else
{
bb_simple_die("Invalid cron track mode: $mode");
}
else
{
bb_simple_die("Invalid cron track mode: $mode");
}
}
//

View File

@ -11,7 +11,7 @@ class datastore_apc extends datastore_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->dbg_enabled = sql_dbg_enabled();
$this->prefix = $prefix;

View File

@ -154,10 +154,10 @@ class datastore_common
$dbg['time'] = $this->cur_query_time;
$id++;
}
else
{
trigger_error("[Datastore] Invalid debug mode: $mode", E_USER_ERROR);
}
else
{
trigger_error("[Datastore] Invalid debug mode: $mode", E_USER_ERROR);
}
}
function debug_find_source ($mode = '')

View File

@ -14,7 +14,7 @@ class datastore_memcache extends datastore_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->cfg = $cfg;
@ -38,11 +38,11 @@ class datastore_memcache extends datastore_common
if (!$this->connected && $this->cfg['con_required'])
{
$con_error = "Could not connect to {$this->engine} server";
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
}

View File

@ -14,7 +14,7 @@ class datastore_redis extends datastore_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->cfg = $cfg;
@ -36,13 +36,13 @@ class datastore_redis extends datastore_common
if (!$this->connected && $this->cfg['con_required'])
{
$con_error = "Could not connect to {$this->engine} server";
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
if (DBG_LOG)
{
dbg_log($con_error, "{$this->engine}-CACHE-connect-FAIL_" . time());
}
die($con_error);
}
$this->debug('stop');

View File

@ -11,7 +11,7 @@ class datastore_xcache extends datastore_common
{
if (!$this->is_installed())
{
die("Error: {$this->engine} extension not installed");
die("Error: {$this->engine} extension not installed");
}
$this->dbg_enabled = sql_dbg_enabled();

View File

@ -539,10 +539,10 @@ function cron_release_deadlock ()
function cron_release_file_lock ()
{
if (file_exists(CRON_RUNNING))
{
rename(CRON_RUNNING, CRON_ALLOWED);
}
if (file_exists(CRON_RUNNING))
{
rename(CRON_RUNNING, CRON_ALLOWED);
}
cron_touch_lock_file(CRON_ALLOWED);
}
@ -553,16 +553,16 @@ function cron_touch_lock_file ($lock_file)
function cron_enable_board ()
{
if (file_exists(BB_DISABLED))
{
rename(BB_DISABLED, BB_ENABLED);
}
if (file_exists(BB_DISABLED))
{
rename(BB_DISABLED, BB_ENABLED);
}
}
function cron_disable_board ()
{
if (file_exists(BB_ENABLED))
{
rename(BB_ENABLED, BB_DISABLED);
}
if (file_exists(BB_ENABLED))
{
rename(BB_ENABLED, BB_DISABLED);
}
}

View File

@ -389,14 +389,14 @@ elseif ( ($submit || $confirm) && !$topic_has_new_posts )
case 'delete':
require_once(INC_DIR .'functions_admin.php');
if (!$post_data['first_post'])
{
delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id);
}
else
{
redirect("modcp.php?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id']);
}
if (!$post_data['first_post'])
{
delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id);
}
else
{
redirect("modcp.php?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id']);
}
break;
}