This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Replycode handler

By: Xenios on Oct 25th, 2012  |  syntax: PHP  |  size: 1.08 KB  |  views: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2. 353 = RPL_NAMREPLY
  3. "<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]"
  4.  
  5. 366 = RPL_ENDOFNAMES
  6. "<channel> :End of /NAMES list"
  7.  
  8. - To reply to a NAMES message, a reply pair consisting of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the server back to the client. If there is no channel found as in the query, then only RPL_ENDOFNAMES is returned. The exception to this is when a NAMES message is sent with no parameters and all visible channels and contents are sent back in a series of RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark the end.
  9. */
  10.  
  11.  
  12.  
  13. // replycode 353 handler ($cmd = untoutched data from $read)
  14.  
  15. if (strpos($cmd, 353) !== false)
  16. {
  17.     //Search reply code 353 (int)
  18.     $replyCodePos = strpos($cmd, 353);
  19.  
  20.     //Search reply code 366 (int) to get end of the name list.
  21.     $replyCodeEndLine = strpos($cmd, 366);
  22.  
  23.     //extract data between reply code 353 and reply code 366.
  24.     $replyCode = substr($cmd, $replyCodePos, $replyCodeEndLine);
  25.     echo "\nUsers in channel are: $replyCode\n"; // should show the part with names and some other things of the NAMES Command
  26.  
  27. }
clone this paste RAW Paste Data