if (!$PeerStatsLocked) { $Cache->cache_value('stats_peers_lock', 1, 30); $DB->query("\n\t\t\tSELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(uid)\n\t\t\tFROM xbt_files_users\n\t\t\tWHERE active = 1\n\t\t\tGROUP BY Type"); $PeerCount = $DB->to_array(0, MYSQLI_NUM, false); $SeederCount = $PeerCount['Seeding'][1] ?: 0; $LeecherCount = $PeerCount['Leeching'][1] ?: 0; $Cache->cache_value('stats_peers', array($LeecherCount, $SeederCount), 1209600); // 2 week cache $Cache->delete_value('stats_peers_lock'); } } else { $PeerStatsLocked = false; list($LeecherCount, $SeederCount) = $PeerStats; } if (!$PeerStatsLocked) { $Ratio = Format::get_ratio_html($SeederCount, $LeecherCount); $PeerCount = number_format($SeederCount + $LeecherCount); $SeederCount = number_format($SeederCount); $LeecherCount = number_format($LeecherCount); } else { $PeerCount = $SeederCount = $LeecherCount = $Ratio = 'Server busy'; } ?> <li>Peers: <?php echo $PeerCount; ?> </li> <li>Seeders: <?php echo $SeederCount; ?> </li>
" title="<?php echo Format::get_size($Downloaded, 5); ?> ">Downloaded: <?php echo Format::get_size($Downloaded); ?> </li> <?php } if ($Override = check_paranoia_here('ratio')) { ?> <li<?php echo $Override === 2 ? ' class="paranoia_override"' : ''; ?> >Ratio: <?php echo Format::get_ratio_html($Uploaded, $Downloaded); ?> </li> <?php } if (($Override = check_paranoia_here('requiredratio')) && isset($RequiredRatio)) { ?> <li<?php echo $Override === 2 ? ' class="paranoia_override"' : ''; ?> >Required Ratio: <span class="tooltip" title="<?php echo number_format((double) $RequiredRatio, 5); ?> "><?php echo number_format((double) $RequiredRatio, 2); ?>
if ($EnableUser != $Cur['Enabled'] && check_perms('users_disable_users')) { $EnableStr = 'account ' . translateUserStatus($Cur['Enabled']) . '->' . translateUserStatus($EnableUser); if ($EnableUser == '2') { Tools::disable_users($UserID, '', 1); $TrackerUserUpdates = array(); } elseif ($EnableUser == '1') { $Cache->increment('stats_user_count'); $VisibleTrIP = $Visible && $Cur['IP'] != '127.0.0.1' ? '1' : '0'; Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'], 'visible' => $VisibleTrIP)); if ($Cur['Downloaded'] == 0 || $Cur['Uploaded'] / $Cur['Downloaded'] >= $Cur['RequiredRatio']) { $UpdateSet[] = "i.RatioWatchEnds = '0000-00-00 00:00:00'"; $CanLeech = 1; $UpdateSet[] = "m.can_leech = '1'"; $UpdateSet[] = "i.RatioWatchDownload = '0'"; } else { $EnableStr .= ' (Ratio: ' . Format::get_ratio_html($Cur['Uploaded'], $Cur['Downloaded'], false) . ', RR: ' . number_format($Cur['RequiredRatio'], 2) . ')'; if ($Cur['RatioWatchEnds'] != '0000-00-00 00:00:00') { $UpdateSet[] = "i.RatioWatchEnds = NOW()"; $UpdateSet[] = "i.RatioWatchDownload = m.Downloaded"; $CanLeech = 0; } $TrackerUserUpdates['can_leech'] = 0; } $UpdateSet[] = "Enabled = '1'"; $LightUpdates['Enabled'] = 1; } $EditSummary[] = $EnableStr; $Cache->replace_value("enabled_{$UserID}", $EnableUser, 0); } if ($ResetPasskey == 1 && check_perms('users_edit_reset_keys')) { $Passkey = db_string(Users::make_secret());
<input type="hidden" id="current_rr" value="<?php echo (double) $LoggedUser['RequiredRatio']; ?> " /> <input id="total_bounty" type="hidden" value="<?php echo $RequestVotes['TotalBounty']; ?> " /> Bounty after tax: <strong><span id="bounty_after_tax">0.00 MB</span></strong><br /> If you add the entered <strong><span id="new_bounty">0.00 MB</span></strong> of bounty, your new stats will be: <br /> Uploaded: <span id="new_uploaded"><?php echo Format::get_size($LoggedUser['BytesUploaded']); ?> </span><br /> Ratio: <span id="new_ratio"><?php echo Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded']); ?> </span> <input type="button" id="button" value="Vote!" disabled="disabled" onclick="Vote();" /> </form> </td> </tr> <?php } ?> <tr id="bounty"> <td class="label">Bounty</td> <td id="formatted_bounty"><?php echo Format::get_size($RequestVotes['TotalBounty']); ?> </td>
function make_tree() { $QueryID = G::$DB->get_query_id(); $UserID = $this->UserID; ?> <div class="invitetree pad"> <?php G::$DB->query("\n\t\t\tSELECT TreePosition, TreeID, TreeLevel\n\t\t\tFROM invite_tree\n\t\t\tWHERE UserID = {$UserID}"); list($TreePosition, $TreeID, $TreeLevel) = G::$DB->next_record(MYSQLI_NUM, false); if (!$TreeID) { return; } G::$DB->query("\n\t\t\tSELECT TreePosition\n\t\t\tFROM invite_tree\n\t\t\tWHERE TreeID = {$TreeID}\n\t\t\t\tAND TreeLevel = {$TreeLevel}\n\t\t\t\tAND TreePosition > {$TreePosition}\n\t\t\tORDER BY TreePosition ASC\n\t\t\tLIMIT 1"); if (G::$DB->has_results()) { list($MaxPosition) = G::$DB->next_record(MYSQLI_NUM, false); } else { $MaxPosition = false; } $TreeQuery = G::$DB->query("\n\t\t\tSELECT\n\t\t\t\tit.UserID,\n\t\t\t\tEnabled,\n\t\t\t\tPermissionID,\n\t\t\t\tDonor,\n\t\t\t\tUploaded,\n\t\t\t\tDownloaded,\n\t\t\t\tParanoia,\n\t\t\t\tTreePosition,\n\t\t\t\tTreeLevel\n\t\t\tFROM invite_tree AS it\n\t\t\t\tJOIN users_main AS um ON um.ID = it.UserID\n\t\t\t\tJOIN users_info AS ui ON ui.UserID = it.UserID\n\t\t\tWHERE TreeID = {$TreeID}\n\t\t\t\tAND TreePosition > {$TreePosition}" . ($MaxPosition ? " AND TreePosition < {$MaxPosition}" : '') . "\n\t\t\t\tAND TreeLevel > {$TreeLevel}\n\t\t\tORDER BY TreePosition"); $PreviousTreeLevel = $TreeLevel; // Stats for the summary $MaxTreeLevel = $TreeLevel; // The deepest level (this changes) $OriginalTreeLevel = $TreeLevel; // The level of the user we're viewing $BaseTreeLevel = $TreeLevel + 1; // The level of users invited by our user $Count = 0; $Branches = 0; $DisabledCount = 0; $DonorCount = 0; $ParanoidCount = 0; $TotalUpload = 0; $TotalDownload = 0; $TopLevelUpload = 0; $TopLevelDownload = 0; $ClassSummary = array(); global $Classes; foreach ($Classes as $ClassID => $Val) { $ClassSummary[$ClassID] = 0; } // We store this in an output buffer, so we can show the summary at the top without having to loop through twice ob_start(); while (list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = G::$DB->next_record(MYSQLI_NUM, false)) { // Do stats $Count++; if ($TreeLevel > $MaxTreeLevel) { $MaxTreeLevel = $TreeLevel; } if ($TreeLevel == $BaseTreeLevel) { $Branches++; $TopLevelUpload += $Uploaded; $TopLevelDownload += $Downloaded; } $ClassSummary[$Class]++; if ($Enabled == 2) { $DisabledCount++; } if ($Donor) { $DonorCount++; } // Manage tree depth if ($TreeLevel > $PreviousTreeLevel) { for ($i = 0; $i < $TreeLevel - $PreviousTreeLevel; $i++) { echo "\n\n<ul class=\"invitetree\">\n\t<li>\n"; } } elseif ($TreeLevel < $PreviousTreeLevel) { for ($i = 0; $i < $PreviousTreeLevel - $TreeLevel; $i++) { echo "\t</li>\n</ul>\n"; } echo "\t</li>\n\t<li>\n"; } else { echo "\t</li>\n\t<li>\n"; } $UserClass = $Classes[$Class]['Level']; ?> <strong><?php echo Users::format_username($ID, true, true, $Enabled != 2 ? false : true, true); ?> </strong> <?php if (check_paranoia(array('uploaded', 'downloaded'), $Paranoia, $UserClass)) { $TotalUpload += $Uploaded; $TotalDownload += $Downloaded; ?> Uploaded: <strong><?php echo Format::get_size($Uploaded); ?> </strong> Downloaded: <strong><?php echo Format::get_size($Downloaded); ?> </strong> Ratio: <strong><?php echo Format::get_ratio_html($Uploaded, $Downloaded); ?> </strong> <?php } else { $ParanoidCount++; ?> Hidden <?php } ?> <?php $PreviousTreeLevel = $TreeLevel; G::$DB->set_query_id($TreeQuery); } $Tree = ob_get_clean(); for ($i = 0; $i < $PreviousTreeLevel - $OriginalTreeLevel; $i++) { $Tree .= "\t</li>\n</ul>\n"; } if ($Count) { ?> <p style="font-weight: bold;"> This tree has <?php echo number_format($Count); ?> entries, <?php echo number_format($Branches); ?> branches, and a depth of <?php echo number_format($MaxTreeLevel - $OriginalTreeLevel); ?> . It has <?php $ClassStrings = array(); foreach ($ClassSummary as $ClassID => $ClassCount) { if ($ClassCount == 0) { continue; } $LastClass = Users::make_class_string($ClassID); if ($ClassCount > 1) { if ($LastClass == 'Torrent Celebrity') { $LastClass = 'Torrent Celebrities'; } else { $LastClass .= 's'; } } $LastClass = "{$ClassCount} {$LastClass} (" . number_format($ClassCount / $Count * 100) . '%)'; $ClassStrings[] = $LastClass; } if (count($ClassStrings) > 1) { array_pop($ClassStrings); echo implode(', ', $ClassStrings); echo ' and ' . $LastClass; } else { echo $LastClass; } echo '. '; echo $DisabledCount; echo $DisabledCount == 1 ? ' user is' : ' users are'; echo ' disabled ('; if ($DisabledCount == 0) { echo '0%)'; } else { echo number_format($DisabledCount / $Count * 100) . '%)'; } echo ', and '; echo $DonorCount; echo $DonorCount == 1 ? ' user has' : ' users have'; echo ' donated ('; if ($DonorCount == 0) { echo '0%)'; } else { echo number_format($DonorCount / $Count * 100) . '%)'; } echo '. </p>'; echo '<p style="font-weight: bold;">'; echo 'The total amount uploaded by the entire tree was ' . Format::get_size($TotalUpload); echo '; the total amount downloaded was ' . Format::get_size($TotalDownload); echo '; and the total ratio is ' . Format::get_ratio_html($TotalUpload, $TotalDownload) . '. '; echo '</p>'; echo '<p style="font-weight: bold;">'; echo 'The total amount uploaded by direct invitees (the top level) was ' . Format::get_size($TopLevelUpload); echo '; the total amount downloaded was ' . Format::get_size($TopLevelDownload); echo '; and the total ratio is ' . Format::get_ratio_html($TopLevelUpload, $TopLevelDownload) . '. '; echo "These numbers include the stats of paranoid users and will be factored into the invitation giving script.\n\t\t</p>\n"; if ($ParanoidCount) { echo '<p style="font-weight: bold;">'; echo $ParanoidCount; echo $ParanoidCount == 1 ? ' user (' : ' users ('; echo number_format($ParanoidCount / $Count * 100); echo '%) '; echo $ParanoidCount == 1 ? ' is' : ' are'; echo ' too paranoid to have their stats shown here, and '; echo $ParanoidCount == 1 ? ' was' : ' were'; echo ' not factored into the stats for the total tree.'; echo '</p>'; } } ?> <br /> <?php echo $Tree; ?> </div> <?php G::$DB->set_query_id($QueryID); }
function generate_user_table($Caption, $Tag, $Details, $Limit) { global $Time; ?> <h3>Top <?php echo $Limit . ' ' . $Caption; ?> <small class="top10_quantity_links"> <?php switch ($Limit) { case 100: ?> - <a href="top10.php?type=users&details=<?php echo $Tag; ?> " class="brackets">Top 10</a> - <span class="brackets">Top 100</span> - <a href="top10.php?type=users&limit=250&details=<?php echo $Tag; ?> " class="brackets">Top 250</a> <?php break; case 250: ?> - <a href="top10.php?type=users&details=<?php echo $Tag; ?> " class="brackets">Top 10</a> - <a href="top10.php?type=users&limit=100&details=<?php echo $Tag; ?> " class="brackets">Top 100</a> - <span class="brackets">Top 250</span> <?php break; default: ?> - <span class="brackets">Top 10</span> - <a href="top10.php?type=users&limit=100&details=<?php echo $Tag; ?> " class="brackets">Top 100</a> - <a href="top10.php?type=users&limit=250&details=<?php echo $Tag; ?> " class="brackets">Top 250</a> <?php } ?> </small> </h3> <table class="border"> <tr class="colhead"> <td class="center">Rank</td> <td>User</td> <td style="text-align: right;">Uploaded</td> <td style="text-align: right;">UL speed</td> <td style="text-align: right;">Downloaded</td> <td style="text-align: right;">DL speed</td> <td style="text-align: right;">Uploads</td> <td style="text-align: right;">Ratio</td> <td style="text-align: right;">Joined</td> </tr> <?php // in the unlikely event that query finds 0 rows... if (empty($Details)) { echo ' <tr class="rowb"> <td colspan="9" class="center"> Found no users matching the criteria </td> </tr> </table><br />'; return; } $Rank = 0; foreach ($Details as $Detail) { $Rank++; $Highlight = $Rank % 2 ? 'a' : 'b'; ?> <tr class="row<?php echo $Highlight; ?> "> <td class="center"><?php echo $Rank; ?> </td> <td><?php echo Users::format_username($Detail['ID'], false, false, false); ?> </td> <td class="number_column"><?php echo Format::get_size($Detail['Uploaded']); ?> </td> <td class="number_column tooltip" title="Upload speed is reported in base 2 in bytes per second, not bits per second."><?php echo Format::get_size($Detail['UpSpeed']); ?> /s</td> <td class="number_column"><?php echo Format::get_size($Detail['Downloaded']); ?> </td> <td class="number_column tooltip" title="Download speed is reported in base 2 in bytes per second, not bits per second."><?php echo Format::get_size($Detail['DownSpeed']); ?> /s</td> <td class="number_column"><?php echo number_format($Detail['NumUploads']); ?> </td> <td class="number_column"><?php echo Format::get_ratio_html($Detail['Uploaded'], $Detail['Downloaded']); ?> </td> <td class="number_column"><?php echo time_diff($Detail['JoinDate']); ?> </td> </tr> <?php } ?> </table><br /> <?php }
?> </li> <li><strong>Total peers: </strong><?php echo number_format($TotalSeeders + $TotalLeechers); ?> </li> <li><strong>Total snatches: </strong><?php echo number_format($TotalOverallSnatches); ?> </li> <li><strong>Seeder/leecher ratio: </strong><?php echo Format::get_ratio_html($TotalSeeders, $TotalLeechers); ?> </li> <li><strong>Seeder/snatch ratio: </strong><?php echo Format::get_ratio_html($TotalSeeders, $TotalOverallSnatches); ?> </li> <br /> <li><strong>Mean seeders per torrent: </strong><?php echo number_format($TotalSeeders / $TotalTorrents, 2); ?> </li> <li><strong>Mean leechers per torrent: </strong><?php echo number_format($TotalLeechers / $TotalTorrents, 2); ?> </li> <li><strong>Mean snatches per torrent: </strong><?php echo number_format($TotalSnatches / $TotalTorrents, 2); ?> </li>
<tr class="row<?php echo $Row; ?> "> <td><?php echo Users::format_username($UserID, true, true, true, true); ?> <br /><?php echo Users::format_username($InviterID, true, true, true, true); ?> </td> <td><?php echo Format::get_ratio_html($Uploaded, $Downloaded); ?> <br /><?php echo Format::get_ratio_html($InviterUploaded, $InviterDownloaded); ?> </td> <td> <span style="float: left;"><?php echo display_str($Email); ?> </span> <span style="float: right;"><a href="userhistory.php?action=email&userid=<?php echo $UserID; ?> " title="History" class="brackets tooltip">H</a> <a href="/user.php?action=search&email_history=on&email=<?php echo display_str($Email); ?> " title="Search" class="brackets tooltip">S</a></span><br /> <span style="float: left;"><?php