From e36af3e30ec75e80ab028a1dc839fd2091495048 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 10 Aug 2023 14:13:43 +0700 Subject: [PATCH] Fixed formatting --- common.php | 2 +- library/includes/cache/common.php | 8 +- library/includes/cache/memcache.php | 14 +-- library/includes/cache/redis.php | 14 +-- library/includes/cache/sqlite.php | 18 +-- library/includes/cache/xcache.php | 2 +- library/includes/core/dbs.php | 2 +- library/includes/core/mysql.php | 154 ++++++++++++------------ library/includes/cron/cron_init.php | 24 ++-- library/includes/datastore/apc.php | 2 +- library/includes/datastore/common.php | 8 +- library/includes/datastore/memcache.php | 12 +- library/includes/datastore/redis.php | 14 +-- library/includes/datastore/xcache.php | 2 +- library/includes/init_bb.php | 24 ++-- posting.php | 16 +-- 16 files changed, 158 insertions(+), 158 deletions(-) diff --git a/common.php b/common.php index b36d5420..f3f0e8d5 100644 --- a/common.php +++ b/common.php @@ -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 diff --git a/library/includes/cache/common.php b/library/includes/cache/common.php index 46f84f6a..10852733 100644 --- a/library/includes/cache/common.php +++ b/library/includes/cache/common.php @@ -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 = '') diff --git a/library/includes/cache/memcache.php b/library/includes/cache/memcache.php index ed4d9563..91a623f3 100644 --- a/library/includes/cache/memcache.php +++ b/library/includes/cache/memcache.php @@ -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'); diff --git a/library/includes/cache/redis.php b/library/includes/cache/redis.php index fd60e410..943a3a5e 100644 --- a/library/includes/cache/redis.php +++ b/library/includes/cache/redis.php @@ -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'); diff --git a/library/includes/cache/sqlite.php b/library/includes/cache/sqlite.php index 4dfc801c..4e88a8e2 100644 --- a/library/includes/cache/sqlite.php +++ b/library/includes/cache/sqlite.php @@ -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; diff --git a/library/includes/cache/xcache.php b/library/includes/cache/xcache.php index 1e63bc1e..60a47a54 100644 --- a/library/includes/cache/xcache.php +++ b/library/includes/cache/xcache.php @@ -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; diff --git a/library/includes/core/dbs.php b/library/includes/core/dbs.php index b4d37920..ef7c8083 100644 --- a/library/includes/core/dbs.php +++ b/library/includes/core/dbs.php @@ -41,7 +41,7 @@ class DBS // определение имени сервера function get_srv_name ($name) { - $srv_name = 'db1'; + $srv_name = 'db1'; if (isset($this->alias[$name])) { diff --git a/library/includes/core/mysql.php b/library/includes/core/mysql.php index d4b103e4..5668291b 100644 --- a/library/includes/core/mysql.php +++ b/library/includes/core/mysql.php @@ -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 .= ''; - } - } - 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 .= ''; + } + } + 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 .= ' - - - - - - -
 '. $dbg['src'] .'  ['. sprintf('%.4f', $dbg['time']) .' s]  '. $dbg['info'] .''. "[$this->engine] $this->db_server.$this->selected_db" .' :: Query #'. ($this->num_queries+1) .' 
'. $this->explain_hold .'
-
'. short_query($dbg['sql'], true) .'  
-
'; - break; + $this->explain_out .= ' + + + + + + +
 '. $dbg['src'] .'  ['. sprintf('%.4f', $dbg['time']) .' s]  '. $dbg['info'] .''. "[$this->engine] $this->db_server.$this->selected_db" .' :: Query #'. ($this->num_queries+1) .' 
'. $this->explain_hold .'
+
'. short_query($dbg['sql'], true) .'  
+
'; + break; - case 'add_explain_row': - if (!$html_table && $row) - { - $html_table = true; - $this->explain_hold .= ''; - foreach (array_keys($row) as $val) - { - $this->explain_hold .= ''; - } - $this->explain_hold .= ''; - } - $this->explain_hold .= ''; - foreach (array_values($row) as $i => $val) - { - $class = !($i % 2) ? 'row1' : 'row2'; - $this->explain_hold .= ''; - } - $this->explain_hold .= ''; + case 'add_explain_row': + if (!$html_table && $row) + { + $html_table = true; + $this->explain_hold .= '
'. $val .'
'. str_replace(array("{$this->selected_db}.", ',', ';'), array('', ', ', ';
'), $val) .'
'; + foreach (array_keys($row) as $val) + { + $this->explain_hold .= ''; + } + $this->explain_hold .= ''; + } + $this->explain_hold .= ''; + foreach (array_values($row) as $i => $val) + { + $class = !($i % 2) ? 'row1' : 'row2'; + $this->explain_hold .= ''; + } + $this->explain_hold .= ''; - return $html_table; - break; + return $html_table; + break; - case 'display': - echo '
'. $this->explain_out .'
'; - break; + case 'display': + echo '
'. $this->explain_out .'
'; + break; - default: - die("Invalid {$this->engine} explain mode"); - break; + default: + die("Invalid {$this->engine} explain mode"); + break; } } } diff --git a/library/includes/cron/cron_init.php b/library/includes/cron/cron_init.php index db00e627..71fb7f0a 100644 --- a/library/includes/cron/cron_init.php +++ b/library/includes/cron/cron_init.php @@ -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"); - } } // diff --git a/library/includes/datastore/apc.php b/library/includes/datastore/apc.php index aab11e13..2b449df7 100644 --- a/library/includes/datastore/apc.php +++ b/library/includes/datastore/apc.php @@ -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; diff --git a/library/includes/datastore/common.php b/library/includes/datastore/common.php index 87ee9579..2d46dd4b 100644 --- a/library/includes/datastore/common.php +++ b/library/includes/datastore/common.php @@ -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 = '') diff --git a/library/includes/datastore/memcache.php b/library/includes/datastore/memcache.php index 941e9836..cef3c8f7 100644 --- a/library/includes/datastore/memcache.php +++ b/library/includes/datastore/memcache.php @@ -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); } diff --git a/library/includes/datastore/redis.php b/library/includes/datastore/redis.php index c499f1df..c3127129 100644 --- a/library/includes/datastore/redis.php +++ b/library/includes/datastore/redis.php @@ -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'); diff --git a/library/includes/datastore/xcache.php b/library/includes/datastore/xcache.php index b2a6e832..2eddb663 100644 --- a/library/includes/datastore/xcache.php +++ b/library/includes/datastore/xcache.php @@ -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(); diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 24ec8d06..220ef3de 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -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); + } } diff --git a/posting.php b/posting.php index d769ecbc..3ef99c02 100644 --- a/posting.php +++ b/posting.php @@ -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; }
'. $val .'
'. str_replace(array("{$this->selected_db}.", ',', ';'), array('', ', ', ';
'), $val) .'