From c9bd92e7817b8b5395fa4387c44b0a8545f51e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B8nstantine=20Kovalensky?= <45331093+kovalensky@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:04:23 +0400 Subject: [PATCH] Legacy code comment translations --- library/includes/file_list_v2.php | 14 ++++++-------- src/Helpers/CronHelper.php | 2 +- src/Legacy/Admin/Common.php | 6 +++--- src/Legacy/BBCode.php | 10 +++++----- src/Legacy/Caches.php | 6 +++--- src/Legacy/Dbs.php | 4 ++-- src/Legacy/Poll.php | 12 ++++++------ src/Legacy/Post.php | 2 +- src/Legacy/SqlDb.php | 4 ++-- src/Legacy/TorrentFileList.php | 4 ++-- src/Legacy/WordsRate.php | 16 ++++++++-------- 11 files changed, 39 insertions(+), 41 deletions(-) diff --git a/library/includes/file_list_v2.php b/library/includes/file_list_v2.php index 69f3504ee..31a74de40 100644 --- a/library/includes/file_list_v2.php +++ b/library/includes/file_list_v2.php @@ -48,25 +48,23 @@ if (!is_file($file_path)) { $file_contents = file_get_contents($file_path); -if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) { +if (!$torrent = \Arokettu\Bencode\Bencode::decode($file_contents, dictType: \Arokettu\Bencode\Bencode\Collection::ARRAY)) { http_response_code(410); die($lang['TORFILE_INVALID']); } -if (isset($tor['info']['private']) && IS_GUEST) { +if (isset($torrent['info']['private']) && IS_GUEST) { http_response_code(403); die($lang['BT_PRIVATE_TORRENT']); } -$list_handler = new TorrentPier\Legacy\TorrentFileList($tor); - -$files = $list_handler->fileTreeTable($tor['info']['file tree']); +$files = (new TorrentPier\Legacy\TorrentFileList($torrent)) -> fileTreeTable($torrent['info']['file tree']); $data = [ - 'name' => htmlCHR($tor['info']['name'] ?? ''), - 'client' => htmlCHR(substr($tor['created by'] ?? 'unknown client', 0, 20)), + 'name' => htmlCHR($torrent['info']['name'] ?? ''), + 'client' => htmlCHR(substr($torrent['created by'] ?? 'unknown client', 0, 20)), 'size' => humn_size($files['size']), - 'date' => (isset($tor['creation date']) && is_numeric($tor['creation date'])) ? delta_time($tor['creation date']) : 'unknown', + 'date' => (isset($torrent['creation date']) && is_numeric($torrent['creation date'])) ? delta_time($torrent['creation date']) : 'unknown', 'site_url' => FULL_URL ]; diff --git a/src/Helpers/CronHelper.php b/src/Helpers/CronHelper.php index 1cc14f55d..7ee97406c 100644 --- a/src/Helpers/CronHelper.php +++ b/src/Helpers/CronHelper.php @@ -26,7 +26,7 @@ class CronHelper } /** - * Снятие блокировки крона (по времени) + * Unlock cron (time-dependent) * * @return void */ diff --git a/src/Legacy/Admin/Common.php b/src/Legacy/Admin/Common.php index 5ea2fb202..92b535d54 100644 --- a/src/Legacy/Admin/Common.php +++ b/src/Legacy/Admin/Common.php @@ -55,7 +55,7 @@ class Common "); DB()->add_shutdown_query("DROP TEMPORARY TABLE IF EXISTS $tmp_sync_forums"); - // начальное обнуление значений + // init values with zeros $forum_ary = explode(',', $forum_csv); DB()->query("REPLACE INTO $tmp_sync_forums (forum_id) VALUES(" . implode('),(', $forum_ary) . ")"); @@ -95,7 +95,7 @@ class Common break; } - // Проверка на остаточные записи об уже удаленных топиках + // Check for left-overs after deleted posts DB()->query("DELETE FROM " . BB_TOPICS . " WHERE topic_first_post_id NOT IN (SELECT post_id FROM " . BB_POSTS . ")"); $tmp_sync_topics = 'tmp_sync_topics'; @@ -542,7 +542,7 @@ class Common return false; } - // фильтр заглавных сообщений в теме + // Filter for header messages if ($exclude_first) { $sql = "SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_first_post_id IN($post_csv)"; diff --git a/src/Legacy/BBCode.php b/src/Legacy/BBCode.php index ea064903f..3ffb4fcbc 100644 --- a/src/Legacy/BBCode.php +++ b/src/Legacy/BBCode.php @@ -267,11 +267,11 @@ class BBCode */ private function escape_titles_callback($m): string { - $tilte = substr($m[3], 0, 250); - $tilte = str_replace(['[', ']', ':', ')', '"'], ['[', ']', ':', ')', '"'], $tilte); - // еще раз htmlspecialchars, т.к. при извлечении из title происходит обратное преобразование - $tilte = htmlspecialchars($tilte, ENT_QUOTES); - return $m[1] . $tilte . $m[4]; + $title = substr($m[3], 0, 250); + $title = str_replace(['[', ']', ':', ')', '"'], ['[', ']', ':', ')', '"'], $title); + // reconvert because after extracting title there's a reverse convertion + $title = htmlspecialchars($title, ENT_QUOTES); + return $m[1] . $title . $m[4]; } /** diff --git a/src/Legacy/Caches.php b/src/Legacy/Caches.php index 2e4d0524f..3e7ba3812 100644 --- a/src/Legacy/Caches.php +++ b/src/Legacy/Caches.php @@ -15,9 +15,9 @@ namespace TorrentPier\Legacy; */ class Caches { - public $cfg = []; // конфиг - public $obj = []; // кеш-объекты - public $ref = []; // ссылки на $obj (имя_кеша => кеш_объект) + public $cfg = []; // config + public $obj = []; // cache-objects + public $ref = []; // links to $obj (cache_name => cache_objects) public function __construct($cfg) { diff --git a/src/Legacy/Dbs.php b/src/Legacy/Dbs.php index 20cf24ad9..832de652d 100644 --- a/src/Legacy/Dbs.php +++ b/src/Legacy/Dbs.php @@ -41,7 +41,7 @@ class Dbs } /** - * Получение / инициализация класса сервера $srv_name + * Initialization / Fetching of $srv_name * * @param string $srv_name_or_alias * @@ -59,7 +59,7 @@ class Dbs } /** - * Определение имени сервера + * Fetching server name * * @param string $name * diff --git a/src/Legacy/Poll.php b/src/Legacy/Poll.php index 4e4b86a98..997b3e8a0 100644 --- a/src/Legacy/Poll.php +++ b/src/Legacy/Poll.php @@ -26,7 +26,7 @@ class Poll } /** - * Формирование результатов голосования + * Forming poll results * * @param $posted_data * @return string @@ -41,7 +41,7 @@ class Poll global $lang; return $this->err_msg = $lang['EMPTY_POLL_TITLE']; } - $this->poll_votes[] = $poll_caption; // заголовок имеет vote_id = 0 + $this->poll_votes[] = $poll_caption; // header is vote_id = 0 foreach (explode("\n", $poll_votes) as $vote) { if (!$vote = str_compact($vote)) { @@ -50,7 +50,7 @@ class Poll $this->poll_votes[] = $vote; } - // проверять на "< 3" -- 2 варианта ответа + заголовок + // check for "< 3" -- 2 answer variants + header if (\count($this->poll_votes) < 3 || \count($this->poll_votes) > $this->max_votes + 1) { global $lang; return $this->err_msg = sprintf($lang['NEW_POLL_VOTES'], $this->max_votes); @@ -58,7 +58,7 @@ class Poll } /** - * Добавление голосов в базу данных + * Recording poll info to the database * * @param int $topic_id */ @@ -83,7 +83,7 @@ class Poll } /** - * Удаление голосования + * Remove poll * * @param int $topic_id */ @@ -94,7 +94,7 @@ class Poll } /** - * Удаление информации о проголосовавших и голосов + * Remove info about voters and their choices * * @param int $topic_id */ diff --git a/src/Legacy/Post.php b/src/Legacy/Post.php index 98bda572b..e2cdb7a4f 100644 --- a/src/Legacy/Post.php +++ b/src/Legacy/Post.php @@ -197,7 +197,7 @@ class Post update_post_html(['post_id' => $post_id, 'post_text' => $post_message]); - //Обновление кеша новостей на главной + // Updating news cache on index page if ($bb_cfg['show_latest_news']) { $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); if (isset($news_forums[$forum_id]) && $bb_cfg['show_latest_news'] && $mode == 'newtopic') { diff --git a/src/Legacy/SqlDb.php b/src/Legacy/SqlDb.php index d2130d159..345c23cea 100644 --- a/src/Legacy/SqlDb.php +++ b/src/Legacy/SqlDb.php @@ -64,7 +64,7 @@ class SqlDb $this->do_explain = ($this->dbg_enabled && !empty($_COOKIE['explain'])); $this->slow_time = SQL_SLOW_QUERY_TIME; - // ссылки на глобальные переменные (для включения логов сразу на всех серверах, подсчета общего количества запросов и т.д.) + // Links to the global vairables (for recording all the logs on all servers, counting total request count and etc) $this->DBS['log_file'] =& $DBS->log_file; $this->DBS['log_counter'] =& $DBS->log_counter; $this->DBS['num_queries'] =& $DBS->num_queries; @@ -820,7 +820,7 @@ class SqlDb if ($this->do_explain) { $this->explain('stop'); } - // проверка установки $this->inited - для пропуска инициализационных запросов + // check for $this->inited - to bypass request controlling if ($this->DBS['log_counter'] && $this->inited) { $this->log_query($this->DBS['log_file']); $this->DBS['log_counter']--; diff --git a/src/Legacy/TorrentFileList.php b/src/Legacy/TorrentFileList.php index ebb5daef9..1c7dfa4f8 100644 --- a/src/Legacy/TorrentFileList.php +++ b/src/Legacy/TorrentFileList.php @@ -35,7 +35,7 @@ class TorrentFileList } /** - * Получение списка файлов + * Fetching file list * * @return string */ @@ -63,7 +63,7 @@ class TorrentFileList } /** - * Формирование списка файлов + * Forming file list * * @return void */ diff --git a/src/Legacy/WordsRate.php b/src/Legacy/WordsRate.php index d4cd9717c..216907e8d 100644 --- a/src/Legacy/WordsRate.php +++ b/src/Legacy/WordsRate.php @@ -24,7 +24,7 @@ class WordsRate public function __construct() { - // слова начинающиеся на.. + // words starting with.. $del_list = file_get_contents(BB_ROOT . '/library/words_rate_del_list.txt'); $del_list = str_compact($del_list); $del_list = str_replace(' ', '|', preg_quote($del_list, '/')); @@ -34,7 +34,7 @@ class WordsRate } /** - * Возвращает "показатель полезности" сообщения используемый для автоудаления коротких сообщений типа "спасибо", "круто" и т.д. + * Returns "usefulness coefficient" for automatic deletion of short sentences as "thanks", "cool" and etc. * * @param string $text * @return int @@ -45,19 +45,19 @@ class WordsRate $this->deleted_words = []; $this->del_text_hl = $text; - // длинное сообщение + // Long text if (\strlen($text) > 600) { return $this->words_rate; } - // вырезаем цитаты если содержит +1 + // Crop quotes if contains +1 if (preg_match('#\+\d+#', $text)) { $text = strip_quotes($text); } - // содержит ссылку + // Contains a link if (strpos($text, '://')) { return $this->words_rate; } - // вопрос + // Question if ($questions = preg_match_all('#\w\?+#', $text, $m)) { if ($questions >= 1) { return $this->words_rate; @@ -71,9 +71,9 @@ class WordsRate } $text = preg_replace($this->words_del_exp, '', $text); - // удаление смайлов + // Delete smilies $text = preg_replace('#:\w+:#', '', $text); - // удаление bbcode тегов + // Delete bb_code tags $text = preg_replace('#\[\S+\]#', '', $text); $words_count = preg_match_all($this->words_cnt_exp, $text, $m);