Fox: eregi_replace bzw. string_replace macht Zeilenumbruch

Hey,

also ich bin dabei einen IRC Bot zu erstellen und zwar mit mysql datenabfrage vo users etc. nur wenn der bot mir bzw einen user aus der datenbank op geben soll geht das nicht da der bot aus einen array den channel ausliest und dabei mit string_replace bzw eregi_replace am ede vom channel einen zeilenumbruch oder so in der konsole anzeigt und der befehl somit nicht funktioniert.

  
<?php  
  
//So the bot doesnt stop.  
  
set_time_limit(0);  
  
ini_set('display_errors', 'on');  
  
  
	//Example connection stuff.  
  
	$config = array(  
		'server' => '127.0.0.1',  
		'port' => 6667,  
		'nick' => 'H2O',  
		'name' => 'bt',  
		'pass' => 'NeCroB0t:572078',  
	);  
	  
  
class IRCBot {  
  
	//This is going to hold our TCP/IP connection  
  
	var $socket;  
  
  
  
	//This is going to hold all of the messages both server and client  
  
	var $ex = array();  
  
  
  
	/*  
  
	 Construct item, opens the server connection, logs the bot in  
  
  
  
	 @param array  
  
	*/  
  
	function __construct($config)  
  
	{  
  
		$this->socket = fsockopen($config['server'], $config['port']);  
  
		$this->login($config);  
  
  
		$this->main();  
  
		$this->send_data('JOIN', '#juli963');  
  
	}  
  
  
  
	/*  
  
	 Logs the bot in on the server  
  
  
  
	 @param array  
  
	*/  
  
	function login($config)  
  
	{  
  
		$this->send_data('USER', $config['nick'].' foxxx '.$config['nick'].' :'.$config['name']);  
  
		$this->send_data('NICK', $config['nick']);  
		$this->send_data('PASS', $config['pass']);  
  
	}  
  
  
	function main()  
  
	{  
  
		$data = fgets($this->socket, 128);  
  
		echo nl2br($data);  
  
		flush();  
  
		$this->ex = explode(' ', $data);  
  
  
  
		if($this->ex[0] == 'PING')  
  
		{  
  
			$this->send_data('PONG', $this->ex[1]); //Plays ping-pong with the server to stay connected.  
  
		}  
  
  
  
		$command = str_replace(array(chr(10), chr(13)), '', $this->ex[3]);  
  
	   if($this->ex[1] == 'JOIN')  
	   {  
       $uhost = eregi_replace( ':', '', $this->ex[0] );  
	   $chan = $this->ex[2];  
       $nickl = explode('!', $this->ex[0]);  
       $nicke = eregi_replace( ':', '', $nickl[0] );  
       $this->mode($nicke, $uhost, $chan);  
	   }  
	  
		switch($command) //List of commands the bot responds to from a user.  
  
		{  
  
			case ':!join':  
  
				$this->join_channel($this->ex[4]);  
  
				break;  
  
  
  
			case ':!quit':  
  
				$this->send_data('QUIT', 'foxxx');  
  
				break;  
				  
				  
		}  
  
     $this->main();  
  
	}  
  
  
  
	function send_data($cmd, $msg = null) //displays stuff to the broswer and sends data to the server.  
  
	{  
  
		if($msg == null)  
  
		{  
  
			fputs($this->socket, $cmd."\r\n");  
  
			echo '<strong>'.$cmd.'</strong><br />';  
  
		} else {  
  
			fputs($this->socket, $cmd.' '.$msg."\r\n");  
  
			echo '<strong>'.$cmd.' '.$msg.'</strong><br />';  
  
		}  
  
	}  
  
    function mode($user, $uhost, $channel)  
	{  
  
	$verbindung = mysql_connect("localhost", "juli963" , "572078");  
        mysql_select_db("bot");  
     $te = str_replace( ':', '', $channel );  
	 $msge = $te." +o ".$user;  
	 $whois = $this->send_data('WHOIS', $user);  
	 echo $whois;  
	 echo $msge;  
	 $abfrage = "SELECT Userhost FROM user WHERE Userhost LIKE '$uhost' LIMIT 1";  
     $ergebnis = mysql_query($abfrage);  
     $row = mysql_fetch_object($ergebnis);  
	 if($row->Userhost == $uhost)  
    {  
    $this->send_data('MODE', $msge);  
    echo "Login erfolgreich.";  
    }  
	}  
  
 }  
	$bot = new IRCBot($config);  
  
?>  
  

Es ist möglich das meine hinzugefügten funktionen unübersichtlich sind.
Der bot ist auf die basis vom wildphp bot.

  1. also ich bin dabei einen IRC Bot zu erstellen und zwar mit mysql datenabfrage vo users etc. nur wenn der bot mir bzw einen user aus der datenbank op geben soll geht das nicht da der bot aus einen array den channel ausliest und dabei mit string_replace bzw eregi_replace am ede vom channel einen zeilenumbruch oder so in der konsole anzeigt und der befehl somit nicht funktioniert.

    Interpunktion!!!11111elf

    Es ist möglich das meine hinzugefügten funktionen unübersichtlich sind.

    Teilweise auch unlogisch - mir erschließt sich nicht ganz warum du einerseits ereg-Funktionen anstatt der preg-Funktionen verwendest und andererseits warum du überhaupt reguläre Ausdrücke verwenden möchtest wo es duch nur um das entfernen von ! und : geht. Das erledigt str_replace() auch zuverlässig und wesentlich billiger.

    Zudem ist case-insensitive zu ersetzen auch unsinnig - meines Wissens haben der Doppelpunkt und das Ausrufezeichen keine Versalien :p