IRC Stats
Mit diesem Script könnt Ihr die akktuelle Idler Zahl aus
eurem Irc Channel auf eurer Website ausstellen.
|
Script: |
<?php
function chanpeak($chan)
{
if (!$fp =
fsockopen("irc.quakenet.org",6667))
return "no connect";
fputs($fp,"NICK
a".substr(md5(uniqid(rand(),1)),0,8)."\r\nUSER
botle 00:botle rox\r\n");
while (!feof($fp))
{
$data =
trim(fgets($fp,1024));
if (substr($data,0,1)
== ":")
{
$dSplit
= explode("
",substr($data,1));
if (!ereg("!",$dSplit[0]))
switch ($dSplit[1])
{
case
"322":
$chanpeak =
$dSplit[4];
if ($dSplit[3]
== $chan)
fputs($fp,"QUIT\r\n");
break;
case
"001":
fputs($fp,"LIST
".$chan."\r\n");
break;
}
} elseif (substr($data,0,4)
== "PING")
fputs($fp,"PONG".substr($data,5)."\r\n");
}
fclose($fp);
return $chanpeak;
}
// Hier channel eintragen,
der abgefragt werden soll
$chan =
"#dreamcodes";
$fp =
fopen("chanpeak.dat","r");
if ($fp)
{
unset($return);
while (!feof($fp))
$return.=
fgets($fp,4096);
fclose($fp);
list($timestamp,$chanpeak)
= explode(",",trim($return));
if ((time()-$timestamp)>600)
{
$chanpeak
= chanpeak($chan);
$fp
= fopen("chanpeak.dat","w");
if ($fp)
fputs($fp,time().",".$chanpeak);
fclose($fp);
}
echo $chanpeak;
} else {
echo "n/a";
}
?>
|
|