diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 01bfa447..bbc29dc3 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -52,8 +52,8 @@ class Test extends Command public function handle() { // $r = \Illuminate\Support\Facades\Schema::getColumnListing('torrents'); - $r = urldecode('bm9wZQ%3D%3D'); - $r = base64_decode($r); + $r = urldecode('%b5%8f%7c%a9%85%ed%e2%bb%09%fd1%ab%8d%11%e5%11%bb%18%deD'); + $r = bin2hex($r); dd($r); } diff --git a/public/announce.php b/public/announce.php index 2a281bb2..366818a4 100644 --- a/public/announce.php +++ b/public/announce.php @@ -79,12 +79,13 @@ $seeder = ($left == 0) ? "yes" : "no"; // check passkey if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){ - $res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); - $az = mysql_fetch_array($res); + $res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror,passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); + $az = $currentUser = mysql_fetch_array($res); $Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950); } if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL"); $userid = intval($az['id'] ?? 0); +$GLOBALS["CURUSER"] = $currentUser; //3. CHECK IF CLIENT IS ALLOWED $clicheck_res = check_client($peer_id,$agent,$client_familyid); @@ -102,12 +103,16 @@ elseif ($az['showclienterror'] == 'yes'){ } // check torrent based on info_hash +$checkTorrentSql = "SELECT id, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned FROM torrents WHERE " . hash_where("info_hash", $info_hash); if (!$torrent = $Cache->get_value('torrent_hash_'.$info_hash.'_content')){ - $res = sql_query("SELECT id, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned FROM torrents WHERE " . hash_where("info_hash", $info_hash)); + $res = sql_query($checkTorrentSql); $torrent = mysql_fetch_array($res); $Cache->cache_value('torrent_hash_'.$info_hash.'_content', $torrent, 350); } -if (!$torrent) err("torrent not registered with this tracker"); +if (!$torrent) { + do_log("[TORRENT NOT EXISTS] $checkTorrentSql"); + err("torrent not registered with this tracker"); +} elseif ($torrent['banned'] == 'yes' && $az['class'] < $seebanned_class) err("torrent banned"); // select peers info from peers table for this torrent $torrentid = $torrent["id"];