############################################################## 
## MOD Title:          Fully integrated shoutbox 
## MOD Author:         Niels < ncr@db9.dk > (Niels Chr. Rd) http://mods.db9.dk
##			Modified for TorrentPier R775 modern by Demetri (Dmitriy Y. Mayer)
## MOD Description:    A fully phpBB2 enabled shoutbox witch support:
##                     database abstration layer, timezones, languages
##                     templates, smilies, BBcode and censored words
##
## MOD Version:        1.1.6 / 0.2.2b for TorrentPier R775 modern
## MOD Compatibility:  TorrentPier R775 modern
## 
## Installation Level: Intermediate
## Installation Time:  ~15-20 Minutes
## Files To Edit:
##      index.php
##      admin/admin_board.php
##      admin/admin_users.php
##      includes/init_bb.php
##	includes/usercp_register.php
##      language/lang_russian/lang_admin.php 
##      language/lang_russian/lang_main.php
##      templates/default/index.tpl
##	templates/default/usercp_register.tpl
##      templates/admin/admin_board.tpl
##      templates/admin/admin_users.tpl
##	templates/default/tpl_config.php
##
## Included Files:
##      shoutbox_db_update.php
##      root/shoutbox.php
##      root/shoutbox_max.php
##      root/shoutbox_view.php
##      root/templates/default/bbcode.js
##      root/templates/default/shoutbox_body.tpl
##      root/templates/default/shoutbox_max_body.tpl
##      root/templates/default/shoutbox_max_guest_body.tpl
##      root/templates/default/shoutbox_view_body.tpl
##	root/templates/default/shoutbox_modcp_viewip.tpl
##      root/templates/default/images/shoutbox/icon_censor.gif
##
############################################################## 
## Author Notes: 
## 
## 1. Full MOD description
## -----------
## A fully phpBB2 enabled shoutbox witch support: database
## abstration layer, timezones, languages templates, smilies,
## BBcode, censored words and user/usergroups.
## Shouts can be set to auto prune after X days, this will
## be executed when ever a user post a shout
##
##  <skipped>
## 
############################################################## 
## MOD History:
##
##   2008-09-12 - Version 0.2.2b
##	- Fix in shoutbox_db_update.php
##
##   2008-09-11 - Version 0.2.1b
##	- Fix in admin/admin_users.php
## 
##   2008-09-11 - Version 0.2.0b
##	- User's option "Shoutbox ON/OFF" added
##	- Shoutbox properties in AdminPanel translated into russian
##	- Changes in admin/admin_users.php
##	- Changes in templates/admin/admin_users.tpl
##	- Changes in includes/usercp_register.php
##	- Changes in templates/default/usercp_register.tpl
##	- Changes in index.php
##	- Changes in templates/default/index.tpl
##	- Changes in language/lang_russian/lang_main.php
##	- Changes in language/lang_russian/lang_admin.php
##	- Changes in shoutbox_db_update.php
##
##   2008-09-10 - Version 0.1.1b
##	- Shoutbox MAX available to Admin/Moderators only
##      - Changes in index.php
##      - Changes in /templates/default/index.tpl
##	- Changes in shoutbox_max.php
## 
##   2008-09-09 - Version 0.1.0b
##      - Changes in index.php
##      - Changes in /templates/default/index.tpl
##      - Changes in shoutbox.php
##      - Changes in /templates/default/shoutbox_body.tpl
##      - Changes in shoutbox_view.php
##      - Changes in /templates/default/shoutbox_view_body.tpl
## 
##   2008-09-08 - Version 0.0.2a
##      - Changes in shoutbox.php
##      - Changes in shoutbox_view.php
##      - Changes in shoutbox_max.php
## 
##   2008-09-08 - Version 0.0.1a
##      - initial alfa release 
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
# 
#-----[ COPY ]------------------------------------------------ 
#

copy shoutbox_db_update.php to shoutbox_db_update.php
copy root/shoutbox.php to shoutbox.php
copy root/shoutbox_max.php to shoutbox_max.php
copy root/shoutbox_view.php to shoutbox_view.php
copy root/templates/default/shoutbox_body.tpl to templates/default/shoutbox_body.tpl
copy root/templates/default/shoutbox_max_body.tpl to templates/default/shoutbox_max_body.tpl
copy root/templates/default/shoutbox_max_guest_body.tpl to templates/default/shoutbox_max_guest_body.tpl
copy root/templates/default/shoutbox_view_body.tpl to templates/default/shoutbox_view_body.tpl
copy root/templates/default/bbcode.js to templates/default/bbcode.js
copy root/templates/default/shoutbox_modcp_viewip.tpl to templates/default/shoutbox_modcp_viewip.tpl
copy root/templates/default/images/icon_censor.gif to templates/default/images/icon_censor.gif

#
#-----[ UPDATE DB ]------------------------------------------------
#

# This MOD need a database update.
# Then, as you must have now copied the shoutbox_db_update.php file
# in your phpBB root directory, run it with your navigator...
#
# http://name.domain/forum/shoutbox_db_update.php
#
# ...and then delete it from the phpBB root directory!!!
#
# Please, do it NOW! Before editing phpBB files by EM or manually!!!
# Otherwise, you may have an error message during your next
# connection.

# 
#-----[ OPEN ]------------------------------------------------ 
#

index.php

# 
#-----[ FIND ]------------------------------------------------ 
#

	'FORUM_LOCKED_IMG'      => $images['forum_locked'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	// [MOD] Shoutbox

	'U_SHOUTBOX' => append_sid("shoutbox.$phpEx"),
	'L_SHOUTBOX' => $lang['Shoutbox'],
	'L_MINI_SHOUTBOX' => $lang['Mini_Shoutbox'],
	'L_OPEN_SHOUTBOX_MAX' => $lang['Open_Shoutbox'],
	'U_SHOUTBOX_MAX' => append_sid("shoutbox_max.$phpEx"),
	'SHOUTBOX_ON' => ($userdata['show_shoutbox'] != 0) ? true : false,
	'SHOUTBOX_MAX_ON' => (IS_ADMIN || IS_MOD) ? true : false,

	// [MOD] Shoutbox [END]

# 
#-----[ OPEN ]------------------------------------------------ 
#

admin/admin_board.php

# 
#-----[ FIND ]------------------------------------------------ 
#

	"L_ENABLE_PRUNE" => $lang['Enable_prune'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	// [MOD] Shoutbox

	'L_PRUNE_SHOUTS' => $lang['Prune_shouts'], 
	'L_PRUNE_SHOUTS_EXPLAIN' => $lang['Prune_shouts_explain'], 

	// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------------ 
#

	"PRUNE_NO" => $prune_no,

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	// [MOD] Shoutbox

	'PRUNE_SHOUTS' => $new['prune_shouts'],

	// [MOD] Shoutbox [END]

# 
#-----[ OPEN ]------------------------------------------ 
#

admin/admin_users.php

# 
#-----[ FIND ]------------------------------------------ 
#

		$allowviewonline = ( isset( $HTTP_POST_VARS['hideonline']) ) ? ( ( $HTTP_POST_VARS['hideonline'] ) ? 0 : TRUE ) : TRUE;

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

		// [MOD] Shoutbox
		
		$showshoutbox = (isset($HTTP_POST_VARS['showshoutbox'])) ? intval($HTTP_POST_VARS['showshoutbox']) : 0;
		
		// [MOD] Shoutbox  [END]

# 
#-----[ FIND ]------------------------------------------ 
#

			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql . "

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#

					user_allow_viewonline = $allowviewonline,

# 
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------ 
#

					show_shoutbox = $showshoutbox,

# 
#-----[ FIND ]------------------------------------------ 
#

		$allowviewonline = $this_userdata['user_allow_viewonline'];

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

		// [MOD] Shoutbox
		
		$showshoutbox = $this_userdata['show_shoutbox'];
		
		// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------ 
#

			$s_hidden_fields .= '<input type="hidden" name="hideonline" value="' . !$allowviewonline . '" />';

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

			// [MOD] Shoutbox
			
			$s_hidden_fields .= '<input type="hidden" name="showshoutbox" value="' . $showshoutbox . '" />';
			
			// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------ 
#

			'HIDE_USER_YES' => (!$allowviewonline) ? 'checked="checked"' : '',

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

			// [MOD] Shoutbox
		
			'L_ENABLED' => $lang['Enabled'],
			'S_SHOW_SHOUTBOX' => ($showshoutbox != 0) ? 'checked="checked"' : '',
		
			// [MOD] Shoutbox [END]
                        
# 
#-----[ FIND ]------------------------------------------ 
#

			'L_HIDE_USER' => $lang['Hide_user'],

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

			// [MOD] Shoutbox
		
			'L_SHOW_SHOUTBOX' => $lang['SHOW_SHOUTBOX'],
		
			// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------------ 
#

				user_delete($user_id, !empty($_POST['delete_user_posts']));

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

				// [MOD] Shoutbox

				$sql = "UPDATE " . SHOUTBOX_TABLE . "
					SET shout_user_id = " . DELETED . ", shout_username = '". $this_userdata['username'] ."' 
					WHERE shout_user_id = $user_id";
				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'Could not update shouts for this user', '', __LINE__, __FILE__, $sql);
				}

				// [MOD] Shoutbox [END]

