mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 05:43:55 -07:00
Fixed download counter for torrents (#1346)
* Fixed download counter for torrents * Updated * Updated * Update CHANGELOG.md
This commit is contained in:
parent
f993983eb0
commit
66b9b7bdc4
7 changed files with 22 additions and 14 deletions
|
@ -19,6 +19,7 @@
|
||||||
- Some enhancements in default template (Part 2) [\#1322](https://github.com/torrentpier/torrentpier/pull/1322) ([belomaxorka](https://github.com/belomaxorka))
|
- Some enhancements in default template (Part 2) [\#1322](https://github.com/torrentpier/torrentpier/pull/1322) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Set response code in some cases [\#1319](https://github.com/torrentpier/torrentpier/pull/1319) ([belomaxorka](https://github.com/belomaxorka))
|
- Set response code in some cases [\#1319](https://github.com/torrentpier/torrentpier/pull/1319) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Fixed auth(): empty $f_access [\#1329](https://github.com/torrentpier/torrentpier/pull/1329) ([belomaxorka](https://github.com/belomaxorka))
|
- Fixed auth(): empty $f_access [\#1329](https://github.com/torrentpier/torrentpier/pull/1329) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
- Fixed download counter for torrents [\#1346](https://github.com/torrentpier/torrentpier/pull/1346) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Fixed HTTP 500 while cron running in server-side [\#1321](https://github.com/torrentpier/torrentpier/pull/1321) ([belomaxorka](https://github.com/belomaxorka))
|
- Fixed HTTP 500 while cron running in server-side [\#1321](https://github.com/torrentpier/torrentpier/pull/1321) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Sending debug errors to us 🌚 via Telegram bot [\#1323](https://github.com/torrentpier/torrentpier/pull/1323) ([belomaxorka](https://github.com/belomaxorka))
|
- Sending debug errors to us 🌚 via Telegram bot [\#1323](https://github.com/torrentpier/torrentpier/pull/1323) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Don't update downloads counter if attachment not exists [\#1345](https://github.com/torrentpier/torrentpier/pull/1345) ([belomaxorka](https://github.com/belomaxorka))
|
- Don't update downloads counter if attachment not exists [\#1345](https://github.com/torrentpier/torrentpier/pull/1345) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
|
|
|
@ -166,12 +166,13 @@ elseif ($submit && $mode == 'group' && (!empty($_POST['auth']) && is_array($_POS
|
||||||
if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) {
|
if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) {
|
||||||
$page_cfg['quirks_mode'] = true;
|
$page_cfg['quirks_mode'] = true;
|
||||||
|
|
||||||
|
$this_userdata = false;
|
||||||
if (!empty($_POST['username'])) {
|
if (!empty($_POST['username'])) {
|
||||||
$this_userdata = get_userdata($_POST['username'], true);
|
$this_userdata = get_userdata($_POST['username'], true);
|
||||||
$user_id = $this_userdata ? $this_userdata['user_id'] : false;
|
} elseif (!empty($user_id)) {
|
||||||
} else {
|
|
||||||
$this_userdata = get_userdata($user_id);
|
$this_userdata = get_userdata($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this_userdata) {
|
if (!$this_userdata) {
|
||||||
bb_die($lang['NO_SUCH_USER']);
|
bb_die($lang['NO_SUCH_USER']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -957,20 +957,21 @@ function clean_username($username)
|
||||||
* @param bool $allow_guest
|
* @param bool $allow_guest
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function get_userdata($u, bool $is_name = false, bool $allow_guest = false, bool $profile_view = false)
|
function get_userdata(int|string $u, bool $is_name = false, bool $allow_guest = false, bool $profile_view = false)
|
||||||
{
|
{
|
||||||
if (empty($u)) {
|
if (empty($u)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$is_name) {
|
if (!$is_name) {
|
||||||
if ((int)$u === GUEST_UID && $allow_guest) {
|
$u = (int)$u;
|
||||||
|
if ($u === GUEST_UID && $allow_guest) {
|
||||||
if ($u_data = CACHE('bb_cache')->get('guest_userdata')) {
|
if ($u_data = CACHE('bb_cache')->get('guest_userdata')) {
|
||||||
return $u_data;
|
return $u_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$where_sql = "WHERE user_id = " . (int)$u;
|
$where_sql = "WHERE user_id = " . $u;
|
||||||
} else {
|
} else {
|
||||||
$where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'";
|
$where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'";
|
||||||
}
|
}
|
||||||
|
@ -993,7 +994,7 @@ function get_userdata($u, bool $is_name = false, bool $allow_guest = false, bool
|
||||||
return $u_data;
|
return $u_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_jumpbox()
|
function make_jumpbox(): void
|
||||||
{
|
{
|
||||||
global $datastore, $template, $bb_cfg;
|
global $datastore, $template, $bb_cfg;
|
||||||
|
|
||||||
|
|
|
@ -415,8 +415,8 @@ ajax.callback.view_post = function(data) {
|
||||||
<span class="small"> | </span>
|
<span class="small"> | </span>
|
||||||
<span title="{L_VIEWS}: {tor.VIEWS}">{tor.VIEWS}</span>
|
<span title="{L_VIEWS}: {tor.VIEWS}">{tor.VIEWS}</span>
|
||||||
</p>
|
</p>
|
||||||
<p style="padding-top: 2px" class="med" title="{L_COMPLETED}: {tor.COMPLETED}">
|
<p style="padding-top: 2px;" class="med" title="{L_COMPLETED}: {tor.COMPLETED}">
|
||||||
<b>{tor.COMPLETED}</b>
|
<b>{tor.DOWNLOADED}</b>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<!-- IF SHOW_SPEED -->
|
<!-- IF SHOW_SPEED -->
|
||||||
|
|
|
@ -480,8 +480,8 @@ td.topic_id { cursor: pointer; }
|
||||||
<span title="{L_VIEWS}: {t.VIEWS}">{t.VIEWS}</span>
|
<span title="{L_VIEWS}: {t.VIEWS}">{t.VIEWS}</span>
|
||||||
</p>
|
</p>
|
||||||
<!-- BEGIN tor -->
|
<!-- BEGIN tor -->
|
||||||
<p style="padding-top: 2px" class="med" title="{L_COMPLETED}: {t.tor.COMPL_CNT}">
|
<p style="padding-top: 2px;" class="med" title="{L_COMPLETED}: {t.tor.COMPL_CNT}">
|
||||||
<b>{t.tor.COMPL_CNT}</b>
|
<b>{t.tor.DOWNLOADED}</b>
|
||||||
</p>
|
</p>
|
||||||
<!-- END tor -->
|
<!-- END tor -->
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -62,6 +62,7 @@ $users_tbl = BB_USERS . ' u';
|
||||||
$tracker_tbl = BB_BT_TRACKER . ' tr';
|
$tracker_tbl = BB_BT_TRACKER . ' tr';
|
||||||
$tr_snap_tbl = BB_BT_TRACKER_SNAP . ' sn';
|
$tr_snap_tbl = BB_BT_TRACKER_SNAP . ' sn';
|
||||||
$dl_stat_tbl = BB_BT_DLSTATUS . ' dl';
|
$dl_stat_tbl = BB_BT_DLSTATUS . ' dl';
|
||||||
|
$attach_desc_tbl = BB_ATTACHMENTS_DESC . ' ad';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search options
|
// Search options
|
||||||
|
@ -654,7 +655,7 @@ if ($allowed_forums) {
|
||||||
$select = "
|
$select = "
|
||||||
SELECT
|
SELECT
|
||||||
tor.topic_id, tor.post_id, tor.attach_id, tor.size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.tor_status, tor.tor_type,
|
tor.topic_id, tor.post_id, tor.attach_id, tor.size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.tor_status, tor.tor_type,
|
||||||
t.topic_title, t.topic_time, t.topic_replies, t.topic_views, sn.seeders, sn.leechers, tor.info_hash, tor.info_hash_v2
|
t.topic_title, t.topic_time, t.topic_replies, t.topic_views, sn.seeders, sn.leechers, tor.info_hash, tor.info_hash_v2, ad.download_count
|
||||||
";
|
";
|
||||||
$select .= (!$hide_speed) ? ", sn.speed_up, sn.speed_down" : '';
|
$select .= (!$hide_speed) ? ", sn.speed_up, sn.speed_down" : '';
|
||||||
$select .= (!$hide_forum) ? ", tor.forum_id" : '';
|
$select .= (!$hide_forum) ? ", tor.forum_id" : '';
|
||||||
|
@ -677,6 +678,7 @@ if ($allowed_forums) {
|
||||||
LEFT JOIN $dl_stat_tbl ON(dl.topic_id = tor.topic_id AND dl.user_id = $user_id)
|
LEFT JOIN $dl_stat_tbl ON(dl.topic_id = tor.topic_id AND dl.user_id = $user_id)
|
||||||
" : '';
|
" : '';
|
||||||
$from .= "LEFT JOIN $tr_snap_tbl ON(sn.topic_id = tor.topic_id)";
|
$from .= "LEFT JOIN $tr_snap_tbl ON(sn.topic_id = tor.topic_id)";
|
||||||
|
$from .= "LEFT JOIN $attach_desc_tbl ON(ad.attach_id = tor.attach_id)";
|
||||||
|
|
||||||
// WHERE
|
// WHERE
|
||||||
$where = "
|
$where = "
|
||||||
|
@ -757,7 +759,8 @@ if ($allowed_forums) {
|
||||||
'SEEDS' => $seeds ?: 0,
|
'SEEDS' => $seeds ?: 0,
|
||||||
'SEEDS_TITLE' => $seeds ? $lang['SEEDERS'] : ($lang['SEED_NOT_SEEN'] . ":\n " . (($s_last) ? bb_date($s_last, $date_format) : $lang['NEVER'])),
|
'SEEDS_TITLE' => $seeds ? $lang['SEEDERS'] : ($lang['SEED_NOT_SEEN'] . ":\n " . (($s_last) ? bb_date($s_last, $date_format) : $lang['NEVER'])),
|
||||||
'LEECHS' => $leechs ?: 0,
|
'LEECHS' => $leechs ?: 0,
|
||||||
'COMPLETED' => $compl ?: 0,
|
'COMPLETED' => declension($compl ?: 0, 'times'),
|
||||||
|
'DOWNLOADED' => $tor['download_count'],
|
||||||
'REPLIES' => $tor['topic_replies'],
|
'REPLIES' => $tor['topic_replies'],
|
||||||
'VIEWS' => $tor['topic_views'],
|
'VIEWS' => $tor['topic_views'],
|
||||||
'ADDED_RAW' => $tor['reg_time'],
|
'ADDED_RAW' => $tor['reg_time'],
|
||||||
|
|
|
@ -287,7 +287,7 @@ if ($forum_data['allow_reg_tracker']) {
|
||||||
|
|
||||||
$select_tor_sql = ',
|
$select_tor_sql = ',
|
||||||
bt.auth_key, tor.info_hash, tor.info_hash_v2, tor.size AS tor_size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.attach_id, tor.tor_status, tor.tor_type,
|
bt.auth_key, tor.info_hash, tor.info_hash_v2, tor.size AS tor_size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.attach_id, tor.tor_status, tor.tor_type,
|
||||||
sn.seeders, sn.leechers
|
sn.seeders, sn.leechers, ad.download_count
|
||||||
';
|
';
|
||||||
$select_tor_sql .= ($join_dl) ? ', dl.user_status AS dl_status' : '';
|
$select_tor_sql .= ($join_dl) ? ', dl.user_status AS dl_status' : '';
|
||||||
|
|
||||||
|
@ -295,6 +295,7 @@ if ($forum_data['allow_reg_tracker']) {
|
||||||
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)
|
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)
|
||||||
LEFT JOIN " . BB_BT_USERS . " bt ON(bt.user_id = {$userdata['user_id']})
|
LEFT JOIN " . BB_BT_USERS . " bt ON(bt.user_id = {$userdata['user_id']})
|
||||||
LEFT JOIN " . BB_BT_TRACKER_SNAP . " sn ON(tor.topic_id = sn.topic_id)
|
LEFT JOIN " . BB_BT_TRACKER_SNAP . " sn ON(tor.topic_id = sn.topic_id)
|
||||||
|
LEFT JOIN " . BB_ATTACHMENTS_DESC . " ad ON(tor.attach_id = ad.attach_id)
|
||||||
";
|
";
|
||||||
$join_tor_sql .= ($join_dl) ? " LEFT JOIN " . BB_BT_DLSTATUS . " dl ON(dl.user_id = {$userdata['user_id']} AND dl.topic_id = t.topic_id)" : '';
|
$join_tor_sql .= ($join_dl) ? " LEFT JOIN " . BB_BT_DLSTATUS . " dl ON(dl.user_id = {$userdata['user_id']} AND dl.topic_id = t.topic_id)" : '';
|
||||||
}
|
}
|
||||||
|
@ -477,7 +478,8 @@ foreach ($topic_rowset as $topic) {
|
||||||
'SEEDERS' => (int)$topic['seeders'],
|
'SEEDERS' => (int)$topic['seeders'],
|
||||||
'LEECHERS' => (int)$topic['leechers'],
|
'LEECHERS' => (int)$topic['leechers'],
|
||||||
'TOR_SIZE' => humn_size($topic['tor_size'], 1),
|
'TOR_SIZE' => humn_size($topic['tor_size'], 1),
|
||||||
'COMPL_CNT' => (int)$topic['complete_count'],
|
'COMPL_CNT' => declension((int)$topic['complete_count'], 'times'),
|
||||||
|
'DOWNLOADED' => (int)$topic['download_count'],
|
||||||
'ATTACH_ID' => $topic['attach_id'],
|
'ATTACH_ID' => $topic['attach_id'],
|
||||||
'MAGNET' => $tor_magnet,
|
'MAGNET' => $tor_magnet,
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue