mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Minor improvements (#1633)
* Minor improvements * Update CHANGELOG.md * Update filelist.php * Update ffprobe_info.php * Updated * Update announce.php * Update announce.php * Update ffprobe_info.php * Updated * Update ffprobe_info.php * Update ffprobe_info.php * Updated * Update common.php * Update common.php * Revert "Update common.php" This reverts commit3793263ff0
. * Revert "Update common.php" This reverts commit3911e72dba
. * Update common.php * Updated * Update playback_m3u.tpl * Update ffprobe_info.php * Update playback_m3u.php * Update dl.php * Update dl.php * Updated * Update dl.php * Update playback_m3u.php * Revert "Update playback_m3u.php" This reverts commit8cf6e9a041
. * Revert "Update dl.php" This reverts commit7c11cc385b
. * Revert "Updated" This reverts commit9c004f0651
. * Revert "Update dl.php" This reverts commit26d5feffa5
. * Revert "Update dl.php" This reverts commit261f8d3e62
. * Update playback_m3u.php * Updated * Update dl.php * Update dl.php * Update CHANGELOG.md
This commit is contained in:
parent
f5a9490dfe
commit
001c210217
16 changed files with 80 additions and 51 deletions
|
@ -18,8 +18,8 @@
|
|||
- Fixed template caching issue [\#1622](https://github.com/torrentpier/torrentpier/pull/1622) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Fixed `md5()` deprecated in PHP 8.4 [\#1561](https://github.com/torrentpier/torrentpier/pull/1561) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Increased `USEREMAIL_MAX_LENGTH` [\#1566](https://github.com/torrentpier/torrentpier/pull/1566) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Minor improvements [\#1570](https://github.com/torrentpier/torrentpier/pull/1570), [\#1571](https://github.com/torrentpier/torrentpier/pull/1571), [\#1575](https://github.com/torrentpier/torrentpier/pull/1575), [\#1589](https://github.com/torrentpier/torrentpier/pull/1589), [\#1592](https://github.com/torrentpier/torrentpier/pull/1592), [\#1605](https://github.com/torrentpier/torrentpier/pull/1605), [\#1611](https://github.com/torrentpier/torrentpier/pull/1611), [\#1612](https://github.com/torrentpier/torrentpier/pull/1612), [\#1615](https://github.com/torrentpier/torrentpier/pull/1615), [\#1627](https://github.com/torrentpier/torrentpier/pull/1627) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Updated deps [\#1563](https://github.com/torrentpier/torrentpier/pull/1563), [\#1564](https://github.com/torrentpier/torrentpier/pull/1564), [\#1608](https://github.com/torrentpier/torrentpier/pull/1608), [\#1609](https://github.com/torrentpier/torrentpier/pull/1609), [\#1610](https://github.com/torrentpier/torrentpier/pull/1610) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Minor improvements [\#1570](https://github.com/torrentpier/torrentpier/pull/1570), [\#1571](https://github.com/torrentpier/torrentpier/pull/1571), [\#1575](https://github.com/torrentpier/torrentpier/pull/1575), [\#1589](https://github.com/torrentpier/torrentpier/pull/1589), [\#1592](https://github.com/torrentpier/torrentpier/pull/1592), [\#1605](https://github.com/torrentpier/torrentpier/pull/1605), [\#1611](https://github.com/torrentpier/torrentpier/pull/1611), [\#1612](https://github.com/torrentpier/torrentpier/pull/1612), [\#1615](https://github.com/torrentpier/torrentpier/pull/1615), [\#1627](https://github.com/torrentpier/torrentpier/pull/1627), [\#1633](https://github.com/torrentpier/torrentpier/pull/1633) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Updated deps [\#1563](https://github.com/torrentpier/torrentpier/pull/1563), [\#1564](https://github.com/torrentpier/torrentpier/pull/1564), [\#1608](https://github.com/torrentpier/torrentpier/pull/1608), [\#1609](https://github.com/torrentpier/torrentpier/pull/1609), [\#1610](https://github.com/torrentpier/torrentpier/pull/1610), [\#1637](https://github.com/torrentpier/torrentpier/pull/1637) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- New Crowdin updates [\#1569](https://github.com/torrentpier/torrentpier/pull/1569), [\#1572](https://github.com/torrentpier/torrentpier/pull/1572), [\#1573](https://github.com/torrentpier/torrentpier/pull/1573), [\#1574](https://github.com/torrentpier/torrentpier/pull/1574), [\#1588](https://github.com/torrentpier/torrentpier/pull/1588), [\#1590](https://github.com/torrentpier/torrentpier/pull/1590), [\#1600](https://github.com/torrentpier/torrentpier/pull/1600), [\#1601](https://github.com/torrentpier/torrentpier/pull/1601), [\#1606](https://github.com/torrentpier/torrentpier/pull/1606), [\#1607](https://github.com/torrentpier/torrentpier/pull/1607), [\#1625](https://github.com/torrentpier/torrentpier/pull/1625), [\#1626](https://github.com/torrentpier/torrentpier/pull/1626), [\#1629](https://github.com/torrentpier/torrentpier/pull/1629), [\#1630](https://github.com/torrentpier/torrentpier/pull/1630), [\#1631](https://github.com/torrentpier/torrentpier/pull/1631), [\#1632](https://github.com/torrentpier/torrentpier/pull/1632) ([Exileum](https://github.com/Exileum))
|
||||
|
||||
## [v2.4.4](https://github.com/torrentpier/torrentpier/tree/v2.4.4) (2024-07-22)
|
||||
|
|
|
@ -865,7 +865,7 @@ function get_list($mode, $id, $select)
|
|||
if ($row[$idfield] == $id) {
|
||||
$s = ' selected';
|
||||
}
|
||||
$catlist .= '<option value="' . $row[$idfield] . '"' . $s . '> ' . htmlCHR(str_short($row[$namefield], 60)) . '</option>\n';
|
||||
$catlist .= '<option value="' . $row[$idfield] . '"' . $s . '> ' . str_short(htmlCHR($row[$namefield]), 60) . '</option>\n';
|
||||
}
|
||||
|
||||
return $catlist;
|
||||
|
@ -1102,7 +1102,7 @@ function sf_get_list($mode, $exclude = 0, $select = 0)
|
|||
$selected = ($fid == $select) ? HTML_SELECTED : '';
|
||||
$disabled = ($fid == $exclude && !$forum_parent) ? HTML_DISABLED : '';
|
||||
$style = $disabled ? ' style="color: gray" ' : (($fid == $exclude) ? ' style="color: darkred" ' : '');
|
||||
$opt .= '<option value="' . $fid . '" ' . $selected . $disabled . $style . '>' . ($f['forum_parent'] ? HTML_SF_SPACER : '') . htmlCHR(str_short($f['forum_name'], 60)) . " </option>\n";
|
||||
$opt .= '<option value="' . $fid . '" ' . $selected . $disabled . $style . '>' . ($f['forum_parent'] ? HTML_SF_SPACER : '') . str_short(htmlCHR($f['forum_name']), 60) . " </option>\n";
|
||||
}
|
||||
|
||||
$opt .= '</optgroup>';
|
||||
|
|
|
@ -214,10 +214,9 @@ if ($lp_info) {
|
|||
|
||||
// Check hybrid status
|
||||
if (!empty($row['info_hash']) && !empty($row['info_hash_v2'])) {
|
||||
$stat_protocol = match ($bb_cfg['tracker']['hybrid_stat_protocol']) {
|
||||
1 => $row['info_hash'],
|
||||
$stat_protocol = match ((int)$bb_cfg['tracker']['hybrid_stat_protocol']) {
|
||||
2 => substr($row['info_hash_v2'], 0, 20),
|
||||
default => $row['info_hash']
|
||||
default => $row['info_hash'] // 1
|
||||
};
|
||||
if ($info_hash !== $stat_protocol) {
|
||||
$hybrid_unrecord = true; // This allows us to announce only for one info-hash
|
||||
|
|
|
@ -244,7 +244,7 @@ function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTE
|
|||
*/
|
||||
function str_compact($str)
|
||||
{
|
||||
return preg_replace('#\s+#u', ' ', trim($str ?? ''));
|
||||
return preg_replace('/\s\s+/', ' ', trim($str ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
14
dl.php
14
dl.php
|
@ -20,6 +20,7 @@ $datastore->enqueue([
|
|||
|
||||
$download_id = request_var('id', 0);
|
||||
$thumbnail = request_var('thumb', 0);
|
||||
$m3u = isset($_GET['m3u']) && $_GET['m3u'];
|
||||
|
||||
// Send file to browser
|
||||
function send_file_to_browser($attachment, $upload_dir)
|
||||
|
@ -100,9 +101,18 @@ if (!($attachment = DB()->sql_fetchrow($result))) {
|
|||
|
||||
$attachment['physical_filename'] = basename($attachment['physical_filename']);
|
||||
|
||||
// Re-define $attachment['physical_filename'] for thumbnails
|
||||
if ($thumbnail) {
|
||||
// Re-define $attachment['physical_filename'] for thumbnails
|
||||
$attachment['physical_filename'] = THUMB_DIR . '/t_' . $attachment['physical_filename'];
|
||||
} elseif ($m3u) {
|
||||
// Check m3u file exist
|
||||
if (!$m3uFile = (new \TorrentPier\TorrServerAPI())->getM3UPath($download_id)) {
|
||||
bb_die($lang['ERROR_NO_ATTACHMENT']);
|
||||
}
|
||||
|
||||
$attachment['physical_filename'] = $attachment['real_filename'] = basename($m3uFile);
|
||||
$attachment['mimetype'] = mime_content_type($m3uFile);
|
||||
$attachment['extension'] = str_replace('.', '', \TorrentPier\TorrServerAPI::M3U['extension']);
|
||||
}
|
||||
|
||||
DB()->sql_freeresult($result);
|
||||
|
@ -194,7 +204,7 @@ if (isset($download_mode[$attachment['extension']])) {
|
|||
}
|
||||
|
||||
// Update download count
|
||||
if (!$thumbnail && is_file(realpath($upload_dir . '/' . $attachment['physical_filename']))) {
|
||||
if (!$m3u && !$thumbnail && is_file(realpath($upload_dir . '/' . $attachment['physical_filename']))) {
|
||||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int)$attachment['attach_id'];
|
||||
|
||||
if (!DB()->sql_query($sql)) {
|
||||
|
|
|
@ -92,14 +92,14 @@ foreach ($files as $file) {
|
|||
]);
|
||||
}
|
||||
|
||||
$torrent_name = !empty($t_name = $torrent->getName()) ? htmlCHR(str_short($t_name, 200)) : $lang['UNKNOWN'];
|
||||
$torrent_name = !empty($t_name = $torrent->getName()) ? str_short(htmlCHR($t_name), 200) : $lang['UNKNOWN'];
|
||||
$torrent_size = humn_size($row['size'], 2);
|
||||
|
||||
$template->assign_vars([
|
||||
'PAGE_TITLE' => "$torrent_name (" . $torrent_size . ")",
|
||||
'FILES_COUNT' => sprintf($lang['BT_FLIST_FILE_PATH'], declension(iterator_count($files), 'files')),
|
||||
'TORRENT_CREATION_DATE' => (!empty($dt = $torrent->getCreationDate()) && is_numeric($creation_date = $dt->getTimestamp())) ? date('d-M-Y H:i (e)', $creation_date) : $lang['UNKNOWN'],
|
||||
'TORRENT_CLIENT' => !empty($creator = $torrent->getCreatedBy()) ? htmlCHR(str_short($creator, 20)) : $lang['UNKNOWN'],
|
||||
'TORRENT_CLIENT' => !empty($creator = $torrent->getCreatedBy()) ? htmlCHR($creator) : $lang['UNKNOWN'],
|
||||
|
||||
'BTMR_NOTICE' => sprintf($lang['BT_FLIST_BTMR_NOTICE'], 'https://github.com/kovalensky/tmrr'),
|
||||
'U_TOPIC' => TOPIC_URL . $topic_id,
|
||||
|
|
|
@ -103,7 +103,7 @@ if (!$group_id) {
|
|||
|
||||
$options = '';
|
||||
foreach ($params as $name => $data) {
|
||||
$text = htmlCHR(str_short(rtrim($name), HTML_SELECT_MAX_LENGTH));
|
||||
$text = str_short(rtrim(htmlCHR($name)), HTML_SELECT_MAX_LENGTH);
|
||||
|
||||
$members = ($data['m']) ? $lang['MEMBERS_IN_GROUP'] . ': ' . $data['m'] : $lang['NO_GROUP_MEMBERS'];
|
||||
$candidates = ($data['c']) ? $lang['PENDING_MEMBERS'] . ': ' . $data['c'] : $lang['NO_PENDING_GROUP_MEMBERS'];
|
||||
|
|
|
@ -715,6 +715,7 @@ VALUES ('1', 'gif', ''),
|
|||
('3', 'cpp', ''),
|
||||
('3', 'hpp', ''),
|
||||
('3', 'diz', ''),
|
||||
('3', 'm3u', ''),
|
||||
('4', 'xls', ''),
|
||||
('4', 'doc', ''),
|
||||
('4', 'dot', ''),
|
||||
|
|
|
@ -17,11 +17,13 @@ if (!$bb_cfg['torr_server']['enabled']) {
|
|||
$this->ajax_die($lang['MODULE_OFF']);
|
||||
}
|
||||
|
||||
if (!$attach_id = (int)$this->request['attach_id'] or !is_numeric($attach_id)) {
|
||||
$attach_id = $this->request['attach_id'] ?? '';
|
||||
if (empty($attach_id) || !is_numeric($attach_id)) {
|
||||
$this->ajax_die($lang['INVALID_ATTACH_ID']);
|
||||
}
|
||||
|
||||
if (!$file_index = (int)$this->request['file_index'] or !is_numeric($file_index)) {
|
||||
$file_index = $this->request['file_index'] ?? '';
|
||||
if (empty($file_index) || !is_numeric($file_index)) {
|
||||
$this->ajax_die("Invalid file index: $file_index");
|
||||
}
|
||||
|
||||
|
@ -61,11 +63,11 @@ if (isset($ffpInfo->streams)) {
|
|||
if (!empty($stream->codec_name)) {
|
||||
$result .= sprintf($lang['AUDIO_CODEC'], $stream->codec_long_name, mb_strtoupper($stream->codec_name, 'UTF-8')) . '<br>';
|
||||
}
|
||||
if (!empty($stream->bit_rate)) {
|
||||
if (!empty($stream->bit_rate) && is_int($stream->bit_rate)) {
|
||||
$result .= sprintf($lang['BITRATE'], humn_bitrate($stream->bit_rate)) . '<br>';
|
||||
}
|
||||
if (!empty($stream->sample_rate)) {
|
||||
$result .= sprintf($lang['SAMPLE_RATE'], $stream->sample_rate) . '<br>';
|
||||
if (!empty($stream->sample_rate) && is_int($stream->sample_rate)) {
|
||||
$result .= sprintf($lang['SAMPLE_RATE'], humn_sample_rate($stream->sample_rate)) . '<br>';
|
||||
}
|
||||
if (!empty($stream->channels)) {
|
||||
$result .= sprintf($lang['CHANNELS'], $stream->channels) . '<br>';
|
||||
|
@ -103,4 +105,39 @@ if (isset($ffpInfo->streams)) {
|
|||
$this->response['ffprobe_data'] = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitrate to human-readable format
|
||||
*
|
||||
* @param int $bitrate
|
||||
* @param string $space
|
||||
* @return string
|
||||
*/
|
||||
function humn_bitrate(int $bitrate, string $space = ' '): string
|
||||
{
|
||||
if ($bitrate >= 1000000) {
|
||||
$unit = 'Mbps';
|
||||
$bitrate /= 1000000;
|
||||
} elseif ($bitrate >= 1000) {
|
||||
$unit = 'kbps';
|
||||
$bitrate /= 1000;
|
||||
} else {
|
||||
$unit = 'bps';
|
||||
}
|
||||
|
||||
return sprintf('%d', commify($bitrate)) . $space . $unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample rate to human-readable format
|
||||
*
|
||||
* @param int $sample_rate
|
||||
* @param string $space
|
||||
* @return string
|
||||
*/
|
||||
function humn_sample_rate(int $sample_rate, string $space = ' '): string
|
||||
{
|
||||
$unit = '';
|
||||
return sprintf('%.1f', commify($sample_rate)) . $space . $unit;
|
||||
}
|
||||
|
||||
$this->response['file_index'] = $file_index;
|
||||
|
|
|
@ -595,29 +595,6 @@ function humn_size($size, $rounder = null, $min = null, $space = ' ')
|
|||
return round($size, $rounder) . $space . $ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitrate to human-readable format
|
||||
*
|
||||
* @param int $bitrate
|
||||
* @param string $space
|
||||
* @return string
|
||||
*/
|
||||
function humn_bitrate(int $bitrate, string $space = ' '): string
|
||||
{
|
||||
if ($bitrate >= 1000000) {
|
||||
$unit = 'Mbps';
|
||||
$bitrate /= 1000000;
|
||||
} elseif ($bitrate >= 1000) {
|
||||
$unit = 'kbps';
|
||||
$bitrate /= 1000;
|
||||
} else {
|
||||
$unit = 'bps';
|
||||
}
|
||||
|
||||
$formattedBitrate = number_format($bitrate, 2);
|
||||
return $formattedBitrate . $space . $unit;
|
||||
}
|
||||
|
||||
function bt_show_ip($ip, $port = '')
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
|
|
@ -42,6 +42,10 @@ if (!defined('BB_ROOT')) {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sqlLogRow:hover {
|
||||
border-color: #8B0000;
|
||||
}
|
||||
|
||||
.sqlLogWrapped {
|
||||
white-space: normal;
|
||||
overflow: visible;
|
||||
|
@ -53,10 +57,6 @@ if (!defined('BB_ROOT')) {
|
|||
cursor: inherit !important;
|
||||
}
|
||||
|
||||
.sqlHover {
|
||||
border-color: #8B0000;
|
||||
}
|
||||
|
||||
.sqlHighlight {
|
||||
background: #FFE4E1;
|
||||
}
|
||||
|
|
|
@ -1286,6 +1286,7 @@ $lang['DOWNLOAD_M3U_FILE'] = 'Download .m3u file';
|
|||
$lang['PLAYBACK_M3U'] = 'Playback .m3u file';
|
||||
$lang['COPY_STREAM_LINK'] = 'Copy stream link to clipboard';
|
||||
$lang['M3U_NOT_SUPPORTED'] = 'This file cannot be played in the browser...';
|
||||
$lang['M3U_FFPROBE_NO_DATA'] = 'It seems ffprobe will not be able to return data about this codec...';
|
||||
$lang['M3U_NOTICE'] = 'Some browsers do not support playback of certain video formats. In such a case, you can download the .m3u file and play it using a third-party player';
|
||||
|
||||
$lang['ATTACHMENT'] = 'Attachments';
|
||||
|
|
|
@ -91,7 +91,7 @@ foreach ($m3uData as $entry) {
|
|||
'IS_VALID' => in_array($getExtension, array_merge($validFormats['audio'], $validFormats['video'])),
|
||||
'IS_AUDIO' => in_array($getExtension, $validFormats['audio']),
|
||||
'STREAM_LINK' => $streamLink,
|
||||
'M3U_DL_LINK' => $m3uFile,
|
||||
'M3U_DL_LINK' => DL_URL . $row['attach_id'] . '&m3u=1',
|
||||
'TITLE' => $title,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ class Dev
|
|||
$perc = '[' . round($dbg['time'] * 100 / $db_obj->sql_timetotal) . '%]';
|
||||
$info = !empty($dbg['info']) ? $dbg['info'] . ' [' . $dbg['src'] . ']' : $dbg['src'];
|
||||
|
||||
$log .= '<div onmouseout="$(this).removeClass(\'sqlHover\');" onmouseover="$(this).addClass(\'sqlHover\');" onclick="$(this).toggleClass(\'sqlHighlight\');" class="sqlLogRow" title="' . $info . '">'
|
||||
$log .= '<div onclick="$(this).toggleClass(\'sqlHighlight\');" class="sqlLogRow" title="' . $info . '">'
|
||||
. '<span style="letter-spacing: -1px;">' . $time . ' </span>'
|
||||
. '<span class="copyElement" data-clipboard-target="#' . $id . '" title="Copy to clipboard" style="color: rgb(128,128,128); letter-spacing: -1px;">' . $perc . '</span> '
|
||||
. '<span style="letter-spacing: 0;" id="' . $id . '">' . $sql . '</span>'
|
||||
|
|
|
@ -70,7 +70,7 @@ class Html
|
|||
if (\is_array($opt_val)) {
|
||||
$this->cur_attr =& $this->cur_attr[$opt_name];
|
||||
|
||||
$label = htmlCHR(str_short($opt_name, $this->max_length));
|
||||
$label = str_short(htmlCHR($opt_name), $this->max_length);
|
||||
|
||||
$this->options .= "\t<optgroup label=\" " . $label . "\">\n";
|
||||
$this->_build_select_rec($opt_val);
|
||||
|
@ -78,7 +78,7 @@ class Html
|
|||
|
||||
$this->cur_attr =& $this->attr;
|
||||
} else {
|
||||
$text = htmlCHR(str_short($opt_name, $this->max_length));
|
||||
$text = str_short(htmlCHR($opt_name), $this->max_length);
|
||||
$value = ' value="' . htmlCHR($opt_val) . '"';
|
||||
|
||||
$class = isset($this->cur_attr[$opt_name]['class']) ? ' class="' . $this->cur_attr[$opt_name]['class'] . '"' : '';
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
if (data.ffprobe_data) {
|
||||
$('#ffprobe_' + data.file_index).html(data.ffprobe_data);
|
||||
} else {
|
||||
$('#ffprobe_' + data.file_index).append('<hr><span class="warnColor2">{L_PLEASE_TRY_AGAIN}</span>');
|
||||
if ($('#ffprobe_' + data.file_index).find('span.warnColor2').length >= 3) {
|
||||
$('#ffprobe_' + data.file_index).html('<hr><span class="warnColor2">{L_M3U_FFPROBE_NO_DATA}</span>');
|
||||
} else {
|
||||
$('#ffprobe_' + data.file_index).append('<hr><span class="warnColor2">{L_PLEASE_TRY_AGAIN}</span>');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -35,7 +39,7 @@
|
|||
<td width="40%"><b>{m3ulist.TITLE}</b>
|
||||
<div id="ffprobe_{m3ulist.FILE_INDEX}">
|
||||
<hr>
|
||||
<a href="#" onclick="ajax.ffprobe_info({m3ulist.FILE_INDEX}, '{m3ulist.IS_AUDIO}'); return false;">{L_SHOW_MORE_INFORMATION_FILE}</a>
|
||||
<input onclick="ajax.ffprobe_info({m3ulist.FILE_INDEX}, '{m3ulist.IS_AUDIO}');" type="button" value="{L_SHOW_MORE_INFORMATION_FILE}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue