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 [TTv3]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2021-05-09 15:09:48
Just a nice addition to this mod, in mybonus.php. Will pluralize point if any number other than 1. By the way, the word RECEIVE was spelled wrong, find
     <li>You will receive <font color=red><?php echo $site_config['bonuspertime']; ?></font> points for every <?php echo floor($site_config['autoclean_interval'] / 10); ?> minutes the system registers you as a seeder per torrent.</li>

change to
    <li>You will receive <font color=red><?php echo $site_config['bonuspertime']; ?></font> <?php echo "point".($site_config['bonuspertime'] == 1 ? "" : "s").""?> for every <?php echo floor($site_config['autoclean_interval'] / 10); ?> minutes the system registers you as a seeder per torrent.</li>

you can do this dumb shit too if you want. Im just playing with stuff now waiting for dinner lol
     <li>You will receive <font color=red><?php echo $site_config['bonuspertime']; ?></font> <?php echo "point".($site_config['bonuspertime'] == 1 ? "" : "s").""?> for every <?php echo floor($site_config['autoclean_interval'] / 60); ?> minutes the system registers you as a seeder per torrent.</li>

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-05-09 16:52:36
2021-05-14 17:18:11
Lots of stuff you can do, in mine I iterated a list of users (avatar pictures) for each bonus item, as those who recently redeemed. Works good!

Also added “Currently Seeding” to the top of that page that queries the peer table with the current users Id and lists in detail.
2021-10-31 18:36:37
edit seedbonus in account details https://torrenttrader.uk/topic?topicid=10359&page=p#post70649

admin modtasks.php
Find
$email = $_POST["email"];


Add below
$seedbonus = $_POST["seedbonus"];


Then in this line
SQL_Query_exec("UPDATE users SET email='$email', title=$title, downloaded='$downloaded', uploaded='$uploaded', signature=$signature, avatar=$avatar, ip=$ip, donated=$donated, forumbanned=$forumbanned, warned=$warned, modcomment=$modcomment, enabled=$enabled, invites=$invites WHERE id=$userid");


Add before WHERE
, seedbonus=$seedbonus


in account-details.php find
print("<tr><td>".T_("INVITES").": </td><td align='left'><input type='text' size='4' name='invites' value='".$user["invites"]."' /></td></tr>\n");


add below
print("<tr><td>Seed Bonus</td><td align='left'><input type='text' size='4' name='seedbonus' value='".$user["seedbonus"]."' /></td></tr>\n");

2021-11-10 11:57:34
i have added seedbonus first time worked well and after about 10 minutes the seed bonus disapeared from login block and when i try to make force cleanup gives error
Database Error. Please report this to an administrator.
2021-11-10 14:34:14
What is the error in admincp sqlerr
2021-11-11 11:24:24
fix it thx the only problem remain seed bonus is blank
Last edited by djlive on 2021-11-11 11:41:47
2021-11-11 16:00:22
lets check block first - save your original file in case you have other mods in block file - this is just quick test

login_block.php replace all code for this
<?php
if (!$CURUSER) {
begin_block(T_("LOGIN"));
?>
<form method="post" action="account-login.php">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr><td>
<table border="0" cellpadding="1" align="center">
<tr>
<td align="center"><font face="verdana" size="1"><b><?php echo T_("USERNAME"); ?>:</b></font></td>
</tr><tr>
<td align="center"><input type="text" size="12" name="username" /></td>
</tr><tr>
<td align="center"><font face="verdana" size="1"><b><?php echo T_("PASSWORD"); ?>:</b></font></td>
</tr><tr>
<td align="center"><input type="password" size="12" name="password"  /></td>
</tr><tr>
<td align="center"><input type="submit" value="<?php echo T_("LOGIN"); ?>" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">[<a href="account-signup.php"><?php echo T_("SIGNUP");?></a>]<br />[<a href="account-recover.php"><?php echo T_("RECOVER_ACCOUNT");?></a>]</td> </tr>
</table>
   </form>
<?php
end_block();

} else {

begin_block($CURUSER["username"]);

$avatar = htmlspecialchars($CURUSER["avatar"]);
if (!$avatar)
$avatar = $site_config["SITEURL"]."/images/default_avatar.png";

$userdownloaded = mksize($CURUSER["downloaded"]);
$useruploaded = mksize($CURUSER["uploaded"]);
$privacylevel = T_($CURUSER["privacy"]);
   $bonus = $CURUSER['seedbonus'];
if ($CURUSER["uploaded"] > 0 && $CURUSER["downloaded"] == 0)
$userratio = "Inf.";
elseif ($CURUSER["downloaded"] > 0)
$userratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
else
$userratio = "---";

print ("<center><img width='80' height='80' src='$avatar' alt='' /></center><br />" . T_("DOWNLOADED") . ": $userdownloaded<br />" . T_("UPLOADED") . ": $useruploaded<br />".T_("CLASS").": ".T_($CURUSER["level"])."<br />" . T_("ACCOUNT_PRIVACY_LVL") . ": $privacylevel<br />". T_("RATIO") .": $userratio<br>Seedbonus : <b><a href=mybonus.php>".$bonus."</a></b>");

?>


<center><a href="account.php"><?php echo T_("ACCOUNT"); ?></a> <br />
<?php if ($CURUSER["control_panel"]=="yes") {print("<a href=\"admincp.php\">".T_("STAFFCP")."</a>");}?>
</center>
<?php
end_block();
}
?>
2021-11-11 18:18:52
nope the same seedbonus blank
2021-11-11 22:27:34
post your login-block, or use below to compare to mine
				//user country flags
$res = SQL_Query_exec("SELECT `name`, `flagpic` FROM `countries` WHERE id=$CURUSER[country] LIMIT 1") ;
if (mysqli_num_rows($res) == 1)    {
$arr = mysqli_fetch_assoc($res);
$country ="<center>$arr[name]<br/><img src= images/countries/$arr[flagpic] height=25 width=36 border=0></center>";
}
else{
$country = "<center>".T_('DUNNOCOUNTRY')."<br/><img src= 'images/countries/nazi.jpg' width='50' /></center>"; ///change default image
}
$bonus = $CURUSER['seedbonus'];
$loggedin = get_elapsed_time(strtotime($CURUSER['last_login']));
print ("<center><img width='80' height='80' src='$avatar' alt='' /></center><br />" . T_("DOWNLOADED") . ": $userdownloaded<br />" . T_("UPLOADED") . ": $useruploaded<br />".T_("CLASS").": ".T_($CURUSER["level"])."<br />" . T_("ACCOUNT_PRIVACY_LVL") . ": $privacylevel<br />" . T_("LOGGED_IN_FOR") . ": $loggedin<br />". T_("RATIO") .": $userratio<br>Seed Bonus : <b><a href=mybonus.php>".$bonus."</a></b><br /><hr/>Port: <a href='testport.php' title='Porttest'>".$port."</a>");


