PDA

View Full Version : [Mod] Add a chatroom to your adoptables install.


Saphira
05-26-2009, 11:05 AM
This is pretty straight forward, and pretty easy to implement. I'm not sure if free web hosts will allow this, because CGI:IRC is pretty resource heavy, due to it reloading the page every few seconds per user.

What you will need:

CGI:IRC (.zip) (http://cgiirc.org/releases/cgiirc-0.5.9.zip)
CGI:IRC (.tar.gz) (http://cgiirc.org/releases/cgiirc-0.5.9.tar.gz)
Your blank.php file.
An IRC server for CGI:IRC to connect to.

First things first, extract CGI:IRC and upload it to your server. I'm not going to go into detail about how to install CGI:IRC, because it's already fully documented on their website (http://cgiirc.org/docs/). All I'm going to say about this is that you need to make sure all files are CHMOD'd to 755, otherwise you'll get internal server errors.

Now that we have CGI:IRC uploaded and ready to use, we have to copy and edit our blank.php file. For this, I'm going to name the copied file chat.php.

Now, open your chat.php file, and find where it says:

$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);

This is where we're going to put our login form. When you've found the above three lines, REPLACE THEM with the following:

$pagecontent = getsitecontent("index");
$article_title = "Your article title";
$article_content = "<script src='http://static.blitzed.org/cgiirc.js'></script>
<form name='cgiirclogin' method='post' onsubmit='return openCgiIrc(this)' action='link to your CGI:IRC irc.cgi file'>
<input type='hidden' name='interface' value='nonjs' />
<input type='hidden' name='Channel' value='channel you want the users to auto connect to, must start with a #' />
<label>Nickname: </label><input type='text' name='Nickname' value='CGI???' />
<input type='submit' value=' Chat! ' />
</form><p>";

The "CGI???" bit is the user's nickname that will be shown in the nickname box automatically (they can change this), the ??? will represent three random numbers.

Now make sure that chat.php is CHMOD'd to 755.

And that's it. Now you should have a working chatroom where people can talk about whatever they want.

If you don't want to/can't set up your own IRC server, there are a lot of them out there which won't mind you having a channel on them. If you're really stuck and can't find any, I'll be happy to point you in the right direction to some. :)

Important note: You MUST leave the http://static.blitzed.org/cgiirc.js link in the script or it WILL NOT WORK.

Coming next: A Java applet client that people can use to connect to the same chatroom.

Seapyramid
05-26-2009, 11:22 AM
I want to offer a word of warning here, mainly for free sites but some paid sites as well. Shout boxes and Chat rooms will use your server resourses extensively and for many hosts... even paid ones... you might find yourself going over in CPU usage. Just a thought so that if you see white pages or suspension pages you have some ideas of where to look.

Saphira
05-26-2009, 11:34 AM
Yeah, I forgot to add that some paid hosts might not allow it, thanks Sea. Make sure you read your ToS agreement with your host before implementing this. :)