number format dashboard + improve scrape cache

This commit is contained in:
xiaomlove
2023-03-05 18:15:31 +08:00
parent 0107d51a7d
commit e59cb7911c
5 changed files with 31 additions and 30 deletions

View File

@@ -7,14 +7,6 @@ dbconn_announce();
// BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
block_browser();
$cacheKey = md5($_SERVER["QUERY_STRING"]);
$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey);
if ($cacheData) {
do_log("[SCRAPE_FROM_CACHE]: " . $_SERVER["QUERY_STRING"]);
benc_resp($cacheData);
exit(0);
}
preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_array);
$fields = "info_hash, times_completed, seeders, leechers";
@@ -26,6 +18,14 @@ else {
$query = "SELECT $fields FROM torrents WHERE " . hash_where_arr('info_hash', $info_hash_array[1]);
}
$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);
}
$res = sql_query($query);
if (mysql_num_rows($res) < 1){