##############################################################
## MOD Title: Cash on index page
## MOD Author: naderman < nils_adermann@hotmail.com > (N/A) http://www.naderman.de/mods/
## MOD Description: This Mod adds the x richest users, their cash and your own cash under the newest user
## on your index page. Configurable through admin panel.
## MOD Version: 0.6.3
##
## MOD angepasst ans Orion von Twins
## http://twinsspieleforum.de
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit:
## index.php
## language/lang_english/lang_main.php
## language/lang_german/lang_main.php
## templates/cback/index_body.tpl
## Included Files:
## admin/admin_cash_indexpage.php
## templates/subSilver/admin/cash_indexpage_config.tpl
## coi_install.php
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## Please excuse my English. I'm German.
##
## This Mod requires the Cash Mod 2.2.1 or Points System.
##
## If you install this with easymod, you'll have to copy
## coi_install.php to root anyway and run it manually.
##
## You can use Admin panel to configure this Mod.
## You find it in the Cash Mod part.
##
##############################################################
## MOD History:
##
## 2003-09-05 - Version 0.0.1
## - Initial Version
##
## 2003-09-05 - Version 0.1.0
## - Richest user's cash is displayed
##
## 2003-09-05 - Version 0.1.1
## - The Currency is added after the user's cash
##
## 2003-09-06 - Version 0.2.0
## - The user's own cash is displayed below the richest user
##
## 2003-09-06 - Version 0.2.1
## - $cash_order is working now
##
## 2003-09-06 - Version 0.3.0
## - number of richest users can be changed
## - prefix and postfix possible
## - Cashname as image supported
##
## 2003-09-09 - Version 0.4.0
## - Configurable in Admin Panel
## - Guests don't see "You have 0 (currency)."
## - bugfix for prefix
## - bugfix for image currencies
##
## 2003-09-11 - Version 0.5.0
## - Points Mod compatible
## - you can choose how the x richest users are listed
##
## 2003-09-12 - Version 0.5.1
## - several bugfixes
##
## 2003-09-12 - Version 0.5.2
## - several bugfixes
##
## 2004-01-08 - Version 0.6.0
## - changed for Cash Mod 2.2.1
## - thousands of improving changes
##
## 2004-08-15 - Version 0.6.1
## - rewrote Administration page
##
## 2004-08-29 - Version 0.6.2
## - fixed bugs in Administration page
##
## 2004-08-29 - Version 0.6.3
## - select Currencies for Cash Mod
## - select the displayed currency
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ COPY ]------------------------------------------
#
copy admin/admin_cash_indexpage.php to admin/admin_cash_indexpage.php
copy admin/style/cash_indexpage_config.tpl to admin/style/cash_indexpage_config.tpl
copy coi_install.php to coi_install.php
#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
define('IN_PHPBB', true);
#
#-----[ AFTER, ADD ]------------------------------------------
#
define('IN_CASHMOD', true);
#
#-----[ FIND ]------------------------------------------
#
$template->set_filenames(array(
'body' => 'index_body.tpl')
);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// RICHEST USER MOD
//
$l_users_cash = $lang['users_cash'];
// Check wether turned on
if ($board_config['cash_richdis'] != 'no')
{
// amount of displayed users
$display_limit = $board_config['cash_richnum'];
// Plural or singular ?
if ( $display_limit > 1)
{
$sornot = '
'.$lang['Richest_users'];
}
else
{
$sornot = '
'.$lang['Richest_user'];
}
}
else
{
$sornor = '';
}
// Cash or Points?
if ($board_config['cash_pointsorcash'] == 'cash')
{
//
// SELECT CASH FIELD NAMES
//
$use_fields = $board_config['cash_indexfields'];
if ($use_fields == '')
{
$use_fields = array();
}
else
{
$use_fields = explode(',', str_replace(array("\n","\r","\t"," ", 0xFF), '', $use_fields));
}
$cash_overall_change = 0;
$cash_id = 1;
$i = 0;
$cash_sqls = '';
$cash_order = '';
while ( $c_cur = &$cash->currency_next($i,CURRENCY_ENABLED) )
{
$cash_change = $c_cur->data('cash_exchange');
if (($cash_change < $cash_overall_change)||($i==1))
{
$cash_id = $c_cur->id();
$cash_overall_change = $cash_change;
}
$cash_field = $c_cur->db();
$cash_sqls = ''.$cash_sqls.', '.$cash_field.'';
$cash_order = ''.$cash_order.'('.$cash_field.' / '.$cash_change.') + ';
}
}
else
{
$cash_sqls = ', user_points';
$cash_order = 'user_points + ';
$cash_name = $board_config['points_name'];
}
// Check wether turned on
if ($board_config['cash_richdis'] != 'no')
{
//
// SELECT RICHEST USER
//
$sql = "SELECT user_id, username $cash_sqls
FROM " . USERS_TABLE . "
WHERE (user_id <> " . ANONYMOUS . " )
ORDER BY ( $cash_order 0) DESC
LIMIT " . $display_limit;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't retrieve users data", "", __LINE__, __FILE__, $sql);
}
$user_countusers = $db->sql_numrows($result);
$user_data = $db->sql_fetchrowset($result);
for ($i = 0; $i < $user_countusers; $i++)
{
$richest_user = $user_data[0]['username'];
$richest_uid = $user_data[0]['user_id'];
$richests_cash = 0;
if ($board_config['cash_pointsorcash'] == 'cash')
{
while ( $c_cur = &$cash->currency_next($j,CURRENCY_ENABLED) )
{
if ((empty($use_fields)) || (in_array($c_cur->id(), $use_fields)))
{
$cash_field = $c_cur->db();
$cash_change = $c_cur->data('cash_exchange');
$richests_cash = $richests_cash + ($user_data[$i][$cash_field]/$cash_change);
}
}
}
else
{
$richests_cash = $user_data[$i]['user_points'];
}
if ( $i != 0 )
{
($board_config['cash_komma'] == 'komma') ?
$komma = ', ':
$komma = '
';
}
if ($board_config['cash_pointsorcash'] == 'cash')
{
$c_cur = $cash->currency($cash_id);
if ($board_config['cash_displaycurrency'] != '')
{
$c_cur_to = $cash->currency(intval($board_config['cash_displaycurrency']));
$richests_cash = (($richests_cash/($c_cur->data('cash_exchange')))*($c_cur_to->data('cash_exchange')));
$c_cur = $c_cur_to;
unset($c_cur_to);
}
$richests_cash = $c_cur->display(round($richests_cash,$c_cur->data('cash_decimals')));
$cashn = ' ('.$richests_cash.')';
}
else
{
$cashn = ' ('.$richests_cash.' '.$cash_name.')';
}
$template->assign_block_vars('richestrow', array(
'USERNAME' => $user_data[$i]['username'],
'KOMMA' => $komma,
'URL' => '',
'CASH' => $cashn)
);
}
}
//
// USER'S CASH
//
// if this is not a guest
if ( $userdata['session_logged_in'] )
{
// Check wether turned on
if ($board_config['cash_userdis'] != 'no')
{
// Cash or Points?
if ($board_config['cash_pointsorcash'] == 'cash')
{
$cash_overall_change = 0;
$cash_id = 1;
$i = 0;
$users_money = 0;
while ( $c_cur = &$cash->currency_next($i,CURRENCY_ENABLED) )
{
$cash_change = $c_cur->data('cash_exchange');
if ((empty($use_fields)) || (in_array($c_cur->id(), $use_fields)))
{
$users_money = $users_money + $userdata[$c_cur->db()] / $cash_change;
}
if (($cash_change < $cash_overall_change)||($i==1))
{
$cash_id = $c_cur->id();
$cash_overall_change = $cash_change;
}
}
$c_cur = $cash->currency($cash_id);
if (($board_config['cash_displaycurrency'] != '') && ($c_cur->id() != $board_config['cash_displaycurrency']))
{
$c_cur_to = $cash->currency(intval($board_config['cash_displaycurrency']));
$users_money = (($users_money/intval($c_cur->data('cash_exchange')))*(intval($c_cur_to->data('cash_exchange'))));
$c_cur = $c_cur_to;
unset($c_cur_to);
}
$users_cash = ' '.$c_cur->display(round($users_money,$c_cur->data('cash_decimals'))).'';
}
else
{
$users_cash = ' '.$userdata['user_points'].' '.$board_config['points_name'].'';
}
}
else
{
$l_users_cash = '';
$users_cash = '';
}
}
else
{
$l_users_cash = '';
$users_cash = '';
}
//
// END OF RICHEST USER MOD
//
#
#-----[ FIND ]------------------------------------------
#
'NEWEST_USER' => sprintf($lang['Newest_user'], '', $newest_user, ''),
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_RICHEST_USER' => $sornot,
'USERS_CASH' => $users_cash,
'L_USERS_CASH' => $l_users_cash,
#
#-----[ OPEN ]------------------------------------------
#
templates/cback/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#