query(" SELECT BonusPoints FROM users_main WHERE ID = $UserID"); if ($DB->has_results()) { list($Points) = $DB->next_record(); if ($Points >= $Donation) { $PoolTipped = false; $DB->query(" UPDATE users_main SET BonusPoints = BonusPoints - $Donation WHERE ID = $UserID"); $DB->query(" UPDATE misc SET First = First + $Donation WHERE Name = 'FreeleechPool'"); $Cache->delete_value('user_info_heavy_'.$UserID); // Check to see if we're now over the target pool size $DB->query(" SELECT First, Second FROM misc WHERE Name = 'FreeleechPool'"); if ($DB->has_results()) { list($Pool, $Target) = $DB->next_record(); if ($Pool > $Target) { $PoolTipped = true; $NumTorrents = rand(2, 6); $Torrents = array(); for ($i = 0; $i < $NumTorrents; $i++) { $TorrentSize = intval($Pool * (($i==$NumTorrents-1)?1:(rand(10,80)/100)) * 100000); $DB->query(" SELECT ID, Size FROM torrents WHERE Size < $TorrentSize AND Size > ($TorrentSize * 0.9) AND Seeders > 0 AND FreeLeechType = '0' ORDER BY Seeders ASC, Size DESC LIMIT 1"); if ($DB->has_results()) { list($TorrentID, $Size) = $DB->next_record(); $DB->query(" INSERT INTO shop_freeleeches (TorrentID, ExpiryTime) VALUES($TorrentID, NOW() + INTERVAL 2 DAY)"); Torrents::freeleech_torrents($TorrentID, 1, 3); $Pool -= $TorrentSize/100000; } else { // Failed to find a torrent. Maybe try again with a new value, maybe move on if (rand(1,5) > 1) { $i--; } } } $Target = rand(10000, 100000); $DB->query(" UPDATE misc SET First = 0, Second = $Target WHERE Name = 'FreeleechPool'"); } } $Cache->delete_value('shop_freeleech_list'); } else { error("Not enough points to donate"); } } View::show_header('Store'); ?>

Donation Successful

You donated to the Freeleech Pool

Your donation triggered a freeleech!

Back to Store

query(" SELECT First FROM misc WHERE Name = 'FreeleechPool'"); if ($DB->has_results()) { list($Pool) = $DB->next_record(); } else { $Pool = 0; } View::show_header('Store'); ?>
There are currently in the Freeleech Pool

Back to Store