I've been searching for a way to display the IRC users online on the site, and I've stumbled over this site:
http://www.phpclasses.org/
definitely worth to register there...
nice PHP site!
Well, here it is. It's still beta, and i plan to add a 'idle time' feature to it, so that people will know how long it's been since people have spoken in IRC. Here's a POC for you guys:
http://g70net.com/shop/irc.html
and the code, of course:
http://g70net.com/shop/irc.html
and the code, of course:
Code: Select all
<?PHP
set_time_limit(0);
$server = "irc.suck-oold.com";
$port = 6667;
$nick = "nbot";
$name = "gogeta70-bot";
$ft = TRUE;
$con = fsockopen($server, $port);
send("USER $name g70net.com g70net.com :$name");
send("NICK $nick");
send("OPER user pass");
send("JOIN #suck-o");
send("PRIVMSG #suck-o :I am Gogeta70's IRC Name Server bot. I don't do anything except act as a relay to tell people who is on.");
$keys = array("PART", "JOIN", "QUIT");
while(!feof($con))
{
$buffer = trim(fgets($con, 4096));
echo "[<--] $buffer\n";
if(substr($buffer, 0, 5) == "PING ")
send("PONG :" . substr($buffer, 6));
$gkeys = explode(" ", $buffer);
@$gkeys = $gkeys[1];
if(in_array($gkeys, $keys) || $ft === TRUE)
{
$a = 0;
send("NAMES #suck-o");
while($a == 0)
{
$nicks = trim(fgets($con, 4096));
$tnicks = $nicks;
$tnicks = explode(" ", $tnicks);
if($tnicks[1] == "353")
{
$a = 6;
}
}
//$drop = fgets($con, 4096);
//unset($drop);
$nicks = explode("#suck-o :", $nicks);
$nicks = $nicks[1];
$nicks = str_replace(" ", ", ", $nicks);
$nicks = "<b>Current users on IRC:</b> $nicks";
$open = fopen("E:\\shop\\irc.html", "w");
fwrite($open, $nicks);
fclose($open);
$ft = FALSE;
}
}
function send($cmd)
{ global $con;
fputs($con, $cmd . "\r\n");
echo "[-->] $cmd\n";
}
?>
¯\_(ツ)_/¯ It works on my machine...
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
sweet gogeta, thanks!
I've found this one on the site and will give it a try: http://www.phpclasses.org/browse/package/1409.html
maybe you can tell me what you think about it....
I've found this one on the site and will give it a try: http://www.phpclasses.org/browse/package/1409.html
maybe you can tell me what you think about it....