Advertisement
Guest User

chatbot.php

a guest
Sep 15th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 47.62 KB | None | 0 0
  1. <?php
  2. set_time_limit( 0 ); // Maximum time of execution
  3. error_reporting( 0 ); // Not show errors
  4.  
  5. class zBot
  6. {
  7.     /* Sample config */
  8.     public $Weoxolink = "http://localhost";
  9.     public $user = "Bot2"; //  BOT Username
  10.     public $pass = "Option"; // Bot Password
  11.     public $chat = "Chat"; // Chat Room Name
  12.     /* Remember that the BOT 's account must have everypower! */
  13.     public $name = "Planets(tickle#noel#ffffff#f#topspin#w6#offset#w6351)[ID:368](Planets)(text#ffffff#0015ff)"; // Bot Nick Name
  14.     public $hat = "(hat#f#0015ff)"; // Bot Hat Code
  15.     public $glow = "(glow#0015ff#ffffff)"; // Bot NameColor/NameGlow
  16.     public $status = "Price: 500 | Limited"; // Bot Status
  17.     public $statusglow = "0015ff"; // Bot StatusGlow
  18.     public $statuscolor = "ffffff"; // Bot StatusColor
  19.     public $textcolor = "(text#ffffff#000001)"; // BOt TextColor
  20.     public $avatar = "(randomplanets)"; // BOT Avatar
  21.     public $home = ""; //  BOT Homepage
  22.     public $maxKicks = 4; //Number of kicks before ban
  23.     public $admins = Array( 5,815,256,100 ); // IDs with bot access example Array(42,100,96218942); etc...
  24.     public $semacesso = "You dont allowed use commands!"; //Message without access..
  25.     public $autoWelcome = "Welcome to Weoxo ! Register your Account and get Free Coins And Days "; // Welcome message for users
  26.     public $automember = True; // True = activated, False = deactivated
  27.     public $autoguest = False; // True = activated, False = deactivated
  28.     public $censor = array("fuck","bitch","motherfucker","penis","pussy");
  29.     public $censor2 = array("test","hehe","hey","hi");
  30.      public $radioinfo = 'semnome';
  31.     /* Extra */
  32.     public $users;
  33.     public $logado;
  34.     public $socket;
  35.     public $chatID ;
  36.     public $botID ;
  37.     public $port ="1204";
  38.     public $ip ="localhost";
  39.     public $k;
  40.    
  41.     /* Function to connect with Weoxo.com*/
  42.     public function conectar( )
  43.     {
  44.         $this->getinfo();
  45.         $this->socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
  46.         $test         = socket_connect( $this->socket, $this->ip, $this->port );
  47.         echo "--> Connecting  {$this->ip}:{$this->port}...\n";
  48.         If ( !$test ) {
  49.             die( "<-- Failed Connection!\n" );
  50.         } //!$test
  51.     }
  52.    
  53.     /* Function to disconnect [ used to debug ] */
  54.     public function desconectar( )
  55.     {
  56.         If ( isset( $this->socket ) && $this->socket == True )
  57.             socket_close( $this->socket );
  58.         $this->socket = False;
  59.     }
  60.    
  61.     /* Function to get informations about the bot User... */
  62.    function getinfo( )
  63.     {
  64.         $curl = curl_init( $this->Weoxolink . "/mobile?" . time() );
  65.         curl_setopt( $curl, CURLOPT_RETURNTRANSFER, True );
  66.         curl_setopt( $curl, CURLOPT_POST, True );
  67.         curl_setopt( $curl, CURLOPT_POSTFIELDS, "username={$this->user}&password={$this->pass}&room={$this->chat}" );
  68.         $url          = curl_exec( $curl );
  69.         $parte1       = explode( "\"id\":\"", $url );
  70.         $id           = explode( "\"", $parte1[ 1 ] );
  71.         $this->botID  = $id[ 0 ];
  72.         $parte2       = explode( "\"k\":\"", $url );
  73.         $k            = explode( "\"", $parte2[ 1 ] );
  74.         $this->k      = $k[ 0 ];
  75.         $parte3       = explode( "'<y r=\"", $url );
  76.         $chat_data              = explode('c="', $url);
  77.         $chatID                 = explode('"', $chat_data[1]);
  78.         $this->chatID   = $chatID[0];
  79.         $parte4       = explode( "WebSocket('ws://", $url );
  80.         $ip           = explode( ":", $parte4[ 1 ] );
  81.         $this->ip     = $ip[ 0 ];
  82.         $dx_data                = explode("\"xats\":\"", $url);
  83.         $dx                             = explode("\"", $dx_data[1]);
  84.         $this->dx               = $dx[0];
  85.         $d1_data                = explode("\"days\":\"", $url);
  86.         $d1                             = explode("\"", $d1_data[1]);
  87.         $this->d1               = $d1[0];
  88.         $d4_data                = explode('"p4":', $url);
  89.         $d4                             = explode(',"', $d4_data[1]);
  90.         $this->d4               = $d4[0];
  91.         $d5_data                = explode('"p5":', $url);
  92.         $d5                             = explode(',"', $d5_data[1]);
  93.         $this->d5               = $d5[0];
  94.         $d6_data                = explode('"p6":', $url);
  95.         $d6                             = explode(',"', $d6_data[1]);
  96.         $this->d6               = $d6[0];
  97.         $d7_data                = explode('"p7":', $url);
  98.         $d7                             = explode(',"', $d7_data[1]);
  99.         $this->d7               = $d7[0];
  100.         $d8_data                = explode('"p8":', $url);
  101.         $d8                             = explode(',"', $d8_data[1]);
  102.         $this->d8               = $d8[0];
  103.         $d9_data                = explode('"p9":', $url);
  104.         $d9                             = explode(',"', $d9_data[1]);
  105.         $this->d9               = $d9[0];
  106.         $d10_data               = explode('"p10":', $url);
  107.         $d10                    = explode(',"', $d10_data[1]);
  108.         $this->d10              = $d10[0];
  109.         $d11_data               = explode('"p11":', $url);
  110.         $d11                    = explode(',"', $d11_data[1]);
  111.         $this->d11              = $d11[0];
  112.         $d12_data               = explode('"p12":', $url);
  113.         $d12                    = explode(',"', $d12_data[1]);
  114.         $this->d12              = $d12[0];
  115.         $d13_data               = explode('"p13":', $url);
  116.         $d13                    = explode(',"', $d13_data[1]);
  117.         $this->d13              = $d13[0];
  118.         $d14_data               = explode('p14":', $url);
  119.         $d14                    = explode(',"', $d14_data[1]);
  120.         $this->d14              = $d14[0];
  121.         $d15_data               = explode('p15":', $url);
  122.         $d15                    = explode('}', $d15_data[1]);
  123.         $this->d15              = $d15[0];
  124.         $parte5       = explode( $this->ip . ":", $url );
  125.         $port        = explode( "/", $parte5[ 1 ] );
  126.         $this->port  = $port[ 0 ];
  127.         If ( empty( $url ) ) {
  128.             die( "<-- Connection failed, or the website could be closed!!\n" );
  129.         } //empty( $url )
  130.         If ( empty( $this->botID ) ) {
  131.             die( "<-- The chat doesn't exist, or the data is incorrect!\n" );
  132.         } //empty( $this->botID )
  133.     }
  134.    
  135.    
  136.     /* Passing XML code to catch B1 and B2 */
  137.     public function passXML( $xml, $return = null )
  138.     {
  139.         $content = @simplexml_load_string( trim( $xml ) );
  140.         Foreach ( $content->Attributes() as $i => $u )
  141.             $return[ $i ] = (string) ( (string) $u );
  142.         return $return;
  143.     }
  144.    
  145.     /* Send obvious packets ._. */
  146.     public function enviar( $packet )
  147.     {
  148.         If ( $packet[ strlen( $packet ) - 1 ] != chr( 0 ) )
  149.             $packet .= chr( 0 );
  150.         echo "[BOT]-> {$packet}\n";
  151.         return socket_write( $this->socket, $packet, strlen( $packet ) );
  152.     }
  153.    
  154.     /* Weoxo not enter group */
  155.    public function entrar( )
  156.     {
  157.         $this->conectar();
  158.         $this->enviar( "<y r=\"{$this->chatID}\" />" );
  159.         $x  = $this->passXML(socket_read($this->socket, 10090));
  160.         $b1 = floor(2 << ($x["yi"] % 94)) % $x["yc"] + $x["yi"];
  161.         $b2 = floor(pow(2, $x["ys"] % 27));
  162.         $j2 = "cb=\"0\" ";
  163.         $j2 .= "auth1=\"{$b1}\" ";
  164.         $j2 .= "auth2=\"{$b2}\" ";
  165.         $j2 .= "y=\"{$x[ 'yi' ]}\" ";
  166.         $j2 .= "k=\"{$this->k}\" ";
  167.         $j2 .= "k3=\"0\" ";
  168.         $j2 .= "d1=\"{$this->d1}\" ";
  169.         $j2 .= "p=\"0\" ";
  170.         $j2 .= "c=\"{$this->chatID}\" ";
  171.         $j2 .= "f=\"8192\" ";
  172.         $j2 .= "u=\"{$this->botID}\" ";
  173.         $j2 .= "m6=\"131072\" ";
  174.         $j2 .= "d0=\"0\" ";
  175.         $j2 .= "d2=\"0\" ";
  176.         $j2 .= "d4=\"{$this->d4}\" ";
  177.         $j2 .= "d5=\"{$this->d5}\" ";
  178.         $j2 .= "d6=\"{$this->d6}\" ";
  179.         $j2 .= "d7=\"{$this->d7}\" ";
  180.         $j2 .= "d8=\"{$this->d8}\" ";
  181.         $j2 .= "d9=\"{$this->d9}\" ";
  182.         $j2 .= "d10=\"{$this->d10}\" ";
  183.         $j2 .= "d11=\"{$this->d11}\" ";
  184.         $j2 .= "d12=\"{$this->d12}\" ";
  185.         $j2 .= "d13=\"{$this->d13}\" ";
  186.         $j2 .= "d14=\"{$this->d14}\" ";
  187.         $j2 .= "d15=\"{$this->d15}\" ";
  188.         $j2 .= "N=\"{$this->user}\" ";
  189.         $j2 .= "n=\"{$this->name}{$this->hat}{$this->glow}##{$this->status}#{$this->statusglow}#{$this->statuscolor}\" ";
  190.         $j2 .= "a=\"{$this->avatar}\" ";
  191.         $j2 .= "h=\"{$this->home}\" ";
  192.         $j2 .= "v=\"0\"";
  193.         $j2 = "<j2 {$j2} />";
  194.         $this->enviar( $j2 );
  195.     }
  196.    
  197.     /* load packets */
  198.     public function load( $check = True, $test_var = True )
  199.     {
  200.         $x = "";
  201.         try {
  202.             $x = rtrim( socket_read( $this->socket, 2048 ) );
  203.             $x = str_replace( "", "", $x );
  204.         }
  205.         catch ( Exception $e ) {
  206.             return "OFF";
  207.         }
  208.         If ( !$x )
  209.             return "OFF";
  210.         If ( $x[ strlen( $x ) - 1 ] != ">" )
  211.             $x .= $this->load( True );
  212.         If ( $check )
  213.             $this->packets( $x, $test_var );
  214.         return $x;
  215.     }
  216.    
  217.     /* show packets  etc... */
  218.     public function packets( $packet, $test = True, $test2 = False )
  219.     {
  220.         If ( substr_count( $packet, ">" ) > 1 ) {
  221.             $packet = explode( "/>", $packet );
  222.             $test2 = True;
  223.         } //substr_count( $packet, ">" ) > 1
  224.         Foreach ( (Array) $packet as $p ) {
  225.             If ( $test2 )
  226.                 $p .= "/>";
  227.             $p = trim( $p );
  228.             If ( strlen( $p ) < 5 )
  229.                 return;
  230.             echo "[WEOXO]-> {$p}\n";
  231.             $tipo = trim( strtolower( substr( $p, 1, strpos( $p . " ", " " ) ) ) );
  232.             $p    = trim( str_replace( "<" . $tipo, "", str_replace( "/>", "", $p ) ) );
  233.             $p    = str_replace( "\"", "", str_replace( "\" ", "&", str_replace( "&", "__38", $p ) ) );
  234.             parse_str( $p, $this->packet[ $tipo ] );
  235.             Foreach ( $this->packet[ $tipo ] as $x => $v )
  236.                 $this->packet[ $tipo ][ $x ] = str_replace( "__38", "&", str_replace( "pl_", "+", $v ) );
  237.             If ( $test )
  238.                 $this->tipos( $tipo, $this->packet[ $tipo ] );
  239.         } //(Array) $packet as $p
  240.     }
  241.    
  242.     /* Some types of packets and commands can be added here ! */
  243.     public function tipos( $tipo, $packet )
  244.     {
  245.         switch ( $tipo ) {
  246.             /* Packets */
  247.             case 'u':
  248.                 $u = $this->fetchUser($packet['u']);
  249.                 $this->users[$packet['u']]['cb'] = @$packet['cb'];
  250.                 $this->users[$packet['u']]['s'] = @$packet['s'];
  251.                 $this->users[$packet['u']]['f'] = (isset($packet['f']))  ? (int)$packet['f']  : 0;
  252.                 $this->users[$packet['u']]['id'] = $packet['u'];
  253.                 $this->users[$packet['u']]['d0'] = (isset($packet['d0'])) ? (int)$packet['d0'] : 0;
  254.                 $this->users[$packet['u']]['d2'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  255.                 $this->users[$packet['u']]['q'] = (isset($packet['q'])) ? (int)$packet['q'] : 0;
  256.                 $this->users[$packet['u']]['registered'] = ((key_exists('N',$packet))?$packet['N']:'Unregistered');
  257.                 //$this->users[$packet['u']]['name'] = (substr(@$packet['n'],0,1)=="$") ? substr(@$packet['n'],0,1) : $packet['n'];
  258.                 $this->users[$packet['u']]['name'] = @$packet['n'];
  259.                 $this->users[$packet['u']]['avatar'] = (isset($packet['a'])) ? @$packet['a'] : 'No Avatar';
  260.                 $this->users[$packet['u']]['home'] = (isset($packet['h'])) ? @$packet['h'] : 'No Homepage';
  261.                 $this->users[$packet['u']]['v'] = (@$packet['v']) ? @$packet['v'] : 0;
  262.                 $this->users[$packet['u']]['bride'] = (isset($packet['d2'])) ? @$packet['d2'] : 0;
  263.                 $this->users[$packet['u']]['rel'] = (@$packet['d0'] & 1) ? 1 : 2;//Relationship Type: 1=BFF 2=Married #note that if they not in a relationship it will show there Married this can be fixed by detecting if they have a bride [D2]
  264.                 $this->users[$packet['u']]['sub'] = (isset($packet['p0'])) ? 1 : 0;
  265.                 if($this->autoWelcome!=''&&!isset($packet['s']))$this->sendPM($packet['u'], $this->autoWelcome);
  266.                
  267.                 if($packet['rank'] == 5)
  268.                 {
  269.                 if($this->automember){
  270.                 $this->member($packet['u']);
  271.                 }
  272.                 }
  273.                 if($packet['rank'] == 3)
  274.                 {
  275.                 if($this->autoguest){
  276.                 $this->guest($packet['u']);
  277.                 }
  278.                 }
  279.                 break;
  280.            
  281.             case'i':
  282.                     $info = explode(';=', $this->packet['i']['b']);
  283.                     $this->radioinfo = str_replace("http://", "", $info[4]);
  284.                     $ci = explode(';=', $packet['b']);
  285.                     $this->chatInfo = array('background'=>$ci[0], 'tabbedChat'=>$ci[1],'tabbedChatID'=>$ci[2],'language'=>$ci[3],'radio'=>str_replace('http://','',$ci
  286.  
  287. [4]),'buttons'=>$ci[5]);
  288.                     print_r($this->chatInfo);
  289.                     break;
  290.             case "z":
  291.                 $this->enviarMSG( "Don't click me :( !", "PM", $packet[ "u" ] );
  292.                 break;
  293.            
  294.              
  295.             case "m": // Use For Add Questions and Answers
  296.                 if(isset($this->packet['m']['s'])) return; 
  297.                
  298.              
  299.             if(($this->packet['m']['t']) =='Assalam o Alaikum') {
  300.                
  301.                $user    = $this->users[ $packet[ "u" ] ];
  302.                $user2 = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  303.                         $this->enviarMSG ('Walikum Assalam  ['.$user2.'] ');
  304.             }
  305.             if(($this->packet['m']['t']) =='bot mar ja') {
  306.                
  307.                $user    = $this->users[ $packet[ "u" ] ];
  308.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  309.                         $this->enviarMSG ('Tujha mar kar maro ga (bite#c#angry) ');
  310.             }
  311.             if(($this->packet['m']['t']) =='assalam o alaikum') {
  312.                
  313.                $user    = $this->users[ $packet[ "u" ] ];
  314.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  315.                         $this->enviarMSG ('Walikum Assalam '.$user.' ');
  316.             }
  317.            
  318.             if(($this->packet['m']['t']) =='salam') {
  319.                
  320.                $user    = $this->users[ $packet[ "u" ] ];
  321.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  322.                         $this->enviarMSG ('Walikum Assalam '.$user.'');
  323.             }
  324.             if(($this->packet['m']['t']) =='andre') {
  325.                
  326.                $user    = $this->users[ $packet[ "u" ] ];
  327.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  328.                         $this->enviarMSG ('yeah i know andre is realy nice person (redface)  ');
  329.             }
  330.             if(($this->packet['m']['t']) =='lazy bot') {
  331.                
  332.                $user    = $this->users[ $packet[ "u" ] ];
  333.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  334.                         $this->enviarMSG ('i am not lazy ok (backoff) ');
  335.             }
  336.             if(($this->packet['m']['t']) =='brb') {
  337.                
  338.                $user    = $this->users[ $packet[ "u" ] ];
  339.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  340.                         $this->enviarMSG ('Go to Fast and come back fast(rapid)');
  341.             }
  342.             if(($this->packet['m']['t']) =='hi') {
  343.                
  344.                $user    = $this->users[ $packet[ "u" ] ];
  345.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  346.                         $this->enviarMSG ('Hi ['.$user.'] (hug)');
  347.             }
  348.             if(($this->packet['m']['t']) =='hi bot') {
  349.                
  350.                $user    = $this->users[ $packet[ "u" ] ];
  351.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  352.                         $this->enviarMSG ('Bye '.$user.' (bye)');
  353.             }
  354.             if(($this->packet['m']['t']) =='xd') {
  355.                
  356.                $user    = $this->users[ $packet[ "u" ] ];
  357.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  358.                         $this->enviarMSG ('(xp#hehe) ['.$user.'] ');
  359.             }
  360.             if(($this->packet['m']['t']) =='how are you?') {
  361.                
  362.                $user    = $this->users[ $packet[ "u" ] ];
  363.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  364.                         $this->enviarMSG ('well thank you very much! (jolly) ['.$user.'] ');
  365.             }
  366.             if(($this->packet['m']['t']) =='bot') {
  367.                
  368.                $user    = $this->users[ $packet[ "u" ] ];
  369.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  370.                         $this->enviarMSG ('Bot is your mother i am boss (un) ');
  371.             }
  372.            
  373.            
  374.            
  375.             case "p":
  376.                        
  377.                       if($this->censor($packet['t'])) {
  378.                       //$this->send('<c p="This word is not allowed here . (D)" u="'.$packet['u'].'" t="/k" />');
  379.                       $this->kick('This word is not allowed here.(d)',$packet['u']);
  380.                       }
  381.                 If ( isset( $packet[ "i" ] ) && $packet[ "i" ] > 0 )
  382.                     break;
  383.    
  384.                 $msg = $mensagem = explode( " ", $packet[ "t" ] );
  385.                 unset( $msg[ 0 ] );
  386.                 $msg = implode( " ", $msg );
  387.                 If ( isset( $mensagem[ 0 ] ) && $mensagem[ 0 ][ 0 ] != "!" )
  388.                     break;
  389.                 $user    = $this->users[ $packet[ "u" ] ];
  390.                 $user = ( $user[ "N" ] ) ? $user[ "N" ] : $user[ "u" ];
  391.                 switch ( substr( $mensagem[ 0 ], 1 ) ) {
  392.                     /* Weoxo Bot Commands for all */
  393.                     case "say":
  394.                         // !say [msg]
  395.                                         $user    = $this->users[ $packet[ "u" ] ];
  396.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  397.                         $this->enviarMSG ('['.$user.'] '.$msg);
  398.                         break;
  399.                    
  400.                    
  401.                      case "test":
  402.                         // !test [msg]
  403.                                         $user    = $this->users[ $packet[ "u" ] ];
  404.                 $user = ( $user[ "registered" ] ) ? $user[ "registered" ] : $user[ "u" ];
  405.                         $this->enviarMSG (' ('.$msg.')');
  406.                         break;
  407.                    
  408.                    
  409.                    
  410.                    
  411.                     case "info":
  412.                         // !info
  413.                         $this->enviarMSG( "Weoxo Bot System for weoxo.com (created by Devil)!", "PM", $packet[ "u" ] );
  414.                         break;
  415.                        
  416.                            case'smiles':
  417.                                      mysql_connect('localhost','root','kinghacker');
  418.                                          mysql_select_db('weoxo') or $this->sendMesage('Can\'t connect.');
  419.                                          $message = explode(' ', $mensagem[1], 1);
  420.                                          $power = $message[0];
  421.                                          $db = mysql_query("SELECT * FROM `powers` WHERE name='$power'");
  422.                                          $row = mysql_fetch_array($db);
  423.                                          if(!$row['name']) {$this->enviarMSG('Power not found! (d)');}
  424.                                          else {
  425.                                          $powers = str_replace(',','#)(',$row['topsh']);
  426.                                          if(empty($row['topsh'])) {$this->enviarMSG(ucfirst($power).' has only ('.$power.') as smilies.');}
  427.                                          else {
  428.                                          $this->enviarMSG('('.$power.'#) Smilies : ('.$powers.'#)');}}
  429.                                          break;          
  430.                  case'dunceme':
  431.                       $message = explode(' ', $mensagem[1], 1);
  432.                       $users = $message[0];
  433.                       if(empty($users)) $users = $packet['u'];
  434.                       $this->enviar('<c p="You have been dunced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are undunced." u="'. $packet['u'] .'" t="/gd3600" />');
  435.                      
  436.                       break;
  437.                 case'snakeme':
  438.                       $message = explode(' ', $mensagem[1], 1);
  439.                       $users = $message[0];
  440.                       if(empty($users)) $users = $packet['u'];
  441.                       $this->enviar('<c w="134" p="You have been snaked by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unsnaked." u="'. $packet['u'] .'" t="/g3600" />');
  442.                      
  443.                       break;
  444.                 case'spaceme':
  445.                       $message = explode(' ', $mensagem[1], 1);
  446.                       $users = $message[0];
  447.                       if(empty($users)) $users = $packet['u'];
  448.                       $this->enviar('<c w="136" p="You have been spaced by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unspaced." u="'. $packet['u'] .'" t="/g3600" />');
  449.                      
  450.                       break;
  451.                 case'matchme':
  452.                       $message = explode(' ', $mensagem[1], 1);
  453.                       $users = $message[0];
  454.                       if(empty($users)) $users = $packet['u'];
  455.                       $this->enviar('<c w="140" p="You have been match by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unmatch." u="'. $packet['u'] .'" t="/g3600" />');
  456.                      
  457.                       break;
  458.                 case'mazeme':
  459.                       $message = explode(' ', $mensagem[1], 1);
  460.                       $users = $message[0];
  461.                       if(empty($users)) $users = $packet['u'];
  462.                       $this->enviar('<c w="152" p="You have been mazed by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unmazed." u="'. $packet['u'] .'" t="/g3600" />');
  463.                      
  464.                       break;
  465.                 case'codeme':
  466.                       $message = explode(' ', $mensagem[1], 1);
  467.                       $users = $message[0];
  468.                       if(empty($users)) $users = $packet['u'];
  469.                       $this->enviar('<c w="162" p="You have been coded by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are uncoded." u="'. $packet['u'] .'" t="/g3600" />');
  470.                      
  471.                       break;
  472.                 case'reverseme':
  473.                       $message = explode(' ', $mensagem[1], 1);
  474.                       $users = $message[0];
  475.                       if(empty($users)) $users = $packet['u'];
  476.                       $this->enviar('<c w="176" p="You have been reverse by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unreversed." u="'. $packet['u'] .'" t="/g3600" />');
  477.                      
  478.                       break;
  479.                 case'zipme':
  480.                       $message = explode(' ', $mensagem[1], 1);
  481.                       $users = $message[0];
  482.                       if(empty($users)) $users = $packet['u'];
  483.                       $this->enviar('<c w="184" p="You have been zip by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unzip." u="'. $packet['u'] .'" t="/g3600" />');
  484.                      
  485.                       break;
  486.                 case'soltme':
  487.                       $message = explode(' ', $mensagem[1], 1);
  488.                       $users = $message[0];
  489.                       if(empty($users)) $users = $packet['u'];
  490.                       $this->enviar('<c w="236" p="You have been solt by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unsolt." u="'. $packet['u'] .'" t="/g3600" />');
  491.                      
  492.                       break;
  493.                
  494.                 case'zapme':
  495.                       $message = explode(' ', $mensagem[1], 1);
  496.                       $users = $message[0];
  497.                       if(empty($users)) $users = $packet['u'];
  498.                       $this->enviar('<c w="121" p="You have been zapped by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unzapped. #screamman#bump" u="'. $packet['u'] .'" t="/k" />');
  499.                      
  500.                       break;
  501.                 case'gagme':
  502.                       $message = explode(' ', $mensagem[1], 1);
  503.                       $users = $message[0];
  504.                       if(empty($users)) $users = $packet['u'];
  505.                       $this->enviar('<c w="41" p="You have been gagged by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are ungagged." u="'. $packet['u'] .'" t="/gg3600" />');
  506.                      
  507.                       break;  
  508.                  case'naughtyme':
  509.                       $message = explode(' ', $mensagem[1], 1);
  510.                       $users = $message[0];
  511.                       if(empty($users)) $users = $packet['u'];
  512.                       $this->enviar('<c p="You have been naughty by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unnaughty." u="'. $packet['u'] .'" t="/gn3600" />');
  513.                      
  514.                       break;
  515.                 case'yellowme':
  516.                       $message = explode(' ', $mensagem[1], 1);
  517.                       $users = $message[0];
  518.                       if(empty($users)) $users = $packet['u'];
  519.                       $this->enviar('<c p="You have been yellow by ['.$this->users[$packet['u']]['registered'].'] or please refresh if you are unyellow." u="'. $packet['u'] .'" t="/gy3600" />');
  520.                      
  521.                       break;
  522.                
  523.  
  524.  
  525.  
  526.                
  527.                                 case 'id':
  528.             $id = file_get_contents('http://weoxo.com/web_gear/chat/auser3.php');
  529.             if(!$id) { return $this->enviarMSG('unable to connect!',($type==0)?1:$type,$packet['u']); }
  530.             //$id = str_replace($id, '=', ' = ');
  531.             $t = explode('&',$id);
  532.             $id = array('id'=>$t[1], 'k1'=>$t[2], 'k2'=>$t[3]);
  533.  
  534.             $link = 'http://xat.com/web_gear/chat/register.php?'.$id['id'].'&'.$id['k1'].'&'.$id['k2'].'&mode=1';
  535.             $this->enviarMSG(implode(', ',$id),($type==0)?1:$type,$packet['u']);
  536.             $this->enviarMSG($link,($type==0)?1:$type,$packet['u']);
  537.        
  538.                         break;
  539.                       case 'radio':
  540.                    $connection = explode(':', $this->radioinfo);
  541.                    $url = fsockopen($connection[0],$connection[1]);
  542.                    if($this->radioinfo == 'semnome' or !$this->radioinfo){$this->enviarMSG("This group chat does not have a radio.");                    
  543.                    return false;}
  544.                    if(!$url){
  545.                    $this->enviarMSG("Connection failed."); return false;
  546.                    } else {
  547.                    fputs($url,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
  548.                    $socket = fread($url, 1000);
  549.                    $return = explode(",", $socket);
  550.                    $final = str_replace("</body></html>", "", $return[6]);
  551.                    if(!$final){
  552.                    $this->enviarMSG("The current song on the radio is: nameless."); return false;
  553.                    } else
  554.                    $this->enviarMSG("The current song on the radio is: {$final}");
  555.                    }
  556.                    break;
  557.                     case 'youtube':
  558.                     case '11':
  559.                         $query = str_replace(' ', '%20', $msg);
  560.                         $x     = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=3&q=' . str_replace(' ', '%20', urlencode($query)));
  561.                         $js    = json_decode(json_encode(new SimpleXMLElement($x)));
  562.                         if (!isset($js->entry[0]->title))
  563.                             return $this->enviarMSG('No results from Youtube.', $type, $msg['u']);
  564.                         $videos = array();
  565.                         $i      = 0;
  566.                         while ($i != 3) {
  567.                             $URL  = get_object_vars($js->entry[$i]->link[0]);
  568.                             $link = explode('&', $URL['@attributes']->href);
  569.                             if (!empty($link[0]))
  570.                                 $this->enviarMSG($js->entry[$i]->title . ' - ' . $link[0], $type, $msg['u']);
  571.                             $i++;
  572.                             sleep(3);
  573.                         }
  574.                         break;
  575.                  case'typing':
  576.                  switch(strtolower($mensagem[1])){
  577.                  case 'on':
  578.                  $this->enviar('/RTypeOn');
  579.                  break;
  580.                  
  581.                  case 'off':
  582.                  $this->enviar('/RTypeOff');
  583.                  break;
  584.                  }
  585.                       break;
  586.                   case'price1':
  587.                      $message = explode(' ', $mensagem[1], 1);
  588.                      $powers = $message[0];
  589.                      mysql_connect('localhost','root','kinghacker');
  590.                      mysql_select_db('weoxo');
  591.                      if(is_numeric($powers)){
  592.                      $db = mysql_query("SELECT * FROM `powers` WHERE id ='$powers'");}
  593.                      else {$db = mysql_query("SELECT * FROM `powers` WHERE name ='$powers'");}
  594.                      $row = mysql_fetch_array($db);
  595.                      if($row['name'] == true) {
  596.                      if(empty($row['xats'])) {$row['xats'] = '0 - 0';}
  597.                      if(empty($row['days'])) {$row['days'] = '0 - 0';}
  598.                      $this->enviarMSG(htmlentities(ucfirst($row['name'])).' Cost '.$row['xats'].' Coins or '.$row['days'].' days.');
  599.                      } else { $this->enviarMSG('Power not found.');}
  600.                      break;
  601.                      
  602.                  case'rinfo':
  603.                      $this->enviarMSG('ID : '.$this->chat.' | Buttons : _'.$this->chatInfo['buttons'].'  | Radio : '.$this->chatInfo['radio'].' | Background : '.$this->chatInfo['background']);
  604.                      break;
  605.                         case "cmd":
  606.                         // !info
  607.                         $this->enviarMSG( "!online , !say , !price , !love , !choose , !perg , !info ,
  608.                                             mazeme,snakeme,!att", "PM", $packet[ "u" ] );
  609.                         break;
  610.                        
  611.                         case 'online':
  612.                         $this->enviarMSG( $users . '' . 'There ' . count( $this->users ) . ' Users Online.' );
  613.                         break;
  614.                    
  615.                     case "choose":
  616.                         // !choose [coisa] [coisa2]
  617.                         $mensagem = explode( ' ou ', strtolower( $msg ) );
  618.                         if ( !isset( $mensagem[ 0 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  619.                             return $this->enviarMSG( 'It takes two choice (D)', "PM", $packet[ 'u' ] );
  620.                         $mensagem = array_values( $mensagem );
  621.                         $rand     = $mensagem[ array_rand( $mensagem ) ];
  622.                         $this->enviarMSG( 'I prefer ' . $rand, "PM", $packet[ 'u' ] );
  623.                         break;
  624.                    
  625.                     case "perg":
  626.                     case "8ball":
  627.                         // !perg/!8ball [pergunta]
  628.                         $respostas = array(
  629.                              'Maybe',
  630.                             'Sim.',
  631.                             'Do Not.',
  632.                             'My sources said no.',
  633.                             'Ah, SIM and SIM',
  634.                             'In fact I do not know',
  635.                             'Outlook does not provide \'-\'',
  636.                             'I think not',
  637.                             'Very good',
  638.                             'It was determined that yes.'
  639.                         );
  640.                         $resposta  = $respostas[ array_rand( $respostas ) ];
  641.                         $mensagens = array( );
  642.                         foreach ( $mensagens as $k => $valor ) {
  643.                             $valor2 = strtoupper( $valor );
  644.                             array_push( $mensagens, $valor2 );
  645.                         } //$mensagens as $k => $valor
  646.                         $this->enviarMSG( ' [' . $user . ']' . $resposta, "PM", $packet[ 'u' ] );
  647.                         break;
  648.                    
  649.                     case 'lovetest':
  650.                         // !lovetest [alguma coisa] [alguma coisa2]
  651.                         $gerar = rand( 0, 100 );
  652.                         $this->enviarMSG( $mensagem[ 1 ] . ' + ' . $mensagem[ 2 ] . ' = ' . $gerar . '%' );
  653.                         break;
  654.                    
  655.                        
  656.                     /* Commands for admins */
  657.                   case "restart":
  658.                         // !restart
  659.                         If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  660.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  661.                         } //!in_Array( $packet[ "u" ], $this->admins )
  662.                         $this->enviarMSG( "[Server]: I'm being restarted (backoff)" );
  663.                         $this->reiniciar();
  664.                                                 $this->entrar();
  665.                         break;
  666.                    
  667.                    
  668.                     case'userinfo':
  669.                   $message = explode(' ', $mensagem[1], 1);
  670.                   $user = $message[0];
  671.  
  672.                   if(!$this->users[$user]['id']){ $this->enviarMSG('I Do not NOOB.');}
  673.                   else{
  674.                   if($this->users[$user]['rel'] == 2) $this->users[$user]['rel'] = "Married";
  675.                   if($this->users[$user]['rel'] == 1) $this->users[$user]['rel'] = "BFF";
  676.                   $myNick = explode("##", $this->users[$user]['name'], 2);
  677.                   $myNick[0] = htmlspecialchars(html_entity_decode(htmlspecialchars_decode($myNick[0])));
  678.                   $relation = $this->users[$user]['rel'].' to '.$this->users[$user]['d2'];
  679.                   if($relation == 'Married to 0') $relation = 'Relation not found.';
  680.                   $name = explode('##', $this->users[$user]['name']);
  681.                   $n = $name[1];
  682.                   $this->enviarMSG('Name : '.$myNick[0].' | Status : '.str_replace('#',' | ',$n).'| Avatar : '.$this->users[$user]['avatar'].' | Home : '.$this->users[$user]['home'].' | Relation : '.$relation);
  683.                   }
  684.                   break;
  685.                  
  686.                     case "desligar":
  687.                     case "die":
  688.                         // !die
  689.                         If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  690.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  691.                         } //!in_Array( $packet[ "u" ], $this->admins )
  692.                         $this->enviarMSG( "[Server]: I'm shutting down (bye)" );
  693.                         die( );
  694.                         break;
  695.                          case "time":
  696.                                                 $s = time() - $this->time;
  697.                                                 $m = floor($s / 60);
  698.                                                 $h = floor($m / 60);
  699.                                                 $msg = "Run time (approx): Seconds - $s | Minutes - $m | Hours - $h";
  700.                                                 $this->sendmsg($msg);
  701.                                         break;
  702.                         case 'automember':
  703.                         // !automember [on/off]
  704.                         if ( !in_array( $packet[ 'u' ], $this->admins ) )
  705.                         {
  706.                             return $this->enviarMSG( 'You do not have to use this command!', 'PM', $packet[ 'u' ] );
  707.                         } //!in_array( $packet[ 'u' ], $this->admins )
  708.                         switch ( $mensagem[ 1 ] )
  709.                         {
  710.                             case 'on':
  711.                                 $this->automember = True;
  712.                                 $this->enviarMSG( 'The automember system was activated!' );
  713.                                 break;
  714.                            
  715.                             case 'off':
  716.                                 $this->automember = False;
  717.                                 $this->enviarMSG( 'The automember system has been disabled!' );
  718.                                 break;
  719.                            
  720.                             default:
  721.                                 $this->enviarMSG( 'You should choose an option [on / off].' );
  722.                         } //$mensagem[ 1 ]
  723.                         break;
  724.                          case 'autoguest':
  725.                         // !automember [on/off]
  726.                         if ( !in_array( $packet[ 'u' ], $this->admins ) )
  727.                         {
  728.                             return $this->enviarMSG( 'You do not have to use this command!', 'PM', $packet[ 'u' ] );
  729.                         } //!in_array( $packet[ 'u' ], $this->admins )
  730.                         switch ( $mensagem[ 1 ] )
  731.                         {
  732.                             case 'on':
  733.                                 $this->autoguest = True;
  734.                                 $this->enviarMSG( 'The autoguest system was activated!' );
  735.                                 break;
  736.                            
  737.                             case 'off':
  738.                                 $this->autoguest = False;
  739.                                 $this->enviarMSG( 'The autoguest system has been disabled!' );
  740.                                 break;
  741.                            
  742.                             default:
  743.                                 $this->enviarMSG( 'You should choose an option [on / off].' );
  744.                         } //$mensagem[ 1 ]
  745.                         break;
  746.                        
  747.                         case 'edit':
  748.                         // !edit name , status , glow , hat ,avatar
  749.                         if ( !in_array( $packet[ 'u' ], $this->admins ) )
  750.                         {
  751.                             return $this->enviarMSG( 'You do not have to use this command!', 'PM', $packet[ 'u' ] );
  752.                         } //!in_array( $packet[ 'u' ], $this->admins )
  753.                         switch ( $mensagem[ 1 ] )
  754.                         {
  755.                            case'name':
  756.                              If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  757.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  758.                         } //!in_Array( $packet[ "u" ], $this->admins )
  759.            $this->name = $mensagem[ 2 ];
  760.            $this->entrar();
  761.            $this->enviarMSG('My name has been changed to : '.$this->name);
  762.            
  763.           break;
  764.                      
  765.         case'status':
  766.           If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  767.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  768.                         } //!in_Array( $packet[ "u" ], $this->admins )
  769.            $this->status =  htmlentities($mensagem[2]);
  770.            $this->entrar();
  771.            $this->enviarMSG('My status has been changed : '.$this->status );
  772.           break;
  773.        
  774.        case'glow':
  775.          If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  776.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  777.                         } //!in_Array( $packet[ "u" ], $this->admins )
  778.            $mensagem = explode( ' ou ', strtolower( $msg ) );
  779.            if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  780.            $this->glow = $mensagem[0];
  781.            $this->entrar();
  782.            $this->enviarMSG('My GlowColor has been changed to [ #'.$this->glow.' ]');
  783.           break;   
  784.  
  785.        case'hat':
  786.          If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  787.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  788.                         } //!in_Array( $packet[ "u" ], $this->admins )
  789.            $mensagem = explode( ' ou ', strtolower( $msg ) );
  790.            if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  791.            $this->hat = $mensagem[0];
  792.            $this->entrar();
  793.            $this->enviarMSG('My hat was changed to Success : ' );
  794.           break;           
  795.  
  796.        case'home':
  797.          If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  798.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  799.                         } //!in_Array( $packet[ "u" ], $this->admins )
  800.            $mensagem = explode( ' ou ', strtolower( $msg ) );
  801.            if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  802.            $this->home = $mensagem[0];
  803.            $this->entrar();
  804.            $this->enviarMSG('My little house has been changed : ' );
  805.           break;                 
  806.          
  807.           case'welcome':
  808.             If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  809.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  810.                         } //!in_Array( $packet[ "u" ], $this->admins )
  811.            $mensagem = explode( ' ou ', strtolower( $msg ) );
  812.            if ( !isset( $mensagem[ 1 ] ) || empty( $mensagem[ 1 ] ) || count( array_keys( $mensagem ) ) == 1 )
  813.            $this->autoWelcome = $mensagem[0];
  814.            $this->entrar();
  815.           $this->enviarMSG('My Welcome message has changed for : '.$this->autoWelcome );
  816.           break;   
  817.          
  818.                            
  819.                             default:
  820.                                 $this->enviarMSG( 'You should choose an option : !edit [name , status , glow , hat ,avatar].' );
  821.                         } //$mensagem[ 1 ]
  822.                         break;
  823.                        
  824.                          /* Command Admin for Bot Created Juninho & Sloom! */
  825.     case "staff":
  826.                         // !staff
  827.                         $this->enviarMSG( " 1 , 4 , 7 , 2M , 1802 , 69 ", "PM", $packet[ "u" ] );
  828.                         break;       
  829.                        
  830.                         case'avatar':
  831.                           If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  832.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  833.                         } //!in_Array( $packet[ "u" ], $this->admins )
  834.          $this->avatar = $mensagem[1];
  835.                       $this->avatar = str_replace(' (', '(', $this->avatar);
  836.                      $this->avatar = str_replace(') ', ')', $this->avatar);
  837.                      $this->avatar = str_replace(' ', ' ', $this->avatar);
  838.                     $this->entrar();
  839.         $this->entrar();
  840.         $this->enviarMSG('My avatar has been changed : '.$this->avatar );
  841.          break;
  842.                  case'last':
  843.                    $pow2 = file_get_contents('http://xat.com/web_gear/chat/pow2.php?Milk=1234');
  844.                    $pow2 = json_decode($pow2, true);
  845.                    $powername = array_search($pow2['0']['1']['id'], $pow2['5']['1']);
  846.                    $status = ($pow2[0][1]['text'] == '[LIMITED]') ? 'LIMITED':'UNLIMITED';
  847.                    $smilie = array_merge(array($powername), array_keys($pow2['3']['1'], $pow2['0']['1']['id'])); //get all smilies of the new power            
  848.                    $smilies = array();
  849.                    $pawns = array();
  850.                    foreach($smilie as $v)
  851.                    array_push($smilies, $v);
  852.                    foreach($pow2[6][1] as $name => $value)
  853.                    if($name != 'time' && $value[0] == $pow2['0']['1']['id'])
  854.                    array_push($pawns, 'h'.$name);
  855.                    $smilielist = implode(", ", $smilies);  
  856.                    $pawnlist = implode(", ", $pawns);  
  857.                    $this->enviarMSG(ucfirst($powername).' | ID : '.$pow2['0']['1']['id'].' | Status : '.$status.' | Smilies: '.ucfirst($smilielist).' | Hats : '.$pawnlist);
  858.                    break;
  859.     case 'calc':
  860.     /* Command created by iZerang */
  861.     // !calc [numero] [/ * * -] [numero 2]
  862.     if ( is_numeric( $mensagem[1] ) && is_numeric( $mensagem[3] ) ) {
  863.     switch ( $mensagem[2] ) {
  864.    
  865.     case "*":
  866.     $x = $mensagem[1] * $mensagem[3];
  867.     $this->enviarMSG("{$mensagem[1]} x {$mensagem[3]} = {$x}");
  868.     break;
  869.    
  870.     case "/":
  871.     $x = $mensagem[1] / $mensagem[3];
  872.     $this->enviarMSG("{$mensagem[1]} + {$mensagem[3]} = {$x}");
  873.     break;
  874.    
  875.     case "+":
  876.     $x = $mensagem[1] + $mensagem[3];
  877.     $this->enviarMSG("{$mensagem[1]} + {$mensagem[3]} = {$x}");
  878.     break;
  879.    
  880.     case "-":
  881.     $x = $mensagem[1] - $mensagem[3];
  882.     $this->enviarMSG("{$mensagem[1]} - {$mensagem[3]} = {$x}");
  883.     break;
  884.     }
  885.     //$mensagem[2]
  886.     } //is_numeric( $mensagem[1] ) && is_numeric( $mensagem[3] )
  887.     else {
  888.     $this->enviarMSG( 'You must enter a valid account' , "PM", $packet[ "u" ] );
  889.     }
  890.     break;
  891.    
  892.     case 'price':
  893.     /* Command created by iZerang */
  894.     $x1 = strtr(substr($mensagem[1], 0, 1), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  895.     $x2 = strtr(substr($mensagem[1], 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz");
  896.     $msg = $x1.$x2;
  897.     if(empty($msg)){$this->enviarMSG('The power of the name can not be empty.'); return;}
  898.     $url = @file_get_contents('http://xatalert.com/fairtrade/');
  899.     file_put_contents($core->lib . "prices.txt", $pricelist);
  900.     if(empty($msg)){$this->enviarMSG('Failed to get price notify an administrator!'); return;}
  901.     $parte1 = explode($msg.'</abbr></td><td></td><td>(', $url);
  902.     $final = explode(')</td><td>',$parte1[1]);
  903.     if(!$final[0]){
  904.     $parte1 = explode($msg.'</abbr></td><td><img src="http://xat.com/images/apicon.png" border="0"></td><td>(', $url);
  905.     $final = explode(')</td><td>',$parte1[1]);
  906.     }
  907.     $parte2 = explode($msg.'</abbr></td><td></td><td>('.$final[0].')</td><td>', $url);
  908.     $final2 = explode('</td><td>',$parte2[1]);
  909.     if(!$final2[0]){
  910.     $parte2 = explode($msg.'</abbr></td><td><img src="http://xat.com/images/apicon.png" border="0"></td><td>('.$final[0].')</td><td>', $url);
  911.     $final2 = explode('</td><td>',$parte2[1]);
  912.     }
  913.     $parte3 = explode($msg.'</abbr></td><td><img src="http://xat.com/images/apicon.png" border="0"></td><td>('.$final[0].')</td><td>'.$final2[0].'</td><td>', $url);
  914.     $final3 = explode('</td><td>',$parte3[1]);
  915.     if(!$final3[0]){
  916.     $parte3 = explode($msg.'</abbr></td><td></td><td>('.$final[0].')</td><td>'.$final2[0].'</td><td>', $url);
  917.     $final3 = explode('</td><td>',$parte3[1]);
  918.     }
  919.     if(!$final[0]){$this->enviarMSG('Power nonexistent, or not added yet.');}else
  920.     $this->enviarMSG('The power in the '.$msg.' store costs: '.$final[0].', trade: '.$final2[0].', in days: '.$final3[0].'.');
  921.     break;       
  922.                
  923.     case 'dx':
  924.                 $days = intval($message[1]);
  925.                 if($days < 1)
  926.                     return $this->sendPM($packet['u'], 'days must be 1 or more');
  927.                
  928.                 $tradeValue = 13;
  929.                 $xats = floor($days * $tradeValue);
  930.                 $this->enviarMSG($days.' days equals '.$xats.' xats');         
  931.             break;
  932.                
  933.                 case 'xclear11111111111111':
  934.               If ( !in_Array( $packet[ "u" ], $this->admins ) ) {
  935.                             return $this->enviarMSG( $this->semacesso, "PM", $packet[ "u" ] );
  936.                         } //!in_Array( $packet[ "u" ], $this->admins )
  937.                     return $this->enviarMSG('Sorry, but you are not allowed to do so!');;
  938.                 $this->clear = $mensagem[1];
  939.                     case 'msg11111111111111':
  940.                     case 'chat11111111111':
  941.                     case 'messages1111111111111':
  942.                     case 'message1111111111111111':
  943.                         $this->clearMsg(true,25);
  944.                         $this->socket->connect();
  945.                         $this->network->join();
  946.                     break;
  947.    
  948.    
  949.                        
  950.                 } //substr( $mensagem[ 0 ], 1 )
  951.         } //$tipo
  952.     }
  953.    
  954.     /* Reiniciar o servidor */
  955.     public function reiniciar( )
  956.     {
  957.         $this->conectar();
  958.         $this->entrar();
  959.     }
  960.     public function fetchUser($id) {
  961.        $id = $this->parseU($id);
  962.        if(isset($this->users[$id]))
  963.        return $this->users[$id];
  964.        else
  965.        return false;
  966.     }
  967.      function kick($message, $id, $log=true) {
  968.         if($log) {
  969.             if(!empty($this->users[$id]['kicks']) ) $this->users[$id]['kicks']++;
  970.             else $this->users[$id]['kicks'] = 1;
  971.         }
  972.         if($this->users[$id]['kicks'] > $this->maxKicks) {
  973.         $this->ban($message,$id,3600);
  974.         $this->users[$id]['kicks'] = 0;
  975.         return;
  976.         }
  977.        $this->enviar('<c p="'.$message." ".$this->users[$id]['kicks'].'/'.$this->maxKicks.'" u="'.$id.'" t="/k" />');  
  978.     }
  979.     function ban($message, $id, $time) {
  980.         $this->enviar('<c p="'.ereg_replace('[^A-Za-z0-9.! ]','',$message).'" u="'.$id.'" t="/g'.$time.'" />');
  981.     }
  982.     public function sendPM($id=0, $packet='') {
  983.         $id = $this->parseU($id);
  984.         $this->enviar('<p u="'.$id.'" t="'.$packet.'" d="'.$id.'" />');
  985.     }
  986.    
  987.     public function parseU($id) {
  988.         if(strpos($id, "_") > -1)
  989.             $e = explode("_", $id);
  990.         $u = (strpos($id, "_") > -1) ? $e[0] : $id;
  991.         return $u;
  992.     }
  993.    
  994.     function member($id,$time=null) {
  995.         if(!$time) $time = 0;
  996.         $id = $this->parseU($id);
  997.         $this->sendC($id, '/e',$time);
  998.     }
  999.     function guest($id,$time=null) {
  1000.         if(!$time) $time = 0;
  1001.         $id = $this->parseU($id);
  1002.         $this->sendC($id, '/r',$time);
  1003.     }
  1004.    
  1005.     public function sendC($id=0, $com='') {//Shit always comes in handy after awhile.
  1006.         $this->enviar('<c u="'.$id.'" t="'.$com.'" />');      
  1007.     }
  1008.     public function censor($message) {
  1009.             $badwords = $this->censor;
  1010.             $message = @preg_replace('#\((.+)\)#U','',strtolower(' '.$message.' '));
  1011.             foreach($badwords as $bad) {
  1012.                 $bad = trim($bad);
  1013.                 if(strpos($message.' ', $bad.' ')!==false) {
  1014.                     if(strlen($bad)>=2) {
  1015.                         return true;
  1016.                     }
  1017.                 }
  1018.                
  1019.             }
  1020.        
  1021.     }
  1022.    
  1023.    
  1024.    
  1025.    
  1026.    
  1027.    
  1028.    
  1029.    
  1030.    
  1031.     /* Enviar MSG, definido com tipo e ID */
  1032.     function enviarMSG( $mensagem, $tipo = "MSG", $id = 0 )
  1033.     {
  1034.         If ( !$mensagem ) {
  1035.             return False;
  1036.         } //!$mensagem
  1037.         switch ( $tipo ) {
  1038.             case "MSG": // Sample
  1039.                 $this->enviar( "<m t=\"{$mensagem}\" u=\"{$this->botID}\" />" );
  1040.                 break;
  1041.            
  1042.             case "PM": // PM
  1043.                 $this->enviar( "<p u=\"{$id}\" t=\"{$mensagem}\" d=\"{$id}\" />" );
  1044.                 break;
  1045.            
  1046.             case "PC": // Privado
  1047.                 $this->enviar( "<z d=\"{$id}\" u=\"{$this->botID}\" t=\"{$mensagem}\" />" );
  1048.                 break;
  1049.         } //$tipo
  1050.     }
  1051.    
  1052. }
  1053.  
  1054. $bot = new zBot(); // Estanciar a class
  1055.  
  1056. while ( 1 ) {
  1057.     try {
  1058.         If ( $bot->load() == "OFF" ) {
  1059.             $bot->desconectar();
  1060.             $bot->entrar();
  1061.         } //$bot->load() == "OFF"
  1062.     }
  1063.     catch ( Exception $e ) {
  1064.         die( $e );
  1065.     }
  1066. } //1
  1067.  
  1068. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement