<?php
/**
*
* @package ppkBB3cker
* @version $Id: tmaxip.php 1.000 2009-03-03 13:31: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(1) pertr, SUM(IF(torrent='$torrentid', 1, 0)) pertorr FROM ".TRACKER_PEERS_TABLE." WHERE ip='$ip'";//, SUM(IF(seeder='yes', 1, 0)) perseed, SUM(IF(seeder='no', 1, 0)) perleech
	$result=my_sql_query($sql);
	$max_ip=mysql_fetch_row($result);
	mysql_free_result($result);
	if($attachment['id'])
	{
		$max_ip[0]-=1;
		$max_ip[1]-=1;
	}

	if($ppkbb_tcmaxip_pertr && $max_ip[0] >= $ppkbb_tcmaxip_pertr)
	{
		err("Maximum Connections (From One IP) Per Tracker Reached: $ppkbb_tcmaxip_pertr");
	}
	if($ppkbb_tcmaxip_pertorr && $max_ip[1] >= $ppkbb_tcmaxip_pertorr)
	{
		err("Maximum Connections (From One IP) Per Torrent Reached: $ppkbb_tcmaxip_pertorr");
	}
?>