TinyPortal

Development => Block Codes => Topic started by: DFDuck on November 19, 2008, 02:21:43 PM

Title: Yet Another Who's In Flashchat Block(s)
Post by: DFDuck on November 19, 2008, 02:21:43 PM
I'm not a php coder so don't laugh (too hard). I used snips of code I found here in the forums, munged them around a bit, added a bit of my own, and it works for me.

I made two separate Who's In Flashchat phpbox blocks. I'm using the SMF default theme and, being lazy, just used the included online.gif graphic. Both blocks assume that Flashchat is standard installed in the chat/ directory in the forum root dir.

BLOCK 1:
Load chat users list once. If user is logged into forum display link to enter chat.

phpbox 1:
global $boardurl;
echo '<img src="',$boardurl,'/Themes/default/images/icons/online.gif" alt="Users Online" /> <b>';
if ($context['user']['is_logged']) { echo '<a href="',$boardurl,'/chat/flashchat.php">Enter Chat Room</a>'; } else { echo 'Who\'s In Chat'; }
echo '</b><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>';





BLOCK 2:
If user is logged into forum auto refresh chat users list and display link to enter chat. Otherwise display chat users list once and show link to register on the forum.

Make a copy of the file chat/info_embedded.php and name it chat/info_embedded_auto.php
Edit info_embedded_auto.php. Down around lines 95 - 97 you should see;


<head>
<title>Who's in the chat?</title>
<meta http-equiv=Content-Type content="text/html;  charset=UTF-8">


Edit to;

<head>
<title>Who's in the chat?</title>
<meta http-equiv=Content-Type content="text/html;  charset=UTF-8">
<meta http-equiv="refresh" content="120" />


The content="120" is in seconds, so the users list will update every 2 minutes. Adjust this to your liking.


phpbox 2:
if ($context['user']['is_logged']) { $auto='_auto'; echo '<a href="',$boardurl,'/chat/flashchat.php">Enter Chat Room</a>'; } else { $auto=''; echo '<a href="',$boardurl,'?action=register">Register Now</a>'; }
echo '</b><iframe frameborder="0" height="100" src="',$boardurl,'/chat/info_embedded',$auto,'.php" style="width: 100%; margin: 0; padding: 0; border: 0; overflow: hidden;" scrolling="no" border="0" allowtransparency="true"></iframe>';



-- Duck