Skip to content

Commit

Permalink
downhash use dot instead of solid line
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Dec 23, 2024
1 parent 2ca703c commit d8ce2bd
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/Console/Commands/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public function __construct()
*/
public function handle()
{
$torrent = Torrent::query()->find(12, ['info_hash']);
$infoHash = $torrent->info_hash;
dd($infoHash === rawurldecode("%15%24%f3%e6%91e%f6%fbT%be%3f%b8%f3%f7_%f5%f6%aa%3fv"));
$str = "1.abc.de";
$res = explode(".", $str, 2);
dd($res);
}

}
1 change: 1 addition & 0 deletions app/Filament/Resources/User/HitAndRunResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static function table(Table $table): Table
Tables\Columns\TextColumn::make('seedTimeRequired')->label(__('label.seed_time_required')),
Tables\Columns\TextColumn::make('inspectTimeLeft')->label(__('label.inspect_time_left')),
Tables\Columns\TextColumn::make('statusText')->label(__('label.status')),
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at')),
])
->defaultSort('id', 'desc')
->filters([
Expand Down
8 changes: 5 additions & 3 deletions app/Repositories/TorrentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public function getDetail($id, User $user)
return $result;
}

private function getDownloadUrl($id, array|User $user): string
public function getDownloadUrl($id, array|User $user): string
{
return sprintf(
'%s/download.php?downhash=%s|%s',
'%s/download.php?downhash=%s.%s',
getSchemeAndHttpHost(), is_array($user) ? $user['id'] : $user->id, $this->encryptDownHash($id, $user)
);
}
Expand Down Expand Up @@ -365,14 +365,16 @@ public function decryptDownHash($downHash, $user)

private function getEncryptDownHashKey($user)
{
$passkey = "";
if ($user instanceof User && $user->passkey) {
$passkey = $user->passkey;
} elseif (is_array($user) && !empty($user['passkey'])) {
$passkey = $user['passkey'];
} elseif (is_scalar($user)) {
$user = User::query()->findOrFail(intval($user), ['id', 'passkey']);
$passkey = $user->passkey;
} else {
}
if (empty($passkey)) {
throw new \InvalidArgumentException("Invalid user: " . json_encode($user));
}
//down hash is relative to user passkey
Expand Down
2 changes: 1 addition & 1 deletion public/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
}
// ------------- end claim block ------------------//

tr($lang_details['torrent_dl_url'],sprintf('<a title="%s" href="%s/download.php?downhash=%s|%s">%s</a>',$lang_details['torrent_dl_url_notice'], getSchemeAndHttpHost(), $CURUSER['id'], $torrentRep->encryptDownHash($row['id'], $CURUSER), $lang_details['torrent_dl_url_text']),1);
tr($lang_details['torrent_dl_url'],sprintf('<a title="%s" href="%s">%s</a>',$lang_details['torrent_dl_url_notice'], $torrentRep->getDownloadUrl($id, $CURUSER), $lang_details['torrent_dl_url_text']),1);

// ---------------- start subtitle block -------------------//
$subTorrentIdArr = [$row['id']];
Expand Down
2 changes: 1 addition & 1 deletion public/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function denyDownload()
}
$torrentRep = new \App\Repositories\TorrentRepository();
if (!empty($_REQUEST['downhash'])) {
$params = explode('|', $_REQUEST['downhash']);
$params = explode('.', $_REQUEST['downhash'], 2);
if (empty($params[0]) || empty($params[1])) {
die("invalid downhash, format error");
}
Expand Down
4 changes: 2 additions & 2 deletions public/getusertorrentlistajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ function maketable($res, $mode = 'seeding')
// $res = sql_query("SELECT torrent,added,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes' ORDER BY torrents.id DESC") or sqlerr();
$fields = "torrent,added,snatched.uploaded,snatched.downloaded,snatched.seedtime,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers,snatched.userid, categories.mode as search_box_id, peers.peer_id, peers.agent, peers.port, peers.ipv4, peers.ipv6";
$tableWhere = "peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes'";
$order = "torrents.id DESC";
$order = "peers.id DESC";
break;
}

Expand All @@ -291,7 +291,7 @@ function maketable($res, $mode = 'seeding')
// $res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers, torrents.added FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.id DESC") or sqlerr();
$fields = "torrent,snatched.uploaded,snatched.downloaded,snatched.seedtime,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers, torrents.added,snatched.userid, categories.mode as search_box_id, peers.peer_id, peers.agent, peers.port, peers.ipv4, peers.ipv6";
$tableWhere = "peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no'";
$order = "torrents.id DESC";
$order = "peers.id DESC";
break;
}

Expand Down
2 changes: 1 addition & 1 deletion public/takeupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ function checkTorrentDict($dict, $key, $type = null)
$description
-------------------------------------------------------------------------------------------------------------------------
{$lang_takeupload_target[$langfolder_array[$i]]['mail_torrent']}<b><a href="javascript:void(null)" onclick="window.open('http://$BASEURL/details.php?id=$id&hit=1')">{$lang_takeupload_target[$langfolder_array[$i]]['mail_here']}</a></b><br />
{$lang_takeupload_target[$langfolder_array[$i]]['mail_torrent']}<b><a href="javascript:void(null)" onclick="window.open('$baseUrl/details.php?id=$id&hit=1')">{$lang_takeupload_target[$langfolder_array[$i]]['mail_here']}</a></b><br />
$baseUrl/details.php?id=$id&hit=1
------{$lang_takeupload_target[$langfolder_array[$i]]['mail_yours']}
Expand Down
2 changes: 1 addition & 1 deletion public/torrentrss.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function get_where($tablename = "sources", $itemname = "source", $getname = "sou
}
$itemurl = $url."/details.php?id=".$row['id'];
if ($dllink)
$itemdlurl = $url."/download.php?id=".$row['id']."&amp;downhash=" . rawurlencode( $user['id'] . '|'. $torrentRep->encryptDownHash($row['id'], $user));
$itemdlurl = $torrentRep->getDownloadUrl($row['id'], $user);
else $itemdlurl = $url."/download.php?id=".$row['id'];
if (!empty($_GET['icat'])) $title .= "[".$row['category_name']."]";
$title .= $row['name'];
Expand Down

0 comments on commit d8ce2bd

Please sign in to comment.