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

2019-03-16 07:43:35
Updated for V3 credit to Original Author

[color=rgb(251, 160, 38)]SQL:[/color]
CREATE TABLE IF NOT EXISTS `bonus` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `cost` decimal(10,1) unsigned NOT NULL DEFAULT '0.0',
 `value` bigint(20) unsigned NOT NULL DEFAULT '0',
 `descr` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
 `type` enum('traffic','invite','VIP','other','HnR') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'other',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7;

INSERT INTO `bonus` (`id`, `title`, `cost`, `value`, `descr`, `type`) VALUES
(1, '1GB Uploaded', '70.0', 1073741824, 'Exchange 70 points for 1 GB upload.', 'traffic'),
(2, '2 GB Uploaded', '100.0', 2147483648, 'Exchange 100 points for  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 `seedbonus` decimal(10,1) NOT NULL;




[color=rgb(251, 160, 38)]blocks/login_blocks.php find[/color]
$privacylevel = T_($CURUSER["privacy"]);


Add after
$bonus = $CURUSER['seedbonus'];


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


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


[color=rgb(251, 160, 38)]backend/Cleanup.php find[/color]
//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
$qry = "SELECT DISTINCT userid as peer, (
SELECT DISTINCT COUNT( torrent )
FROM peers
WHERE seeder = 'yes'  AND userid = peer) AS count
FROM peers WHERE seeder = 'yes'";

$res = SQL_Query_exec($qry);
while ( $row = mysqli_fetch_object($res) )
{
SQL_Query_exec("UPDATE users SET seedbonus = seedbonus + '" . ($site_config["bonuspertime"] * $row->count) . "' WHERE id = '" . $row->peer . "'");
}
// End


[color=rgb(251, 160, 38)]in backend/config.php find[/color]
$site_config['blocks_dir'] = getcwd().'/blocks';


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


[color=rgb(251, 160, 38)]in account.php find[/color]
<?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>");?>


[color=rgb(251, 160, 38)]in admincp.php find[/color]
<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><br>Management of Seed Bonus</a></td>
           </tr>


Search
} // End Forum management


Add after
#======================================================================#
# Seedbonus Manager
#======================================================================#
if ($action == "seedbonus" && $do != "change")
{

  if (get_user_class() < 3)
     show_error_msg("STOP", "Area reserved for people entitled! and you do not have permission !!!");
   if ($do == "del")
   {
       if (!@count($_POST["ids"])) show_error_msg("Error", "select nothing.", 1);
       $ids = array_map("intval", $_POST["ids"]);
       $ids = implode(", ", $ids);
       
       SQL_Query_exec("DELETE FROM `bonus` WHERE `id` IN ($ids)");
       autolink("admincp.php?action=seedbonus", "deleted entries");
   }

   $count = get_row_count("bonus");

   list($pagertop, $pagerbottom, $limit) = pager(25, $count, 'admincp.php?action=seedbonus&amp;');
                                                                                                                                                                                                                                                               
   $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 trade which users can exchange for seedbonus.<?php echo number_format($count); ?> ; <br><br><a href="admincp.php?action=seedbonus&amp;do=change&amp;id=null">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">Valeur</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)):
 $row->value = ( $row->type == "traffic" ) ? mksize( $row->value ) : ( int ) $row->value;
 ?>
   <tr>
   <td class="table_col1" align="center"><?php echo htmlspecialchars($row->title); ?></td>
   <td class="table_col2"><?php echo htmlspecialchars($row->descr); ?></td>
   <td class="table_col1" align="center"><?php echo $row->cost; ?></td>
   <td class="table_col2" align="center"><?php echo $row->value; ?></td>
   <td class="table_col1" align="center"><?php echo $row->type; ?></td>
   <td class="table_col2" align="center"><a href="admincp.php?action=seedbonus&amp;do=change&amp;id=<?php echo $row->id; ?>">Edit</a></td>
   <td class="table_col1" align="center"><input type="checkbox" name="ids[]" value="<?php echo $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")
{
   $row = null;
   if ( is_valid_id($_REQUEST['id']) )
   {
       $res = SQL_Query_exec("SELECT id, title, cost, value, descr, type FROM `bonus` WHERE `id` = '$_REQUEST[id]'");
       $row = mysqli_fetch_object($res);
   }

   if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
   {
       if ( empty($_POST['title']) or empty($_POST['descr']) or empty($_POST['type']) or !is_numeric($_POST['cost']) )
       {
               autolink($_SERVER['HTTP_REFERER'], "missing information.");
       }


$_POST["value"] = ( $_POST["type"] == "traffic" ) ? strtobytes( $_POST["value"] ) : ( int ) $_POST["value"];
       $var = array_map('sqlesc', $_POST);
       extract( $var );

       if ( $row == null )
       {
               SQL_Query_exec("INSERT INTO `bonus` (`title`, `descr`, `cost`, `value`, `type`) VALUES ($title, $descr, $cost, $value, $type)");
       }
       else
       {
               SQL_Query_exec("UPDATE `bonus` SET `title` = $title, `descr` = $descr, `cost` = $cost, `value` = $value, `type` = $type WHERE `id` = $id");
       }
                       
       autolink("admincp.php?action=seedbonus", "Updating the bonus seed.");
   }
       
   stdhead("Seedbonus Management");
   navmenu();

   begin_frame("Seedbonus Management");
   ?>

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

   <?php if ($row != null): ?>
   <input type="hidden" name="id" value="<?php echo $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 ( $row != null ? $row->title : null ); ?>" size="50" /></td>
   </tr>
   <tr>
       <td class="table_col1"><b>Points:</b></td>
       <td class="table_col2"><input type="text" name="cost" value="<?php echo ( $row != null ? $row->cost : null ); ?>" size="5" /></td>
   </tr>
   <tr>
       <td class="table_col1"><b>Type:</b></td>
       <td class="table_col2">
       <select name="type">
       <?php foreach (array('invite', 'traffic','VIP', 'other') as $type): ?>
       <option value="<?php echo $type; ?>" <?php echo ( $row != null && $row->type == $type ? 'selected="selected"' : null ); ?>><?php echo $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 ( $row != null ? $row->value : null ); ?>" size="10" /></td>
   </tr>
   <tr>
       <td class="table_col1" valign="top"><b>Description:</b></td>
       <td class="table_col2"><textarea name="descr" rows="5" cols="38"><?php echo ( $row != null ? $row->descr : null ); ?></textarea></td>
   </tr>
   <tr>
       <td colspan="2" align="right">
       <input type="reset" value="Cancel" />
       <input type="submit" value="To send" />
       </td>
   </tr>
   </table>
   </form>

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



in images/admin folder add seedbonus.png
upload to root bonus.php
bonus.zip
Download
2019-03-17 20:30:30
heres a simple image to use with it
seedbonus.png
seedbonus.png

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)
2019-04-08 09:59:14
This line makes some issue. other than that all works

<br>Seedbonus : <b><a href=mybonus.php>".$bonus."</a></b>
2019-04-08 15:37:10
the full line should look like this m8
    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>");
2019-04-10 07:14:09
"m-jay,  post: 66417, member: 20288":

the full line should look like this m8
    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>");


Now works
2019-05-18 21:08:44
correction, deleted >> [ code ] for table sql ;)

Big thanks (y)
2019-07-11 16:38:06
small complement ...

5 seedbonus points for commenting on a torrent.
[color=rgb(41, 105, 176)](it's up to you to change the number 5 to Luis himself) [/color]

Search in [color=rgb(251, 160, 38)]torrents-details.php[/color] :
SQL_Query_exec("UPDATE torrents SET comments = comments + 1 WHERE id = $id");


Add after :

// Points Seedbonus By spiritblue
$commentaire = get_row_count("comments", "WHERE torrent = $id AND user = $CURUSER[id]");        
if ($commentaire < 1) {
   SQL_Query_exec("UPDATE users SET seedbonus = seedbonus+5.0 WHERE id = ".$CURUSER["id"]."") ;
}
// End Points Seedbonus    


Note: this line could also be used on another page, change the variable (y)
2019-10-03 17:46:25
Hello there is a bug with the sql table, when we send the sql table below in the bdd ???

ALTER TABLE users ADD `seedbonus` decimal(10,1) NOT NULL;

it is no longer possible to create a new registration on the tracker because when we make a new account we get this error message ???

Database Error. Please report this to an administrator.



the error message in SQL Error admin is below;

Database Error in account-signup.php on line 124: Field 'seedbonus' doesn't have a default value. Query was: INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, language, class, ip) VALUES ('niki2333','d3a4782d6aa9cd9e87e3b7c3503e0bb753abcf55','1PmaLiD8RoQIDrljoSMQ','titeuf77@live.fr','confirmed','2019-10-03 17:31:46','2019-10-03 17:31:46',45,89,'Male','utorrent',1,1,1,'81.244.98.241'). 




then when you delete the sql code from the database in user table, the members' registrations on the tracker work well.
2019-10-04 14:14:45
This along with the signup error with the modded version looks like strict mode is enabled or are you using above php 7.2
2019-10-04 22:14:07
anyone think this would work in account-signup.php? Just inserting the seedbonus value? Then it should just take over by itself after that. Yes? No? lol
    SQL_Query_exec("INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, language, class, ip, seedbonus) VALUES (" .
     implode(",", array_map("sqlesc", array($wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), $age, $country, $gender, $client, $site_config["default_theme"], $site_config["default_language"], $signupclass, getip(), 0.0))).")");

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)
2019-10-05 14:17:33
Some additions to this mod:

~
// Time between each auto cleanup (Seconds).
~ // Set the maximum possible value of your seed bonus.
~ // On or Off ? - true / false.

Search [color=rgb(251, 160, 38)]backend / [/color][color=rgb(243, 121, 52)]config.php[/color][color=rgb(251, 160, 38)] [/color]:

//SEEDBONUS
$site_config["bonuspertime"] = 0.5;


Replace with :

// Seed Bonus
$site_config["bonuspertime"] = 0.5; // Set this to what ever you want to give people per torrent.
$site_config["bonusmax"] = 3000; // Set the maximum possible value of your seed bonus.
$site_config['SEEDBONUS'] = false; // On or Off ? - true / false.


In [color=rgb(251, 160, 38)]backend /[/color] [color=rgb(243, 121, 52)]cleanup.php[/color] search :

// Seedbonus
$qry = "SELECT DISTINCT userid as peer, (
SELECT DISTINCT COUNT( torrent )
FROM peers
WHERE seeder = 'yes'  AND userid = peer) AS count
FROM peers WHERE seeder = 'yes'";

$res = SQL_Query_exec($qry);
while ( $row = mysqli_fetch_object($res) )
{
SQL_Query_exec("UPDATE users SET seedbonus = seedbonus + '" . ($site_config["bonuspertime"] * $row->count) . "' WHERE id = '" . $row->peer . "'");
}
// End


Replace with :

// Seedbonus upadate 2019 by spiritblue
if ($CURUSER["SEEDBONUS"]) {
$qry = "SELECT DISTINCT userid as peer, (
SELECT DISTINCT COUNT( torrent )
FROM peers
WHERE seeder = 'yes'  AND userid = peer) AS count
FROM peers WHERE seeder = 'yes'";

$res = SQL_Query_exec($qry);
while ( $row = mysqli_fetch_object($res) )
{
SQL_Query_exec("UPDATE users SET seedbonus = seedbonus + '" . ($site_config["bonuspertime"] * $row->count) . "' WHERE id = '" . $row->peer . "' AND seedbonus < ".$site_config["bonusmax"]."");
}
}
// End Seedbonus



Last edited by spiritblue on 2023-08-03 14:49:26
2019-10-06 11:39:38
"MicroMonkey, post: 67255, member: 311":

this w
2019-10-06 11:40:13
Hello and a big thank you to MicroMonkey and
spiritblue everything works fine now  (y):D
2019-10-06 15:41:24
Good to hear its working for you. You should still disable mysql strict mode unless everything else is working fine for you. Good information found here https://www.torrenttrader.xyz/index.php?threads/please-create-a-video-of-howto-install-torrenttrader-on-a-linux-os.9872/#post-67265
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)
2019-10-06 16:10:40
make sure you dont have this twice in your config if using spiritblue edits :) This already exists in your config
$site_config['autoclean_interval'] = '3600'; // Time between each auto cleanup (Seconds).

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)
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