mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-19 21:03:54 -07:00
RC2 timeline (#1186)
* Disallow downloading of frozen status attachments * Don't show info-hash, magnet link for frozen attachments * Direct torrent downloads & post html view in Atom feeds
This commit is contained in:
parent
68f402d8e7
commit
6911b6099b
6 changed files with 65 additions and 25 deletions
|
@ -83,7 +83,7 @@ if (!isset($info_hash)) {
|
|||
$info_hash_hex = bin2hex($info_hash);
|
||||
|
||||
// Store peer id
|
||||
$peer_id_sql = rtrim(DB()->escape(preg_replace('/[^a-zA-Z0-9\-\_\.]/', '', $peer_id)), ' ');
|
||||
$peer_id_sql = rtrim(DB()->escape(preg_replace('/[^a-zA-Z0-9\-\_]/', '', $peer_id)), ' ');
|
||||
|
||||
// Check info_hash length
|
||||
if (strlen($info_hash) !== 20) {
|
||||
|
@ -390,13 +390,12 @@ if (!$output) {
|
|||
// Retrieve peers
|
||||
$numwant = (int)$bb_cfg['tracker']['numwant'];
|
||||
$compact_mode = ($bb_cfg['tracker']['compact_mode'] || !empty($compact));
|
||||
$priority = $seeder ? 'seeder ASC, RAND()' : 'RAND()';
|
||||
|
||||
$rowset = DB()->fetch_rowset("
|
||||
SELECT ip, ipv6, port
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
WHERE topic_id = $topic_id
|
||||
ORDER BY $priority
|
||||
ORDER BY seeder ASC, RAND()
|
||||
LIMIT $numwant
|
||||
");
|
||||
|
||||
|
|
21
dl.php
21
dl.php
|
@ -143,9 +143,26 @@ if (!$authorised) {
|
|||
|
||||
$datastore->rm('cat_forums');
|
||||
|
||||
//
|
||||
|
||||
// Check tor status
|
||||
if (!IS_AM) {
|
||||
$sql = 'SELECT tor_status, poster_id FROM ' . BB_BT_TORRENTS . ' WHERE attach_id = ' . (int)$attachment['attach_id'];
|
||||
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
bb_die('Could not query tor_status information');
|
||||
}
|
||||
|
||||
$row = DB()->sql_fetchrow($result);
|
||||
|
||||
if (isset($bb_cfg['tor_frozen'][$row['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$row['tor_status']]) && $userdata['user_id'] === $row['poster_id'])) {
|
||||
bb_die($lang['TOR_STATUS_FORBIDDEN'] . $lang['TOR_STATUS_NAME'][$row['tor_status']]);
|
||||
}
|
||||
|
||||
DB()->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Get Information on currently allowed Extensions
|
||||
//
|
||||
|
||||
$rows = get_extension_informations();
|
||||
$num_rows = count($rows);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ if (!defined('BB_ROOT')) {
|
|||
}
|
||||
|
||||
// Server settings
|
||||
$reserved_name = 'torrentpier.com';
|
||||
$reserved_name = 'torrentpier.com'; // Use your domain name for auto-generated atom feeds
|
||||
$reserved_port = 80;
|
||||
|
||||
$bb_cfg = [];
|
||||
|
@ -629,6 +629,8 @@ $bb_cfg['captcha'] = [
|
|||
$bb_cfg['atom'] = [
|
||||
'path' => INT_DATA_DIR . '/atom', // without ending slash
|
||||
'url' => './internal_data/atom', // without ending slash
|
||||
'direct_down' => true, // Allow direct downloading of torrents from feeds
|
||||
'direct_view' => true, // Allow direct viewing of post texts in feeds
|
||||
];
|
||||
|
||||
// Nofollow
|
||||
|
|
|
@ -68,7 +68,7 @@ $lang['SHORT_PAGE'] = 'page';
|
|||
$lang['GOTO_PAGE'] = 'Go to page';
|
||||
$lang['GOTO_SHORT'] = 'Page';
|
||||
$lang['JOINED'] = 'Joined';
|
||||
$lang['LONGEVITY'] = 'Longevity';
|
||||
$lang['LONGEVITY'] = 'Registered';
|
||||
$lang['IP_ADDRESS'] = 'IP Address';
|
||||
$lang['POSTED_AFTER'] = 'after';
|
||||
|
||||
|
@ -1106,25 +1106,26 @@ $lang['TOR_STATUS'] = 'Status';
|
|||
$lang['TOR_STATUS_SELECT_ACTION'] = 'Select status';
|
||||
$lang['TOR_STATUS_NOT_SELECT'] = 'You have not selected status.';
|
||||
$lang['TOR_STATUS_SELECT_ALL'] = 'All statuses';
|
||||
$lang['TOR_STATUS_FORBIDDEN'] = 'This topic\'s status is: ';
|
||||
$lang['TOR_STATUS_NAME'] = [
|
||||
TOR_NOT_APPROVED => 'not checked',
|
||||
TOR_CLOSED => 'closed',
|
||||
TOR_APPROVED => 'checked',
|
||||
TOR_NEED_EDIT => 'not formalized until',
|
||||
TOR_NO_DESC => 'not formalized',
|
||||
TOR_DUP => 'repeat',
|
||||
TOR_CLOSED_CPHOLD => 'closed right',
|
||||
TOR_DUP => 'duplicate',
|
||||
TOR_CLOSED_CPHOLD => 'closed (copyright)',
|
||||
TOR_CONSUMED => 'absorbed',
|
||||
TOR_DOUBTFUL => 'doubtful',
|
||||
TOR_CHECKING => 'verified',
|
||||
TOR_CHECKING => 'being checked',
|
||||
TOR_TMP => 'temporary',
|
||||
TOR_PREMOD => 'pre-moderation',
|
||||
TOR_REPLENISH => 'replenish',
|
||||
TOR_REPLENISH => 'replenishing',
|
||||
];
|
||||
$lang['TOR_STATUS_FAILED'] = 'Such status does not exist!';
|
||||
$lang['TORRENT_FAILED'] = 'Distribution was not found!';
|
||||
$lang['TOR_STATUS_DUB'] = 'Distribution has the same status';
|
||||
$lang['TOR_DONT_CHANGE'] = 'Change of status can not be!';
|
||||
$lang['TOR_DONT_CHANGE'] = 'Change of status can not be performed!';
|
||||
$lang['TOR_STATUS_OF'] = 'Distribution has the status of:';
|
||||
$lang['TOR_STATUS_CHANGED'] = 'Status changed: ';
|
||||
$lang['TOR_BACK'] = ' back';
|
||||
|
|
|
@ -33,7 +33,7 @@ class Atom
|
|||
$forum_data['forum_name'] = $lang['ATOM_GLOBAL_FEED'] ?? $bb_cfg['server_name'];
|
||||
}
|
||||
if ($forum_id > 0 && $forum_data['allow_reg_tracker']) {
|
||||
$select_tor_sql = ', tor.size AS tor_size, tor.tor_status';
|
||||
$select_tor_sql = ', tor.size AS tor_size, tor.tor_status, tor.attach_id';
|
||||
$join_tor_sql = "LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)";
|
||||
}
|
||||
if ($forum_id == 0) {
|
||||
|
@ -43,12 +43,14 @@ class Atom
|
|||
u1.username AS first_username,
|
||||
p1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,
|
||||
tor.size AS tor_size, tor.tor_status
|
||||
tor.size AS tor_size, tor.tor_status, tor.attach_id,
|
||||
pt.post_html
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_TOPICS . " t ON(tor.topic_id = t.topic_id)
|
||||
LEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " pt ON(p1.post_id = pt.post_id)
|
||||
ORDER BY t.topic_last_post_time DESC
|
||||
LIMIT 100
|
||||
";
|
||||
|
@ -58,12 +60,14 @@ class Atom
|
|||
t.topic_id, t.topic_title, t.topic_status,
|
||||
u1.username AS first_username,
|
||||
p1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,
|
||||
pt.post_html
|
||||
$select_tor_sql
|
||||
FROM " . BB_TOPICS . " t
|
||||
LEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " pt ON(p1.post_id = pt.post_id)
|
||||
$join_tor_sql
|
||||
WHERE t.forum_id = $forum_id
|
||||
ORDER BY t.topic_last_post_time DESC
|
||||
|
@ -114,11 +118,13 @@ class Atom
|
|||
u1.username AS first_username,
|
||||
p1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,
|
||||
tor.size AS tor_size, tor.tor_status
|
||||
tor.size AS tor_size, tor.tor_status, tor.attach_id,
|
||||
pt.post_html
|
||||
FROM " . BB_TOPICS . " t
|
||||
LEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " pt ON(p1.post_id = pt.post_id)
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)
|
||||
WHERE t.topic_poster = $user_id
|
||||
ORDER BY t.topic_last_post_time DESC
|
||||
|
@ -163,7 +169,7 @@ class Atom
|
|||
*/
|
||||
private static function create_atom($file_path, $mode, $id, $title, $topics)
|
||||
{
|
||||
global $lang;
|
||||
global $bb_cfg, $lang;
|
||||
$date = null;
|
||||
$time = null;
|
||||
$dir = \dirname($file_path);
|
||||
|
@ -181,8 +187,7 @@ class Atom
|
|||
$time = bb_date($last_time, 'H:i:s', 0);
|
||||
break;
|
||||
}
|
||||
$atom = "";
|
||||
$atom .= "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
||||
$atom = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
||||
$atom .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xml:base=\"" . FULL_URL . "\">\n";
|
||||
$atom .= "<title>$title</title>\n";
|
||||
$atom .= "<updated>" . $date . "T$time+00:00</updated>\n";
|
||||
|
@ -194,6 +199,10 @@ class Atom
|
|||
if (isset($topic['tor_size'])) {
|
||||
$tor_size = str_replace(' ', ' ', ' [' . humn_size($topic['tor_size']) . ']');
|
||||
}
|
||||
$tor_status = '';
|
||||
if (isset($topic['tor_status'])) {
|
||||
$tor_status = " ({$lang['TOR_STATUS_NAME'][$topic['tor_status']]})";
|
||||
}
|
||||
$topic_title = $topic['topic_title'];
|
||||
$orig_word = [];
|
||||
$replacement_word = [];
|
||||
|
@ -215,13 +224,23 @@ class Atom
|
|||
$updated = '[' . $lang['ATOM_UPDATED'] . '] ';
|
||||
}
|
||||
$atom .= "<entry>\n";
|
||||
$atom .= " <title type=\"html\"><![CDATA[$updated$topic_title$tor_size]]></title>\n";
|
||||
$atom .= " <title type=\"html\"><![CDATA[$updated$topic_title$tor_status$tor_size]]></title>\n";
|
||||
$atom .= " <author>\n";
|
||||
$atom .= " <name>$author_name</name>\n";
|
||||
$atom .= " </author>\n";
|
||||
$atom .= " <updated>" . $date . "T$time+00:00</updated>\n";
|
||||
$atom .= " <id>tag:rto.feed," . $date . ":/t/$topic_id</id>\n";
|
||||
if ($bb_cfg['atom']['direct_down'] && isset($topic['attach_id'])) {
|
||||
$atom .= " <link href=\"" . DL_URL . $topic['attach_id'] . "\" />\n";
|
||||
}
|
||||
else {
|
||||
$atom .= " <link href=\"" . TOPIC_URL . $topic_id . "\" />\n";
|
||||
}
|
||||
|
||||
if ($bb_cfg['atom']['direct_view']) {
|
||||
$atom .= " <description>" . $topic['post_html'] . "\n\nNews URL: " . FULL_URL . TOPIC_URL . $topic_id . "</description>\n";
|
||||
}
|
||||
|
||||
$atom .= "</entry>\n";
|
||||
}
|
||||
$atom .= "</feed>";
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
|
||||
<table class="attach bordered med">
|
||||
<tr class="row3">
|
||||
<th colspan="3" class="{postrow.attach.tor_reged.DL_LINK_CLASS}">{postrow.attach.tor_reged.DOWNLOAD_NAME}<!-- IF MAGNET_LINKS --> {postrow.attach.tor_reged.MAGNET}<!-- ENDIF --></th>
|
||||
<th colspan="3" class="{postrow.attach.tor_reged.DL_LINK_CLASS}">{postrow.attach.tor_reged.DOWNLOAD_NAME}<!-- IF MAGNET_LINKS and not postrow.attach.tor_reged.TOR_FROZEN --> {postrow.attach.tor_reged.MAGNET}<!-- ENDIF --></th>
|
||||
</tr>
|
||||
<!-- IF postrow.attach.tor_reged.TOR_TYPE -->
|
||||
<tr class="row4">
|
||||
|
@ -156,8 +156,10 @@
|
|||
<td width="70%">
|
||||
{postrow.attach.tor_reged.TRACKER_LINK}
|
||||
[ <span title="{postrow.attach.tor_reged.REGED_DELTA}">{postrow.attach.tor_reged.REGED_TIME}</span> ]
|
||||
<br><!-- IF postrow.attach.tor_reged.HASH --><br>info_hash: {postrow.attach.tor_reged.HASH}<!-- ENDIF -->
|
||||
<!-- IF postrow.attach.tor_reged.HASH_V2 --><br>info_hash v2: {postrow.attach.tor_reged.HASH_V2}<!-- ENDIF -->
|
||||
<!-- IF not postrow.attach.tor_reged.TOR_FROZEN -->
|
||||
<br><!-- IF postrow.attach.tor_reged.HASH and not postrow.attach.tor_reged.TOR_FROZEN --><br>info_hash: {postrow.attach.tor_reged.HASH}<!-- ENDIF -->
|
||||
<!-- IF postrow.attach.tor_reged.HASH_V2 and not postrow.attach.tor_reged.TOR_FROZEN --><br>info_hash v2: {postrow.attach.tor_reged.HASH_V2}<!-- ENDIF -->
|
||||
<!-- ENDIF -->
|
||||
</td>
|
||||
<td width="15%" rowspan="4" class="tCenter pad_6">
|
||||
<!-- IF postrow.attach.tor_reged.TOR_FROZEN -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue