Guest User

Untitled

a guest
Mar 17th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', '1');
  4.  
  5. class draggy {
  6. var $telnet,$errno, $errmsg;
  7. var $canal, $botnick;
  8.  
  9. function draggy($datos) {
  10. $this->login=$datos['login'];
  11. $this->pass=$datos['pass'];
  12. $this->server=$datos['ip'];
  13. $this->puerto=$datos['puerto'];
  14. }
  15.  
  16. function sendtxt($str) {
  17. fputs($this->telnet, "$str\n");
  18. }
  19.  
  20. function conectar() {
  21. $this->telnet = fsockopen($this->server,$this->puerto, $errnum, $errstr, 10);
  22. if (!$this->telnet) {
  23. echo "Error: $errstr";
  24. return(false);
  25. }
  26. $s = fgets($this->telnet, 4096);
  27.  
  28. while ((strpos($s,"ickname")===false) && ($s!==false)) $s=fgets($this->telnet, 4096);
  29. if ($s===false) return(false);
  30. $this->sendtxt($this->login);
  31.  
  32. while ((strpos($s,"assword")===false) && ($s!==false)) $s=fgets($this->telnet, 4096);
  33. if ($s===false) return(false);
  34. $this->sendtxt($this->pass);
  35.  
  36. while (strpos($s,"joined")===false && ($s!==false)) $s=fgets($this->telnet, 4096);
  37. if ($s===false) return(false);
  38. $this->sendtxt(".console +mpjkco");
  39. set_socket_blocking($this->telnet,false);
  40. return(true);
  41. }
  42.  
  43. function desconectar() { $this->sendtxt(".quit"); fclose($this->telnet); }
  44.  
  45. function msg($nick, $msg) { $this->sendtxt(".msg $nick $msg"); }
  46.  
  47. function say($msg, $chan = "") { $this->sendtxt(".say $chan $msg"); }
  48.  
  49. function cambiarcanal($chan) { $this->sendtxt(".console $chan"); }
  50. }
  51. ?>
Add Comment
Please, Sign In to add comment