xymcrush17 Posted May 5, 2013 Share Posted May 5, 2013 Hi everyone I need help how to check the authentication by sending username and password form to IRC <html> <title></title> <body> <form method="get" > Username: <input type="text" name="user"><br> Password: <input type="password" name="pwd"><br> <input type="submit" value="Submit"> </form> <?php $server = "XXXX"; $port = "XXXX"; $enable_password = true; error_reporting(0); if (isset($_GET['user']) && isset($_GET['pwd'])) { $username = $_GET['user']; $password = $_GET['pwd']; if (($username !== "") && ($password !== "")) { set_time_limit(30); if (!($socket = fsockopen($server, $port, $errno, $errstr, 10))) { echo "Cant Connect Server"; flush(); } else { if ($enable_password) fputs($socket, "USER " . $username . "\n"); fputs($socket, "PASS " . $password . "\n"); // here where i want to get output if the username and password that i input in form is connected,it will be printed "connected" and else is "not connected".. and i have try be add code in the next line below . //get $line $line = @fgets($socket, 1024); if (strstr($line, "Authentication successful. You are now Login")) { echo "Connected"; } else { echo "Not Connected"; } } } } ?> </body> but its not work..while i put correct user and password its still not connected. any suggest? Quote Link to comment Share on other sites More sharing options...
xymcrush17 Posted May 7, 2013 Author Share Posted May 7, 2013 (edited) I just keep trying to get this work's at lease it works's <form method="get" > Username: <input type="text" name="user"><br> Password: <input type="password" name="pwd"><br> <input type="submit" value="Submit"> </form> <?php if (isset($_GET['user']) && isset($_GET['pwd'])) { $nick = $_GET['user']; $server = ""; $port = ""; $nickpass = $_GET['pwd']; $s = fsockopen( $server , $port, $errno, $errstr, 10 ); fputs( $s, "NICK $nick\n" ); fputs( $s, "NICK $nick\n" ); fputs( $s, "NICK $nick\n" ); fputs( $s, "PASS $nickpass\n" ); fputs( $s, "USER $nick $nick $nick $nick :$nick\n" ); while ($data = fgets( $s, 768 )) { flush(); $info = split( " ", $data ); //parsing data auth if ( strstr( $data, "Authentication failed." )) { echo "<pre>Not Connected</pre>"; } if ( strstr( $data, "Authentication successful. You are now logged in." )) { echo "<pre>Connected</pre>"; } } } ?> but its so long loading to connect to server.. would anybody help me how to make fast connect? thanks Edited May 7, 2013 by xymcrush17 Quote Link to comment Share on other sites More sharing options...
requinix Posted May 7, 2013 Share Posted May 7, 2013 I forget exactly why but some servers will do reverse lookups on you. That can take a few seconds. Manually connect with telnet and see what the server is doing. Quote Link to comment Share on other sites More sharing options...
xymcrush17 Posted May 7, 2013 Author Share Posted May 7, 2013 Yes sure i hve checked via telnet, and not longer than it.. and in that code it connected fast to server before i added while statement to parse line. Quote Link to comment Share on other sites More sharing options...
Solution xymcrush17 Posted May 8, 2013 Author Solution Share Posted May 8, 2013 i solved my problem by myself added break; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.