2020-12-26 01:42:23 +08:00
|
|
|
<?php
|
2021-02-26 15:15:13 +08:00
|
|
|
require_once('../include/bittorrent_announce.php');
|
2022-03-19 14:55:43 +08:00
|
|
|
require ROOT_PATH . 'include/core.php';
|
2021-06-09 02:23:09 +08:00
|
|
|
//require_once('../include/benc.php');
|
2020-12-26 01:42:23 +08:00
|
|
|
dbconn_announce();
|
|
|
|
|
|
|
|
|
|
// BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
|
|
|
|
|
block_browser();
|
|
|
|
|
|
|
|
|
|
preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_array);
|
|
|
|
|
$fields = "info_hash, times_completed, seeders, leechers";
|
|
|
|
|
|
|
|
|
|
if (count($info_hash_array[1]) < 1) {
|
2023-06-10 02:07:56 +08:00
|
|
|
warn("Require info_hash.", 86400);
|
2021-03-18 20:32:35 +08:00
|
|
|
// $query = "SELECT $fields FROM torrents ORDER BY id";
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$query = "SELECT $fields FROM torrents WHERE " . hash_where_arr('info_hash', $info_hash_array[1]);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-05 18:15:31 +08:00
|
|
|
$cacheKey = md5(http_build_query($info_hash_array[1]));
|
|
|
|
|
$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey);
|
|
|
|
|
if ($cacheData) {
|
|
|
|
|
do_log("[SCRAPE_FROM_CACHE]: " . $_SERVER["QUERY_STRING"]);
|
|
|
|
|
benc_resp($cacheData);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-26 01:42:23 +08:00
|
|
|
$res = sql_query($query);
|
|
|
|
|
|
|
|
|
|
if (mysql_num_rows($res) < 1){
|
2023-06-10 02:07:56 +08:00
|
|
|
warn("Torrent not registered with this tracker.", 86400);
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
|
2021-06-09 02:23:09 +08:00
|
|
|
$torrent_details = [];
|
2020-12-26 01:42:23 +08:00
|
|
|
while ($row = mysql_fetch_assoc($res)) {
|
2021-06-09 02:23:09 +08:00
|
|
|
$torrent_details[$row['info_hash']] = [
|
|
|
|
|
'complete' => (int)$row['seeders'],
|
|
|
|
|
'downloaded' => (int)$row['times_completed'],
|
|
|
|
|
'incomplete' => (int)$row['leechers']
|
|
|
|
|
];
|
2020-12-26 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
|
2021-06-09 02:23:09 +08:00
|
|
|
$d = ['files' => $torrent_details];
|
2023-03-04 13:26:20 +08:00
|
|
|
\Nexus\Database\NexusDB::cache_put($cacheKey, $d, 1200);
|
2021-06-09 02:23:09 +08:00
|
|
|
benc_resp($d);
|