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? Link to comment https://forums.phpfreaks.com/topic/277655-checking-authentication-login-irc-via-php/ Share on other sites More sharing options...
xymcrush17 Posted May 7, 2013 Author Share Posted May 7, 2013 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 Link to comment https://forums.phpfreaks.com/topic/277655-checking-authentication-login-irc-via-php/#findComment-1428894 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. Link to comment https://forums.phpfreaks.com/topic/277655-checking-authentication-login-irc-via-php/#findComment-1428943 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. Link to comment https://forums.phpfreaks.com/topic/277655-checking-authentication-login-irc-via-php/#findComment-1428965 Share on other sites More sharing options...
xymcrush17 Posted May 8, 2013 Author Share Posted May 8, 2013 i solved my problem by myself added break; Link to comment https://forums.phpfreaks.com/topic/277655-checking-authentication-login-irc-via-php/#findComment-1429008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.