TinyPortal

General => Chit chat => Topic started by: Amay_Zing on November 14, 2005, 07:59:51 PM

Title: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: Amay_Zing on November 14, 2005, 07:59:51 PM
I have tried inserting this code as per documentation

// flashchat users
echo '
<tr>
<td class="catbg" colspan="2">FlashChat Users</td>
</tr>
<tr>
<td class="windowbg">&nbsp;</td>
<td class="windowbg2" width="100%"><iframe frameborder="0" height="100" src="', $GLOBALS['boardurl'], '/chat/info_embedded.php" style="width: 100%; margin: 0; padding: 0; border: 0; overflow: hidden;" scrolling="no" border="0" allowtransparency="true"></iframe></td>
</tr>';

but it don't work.  Any ideas guys as to where I am going wrong?

Thanks
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: gerrymo on November 14, 2005, 08:52:00 PM
There is code for this in code block snippets. It should work OK in most themes.
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: Amay_Zing on November 14, 2005, 10:09:39 PM
it takes ages to get a reply on Flashchat forums and sometimes they don't  >:(

Where are snippets?
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: gerrymo on November 14, 2005, 11:59:26 PM
Here is the thread.
http://www.tinyportal.net/smf/index.php?topic=1298.0

Code Block Snippets is a child board in Beta Testing.
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: Amay_Zing on November 15, 2005, 09:31:19 AM
Thanks bud

Just tried the link and I am getting an error - the topic seems to be missing or is off limits to you :(
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: gerrymo on November 15, 2005, 09:41:35 AM
Put the code below into a right or left php block.


global $boardurl;
echo '
<iframe frameborder="0" height="100" src="', $boardurl, '/chat/info_embedded.php" style="width: 100%; margin: 0; padding: 0; border: 0; overflow: hidden;" scrolling="no" border="0" allowtransparency="true"></iframe>';


The path should be your path to the chat directory (Above it is: /chat/info_embedded.php)
Scrolling can be changed to suit you.
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: pheasant_plucker on December 18, 2005, 07:13:03 AM
In flashchat change the info.php file to this



header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");


/**
If this file is not in the FlashChat root folder, then change this
path to the location of the inc/common.php file.
*/
include_once('inc/common.php');

ChatServer::purgeExpired();

/**
Retrieves the number of users who are chatting in any room.
Leave the $room parameter empty to return the number of users in all room.
*/
function numusers( $room = "" )
{
if($room) {
$stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?");
$rs = $stmt->process($room);
} else {
$stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL");
$rs = $stmt->process();
}

$rec = $rs->next();

return $rec?$rec['numb']:0;
}

/**
Retrieves a list of the users (by login ID) who are in $room.
Leave the $room parameter empty to return a list of all users in all rooms.
*/
function usersinroom( $room = "" )
{
$cms = $GLOBALS['fc_config']['cms'];
$list = array();

if($room) {
$stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?");
$rs = $stmt->process($room);
} else {
$stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL");
$rs = $stmt->process();
}

while($rec = $rs->next()) $list[] = array_merge($cms->getUser($rec['userid']), $rec);

return $list;
}

/**
Retrieves a list of all available rooms, as an array.
*/
function roomlist()
{
$list = array();

// populate $list with the names of all available rooms
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NOT NULL");
$rs = $stmt->process();

while($rec = $rs->next()) $list[] = $rec;

//result will be an array of arrays like ('id' => <room id>, 'updated' = <timestamp>, 'created' => <timestamp>, 'name' => <room name>, 'ispublic' => <public flag>, 'ispermanent' => <autoclose flag>)
return $list;
}


$rooms = roomlist();
$roomnumb = sizeof($rooms);
?>

<html>
<title>Who's in the chat?</title>

<body>


<?php
if($roomnumb) {

ÂÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ, foreach($rooms as $room) {





ÂÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  $users usersinroom($room['id']);

ÂÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  foreach( $users as $user ) {
ÂÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  echo $user['login']. ", ";
ÂÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  Ãƒâ€šÃ,  }ÂÃ,  }ÂÃ,  }

?>



</body>
</html>


then in your tpadmin create a PHPblock in the place you want it then add the code include(URL TO Your Webspace/FlashChat/info.php');   for example mine is include('http://www.rcmodelflyers.co.uk/4um/FlashChat/info.php');

This will list the names of users in the chat in a box.

Gerry
Title: Re: Adding who's chatting box to smf 1.1 RC1 Helios multi theme
Post by: Amay_Zing on December 18, 2005, 03:38:40 PM
Thanks