fsockopen()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

fsockopen()

Post 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?
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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");
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post by William »

Wow, looks like it worked, thanks :D
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post 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.
Post Reply