View Single Post
  #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