mam problem z fsockopen.
Mój skrypt dostaje na wejściu dane z tail -n0 -f /log/serwera. Ma to być przetwarzane i ewentualnie wysyłane na kanał IRC.
Utknąlem podczas podłączania. Co może być nie tak?
tu kod:
#!/usr/bin/php <?php //First lets set the timeout limit to 0 so the page wont time out. //set_time_limit(0); //Also inclue our config file include("cfg.php"); //Read the data from STDIN //Now lets connect. //Open the socket connection to the IRC server if($server['SOCKET']) { //Ok, we have connected to the server, now we have to send the login commands. SendCommand("PASS $server_pass\nr"); //Sends the password not needed for most servers SendCommand("NICK $nickname\nr"); //sends the nickname SendCommand("USER $ident\nr"); //sends the user must have 4 paramters { /* IRC Sends a "PING" command to the client which must be anwsered with a "PONG" Or the client gets Disconnected */ //Now lets check to see if we have joined the server if(strpos($server['READ_BUFFER'], "422")) //422 is the message number of the MOTD for the server (The last thing displayed after a successful connection) { //If we have joined the server SendCommand("JOIN $server_chan\nr"); //Join the chanel } { //As you can see i dont have it reply with just "PONG" //It sends PONG and the data recived after the "PING" text on that recived line //Reason being is some irc servers have a "No Spoof" feature that sends a key after the PING //Command that must be replied with PONG and the same key sent. } //PLAYER_ENTERED |x|_hoax 62.56.79.192 Ś×Ś Hoax //PLAYER_RENAMED ctxtadd Tadd@crazy-tronners.com 84.57.165.48 1 CTxTadd while (1) { { $name = $keywords[2]; foreach($watched as $wPlayer) { $command = "PRIVMSG $server_chan :".$date().": I've just found ".$name." on Open Sumo Server\nr"; SendCommand($command); } } } flush(); //This flushes the output buffer forcing the text in the while loop to be displayed "On demand" } } } else { } function SendCommand ($cmd) { //echo "[SEND] $cmd <br>"; //displays it on the screen } ?>
a tu odpowiedź:
Kod
codezone@joy:~/P4$ ./start_bot.sh
[STATUS] Starting the script.
[STATUS] Included configs.
[STATUS] 110 Connection timed out
[STATUS] Starting the script.
[STATUS] Included configs.
[STATUS] 110 Connection timed out
serwer na pingi odpowiada, nalezy dodac ze to irc.freenode.net port 6667
pingi z shella dochodza