eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Development resources
 ::   WebWare 2.1 (Perl)
 ::   WebWare 2.0 (Java)
 ::   Cool hacks
Radical Hacks :
Display WebChat Occupants with SSI  
sent in the following hack...

Anyway, here's the small hack I was talking about. I'm not much of a programmer, so if you see any glaring errors, please correct them (and let me know). This hack is based on some of the code from Jarkko's hack, listed at your site.

The following hack allows you to list the occupants of your chat room, via SSI, on any part of your website, such as on your home page.

Use: <!--#exec cgi="/path/to/chat/room/users.cgi"-->

So if you put the "users.cgi" file within your main chat (called "main"), and you have it set up so that the chat room directories lie within a main "chat" directory in your "cgi-bin" directory, then this would read:

<!--#exec cgi="/cgi-bin/chat/main/users.cgi"-->

Save the following code as "users.cgi":


print "Content-type: text/html\n";

# hello, is there anyone home?

opendir(CHATDIR, ".");
    @files = grep(/who$/,readdir(CHATDIR));
    if (@files > 0) {
        foreach $whofile (@files) {
            open (WHOFILE,"./$whofile");
            $wholine = <WHOFILE>;
            @whofields = split(/\|/,$wholine);
            $userlist .= qq!$whofields[0] !;
	else {
        $userlist .= "Empty";

print qq!

If you have several rooms, place a copy of the file within each one, and call them separately via SSI.