<?php
/**
*
* @package ppkBB3cker
* @version $Id: memberlist_add1.php 1.000 2009-02-26 15:55:00 PPK $
* @copyright (c) 2008б 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;
}

		if(!function_exists('display_forums'))
		{
            		include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
            	}
		$sql="SELECT SUM(IF(user_id='{$user_id}', 1, 0)) from_user, SUM(IF(to_user='{$user_id}', 1, 0)) to_user FROM ". TRACKER_THANKS_TABLE ." WHERE user_id='{$user_id}' OR to_user='{$user_id}'";
		$result=$db->sql_query($sql);
		$user_thanks=$db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		$is_admod=$auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_') ? 1 : 0;

		$template->assign_vars(array(
			'TRACKER_USER_TORRENTS'		=> '<a href="'.append_sid("{$phpbb_root_path}search.$phpEx", "search_id=egosearch&amp;torrent=my&amp;u=".$user_id).'">'.$member['user_torrents'].'</a>',
			'TRACKER_USER_COMMENTS'		=> '<a href="'.append_sid("{$phpbb_root_path}search.$phpEx", "search_id=egosearch&amp;torrent=mycomment&amp;u=".$user_id).'">'.$member['user_comments'].'</a>',
			'TRACKER_USER_UPLOAD'		=> get_formatted_filesize($member['user_uploaded'], 0).' '.get_size_lang($member['user_uploaded']),
			'TRACKER_USER_DOWNLOAD'		=> get_formatted_filesize($member['user_downloaded'], 0).' '.get_size_lang($member['user_downloaded']),
			'TRACKER_USER_REALDOWNLOAD'		=> $member['user_id']==$user->data['user_id'] || $is_admod ? get_formatted_filesize($member['user_shadow_downloaded'], 0).' '.get_size_lang($member['user_shadow_downloaded']) : '',
			'TRACKER_USER_BONUS'		=> $member['user_bonus'],
			'TRACKER_USER_YTHANKS'		=> intval($user_thanks['from_user']),
			'TRACKER_USER_TYTHANKS'		=> intval($user_thanks['to_user']),
			'TRACKER_USER_RRATIO'		=> get_ratio($member['user_uploaded'], $member['user_downloaded']),
			'TRACKER_USER_RATIO'		=> get_ratio($member['user_uploaded'], $member['user_downloaded'], $config['ppkbb_tcratio_start'], $member['user_bonus']),
			'TRACKER_USER_PASSKEY'		=> /*$member['user_id']==$user->data['user_id'] || $is_admod ? $member['user_passkey'] : */'',
		));

		$torrent_opt=request_var('opt', '');
		$torrent_info_curr='';

		$torrent_info_curr_explain=array();
		$assign_vars=array();
		$torrent_info=array();
		$sort_opt=array();
		$i3=0;

		$memberlist_url=append_sid("memberlist.$phpEx", "mode=viewprofile&amp;u=".$user_id);
		$torrent_info['torrent']="<a href='{$memberlist_url}&amp;opt=torrent&amp;optp=topic_title#opt'>{$user->lang['USER_TORRENT']}</a>";
		$torrent_info['finished']="<a href='{$memberlist_url}&amp;opt=finished&amp;optp=topic_title#opt'>{$user->lang['USER_TORRENT_FINISH']}</a>";
		$torrent_info['seed']="<a href='{$memberlist_url}&amp;opt=seed&amp;optp=topic_title#opt'>{$user->lang['USER_TORRENT_SEED']}</a>";
		$torrent_info['leech']="<a href='{$memberlist_url}&amp;opt=leech&amp;optp=topic_title#opt'>{$user->lang['USER_TORRENT_LEECH']}</a>";
		$torrent_info['tothanks']="<a href='{$memberlist_url}&amp;opt=tothanks&amp;optp=username#opt'>{$user->lang['USER_TORRENT_TOTHANKS']}</a>";
		$torrent_info['fromthanks']="<a href='{$memberlist_url}&amp;opt=fromthanks&amp;optp=username#opt'>{$user->lang['USER_TORRENT_FROMTHANKS']}</a>";
		$torrent_info['history']="<a href='{$memberlist_url}&amp;opt=history&amp;optp=topic_title#opt'>{$user->lang['USER_TORRENT_HISTORY']}</a>";
		$torrent_info['leave']="<a href='{$memberlist_url}&amp;opt=leave&amp;optp=topic_title#opt'>{$user->lang['USER_TORRENT_LEAVE']}</a>";

			$opt_sort=request_var('opts', '');
			$opt_param=request_var('optp', '');
			$opt_sort=='ASC' ? '' : $opt_sort='DESC';
			$memberlist_add1inc=$phpbb_root_path.'tracker/include/';
			switch($torrent_opt)
			{
				case 'leave':
					include($memberlist_add1inc.'memberlist_add1_leave.'.$phpEx);
					break;

				case 'history':
					include($memberlist_add1inc.'memberlist_add1_history.'.$phpEx);
					break;

				case 'finished':
					include($memberlist_add1inc.'memberlist_add1_finished.'.$phpEx);
					break;

				case 'seed':
					include($memberlist_add1inc.'memberlist_add1_seed.'.$phpEx);
					break;

				case 'leech':
					include($memberlist_add1inc.'memberlist_add1_leech.'.$phpEx);
					break;

				case 'tothanks':
					include($memberlist_add1inc.'memberlist_add1_tothanks.'.$phpEx);
					break;

				case 'fromthanks':
					include($memberlist_add1inc.'memberlist_add1_fromthanks.'.$phpEx);
					break;


				case 'torrent':
					include($memberlist_add1inc.'memberlist_add1_torrent.'.$phpEx);
					break;

				default:
					$torrent_opt=0;
					break;
			}
			$db->sql_freeresult($result);

		$template->assign_vars(array(
			'S_HAS_TORRENT_EXPLAIN'	=> $torrent_info_curr ? true : false,
			'S_HAS_TORRENT_EXPLAIN_TORRENT'	=> @$torrent_info_curr_explain['torrent'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_FINISHED'	=> @$torrent_info_curr_explain['finished'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_FROMTHANKS'=> @$torrent_info_curr_explain['fromthanks'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_TOTHANKS'	=> @$torrent_info_curr_explain['tothanks'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_HISTORY'	=> @$torrent_info_curr_explain['history'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_LEAVE'	=> @$torrent_info_curr_explain['leave'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_SEED'	=> @$torrent_info_curr_explain['seed'] ? true : false,
			'S_HAS_TORRENT_EXPLAIN_LEECH'	=> @$torrent_info_curr_explain['leech'] ? true : false,
			'TORRENT_INFO_OPT'=>implode(' : ', $torrent_info),
		));

		if($assign_vars)
		{
			foreach($assign_vars as $k2 => $v2)
			{
				$template->assign_block_vars($torrent_info_curr.'_option', $v2);
			}
		}
?>