Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   free silver and 2xup (http://www.bvlist.com/showthread.php?t=12161)

elvira 26th September 2019 17:40

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

Elena 26th September 2019 18:45

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


elvira 26th September 2019 19:14

I think we dont use same source, I use TBDev08 I just need an answer if is correct my code.


Thanks

Elena 26th September 2019 19:28

Quote:

Originally Posted by elvira (Post 54124)
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. :coffee:

elvira 26th September 2019 19:31

nice

Elena 26th September 2019 20:21

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?

elvira 26th September 2019 21:44

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

Elena 26th September 2019 22:32

Quote:

Originally Posted by elvira (Post 54128)
think this must work

:coffee:
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");}


elvira 26th September 2019 23:41

so must tested if is work or no


All times are GMT +2. The time now is 16:36.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2020, vBulletin Solutions Inc.