# 
#-----[ OPEN ]------------------------------------------------ 
#

includes/init_bb.php

# 
#-----[ FIND ]------------------------------------------------ 
#

define('PAGE_FOOTER', INC_DIR .'page_footer.'. PHP_EXT);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

// [MOD] Shoutbox

define('PAGE_SHOUTBOX_MAX',     -1035);
define('PAGE_SHOUTBOX',         -1035);

// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------------ 
#

define('VOTE_USERS_TABLE',           $t .'vote_voters');

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

// [MOD] Shoutbox

define('SHOUTBOX_TABLE', $t.'shout');

// [MOD] Shoutbox [END]

# 
#-----[ OPEN ]------------------------------------------ 
#

includes/usercp_register.php

# 
#-----[ FIND ]------------------------------------------ 
#

if ( $bb_cfg['allow_namechange'] || $mode == 'register' )

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

	// [MOD] Shoutbox
	
	$showshoutbox = (isset($HTTP_POST_VARS['showshoutbox'])) ? intval($HTTP_POST_VARS['showshoutbox']) : 0;
	
	// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------ 
#

			$sql = "UPDATE " . USERS_TABLE . "

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#

					user_allow_viewonline = $allowviewonline,

# 
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------ 
#

					show_shoutbox = $showshoutbox,

# 
#-----[ FIND ]------------------------------------------ 
#

	$allowviewonline = $userdata['user_allow_viewonline'];

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	// [MOD] Shoutbox
	
	$showshoutbox = $userdata['show_shoutbox'];
	
	// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------ 
#

	//
	// Let's do an overall check for settings/versions which would prevent

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

	// [MOD] Shoutbox

	if ($mode == 'register')
	{	
		$showshoutbox = "1";
	}

	// [MOD] Shoutbox [END]
        
# 
#-----[ FIND ]------------------------------------------ 
#

			$sql = "INSERT INTO " . USERS_TABLE . "
                        
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#

, user_allow_viewonline

# 
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------ 
#        

, show_shoutbox 

# 
#-----[ IN-LINE FIND ]------------------------------------------ 
#

, $allowviewonline

# 
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------ 
#        

, $showshoutbox


#
#-----[ FIND ]------------------------------------------ 
#

		'VIEW_EMAIL_YES' => ( $viewemail ) ? 'checked="checked"' : '',

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

		// [MOD] Shoutbox
		
                'L_ENABLED' => $lang['Enabled'],
		'S_SHOW_SHOUTBOX' => ($showshoutbox != 0) ? 'checked="checked"' : '',
		
		// [MOD] Shoutbox [END]

