Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.95 KB | None | 0 0
  1. <?php
  2.  
  3. $ip = "irc.cit2.net";
  4. $port = 6667;
  5. $nickname = "AayushBot";
  6. $ident = "Nub";
  7. $realname = "BOT";
  8. $home = "#HIS";
  9. $backslash = chr(92);
  10. $userbase['soulkeeper'] = "password";
  11. $userbase['soulkeeper'] = "password";
  12.  
  13. error_reporting(1);
  14. function wideban($address) {
  15. $this_ban = "*";
  16. $dot = explode(".", $address);
  17. foreach ($dot as $yah_dot_yah) {
  18. $numbers = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
  19. foreach ($numbers as $this_num) {
  20. $pos = strpos($yah_dot_yah, $this_num);
  21. if ($pos === false) { $num = FALSE; } else { $num = TRUE; $never_set = TRUE; }
  22. }
  23. if (!$num) { $this_ban .= ".$yah_dot_yah"; $num = FALSE; }
  24. }
  25. if (!$never_set) {
  26. $this_ban = "*";
  27. foreach ($dot as $this_dot) {
  28. if ($first) { $this_ban .= ".$this_dot"; }
  29. $first = TRUE;
  30. }
  31. }
  32. return $this_ban;
  33. }
  34. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  35. socket_connect($socket, $ip, $port);
  36. sleep(1);
  37. socket_write($socket, "USER $ident $ident $ident :$realname\nNICK $nickname\n");
  38. while ($read = socket_read($socket, 2048)) {
  39. $hack = explode("\n", $read);
  40. foreach ($hack as $this_hack) {
  41. $token = explode(" ", $this_hack);
  42. $id = explode("!", strtolower($token[0]));
  43. $nick = str_replace(":", "", $id[0]);
  44. $ident = explode("@", $id[1]);
  45. $address = $ident[1];
  46. $ident = $ident[0];
  47. $channel = str_replace(":", "", trim(strtolower($token[2])));
  48. if ($token[0] == "PING") { socket_write($socket, "PONG $token[1]\n"); }
  49. if ($token[1] == "376") { socket_write($socket, "JOIN $home\n"); socket_write($socket, "UMODE -Mm\n"); }
  50. if ($token[1] == "353") {
  51. $channel = strtolower($token[4]);
  52. $tmpnames = explode(":", trim(strtolower($this_hack)));
  53. $tmpnames = explode(" ", $tmpnames[2]);
  54. foreach ($tmpnames as $this_name) {
  55. $this_name = str_replace("@", "", $this_name);
  56. $this_name = str_replace("+", "", $this_name);
  57. $ial[$channel][$this_name]['h'] = TRUE;
  58. socket_write($socket, "WHO $this_name\n");
  59. }
  60. }
  61. if ($token[1] == "352") {
  62. $ident = strtolower($token[4]);
  63. $address = strtolower($token[5]);
  64. $nick = strtolower($token[7]);
  65. foreach ($ial as $this_chan=>$this_nick) {
  66. if ($ial[$this_chan][$nick]['h']) { $ial[$this_chan][$nick]['h'] = $address; $ial[$this_chan][$nick]['i'] = $ident; }
  67. }
  68. }
  69. if ($token[1] == "JOIN") {
  70. $ial[$channel][$nick]['h'] = $address;
  71. $ial[$channel][$nick]['i'] = $ident;
  72. if (isset($banlist[$channel][$nick])) { socket_write($socket, "KICK $channel $nick :Banned.\n"); }
  73.  
  74. if ($token[1] == "MODE") {
  75. if($token[4] == "Megazord") {
  76. if($token[3] == "-o") { sockwrite($socket, "PRIVMSG ChanServ op $channel\n"); }
  77. }
  78. }
  79. foreach ($banlist[$channel] as $this_nick=>$banmask) {
  80. if ($banmask == $ial[$channel][$nick]['h']) { socket_write($socket, "KICK $channel $nick :Nice try. ;)\n"); }
  81. }
  82. }
  83. if ($token[1] == "PRIVMSG") {
  84. $message = explode(":", trim(strtolower($this_hack)));
  85. $priv_token = explode(" ", $message[2]);
  86. $this_nick = $priv_token[1];
  87. $this_ban = wideban($ial[$channel][$this_nick]['h']);
  88. if ($priv_token[0] == "login") {
  89. if ($userbase[$nick] == $priv_token[1]) { $logged_in[$nick] = TRUE; socket_write($socket, "NOTICE $nick :Successfully logged in.\n"); } else { socket_write($socket, "NOTICE $nick :Access \002denied\002\n"); }
  90. }
  91. if (!$logged_in[$nick]) { unset($priv_token); }
  92. if ($priv_token[0] == ".ban") {
  93. if (!isset($ial[$channel][$this_nick]['h'])) { socket_write($socket, "PRIVMSG $channel :Take a look at the nick list, pal.\n"); } else {
  94. $banlist[$channel][$this_nick] = $ial[$channel][$this_nick]['h'];
  95. echo "Banning $channel : $this_ban\n";
  96. socket_write($socket, "MODE $channel +b *!*@$this_ban\n");
  97. socket_write($socket, "KICK $channel $this_nick :Requested by $nick\n");  
  98. }
  99. }
  100. if ($priv_token[0] == ".unban") {
  101. if (isset($banlist[$channel][$this_nick])) {
  102. $this_ban = wideban($banlist[$channel][$this_nick]);
  103. unset($banlist[$channel][$this_nick]);
  104. socket_write($socket, "MODE $channel -b *!*@$this_ban\n");
  105. socket_write($socket, "PRIVMSG $channel :Done.\n");
  106. }
  107.  
  108. }
  109. if ($priv_token[0] == ".banlist") {
  110. $count = 0;
  111. if (isset($banlist[$channel])) { socket_write($socket, "PRIVMSG $channel :Listing banlist entries for $channel.\n"); foreach ($banlist[$channel] as $whateva=>$banmask) { $count++; socket_write($socket, "PRIVMSG $channel :#$count $whateva [\002$banmask\002]\n"); } } else { socket_write($socket, "PRIVMSG $channel :No entries in banlist for $channel\n"); }
  112.  
  113. }
  114. if ($priv_token[0] == ".join") {
  115.     socket_write($socket, "JOIN $priv_token[1]\n");
  116.     socket_write($socket, "NOTICE $nick :Succesfully joined $priv_token[1]\n");
  117. }
  118. if ($priv_token[0] == ".part") {
  119.     socket_write($socket, "PART $priv_token[1]\n");
  120.     socket_write($socket, "NOTICE $nick :Succesfully parted $priv_token[1]\n");
  121. }
  122. if ($priv_token[0] == ".die") {
  123.     socket_write($socket, "PRIVMSG $chan :Killing Myself. D=\n");
  124.     die("Dead");
  125. }
  126. if ($priv_token[0] == ".identify") {
  127.     socket_write($socket, "NICK Megazord [Password]\n");
  128.     socket_write($socket, "NOTICE $nick :Successfully Authed!\n");
  129. }
  130.  
  131. }
  132. echo "$this_hack\n";
  133. }
  134. }
  135.  
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement