note 62177 deleted from ref.stream by betz

From: Date: Wed, 22 Feb 2006 00:49:08 +0000
Subject: note 62177 deleted from ref.stream by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104179@lists.php.net to get a copy of this message
Note Submitter: c4L-TAXI at online dot de ---- I tried a socket connection to a IRC Server:

<?php
function IRClogin($user, $pass) {
 $dummi = "";
 $retarray['stream'];
 $retarray['pingID'];

 $stream = fsockopen("darkzone.biz", 6667);

 if(!stream) {
 $retarray['stream'] = -1;
 $retarray['pingID'] = "Keine Verbindung zum Char-Server";
 return $retarray;
 }

 $retarray['stream'] = $stream;

 fputs($stream, "USER RegBot 0 0 :DarkZone Bot\r\nNick $user\r\n");
 while(!feof($stream)) {
 $dummi .= fgets($stream,1);
 }
 if(strstr($dummi, "PING :")) {
 $fooray = explode("PING :", $dummi);
 $foora = explode("\n", $fooray[1]);
 $retarray['pingID'] = $foora[0];
 $pingID = $retarray['pingID'];
 fputs($stream, "PONG :$pingID\r\n");
 } elseif(strstr($dummi,"Nickname is already in use.")) {
 $retarray['stream'] = -1;
 $retarray['pingID'] = "$user ist gerade im Chat unterwegs";
 fclose($stream);
 return $retarray;
 break;
 }

 while(!feof($stream)) {
 $dummi .= fgets($stream,1);
 }

 if(!strstr($dummi, "please choose a different nick.")) {
 $retarray['stream'] = -1;
 $retarray['pingID'] = "$user scheint nicht Registriert zu sein";
 fclose($stream);
 return $retarray;
 }

 fputs($stream, "PRIVMSG NickServ :IDENTIFY $pass\r\n");
 $dummi = "";
 while(!feof($stream)) {
 $dummi .= fgets($stream,1);
 }

 if(strstr($dummi, ! "PIN G :")) {
 fputs($stream, "PONG :$pingID\r\n");
 while(!feof($stream)) {
 $dummi .= fgets($stream,1);
 }
 }

 if(strstr($dummi, "Password incorrect.")) {
 $retarray['stream'] = -1;
 $retarray['pingID'] = "Interner Passwortfehler!<br />Bitte wende dich an einen Admin";
 fclose($stream);
 return $retarray;
 }

 return $retarray;
}
?>

but there is always the same error by calling the function IRClogin:
Fatal error: Maximum execution time of 30 seconds exceeded in /path/to/test.php on line 18 (which is: while(!feof($stream)) { )

« previous php.notes (#104179) next »