################################################################################### 
## HACK Title:		Music Statistics (Music Online Mod by Cf Manager) 3
## HACK Version:	1.0.0 (ex phpbb 2.0.8)
## HACK Author:		Cf Manager < cf_manager@yahoo.com > (Thai Thanh Son)
## Support:		http://cfmanager.net.tf
##
## Description:	 	This hack will help you can create the Music Statistics 
##			Block on your ezPortal or Index Page
##
## Compatibility:	2.0.4 --> 2.0.8 (I tested on phpBB 2.0.6 & 2.0.8)
##
## HACK Level:		Medium
## HACK Time:		5 - 10 min
## Files to edit:	3
##			language/lang_english/lang_main.php
##			portal.php
##			index.php
##      	templates/subSilver/portal_body.tpl
##			templates/subSilver/index_body.tpl
##
## Included Files:	n/a
##
################################################################################### 
## Installation/Author Notes:
## 
## 	Full support for this HACK can be obtained at: http://cfmanager.net.tf 
## 	This HACK was tested with the following databases: MySQL
################################################################################### 
## HACK History:
## 		01/07/2004 v1.0.0: First Release ;)
###################################################################################
## This HACK is released under the GPL License.
###################################################################################
## BEFORE, ADDing This HACK To Your Forum, You Should Back Up All Files Related To This HACK
###################################################################################
###################################################################################
#
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------
# 
$lang['Music'] = 'Music'

# 
#-----[ AFTER, ADD ]-------------------------------------
#
//
// Music Statistics
//
$lang['Music_Statistics'] = 'Music Statistics'; // for ezPortal only
$lang['Posted_songs_total'] = 'Our users have posted a total of <b>%d</b> songs'; // Number of songs
$lang['Cats_total'] = 'within <b>%d</b> categories';
$lang['Newest_song'] = 'The newest song is:';

#
#-----[ OPEN ]------------------------------------------ 
# 
index.php
# 
#-----[ FIND ]------------------------------------------
# 
//
// Start page proper
//

# 
#-----[ BEFORE, ADD ]------------------------------------
#
//
// BEGIN Music Statistics
//

// Get Categories Info
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
			FROM " . MUSIC_CAT_TABLE . " c
			ORDER BY c.cat_order";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query cats information', '', __LINE__, __FILE__, $sql);
}
$catrow = array();
while( $row = $db->sql_fetchrow($result) )
{
	$catrow[] = $row;
}
$total_cats = count($catrow);

// Get Songs Info
$sql = "SELECT s.song_id, s.song_title, s.song_user_id, s.song_username, s.song_time
			FROM " . MUSIC_TABLE . " s
			ORDER BY s.song_time DESC";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query songs information', '', __LINE__, __FILE__, $sql);
}
$songrow = array();
while( $row = $db->sql_fetchrow($result) )
{
	$songrow[] = $row;
}
$total_songs = count($songrow);

// Get Last Song Info
$sql = "SELECT song_id, song_title, song_user_id, song_username, song_time 
			FROM phpbb_music 
			ORDER BY song_time DESC 
			LIMIT 0,1";
if (!$result = $db->sql_query($sql))
	{
	message_die(GENERAL_ERROR, 'Could not query last song information', '', __LINE__, __FILE__, $sql);
	}
$lastsong = $db->sql_fetchrow($result);

//
// END Music Statistics
//

# 
#-----[ FIND ]------------------------------------------
#
		'FORUM_IMG' => $images['forum'],

# 
#-----[ BEFORE, ADD ]------------------------------------
#
		// Music Statistics
		'L_NEWEST_SONG' => $lang['Newest_song'],
		'U_SONG' => '<a href="'. append_sid('music_page.'. $phpEx . '?song_id=' .  $lastsong['song_id']) . '">' . $lastsong['song_title'] . '</a>',
		'SONG_POSTER' => '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&amp;".  POST_USERS_URL .'='. $lastsong['song_user_id']) .'">'. $lastsong['song_username'] .'</a>',
		'SONG_TIME' => create_date($board_config['default_dateformat'], $lastsong['song_time'],  $board_config['board_timezone']),
		'TOTAL_SONGS' => sprintf($lang['Posted_songs_total'], $total_songs),
		'TOTAL_CATS' => sprintf($lang['Cats_total'], $total_cats),

#
#-----[ OPEN ]------------------------------------------ 
# Similar to other templates
templates/subSilver/index_body.tpl

# 
#-----[ FIND ]------------------------------------------
#
#	<td class="row1" align="center" valign="middle" rowspan="4"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
rowspan="4"
# 
#-----[ IN-LINE FIND ]-----------------------------------
#
rowspan="4">
# 
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
rowspan="5">

# 
#-----[ FIND ]------------------------------------------
#
#  <tr> 
#	<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
#  </tr>
  <tr> 
  {TOTAL_POSTS}
  </tr>
	   
# 
#-----[ AFTER, ADD ]-------------------------------------
#
  <tr>
	<td class="row1" align="left" width="100%" colspan="2"><span class="gensmall">{TOTAL_SONGS} {TOTAL_CATS}<br /><br />{L_NEWEST_SONG} <b>{U_SONG}</b> by {SONG_POSTER} on {SONG_TIME}</span></td>
  </tr>

#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM