Guest User

Untitled

a guest
Mar 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', '1');
  5.  
  6.  
  7. class draggy {
  8. var $telnet,$errno, $errmsg;
  9. var $canal, $botnick;
  10.  
  11. function draggy($datos) {
  12. $this->login=$datos['login'];
  13. $this->pass=$datos['pass'];
  14. $this->server=$datos['ip'];
  15. $this->puerto=$datos['puerto'];
  16. }
  17.  
  18. function sendtxt($str) {
  19. fputs($this->telnet, "$str\n");
  20. }
  21.  
  22. function conectar() {
  23. $this->telnet = fsockopen($this->server,$this->puerto, $errnum, $errstr, 10);
  24. if (!$this->telnet) {
  25. echo "Error: $errstr";
  26. return(false);
  27. }
  28. $s = fgets($this->telnet, 4096);
  29.  
  30. while ((strpos($s,"ickname")===false) && ($s!==false)) $s=fgets($this->telnet, 4096);
  31. if ($s===false) return(false);
  32. $this->sendtxt($this->login);
  33.  
  34. while ((strpos($s,"assword")===false) && ($s!==false)) $s=fgets($this->telnet, 4096);
  35. if ($s===false) return(false);
  36. $this->sendtxt($this->pass);
  37.  
  38. while (strpos($s,"joined")===false && ($s!==false)) $s=fgets($this->telnet, 4096);
  39. if ($s===false) return(false);
  40. $this->sendtxt(".console +mpjkco");
  41. set_socket_blocking($this->telnet,false);
  42. // $this->telnet = $telnet;
  43. return(true);
  44. }
  45.  
  46. function desconectar() { $this->sendtxt(".quit"); fclose($this->telnet); }
  47.  
  48. function msg($nick, $msg) { $this->sendtxt(".msg $nick $msg"); }
  49.  
  50. function say($msg, $chan = "") { $this->sendtxt(".say $chan $msg"); }
  51.  
  52. function cambiarcanal($chan) { $this->sendtxt(".console $chan"); }
  53. }
  54.  
  55. $data['login'] = 'angelbroz';
  56. $data['pass'] = 'w3b0s';
  57. $data['puerto'] = '33340';
  58. $data['ip'] = 'localhost';
  59.  
  60. $mybot = & new draggy($data);
  61.  
  62. echo "Conectando con el servidor<br>";
  63.  
  64. $mybot->conectar() or die("No me puedo conectar\n");
  65.  
  66. $mybot->cambiarcanal('#ikimlinux');
  67. echo "Saying AngelBroz connected<br>";
  68. $mybot->say('AngelBroz connected','#ikimlinux');
  69. echo "Descoenctandose<br>";
  70. $mybot->desconectar();
  71.  
  72. ?>
Add Comment
Please, Sign In to add comment