|
#1
|
||||
|
||||
free silver and 2xup
hey can someone check if I have correct in announce.php
PHP Code:
and this one use for userfree PHP Code:
and this Quote:
thanks for help Last edited by elvira; 26th September 2019 at 18:32. |
#2
|
|||
|
|||
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. |
#3
|
||||
|
||||
I think we dont use same source, I use TBDev08 I just need an answer if is correct my code.
Thanks |
#4
|
|||
|
|||
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.
|
#5
|
||||
|
||||
nice
|
#6
|
|||
|
|||
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'; 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)); 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)');} 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"); |
#7
|
||||
|
||||
Quote:
think this must work |
#8
|
|||
|
|||
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. |
#9
|
||||
|
||||
so must tested if is work or no
|
|
|