diff --git a/bt/announce.php b/bt/announce.php index 668306319..e21101e18 100644 --- a/bt/announce.php +++ b/bt/announce.php @@ -36,9 +36,6 @@ if (empty($_SERVER['HTTP_USER_AGENT'])) { // Ignore 'completed' event if (isset($_GET['event']) && $_GET['event'] === 'completed') { - if (DBG_LOG) { - dbg_log(' ', '!die-event-completed'); - } dummy_exit(mt_rand(600, 1200)); } @@ -149,10 +146,6 @@ $peer_hash = md5( // Get cached peer info from previous announce (last peer info) $lp_info = CACHE('tr_cache')->get(PEER_HASH_PREFIX . $peer_hash); -if (DBG_LOG) { - dbg_log(' ', '$lp_info-get_from-CACHE-' . ($lp_info ? 'hit' : 'miss')); -} - // Drop fast announce if ($lp_info && (!isset($event) || $event !== 'stopped')) { drop_fast_announce($lp_info); @@ -174,10 +167,6 @@ function drop_fast_announce($lp_info) function msg_die($msg) { - if (DBG_LOG) { - dbg_log(' ', '!die-' . clean_filename($msg)); - } - $output = \Rych\Bencode\Bencode::encode([ 'min interval' => (int)1800, 'failure reason' => (string)$msg, @@ -196,9 +185,6 @@ $stopped = ($event === 'stopped'); // Stopped event if ($stopped) { CACHE('tr_cache')->rm(PEER_HASH_PREFIX . $peer_hash); - if (DBG_LOG) { - dbg_log(' ', 'stopped'); - } } // Get last peer info from DB @@ -206,10 +192,6 @@ if (!CACHE('tr_cache')->used && !$lp_info) { $lp_info = DB()->fetch_row(" SELECT * FROM " . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1 "); - - if (DBG_LOG) { - dbg_log(' ', '$lp_info-get_from-DB-' . ($lp_info ? 'hit' : 'miss')); - } } if ($lp_info) { @@ -312,7 +294,7 @@ if ($lp_info) { } // Up/Down speed -$speed_up = $speed_down = $uploaded = $downloaded = 0; +$speed_up = $speed_down = 0; if ($lp_info && $lp_info['update_time'] < TIMENOW) { if ($uploaded > $lp_info['uploaded']) { @@ -358,8 +340,8 @@ if ($lp_info) { $sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : ''; $sql .= ", remain = $left"; - $sql .= ($up_add) ? ", up_add = up_add + $up_add" : ''; - $sql .= ($down_add) ? ", down_add = down_add + $down_add" : ''; + $sql .= $up_add ? ", up_add = up_add + $up_add" : ''; + $sql .= $down_add ? ", down_add = down_add + $down_add" : ''; $sql .= ", speed_up = $speed_up"; $sql .= ", speed_down = $speed_down"; @@ -370,10 +352,6 @@ if ($lp_info) { DB()->query($sql); $peer_info_updated = DB()->affected_rows(); - - if (DBG_LOG) { - dbg_log(' ', 'this_peer-update' . ($peer_info_updated ? '' : '-FAIL')); - } } if (!$lp_info || !$peer_info_updated) { @@ -381,10 +359,6 @@ if (!$lp_info || !$peer_info_updated) { $values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time"; DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)"); - - if (DBG_LOG) { - dbg_log(' ', 'this_peer-insert'); - } } // Exit if stopped @@ -406,17 +380,9 @@ $lp_info = array( $lp_info_cached = CACHE('tr_cache')->set(PEER_HASH_PREFIX . $peer_hash, $lp_info, PEER_HASH_EXPIRE); -if (DBG_LOG && !$lp_info_cached) { - dbg_log(' ', '$lp_info-caching-FAIL'); -} - // Get cached output $output = CACHE('tr_cache')->get(PEERS_LIST_PREFIX . $topic_id); -if (DBG_LOG) { - dbg_log(' ', '$output-get_from-CACHE-' . ($output !== false ? 'hit' : 'miss')); -} - if (!$output) { // Retrieve peers $numwant = (int)$bb_cfg['tracker']['numwant']; @@ -471,14 +437,9 @@ if (!$output) { ); $peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE); - - if (DBG_LOG && !$peers_list_cached) { - dbg_log(' ', '$output-caching-FAIL'); - } } // Return data to client echo \Rych\Bencode\Bencode::encode($output); -tracker_exit(); exit; diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php index c2abe73af..76b24e982 100644 --- a/bt/includes/init_tr.php +++ b/bt/includes/init_tr.php @@ -37,45 +37,18 @@ if ($bb_cfg['tracker']['off']) { // // Functions // -function tracker_exit() -{ - global $DBS; - - if (DBG_LOG && DBG_TRACKER) { - if ($gen_time = utime() - TIMESTART) { - $sql_init_perc = round($DBS->sql_inittime * 100 / $gen_time); - $sql_total_perc = round($DBS->sql_timetotal * 100 / $gen_time); - - $str = array(); - $str[] = substr(TIMENOW, -4, 4); - $str[] = sprintf('%.4f', $gen_time); - $str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_inittime, $sql_init_perc); - $str[] = sprintf('%.4f' . LOG_SEPR . '%02d%%', $DBS->sql_timetotal, $sql_total_perc); - $str[] = $DBS->num_queries; - $str[] = sprintf('%.1f', sys('la')); - $str = implode(LOG_SEPR, $str) . LOG_LF; - dbg_log($str, '!!gentime'); - } - } - exit; -} - function silent_exit() { ob_end_clean(); - tracker_exit(); + exit; } function error_exit($msg = '') { - if (DBG_LOG) { - dbg_log(' ', '!err-' . clean_filename($msg)); - } - silent_exit(); echo \Rych\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]); - tracker_exit(); + exit; } diff --git a/bt/scrape.php b/bt/scrape.php index e4e926bca..9f5f02d27 100644 --- a/bt/scrape.php +++ b/bt/scrape.php @@ -46,10 +46,6 @@ $info_hash = $_GET['info_hash']; function msg_die($msg) { - if (DBG_LOG) { - dbg_log(' ', '!die-' . clean_filename($msg)); - } - $output = \Rych\Bencode\Bencode::encode([ 'min interval' => (int)1800, 'failure reason' => (string)$msg, @@ -79,5 +75,4 @@ $output['files'][$info_hash] = array( echo \Rych\Bencode\Bencode::encode($output); -tracker_exit(); exit; diff --git a/library/defines.php b/library/defines.php index 616907117..bbd9a0cbd 100644 --- a/library/defines.php +++ b/library/defines.php @@ -65,8 +65,6 @@ define('XS_TAG_ENDIF', 8); define('XS_TAG_BEGINELSE', 11); // Debug -define('DBG_LOG', false); // enable forum debug (off on production) -define('DBG_TRACKER', false); // enable tracker debug (off on production) define('COOKIE_DBG', 'bb_dbg'); // debug cookie name define('SQL_DEBUG', true); // enable forum sql & cache debug define('SQL_LOG_ERRORS', true); // all SQL_xxx options enabled only if SQL_DEBUG == TRUE diff --git a/library/includes/cron/jobs/tr_cleanup_and_dlstat.php b/library/includes/cron/jobs/tr_cleanup_and_dlstat.php index ca5a1d8b5..fa21fb186 100644 --- a/library/includes/cron/jobs/tr_cleanup_and_dlstat.php +++ b/library/includes/cron/jobs/tr_cleanup_and_dlstat.php @@ -58,7 +58,7 @@ if ($bb_cfg['tracker']['update_dlstat']) { topic_id, user_id, IF(releaser, $releaser, seeder), SUM(up_add), SUM(down_add), IF(releaser, SUM(up_add), 0), SUM(speed_up), SUM(speed_down) FROM " . BB_BT_TRACKER . " WHERE (up_add != 0 OR down_add != 0) - GROUP BY topic_id, user_id, releaser, seeder + GROUP BY topic_id, user_id "); // Reset up/down additions in tracker diff --git a/src/Legacy/Cache/Memcache.php b/src/Legacy/Cache/Memcache.php index 1b10d2c2e..5b6e57038 100644 --- a/src/Legacy/Cache/Memcache.php +++ b/src/Legacy/Cache/Memcache.php @@ -61,10 +61,6 @@ class Memcache extends Common $this->connected = true; } - if (DBG_LOG) { - dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL')); - } - if (!$this->connected && $this->cfg['con_required']) { die('Could not connect to memcached server'); } diff --git a/src/Legacy/Cache/SqliteCommon.php b/src/Legacy/Cache/SqliteCommon.php index fdc2056ca..0938a1671 100644 --- a/src/Legacy/Cache/SqliteCommon.php +++ b/src/Legacy/Cache/SqliteCommon.php @@ -65,10 +65,6 @@ class SqliteCommon extends Common $this->connected = true; } - if (DBG_LOG) { - dbg_log(' ', $this->cfg['log_name'] . '-connect' . ($this->connected ? '' : '-FAIL')); - } - if (!$this->connected && $this->cfg['con_required']) { trigger_error('SQLite not connected', E_USER_ERROR); } diff --git a/src/Legacy/Datastore/Memcache.php b/src/Legacy/Datastore/Memcache.php index 18c4e536c..ac6fad891 100644 --- a/src/Legacy/Datastore/Memcache.php +++ b/src/Legacy/Datastore/Memcache.php @@ -60,10 +60,6 @@ class Memcache extends Common $this->connected = true; } - if (DBG_LOG) { - dbg_log(' ', 'CACHE-connect' . ($this->connected ? '' : '-FAIL')); - } - if (!$this->connected && $this->cfg['con_required']) { die('Could not connect to memcached server'); } diff --git a/src/Legacy/Datastore/SqliteCommon.php b/src/Legacy/Datastore/SqliteCommon.php index 029a1d82e..6a8a21885 100644 --- a/src/Legacy/Datastore/SqliteCommon.php +++ b/src/Legacy/Datastore/SqliteCommon.php @@ -65,10 +65,6 @@ class SqliteCommon extends Common $this->connected = true; } - if (DBG_LOG) { - dbg_log(' ', $this->cfg['log_name'] . '-connect' . ($this->connected ? '' : '-FAIL')); - } - if (!$this->connected && $this->cfg['con_required']) { trigger_error('SQLite not connected', E_USER_ERROR); } diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index 6e4a5885f..c3c27277f 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -805,7 +805,7 @@ class SqlDb $dbg =& $this->dbg[$id]; if ($mode == 'start') { - if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) { + if (SQL_CALC_QUERY_TIME || SQL_LOG_SLOW_QUERIES) { $this->sql_starttime = utime(); } if ($this->dbg_enabled) { @@ -821,7 +821,7 @@ class SqlDb $this->explain('start'); } } elseif ($mode == 'stop') { - if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) { + if (SQL_CALC_QUERY_TIME || SQL_LOG_SLOW_QUERIES) { $this->cur_query_time = utime() - $this->sql_starttime; $this->sql_timetotal += $this->cur_query_time; $this->DBS['sql_timetotal'] += $this->cur_query_time; @@ -855,13 +855,7 @@ class SqlDb public function trigger_error($msg = 'DB Error') { if (error_reporting()) { - if (DBG_LOG === true) { - $err = $this->sql_error(); - $msg .= "\n" . trim(sprintf('#%06d %s', $err['code'], $err['message'])); - } else { - $msg .= ' [' . $this->debug_find_source() . ']'; - } - + $msg .= ' [' . $this->debug_find_source() . ']'; trigger_error($msg, E_USER_ERROR); } } diff --git a/styles/templates/default/viewtopic_attach.tpl b/styles/templates/default/viewtopic_attach.tpl index 0fc3b92cb..0f95e5903 100644 --- a/styles/templates/default/viewtopic_attach.tpl +++ b/styles/templates/default/viewtopic_attach.tpl @@ -223,11 +223,6 @@ {L_SIZE}: {postrow.attach.tor_reged.TORRENT_SIZE} - - - {postrow.attach.tor_reged.comment.COMMENT} - -