mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
WIP: Added search by info_hash v2 🐯 (#869)
* Added search by info_hash v2 * Update functions.php * Update functions.php
This commit is contained in:
parent
9b43d144a4
commit
072b5a074f
2 changed files with 14 additions and 4 deletions
|
@ -1949,14 +1949,24 @@ function hash_search($hash)
|
||||||
global $lang;
|
global $lang;
|
||||||
|
|
||||||
$hash = htmlCHR(trim($hash));
|
$hash = htmlCHR(trim($hash));
|
||||||
|
$info_hash_where = null;
|
||||||
|
|
||||||
if (!isset($hash) || mb_strlen($hash, 'UTF-8') != 40) {
|
if (!isset($hash)) {
|
||||||
bb_die(sprintf($lang['HASH_INVALID'], $hash));
|
bb_die(sprintf($lang['HASH_INVALID'], $hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
$info_hash = DB()->escape(pack("H*", $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'")) {
|
// Check info_hash version
|
||||||
|
if (mb_strlen($hash, 'UTF-8') == 40) {
|
||||||
|
$info_hash_where = "WHERE info_hash = '$info_hash'";
|
||||||
|
} elseif (mb_strlen($hash, 'UTF-8') == 64) {
|
||||||
|
$info_hash_where = "WHERE info_hash_v2 = '$info_hash'";
|
||||||
|
} else {
|
||||||
|
bb_die(sprintf($lang['HASH_INVALID'], $hash));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " $info_hash_where")) {
|
||||||
redirect(TOPIC_URL . $row['topic_id']);
|
redirect(TOPIC_URL . $row['topic_id']);
|
||||||
} else {
|
} else {
|
||||||
bb_die(sprintf($lang['HASH_NOT_FOUND'], $hash));
|
bb_die(sprintf($lang['HASH_NOT_FOUND'], $hash));
|
||||||
|
|
|
@ -283,7 +283,7 @@ $(function(){
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><span class="a-hash bold" onclick="$(this).addClass('bold').next().removeClass('bold'); $('#title_search').attr('name','{TITLE_MATCH_NAME}');">{L_TITLE_MATCH}</span> · <span class="a-hash" onclick="$(this).addClass('bold').prev().removeClass('bold'); $('#title_search').attr('name','hash');">{L_HASH_S}</span></legend>
|
<legend><span class="a-hash bold" onclick="$(this).addClass('bold').next().removeClass('bold'); $('#title_search').attr('name','{TITLE_MATCH_NAME}').attr('maxlength','{TITLE_MATCH_MAX}');">{L_TITLE_MATCH}</span> · <span class="a-hash" onclick="$(this).addClass('bold').prev().removeClass('bold'); $('#title_search').attr('name','hash').attr('maxlength',64);">{L_HASH_S}</span></legend>
|
||||||
<div>
|
<div>
|
||||||
<p class="input">
|
<p class="input">
|
||||||
<input id="title_search" style="width: 95%;" class="post" type="text" size="50" maxlength="{TITLE_MATCH_MAX}" name="{TITLE_MATCH_NAME}" value="{TITLE_MATCH_VAL}" />
|
<input id="title_search" style="width: 95%;" class="post" type="text" size="50" maxlength="{TITLE_MATCH_MAX}" name="{TITLE_MATCH_NAME}" value="{TITLE_MATCH_VAL}" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue