Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. <?php
  2. $server = "irc.toribash.com";
  3. $port = 6667;
  4. $channel = "DAT";
  5.  
  6. $username = "KozBot";
  7. $password = "";
  8.  
  9. $database_username = "";
  10. $database_password = "";
  11. $database = "bot";
  12.  
  13. set_time_limit(0);
  14. $socket = fsockopen($server, $port);
  15. fputs($socket, "USER " . $username . " " . $username . " " . $username . ": " . $username . "\n");
  16. fputs($socket, "NICK " . $username . "\n");
  17. $save = time();
  18.  
  19. $connect = mysql_connect("mysql15.000webhost.com", $database_username, $database_password);
  20. mysql_select_db($database);
  21.  
  22. while(1) {
  23. while($data = fgets($socket, 4096)) {
  24. echo $data . "\n";
  25.  
  26. flush();
  27. preg_match("/^:(.*?)!(.*?)@(.*?)[\s](.*?)[\s](.*?)[\s]:(.*?)$/", $data, $rawdata);
  28.  
  29. if ($rawdata[4] == "JOIN" || $rawdata[4] == "PART" || $rawdata[4] == "QUIT") {
  30. $count = 0;
  31. fputs($socket, "WHO #" . $channel . "\n");
  32. }
  33.  
  34. $ex = explode(" ", $data);
  35.  
  36. if ($ex[0] == "PING")
  37. fputs($socket, "PONG " . $ex[1]. "\n");
  38.  
  39. if ($ex[1] == "001" ) {
  40. fputs($socket, "PRIVMSG NickServ :identify " . $password . "\n" );
  41. sleep(.75);
  42. } else if (strstr($data, "Password accepted") or strstr($data, "You are already identified") or strstr($data, "Your nick isn't registered")) {
  43. fputs($socket, "JOIN #" . $channel . "\n" );
  44. $count = 0;
  45. fputs($socket, "WHO #" . $channel . "\n");
  46. } else if ($ex[1] == "352" && $ex[2] == $channel && $ex[3] == "#" . $channel && $ex[6] == "*" && $ex[9] == ":0")
  47. $count++;
  48.  
  49. if ((time() - $save) > 10) {
  50. $save = time();
  51. echo "Saving online count to database...\n\n";
  52. mysql_query("UPDATE `irc_online` SET `online` = '" . $count . "'");
  53. }
  54. }
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement