Log in

View Full Version : Help with a mod


BunkTek
10-24-2004, 09:13 PM
I've gotten X7 chat set up and am trying to add a "Currently In Chat" info area, like the "Currently Active Users". I have it all set up and am trying to get the following to work. vBulletin isn't pulling this information like it does on my chat page. I want people reading the forums to be able to see who is chatting from the forum.

Do I need to create a variable?

<?include_once("chatonline.php");list_totals();?>

<?include_once("chatonline.php");list_members(" - ");?>

Once I can get this to work I'll create a thread with everything I've done so that other people can use the information and set up X7, a really nice chat.

This is what the current code looks like in the edited forumhome, I've bolded the code I'm having a problem with:

<!-- who's in chat -->

<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="chatonline.php">Currently In Chat: <?("chatonline.php");list_totals();?></a>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="alt2"><a href="chatonline.php"><img src="chatonline.gif" alt="View Who's Chatting" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div><?include_once("chatonline.php");list_members(" - ");?></div>
</div>
</td>
</tr>
</tbody>

<!-- end who's in chat -->

I'm no pro at editing vBulletin or modding. The above is cut/edit/paste of the logged in users section directly above this code.

Any help with getting this working will be much appreciated and credited when I post the X7 sort of mod :)

BunkTek
10-25-2004, 04:11 AM
More info, here is the code in the chatonline.php that is being called:

<?
function who_is_in_chat(){
// MySql Information
$user = ""; // Your MySql username
$pass = ""; // Your MySql password
$db = ""; // Your MySql Database
$prefix = "X7Chat_"; // Your table prefix
$expire_time = 240; // The amount of seconds that users can be idle before they are considered offline
// This value is setable in the X7 Chat admin panel, you must also set it here.
// If the values do not match then the scripts may be inaccurate.
// No more editing required

mysql_connect("localhost",$user,$pass);
mysql_select_db($db);

$exp_time = time()-$expire_time;
$q = mysql_query("DELETE FROM {$prefix}online WHERE time<'$exp_time'");
$q = mysql_query("SELECT username FROM {$prefix}online");
$results = array();
while($row = mysql_fetch_row($q))
$results[] = $row[0];
return $results;
}

function list_totals(){
echo count(who_is_in_chat());
}

function list_members($sep=", "){
$online = who_is_in_chat();
echo implode($sep,$online);
}

?>