mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Legacy code comment translations
This commit is contained in:
parent
1ce0101045
commit
c9bd92e781
11 changed files with 39 additions and 41 deletions
|
@ -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
|
||||
];
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class CronHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Снятие блокировки крона (по времени)
|
||||
* Unlock cron (time-dependent)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -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)";
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -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']--;
|
||||
|
|
|
@ -35,7 +35,7 @@ class TorrentFileList
|
|||
}
|
||||
|
||||
/**
|
||||
* Получение списка файлов
|
||||
* Fetching file list
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ class TorrentFileList
|
|||
}
|
||||
|
||||
/**
|
||||
* Формирование списка файлов
|
||||
* Forming file list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue