while(!feof($server["socket"])) //while we are connected to the server
{
$server['READ_BUFFER'] = fgets($server["socket"], 1024); //get a line of data from the server
echo date("G:i:s")." [RECEIVE] ".$server['READ_BUFFER']."<br>\n\r"; //display the recived data from the server
//IRC Sends a "PING" command to the client which must be anwsered with a "PONG"
//Or the client gets Disconnected
//Now lets check to see if we have joined the server
if(strpos($server['READ_BUFFER'], "422")) //422 is the message number of the MOTD for the server (The last thing displayed after a successful connection)
{
//If we have joined the server
SendCommand("JOIN $chan\n\r"); //Join the chanel
}
if(substr($server['READ_BUFFER'], 0, 6) == "PING :") //If the server has sent the ping command
{
SendCommand("PONG :".substr($server['READ_BUFFER'], 6)."\n\r");
}
$msg=file_get_contents("msg.txt");
if($msg!=""){
SendCommand("privmsg $chan $msg\n\r");
file_put_contents("msg.txt","");
}
flush();
}