you will be focusing on this part. There may be differences, but you can see what the code is for the seedbonus, just ignore the other stuff, or do like I said and post your login-block.php code, and we can take a look. That would prolly be easier
$bonus = $CURUSER['seedbonus'];
$loggedin = get_elapsed_time(strtotime($CURUSER['last_login']));
print ("<center><img width='80' height='80' src='$avatar' alt='' /></center><br />" . T_("DOWNLOADED") . ": $userdownloaded<br />" . T_("UPLOADED") . ": $useruploaded<br />".T_("CLASS").": ".T_($CURUSER["level"])."<br />" . T_("ACCOUNT_PRIVACY_LVL") . ": $privacylevel<br />" . T_("LOGGED_IN_FOR") . ": $loggedin<br />". T_("RATIO") .": $userratio<br>Seed Bonus : <b><a href=mybonus.php>".$bonus."</a></b><br /><hr/>Port: <a href='testport.php' title='Porttest'>".$port."</a>");

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-11-11 23:48:26
2021-11-12 10:53:08
<?php
if (!$CURUSER) {
begin_block(T_("LOGIN"));
?>
<form method="post" action="account-login.php">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr><td>
<table border="0" cellpadding="1" align="center">
<tr>
<td align="center"><font face="verdana" size="1"><b><?php echo T_("USERNAME"); ?>:</b></font></td>
</tr><tr>
<td align="center"><input type="text" size="12" name="username" /></td>
</tr><tr>
<td align="center"><font face="verdana" size="1"><b><?php echo T_("PASSWORD"); ?>:</b></font></td>
</tr><tr>
<td align="center"><input type="password" size="12" name="password"  /></td>
</tr><tr>
<td align="center"><input type="submit" value="<?php echo T_("LOGIN"); ?>" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">[<a href="account-signup.php"><?php echo T_("SIGNUP");?></a>]<br />[<a href="account-recover.php"><?php echo T_("RECOVER_ACCOUNT");?></a>]</td> </tr>
</table>
  </form>
<?php
end_block();

} else {

begin_block($CURUSER["username"]);

$avatar = htmlspecialchars($CURUSER["avatar"]);
if (!$avatar)
$avatar = $site_config["SITEURL"]."/images/default_avatar.png";

$userdownloaded = mksize($CURUSER["downloaded"]);
$useruploaded = mksize($CURUSER["uploaded"]);
$privacylevel = T_($CURUSER["privacy"]);
  $bonus = $CURUSER['seedbonus'];
if ($CURUSER["uploaded"] > 0 && $CURUSER["downloaded"] == 0)
$userratio = "Inf.";
elseif ($CURUSER["downloaded"] > 0)
$userratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
else
$userratio = "---";

print ("<center><img width='80' height='80' src='$avatar' alt='' /></center><br />" . T_("DOWNLOADED") . ": $userdownloaded<br />" . T_("UPLOADED") . ": $useruploaded<br />".T_("CLASS").": ".T_($CURUSER["level"])."<br />" . T_("ACCOUNT_PRIVACY_LVL") . ": $privacylevel<br />". T_("RATIO") .": $userratio<br>Seedbonus : <b><a href=mybonus.php>".$bonus."</a></b>");

?>


<center><a href="account.php"><?php echo T_("ACCOUNT"); ?></a> <br />
<?php if ($CURUSER["control_panel"]=="yes") {print("<a href=\"admincp.php\">".T_("STAFFCP")."</a>");}?>
</center>
<?php
end_block();
}
?>
2021-11-12 11:52:15
hmm, that looks correct. Must have an issue somewhere else
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2021-11-12 12:08:44
yes did it thanx for help i didnt put all sql code :P
i forgot to put
ALTER TABLE users ADD `seedbonus` decimal(10,1) NOT NULL;


Sry but thx again for help it is all working now
2023-08-05 12:01:15
error>>>> $res1 = SQL_Query_exec($qry);  nores1  by res

@+
2024-05-13 13:28:26
Problem Warning: mysqli_fetch_object() expects parameter 1 to be mysqli_result, resource given in /www/wwwroot/tt208.local/admincp.php on line 4737 how to fix
2026-11-09 10:33:23
Thanks to M-Jay and mostvotedplaya for this mod. Here is an updated version for PHP 8, following the same steps as the first post. Please take a backup of your files and database first.

Files pass a PHP syntax check and the pages load on PHP 8.5 with MariaDB 10.10. Point awards and exchanges have only had light testing so far, so please try it on a test account first.

What changed from the first post
- mysql_fetch_assoc() no longer exists in PHP 8 and crashed the HnR option
- Undefined $_POST keys and null values no longer give warnings
- Points are charged in one query, only after all checks pass, so a double click cannot spend them twice
- The HnR option clears only your own HnR (it could clear another member's), and now has its Torrent ID box
- VIP set class 7, which is Administrator on a default install. It now uses the VIP class and never lowers Uploaders or staff
- The manager no longer uses extract() on $_POST
- seedbonus gets a default of 0, which fixes the signup error in strict mode reported in this topic

SQL:
(If you have a NULL or missing default on seedbonus from the old version, the last two lines fix it. On MySQL remove IF NOT EXISTS.)
CREATE TABLE IF NOT EXISTS `bonus` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `title` varchar(50) NOT NULL,
 `cost` decimal(10,1) unsigned NOT NULL DEFAULT '0.0',
 `value` bigint(20) unsigned NOT NULL DEFAULT '0',
 `descr` varchar(100) NOT NULL,
 `type` varchar(20) NOT NULL DEFAULT 'other',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM;

INSERT IGNORE INTO `bonus` (`id`, `title`, `cost`, `value`, `descr`, `type`) VALUES
(1, '1 GB Uploaded', '70.0', 1073741824, 'Exchange 70 points for 1 GB upload.', 'traffic'),
(2, '2 GB Uploaded', '100.0', 2147483648, 'Exchange 100 points for 2 GB upload.', 'traffic'),
(3, '5 GB Uploaded', '250.0', 5368709120, 'Exchange 250 points for 5 GB upload.', 'traffic'),
(4, '10 GB Uploaded', '500.0', 10737418240, 'Exchange 500 points for 10 GB upload.', 'traffic'),
(5, 'Invitations', '1000.0', 2, 'Receive 2 Invites for 1000.00 seedbonus points.', 'invite');

ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `seedbonus` decimal(10,1) NOT NULL DEFAULT '0.0';
UPDATE `users` SET `seedbonus` = 0 WHERE `seedbonus` IS NULL;
ALTER TABLE `users` MODIFY `seedbonus` decimal(10,1) NOT NULL DEFAULT '0.0';


blocks/login_block.php find
$privacylevel = T_($CURUSER["privacy"]);

Add after
$bonus = number_format((float) ($CURUSER["seedbonus"] ?? 0), 1);

Search (at end of line)
". T_("RATIO") .": $userratio

Add after :
<br>Seedbonus : <b><a href=mybonus.php>".$bonus."</a></b>


backend/cleanup.php find
//LOCAL TORRENTS - MAKE NON-ACTIVE/OLD TORRENTS INVISIBLE
$deadtime = gmtime() - $site_config["max_dead_torrent_time"];
SQL_Query_exec("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime) AND seeders = '0' AND leechers = '0' AND external !='yes'");

Add after :
// Seedbonus: points per torrent each member is seeding
$res = SQL_Query_exec("SELECT userid, COUNT(DISTINCT torrent) AS seeding FROM peers WHERE seeder = 'yes' GROUP BY userid");
while ($row = mysqli_fetch_object($res)) {
   $points = (float) $site_config["bonuspertime"] * (int) $row->seeding;
   SQL_Query_exec("UPDATE users SET seedbonus = seedbonus + $points WHERE id = " . (int) $row->userid);
}
// End Seedbonus


backend/config.php find
$site_config['blocks_dir'] = getcwd().'/blocks';

After add
$site_config["bonuspertime"] = 0.5;


account.php find
<?php print("<a href='mailbox.php'><b>".T_("YOUR_MESSAGES")."</b></a>");?>
&nbsp;|&nbsp;

Add below
&nbsp;|&nbsp;
<?php print("<a href='mybonus.php'><b>My Seedbonus</b></a>");?>


admincp.php find
<td align="center"><a href="admincp.php?action=sqlerr"><img src="images/admin/sql_error.png" border="0" width="32" height="32" alt="" /><br />SQL Error<br /></a></td>

Add below
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td align="center"><a href="admincp.php?action=seedbonus"><img src="images/admin/seedbonus.png" border="0" width="32" height="32" alt="" /><br />Management of Seed Bonus</a></td>
</tr>

Search
} // End Forum management

Add after
#======================================================================#
# Seedbonus Manager
#======================================================================#
if ($action == "seedbonus" && $do != "change")
{
   if ($do == "del")
   {
       $ids = array_map("intval", (array) ($_POST["ids"] ?? array()));
       if (!$ids) show_error_msg(T_("ERROR"), "Nothing selected.", 1);

       SQL_Query_exec("DELETE FROM `bonus` WHERE `id` IN (" . implode(", ", $ids) . ")");
       autolink("admincp.php?action=seedbonus", "Deleted entries");
   }

   $count = get_row_count("bonus");

   list($pagertop, $pagerbottom, $limit) = pager(25, $count, 'admincp.php?action=seedbonus&');

   $res = SQL_Query_exec("SELECT id, title, cost, value, descr, type FROM `bonus` ORDER BY `type` $limit");

   stdhead("Seedbonus Manager");
   navmenu();

   begin_frame("Management of Seed Bonus");
?>

<center>
This page displays all available options which users can exchange for seedbonus: <?php echo number_format($count); ?><br /><br />
<a href="admincp.php?action=seedbonus&do=change">Add</a> a new option?
</center>

<?php if ($count > 0): ?>
<br />
<form id="seedbonus" method="post" action="admincp.php?action=seedbonus">
<input type="hidden" name="do" value="del" />
<table border="0" cellpadding="3" cellspacing="0" width="100%" align="center" class="table_table">
<tr>
   <th class="table_head">Title</th>
   <th class="table_head">Description</th>
   <th class="table_head">Points</th>
   <th class="table_head">Value</th>
   <th class="table_head">Type</th>
   <th class="table_head">Edit</th>
   <th class="table_head"><input type="checkbox" name="checkall" onclick="checkAll(this.form.id);" /></th>
</tr>

<?php while ($row = mysqli_fetch_object($res)):
   $shown_value = ($row->type == "traffic") ? mksize($row->value) : (int) $row->value;
?>
<tr>
   <td class="table_col1" align="center"><?php echo htmlspecialchars((string) $row->title); ?></td>
   <td class="table_col2"><?php echo htmlspecialchars((string) $row->descr); ?></td>
   <td class="table_col1" align="center"><?php echo htmlspecialchars((string) $row->cost); ?></td>
   <td class="table_col2" align="center"><?php echo $shown_value; ?></td>
   <td class="table_col1" align="center"><?php echo htmlspecialchars((string) $row->type); ?></td>
   <td class="table_col2" align="center"><a href="admincp.php?action=seedbonus&do=change&id=<?php echo (int) $row->id; ?>">Edit</a></td>
   <td class="table_col1" align="center"><input type="checkbox" name="ids[]" value="<?php echo (int) $row->id; ?>" /></td>
</tr>
<?php endwhile; ?>

<tr>
   <td colspan="7" align="right"><input type="submit" value="Remove Selected" /></td>
</tr>
</table>
</form>
<?php
   endif;

   if ($count > 25) echo $pagerbottom;

   end_frame();
   stdfoot();
}

