##############################################################
## MOD Title: Last added, top torrents, top users Mod
## MOD Author: RoadTrain < N/A > http://torrentpier.com/viewtopic.php?f=8&t=1246
## MOD Version: 0.1
## Описание: Статистика по торрентам и юзерам в боковой панели.
## Installation Level: Easy
## Installation Time: 10 Minutes
## Files To Edit: config.php
## index.php
## includes/datastore/build_cat_forums.php
## language/lang_russian/lang_main.php
## templates/default/page_header.tpl
## Included Files: none
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://torrentpier.com/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://torrentpier.com/
##############################################################
## Author Notes:
## nah & poh
##############################################################
## MOD History:
## 2008-10-16 - Version 0.1.0
## - initial release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]---------------------------------
#
config.php
#
#-----[ FIND ]---------------------------------
#
$bb_cfg['tor_help_links'] = '';
#
#-----[ AFTER, ADD ]---------------------------------
#
//Last added torrents
$bb_cfg['t_last_added_num'] = 7;
//Top downloaded torrents
$bb_cfg['t_top_downloaded'] = 7;
//Top seeders
$bb_cfg['t_top_uploaders'] = 5;
//Top leechers
$bb_cfg['t_top_downloaders'] = 5;
#
#-----[ OPEN ]---------------------------------
#
index.php
#
#-----[ FIND ]---------------------------------
#
// Init userdata
$user->session_start();
#
#-----[ BEFORE, ADD ]---------------------------------
#
//Enqueue last added
if ($bb_cfg['t_last_added_num'])
{
$datastore->enqueue('last_added');
}
//Enqueue top downloaded
if ($bb_cfg['t_top_downloaded'])
{
$datastore->enqueue('top_downloaded');
}
//Enqueue top uploaders
if ($bb_cfg['t_top_uploaders'])
{
$datastore->enqueue('top_uploaders');
}
//Enqueue top downloaders
if ($bb_cfg['t_top_downloaders'])
{
$datastore->enqueue('top_downloaders');
}
#
#-----[ FIND ]---------------------------------
#
// Build index page
foreach ($cat_forums as $cid => $c)
{
#
#-----[ BEFORE, ADD ]---------------------------------
#
//
// BEGIN last 10.
//
if($bb_cfg['t_last_added_num'])
{
$template -> assign_vars(array(
'LAST_ADDED_ON' => true,
));
$last_added = $datastore->get('last_added');
foreach ($last_added as $last_add)
{
$template -> assign_block_vars('lastAdded',array(
'TITLE' => $last_add['topic_title'],
'TOPIC_ID' => $last_add['topic_id'],
'FORUM' => $last_add['forum_name'],
'FORUM_ID' => $last_add['forum_id'],
'POSTER' => $last_add['username'],
'POSTER_ID' => $last_add['user_id'],
'TORRENT_TIME' => bb_date($last_add['reg_time'])
)) ;
}
}
//
// END last 10
//
//
// BEGIN TopDownloaded
//
if($bb_cfg['t_top_downloaded'])
{
$template -> assign_vars(array(
'TOP_DOWNLOADED_ON' => true,
));
$top_downloaded = $datastore->get('top_downloaded');
foreach ($top_downloaded as $top_download)
{
$template -> assign_block_vars('TopDownloaded',array(
'TITLE' => $top_download['topic_title'],
'TOPIC_ID' => $top_download['topic_id'],
'FORUM' => $top_download['forum_name'],
'FORUM_ID' => $top_download['forum_id'],
'POSTER' => $top_download['username'],
'POSTER_ID' => $top_download['user_id'],
'COMPLETED' => $top_download['complete_count'] . ' раз',
'TORRENT_TIME' => bb_date($top_download['reg_time'])
)) ;
}
}
//
// END TopDownloaded
//
//
// BEGIN Top Uploaders.
//
if($bb_cfg['t_top_uploaders']) {
$template -> assign_vars(array(
'TOP_UPLOADERS_ON' => true,
'UL_TOP_COUNT' => $bb_cfg['t_top_uploaders'],
));
$top_uploaders = $datastore->get('top_uploaders');
foreach ($top_uploaders as $top_uploader)
{
$template -> assign_block_vars('TopUploaders',array(
'USER_ID' => $top_uploader['user_id'],
'UPL_NAME' => $top_uploader['username'],
'UPLOADED' => (humn_size($top_uploader['sum'])),
)) ;
}
}
//
// END Top Uploaders
//
//
// BEGIN Top Downloaders.
//
if($bb_cfg['t_top_downloaders']) {
$template -> assign_vars(array(
'TOP_DOWNLOADERS_ON' => true,
'DL_TOP_COUNT' => $bb_cfg['t_top_downloaders'],
));
$top_downloaders = $datastore->get('top_downloaders');
foreach ($top_downloaders as $top_downloader)
{
$template -> assign_block_vars('TopDownloaders',array(
'USER_ID' => $top_downloader['user_id'],
'DOWNL_NAME' => $top_downloader['username'],
'DOWNLOADED' => (humn_size($top_downloader['sum'])),
)) ;
}
}
//
// END Top Downloaders
//
#
#-----[ OPEN ]---------------------------------
#
includes/datastore/build_cat_forums.php
#
#-----[ FIND ]---------------------------------
#
bb_update_config(array('active_ads' => serialize($ad_block_assignment)));
#
#-----[ AFTER, ADD ]---------------------------------
#
//Store LastAdded
if($bb_cfg['t_last_added_num'])
{
$data = DB()->fetch_rowset("SELECT
tr.topic_id, tr.forum_id, tr.reg_time,
t.topic_title,
f.forum_name,
u.username, u.user_id
FROM
". BB_BT_TORRENTS ." tr
LEFT JOIN ". BB_TOPICS ." t ON tr.topic_id = t.topic_id
LEFT JOIN ". BB_FORUMS ." f ON tr.forum_id = f.forum_id
LEFT JOIN ". BB_USERS ." u ON tr.poster_id = u.user_id
ORDER BY
tr.reg_time DESC
LIMIT 0,".$bb_cfg['t_last_added_num']);
$this->store('last_added', $data);
}
//Store TopDownloaded
if($bb_cfg['t_top_downloaded'])
{
$data = DB()->fetch_rowset("SELECT
tr.topic_id, tr.forum_id, tr.reg_time, tr.complete_count,
t.topic_title,
f.forum_name,
u.username, u.user_id
FROM
". BB_BT_TORRENTS ." tr
LEFT JOIN ". BB_TOPICS ." t ON tr.topic_id = t.topic_id
LEFT JOIN ". BB_FORUMS ." f ON tr.forum_id = f.forum_id
LEFT JOIN ". BB_USERS ." u ON tr.poster_id = u.user_id
ORDER BY
tr.complete_count DESC
LIMIT 0,".$bb_cfg['t_top_downloaded']);
$this->store('top_downloaded', $data);
}
//Store TopUploaders
if($bb_cfg['t_top_uploaders'])
{
$data = DB()->fetch_rowset("SELECT t.user_id, u.username, SUM( t.u_up_total ) sum
FROM ". BB_BT_USERS ." t
LEFT JOIN ". BB_USERS ." u ON ( t.user_id = u.user_id )
GROUP BY t.user_id
ORDER BY sum DESC
LIMIT 0 ,".$bb_cfg['t_top_uploaders']);
$this->store('top_uploaders', $data);
}
//Store TopDownloaders
if($bb_cfg['t_top_downloaders'])
{
$data = DB()->fetch_rowset("SELECT t.user_id, u.username, SUM( t.u_down_total ) sum
FROM ". BB_BT_USERS ." t
LEFT JOIN ". BB_USERS ." u ON ( t.user_id = u.user_id )
GROUP BY t.user_id
ORDER BY sum DESC
LIMIT 0 ,".$bb_cfg['t_top_downloaders']);
$this->store('top_downloaders', $data);
}
#
#-----[ OPEN ]---------------------------------
#
language/lang_russian/lang_main.php
#
#-----[ FIND ]---------------------------------
#
$lang['TORHELP_TITLE'] = 'Этим раздачам необходима ваша помощь!';
#
#-----[ AFTER, ADD ]---------------------------------
#
$lang['LAST_ADDED'] = 'Новые торренты';
$lang['TOP_DOWNLOADED'] = 'Самые скачиваемые';
$lang['TOP_SEEDERS'] = "Топ {$bb_cfg['t_top_uploaders']} сидеров";
$lang['TOP_LEECHERS'] = "Топ {$bb_cfg['t_top_downloaders']} личеров";
#
#-----[ OPEN ]---------------------------------
#
templates/default/page_header.tpl
#
#-----[ FIND ]---------------------------------
#
<?php if (!empty($bb_cfg['sidebar1_static_content_path'])) include($bb_cfg['sidebar1_static_content_path']); ?>
#
#-----[ BEFORE, ADD ]---------------------------------
#
<!-- IF TOP_UPLOADERS_ON -->
<br>
<div class="spacer" style="height:5px"> </div>
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="attachtable">
<tr class="cat_title"><th colspan="2" scope="col"><b>{L_TOP_SEEDERS}</b></th></tr>
<!-- BEGIN TopUploaders -->
<tr>
<td class="row1 f_titles" style="border-bottom: 1px solid #C3CBD1;">
<div style="font-size:11px" align="center"><b><a href="profile.php?mode=viewprofile&u={TopUploaders.USER_ID}">{TopUploaders.UPL_NAME}</a><b></div>
</td>
<td class="row1 f_titles" style="border-bottom: 1px solid #C3CBD1;">
<div style="font-size:11px"><b><span class="seedmed">{TopUploaders.UPLOADED}</span></b> </div>
</td>
</tr>
<!-- END TopUploaders -->
</table>
<!-- ENDIF -->
<br>
<!-- IF TOP_DOWNLOADERS_ON -->
<div class="spacer" style="height:5px"> </div>
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="attachtable">
<tr class="cat_title"><th colspan="2" scope="col"><b>{L_TOP_LEECHERS}</b></th></tr>
<!-- BEGIN TopDownloaders -->
<tr>
<td class="row1 f_titles" style="border-bottom: 1px solid #C3CBD1;">
<div style="font-size:11px" align="center"><b><a href="profile.php?mode=viewprofile&u={TopDownloaders.USER_ID}">{TopDownloaders.DOWNL_NAME}</a><b></div>
</td>
<td class="row1 f_titles" style="border-bottom: 1px solid #C3CBD1;">
<div style="font-size:11px"><b><span class="leechmed">{TopDownloaders.DOWNLOADED}</span></b> </div>
</td>
</tr>
<!-- END TopDownloaders -->
</table>
<!-- ENDIF -->
<!-- IF LAST_ADDED_ON -->
<div class="spacer"> </div>
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="attachtable">
<tr class="cat_title"><td><b>{L_LAST_ADDED}</b></td></tr>
<!-- BEGIN lastAdded -->
<tr>
<td class="f_titles" style="border-bottom: 1px solid #C3CBD1;">
<div><a href="viewtopic.php?t={lastAdded.TOPIC_ID}" style="font-size:11px">{lastAdded.TITLE}</a></div>
<div style="font-size:10px">{L_AUTHOR}: <a href="profile.php?mode=viewprofile&u={lastAdded.POSTER_ID}">{lastAdded.POSTER}</a>; {lastAdded.TORRENT_TIME}</div><div style="font-size:10px"> {L_FORUM}: <a href="viewforum.php?f={lastAdded.FORUM_ID}">{lastAdded.FORUM}</a></div>
</td>
</tr>
<!-- END lastAdded -->
</table>
<!-- ENDIF -->
<!-- IF TOP_DOWNLOADED_ON -->
<div class="spacer"> </div>
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="attachtable">
<tr class="cat_title"><td><b>{L_TOP_DOWNLOADED}</b></td></tr>
<!-- BEGIN TopDownloaded -->
<tr>
<td class="f_titles" style="border-bottom: 1px solid #C3CBD1;">
<div><a href="viewtopic.php?t={TopDownloaded.TOPIC_ID}" style="font-size:11px">{TopDownloaded.TITLE}</a></div>
<div style="font-size:10px">{L_COMPLETED}: <b>{TopDownloaded.COMPLETED}</b></div>
<div style="font-size:10px">{L_AUTHOR}: <a href="profile.php?mode=viewprofile&u={TopDownloaded.POSTER_ID}">{TopDownloaded.POSTER}</a>; {TopDownloaded.TORRENT_TIME}</div><div style="font-size:10px"> {L_FORUM}: <a href="viewforum.php?f={TopDownloaded.FORUM_ID}">{TopDownloaded.FORUM}</a></div>
</td>
</tr>
<!-- END TopDownloaded -->
</table>
<!-- ENDIF -->
#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------
#
# EoM