Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Seed Bonus [Reworked]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / V4 / Downloads & Updates

2020-09-20 03:09:53
I redid seed bonus, as I didnt like the old one and it needed to be cut down a few. So here is working copy, still progressing as I go to settle features and what not.

Full compat for any edition soon.

[ATTACH type="full" alt="1.png"]5896[/ATTACH]

[ATTACH type="full" alt="2.png"]5897[/ATTACH]


<?
// Seed Bonus - Reworked - Sep 19, 2020
require_once '../site.php';
$db->connect();
site_header();

if (!$account->sessionLogin()) {
   header(sprintf('Location: %s/siginin/', $CONFIG['base_url']));
   die;
}

$errors = array();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
   
   $data = array();
   $keys = array('id', 'userid', 'torrentid');
   foreach ($keys as $key) {
       if (!array_key_exists($key, $_POST)) {
           sprintf('Seed bonus item ID %s not valid.', $key);        
       }
       $data[$key] = $_POST[$key];
   }
   
   $res = $db->query_params('SELECT users.seedbonus, users.perk_avatar, users.username, users.slots, users.last_exchange, users.class, users.user_id, bonus.cost, bonus.descr, bonus.type, bonus.value, bonus.id FROM users, bonus WHERE users.user_id = :user_id AND bonus.id = :post_id', array('user_id' => $account->getId(), 'post_id' => $data['id'])) or die('db error');
   
   if (!($row = $res->fetch()) || $row['seedbonus'] < $row['cost']) {
       $errors []= 'Demand not valid.';
   }
   
   if (empty($errors)) {
       $db->query_params("UPDATE users SET seedbonus = seedbonus - :cost WHERE user_id = :user_id", array('cost' => $row['cost'], 'user_id' => $account->getid())) or die('User bonus update failed.');
   }
   
   $types = array(
       'invite' => true,
       'traffic' => true,
       'hnr' => true,
       'slots' => true,
       'vip' => true,
       'last_exchange' => true,
       'value' => true,
       'feature' => true
   );

   $data_row = array();
   foreach ($types as $key => $req) {
       if (array_key_exists($key, $row)) {
           $data_row[$key] = $row[$key];
       } else if ($req) {
           sprintf('Invalid type %s', $key);
       }
   }
   
 if (empty($errors) || array_key_exists('id', $data)) {
           
       if ($row['type'] == 'invite' && $data['id'] == $row['id']) {
           $db->query_params("UPDATE users SET invites = invites + :value WHERE user_id = :user_id", array('value' => $row['value'], 'user_id' => $account->getid()));
           echo sprintf('Your account has been <b>credited</b> for <b>%s</b> Extra Invites!', $row['value']);
       }
       
       if ($row['type'] == 'traffic' && $data['id'] == $row['id']) {
           $db->query_params("UPDATE users SET uploaded = uploaded + :value, last_exchange = :bonus WHERE user_id = :user_id", array('bonus' => $row['value'], 'value' => $row['value'], 'user_id' => $account->getid()));
           echo sprintf('Your account has been <b>credited</b> for <b>%s</b> bonus Upload Data!', format_size($row['value']));
       }
   
       if ($row['type'] == 'HnR' && $data['id'] == $row['id']) {
       
       $uid = $row['class'] == '1' ? $data['userid'] : $account->getId();
           
       if (!array_key_exists('torrentid', $data)) {
           die('You must fill the box with the id of the torrent.');
       }
       
       if (isset($uid)) {
           $res = $db->query_params("SELECT * FROM snatched WHERE tid = :tid AND uid = :uid AND hnr = 'yes'", array('tid' => $data['torrentid'], 'uid' => $uid));
           if ($res)
               die('No HnR found with this information.');
       
       $res1 = $db->query_params("SELECT username FROM users WHERE user_id = :uid", array('uid' => $uid));
       $row1 = $res1->fetch();
       
       $res2 = $db->query_params("SELECT name FROM torrents WHERE torrent_id = :tid", array('tid' => $tid));
       $row2 = $res2->fetch();
               
       $username = html_escape($row1['username']);
       $torname  = html_escape($row2['name']);

       // TODO: db Hit n Run logging
       echo sprintf('Hit and Run has been cleared for torrent %s', $row2['name']);
       
       if ($uid == $account->getId())
           $new_modcomment .= "H&R on the torrent " . $torname . " cleared against " . $row['cost'] . " points \n";
       else
           $new_modcomment .= "H&R on the torrent " . $torname . " cleared by " . $account->username() . " \n";
           $modcom = gmdate('d-m-Y \à H:i') . ' - ';
               
       $db->query_params('UPDATE users SET modcomment = CONCAT(:modcom,modcomment) WHERE user_id = :user_id', array('modcom' => $modcom, 'user_id' => $uid));
       $db->query_params("UPDATE snatched SET ltime = '129600', hnr = 'no' WHERE tid = :tid AND uid = :uid", array('tid' => $modcom, 'uid' => $uid));
       
       }
   }

   if ($row['type'] == 'slots' && $data['id'] == $row['id']) {
       $db->query_params('UPDATE users SET slots = :slots WHERE user_id = :user_id', array('slots' => $data_row['value'], 'user_id' => $account->getid()));
       echo sprintf('Your account has been <b>credited</b> for <b>%s</b> Extra Download Slots!', $row['value']);
   }
   
   if ($row['type'] == 'feature' && $data['id'] == $row['id']) {
       $db->query_params("UPDATE users SET perk_avatar = 'yes' WHERE user_id = :user_id", array('user_id' => $account->getid()));
       echo sprintf('Your avatar has been <b>enlarged</b> to <b>%s</b> Pixels!', $row['value']);
   }
   
 }
}
1.png
1.png
2.png
2.png
2020-09-20 06:42:42
good sunday and thank you for your work nice job, and I'm looking forward to have it in mysqli so that I can test it. (y):D
2020-09-21 01:14:27
Annd the announce code for this

