replic 17 Light Poster

Hi everyone,
as said in the title i have a _very_ basic IRC bot that keeps disconnecting after a few seconds.
This is what i have so far and i'm grateful for every hint you might have.
I also checked this thread but it did not really help: http://www.daniweb.com/forums/thread243489.html

<php>
<?php

set_time_limit(0);

ini_set("display_errors", "on");

error_reporting(E_ALL | E_NOTICE); 

$config = array( 
	"server" => "irc.irchighway.net", 
	"port" => 6667, 
	"nick" => "bot", 
	"name" => "foo", 
	"pass" => "bar", 
	"chan" => "#channel",
);
	$firstrun = true;	
		
	$ex = array();
	
	$socket = fsockopen($config["server"], $config["port"]);
	
	fputs($socket, "PASS ".$config['pass']."\n\r");
	fputs($socket, "NICK ".$config["nick"]."\n\r");
	fputs($socket, "USER ".$config["nick"]." USING THE INTERNET\n\r");		
	
	while (!feof($socket))
	{
		$data = fgets($socket, 1024);

		echo nl2br($data);		

		$ex = explode(" ", $data);

		if ($ex[0] == "PING")
		{
			fputs($socket, "PONG".$ex[1]);
		}	
		
		if ($firstrun)
		{
			fputs($socket, "JOIN ".$config["chan"]."\n\r");			
			$firstrun = false;
		}		
		
		flush();
	}	
?>
</php>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.