mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Announcer's code re-formatting (#1112)
This commit is contained in:
parent
a77b32e2ab
commit
61ef24539a
2 changed files with 10 additions and 1 deletions
|
@ -30,11 +30,13 @@ if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
|
|||
if (strpos($_SERVER['REQUEST_URI'], 'scrape') !== false) {
|
||||
msg_die('Please disable SCRAPE!');
|
||||
}
|
||||
|
||||
if (!isset($_GET[$passkey_key]) || !is_string($_GET[$passkey_key])) {
|
||||
msg_die('Please LOG IN and RE-DOWNLOAD this torrent (passkey not found)');
|
||||
}
|
||||
|
||||
// Input var names
|
||||
|
||||
// String
|
||||
$input_vars_str = ['info_hash', 'peer_id', 'event', $passkey_key];
|
||||
// Numeric
|
||||
|
@ -45,10 +47,12 @@ $input_vars_num = ['port', 'uploaded', 'downloaded', 'left', 'numwant', 'compact
|
|||
foreach ($input_vars_str as $var_name) {
|
||||
$$var_name = isset($_GET[$var_name]) ? (string)$_GET[$var_name] : null;
|
||||
}
|
||||
|
||||
// Numeric
|
||||
foreach ($input_vars_num as $var_name) {
|
||||
$$var_name = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
|
||||
}
|
||||
|
||||
// Passkey
|
||||
$passkey = $$passkey_key ?? null;
|
||||
|
||||
|
@ -83,9 +87,11 @@ if (!isset($port) || $port < 0 || $port > 0xFFFF) {
|
|||
if (!isset($uploaded) || $uploaded < 0) {
|
||||
msg_die('Invalid uploaded value: ' . $uploaded);
|
||||
}
|
||||
|
||||
if (!isset($downloaded) || $downloaded < 0) {
|
||||
msg_die('Invalid downloaded value: ' . $downloaded);
|
||||
}
|
||||
|
||||
if (!isset($left) || $left < 0) {
|
||||
msg_die('Invalid left value: ' . $left);
|
||||
}
|
||||
|
@ -150,6 +156,7 @@ if ($lp_info && (!isset($event) || !$stopped)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get last peer info from DB
|
||||
if (!CACHE('tr_cache')->used && !$lp_info) {
|
||||
$lp_info = DB()->fetch_row("
|
||||
|
@ -339,7 +346,6 @@ if ((!$lp_info || !$peer_info_updated) && !$stopped && empty($hybrid_unrecord))
|
|||
DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
|
||||
}
|
||||
|
||||
|
||||
// Exit if stopped
|
||||
if ($stopped) {
|
||||
silent_exit('Cache will be reset within 30 seconds');
|
||||
|
@ -443,6 +449,7 @@ if (!$output) {
|
|||
if (!empty($peers)) {
|
||||
$output['peers'] = $peers;
|
||||
}
|
||||
|
||||
if (!empty($peers6)) {
|
||||
$output['peers6'] = $peers6;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ $info_hash = isset($_GET['info_hash']) ? (string)$_GET['info_hash'] : null;
|
|||
if (!isset($info_hash)) {
|
||||
msg_die('info_hash was not provided');
|
||||
}
|
||||
|
||||
// Store info hash in hex format
|
||||
$info_hash_hex = mb_check_encoding($info_hash, 'UTF8') ? $info_hash : bin2hex($info_hash);
|
||||
|
||||
|
@ -45,6 +46,7 @@ foreach ($info_hash_array[1] as $hash) {
|
|||
if (strlen($decoded_hash) !== 20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($scrape_cache = CACHE('tr_cache')->get(SCRAPE_LIST_PREFIX . bin2hex($decoded_hash))) {
|
||||
$torrents['files'][$info_key = array_key_first($scrape_cache)] = $scrape_cache[$info_key];
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue