Use hardcoded dictionary names for better counting result in file listing (#1247)

Thanks to @arokettu for pointing this out.
This commit is contained in:
Cønstantine Kovalensky 2023-12-21 20:26:09 +04:00 committed by GitHub
commit 573c772798
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,9 +50,9 @@ if (!is_file($file_path)) {
$file_contents = file_get_contents($file_path); $file_contents = file_get_contents($file_path);
if ($bb_cfg['flist_max_files']) { if ($bb_cfg['flist_max_files']) {
$filetree_pos = strpos($file_contents, ':file tree'); $filetree_pos = strpos($file_contents, '9:file tree');
$files_pos = !empty($row['info_hash']) ? strpos($file_contents, ':files', $filetree_pos) : false; $files_pos = !empty($row['info_hash']) ? strpos($file_contents, '5:files', $filetree_pos) : false;
$file_count = substr_count($file_contents, ':length', $filetree_pos, ($files_pos ? ($files_pos - $filetree_pos) : null)); $file_count = substr_count($file_contents, '6:length', $filetree_pos, ($files_pos ? ($files_pos - $filetree_pos) : null));
if ($file_count > $bb_cfg['flist_max_files']) { if ($file_count > $bb_cfg['flist_max_files']) {
http_response_code(410); http_response_code(410);