mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Some enhancements for dl.php (#1209)
* Some enhancements for dl.php * Update CHANGELOG.md
This commit is contained in:
parent
101c8db18f
commit
58e6537f03
2 changed files with 38 additions and 29 deletions
|
@ -10,6 +10,7 @@
|
||||||
- Updated TorrentPier footer text (: [\#1204](https://github.com/torrentpier/torrentpier/pull/1204) ([kovalensky](https://github.com/kovalensky))
|
- Updated TorrentPier footer text (: [\#1204](https://github.com/torrentpier/torrentpier/pull/1204) ([kovalensky](https://github.com/kovalensky))
|
||||||
- Repository link in page footer instead of forum [\#1205](https://github.com/torrentpier/torrentpier/pull/1205) ([kovalensky](https://github.com/kovalensky))
|
- Repository link in page footer instead of forum [\#1205](https://github.com/torrentpier/torrentpier/pull/1205) ([kovalensky](https://github.com/kovalensky))
|
||||||
- Minor improvements [\#1206](https://github.com/torrentpier/torrentpier/pull/1206) ([belomaxorka](https://github.com/belomaxorka))
|
- Minor improvements [\#1206](https://github.com/torrentpier/torrentpier/pull/1206) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
- Some enhancements for dl.php [\#1209](https://github.com/torrentpier/torrentpier/pull/1209) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
|
||||||
## [v2.4.0-rc2](https://github.com/torrentpier/torrentpier/tree/v2.4.0-rc2) (2023-12-12)
|
## [v2.4.0-rc2](https://github.com/torrentpier/torrentpier/tree/v2.4.0-rc2) (2023-12-12)
|
||||||
[Full Changelog](https://github.com/torrentpier/torrentpier/compare/v2.4.0-rc1...v2.4.0-rc2)
|
[Full Changelog](https://github.com/torrentpier/torrentpier/compare/v2.4.0-rc1...v2.4.0-rc2)
|
||||||
|
|
30
dl.php
30
dl.php
|
@ -99,6 +99,11 @@ if (!($attachment = DB()->sql_fetchrow($result))) {
|
||||||
|
|
||||||
$attachment['physical_filename'] = basename($attachment['physical_filename']);
|
$attachment['physical_filename'] = basename($attachment['physical_filename']);
|
||||||
|
|
||||||
|
// Re-define $attachment['physical_filename'] for thumbnails
|
||||||
|
if ($thumbnail) {
|
||||||
|
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
|
||||||
|
}
|
||||||
|
|
||||||
DB()->sql_freeresult($result);
|
DB()->sql_freeresult($result);
|
||||||
|
|
||||||
// get forum_id for attachment authorization or private message authorization
|
// get forum_id for attachment authorization or private message authorization
|
||||||
|
@ -137,6 +142,7 @@ for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check the auth rights
|
||||||
if (!$authorised) {
|
if (!$authorised) {
|
||||||
bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
|
bb_die($lang['SORRY_AUTH_VIEW_ATTACH']);
|
||||||
}
|
}
|
||||||
|
@ -176,10 +182,9 @@ if (!in_array($attachment['extension'], $allowed_extensions)) {
|
||||||
bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) . '<br /><br />' . $lang['FILENAME'] . ": " . $attachment['physical_filename']);
|
bb_die(sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) . '<br /><br />' . $lang['FILENAME'] . ": " . $attachment['physical_filename']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$download_mode = (int)$download_mode[$attachment['extension']];
|
// Getting download mode by extension
|
||||||
|
if (!$download_mode = (int)$download_mode[$attachment['extension']]) {
|
||||||
if ($thumbnail) {
|
bb_die('Incorrect download mode');
|
||||||
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update download count
|
// Update download count
|
||||||
|
@ -192,13 +197,13 @@ if (!$thumbnail) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the 'presenting'-method
|
// Determine the 'presenting'-method
|
||||||
if ($download_mode == PHYSICAL_LINK) {
|
switch ($download_mode) {
|
||||||
|
case PHYSICAL_LINK:
|
||||||
$url = make_url($upload_dir . '/' . $attachment['physical_filename']);
|
$url = make_url($upload_dir . '/' . $attachment['physical_filename']);
|
||||||
header('Location: ' . $url);
|
header('Location: ' . $url);
|
||||||
exit;
|
exit;
|
||||||
}
|
case INLINE_LINK:
|
||||||
|
if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) {
|
||||||
if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) {
|
|
||||||
global $template;
|
global $template;
|
||||||
|
|
||||||
$redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/';
|
$redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/';
|
||||||
|
@ -214,7 +219,10 @@ if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) {
|
||||||
|
|
||||||
require(PAGE_HEADER);
|
require(PAGE_HEADER);
|
||||||
require(PAGE_FOOTER);
|
require(PAGE_FOOTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
send_file_to_browser($attachment, $upload_dir);
|
send_file_to_browser($attachment, $upload_dir);
|
||||||
exit;
|
exit;
|
||||||
|
default:
|
||||||
|
bb_die('Incorrect download mode: ' . $download_mode);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue