Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 26th September 2019, 17:40
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default free silver and 2xup
hey can someone check if I have correct in announce.php


PHP Code:
$res mysql_query("SELECT id, banned, free, silver, dupla_seed, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " hash_where("info_hash"$info_hash)); 

and this one use for userfree


PHP Code:
    $rz mysql_query("SELECT id, uploaded, downloaded, class, userfree, parked FROM users WHERE passkey=".sqlesc($passkey)." AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2"); 

and this







Quote:
//userfree
if ($upthis > 0 || $downthis > 0)
if ($az["userfree"] == "no")
$downthis = max(0, $downloaded - $self["downloaded"]);
else
$downthis = 0;

//2x upload
if ($torrent['dupla_seed']=='yes')
if ($upthis > 0 || $downthis > 0)
$upthis = $upthis * 2;

//silver download
if($torrent['silver']=='yes'){
if ($upthis > 0 || $downthis > 0)
$downthis=$downthis/2;
$upthis = $upthis*2;
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3 (silver)");
}

//normal download
if ($torrent['free']=='no')
if ($upthis > 0 || $downthis > 0)
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");

//gold download
if ($torrent['free']=='yes')
if ($upthis > 0 || $downthis > 0)
mysql_query("UPDATE users SET uploaded = uploaded + $upthis WHERE id=$userid") or err("Tracker error 3");

thanks for help

Last edited by elvira; 26th September 2019 at 18:32.
Reply With Quote
  #2  
Old 26th September 2019, 18:45
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 111
Default
And what about the free cell, what are the values there?
I already have three samples there - bril, yes, silver, no.

Here is the code from my announce.php, remake it for yourself, the principle should be the same.

Code:
dbconn();
$cache = new Memcache();$cache->connect('127.0.0.1', 11211);$valid = array();if(!$valid = $cache->get('user_passkey_'.$passkey)){$valid = mysql_num_rows(mysql_query("SELECT id FROM users WHERE passkey = ".sqlesc($passkey))) or err(mysql_error());$cache->set('user_passkey_'.$passkey, $valid, MEMCACHE_COMPRESSED, 7200);}if($valid == 0) err('Invalid passkey! Re-download the .torrent from '.$DEFAULTBASEURL);
$hash = bin2hex($info_hash);
$torrent = array();if(!$torrent = $cache->get('torrent_infohash_'.$hash)){$res = mysql_query('SELECT id, visible, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE info_hash = "'.$hash.'"') or err('Torrents error 1 (select)');$torrent = mysql_fetch_array($res); $cache->set('torrent_infohash_'.$hash, $torrent, MEMCACHE_COMPRESSED, 300);}


switch($torrent['free']){
case 'bril': $upthist = round($upthis * 2);$downthist = 0;break;
case 'yes': $upthist = max(0, $uploaded - $self['uploaded']);$downthist = 0;break;
case 'silver': $upthist = max(0, $uploaded - $self['uploaded']);$downthist = round($downthis / 2);break;
case 'no': $upthist = max(0, $uploaded - $self['uploaded']);$downthist = max(0, $downloaded - $self['downloaded']);break;}
$upthisr = $upthist;$downthisr = $downthist;
if($upthis > 0 || $downthis >= 0){
mysql_query('UPDATE LOW_PRIORITY users SET uploaded = uploaded + '.$upthisr.', downloaded = downloaded + '.$downthisr.' WHERE id='.$userid) or err('Users error 2 (update)');}
$downloaded2 = max(0, $downloaded - $self['downloaded']);$uploaded2 = max(0, $uploaded - $self['uploaded']);
if($downloaded2 > 0 || $uploaded2 > 0){$snatch_updateset[] = "uploaded = uploaded + $uploaded2";$snatch_updateset[] = "downloaded = downloaded + $downloaded2";$snatch_updateset[] = "to_go = $left";}
$snatch_updateset[] = "port = $port";$snatch_updateset[] = "last_action = $dt";$snatch_updateset[] = "seeder = '$seeder'";$prev_action = $self['last_action'];
mysql_query("UPDATE LOW_PRIORITY peers SET uploaded = $uploaded, downloaded = $downloaded, uploadoffset = $uploaded2, downloadoffset = $downloaded2, to_go = $left, last_action = NOW(), prev_action = ".sqlesc($prev_action).", seeder = '$seeder'".($seeder == "yes" && $self["seeder"] != $seeder ? ", finishedat = " . time() : "").", agent = ".sqlesc($agent)." WHERE $selfwhere") or err('Peers error 3 (update)');

Last edited by Elena; 26th September 2019 at 19:04.
Reply With Quote
  #3  
Old 26th September 2019, 19:14
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
I think we dont use same source, I use TBDev08 I just need an answer if is correct my code.


Thanks
Reply With Quote
  #4  
Old 26th September 2019, 19:28
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 111
Default
Quote:
Originally Posted by elvira View Post
I think we dont use same source, I use TBDev08 I just need an answer if is correct my code.

Thanks
Too many unnecessary requests, everything can be reduced to one and reduce the load on the announcement. I gave the code, it is for the TBDeV script and its source. Now I’ll correct you your code if you can’t make out my improved version.
Reply With Quote
  #5  
Old 26th September 2019, 19:31
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
nice
Reply With Quote
  #6  
Old 26th September 2019, 20:21
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 111
Default
I propose this option with a minimum of edits and a minimum of queries in the announcer (will not hammer the database constantly).

Database query:
Code:
ALTER TABLE `torrents` ADD `free` enum('bril','yes','silver','no') DEFAULT 'no';
remove unnecessary from your request, namely: silver, dupla_seed,
to stay like this:
Code:
$res = mysql_query("SELECT id, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " . hash_where("info_hash", $info_hash));
Well, actually the code that is responsible for the double upload, gold, silver or without discounts:
Code:
switch($torrent['free']){
case 'bril': $upthist = round($upthis * 2);$downthist = 0;break;
case 'yes': $upthist = max(0, $uploaded - $self['uploaded']);$downthist = 0;break;
case 'silver': $upthist = max(0, $uploaded - $self['uploaded']);$downthist = round($downthis / 2);break;
case 'no': $upthist = max(0, $uploaded - $self['uploaded']);$downthist = max(0, $downloaded - $self['downloaded']);break;}
$upthisr = $upthist;$downthisr = $downthist;
if($upthis > 0 || $downthis >= 0){
mysql_query('UPDATE LOW_PRIORITY users SET uploaded = uploaded + '.$upthisr.', downloaded = downloaded + '.$downthisr.' WHERE id='.$userid) or err('Users error 2 (update)');}
This is your request to userfree for what actually answers?
Code:
$rz = mysql_query("SELECT id, uploaded, downloaded, class, userfree, parked FROM users WHERE passkey=".sqlesc($passkey)." AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
Global freezing of all torrents on the tracker? Is everything in gold?
Reply With Quote
  #7  
Old 26th September 2019, 21:44
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
Quote:
if ($torrent['free'] == 'yes')
$downthis = 0;
if ($torrent['dupla_seed'] == 'yes')
$upthis = $upthis * 2;
if ($torrent['silver']=='yes')
$downthis=$downthis * 2;
$upthis = $upthis * 2;
if ($upthis > 0 || $downthis > 0)
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");

think this must work
Reply With Quote
  #8  
Old 26th September 2019, 22:32
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 111
Default
Quote:
Originally Posted by elvira View Post
think this must work

Code:
if ($torrent['free'] == 'yes'){$downthis = 0;}
elseif ($torrent['dupla_seed'] == 'yes'){$upthis = $upthis * 2;}
elseif ($torrent['silver']=='yes'){$downthis=$downthis * 2;$upthis = $upthis * 2;}
elseif ($torrent['free']=='no'){$downthis=$downthis;$upthis = $upthis}
if ($upthis > 0 || $downthis > 0){
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");}

Last edited by Elena; 26th September 2019 at 22:48.
Reply With Quote
  #9  
Old 26th September 2019, 23:41
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
so must tested if is work or no
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 11:32. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.