<?php
/**
*
* @package ppkBB3cker
* @version $Id: tmaxsl.php 1.000 2009-03-03 13:32:00 PPK $
* @copyright (c) 2009 PPK
* http://ppkbb3cker.rx22.ru, http://protoneutron.narod.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

	$sql="SELECT SUM(IF(seeder='yes', 1, 0)) seed, SUM(IF(seeder='no', 1, 0)) leech FROM ".TRACKER_PEERS_TABLE." WHERE userid='$userid'";
	$result=my_sql_query($sql);
	$max_seed_leech=mysql_fetch_row($result);
	mysql_free_result($result);

	if($attachment['id'])
	{
		$max_seed_leech[0]-=1;
		$max_seed_leech[1]-=1;
	}
	if($seeder=='no' && (!$rights[8] || !$rights[2]) && $ppkbb_tcmaxleech_restr)
	{
		if(!function_exists('get_trestricts'))
		{
			include($tincludedir.'trestricts.'.$phpEx);
		}		
		$t_leech=get_trestricts($user['user_uploaded'], $user['user_downloaded'], $userratio, $ppkbb_tcmaxleech_restr);
		if (($t_leech > 0 && $max_seed_leech[1] >= $t_leech) || ($t_leech==0))
		{
			err("Ratio And/Or Download Restrictions: Maximum torrents to leeching: $t_leech");
		}
	}
	if($seeder=='yes' && $max_seed_leech[0] >= $ppkbb_tcmax_seed)
	{
		err("Maximum torrents to seeding: $ppkbb_tcmax_seed");
	}
	if($seeder=='no' && $max_seed_leech[1] >= $ppkbb_tcmax_leech)
	{
		err("Maximum torrents to leeching: $ppkbb_tcmax_leech");
	}
?>