################################################################# 
## MOD Title: Top Posters on ezPortal - EM Friendly
## MOD Author: Spinebuster < Spinebuster27@hotmail.com > 
## MOD Author: Nightrider < NA > 
## MOD Description: This mod will add the top posting members to your ezportal portal page.  
## 	   				You can set the amount of users in your board configuration.
## MOD Version: 1.0.1
## 
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: 
## 		  portal.php
##		  admin/admin_board.php
##		  language/lang_english/lang_main.php
##		  templates/subSilver/admin/board_config_body.tpl
##		  templates/subSilver/portal_body.tpl
## Included Files: n/a
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 
############################################################## 
## For security purposes, please check: http://www.phpbb-customs.com 
## for the latest version of this MOD. Although MODs are checked 
## before being allowed in the MODs Database there is no guarantee 
## that there are no security problems within the MOD. No support 
## will be given for MODs not found within the MODs Database which 
## can be found at http://www.phpbb-customs.com
############################################################## 
## Author Notes: If EM cannot complete the SQL query, please run the SQL command 
## 		  		 that I have provided in this file prior to installing this mod.
##
## NOTE:  Do not add this version if you have already installed the Top Posters on Index MOD.
## 		  You would want to remove the parts from this script that have already been installed...
## 
############################################################## 
## MOD History: 
##
##   2006-1-22 - Version 1.0.1 
##      - Fixed a few minor issues and added code for if you had aUsTiN's AUC mod installed. 
##   2005-12-29 - Version 1.0.0 
##      - Initial Release
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
#
#-----[ SQL ]---------------------------------------------
#
INSERT INTO phpbb_config (config_name, config_value) VALUES ('top_posters','10');
#
#-----[ OPEN ]---------------------------------------------
#
portal.php
#
#-----[ FIND ]---------------------------------------------
#
//
// Generate the page
#
#-----[ BEFORE, ADD ]---------------------------------------------
#
// Begin Top Posters on Index
if ($board_config['top_posters'])
{
	$top_posters = $board_config['top_posters'];

	$sql = "SELECT username, user_id, user_level, user_posts
        	FROM " . USERS_TABLE . "
        	WHERE user_id <> " . ANONYMOUS . "
        	ORDER BY user_posts DESC LIMIT $top_posters";
	if( !($result = $db->sql_query($sql)) )
	{
        message_die(GENERAL_ERROR, 'Could not Query Top Posting Users', '', __LINE__, __FILE__, $sql);
	}

	$user_count = $db->sql_numrows($result);
	$user_data = $db->sql_fetchrowset($result);

	$firstcount = $user_data[0]['user_posts'];
	$total_posts = get_db_stat('postcount');
	$total_top_posters = 0;
	$top_posters_userlist = '';
	$seperator 	= ', ';

	for ($i = 0; $i < $user_count; $i++)
	{
		if ($user_data[$i]['user_level'] == ADMIN)
		{
			$user_data[$i]['username'] = '<b><span style="color:#'. $theme['fontcolor3'] .'">'. $user_data[$i]['username'] .'</span></b>';
		}
		else if ($user_data[$i]['user_level'] == MOD)
		{
			$user_data[$i]['username'] = '<b><span style="color:#'. $theme['fontcolor2'] .'">'. $user_data[$i]['username'] .'</span></b>';
		}
		else
		{
			$user_data[$i]['username'] = '<b><span style="color:#'. $theme['fontcolor1'] .'">'. $user_data[$i]['username'] .'</span></b>';
		}
		
		$top_posters_userlist .= (( ($top_posters_userlist) && ($user_data[$i]['user_id']) ) ? $seperator : '') .'<a alt="'. $alt .'" title="'. $alt .'" href="profile.'. $phpEx .'?mode=viewprofile&amp;u='. $user_data[$i]['user_id'] .'" class="copyright">'. $user_data[$i]['username'] .'</a>('. $user_data[$i]['user_posts'] .')';
		
		$total_top_posters++;
	}

	$template->assign_vars(array(		
	'L_TOP_POSTERS' => $lang['Top_Posters'],
	'TOP_POSTERS' => $top_posters_userlist
		)
	);
}
// End Top Posters on Index

#
#-----[ OPEN ]---------------------------------------------
#
#
admin/admin_board.php
#
#-----[ FIND ]---------------------------------------------
#
"S_CONFIG_ACTION" =>
#
#-----[ AFTER, ADD ]---------------------------------------------
#
	//Top Posters on Index
	'L_TOP_POSTERS'		=> $lang['Top_Posters'],
	'L_TOP_POSTERS_EXP'	=> $lang['Top_Posters_Exp'],
	'TOP_POSTERS'		=> $board_config['top_posters'],
#
#-----[ OPEN ]---------------------------------------------
#
#
language/lang_english/lang_main.php
#
#-----[ FIND ]---------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]---------------------------------------------
#
// Top Posters on Index
$lang['Top_Posters'] = 'Top Posting Members';
$lang['Top_Posters_Exp'] = 'Amount of Top Posting Members on Index Page.';
#
#-----[ OPEN ]---------------------------------------------
#
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]---------------------------------------------
#
{PRUNE_YES}
#
#-----[ FIND ]---------------------------------------------
#
</tr>
#
#-----[ AFTER, ADD ]---------------------------------------------
#
	<!-- Begin: Top Posters on Index -->
	<tr>
		<td class="row1">{L_TOP_POSTERS}<br /><span class="gensmall">{L_TOP_POSTERS_EXP}</span></td>
		<td class="row2"><input type="text" class="post" size="3" maxlength="4" value="{TOP_POSTERS}" name="top_posters"></td>
	</tr>
	<!-- End: Top Posters on Index -->
#
#-----[ OPEN ]---------------------------------------------
#
#
templates/subSilver/portal_body.tpl
#
#-----[ FIND ]---------------------------------------------
#
<table
<tr>
{L_STATISTICS}
#
#-----[ BEFORE, ADD ]---------------------------------------------
#
<!-- Begin: Top Posters on Index -->
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
	<td class="catHead" align ="left" colspan="2" nowrap="nowrap"><span class="genmed"><b>{L_TOP_POSTERS}</b></span></td>
</tr>
<tr>
	<td class="row1" align="left" valign="middle" width="100%"><span class="genmed">{TOP_POSTERS}</span></td>
</tr>
</table>

<br />
<!-- End: Top Posters on Index -->
# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------- 
# 
# EoM