From 098595e3eabc3890d08a7194594359b429a32bc6 Mon Sep 17 00:00:00 2001 From: Exile Date: Sun, 24 Aug 2014 21:15:26 +0400 Subject: [PATCH] Info-hash search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавляем поиск по хешу, вывод хеша в топики. --- upload/attach_mod/displaying_torrent.php | 1 + upload/config.php | 2 +- upload/includes/functions.php | 23 ++++++++ upload/language/en/main.php | 4 ++ upload/language/ru/main.php | 4 ++ upload/language/uk/main.php | 4 ++ upload/templates/default/css/main.css | 11 ++-- upload/templates/default/page_header.tpl | 3 +- upload/templates/default/tracker.tpl | 4 +- upload/templates/default/viewtopic_attach.tpl | 41 +++++++------- upload/tracker.php | 56 ++++++++++--------- 11 files changed, 99 insertions(+), 54 deletions(-) diff --git a/upload/attach_mod/displaying_torrent.php b/upload/attach_mod/displaying_torrent.php index 6ee7e12f6..4373939a7 100644 --- a/upload/attach_mod/displaying_torrent.php +++ b/upload/attach_mod/displaying_torrent.php @@ -230,6 +230,7 @@ if ($tor_reged && $tor_info) 'DL_TITLE_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_status_css[$bt_userdata['user_status']] : 'gen', 'FILESIZE' => $tor_file_size, 'MAGNET' => $tor_magnet, + 'HASH' => strtoupper(bin2hex($tor_info['info_hash'])), 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count), 'REGED_TIME' => bb_date($tor_info['reg_time']), 'REGED_DELTA' => delta_time($tor_info['reg_time']), diff --git a/upload/config.php b/upload/config.php index 1a6a068ed..2b3c24b48 100644 --- a/upload/config.php +++ b/upload/config.php @@ -70,7 +70,7 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do // Version info $bb_cfg['tp_version'] = '2.0.9 (RC)'; -$bb_cfg['tp_release_date'] = '23-08-2014'; +$bb_cfg['tp_release_date'] = '24-08-2014'; $bb_cfg['tp_release_state'] = 'R597'; // Database diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 09d508309..9e45a33b5 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -2844,4 +2844,27 @@ function update_atom ($type, $id) update_user_feed($topic_poster, get_username($topic_poster)); break; } +} + +function hash_search ($hash) +{ + global $lang; + + $hash = htmlCHR(trim($hash)); + + if (!isset($hash) || mb_strlen($hash, 'UTF-8') != 40) + { + bb_die(sprintf($lang['HASH_INVALID'], $hash)); + } + + $info_hash = DB()->escape(pack("H*", $hash)); + + if ($row = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash'")) + { + redirect(TOPIC_URL . $row['topic_id']); + } + else + { + bb_die(sprintf($lang['HASH_NOT_FOUND'], $hash)); + } } \ No newline at end of file diff --git a/upload/language/en/main.php b/upload/language/en/main.php index e27e6fc1e..e30cdc212 100644 --- a/upload/language/en/main.php +++ b/upload/language/en/main.php @@ -1494,6 +1494,7 @@ $lang['REPORTS_DELETED'] = 'The selected reports were deleted.';// $lang['SEARCH_S'] = 'search...'; $lang['FORUM_S'] = 'on forum'; $lang['TRACKER_S'] = 'on tracker'; +$lang['HASH_S'] = 'by info_hash'; // copyright $lang['NOTICE'] = '!ATTENTION!'; @@ -2976,3 +2977,6 @@ $lang['ATOM_SUBSCRIBE'] = 'Subscribe to the feed'; $lang['ATOM_NO_MODE'] = 'Do not specify a mode for the feed'; $lang['ATOM_NO_FORUM'] = 'This forum does not have a feed (no ongoing topics)'; $lang['ATOM_NO_USER'] = 'This user does not have a feed (no ongoing topics)'; + +$lang['HASH_INVALID'] = 'Hash %s is invalid'; +$lang['HASH_NOT_FOUND'] = 'Release with hash %s not found'; \ No newline at end of file diff --git a/upload/language/ru/main.php b/upload/language/ru/main.php index abfb9d0d6..3e0cf85c7 100644 --- a/upload/language/ru/main.php +++ b/upload/language/ru/main.php @@ -1494,6 +1494,7 @@ $lang['REPORTS_DELETED'] = 'Выбранные сообщения удалены $lang['SEARCH_S'] = 'поиск…'; $lang['FORUM_S'] = 'по форуму'; $lang['TRACKER_S'] = 'по трекеру'; +$lang['HASH_S'] = 'по info_hash'; // copyright $lang['NOTICE'] = '!ВНИМАНИЕ!'; @@ -2976,3 +2977,6 @@ $lang['ATOM_SUBSCRIBE'] = 'Подписка на ленту'; $lang['ATOM_NO_MODE'] = 'Не указан режим для ленты'; $lang['ATOM_NO_FORUM'] = 'Для этого форума нет ленты (нет начатых тем)'; $lang['ATOM_NO_USER'] = 'Для этого пользователя нет ленты (нет начатых тем)'; + +$lang['HASH_INVALID'] = 'Хэш %s некорректен'; +$lang['HASH_NOT_FOUND'] = 'Раздача с хэшем %s не найдена'; \ No newline at end of file diff --git a/upload/language/uk/main.php b/upload/language/uk/main.php index 5445b2726..875309729 100644 --- a/upload/language/uk/main.php +++ b/upload/language/uk/main.php @@ -1494,6 +1494,7 @@ $lang['REPORTS_DELETED'] = 'Вибрані повідомлення видале $lang['SEARCH_S'] = 'пошук...'; $lang['FORUM_S'] = 'по форуму'; $lang['TRACKER_S'] = 'по трекеру'; +$lang['HASH_S'] = 'по info_hash'; // copyright $lang['NOTICE'] = '!УВАГА!'; @@ -2976,3 +2977,6 @@ $lang['ATOM_SUBSCRIBE'] = 'Підписка на стрічку'; $lang['ATOM_NO_MODE'] = 'Не вказано режим для стрічки'; $lang['ATOM_NO_FORUM'] = 'Для цього форуму немає стрічки (немає початих тем)'; $lang['ATOM_NO_USER'] = 'Для цього користувача немає стрічки (немає початих тем)'; + +$lang['HASH_INVALID'] = 'Хеш %s некоректний'; +$lang['HASH_NOT_FOUND'] = 'Роздача з хешем %s не знайдено'; \ No newline at end of file diff --git a/upload/templates/default/css/main.css b/upload/templates/default/css/main.css index f09322839..abf92ce07 100644 --- a/upload/templates/default/css/main.css +++ b/upload/templates/default/css/main.css @@ -289,10 +289,10 @@ a.postLink-name, a.postLink-name:visited { text-decoration: none; } * ---------------------------------- */ .infobox { border: 1px #B7C0C5 solid; background: #EFEFEF; padding: 1px; - } - .infobox h1 { - background: #D1D7DC; font-size: 1.2em; padding: 0 0.6em 2px; - } +} +.infobox h1 { + background: #D1D7DC; font-size: 1.2em; padding: 0 0.6em 2px; +} /* ---------------------------------- * Inputs, buttons, forms * ---------------------------------- */ @@ -882,6 +882,9 @@ fieldset.attach { width: 95%; margin: 14px auto; padding: 2px; clear: both; } a.tr-dl, a.dl-link:link { font-weight: bold; } a.dl-link { font-size: 13px; text-decoration: none; } a.tr-dl:visited, a.f-dl:visited, a.dl-link:visited { color: #5493B4; font-weight: normal; } +.a-hash { color: #000066 !important; cursor: pointer; } +.a-hash:hover { color: #DD6900 !important; text-decoration: underline !important; } +.a-hash:active, .a-hash:focus { color: #DD6900 !important; text-decoration: underline !important; } .seed-leech { padding-left: 1px; padding-right: 0; } .tr_tm { margin-top: 2px; font-size: 10px; color: #676767; } diff --git a/upload/templates/default/page_header.tpl b/upload/templates/default/page_header.tpl index fc2263f0b..4e9874f67 100644 --- a/upload/templates/default/page_header.tpl +++ b/upload/templates/default/page_header.tpl @@ -311,13 +311,14 @@ $(document).ready(function() {
- diff --git a/upload/templates/default/tracker.tpl b/upload/templates/default/tracker.tpl index 5af9649e6..19f9555be 100644 --- a/upload/templates/default/tracker.tpl +++ b/upload/templates/default/tracker.tpl @@ -267,10 +267,10 @@ $(function(){
- {L_TITLE_MATCH} + {L_TITLE_MATCH} · {L_HASH_S}

- +

{ALL_WORDS_CHBOX} diff --git a/upload/templates/default/viewtopic_attach.tpl b/upload/templates/default/viewtopic_attach.tpl index c6b3d1e95..28f377d56 100644 --- a/upload/templates/default/viewtopic_attach.tpl +++ b/upload/templates/default/viewtopic_attach.tpl @@ -147,19 +147,20 @@ {postrow.attach.tor_reged.DOWNLOAD_NAME} {postrow.attach.tor_reged.MAGNET} - -  {L_SILVER_STATUS}  - - - -  {L_GOLD_STATUS}  - - + +  {L_SILVER_STATUS}  + + + +  {L_GOLD_STATUS}  + + {L_TORRENT}: - {postrow.attach.tor_reged.TRACKER_LINK}   + {postrow.attach.tor_reged.TRACKER_LINK} [ {postrow.attach.tor_reged.REGED_TIME} ] + · {postrow.attach.tor_reged.HASH} @@ -190,12 +191,12 @@ }); }; ajax.callback.change_tor_status = function(data) { - - $('#tor-'+ data.attach_id +'-status').html(data.status); - - $('#tor_comment').html('{L_TOR_AUTH_SENT_COMMENT}'); - - $('#comment').attr('value', ''); + + $('#tor-'+ data.attach_id +'-status').html(data.status); + + $('#tor_comment').html('{L_TOR_AUTH_SENT_COMMENT}'); + + $('#comment').attr('value', ''); }; @@ -231,8 +232,8 @@ @@ -265,9 +266,7 @@ - - {TOR_HELP_LINKS} @@ -350,8 +349,8 @@ $('#tor-filelist-btn').click(function(){ -

- {L_COLLAPSE}· + diff --git a/upload/tracker.php b/upload/tracker.php index a71ce7380..16d34e7cf 100644 --- a/upload/tracker.php +++ b/upload/tracker.php @@ -220,31 +220,32 @@ foreach ($s_not_seen_opt as $val => $opt) } $GPC = array( -# var_name key_name def_value GPC type - 'all_words' => array('allw', 1, CHBOX), - 'active' => array('a', 0, CHBOX), - 'cat' => array('c', null, REQUEST), - 'dl_cancel' => array('dla', 0, CHBOX), - 'dl_compl' => array('dlc', 0, CHBOX), - 'dl_down' => array('dld', 0, CHBOX), - 'dl_will' => array('dlw', 0, CHBOX), - 'forum' => array('f', $search_all, REQUEST), - 'my' => array('my', 0, CHBOX), - 'new' => array('new', 0, CHBOX), - 'title_match' => array('nm', null, REQUEST), - 'order' => array('o', $ord_posted, SELECT), - 'poster_id' => array('pid', null, GET), - 'poster_name' => array('pn', null, REQUEST), - 'user_releases' => array('rid', null, GET), - 'sort' => array('s', $sort_desc, SELECT), - 'seed_exist' => array('sd', 0, CHBOX), - 'show_author' => array('da', 1, CHBOX), - 'show_cat' => array('dc', 0, CHBOX), - 'show_forum' => array('df', 1, CHBOX), - 'show_speed' => array('ds', 0, CHBOX), - 's_not_seen' => array('sns', $search_all, SELECT), - 'time' => array('tm', $search_all, SELECT), - 'tor_type' => array('tor_type', 0, CHBOX), +# var_name key_name def_value GPC type + 'all_words' => array('allw', 1, CHBOX), + 'active' => array('a', 0, CHBOX), + 'cat' => array('c', null, REQUEST), + 'dl_cancel' => array('dla', 0, CHBOX), + 'dl_compl' => array('dlc', 0, CHBOX), + 'dl_down' => array('dld', 0, CHBOX), + 'dl_will' => array('dlw', 0, CHBOX), + 'forum' => array('f', $search_all, REQUEST), + 'my' => array('my', 0, CHBOX), + 'new' => array('new', 0, CHBOX), + 'title_match' => array('nm', null, REQUEST), + 'order' => array('o', $ord_posted, SELECT), + 'poster_id' => array('pid', null, GET), + 'poster_name' => array('pn', null, REQUEST), + 'user_releases' => array('rid', null, GET), + 'sort' => array('s', $sort_desc, SELECT), + 'seed_exist' => array('sd', 0, CHBOX), + 'show_author' => array('da', 1, CHBOX), + 'show_cat' => array('dc', 0, CHBOX), + 'show_forum' => array('df', 1, CHBOX), + 'show_speed' => array('ds', 0, CHBOX), + 's_not_seen' => array('sns', $search_all, SELECT), + 'time' => array('tm', $search_all, SELECT), + 'tor_type' => array('tor_type', 0, CHBOX), + 'hash' => array('hash', null, REQUEST), ); // Define all GPC vars with default values @@ -425,6 +426,11 @@ if (!$set_default) } } + if (isset($_REQUEST[$hash_key])) + { + hash_search($_REQUEST[$hash_key]); + } + if ($tm =& $_REQUEST[$title_match_key] AND is_string($tm)) { if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len))