if ($action == "seedbonus" && $do == "change")
{
   $bonus_types = array('invite', 'traffic', 'VIP', 'HnR', 'other');
   $bonus_id = (int) ($_REQUEST['id'] ?? 0);
   $row = null;
   if ($bonus_id > 0)
   {
       $row = mysqli_fetch_object(SQL_Query_exec("SELECT id, title, cost, value, descr, type FROM `bonus` WHERE `id` = $bonus_id"));
   }

   if ($_SERVER['REQUEST_METHOD'] == 'POST')
   {
       $title = trim((string) ($_POST['title'] ?? ''));
       $descr = trim((string) ($_POST['descr'] ?? ''));
       $type = (string) ($_POST['type'] ?? '');
       $cost = $_POST['cost'] ?? '';
       $raw_value = trim((string) ($_POST['value'] ?? ''));

       if ($title === '' || $descr === '' || !in_array($type, $bonus_types, true) || !is_numeric($cost) || $cost < 0)
       {
           autolink("admincp.php?action=seedbonus&do=change&id=$bonus_id", "Missing information.");
       }

       $value = ($type == "traffic" && !ctype_digit($raw_value)) ? strtobytes($raw_value) : $raw_value;
       $value = sprintf("%.0f", (float) $value);
       $cost = (float) $cost;
       $title_sql = "'" . mysqli_real_escape_string($GLOBALS["DBconnector"], $title) . "'";
       $descr_sql = "'" . mysqli_real_escape_string($GLOBALS["DBconnector"], $descr) . "'";

       if ($row == null)
       {
           SQL_Query_exec("INSERT INTO `bonus` (`title`, `descr`, `cost`, `value`, `type`) VALUES ($title_sql, $descr_sql, $cost, $value, '$type')");
       }
       else
       {
           SQL_Query_exec("UPDATE `bonus` SET `title` = $title_sql, `descr` = $descr_sql, `cost` = $cost, `value` = $value, `type` = '$type' WHERE `id` = $bonus_id");
       }

       autolink("admincp.php?action=seedbonus", "Seed bonus option saved.");
   }

   stdhead("Seedbonus Management");
   navmenu();

   begin_frame("Seedbonus Management");
   $field = function ($name) use ($row) {
       return $row != null ? htmlspecialchars((string) $row->$name, ENT_QUOTES) : '';
   };
?>

<form method="post" action="admincp.php?action=seedbonus&do=change">

<?php if ($row != null): ?>
<input type="hidden" name="id" value="<?php echo (int) $row->id; ?>" />
<?php endif; ?>

<table border="0" class="table_table" width="90%" cellpadding="3" align="center">
<tr>
   <th class="table_head" colspan="2">Seedbonus Management</th>
</tr>
<tr>
   <td class="table_col1"><b>Title:</b></td>
   <td class="table_col2"><input type="text" name="title" value="<?php echo $field('title'); ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
   <td class="table_col1"><b>Points:</b></td>
   <td class="table_col2"><input type="text" name="cost" value="<?php echo $field('cost'); ?>" size="5" /></td>
</tr>
<tr>
   <td class="table_col1"><b>Type:</b></td>
   <td class="table_col2">
   <select name="type">
   <?php foreach ($bonus_types as $bonus_type): ?>
       <option value="<?php echo $bonus_type; ?>" <?php echo ($row != null && $row->type == $bonus_type ? 'selected="selected"' : ''); ?>><?php echo $bonus_type; ?></option>
   <?php endforeach; ?>
   </select>
   </td>
</tr>
<tr>
   <td class="table_col1"><b>Value:</b></td>
   <td class="table_col2"><input type="text" name="value" value="<?php echo $field('value'); ?>" size="14" /> Traffic: bytes or a size such as 5 GB. VIP: days. Invite: number.</td>
</tr>
<tr>
   <td class="table_col1" valign="top"><b>Description:</b></td>
   <td class="table_col2"><textarea name="descr" rows="5" cols="38" maxlength="100"><?php echo $field('descr'); ?></textarea></td>
</tr>
<tr>
   <td colspan="2" align="right">
       <input type="reset" value="Cancel" />
       <input type="submit" value="Save" />
   </td>
</tr>
</table>
</form>

<?php
   end_frame();
   stdfoot();
}


Use seedbonus.png from bonus.zip in the first post (images/admin folder).

Replace mybonus.php in the root with:
<?php
/**
* @package Seedbonus
* @version TorrentTrader v3 MicroMonkey
* @author  mostvotedplaya
* Updated for PHP 8.
*/

require_once("backend/functions.php");
dbconn();
loggedinonly();

// group_id of VIP in your groups table (3 on a default install)
const BONUS_VIP_CLASS = 3;

