MySocket = fsockopen($this->host,$this->port);
$this->SendCommand('nick fsockopen');
$this->SendCommand('user fsockopen fsockopen fsockopen :PHP IRCConnect class');
Sleep(2);
$this->SendCommand('JOIN #Accueil');
$this->GetCommand();
}
public function SendCommand($MyCmd)
{
if (!empty($this->MySocket))
{
fputs($this->MySocket,$MyCmd.chr(10).chr(13));
echo '[<<] '.$MyCmd.'
';
}
}
public function GetCommand()
{
while (1)
{
while ($MyData = fgets($this->MySocket,1024))
{
echo '[>>] '.nl2br($MyData).'
';
flush();
$this->AnswerIt($MyData);
}
}
}
public function AnswerIt($MyData)
{
if (substr($MyData,0,4) == "PING")
{
$this->SendCommand('PONG '.substr($MyData,5,strlen($MyData)));
}
}
}
$IRCConnect = new IRCConnect();
?>