Page 1 of 1

fsockopen()

Posted: Tue Nov 02, 2004 12:12 am
by William

Code: Select all

<?php

$irc_server = "irc.us.gamesurge.net";
$irc_port = "6667";
$localhost = "localhost";
$irc_nick = "William2004";
$irc_realname = "[eXtract] IRC Bot";
$irc_channel = "#test";
$irc_quiet = "Session Ended";

$irc_connection = fsockopen("$irc_server",$irc_port);
fputs($irc_connection, "USER $irc_nick $localhost $irc_server : $irc_realname n");  
fputs($irc_connection, "NICK $irc_nick n");  
fputs($irc_connection, "JOIN #irc_channel n");  
fputs($irc_connection, "QUIT $irc_quiet n");  

while (!feof($irc_connection) OR !$irc_connection) {  
	$data = fgets($irc_connection, 1024);    
	echo str_replace(" ", "<br>", $data);
	$match = explode(" ", $data);  
  
	if ($match[1] == "001") {  
		fclose($irc_connection);
		exit;  
	}
}

?>
Thats my code, My error is:

NOTICE
AUTH
:***
Looking
up
your
hostname NOTICE
AUTH
:***
Found
your
hostname,
cached NOTICE
AUTH
:***
Checking
Ident ERROR
:Closing
Link:

by
NetFire.TX.US.GameSurge.net
(Registration
Timeout)

I don't get the problem, Does anyone have any ideas?

Posted: Tue Nov 02, 2004 12:55 am
by rehfeld
not sure if this is your problem, but you forgot to escape your n's at the end of each header

you need to use \n to create a newline

Code: Select all

fputs($irc_connection, "USER $irc_nick $localhost $irc_server : $irc_realname \n");  
fputs($irc_connection, "NICK $irc_nick \n");  
fputs($irc_connection, "JOIN #irc_channel \n");  
fputs($irc_connection, "QUIT $irc_quiet \n");

Posted: Tue Nov 02, 2004 1:03 am
by William
Wow, looks like it worked, thanks :D

Posted: Tue Nov 02, 2004 1:05 am
by William
NOTICE
AUTH
:***
Looking
up
your
hostname NOTICE
AUTH
:***
Checking
Ident NOTICE
AUTH
:***
Found
your
hostname PING
:970343986 :NetFire.TX.US.GameSurge.net
451
William2004
William2004
:Register
first.