Mod Name / Version - Integrated DigiChat with UBBT 1.1
Description - This modification allows a seamless integration with DigiChat using data from the UBBT database
Working Under - UBB.Threads 6.2
Features - Retrieves the data from the database and passes it as parameters in the DigiChat applet
- Shows on the Who's Online screen on a different section, who is online
Pre-requisites - none
Author - dimopoulos
Credits - Threadsdev
Files Altered - online.php, templates/default/online.tmpl, templates/default/ubbt_registerednav.tmpl
Database Altered - Yes. New table w3t_InChat. New field U_ChatIcon in w3t_Users table
New Files - Yes. chatmain.php, chatcheck.php, chat.php
Other Info - Backup your database and your files before modifying!!!!!
1. DATABASE Changes
1.1 Create a new table called w3t_InChat with two fields: C_UserID INT(9) NOT NULL and C_Last INT(9) UNSIGNED NOT NULL.
<br />CREATE TABLE w3t_InChat <br />( <br /> C_UserID int(9) NOT NULL <br /> C_Last int(9) UNSIGNED NOT NULL <br />); <br />
1.2 Add a new field in the w3t_Users table called U_ChatIcon VARCHAR(10) DEFAULT "1000"
<br />ALTER TABLE w3t_InChat ADD U_ChatIcon VARCHAR(10) DEFAULT '1000'; <br />
The U_ChatIcon field holds the chat icon that the user will have. It defaults to the default icon of DigiChat which is 1000. You can put more items in there
2. Open templates/default/ubbt_registerednav.tmpl
Find
<br />($template['members_link']) <br />
BELOW it ADD
<br />UBBTPRINT; <br />// 20030113 - Chat Link - New Start <br />echo <<<UBBTPRINT <br /> | <br /><script langauge="javascript" type="text/javascript"> <br /> function OpenChat(){window.open('$phpurl/chat.php','','left=10,right=10,width=400,height=250');} <br /> </script><a href="javascript: OpenChat()">Chat</a> <br />UBBTPRINT; <br />// 20030113 - Chat Link - New End <br />echo <<<UBBTPRINT <br />
NOTE: The above code is in One line. I present it in three lines for aesthetic purposes 3. Open online.php
Find
<br />// ------------------------- <br />// Delete the inactive users <br /> $html = new html; <br /> $Outdated = $html -> get_date() - 600; <br /> $query = " <br /> DELETE FROM {$config['tbprefix']}Online <br /> WHERE O_Last < $Outdated <br /> "; <br /> $dbh -> do_query($query); <br />
Add below it
<br />// 20030113 In Chat Check New Start <br /> $Outdated = $html -> get_date() - 60; <br /> $query = " <br /> DELETE FROM {$config['tbprefix']}InChat <br /> WHERE C_Last < $Outdated <br /> "; <br /> $dbh -> do_query($query); <br />// 20030113 In Chat Check New End <br />[code] <br /> <br />Open online.php <br />Find <br />[code] <br /> $color = $html -> switch_colors($color); <br /> $x++; <br /> <br /> } <br /> $regsize = 0; <br /> if (isset($regrow)) { <br /> $regsize = sizeof($regrow); <br /> } <br /> $dbh -> finish_sth($reged); <br />
Add below it
<br />// 20030113 In Chat Check New Start <br /> $query = " <br /> SELECT t2.U_Username, t1.C_Last,t2.U_Status,t2.U_Visible,t2.U_Extra1, <br /> t2.U_Title,t2.U_Color,t2.U_OnlineFormat,t2.U_Number <br /> FROM {$config['tbprefix']}InChat AS t1, <br /> {$config['tbprefix']}Users AS t2 <br /> WHERE t1.C_UserID = t2.U_Number <br /> ORDER BY t1.C_Last DESC <br /> "; <br /> $regedinchat = $dbh -> do_query($query); <br /> $regrowsinchat = $dbh -> total_rows($regedinchat); <br /> <br /> $color = "lighttable"; <br /> <br />// Array key tracker <br /> $x = 0; <br /> <br /> [:"blue"]while (list($Username,$Last,$Status,$Visible,$ICQ, <br /> $Title,$Color,$OnlineFormat,$Uid) = $dbh -> fetch_array($regedinchat) ) [/] <br /> { <br /> <br /> $Last = $html -> convert_time($Last,$toffset); <br /> $EUsername = $Uid; <br /> $PUsername = $Username; <br /> if ($Color) <br /> { <br /> $PUsername = "<font color=\"$Color\">$Username</font>"; <br /> } <br /> <br /> $regrowinchat[$x]['color'] = $color; <br /> $regrowinchat[$x]['EUsername'] = $EUsername; <br /> $regrowinchat[$x]['PUsername'] = $PUsername; <br /> <br /> if ($Status == "Administrator") <br /> { <br /> $Status = $ubbt_lang['USER_ADMIN']; <br /> } <br /> if ($Status == "Moderator") <br /> { <br /> $Status = $ubbt_lang['USER_MOD']; <br /> } <br /> if ($Status == "User") <br /> { <br /> $Status == $ubbt_lang['USER_USER']; <br /> } <br /> <br /> // Set up the link to send the user a Private Message - by JoshPet <br /> if ($config['private']) <br /> { <br /> [:"blue"]$privmessage = "<a href=\"{$config['phpurl']}/sendprivate.php?Cat=$Cat&User=$Uid\"> <br /> <img src=\"{$config['images']}/sendprivate.gif\" <br /> alt=\"{$ubbt_lang['PRIV_HEAD']}\" border=\"0\" /></a>";[/] <br /> } <br /> <br /> // ----------------------------------------------------- <br /> // Here we give more information on what they are doing <br /> if ( ($OnlineFormat == "no") && ($user['U_Status'] != "Administrator") ) <br /> { <br /> $Private = 1; <br /> } <br /> <br /> <br /> if ( $Private ) <br /> { <br /> $Where = "<font class=\"small\"><br /> ({$ubbt_lang['Private']})"; <br /> } <br /> else <br /> { <br /> $Where = "Chatting..."; <br /> } <br /> <br /> if ( (preg_match('/^\d+$/',$ICQ)) && ($config['ICQ_Status']) ) <br /> { <br /> $icqindicator = "<img src=\"http://online.mirabilis.com/scripts/online.dll?icq=$ICQ&img=5\" alt=\"*\" />"; <br /> } <br /> else <br /> { <br /> $icqindicator = ""; <br /> } <br /> <br /> $regrowinchat[$x]['icqindicator'] = $icqindicator; <br /> $regrowinchat[$x]['Status'] = $Status; <br /> $regrowinchat[$x]['privmessage'] = $privmessage; <br /> $regrowinchat[$x]['Title'] = $Title; <br /> $regrowinchat[$x]['Last'] = $Last; <br /> $regrowinchat[$x]['Where'] = $Where; <br /> <br /> $color = $html -> switch_colors($color); <br /> $x++; <br /> <br /> } <br /> <br /> $regsizeinchat = 0; <br /> if (isset($regrowsinchat)) { <br /> $regsizeinchat = sizeof($regrowsinchat); <br /> } <br /> $dbh -> finish_sth($regedinchat); <br />// 20030113 In Chat Check New End <br />
Open templates/default/online.tmpl
Find
<br />UBBTPRINT; <br />} <br />echo <<<UBBTPRINT <br /><!-- END OF LOOP --> <br /> <br />$tbclose <br /><br /> <br /><br /> <br />
Add below it
<br />UBBTPRINT; <br />// 20030113 In Chat link - New Start <br />echo <<<UBBTPRINT <br />$tbopen <br /><tr> <br /><td class="tdheader" colspan="5" align="center"> <br /><font style="text-decoration: underline">$regrowsinchat {$ubbt_lang['REGED_USERS']}</font> <br /></td> <br /></tr> <br /><tr> <br /><td class="tdheader" width="15%"> <br />{$ubbt_lang['USERNAME_TEXT']} <br /></td> <br /><td class="tdheader" width="2%"> <br />PM <br /></td> <br /><td class="tdheader" width="12%"> <br />{$ubbt_lang['USER_TITLE']} <br /></td> <br /><td class="tdheader" width="16%"> <br />{$ubbt_lang['LAST_ACTIVE']} <br /></td> <br /><td class="tdheader" width="30%"> <br />{$ubbt_lang['ONLINE_LOC']} <br /></td> <br /></tr> <br /> <br /><!-- BEGIN ONLINE LOOP, DO NO REMOVE COMMENT --> <br />UBBTPRINT; <br />for ($i=0;$i<$regsizeinchat;$i++) { //UBBTREMARK <br />echo <<<UBBTPRINT <br /> <br /><tr> <br /><td valign="top" class="{$regrowinchat[$i]['color']}"> <br />{$regrowinchat[$i]['icqindicator']} <br />[:"blue"]<a href="{$config['phpurl']}/showprofile.php?Cat=$Cat& <br />User={$regrowinchat[$i]['EUsername']}&what=online">{$regrowinchat[$i]['PUsername']}</a>[/] <br /></td> <br /><td valign="top" class="{$regrowinchat[$i]['color']}"> <br />{$regrowinchat[$i]['privmessage']} <br /></td> <br /><td valign="top" class="{$regrowinchat[$i]['color']}"> <br />{$regrowinchat[$i]['Title']} <br /></td> <br /><td valign="top" class="{$regrowinchat[$i]['color']}"> <br />{$regrowinchat[$i]['Last']} <br /></td> <br /><td valign="top" class="{$regrowinchat[$i]['color']}"> <br />{$regrowinchat[$i]['Where']} <br /></td> <br /></tr> <br /> <br />UBBTPRINT; <br />} <br />echo <<<UBBTPRINT <br /><!-- END OF LOOP --> <br /> <br />$tbclose <br /><br /> <br /><br /> <br />UBBTPRINT; <br />// 20030113 In Chat link - New End <br />echo <<<UBBTPRINT <br />
NOTE: The code in [:"blue"]blue[/] should be in ONE line. It has been split in two for aesthetic purposes Last step is to open the chatmain.php and put in the codebase directive your domain name.
Warm regards
Nikos