$Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache } $UserCount = (int) $UserCount; ?> <li>Enabled users: <?php echo number_format($UserCount); ?> <a href="stats.php?action=users" class="brackets">Details</a></li> <?php if (($UserStats = $Cache->get_value('stats_users')) === false) { $DB->query("\n\t\tSELECT COUNT(ID)\n\t\tFROM users_main\n\t\tWHERE Enabled = '1'\n\t\t\tAND LastAccess > '" . time_minus(3600 * 24) . "'"); list($UserStats['Day']) = $DB->next_record(); $DB->query("\n\t\tSELECT COUNT(ID)\n\t\tFROM users_main\n\t\tWHERE Enabled = '1'\n\t\t\tAND LastAccess > '" . time_minus(3600 * 24 * 7) . "'"); list($UserStats['Week']) = $DB->next_record(); $DB->query("\n\t\tSELECT COUNT(ID)\n\t\tFROM users_main\n\t\tWHERE Enabled = '1'\n\t\t\tAND LastAccess > '" . time_minus(3600 * 24 * 30) . "'"); list($UserStats['Month']) = $DB->next_record(); $Cache->cache_value('stats_users', $UserStats, 0); } ?> <li>Users active today: <?php echo number_format($UserStats['Day']); ?> (<?php echo number_format($UserStats['Day'] / $UserCount * 100, 2); ?> %)</li> <li>Users active this week: <?php echo number_format($UserStats['Week']); ?> (<?php
$DayAgo = time_minus(86400); $Query = $BaseQuery . ' WHERE t.Seeders>0 AND '; if (!empty($Where)) { $Query .= $Where . ' AND '; } $Query .= "\n\t\t\tt.Time>'{$DayAgo}'\n\t\t\tORDER BY (t.Seeders + t.Leechers) DESC\n\t\t\tLIMIT {$Limit};"; $DB->query($Query); $TopTorrentsActiveLastDay = $DB->to_array(); // TODO: MYSQLI_NUM to avoid duplicate data in the cache (does that break something with generate_torrent_json?) $Cache->cache_value('top10tor_day_' . $Limit . $WhereSum, $TopTorrentsActiveLastDay, 3600 * 2); } $OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit); } if ($Details == 'all' || $Details == 'week') { if (!($TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_' . $Limit . $WhereSum))) { $WeekAgo = time_minus(604800); $Query = $BaseQuery . ' WHERE '; if (!empty($Where)) { $Query .= $Where . ' AND '; } $Query .= "\n\t\t\tt.Time>'{$WeekAgo}'\n\t\t\tORDER BY (t.Seeders + t.Leechers) DESC\n\t\t\tLIMIT {$Limit};"; $DB->query($Query); $TopTorrentsActiveLastWeek = $DB->to_array(); $Cache->cache_value('top10tor_week_' . $Limit . $WhereSum, $TopTorrentsActiveLastWeek, 3600 * 6); } $OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit); } if ($Details == 'all' || $Details == 'overall') { if (!($TopTorrentsActiveAllTime = $Cache->get_value("top10tor_overall_{$Limit}{$WhereSum}"))) { // IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it! $Query = $BaseQuery;
$Cache->begin_transaction("thread_{$ID}" . '_info'); $Cache->update_row(false, array('IsLocked' => '1')); $Cache->commit_transaction(3600 * 24 * 30); $Cache->expire_value("thread_{$ID}" . '_catalogue_0', 3600 * 24 * 30); $Cache->expire_value("thread_{$ID}" . '_info', 3600 * 24 * 30); Forums::add_topic_note($ID, 'Locked automatically by schedule', 0); } $ForumIDs = array_flip(array_flip($ForumIDs)); foreach ($ForumIDs as $ForumID) { $Cache->delete_value("forums_{$ForumID}"); } } echo "Old threads locked\n"; //------------- Delete dead torrents ------------------------------------// sleep(10); $DB->query("\n\t\tSELECT\n\t\t\tt.ID,\n\t\t\tt.GroupID,\n\t\t\ttg.Name,\n\t\t\tt.Format,\n\t\t\tt.Encoding,\n\t\t\tt.UserID,\n\t\t\tt.Media,\n\t\t\tHEX(t.info_hash) AS InfoHash\n\t\tFROM torrents AS t\n\t\t\tJOIN torrents_group AS tg ON tg.ID = t.GroupID\n\t\tWHERE\n\t\t\t(t.last_action < '" . time_minus(3600 * 24 * 28) . "' AND t.last_action != 0)\n\t\t\tOR\n\t\t\t(t.Time < '" . time_minus(3600 * 24 * 2) . "' AND t.last_action = 0)"); $Torrents = $DB->to_array(false, MYSQLI_NUM, false); echo 'Found ' . count($Torrents) . " inactive torrents to be deleted.\n"; $LogEntries = $DeleteNotes = array(); // Exceptions for inactivity deletion $InactivityExceptionsMade = array(); $i = 0; foreach ($Torrents as $Torrent) { list($ID, $GroupID, $Name, $Format, $Encoding, $UserID, $Media, $InfoHash) = $Torrent; if (array_key_exists($UserID, $InactivityExceptionsMade) && time() < $InactivityExceptionsMade[$UserID]) { // don't delete the torrent! continue; } $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false); if ($ArtistName) { $Name = "{$ArtistName} - {$Name}";
<?php authorize(); if (!isset($_GET['forumid']) || $_GET['forumid'] != 'all' && !is_number($_GET['forumid'])) { error(403); } if ($_GET['forumid'] == 'all') { $DB->query("\n\t\tUPDATE users_info\n\t\tSET CatchupTime = NOW()\n\t\tWHERE UserID = {$LoggedUser['ID']}"); $Cache->delete_value('user_info_' . $LoggedUser['ID']); header('Location: forums.php'); } else { // Insert a value for each topic $DB->query("\n\t\tINSERT INTO forums_last_read_topics (UserID, TopicID, PostID)\n\t\tSELECT '{$LoggedUser['ID']}', ID, LastPostID\n\t\tFROM forums_topics\n\t\tWHERE (LastPostTime > '" . time_minus(3600 * 24 * 30) . "' OR IsSticky = '1')\n\t\t\tAND ForumID = " . $_GET['forumid'] . "\n\t\tON DUPLICATE KEY UPDATE\n\t\t\tPostID = LastPostID"); header('Location: forums.php?action=viewforum&forumid=' . $_GET['forumid']); }
$Search = db_string($_GET['search']); } else { $Search = false; } $Words = explode(' ', $Search); $SQL = ' SELECT SQL_CALC_FOUND_ROWS ID, Message, Time FROM log '; if ($Search) { $SQL .= "WHERE Message LIKE '%"; $SQL .= implode("%' AND Message LIKE '%", $Words); $SQL .= "%' "; } if (!check_perms('site_view_full_log')) { if ($Search) { $SQL .= ' AND '; } else { $SQL .= ' WHERE '; } $SQL .= " Time>'" . time_minus(3600 * 24 * 28) . "' "; } $SQL .= "\n\tORDER BY ID DESC\n\tLIMIT {$Limit}"; $Log = $DB->query($SQL); $DB->query('SELECT FOUND_ROWS()'); list($NumResults) = $DB->next_record(); $TotalMatches = $NumResults; $DB->set_query_id($Log);
} $UserCount = (int)$UserCount; ?> <li>Enabled Users: <?php echo number_format($UserCount); ?> [<a href="stats.php?action=users">Details</a>]</li> <? if (!$UserStats = $Cache->get_value('stats_users')) { $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600*24)."'"); list($UserStats['Day']) = $DB->next_record(); $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600*24*7)."'"); list($UserStats['Week']) = $DB->next_record(); $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600*24*30)."'"); list($UserStats['Month']) = $DB->next_record(); $Cache->cache_value('stats_users',$UserStats,0); } ?> <li>Users active today: <?php echo number_format($UserStats['Day']); ?> (<?php echo number_format($UserStats['Day'] / $UserCount * 100, 2); ?> %)</li> <li>Users active this week: <?php echo number_format($UserStats['Week']); ?>
<?php if (!check_perms('users_view_ips') || !check_perms('users_view_email')) { error(403); } show_header('Registration log'); define('USERS_PER_PAGE', 50); list($Page, $Limit) = page_limit(USERS_PER_PAGE); $RS = $DB->query("SELECT \n\tSQL_CALC_FOUND_ROWS\n\tm.ID,\n\tm.IP,\n\tm.Email,\n\tm.Username,\n\tm.PermissionID,\n\tm.Uploaded,\n\tm.Downloaded,\n\tm.Enabled,\n\ti.Donor,\n\ti.Warned,\n\ti.JoinDate,\n\t(SELECT COUNT(h1.UserID) FROM users_history_ips AS h1 WHERE h1.IP=m.IP) AS Uses,\n\tim.ID,\n\tim.IP,\n\tim.Email,\n\tim.Username,\n\tim.PermissionID,\n\tim.Uploaded,\n\tim.Downloaded,\n\tim.Enabled,\n\tii.Donor,\n\tii.Warned,\n\tii.JoinDate,\n\t(SELECT COUNT(h2.UserID) FROM users_history_ips AS h2 WHERE h2.IP=im.IP) AS InviterUses \n\tFROM users_main AS m \n\tLEFT JOIN users_info AS i ON i.UserID=m.ID\n\tLEFT JOIN users_main AS im ON i.Inviter = im.ID\n\tLEFT JOIN users_info AS ii ON i.Inviter = ii.UserID\n\tWHERE i.JoinDate > '" . time_minus(3600 * 24 * 14) . "' \n\tORDER BY i.Joindate DESC LIMIT {$Limit}"); $DB->query("SELECT FOUND_ROWS()"); list($Results) = $DB->next_record(); $DB->set_query_id($RS); if ($DB->record_count()) { ?> <div class="linkbox"> <?php $Pages = get_pages($Page, $Results, USERS_PER_PAGE, 11); echo $Pages; ?> </div> <table width="100%"> <tr class="colhead"> <td>User</td> <td>Ratio</td> <td>Email</td> <td>IP</td> <td>Host</td> <td>Registered</td> </tr> <?php while (list($UserID, $IP, $Email, $Username, $PermissionID, $Uploaded, $Downloaded, $Enabled, $Donor, $Warned, $Joined, $Uses, $InviterID, $InviterIP, $InviterEmail, $InviterUsername, $InviterPermissionID, $InviterUploaded, $InviterDownloaded, $InviterEnabled, $InviterDonor, $InviterWarned, $InviterJoined, $InviterUses) = $DB->next_record()) {
die; } elseif (array_key_exists($_POST['type'], $Types[$CategoryID])) { $Type = $_POST['type']; $ReportType = $Types[$CategoryID][$Type]; } elseif (array_key_exists($_POST['type'], $Types['master'])) { $Type = $_POST['type']; $ReportType = $Types['master'][$Type]; } else { //There was a type but it wasn't an option! echo 'Wrong type'; die; } $ExtraID = db_string($_POST['otherid']); if (!empty($_POST['extra'])) { $Extra = db_string($_POST['extra']); } else { $Extra = ''; } if (!empty($Err)) { echo $Err; die; } $DB->query("\n\tSELECT ID\n\tFROM reportsv2\n\tWHERE TorrentID = {$TorrentID}\n\t\tAND ReporterID = " . db_string($LoggedUser['ID']) . "\n\t\tAND ReportedTime > '" . time_minus(3) . "'"); if ($DB->has_results()) { die; } $DB->query("\n\tINSERT INTO reportsv2\n\t\t(ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, ExtraID)\n\tVALUES\n\t\t(" . db_string($LoggedUser['ID']) . ", {$TorrentID}, '{$Type}', '{$Extra}', 'New', '" . sqltime() . "', '{$ExtraID}')"); $ReportID = $DB->inserted_id(); $Cache->delete_value("reports_torrent_{$TorrentID}"); $Cache->increment('num_torrent_reportsv2'); echo $ReportID;
<?php die("promotion, check source"); $Criteria = array(); $Criteria[] = array('From' => USER, 'To' => MEMBER, 'MinUpload' => 10 * 1024 * 1024 * 1024, 'MinRatio' => 0, 'MinUploads' => 0, 'MaxTime' => time_minus(3600 * 24 * 7)); $Criteria[] = array('From' => MEMBER, 'To' => POWER, 'MinUpload' => 25 * 1024 * 1024 * 1024, 'MinRatio' => 0, 'MinUploads' => 5, 'MaxTime' => time_minus(3600 * 24 * 7 * 2)); $Criteria[] = array('From' => POWER, 'To' => ELITE, 'MinUpload' => 100 * 1024 * 1024 * 1024, 'MinRatio' => 0, 'MinUploads' => 50, 'MaxTime' => time_minus(3600 * 24 * 7 * 4)); $Criteria[] = array('From' => ELITE, 'To' => TORRENT_MASTER, 'MinUpload' => 500 * 1024 * 1024 * 1024, 'MinRatio' => 0, 'MinUploads' => 500, 'MaxTime' => time_minus(3600 * 24 * 7 * 8)); foreach ($Criteria as $L) { // $L = Level $Query = "SELECT ID FROM users_main JOIN users_info ON users_main.ID = users_info.UserID\n WHERE PermissionID=" . $L['From'] . "\n AND Warned= '0000-00-00 00:00:00'\n AND Uploaded>='{$L['MinUpload']}'\n AND (Uploaded/Downloaded >='{$L['MinRatio']}' OR (Uploaded/Downloaded IS NULL))\n AND JoinDate<'{$L['MaxTime']}'\n AND (SELECT COUNT(ID) FROM torrents WHERE UserID=users_main.ID)>='{$L['MinUploads']}'\n AND Enabled='1'"; if (!empty($L['Extra'])) { $Query .= ' AND ' . $L['Extra']; } $DB->query($Query); $UserIDs = $DB->collect('ID'); if (count($UserIDs) > 0) { foreach ($UserIDs as $UserID) { /*$Cache->begin_transaction('user_info_'.$UserID); $Cache->update_row(false, array('PermissionID'=>$L['To'])); $Cache->commit_transaction(0);*/ $Cache->delete_value('user_info_' . $UserID); $Cache->delete_value('user_info_heavy_' . $UserID); $Cache->delete_value('user_stats_' . $UserID); $Cache->delete_value('enabled_' . $UserID); $DB->query("UPDATE users_info SET AdminComment = CONCAT('" . sqltime() . " - Class changed to " . make_class_string($L['To']) . " by System\n\n', AdminComment) WHERE UserID = " . $UserID); } $DB->query("UPDATE users_main SET PermissionID=" . $L['To'] . " WHERE ID IN(" . implode(',', $UserIDs) . ")"); } $Query = "SELECT ID FROM users_main JOIN users_info ON users_main.ID = users_info.UserID\n WHERE PermissionID='{$L['To']}'\n AND ( Uploaded<'{$L['MinUpload']}'\n OR (SELECT COUNT(ID) FROM torrents WHERE UserID=users_main.ID)<'{$L['MinUploads']}'"; if (!empty($L['Extra'])) {
<? authorize(); if(!isset($_GET['forumid']) || ($_GET['forumid']!='all' && !is_number($_GET['forumid']))) { error(403); } if ($_GET['forumid']=='all') { $DB->query("UPDATE users_info SET CatchupTime=NOW() WHERE UserID=$LoggedUser[ID]"); $Cache->delete_value('user_info_'.$LoggedUser['ID']); header('Location: forums.php'); } else { // Insert a value for each topic $DB->query("INSERT INTO forums_last_read_topics (UserID, TopicID, PostID) SELECT '$LoggedUser[ID]', ID, LastPostID FROM forums_topics WHERE (LastPostTime>'".time_minus(3600*24*30)."' OR IsSticky='1') AND ForumID = ".$_GET['forumid']." ON DUPLICATE KEY UPDATE PostID=LastPostID"); header('Location: forums.php?action=viewforum&forumid='.$_GET['forumid']); } ?>
$i = 0; $DB->query("SELECT t.ID, t.GroupID, tg.Name, ag.Name, t.last_action, t.Format, t.Encoding, t.UserID FROM torrents AS t JOIN torrents_group AS tg ON tg.ID=t.GroupID LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID WHERE t.last_action<'".time_minus(3600*24*28)."' AND t.last_action!='0000-00-00 00:00:00' OR t.Time<'".time_minus(3600*24*14)."' AND t.last_action='0000-00-00 00:00:00'"); $TorrentIDs = $DB->to_array(); $LogEntries = array(); foreach ($TorrentIDs as $TorrentID) { list($ID, $GroupID, $Name, $ArtistName, $LastAction, $Format, $Encoding, $UserID) = $TorrentID; if($ArtistName) { $Name = $ArtistName.' - '.$Name; } if($Format && $Encoding) { $Name.=' ['.$Format.' / '.$Encoding.']'; } delete_torrent($ID, $GroupID); $LogEntries[] = "Torrent ".$ID." (".$Name.") was deleted for inactivity (unseeded)";
im.IP, im.Email, im.Username, im.PermissionID, im.Uploaded, im.Downloaded, im.Enabled, ii.Donor, ii.Warned, ii.JoinDate, (SELECT COUNT(h2.UserID) FROM users_history_ips AS h2 WHERE h2.IP=im.IP) AS InviterUses FROM users_main AS m LEFT JOIN users_info AS i ON i.UserID=m.ID LEFT JOIN users_main AS im ON i.Inviter = im.ID LEFT JOIN users_info AS ii ON i.Inviter = ii.UserID WHERE i.JoinDate > '".time_minus(3600*24*3)."' ORDER BY i.Joindate DESC LIMIT $Limit"); $DB->query("SELECT FOUND_ROWS()"); list($Results) = $DB->next_record(); $DB->set_query_id($RS); if($DB->record_count()) { ?> <div class="linkbox"> <? $Pages=get_pages($Page,$Results,USERS_PER_PAGE,11) ; echo $Pages; ?> </div> <table width="100%"> <tr class="colhead">
if (!checkdate($M, $D, $Y)) { error('Incorrect "after" date format'); } list($Y, $M, $D) = explode('-', $BeforeDate); if (!checkdate($M, $D, $Y)) { error('Incorrect "before" date format'); } $AfterDate = db_string($AfterDate); $BeforeDate = db_string($BeforeDate); $DateSearch = true; } $RS = "\n\tSELECT\n\t\tSQL_CALC_FOUND_ROWS\n\t\tm.ID,\n\t\tm.IP,\n\t\tm.ipcc,\n\t\tm.Email,\n\t\tm.Username,\n\t\tm.PermissionID,\n\t\tm.Uploaded,\n\t\tm.Downloaded,\n\t\tm.Enabled,\n\t\ti.Donor,\n\t\ti.Warned,\n\t\ti.JoinDate,\n\t\t(\n\t\t\tSELECT COUNT(h1.UserID)\n\t\t\tFROM users_history_ips AS h1\n\t\t\tWHERE h1.IP = m.IP\n\t\t) AS Uses,\n\t\tim.ID,\n\t\tim.IP,\n\t\tim.ipcc,\n\t\tim.Email,\n\t\tim.Username,\n\t\tim.PermissionID,\n\t\tim.Uploaded,\n\t\tim.Downloaded,\n\t\tim.Enabled,\n\t\tii.Donor,\n\t\tii.Warned,\n\t\tii.JoinDate,\n\t\t(\n\t\t\tSELECT COUNT(h2.UserID)\n\t\t\tFROM users_history_ips AS h2\n\t\t\tWHERE h2.IP = im.IP\n\t\t) AS InviterUses\n\tFROM users_main AS m\n\t\tLEFT JOIN users_info AS i ON i.UserID = m.ID\n\t\tLEFT JOIN users_main AS im ON i.Inviter = im.ID\n\t\tLEFT JOIN users_info AS ii ON i.Inviter = ii.UserID\n\tWHERE"; if ($DateSearch) { $RS .= " i.JoinDate BETWEEN '{$AfterDate}' AND '{$BeforeDate}' "; } else { $RS .= " i.JoinDate > '" . time_minus(3600 * 24 * 3) . "'"; } $RS .= "\n\tORDER BY i.Joindate DESC\n\tLIMIT {$Limit}"; $QueryID = $DB->query($RS); $DB->query('SELECT FOUND_ROWS()'); list($Results) = $DB->next_record(); $DB->set_query_id($QueryID); ?> <form action="" method="post" acclass="thin box pad"> <input type="hidden" name="action" value="registration_log" /> Joined after: <input type="date" name="after_date" /> Joined before: <input type="date" name="before_date" /> <input type="submit" /> </form>
} else { $Err = "As useful as blank reports are, could you be a tiny bit more helpful? (Leave a comment)"; } $DB->query("SELECT ID FROM torrents WHERE ID=".$TorrentID); if($DB->record_count() < 1) { $Err = "A torrent with that ID doesn't exist!"; } if(!empty($Err)) { error_message($Err); include(SERVER_ROOT.'/sections/reportsv2/report.php'); die(); } $DB->query("SELECT ID FROM reportsv2 WHERE TorrentID=".$TorrentID." AND ReporterID=".db_string($LoggedUser['ID'])." AND ReportedTime > '".time_minus(3)."'"); if($DB->record_count() > 0) { header('Location: torrents.php?torrentid='.$TorrentID); die(); } $DB->query("INSERT INTO reportsv2 (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link) VALUES (".db_string($LoggedUser['ID']).", $TorrentID, '".$Type."', '$Extra', 'New', '".sqltime()."', '$Tracks', '$Images', '$ExtraIDs', '$Links')"); $ReportID = $DB->inserted_id(); $ReportArray = $Cache->get_value('reports_torrent_'.$TorrentID); if(!$ReportArray) { $DB->query("SELECT r.ID,