Page 1 of 2

Register Nick From web portal

Posted: Tue Mar 08, 2005 12:27 pm
by Number
I'm sorry but i can't use Awesome ...

I'm read and change the config file.. Whit localhost for ip of the server
But when i'm logon i didn't say anything ...


I would like to register nick from a web portal and I can use php ..
I use socket but i can't how to use it ....

Someone have a example please ??
I woul like to do this alone .. but i need help..

Posted: Tue Mar 08, 2005 2:22 pm
by Number
I'm come back home...
And this is my code :

Code: Select all

<?php

$ip = "localhost";
$port = "6667";
$nickname = "Number_?";
$channel = "#Bienvenue";

$fp = fsockopen("$ip", $port, $errno, $errstr);


$fget = fgets($fp);

echo "$fget <br />";


$fputs = fputs($fp, "USER 'TEST' 'TEST'@'localhost' :TEST");

$fgets = fgets($fp);

echo "$fgets <br />";


$fput = fputs($fp,"NICK TEST");

$fg = fgets($fp);

echo "$fg <br />";

?>
But the only response i have is that :
:irc.number.no-ip.org NOTICE AUTH :*** Looking up your hostname...
:irc.number.no-ip.org NOTICE AUTH :*** Found your hostname
What can i do ? to be logon and have the motd whit socket in php ??

Thanks a lot

Posted: Tue Mar 08, 2005 2:24 pm
by w00t
Ugh. Try introducing at least a general loop checking the eof state of the socket.

You'll also need to handle IRC commands such as PING, etc etc etc etc.

Hint: Research the following PHP stuff: while loops, feof, fclose.

Posted: Tue Mar 08, 2005 3:17 pm
by Number
Thanks ... Now it run ...
But i have a another problem...

See this :
connect to localhost...
Ident...
:irc.number.no-ip.org NOTICE AUTH :*** Looking up your hostname...
:irc.number.no-ip.org NOTICE AUTH :*** Found your hostname
:irc.number.no-ip.org NOTICE Test :*** If you are having problems connecting due to ping timeouts, please type /quote pong 70EFC0C3 or /raw pong 70EFC0C3 now.
PING :70EFC0C3
PONG !
:irc.number.no-ip.org 451 STATS :You have not registered
ERROR :Closing Link: Test[127.0.0.1] (Ping timeout)
What does it mean : "451 STATS: You have not registered"

I don't need to be register to do /STATS u...

Why ???

Code: Select all

$fp=fsockopen("$serv","6667");

fputs($fp, "USER Test localhost localhost :register\r\n");
fputs($fp,"NICK Test\r\n");

sleep(1);

fputs($fp,"STATS u\r\n");   
     
            while ($line = fgets($fp,1024)) {

                $a = explode(" ", $line);

		echo "$line <br />";

                if ($a[0] == "PING") {

                    fputs($sock, "PONG $a[1]");
			echo "PONG ! <br />";
                }
		}
Thanks for your help w00t

Posted: Tue Mar 08, 2005 3:29 pm
by w00t
Try waiting for an "001" response in a[1] and sending the STATS request then.

Posted: Tue Mar 08, 2005 3:34 pm
by Number
But ...
On each fgets from a socket i'm print the result...

Thus i don't have anithing whit 00 .. ?
I can use sleep(5); for wait a response ..

i'm right ??

Posted: Tue Mar 08, 2005 3:52 pm
by w00t
fputs($sock, "PONG $a[1]");

echo that back EXACTLY so we cna see what you're sending.

Posted: Tue Mar 08, 2005 4:26 pm
by Number
i Know that ...

Echo Print what the server send by the socket ...
And for each thing the web page receive i use echo to see it ...

If i receive PING - 1234567
I send (now ) PONG- 1234567

But i have this :
=>USER Test localhost localhost :register
=>NICK Test
<= :irc.number.no-ip.org NOTICE AUTH :*** Looking up your hostname...
<= :irc.number.no-ip.org NOTICE AUTH :*** Found your hostname
<= :irc.number.no-ip.org NOTICE Test :*** If you are having problems connecting due to ping timeouts, please type /quote pong 6D4CBA32 or /raw pong 6D4CBA32 now.
<= PING :6D4CBA32
=> PONG :6D4CBA32
<= :irc.number.no-ip.org 451 STATS :You have not registered
<= ERROR :Closing Link: Test[127.0.0.1] (Ping timeout)
In php :

I send USER
I Send NICK
I wait 10 ''
I Respond to PONG if server send PING ..
And I Send STATS ...

Posted: Tue Mar 08, 2005 4:32 pm
by codemastr
Doesn't PHP come with a basic set of IRC functions? http://docs.php.net/en/ref.ircg.html

Posted: Tue Mar 08, 2005 4:32 pm
by w00t
Don't wait that 10 seconds. You might be missing something, and you dont need to wait. The loop will only finish if the socket gets closed (so you'll want to send a QUIT after you recieve RPL_ENDOFSTATS or whatever

Posted: Tue Mar 08, 2005 4:41 pm
by Number
codemastr wrote:Doesn't PHP come with a basic set of IRC functions? http://docs.php.net/en/ref.ircg.html
It's not with php ..
You can't compile php with ircg ..
You need to install it after ...

I don't want to use ircg because my website must to be "portabl" ..

w00t ..
I deleted the "sleep(10)" but i have the same ...
You can test whit me ?? please ...

Posted: Tue Mar 08, 2005 4:46 pm
by w00t
codemastr, the ircg library also gave me quite a few headaches when i tried it :p (php/apache crashes, etc)

Number: Not today sorry. it's 3:45am, and i'm having trouble just typing. :)

Posted: Tue Mar 08, 2005 4:50 pm
by Number
Thanks w00t i'm patient ...

Thanks for your help .. And i wait a response from you to continue ..
While this response i'm continue to test ..

Thanks a lot ...

Posted: Tue Mar 08, 2005 6:38 pm
by Matridom
codemastr wrote:Doesn't PHP come with a basic set of IRC functions? http://docs.php.net/en/ref.ircg.html
Wow, Thanx codemastr, and i was using fsockets the entire time for some web based stuff to IRC.. Time to do some reading.

Posted: Wed Mar 09, 2005 2:22 pm
by Number
w00z Your are ready for the socket adventure today ??