2013-05-04 26 views
-1

這裏是我的代碼如果登錄嘗試回顯連接,使用身份驗證的IRC登錄會發送到NICKSERV?

<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 
//konfig 
     $server = "XXXX"; 
     $port = "XXXX"; 
     $enable_password = true; 
//error 
     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"); 

       //get $line 
       $line = @fgets($socket, 1024); 
       if (strstr($line, "Authentication successful. You are now Login")) { 
        echo "Connected"; 
       } else { 
        echo "Not Connected"; 
       } 
      } 
     } 
    } 
    ?> 
</body> 

襪子裝在我的PHP。 我嘗試,並輸出未連接,而用戶名和密碼爲真。 它需要通過發送/ msg NICKSERV標識[passwd]來識別用戶名和密碼。 任何想法如何將該命令添加到我的腳本?和輸出的希望結果是正確的,而我輸入用戶名和密碼..

回答

0

我發現話題:

Send a private message to an IRC bot

它具有以下功能:

function SendCommand ($cmd) 
{ 
    global $server; //Extends our $server array to this function 
    @fwrite($server['SOCKET'], $cmd, strlen($cmd)); //sends the command to the server 
    echo "[SEND] $cmd <br>"; //displays it on the screen 
} 

所以發送命令,因爲它顯示即:

SendCommand("PONG :".substr($server['READ_BUFFER'], 6)."\n\r"); 

看來你sh應遵循像fwrite($ socket,$ cmd,strlen($ cmd))這樣的模式;

+0

確定我會嘗試通過配置添加到陣列... – user2328538 2013-05-04 14:21:25

+0

感謝建議 – user2328538 2013-05-04 14:21:26