# 
#-----[ FIND ]------------------------------------------ 
#

		'L_PREFERENCES' => $lang['Preferences'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

		// [MOD] Shoutbox
		
		'L_SHOW_SHOUTBOX' => $lang['SHOW_SHOUTBOX'],
		
		// [MOD] Shoutbox [END]

# 
#-----[ OPEN ]------------------------------------------------ 
# 

language/lang_russian/lang_admin.php

# 
#-----[ FIND ]------------------------------------------------ 
#

?>

# 
#-----[ BEFORE, ADD ]----------------------------------------- 
#

//
// [MOD] Shoutbox
//
$lang['Prune_shouts'] = '  -'; 
$lang['Prune_shouts_explain'] = ' ,      .   "0",     '; 
//
// [MOD] Shoutbox [END]
//

# 
#-----[ OPEN ]------------------------------------------------ 
#

language/lang_russian/lang_main.php

# 
#-----[ FIND ]------------------------------------------------ 
#

?>

# 
#-----[ BEFORE, ADD ]----------------------------------------- 
#

//
// [MOD] Shoutbox
//
$lang['Open_Shoutbox'] = '  ';
$lang['Mini_Shoutbox'] = '-';
$lang['Shoutbox'] = '';
//$lang['Shoutbox_date'] = 'h:i:s d-m-Y';
$lang['Shoutbox_date'] = 'H:i:s';
$lang['Shout_censor'] = ' ! <>';
$lang['Shout_refresh'] = '';
$lang['Shout_text'] = '';
$lang['Viewing_Shoutbox']= ' ';
$lang['Censor'] ='';
$lang['Shout_smiles'] = '';
$lang['SHOW_SHOUTBOX'] = ' -';
//
// [MOD] Shoutbox [END]
//

# 
#-----[ OPEN ]------------------------------------------------ 
#

templates/default/index.tpl

# 
#-----[ FIND ]------------------------------------------------ 
#

<div id="forums_top_links">

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

<!-- [MOD] Shoutbox -->

<!-- IF SHOUTBOX_ON -->
<br/>
<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2" class="forumline"> 
      <tr> 
         <td align="center" nowrap="nowrap" class="catHead"><span class="cattitle">{L_MINI_SHOUTBOX}<!-- IF SHOUTBOX_MAX_ON --> (<a href="{U_SHOUTBOX_MAX}">{L_OPEN_SHOUTBOX_MAX})</a><!-- ENDIF --></span></td> 
      </tr> 
      <tr>
         <td class="row2">
          <iframe src="{U_SHOUTBOX}" scrolling="NO" width="100%" height="200" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="true"></iframe>
         </td> 
      </tr> 
</table>
<br/>
<!-- ENDIF -->

<!-- [MOD] Shoutbox [END] -->

# 
#-----[ OPEN ]------------------------------------------ 
#

templates/default/usercp_register.tpl

# 
#-----[ FIND ]------------------------------------------ 
#

<tr>
	<td>{L_PUBLIC_VIEW_EMAIL}:</td>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

<!-- [MOD] Shoutbox -->

<tr>
	<td>{L_SHOW_SHOUTBOX}:</td>
	<td>
		{L_ENABLED}<input type="checkbox" name="showshoutbox" value="1" {S_SHOW_SHOUTBOX} /></td>
	</td>
</tr>
	
<!-- [MOD] Shoutbox [END] -->

# 
#-----[ OPEN ]------------------------------------------------ 
# 

templates/admin/admin_board.tpl

# 
#-----[ FIND ]------------------------------------------------ 
#

<tr>
	<td><h4>{L_ENABLE_PRUNE}</h4></td>
	<td><input type="radio" name="prune_enable" value="1" {PRUNE_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="prune_enable" value="0" {PRUNE_NO} /> {L_NO}</td>
</tr>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

<!-- [MOD] Shoutbox -->

<tr>
	<td><h4>{L_PRUNE_SHOUTS}</h4><h6>{L_PRUNE_SHOUTS_EXPLAIN}</h6></td>
	<td class="row2"><input class="post" type="text" size="4" maxlength="6" name="prune_shouts" value="{PRUNE_SHOUTS}" /></td>
</tr>
	
<!-- [MOD] Shoutbox [END] -->

# 
#-----[ OPEN ]------------------------------------------ 
#

template/admin/admin_user.tpl

# 
#-----[ FIND ]------------------------------------------ 
#

	<tr>
	  <td class="row1"><span class="gen">{L_PUBLIC_VIEW_EMAIL}</span></td>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

	<!-- [MOD] Shoutbox -->

	<tr>
		<td class="row1">{L_SHOW_SHOUTBOX}:</td>
		<td class="row2">
			{L_ENABLED}<input type="checkbox" name="showshoutbox" value="1" {S_SHOW_SHOUTBOX} /></td>
		</td>
	</tr>
	
	<!-- [MOD] Shoutbox [END] -->

# 
#-----[ OPEN ]------------------------------------------------ 
#

templates/default/tpl_config.php

# 
#-----[ FIND ]------------------------------------------------ 
#

$images['progress_bar']	       = $_main .'progress_bar.gif';
$images['progress_bar_full']	 = $_main .'progress_bar_full.gif';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

// [MOD] Shoutbox 

$images['icon_censor'] = $_main .'shoutbox/icon_censor.gif';

// [MOD] Shoutbox [END]

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