if (is_valid_id($_POST['id'] ?? 0)) {
   $item = mysqli_fetch_object(SQL_Query_exec("SELECT `type`, `value`, `cost` FROM `bonus` WHERE `id` = " . (int) $_POST['id']));

   if (!$item || (float) $CURUSER['seedbonus'] < (float) $item->cost) {
       autolink("mybonus.php", "Demand not valid.");
   }

   $uid = (int) $CURUSER['id'];
   $cost = (float) $item->cost;
   $value = (int) $item->value;
   $tid = (int) ($_POST["torrentid"] ?? 0);

   // checked before anything is charged
   if ($item->type == 'HnR') {
       if (!$tid) {
           autolink("mybonus.php", "You must fill the box with the id of the torrent.");
       }
       $check = SQL_Query_exec("SELECT 1 FROM `snatched` WHERE `tid` = $tid AND `uid` = $uid AND `hnr` = 'yes'");
       if (mysqli_num_rows($check) == 0) {
           autolink("mybonus.php", "No HnR found with this information.");
       }
   }

   // charged in one statement, so a double click cannot spend the points twice
   if ($cost > 0) {
       SQL_Query_exec("UPDATE `users` SET `seedbonus` = `seedbonus` - $cost WHERE `id` = $uid AND `seedbonus` >= $cost");
       if (mysqli_affected_rows($GLOBALS["DBconnector"]) < 1) {
           autolink("mybonus.php", "Demand not valid.");
       }
   }

   switch ($item->type) {
       case 'invite':
           SQL_Query_exec("UPDATE `users` SET `invites` = `invites` + $value WHERE `id` = $uid");
           break;

       case 'traffic':
           SQL_Query_exec("UPDATE `users` SET `uploaded` = `uploaded` + $value WHERE `id` = $uid");
           break;

       case 'HnR':
           $torrent = mysqli_fetch_assoc(SQL_Query_exec("SELECT `name` FROM `torrents` WHERE `id` = $tid"));
           $torname = $torrent ? $torrent["name"] : "ID $tid";

           write_log("The HnR of " . $CURUSER['username'] . " on the torrent " . htmlspecialchars($torname) . " has been cleared with seed bonus points.");

           $modcom = sqlesc(gmdate("d-m-Y H:i") . " - H&R on the torrent $torname cleared against $cost points\n");
           SQL_Query_exec("UPDATE `users` SET `modcomment` = CONCAT($modcom, IFNULL(`modcomment`, '')) WHERE `id` = $uid");
           SQL_Query_exec("UPDATE `snatched` SET `ltime` = '129600', `hnr` = 'no' WHERE `tid` = $tid AND `uid` = $uid");
           break;

       case 'VIP':
           // Uploaders and staff keep their higher class
           SQL_Query_exec("UPDATE `users` SET `class` = " . BONUS_VIP_CLASS . " WHERE `id` = $uid AND `class` < " . BONUS_VIP_CLASS);
           break;

       case 'other':
           break;
   }

   autolink("mybonus.php", "Your account has been credited.");
}

$my_points = (float) ($CURUSER['seedbonus'] ?? 0);

$items = array();
$res = SQL_Query_exec("SELECT * FROM `bonus` ORDER BY `type`");
while ($row = mysqli_fetch_object($res)) {
   $items[] = $row;
}

stdhead("Seedbonus");
begin_frame("Bonus Exchange");

// one form per item; the fields in the table refer to it with the form attribute
foreach ($items as $row) {
   echo "<form id='bonus-form-" . (int) $row->id . "' method='post' action='mybonus.php'><input type='hidden' name='id' value='" . (int) $row->id . "' /></form>\n";
}
?>

<center>
This page displays the options that you can redeem your accumulated points for.<br />
Your points: <b><?php echo number_format($my_points, 1); ?></b>
</center>

<br />
<table border="0" cellpadding="3" class="table_table" width="100%">
<tr>
   <th class="table_head">Option</th>
   <th class="table_head">What is it?</th>
   <th class="table_head">Points</th>
   <th class="table_head">Exchange</th>
</tr>
<?php foreach ($items as $row): $form = "bonus-form-" . (int) $row->id; ?>
<tr>
   <td class="table_col1">
       <?php echo htmlspecialchars((string) $row->title); ?>
       <?php if ($row->type == 'HnR'): ?>
           <br /><input type="text" name="torrentid" form="<?php echo $form; ?>" placeholder="Enter Torrent ID" required />
       <?php endif; ?>
   </td>
   <td class="table_col2"><?php echo htmlspecialchars((string) $row->descr); ?></td>
   <td class="table_col1" align="center"><?php echo number_format((float) $row->cost, 1); ?></td>
   <td class="table_col2" align="center"><input type="submit" form="<?php echo $form; ?>" value="Exchange" <?php echo ($my_points < (float) $row->cost ? 'disabled="disabled"' : ''); ?> /></td>
</tr>
<?php endforeach; ?>
</table>

<ul>
  <li>You receive <b><?php echo htmlspecialchars((string) $site_config['bonuspertime']); ?></b> points per torrent you are seeding, every <?php echo (int) floor($site_config['autoclean_interval'] / 60); ?> minutes.</li>
</ul>
<ul>
  <li><a href="account.php">Return to profile</a></li>
</ul>
<?php
end_frame();
stdfoot();
?>


Notes: the HnR option needs the snatched table from the HnR mod. VIP only raises the class and does not expire by itself.
If It Ain't Dutch, It Ain't Much!!
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: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728