Run query to start accepting slots to user account
ALTER TABLE users ADD COLUMN slots INT(10) NOT NULL DEFAULT 3


(this will be ported for all editions)

// Max download slots check - Sep 20, 2020
$maxslots = $db->query_params("SELECT COUNT(DISTINCT torrent_id) AS total FROM peers WHERE user_id = :user_id AND seeder = 'no'", array('user_id' => $user_row['user_id']));
$maxslot2 = $db->query_params("SELECT p.user_id, u.slots FROM users u LEFT JOIN peers p ON p.user_id = u.user_id WHERE u.user_id = :user_id AND p.seeder = 'no' LIMIT 1", array('user_id' => $user_row['user_id']));

foreach ($maxslots as $slots) {
   foreach ($maxslot2 as $maxslot) {
       if ($slots['total'] > $maxslot['slots']) {
           fail("Maximum $slots[total]/$maxslot[slots] download slots exceeded! Finish current transfers to reclaim slots.");
       }
   }
}

And the config setting

UPDATE:
this is better, and doesnt need a loop. Connectable='yes', seeder='no' is important here. I made sure only their slot message happens only ONE time (since last announce) or shoutbox gets spammed really hard.

// Max Slots - Fixed - Seedbox-Compatible - Sep 20, 2020 - No foreach!
$maxslots = $db->query_params("SELECT COUNT(DISTINCT torrent_id) AS total, last_announce FROM peers WHERE user_id = :user_id AND seeder = 'no'", array('user_id' => $user_row['user_id']));
$current  = $maxslots->fetch();
if ($current['total'] > $user_row['slots']) {
   $checklast   = $db->query_params('SELECT user, date, message FROM shoutbox WHERE user = :username', array('username' => $user_row['username']));
   $lastmessage = $checklast->fetch();
   if ($lastmessage['date'] <= $current['last_announce']) {
       $event = "$user_row[username] reached their maximum download slot $current[total]/$user_row[slots]";
       $db->query_params('INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, :receiver, :event, NOW(), 0)', array('receiver' => $user_row['username'], 'event' => $event));
   }
   fail("$current[total]/$user_row[slots] download slots exceeded! Finish current transfers to reclaim slots.");
}


[ATTACH type="full" alt="MaxSlotsShoutboxAnnouncement.png"]5900[/ATTACH]

[color=rgb(226, 80, 65)]'max_download_slots'[/color] [color=rgb(61, 142, 185)]=>[/color] [color=rgb(147, 101, 184)]3[/color]

Note: the nature of this is reading 'users.slots' now and default of 3 slots available now, unless user exchanges points for more download slots.

This is very reliable and is not relying on (possible) spoofed upload/download stats, peer problems or other client issues. This is simply user slots! Tested and works great with also testing bonuses for more slots to ensure its working as expected.
MaxSlotsShoutboxAnnouncement.png
MaxSlotsShoutboxAnnouncement.png
2020-09-22 04:43:12
Fake Ratio Checking

// Defines the transmission rate from which a Ratiofaker entry is created in the user profile.
// For trackers that do not have a speed limit, this value should be set to approx. 5 MB per second. Ratiofaker tools usually have upload rates in the GB / s range.
// Type: Number (bytes per second)
// Possible values: N / A
if (($data['uploaded'] / 60 * 20) > 1024 * 1024 * 5) fail('Ratiofaker-Tool used!');
2020-09-22 05:35:47
Vouchers under work - So this checks holidays on doclean() and if is holiday, it generates a unique code and sent to user PM for some promotional GBs or other.

This uses 2 classes on hand.

Under work:


   // BEGIN holiday / voucher check
   $t = date('Y-m-d');
   $q = $db->query_params("SELECT value_s as s, value_i as i FROM avps WHERE arg = 'lastholidaycheck'");
   $d = $q->fetch();
   if($d['s'] != $t){
       if($d['i'] === 0){
           $i = 0;
           $h = new Holidays();
           if(!$h->isDateIsHoliday($t))
               $i = 1;
           else{
               $v = new voucher();
               if($v->todaysVoucher() === false)
                   $v->create("","",0,true);
               $c = $v->code;
               $q = $db->query_params('SELECT user_id FROM users');
               $d = $q->fetch();
               $txt = "To celebrate the day you will receive ". $C." This voucher is only valid today! [url=vouchers.php] Click here![/url]";
               foreach($d as $u)
                   $db->query_params('INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, :user_id, NOW(), :message, 0)', array('user_id' => $u['user_id'], 'message' => $txt));
               $i = 1;
           }
           $q = $db->query_params("UPDATE avps SET value_s = :s, value_i = :i WHERE arg = 'lastholidaycheck'", array('s' => $t, 'i' => $i));
       }
   }
2020-10-20 02:31:06
Final is pushed to BETA5. Disregard this thread.
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728