| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
if( !empty($setmodules) ) {</span> |
|---|
| 4 |
<span class="code-keyword"> $filename = basename(__FILE__); |
|---|
| 5 |
$module['statistic']['upload_statistic'] = $filename; |
|---|
| 6 |
return; |
|---|
| 7 |
} |
|---|
| 8 |
|
|---|
| 9 |
define('IN_PHPBB', 1); |
|---|
| 10 |
|
|---|
| 11 |
$root_path = './../'; |
|---|
| 12 |
$admin_path = './';</span> |
|---|
| 13 |
<span class="code-lang">require($root_path . 'extension.inc'); |
|---|
| 14 |
require($admin_path . 'pagestart.' . $phpEx); |
|---|
| 15 |
|
|---|
| 16 |
$template->set_filenames(array(</span> |
|---|
| 17 |
<span class="code-lang"> 'body' => '../admin/admin_upload_statistics.tpl') |
|---|
| 18 |
); |
|---|
| 19 |
|
|---|
| 20 |
$uporder = request_var('uporder', ''); |
|---|
| 21 |
$catorder = request_var('catorder', '');</span> |
|---|
| 22 |
<span class="code-lang"> |
|---|
| 23 |
switch($uporder) { |
|---|
| 24 |
case 'name': |
|---|
| 25 |
$orderby = 'u.name ASC'; |
|---|
| 26 |
break; |
|---|
| 27 |
case 'ratio': |
|---|
| 28 |
$orderby = 'u.uploaded/u.downloaded DESC'; |
|---|
| 29 |
break; |
|---|
| 30 |
case 'torrents': |
|---|
| 31 |
$orderby = 'num_torrents DESC'; |
|---|
| 32 |
break; |
|---|
| 33 |
case 'peers': |
|---|
| 34 |
$orderby = 'num_peers DESC'; |
|---|
| 35 |
break; |
|---|
| 36 |
case 'last_up': |
|---|
| 37 |
$orderby = 'torrent_added DESC'; |
|---|
| 38 |
break; |
|---|
| 39 |
default: |
|---|
| 40 |
$orderby = 'u.uid'; |
|---|
| 41 |
break; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
$sql = 'SELECT u.uid, u.name AS username, u.added, u.uploaded, u.downloaded, u.donor, u.warneduntil, u.parked, u.class, u.enabled, MAX(t.ctime) AS torrent_added, COUNT(t.fid) AS num_torrents, SUM(t.leechers + t.seeders) AS num_peers</span> |
|---|
| 46 |
<span class="code-lang"> FROM ' . USERS_TABLE . ' u LEFT JOIN ' . TORRENTS_TABLE . ' t ON u.uid = t.owner |
|---|
| 47 |
WHERE class >= ' . UC_UPLOADER . ' |
|---|
| 48 |
GROUP BY u.uid ORDER BY ' . $orderby; |
|---|
| 49 |
$result = $db->sql_query($sql); |
|---|
| 50 |
|
|---|
| 51 |
$template->assign_vars(array(</span> |
|---|
| 52 |
<span class="code-lang"> 'U_UP_ST_USERNAME' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&uporder=name'), |
|---|
| 53 |
'U_UP_ST_RATIO' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&uporder=ratio'), |
|---|
| 54 |
'U_UP_ST_TORRENTS' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&uporder=torrents'), |
|---|
| 55 |
'U_UP_ST_PEERS' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&uporder=peers'), |
|---|
| 56 |
'U_UP_ST_LASTUP' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&uporder=last_up'), |
|---|
| 57 |
|
|---|
| 58 |
'U_CT_ST_CATEGORY' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&catorder=category'), |
|---|
| 59 |
'U_CT_ST_LASTUL' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&catorder=lastul'), |
|---|
| 60 |
'U_CT_ST_TORRENTS' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&catorder=torrents'), |
|---|
| 61 |
'U_CT_ST_PEERS' => append_sid($admin_path . 'admin_upload_statistics.php?act=upstats&catorder=peers'), |
|---|
| 62 |
)); |
|---|
| 63 |
$counter = 0;</span> |
|---|
| 64 |
<span class="code-lang">while ($row = $db->sql_fetchrow($result)) { |
|---|
| 65 |
$ratio = get_ratio($row["uploaded"], $row["downloaded"]); |
|---|
| 66 |
$ratio_color = get_ratio_color($ratio); |
|---|
| 67 |
$counter++; |
|---|
| 68 |
|
|---|
| 69 |
$template->assign_block_vars('uploaders_row', array( |
|---|
| 70 |
'COUNTER' => $counter, |
|---|
| 71 |
'TD_COLOR' => ( $counter % 2 ? $theme['td_class1'] : $theme['td_class2'] ), |
|---|
| 72 |
'USERNAME' => get_user_class_color($row['class'], $row['username']), |
|---|
| 73 |
'UPLOADED' => mksize($row['uploaded']), |
|---|
| 74 |
'DOWNLOADED' => mksize($row['downloaded']), |
|---|
| 75 |
'USER_ICONS' => get_user_icons($row), |
|---|
| 76 |
'RATIO' => $ratio, |
|---|
| 77 |
'RATIO_COLOR' => $ratio_color, |
|---|
| 78 |
'NUM_TORRENTS' => ( $row['num_torrents'] ? $row['num_torrents'] : 0), |
|---|
| 79 |
'NUM_PEERS' => ( $row['num_peers'] ? $row['num_peers'] : 0 ), |
|---|
| 80 |
'LAST_ADDED' => ( $row['num_torrents'] ? get_elapsed_time($row['torrent_added']) . ' (' . create_date($row['torrent_added']) . ')' : '---' ), |
|---|
| 81 |
|
|---|
| 82 |
'U_USERDETAILS' => append_sid($root_path . 'userdetails.php?id=' . $row['uid']), |
|---|
| 83 |
'U_PM' => append_sid($root_path . 'message.php?action=send&receiver=' . $row['uid']), |
|---|
| 84 |
)); |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
$template->assign_vars(array(</span> |
|---|
| 88 |
<span class="code-lang"> 'NUM' => $counter, |
|---|
| 89 |
'L_TOTAL_UPLOADERS' => sprintf($lang['total_uploaders'], $counter) ) |
|---|
| 90 |
); |
|---|
| 91 |
|
|---|
| 92 |
switch($catorder) { |
|---|
| 93 |
case 'lastul': |
|---|
| 94 |
$orderby = 'last DESC, c.name'; |
|---|
| 95 |
break; |
|---|
| 96 |
case 'torrents': |
|---|
| 97 |
$orderby = 'n_t DESC, c.name'; |
|---|
| 98 |
break; |
|---|
| 99 |
case 'peers': |
|---|
| 100 |
$orderby = 'n_p DESC, name'; |
|---|
| 101 |
break; |
|---|
| 102 |
default: |
|---|
| 103 |
$orderby = 'c.name'; |
|---|
| 104 |
break; |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
$sql = 'SELECT c.name, MAX(t.ctime) AS last, COUNT(DISTINCT t.fid) AS n_t, COUNT(p.uid) AS n_p</span> |
|---|
| 108 |
<span class="code-lang"> FROM ' . CATEGORIES_TABLE . ' c, ' . TORRENTS_TABLE . ' t LEFT JOIN ' . PEERS_TABLE . ' p ON t.fid = p.fid |
|---|
| 109 |
WHERE t.category = c.id GROUP BY c.id ORDER BY ' . $orderby; |
|---|
| 110 |
$result = $db->sql_query($sql); |
|---|
| 111 |
|
|---|
| 112 |
$cat1 = array(); |
|---|
| 113 |
$num_torrents = $i = $num_peers = 0;</span> |
|---|
| 114 |
<span class="code-lang">while ($cat = $db->sql_fetchrow($result)) { |
|---|
| 115 |
$cat1[] = $cat; |
|---|
| 116 |
$num_torrents += $cat['n_t']; |
|---|
| 117 |
$num_peers += $cat['n_p']; |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
foreach ($cat1 as $cat) { |
|---|
| 121 |
$i++; |
|---|
| 122 |
$template->assign_block_vars('cats_row', array( |
|---|
| 123 |
'TD_COLOR' => ($i % 2 ? $theme['td_class1'] : $theme['td_class2'] ), |
|---|
| 124 |
'CAT_NAME' => $cat['name'], |
|---|
| 125 |
'LAST_UP' => ($cat['last'] ? create_date($cat['last']) . ' (' . get_elapsed_time($cat['last']) . ')' : '---'), |
|---|
| 126 |
'NUM_TORRENTS' => $cat['n_t'], |
|---|
| 127 |
'TORRENTS_PERCENT' => ( $cat['n_t'] ? number_format(100*$cat['n_t']/$num_torrents,1) .'%' : '---') , |
|---|
| 128 |
'NUM_PEERS' => $cat['n_p'], |
|---|
| 129 |
'PEERS_PERCENT' => ( $cat['n_p'] ? number_format(100 * $cat['n_p']/$num_peers,1). '%' : '---' ) ) |
|---|
| 130 |
); |
|---|
| 131 |
|
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
$template->display('body');</span> |
|---|
| 136 |
<span class="code-lang">include('./page_footer_admin.'.$phpEx); |
|---|
| 137 |
?> |
|---|