| 1 |
<?php</span> |
|---|
| 2 |
<span class="code-lang">$root_path = './'; |
|---|
| 3 |
require ($root_path . 'include/config.php'); |
|---|
| 4 |
require ($root_path . 'include/bbcode/bbcode.lib.php'); |
|---|
| 5 |
|
|---|
| 6 |
$userdata = session_pagestart($user_ip); |
|---|
| 7 |
init_userprefs($userdata); |
|---|
| 8 |
|
|---|
| 9 |
$bb_code = new bbcode();</span> |
|---|
| 10 |
<span class="code-lang"> |
|---|
| 11 |
if ( $userdata['session_logged_in'] ) { |
|---|
| 12 |
|
|---|
| 13 |
$now = date('m-d', time() + $userdata['tzoffset']); |
|---|
| 14 |
$sql = 'SELECT uid, name, class, parked, warneduntil, enabled, donor, birthday |
|---|
| 15 |
FROM ' . USERS_TABLE . ' |
|---|
| 16 |
WHERE birthday LIKE \'%-' . $now . '\' |
|---|
| 17 |
AND enabled = 1 |
|---|
| 18 |
AND status = 1 |
|---|
| 19 |
ORDER BY class DESC, name ASC'; |
|---|
| 20 |
$result = $db->sql_query($sql, 120 * 60); |
|---|
| 21 |
|
|---|
| 22 |
$birthday_users = ''; |
|---|
| 23 |
$i = 0; |
|---|
| 24 |
if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 25 |
do { |
|---|
| 26 |
++$i; |
|---|
| 27 |
|
|---|
| 28 |
$seo->set_user_url($row['name'], $row['uid']); |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
$age = get_age($row['birthday']); |
|---|
| 32 |
$row['name'] = get_user_class_color($row['class'], $row['name']); |
|---|
| 33 |
$birthday_users .= ( $birthday_users ? ', ' : '' ) . '<a href="' . append_sid($root_path . 'userdetails.php?id=' . $row['uid']) . '">' . $row['name'] . '</a> (' . $age . ')' . get_user_icons($row); |
|---|
| 34 |
|
|---|
| 35 |
if ( $i == 50 ) { |
|---|
| 36 |
$birthday_users .= ' <a href="javascript:;" onclick="$(this).next(\'span\').show();$(this).remove();">' . $lang['see_full_list'] . '</a><span style="display:none">'; |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
} |
|---|
| 41 |
while ( $row = $db->sql_fetchrow($result) ); |
|---|
| 42 |
|
|---|
| 43 |
if ( $i > 50 ) { |
|---|
| 44 |
$birthday_users .= '</span>'; |
|---|
| 45 |
} |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
$template->assign_vars(array( |
|---|
| 50 |
'BIRTHDAY_USERS' => $birthday_users |
|---|
| 51 |
)); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$sql = 'SELECT vote_id, vote_start, vote_length |
|---|
| 55 |
FROM ' . VOTE_DESC_TABLE . ' |
|---|
| 56 |
WHERE topic_id = 0 |
|---|
| 57 |
ORDER by vote_id DESC'; |
|---|
| 58 |
$result = $db->sql_query_limit($sql, 1, 0, 24 * 60 * 60); |
|---|
| 59 |
$poll_id = 0; |
|---|
| 60 |
$poll_until = 0; |
|---|
| 61 |
if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 62 |
$poll_id = $row['vote_id']; |
|---|
| 63 |
$poll_until = ( $row['vote_length'] ) ? ( 5 * 24 * 60 * 60 ) + $row['vote_start'] + $row['vote_length'] : 0; |
|---|
| 64 |
} |
|---|
| 65 |
$db->sql_freeresult($result); |
|---|
| 66 |
|
|---|
| 67 |
if ( $poll_id && ( !$poll_until || $poll_until > time() ) ) { |
|---|
| 68 |
$template->assign_block_vars('poll', array( |
|---|
| 69 |
'POLL_ID' => $poll_id, |
|---|
| 70 |
'U_VIEW_RESULT' => append_sid($root_path . '?vote=viewresult'), |
|---|
| 71 |
'IMG_BAR_LEFT' => $images['bar_left'], |
|---|
| 72 |
'IMG_BAR' => $images['bar'], |
|---|
| 73 |
'IMG_BAR_RIGHT' => $images['bar_right'] |
|---|
| 74 |
)); |
|---|
| 75 |
|
|---|
| 76 |
$sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result |
|---|
| 77 |
FROM ' . VOTE_DESC_TABLE . ' vd, ' . VOTE_RESULTS_TABLE . ' vr |
|---|
| 78 |
WHERE vd.topic_id = 0 |
|---|
| 79 |
AND vr.vote_id = vd.vote_id |
|---|
| 80 |
AND vd.vote_id = ' . $poll_id . ' |
|---|
| 81 |
ORDER BY vr.vote_option_id ASC'; |
|---|
| 82 |
$result = $db->sql_query($sql); |
|---|
| 83 |
|
|---|
| 84 |
if ( $vote_info = $db->sql_fetchrowset($result) ) { |
|---|
| 85 |
|
|---|
| 86 |
$db->sql_freeresult($result); |
|---|
| 87 |
|
|---|
| 88 |
$vote_options = sizeof($vote_info); |
|---|
| 89 |
|
|---|
| 90 |
$vote_id = $vote_info[0]['vote_id']; |
|---|
| 91 |
$vote_title = $vote_info[0]['vote_text']; |
|---|
| 92 |
|
|---|
| 93 |
$sql = 'SELECT vote_id |
|---|
| 94 |
FROM ' . VOTE_USERS_TABLE . ' |
|---|
| 95 |
WHERE vote_id = ' . $vote_id . ' |
|---|
| 96 |
AND vote_user_id = ' . $userdata['uid']; |
|---|
| 97 |
$result = $db->sql_query($sql); |
|---|
| 98 |
|
|---|
| 99 |
$user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0; |
|---|
| 100 |
$db->sql_freeresult($result); |
|---|
| 101 |
|
|---|
| 102 |
$vote = request_var('vote', ''); |
|---|
| 103 |
$vote_option_id = request_var('vote_option_id', 0); |
|---|
| 104 |
|
|---|
| 105 |
if ( $vote ) { |
|---|
| 106 |
|
|---|
| 107 |
$view_result = ( $vote == 'viewresult' ) ? TRUE : 0; |
|---|
| 108 |
|
|---|
| 109 |
if ( $vote_option_id ) { |
|---|
| 110 |
if ( $user_voted ) { |
|---|
| 111 |
trigger_error($lang['dupe_vote']); |
|---|
| 112 |
} |
|---|
| 113 |
else { |
|---|
| 114 |
$sql = "UPDATE " . VOTE_RESULTS_TABLE . " |
|---|
| 115 |
SET vote_result = vote_result + 1 |
|---|
| 116 |
WHERE vote_id = $vote_id |
|---|
| 117 |
AND vote_option_id = $vote_option_id"; |
|---|
| 118 |
|
|---|
| 119 |
$db->sql_query($sql); |
|---|
| 120 |
$sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip, vote_cast) |
|---|
| 121 |
VALUES ($vote_id, " . $userdata['uid'] . ", '$user_ip', $vote_option_id)"; |
|---|
| 122 |
$db->sql_query($sql); |
|---|
| 123 |
|
|---|
| 124 |
$user_voted_option_id = $vote_option_id; |
|---|
| 125 |
$user_voted = TRUE; |
|---|
| 126 |
} |
|---|
| 127 |
} |
|---|
| 128 |
} |
|---|
| 129 |
else { |
|---|
| 130 |
$view_result = 0; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0; |
|---|
| 134 |
|
|---|
| 135 |
if ( $user_voted || $view_result || $poll_expired ) { |
|---|
| 136 |
$template->assign_block_vars("poll.voted", array()); |
|---|
| 137 |
|
|---|
| 138 |
$vote_results_sum = 0; |
|---|
| 139 |
|
|---|
| 140 |
for($i = 0; $i < $vote_options; $i++) { |
|---|
| 141 |
$vote_results_sum += $vote_info[$i]['vote_result']; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
$vote_graphic = 0; |
|---|
| 145 |
$vote_graphic_max = sizeof($images['voting_graphic']); |
|---|
| 146 |
|
|---|
| 147 |
for($i = 0; $i < $vote_options; $i++) { |
|---|
| 148 |
if ( isset($user_voted_option_id) && $vote_info[$i]['vote_option_id'] == $user_voted_option_id ) { |
|---|
| 149 |
$vote_info[$i]['vote_result'] = $vote_info[$i]['vote_result'] + 1; |
|---|
| 150 |
$vote_results_sum = $vote_results_sum + 1; |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
if ( $vote_results_sum ) { |
|---|
| 154 |
$vote_percent = $vote_info[$i]['vote_result'] / $vote_results_sum * 100; |
|---|
| 155 |
} |
|---|
| 156 |
else { |
|---|
| 157 |
$vote_percent = 0; |
|---|
| 158 |
} |
|---|
| 159 |
$vote_graphic_length = round($vote_percent / 100 * $config['vote_graphic_length'] * 2); |
|---|
| 160 |
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0; |
|---|
| 161 |
|
|---|
| 162 |
$vote_option_text = $vote_info[$i]['vote_option_text']; |
|---|
| 163 |
$bb_code->parse($vote_option_text); |
|---|
| 164 |
$vote_option_text = $bb_code->get_html(); |
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
$vote_info[$i]['vote_option_text'] = $vote_option_text; |
|---|
| 168 |
|
|---|
| 169 |
$template->assign_block_vars("poll.voted.voted_row", array( |
|---|
| 170 |
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], |
|---|
| 171 |
'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'], |
|---|
| 172 |
'POLL_OPTION_PERCENT' => round($vote_percent) . '%', |
|---|
| 173 |
'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length) |
|---|
| 174 |
); |
|---|
| 175 |
} |
|---|
| 176 |
|
|---|
| 177 |
$template->assign_vars(array( |
|---|
| 178 |
'TOTAL_VOTES' => $vote_results_sum |
|---|
| 179 |
)); |
|---|
| 180 |
|
|---|
| 181 |
} |
|---|
| 182 |
else { |
|---|
| 183 |
$template->assign_block_vars("poll.no_voted", array( |
|---|
| 184 |
'S_FORM_ACTION' => append_sid($root_path . 'index.php') |
|---|
| 185 |
)); |
|---|
| 186 |
|
|---|
| 187 |
for($i = 0; $i < $vote_options; $i++) { |
|---|
| 188 |
$vote_option_text = $vote_info[$i]['vote_option_text']; |
|---|
| 189 |
$bb_code->parse($vote_option_text); |
|---|
| 190 |
$vote_option_text = $bb_code->get_html(); |
|---|
| 191 |
|
|---|
| 192 |
$template->assign_block_vars("poll.no_voted.novoted_row", array( |
|---|
| 193 |
'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'], |
|---|
| 194 |
'POLL_OPTION_CAPTION' => $vote_option_text |
|---|
| 195 |
)); |
|---|
| 196 |
} |
|---|
| 197 |
} |
|---|
| 198 |
$vote_title = censor_text($vote_title); |
|---|
| 199 |
|
|---|
| 200 |
$expire_time = ( $vote_info[0]['vote_length'] ? create_date($vote_info[0]['vote_start'] + $vote_info[0]['vote_length']) : 0 ); |
|---|
| 201 |
|
|---|
| 202 |
$bb_code->parse($vote_title); |
|---|
| 203 |
$vote_title = $bb_code->get_html(); |
|---|
| 204 |
|
|---|
| 205 |
$template->assign_vars(array( |
|---|
| 206 |
'POLL_QUESTION' => $vote_title, |
|---|
| 207 |
'S_THIS_POLL_WILL_EXPIRE_AT' => ( $expire_time ? ( $poll_expired ? sprintf($lang['this_poll_expired_at'], $expire_time ) : sprintf($lang['this_poll_will_expire_at'], $expire_time ) ) : '') ) |
|---|
| 208 |
); |
|---|
| 209 |
} |
|---|
| 210 |
} |
|---|
| 211 |
|
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
$template->assign_vars(array(</span> |
|---|
| 215 |
<span class="code-lang"> 'U_RELEASES' => append_sid('releases.php'), |
|---|
| 216 |
)); |
|---|
| 217 |
|
|---|
| 218 |
if ( $userdata['class'] >= UC_ADMINISTRATOR ) { |
|---|
| 219 |
$template->assign_block_vars('switch_admin_section', array()); |
|---|
| 220 |
} |
|---|
| 221 |
|
|---|
| 222 |
$sql = 'SELECT * FROM ' . NEWS_TABLE . ' WHERE added > ( UNIX_TIMESTAMP(NOW()) - 28 * 24 * 60 * 60 ) ORDER BY added DESC'; |
|---|
| 223 |
$result = $db->sql_query($sql, 10 * 24 * 60 * 60); |
|---|
| 224 |
$show_news = false;</span> |
|---|
| 225 |
<span class="code-lang">if( $row = $db->sql_fetchrow($result) ) { |
|---|
| 226 |
$news_ary = array(); |
|---|
| 227 |
do { |
|---|
| 228 |
$n_a_u_c = explode(',', $row['news_announce_user_classes']); |
|---|
| 229 |
if ( $n_a_u_c[0] == '' || in_array($userdata['class'], $n_a_u_c) || $userdata['class'] >= UC_MODERATOR ) { |
|---|
| 230 |
$show_news = true; |
|---|
| 231 |
$news_ary[] = $row; |
|---|
| 232 |
} |
|---|
| 233 |
} |
|---|
| 234 |
while ( $row = $db->sql_fetchrow($result) ); |
|---|
| 235 |
|
|---|
| 236 |
if ( $show_news ) { |
|---|
| 237 |
$i = 0; |
|---|
| 238 |
foreach ( $news_ary AS $key => $ary ) { |
|---|
| 239 |
|
|---|
| 240 |
$bb_code->parse($ary['body']); |
|---|
| 241 |
$ary['body'] = $bb_code->get_html(); |
|---|
| 242 |
|
|---|
| 243 |
$template->assign_block_vars('news_row', array( |
|---|
| 244 |
'ID' => $ary['id'], |
|---|
| 245 |
'ADDED' => create_date($ary['added'], 'M d'), |
|---|
| 246 |
'STYLE_DISPLAY' => ( $i ? 'none' : 'block' ), |
|---|
| 247 |
'PIC' => $root_path . 'pic/' . ( $i ? 'plus.gif' : 'minus.gif' ), |
|---|
| 248 |
'TITLE' => $ary['title'], |
|---|
| 249 |
'BODY' => $ary['body'], |
|---|
| 250 |
'U_ADD_COMMENT' => append_sid($root_path . 'comment.php', 'type=' . TYPE_NEWS . '&action=add&tid=' . $ary['id']), |
|---|
| 251 |
'COMMENTS_COUNT' => $ary['news_comments'], |
|---|
| 252 |
'DISABLE_COMMENTS' => $ary['news_disable_comments'] |
|---|
| 253 |
)); |
|---|
| 254 |
++$i; |
|---|
| 255 |
} |
|---|
| 256 |
} |
|---|
| 257 |
} |
|---|
| 258 |
|
|---|
| 259 |
$sql = 'SELECT COUNT(i.id) AS count</span> |
|---|
| 260 |
<span class="code-lang"> FROM ' . INDEXRELEASES_TABLE . ' i, ' . CATEGORIES_TABLE . ' c, ' . TORRENTS_TABLE . ' t |
|---|
| 261 |
WHERE t.category = c.id |
|---|
| 262 |
AND i.torrent_id = t.fid |
|---|
| 263 |
AND t.banned = 0 |
|---|
| 264 |
AND t.hidden = 0' . |
|---|
| 265 |
( $userdata['uid'] == ANONYMOUS ? ' AND c.anonymous_view = 1' : '' ); |
|---|
| 266 |
$result = $db->sql_query($sql, 31536000); |
|---|
| 267 |
$count = ( $row = $db->sql_fetchrow($result) ) ? $row['count'] : 0;</span> |
|---|
| 268 |
<span class="code-lang"> |
|---|
| 269 |
list($pagertop, $pagerbottom, $offset, $limit) = pager(6, $count, 'index.php?'); |
|---|
| 270 |
|
|---|
| 271 |
$sql = 'SELECT i.*, c.image AS category_image, c.name AS category_name, t.name AS torrent_name, t.category</span> |
|---|
| 272 |
<span class="code-lang"> FROM ' . INDEXRELEASES_TABLE . ' i, ' . CATEGORIES_TABLE . ' c, ' . TORRENTS_TABLE . ' t |
|---|
| 273 |
WHERE t.category = c.id |
|---|
| 274 |
AND i.torrent_id = t.fid |
|---|
| 275 |
AND t.banned = 0 |
|---|
| 276 |
AND t.hidden = 0' . |
|---|
| 277 |
( $userdata['uid'] == ANONYMOUS ? ' AND c.anonymous_view = 1' : '' ) |
|---|
| 278 |
. ' ORDER BY t.ctime DESC'; |
|---|
| 279 |
$result = $db->sql_query_limit($sql, $limit, $offset, 31536000); |
|---|
| 280 |
$show_releases = false;</span> |
|---|
| 281 |
<span class="code-lang">if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 282 |
$show_releases = true; |
|---|
| 283 |
do { |
|---|
| 284 |
$name = ( $row['name'] ? $row['name'] : $row['torrent_name'] ); |
|---|
| 285 |
|
|---|
| 286 |
$dispname = censor_text($name); |
|---|
| 287 |
|
|---|
| 288 |
$seo->set_torrent_url($row['torrent_id'], $name, $row['category']); |
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
$bb_code->parse($row['description']); |
|---|
| 292 |
$description = $bb_code->get_html(); |
|---|
| 293 |
$description = censor_text($description); |
|---|
| 294 |
|
|---|
| 295 |
$template->assign_block_vars('releases_row', array( |
|---|
| 296 |
'NAME' => $dispname, |
|---|
| 297 |
'ID' => $row['id'], |
|---|
| 298 |
'U_EDIT' => append_sid('releases.php?action=add&id=' . $row['id'] . '&returnto=index.php'), |
|---|
| 299 |
'U_DELETE' => append_sid('releases.php?action=delete&id=' . $row['id'] . '&returnto=index.php'), |
|---|
| 300 |
'U_CATEGORY' => append_sid($root_path . 'browse.php?cat=' . $row['category']), |
|---|
| 301 |
'U_DETAILS' => append_sid($root_path . 'details.php?id=' . $row['torrent_id']), |
|---|
| 302 |
'COVER' => $row['cover'], |
|---|
| 303 |
'CATEGORY' => $row['category'], |
|---|
| 304 |
'CATEGORY_IMAGE' => $root_path . 'pic/categories/' . $row['category_image'], |
|---|
| 305 |
'CATEGORY_NAME' => $row['category_name'], |
|---|
| 306 |
'DESCRIPTION' => $description, |
|---|
| 307 |
'IMDB_LINK' => ( $row['imdb_link'] ? ' [<a href="redir.php?url=' . $row['imdb_link'] . '" target="_blank">IMDB</a>]' : '' ), |
|---|
| 308 |
'FORUM_LINK' => ( $row['forum_link'] ? ' [<a href="' . append_sid($root_path . 'phpbb2.php?page=viewtopic&t=' . $row['forum_link']) . '" target="_blank">' . $lang['talk_at_forum'] . '</a>]' : '' ) |
|---|
| 309 |
)); |
|---|
| 310 |
} |
|---|
| 311 |
while ( $row = $db->sql_fetchrow($result) ); |
|---|
| 312 |
} |
|---|
| 313 |
|
|---|
| 314 |
$stats = $cache->get('_index_stats');</span> |
|---|
| 315 |
<span class="code-lang"> |
|---|
| 316 |
if ( $stats === false ) { |
|---|
| 317 |
$stats = array(); |
|---|
| 318 |
$stats['registered'] = get_row_count(USERS_TABLE) - 1; |
|---|
| 319 |
$stats['torrents'] = get_row_count(TORRENTS_TABLE); |
|---|
| 320 |
|
|---|
| 321 |
$sql = 'SELECT SUM(downloaded) AS totaldl, SUM(uploaded) AS totalul FROM ' . USERS_TABLE; |
|---|
| 322 |
$result = $db->sql_query($sql); |
|---|
| 323 |
$row = $db->sql_fetchrow($result); |
|---|
| 324 |
$stats['totaldownloaded'] = $row['totaldl']; |
|---|
| 325 |
$stats['totaluploaded'] = $row['totalul']; |
|---|
| 326 |
|
|---|
| 327 |
if ( defined('USE_XBTT') ) { |
|---|
| 328 |
$fp = @file_get_contents($config['xbt_listen_url'] . ':' . $config['listen_port'] . '/st'); |
|---|
| 329 |
if ( $fp !== false ) { |
|---|
| 330 |
preg_match('/leechers<td align=right>([0-9]+)<tr><td>seeders<td align=right>([0-9]+)<tr><td>peers<td align=right>([0-9]+)<tr><td>torrents<td align=right>([0-9]+)/', $fp, $matches); |
|---|
| 331 |
$stats['seeders'] = (int) $matches[2]; |
|---|
| 332 |
$stats['leechers'] = (int) $matches[1]; |
|---|
| 333 |
$stats['active_torrents'] = (int) $matches[4]; |
|---|
| 334 |
|
|---|
| 335 |
$stats['dead_torrents'] = $stats['torrents'] - $stats['active_torrents']; |
|---|
| 336 |
} |
|---|
| 337 |
else { |
|---|
| 338 |
$stats['seeders'] = get_row_count(PEERS_TABLE, 'WHERE `left` = 0 AND active = 1'); |
|---|
| 339 |
$stats['leechers'] = get_row_count(PEERS_TABLE, 'WHERE `left` <> 0 AND active = 1'); |
|---|
| 340 |
} |
|---|
| 341 |
} |
|---|
| 342 |
else { |
|---|
| 343 |
$stats['dead_torrents'] = get_row_count(TORRENTS_TABLE, 'WHERE visible = 0'); |
|---|
| 344 |
$stats['seeders'] = get_row_count(PEERS_TABLE, 'WHERE `left` = 0'); |
|---|
| 345 |
$stats['leechers'] = get_row_count(PEERS_TABLE, 'WHERE `left` <> 0'); |
|---|
| 346 |
} |
|---|
| 347 |
|
|---|
| 348 |
|
|---|
| 349 |
$stats['ratio'] = ( $stats['leechers'] ? round($stats['seeders'] / $stats['leechers'] * 100) : '∞'); |
|---|
| 350 |
$stats['total_peers'] = $stats['seeders'] + $stats['leechers']; |
|---|
| 351 |
|
|---|
| 352 |
$sql = 'SELECT COUNT( DISTINCT (uid) ) AS unique_leechers FROM ' . PEERS_TABLE . ' WHERE `left` <> 0' . ( defined('USE_XBTT') ? ' AND active = 1' : '' ); |
|---|
| 353 |
$result = $db->sql_query($sql); |
|---|
| 354 |
$stats['unique_leechers'] = ( $row = $db->sql_fetchrow($result) ) ? $row['unique_leechers'] : 0 ; |
|---|
| 355 |
|
|---|
| 356 |
$sql = 'SELECT COUNT( DISTINCT (uid) ) AS unique_seeders FROM ' . PEERS_TABLE . ' WHERE `left` = 0' . ( defined('USE_XBTT') ? ' AND active = 1' : '' ); |
|---|
| 357 |
$result = $db->sql_query($sql); |
|---|
| 358 |
$stats['unique_seeders'] = ( $row = $db->sql_fetchrow($result) ) ? $row['unique_seeders'] : 0 ; |
|---|
| 359 |
|
|---|
| 360 |
$stats['unique_peers'] = $stats['unique_leechers'] + $stats['unique_seeders']; |
|---|
| 361 |
|
|---|
| 362 |
$cache->put('_index_stats', $stats, 30 * 60); |
|---|
| 363 |
} |
|---|
| 364 |
|
|---|
| 365 |
$template->assign_vars(array(</span> |
|---|
| 366 |
<span class="code-lang"> 'SHOW_NEWS' => $show_news, |
|---|
| 367 |
'SHOW_RELEASES' => $show_releases, |
|---|
| 368 |
'PAGERBOTTOM' => $pagerbottom, |
|---|
| 369 |
|
|---|
| 370 |
'ONLINE_SINCE' => create_date($config['onlinesince'], 'Y-m-d'), |
|---|
| 371 |
'REGISTERED_USERS' => $stats['registered'], |
|---|
| 372 |
'TOTAL_TORRENTS' => $stats['torrents'], |
|---|
| 373 |
'DEAD_TORRENTS' => $stats['dead_torrents'], |
|---|
| 374 |
'TOTAL_PEERS' => $stats['total_peers'], |
|---|
| 375 |
'UNIQUE_PEERS' => $stats['unique_peers'], |
|---|
| 376 |
'UNIQUE_SEEDERS' => $stats['unique_seeders'], |
|---|
| 377 |
'UNIQUE_LEECHERS' => $stats['unique_leechers'], |
|---|
| 378 |
'SEEDERS' => $stats['seeders'], |
|---|
| 379 |
'LEECHERS' => $stats['leechers'], |
|---|
| 380 |
'UNIQUE_RATIO' => ( $stats['unique_leechers'] ? round($stats['unique_seeders'] / $stats['unique_leechers'] * 100) : '∞'), |
|---|
| 381 |
'RATIO' => $stats['ratio'], |
|---|
| 382 |
'TOTAL_DOWNLOADED' => mksize($stats['totaldownloaded']), |
|---|
| 383 |
'TOTAL_UPLOADED' => mksize($stats['totaluploaded']), |
|---|
| 384 |
'SHOW_PEERS_STATS' => $stats['total_peers'] |
|---|
| 385 |
)); |
|---|
| 386 |
|
|---|
| 387 |
stdhead($lang['index']); |
|---|
| 388 |
$template->set_filenames(array(</span> |
|---|
| 389 |
<span class="code-lang"> 'body' => 'index_body.html') |
|---|
| 390 |
); |
|---|
| 391 |
stdfoot(); |
|---|
| 392 |
?> |
|---|