mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Minor improvements (#975)
This commit is contained in:
parent
10468263cd
commit
3f98d7680b
2 changed files with 17 additions and 22 deletions
|
@ -328,7 +328,7 @@ foreach ($profile_fields as $field => $can_edit) {
|
||||||
'user_viewemail' => $reg_mode ? false : (IS_ADMIN || $bb_cfg['show_email_visibility_settings']),
|
'user_viewemail' => $reg_mode ? false : (IS_ADMIN || $bb_cfg['show_email_visibility_settings']),
|
||||||
'user_viewonline' => $reg_mode ? false : true,
|
'user_viewonline' => $reg_mode ? false : true,
|
||||||
'user_notify' => $reg_mode ? true : true,
|
'user_notify' => $reg_mode ? true : true,
|
||||||
'user_notify_pm' => $reg_mode ? true : true,
|
'user_notify_pm' => $reg_mode ? true : $bb_cfg['pm_notify_enabled'],
|
||||||
'user_porn_forums' => $reg_mode ? false : true,
|
'user_porn_forums' => $reg_mode ? false : true,
|
||||||
'user_dls' => $reg_mode ? false : true,
|
'user_dls' => $reg_mode ? false : true,
|
||||||
'user_callseed' => $reg_mode ? true : true,
|
'user_callseed' => $reg_mode ? true : true,
|
||||||
|
|
|
@ -293,19 +293,19 @@ class Torrent
|
||||||
$v2_hash = null;
|
$v2_hash = null;
|
||||||
|
|
||||||
if ($torrent['extension'] !== TORRENT_EXT) {
|
if ($torrent['extension'] !== TORRENT_EXT) {
|
||||||
return self::torrent_error_exit($lang['NOT_TORRENT']);
|
self::torrent_error_exit($lang['NOT_TORRENT']);
|
||||||
}
|
}
|
||||||
if (!$torrent['allow_reg_tracker']) {
|
if (!$torrent['allow_reg_tracker']) {
|
||||||
return self::torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
|
self::torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
|
||||||
}
|
}
|
||||||
if ($post_id != $torrent['topic_first_post_id']) {
|
if ($post_id != $torrent['topic_first_post_id']) {
|
||||||
return self::torrent_error_exit($lang['ALLOWED_ONLY_1ST_POST_REG']);
|
self::torrent_error_exit($lang['ALLOWED_ONLY_1ST_POST_REG']);
|
||||||
}
|
}
|
||||||
if ($torrent['tracker_status']) {
|
if ($torrent['tracker_status']) {
|
||||||
return self::torrent_error_exit($lang['ALREADY_REG']);
|
self::torrent_error_exit($lang['ALREADY_REG']);
|
||||||
}
|
}
|
||||||
if ($this_topic_torrents = self::get_registered_torrents($topic_id, 'topic')) {
|
if ($this_topic_torrents = self::get_registered_torrents($topic_id, 'topic')) {
|
||||||
return self::torrent_error_exit($lang['ONLY_1_TOR_PER_TOPIC']);
|
self::torrent_error_exit($lang['ONLY_1_TOR_PER_TOPIC']);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::torrent_auth_check($forum_id, $torrent['poster_id']);
|
self::torrent_auth_check($forum_id, $torrent['poster_id']);
|
||||||
|
@ -313,14 +313,11 @@ class Torrent
|
||||||
$filename = get_attachments_dir() . '/' . $torrent['physical_filename'];
|
$filename = get_attachments_dir() . '/' . $torrent['physical_filename'];
|
||||||
$file_contents = file_get_contents($filename);
|
$file_contents = file_get_contents($filename);
|
||||||
|
|
||||||
if (!is_file($filename)) {
|
if (!is_file($filename) || !file_exists($filename)) {
|
||||||
return self::torrent_error_exit('File name error');
|
self::torrent_error_exit($lang['ERROR_NO_ATTACHMENT']);
|
||||||
}
|
|
||||||
if (!file_exists($filename)) {
|
|
||||||
return self::torrent_error_exit('File not exists');
|
|
||||||
}
|
}
|
||||||
if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents)) {
|
if (!$tor = \Arokettu\Bencode\Bencode::decode($file_contents)) {
|
||||||
return self::torrent_error_exit('This is not a bencoded file');
|
self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bb_cfg['bt_disable_dht']) {
|
if ($bb_cfg['bt_disable_dht']) {
|
||||||
|
@ -338,14 +335,14 @@ class Torrent
|
||||||
|
|
||||||
if (!$ann || !\in_array($ann, $announce_urls)) {
|
if (!$ann || !\in_array($ann, $announce_urls)) {
|
||||||
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
|
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
|
||||||
return self::torrent_error_exit($msg);
|
self::torrent_error_exit($msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = isset($tor['info']) ? $tor['info'] : [];
|
$info = isset($tor['info']) ? $tor['info'] : [];
|
||||||
|
|
||||||
if (!isset($info['name'], $info['piece length'])) {
|
if (!isset($info['name'], $info['piece length'])) {
|
||||||
return self::torrent_error_exit($lang['TORFILE_INVALID']);
|
self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if torrent contains info_hash v2 or v1
|
// Check if torrent contains info_hash v2 or v1
|
||||||
|
@ -357,7 +354,7 @@ class Torrent
|
||||||
$bt_v1 = true;
|
$bt_v1 = true;
|
||||||
}
|
}
|
||||||
if ($bb_cfg['tracker']['disabled_v2_torrents'] && $bt_v2 && !$bt_v1) {
|
if ($bb_cfg['tracker']['disabled_v2_torrents'] && $bt_v2 && !$bt_v1) {
|
||||||
return self::torrent_error_exit('v2-only torrents were disabled, allowed: v1 and hybrids');
|
self::torrent_error_exit('v2-only torrents were disabled, allowed: v1 and hybrids');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting info_hash v1
|
// Getting info_hash v1
|
||||||
|
@ -414,7 +411,7 @@ class Torrent
|
||||||
|
|
||||||
$totallen = (float)$fileTreeSize($info['file tree']);
|
$totallen = (float)$fileTreeSize($info['file tree']);
|
||||||
} else {
|
} else {
|
||||||
return self::torrent_error_exit($lang['TORFILE_INVALID']);
|
self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$size = sprintf('%.0f', (float)$totallen);
|
$size = sprintf('%.0f', (float)$totallen);
|
||||||
|
@ -430,7 +427,7 @@ class Torrent
|
||||||
if ($sql_error['code'] == 1062) {
|
if ($sql_error['code'] == 1062) {
|
||||||
// Duplicate entry
|
// Duplicate entry
|
||||||
|
|
||||||
return self::torrent_error_exit($lang['BT_REG_FAIL_SAME_HASH']);
|
self::torrent_error_exit($lang['BT_REG_FAIL_SAME_HASH']);
|
||||||
}
|
}
|
||||||
bb_die('Could not register torrent on tracker');
|
bb_die('Could not register torrent on tracker');
|
||||||
}
|
}
|
||||||
|
@ -591,7 +588,7 @@ class Torrent
|
||||||
// Send torrent
|
// Send torrent
|
||||||
$output = \Arokettu\Bencode\Bencode::encode($tor);
|
$output = \Arokettu\Bencode\Bencode::encode($tor);
|
||||||
|
|
||||||
$dl_fname = wbr($topic_title) . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.torrent';
|
$dl_fname = wbr($topic_title) . ' [' . $bb_cfg['server_name'] . '-' . $topic_id . ']' . '.torrent';
|
||||||
|
|
||||||
if (!empty($_COOKIE['explain'])) {
|
if (!empty($_COOKIE['explain'])) {
|
||||||
$out = "attach path: $filename<br /><br />";
|
$out = "attach path: $filename<br /><br />";
|
||||||
|
@ -700,9 +697,9 @@ class Torrent
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function torrent_error_exit($message)
|
private static function torrent_error_exit(string $message): void
|
||||||
{
|
{
|
||||||
global $reg_mode, $return_message, $lang;
|
global $reg_mode, $return_message, $lang;
|
||||||
|
|
||||||
|
@ -716,8 +713,6 @@ class Torrent
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_die($msg . $message);
|
bb_die($msg . $message);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue