tags:

views:

52

answers:

1

I'm working with a closed community site (PHP-based) of about 100 users, and one of the features we've implemented is an ajax shoutbox that works as a "chatroom" on the site frontpage when users logged in. The dev team is using a private irc server for collaboration, and in one channel we're running a quizbot. We came up with the idea to try and make a web interface for connecting to irc through our site, so all the (non-tech-savvy) users of our site can participate in our irc quizzes.

Now, I'm no IRC expert, but I've looked into a few PHP-IRC tutorials, and it seems to me that in order to connect to IRC, PHP needs to maintain an open connection.. which means that we need to do a comet-style trick and let the PHP script execute without timing out. However, this means that if the user navigates away from the page or closes the tab, we loose control of that php execution. We could probably figure out a way to stop the connection if this happens, but even so the user would have to reconnect to irc if he navigates back to the chatroom.

What we want to achieve is a way for users to be perpetually connected to the irc server, even if they aren't logged in to the site. The dev team all have shell accounts on one of our servers, and we use screen and irssi to stay connected. I figure it should be somehow possible to have a php script connect to irc through a shell account that is always connected to irc. Because of our limited number of users, it isn't a problem to set up shell accoutns for all of them, but I haven't yet figured out the missing link - a command-line irc client that allows php access in some way.

Anyone have any suggestions?

+1  A: 

One option would be to run a BNC, basically a proxy that will maintain connections to the IRC server, and your PHP script can connect to it when it needs to. You'd need to set up a way to identify a user's PHP session to the BNC software, set session timeouts etc. that would all depend on the specific software you're using and its available options.

Alternatively it wouldn't be that hard to write a special purpose proxy in say Python or something that would maintain a list of IRC connections for PHP sessions.

You also might not want one IRC connection per PHP session, a single persistent bot connection on the IRC channel could easily include a username in each message identifying the PHP user that sent it.

Brook Miles
I was thinking of the same thing. One irc bot to relay chatter to/from the site, prefixing each message with the web user's username.I've looked a little into http://phergie.org/ "Phergie" lately and it looks pretty interesting.In any case you need a continuous connection for irc to work.
Fanis