#############################################################################
##	Mod Title:   PhpBB2 - Shoutbox Integration v0.2b
##	Mod Version: 0.2b
##	Author:      Onur Turgay (onurturgay@isnet.net.tr)
##	Description:
##		This hack will allow you to have an integrated chatbox on your index of phpBB2
##
##	Features:
##		- Ability to disallow anonymous to post
##		- User-definable message deleting time
##		- CSS defined styles
##		- Emoticons & Emoticon panel
##		- Uses phpBB2 user name and doesnt allow any other name to be entered
##		- Very quick and doesnt use much resources
##		- pop-up window ability
##		- Who Are Chatting and How Many Chatting features on index page
##		- Online and Away lists in chat window
##		- Join-Left and Away Notifications
##
##	Credits:
##      - This hack is based on Original Shoutbox Code (c) 2001 Brett Taylor
## <http://www.addict.net.nz/~glutnix> <mailto:glutnix@addict.net.nz>
##
##
##	HISTORY:
##
##
##		2001-01-29 0.2a - Onur Turgay
##		- Away / Online feature added
##		- Showing the list of chatters on front page added
##		- Showing the number of chatters on front page added
##		- cleaned up some code
##		- put all files in a seperate directory
##
##
##		2001-01-14(yeah same day!) v0.1b - Onur Turgay
##		- messaging&refresh on index page is disabled
##		- pop-up window future enabled
##		- "deleting of the written message during refresh" problem is solved
##		- A new CSS that's compatible with subSilver theme is created
##		- first public release!!
##
##		2001-01-14 v0.1a - Onur Turgay -
##			-alpha release
##
##
##
## Installation Level:  intermediate
## Installation Time:   5-10 Minutes
## Files To Edit:       2
##			index.php
##			templates/subSilver/index_body.tpl
## Included Files:      12
##			[15 (main directory)]
##			[34 smileys in smileys/orange]
##


# IMPORTANT: DO YOUR CONFIGURATION FROM mods/chat/shoutboxconf.php
# every variable is understandable...
#
## Here we GO
#
# First Create The Tables, use the query below:
CREATE TABLE shoutbox (
        id int(11) NOT NULL auto_increment,
        name varchar(30) NOT NULL,
        shout varchar(255) NOT NULL,
        url varchar(100) NOT NULL,
        timestamp int(10) unsigned NOT NULL,
        ipaddress TEXT not null,
        PRIMARY KEY (id));

CREATE TABLE chatsession (
   username varchar(30) NOT NULL,
   lastactive int(11) DEFAULT '0' NOT NULL,
   laststatus varchar(8) NOT NULL,
   UNIQUE username (username)
);



#copy the files to your phpBB2 root directory
#all shoutbox files must be in a directory structure mods/chat with respect to phpBB root.
#except shoutbox_pre.php WHICH HAVE TO BE IN PHPBB2 ROOT DIR
#smileys must be in a directory structure mods/chat/smileys/orange with respect to phpBB root

# --- [ OPEN index.php ] ---

# --- [ BEFORE ] --- around line 26x -27x

$template->assign_vars(array(
		"TOTAL_POSTS" => sprintf($l_total_post_s, $total_posts),
		"TOTAL_USERS" => sprintf($l_total_user_s, $total_users),

# --- [ ADD ] ---


	require_once("shoutbox_pre.php");
	$howmanychat = howmanyChat();
	$chatters = chattersMain();


# --- [ AFTER ] --- around line 27x - 28x

"L_MARK_FORUMS_READ" => $lang['Mark_all_forums'],

# --- [ ADD ] ---

"USERNAME-CHAT" => $userdata['username'],
"WHO_ARE_CHATTING_HEAD" => $lang['Who_Is_Chatting_Heading'],
"TOTAL_CHATTERS_ONLINE" => sprintf($lang['How_Many_Chatters'], $howmanychat),
"CHATTERS_LIST" => sprintf($lang['Who_Are_Chatting' ],$chatters),
"MISC_INFO" => $lang['Misc_Info'],
"CHAT" => $lang['Chat_Title'],
"STATS" => $lang['Stats'],

# --- [ CLOSE index.php ] ---

# --- [ OPEN language/lang_english/lang_main.php ] --- (or whatever your language is)

# --- [ ADD ] --- TO THE LAST OF DOCUMENT BEFORE ?>

$lang['Who_Is_Chatting_Heading'] = "Who is Chatting";
$lang['How_Many_Chatters'] = "There are <B>%d</B> people on chat now";
$lang['Who_Are_Chatting' ] = "These people are on chat: <B>%s</B>";
$lang['Misc_Info'] = "Misc. Info";
$lang['Chat_Title'] = "Chat";
$lang['Stats'] = "Stats";


# --- [ CLOSE language/lang_english/lang_main.php ] ---


# --- [ REPLACE templates/subSilver/index_body.tpl with index_body.tpl included in archive ]
# This is the default layout, But If you want to put chat in another place, code for chat is:

 <iframe bgcolor="#000033" src="mods/chat/viewshoutbox.php?nick={USERNAME-CHAT}" width="150" height="200" frameborder="0"></iframe>

# you can put this code whereever you like
# code for who are chatting title:

{WHO_ARE_CHATTING_HEAD}

# who are chatting list

{CHATTERS_LIST}

# number of chatters

{TOTAL_CHATTERS_ONLINE}

# chat title

{CHAT}

# You can create your own templates with these information. Look at hacks.phpbb.com for diffrent layouts
# created by other users of this script. I will include all layouts in final release. My recommendation is
# using the index_body.tpl included in archive.. It is painless and easy