Advertisement
Guest User

C # . . . 0H H3||O

a guest
Jul 9th, 2014
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. set_time_limit(0);
  4. ignore_user_abort(1);
  5. ob_implicit_flush(1);
  6. //ob_implicit_flush(0);
  7. error_reporting(0);
  8.  
  9. //ob_start();
  10.  
  11. class MSG {
  12.  
  13.     private static $buffer_r;
  14.     private static $size_r;
  15.     private static $cursor_r;
  16.     private static $bits_r;
  17.    
  18.     private static $buffer_w;
  19.     private static $bits_w;
  20.    
  21.     static function ReadStart( $buffer ) {
  22.    
  23.         self::$buffer_r = $buffer;
  24.        
  25.         self::$size_r = strlen( $buffer );
  26.        
  27.         self::$cursor_r = 0;
  28.    
  29.         self::$bits_r = 0;
  30.  
  31.     }
  32.    
  33.     static private function ReadOneBit() {
  34.    
  35.         $byte = ord( self::$buffer_r[ self::$cursor_r ] );
  36.    
  37.         $bit = ( $byte >> self::$bits_r++ ) & 0x01;
  38.        
  39.         if ( self::$bits_r === 8 ) {
  40.        
  41.             self::$bits_r = 0;
  42.  
  43.             self::$cursor_r++;
  44.            
  45.         }
  46.        
  47.         return $bit;
  48.  
  49.     }
  50.     static private function ReadOneByte() {
  51.    
  52.         if ( self::$bits_r === 0 )
  53.    
  54.             return ord( self::$buffer_r[ self::$cursor_r++ ] );
  55.  
  56.         return
  57.             ( sefl::ReadOneBit()      ) |
  58.             ( sefl::ReadOneBit() << 1 ) |
  59.             ( sefl::ReadOneBit() << 2 ) |
  60.             ( sefl::ReadOneBit() << 3 ) |
  61.             ( sefl::ReadOneBit() << 4 ) |
  62.             ( sefl::ReadOneBit() << 5 ) |
  63.             ( sefl::ReadOneBit() << 6 ) |
  64.             ( sefl::ReadOneBit() << 7 ) ;
  65.  
  66.     }
  67.    
  68.     static function ReadBitsEnd() {
  69.    
  70.         if ( self::$bits_r > 0 ) {
  71.        
  72.             self::$bits_r = 0;
  73.  
  74.             self::$cursor_r++;
  75.            
  76.         }
  77.    
  78.     }
  79.     static function ReadBits( $n ) {
  80.    
  81.         $res = 0;
  82.    
  83.         for ( $i = 0; $i < $n; $i++ )
  84.        
  85.             $res |= ( self::ReadOneBit() << $i );
  86.    
  87.         return $res;
  88.    
  89.     }
  90.     static function ReadDWord() {
  91.    
  92.         return ( self::ReadOneByte() ) | ( self::ReadOneByte() << 8 ) | ( self::ReadOneByte() << 16 ) | ( self::ReadOneByte << 24 );
  93.    
  94.     }
  95.     static function ReadWord() {
  96.    
  97.         return ( self::ReadOneByte() ) | ( self::ReadOneByte() << 8 );
  98.    
  99.     }
  100.     static function ReadByte() {
  101.    
  102.         return ( self::ReadOneByte() );
  103.    
  104.     }
  105.     static function ReadPString() {
  106.    
  107.         $res = "";
  108.        
  109.         while( ( $ch = self::ReadOneByte() ) !== 0 )
  110.        
  111.             $res .= chr( $ch );
  112.            
  113.         return $res;
  114.    
  115.     }
  116.  
  117.     static function WriteStart() {
  118.    
  119.         self::$buffer_w = $buffer;
  120.    
  121.         self::$bits_w = 0; 
  122.    
  123.     }
  124.    
  125.     static private function WriteOneBit( $bit ) {
  126.    
  127.         $bit &= 0x01;
  128.    
  129.         if ( self::$bits_w === 0 ) {
  130.        
  131.             self::$buffer_w .= chr( $bit );
  132.            
  133.             self::$bits_w++;
  134.        
  135.             return;
  136.        
  137.         }
  138.  
  139.         $i = strlen( self::$buffer_w ) - 1;
  140.        
  141.         $byte = ord( self::$buffer_w[ $i ] );
  142.        
  143.         $byte |= ( ( $bit & 0x01 ) << ( self::$bits_w++ ) );
  144.  
  145.         self::$buffer_w[ $i ] = chr( $byte );
  146.        
  147.         if ( self::$bits_w === 8 )
  148.        
  149.             self::$bits_w = 0;
  150.        
  151.     }
  152.     static private function WriteOneByte( $byte ) {
  153.    
  154.         $byte &= 0xFF;
  155.    
  156.         if ( self::$bits_w === 0 ) {
  157.  
  158.             self::$buffer_w .= chr( $byte );
  159.        
  160.             return;
  161.        
  162.         }
  163.        
  164.         self::WriteOneBit( ( $byte      ) & 0x01 );
  165.         self::WriteOneBit( ( $byte >> 1 ) & 0x01 );
  166.         self::WriteOneBit( ( $byte >> 2 ) & 0x01 );
  167.         self::WriteOneBit( ( $byte >> 3 ) & 0x01 );
  168.         self::WriteOneBit( ( $byte >> 4 ) & 0x01 );
  169.         self::WriteOneBit( ( $byte >> 5 ) & 0x01 );
  170.         self::WriteOneBit( ( $byte >> 6 ) & 0x01 );
  171.         self::WriteOneBit( ( $byte >> 7 ) & 0x01 );
  172.    
  173.     }
  174.  
  175.     static function WriteBitsEnd() {
  176.    
  177.         self::$bits_w = 0;
  178.    
  179.     }
  180.     static function WriteBits( $num , $n ) {
  181.        
  182.         for ( $i = 0; $i < $n; $i++ )
  183.        
  184.             self::WriteOneBit( ( $num >> $i ) & 0x01 );
  185.    
  186.     }
  187.    
  188.     static function WriteDWord( $num ) {
  189.    
  190.         self::WriteOneByte( ( $num       ) & 0xFF );
  191.         self::WriteOneByte( ( $num >> 8  ) & 0xFF );
  192.         self::WriteOneByte( ( $num >> 16 ) & 0xFF );
  193.         self::WriteOneByte( ( $num >> 24 ) & 0xFF );
  194.    
  195.     }
  196.     static function WriteWord( $num ) {
  197.    
  198.         self::WriteOneByte( ( $num       ) & 0xFF );
  199.         self::WriteOneByte( ( $num >> 8  ) & 0xFF );
  200.    
  201.     }
  202.     static function WriteByte( $num ) {
  203.    
  204.         self::WriteOneByte( ( $num       ) & 0xFF );
  205.    
  206.     }
  207.     static function WritePString( $st ) {
  208.    
  209.         $l = strlen($st);
  210.        
  211.         for ( $i = 0; $i < $l; $i++ )
  212.        
  213.             self::WriteOneByte( ord( $st[$i] ) );
  214.    
  215.         self::WriteOneByte( 0 );
  216.        
  217.     }
  218.     static function WriteGet() {
  219.    
  220.         return self::$buffer_w;
  221.    
  222.     }
  223.    
  224.    
  225. }
  226.  
  227. class __MSG {
  228.  
  229.     static $bits_table = Array(
  230.         0x00 , 0x01 , 0x03 , 0x07 ,
  231.         0x0F , 0x1F , 0x3F , 0x7F
  232.     );
  233.    
  234.  
  235.    
  236.     static $buffer;
  237.     static $size;
  238.     static $cursor;
  239.     static $bits;
  240.  
  241.  
  242.  
  243.     static function ReadBegin( $buffer ) {
  244.    
  245.         self::$buffer = &$buffer;
  246.        
  247.         self::$size = strlen( self::$buffer );
  248.        
  249.         self::$cursor = 0;
  250.        
  251.         self::$bits = 0;
  252.            
  253.     }
  254.     static function ReadBitsEnd() {
  255.    
  256.         if ( self::$bits === 0 )
  257.            
  258.             return;
  259.        
  260.         self::$bits = 0;
  261.        
  262.         self::$cursor++;
  263.    
  264.     }
  265.  
  266.     static function ReadBits( $n ) {    //  n in [1..32]
  267.    
  268.         if ( $n === 0 )
  269.        
  270.             return false;
  271.            
  272.         if ( ( ( self::$cursor << 3 ) + self::$bits + $n ) > ( self::$size << 3 ) )
  273.  
  274.             return false;
  275.        
  276.         $bytes = $n >> 3;
  277.        
  278.         $n -= $bytes << 3;
  279.        
  280.         $ret = self::ReadString( $bytes );     
  281.  
  282.         if ( $n !== 0 ) {
  283.        
  284.             if ( self::$bits === 0 ) {
  285.            
  286.                 $ret .= chr( ord( self::$buffer[ self::$cursor ] ) & self::$bits_table[ $n ] );
  287.        
  288.                 self::$bits = $n;
  289.        
  290.             } else {
  291.            
  292.                 $last = 8 - self::$bits;
  293.                
  294.                 if ( $last <= $n ) {
  295.                
  296.                     $ret .= chr(
  297.                         ( ( ord( self::$buffer[ self::$cursor++ ] ) >> self::$bits ) & self::$bits_table[ $last ] ) |
  298.                         ( ( ord( self::$buffer[ self::$cursor ] ) << $last ) & self::$bits_table[ $n ] )
  299.                     );
  300.                
  301.                     self::$bits += $n - 8;
  302.                                    
  303.                 } else {
  304.  
  305.                     $ret .= chr( ( ord( self::$buffer[ self::$cursor ] ) >> self::$bits ) & self::$bits_table[ $n ] );
  306.                    
  307.                     self::$bits += $n;
  308.  
  309.                 }
  310.            
  311.             }
  312.        
  313.         }
  314.    
  315.         if ( strlen( $ret ) > 4 )
  316.            
  317.             return $ret;
  318.            
  319.         switch ( strlen( $ret ) ) {
  320.             case 0: $ret .= "\x00\x00\x00\x00"; break;
  321.             case 1: $ret .= "\x00\x00\x00"; break;
  322.             case 2: $ret .= "\x00\x00"; break;
  323.             case 3: $ret .= "\x00"; break;
  324.         }
  325.            
  326.         return unpack( "L" , $ret )[1];
  327.    
  328.     }
  329.     static function ReadOneBit() {
  330.    
  331.         return self::ReadBits( 1 );
  332.    
  333.     }
  334.    
  335.     static function ReadInt32() {
  336.        
  337.         if ( self::$bits === 0 ) {
  338.        
  339.             if ( self::$cursor + 3 >= self::$size )
  340.                
  341.                 return false;
  342.                
  343.             else
  344.                
  345.                 $ret = unpack( "l" , substr( self::$buffer , self::$cursor , 4 ) )[1];
  346.    
  347.                 self::$cursor += 4;
  348.                
  349.                 return $ret;
  350.    
  351.         }
  352.        
  353.         if ( self::$cursor + 4 >= self::$size )
  354.                
  355.             return false;
  356.        
  357.         $ret = self::ReadChar() . self::ReadChar() . self::ReadChar() . self::ReadChar();
  358.    
  359.         $ret = unpack( "l" , $ret )[1];
  360.  
  361.         self::$cursor += 4;
  362.        
  363.         return $ret;
  364.  
  365.     }
  366.     static function ReadInt16() {
  367.    
  368.         $ret1 = self::ReadByte();
  369.        
  370.         if ( $ret1 === false )
  371.        
  372.             return false;          
  373.        
  374.        
  375.         $ret2 = self::ReadByte();
  376.        
  377.         if ( $ret2 === false ) {
  378.        
  379.             self::$cursor--;
  380.        
  381.             return false;
  382.            
  383.         }
  384.        
  385.         $ret = (int) ( $ret1 + ( $ret2 << 8 ) );
  386.        
  387.         return ( $ret2 >> 7 ) ? ( ( $ret & 0x7FFF ) - 32768 ) : $ret;
  388.    
  389.     }
  390.     static function ReadInt8() {
  391.    
  392.         $ret = self::ReadByte();
  393.        
  394.         if ( $ret1 === false )
  395.        
  396.             return false;          
  397.        
  398.         return ( $ret >> 7 ) ? ( ( $ret & 0x7F ) - 128 ) : $ret;
  399.    
  400.     }
  401.  
  402.     static function ReadDWord() {
  403.        
  404.         if ( self::$bits === 0 ) {
  405.        
  406.             if ( self::$cursor + 3 >= self::$size )
  407.                
  408.                 return false;
  409.                
  410.             else
  411.                
  412.                 $ret = unpack( "L" , substr( self::$buffer , self::$cursor , 4 ) )[1];
  413.    
  414.                 self::$cursor += 4;
  415.                
  416.                 return $ret;
  417.    
  418.         }
  419.        
  420.         if ( self::$cursor + 4 >= self::$size )
  421.                
  422.             return false;
  423.        
  424.         $ret = self::ReadChar() . self::ReadChar() . self::ReadChar() . self::ReadChar();
  425.    
  426.         $ret = unpack( "L" , $ret )[1];
  427.  
  428.         self::$cursor += 4;
  429.        
  430.         return $ret;
  431.  
  432.     }
  433.     static function ReadWord() {
  434.    
  435.         $ret1 = self::ReadByte();
  436.        
  437.         if ( $ret1 === false )
  438.        
  439.             return false;          
  440.        
  441.        
  442.         $ret2 = self::ReadByte();
  443.        
  444.         if ( $ret2 === false ) {
  445.        
  446.             self::$cursor--;
  447.        
  448.             return false;
  449.            
  450.         }
  451.        
  452.         return (int) ( $ret1 + ( $ret2 << 8 ) );
  453.    
  454.     }
  455.     static function ReadByte() {
  456.        
  457.         if ( self::$bits === 0 )
  458.        
  459.             return ( self::$cursor >= self::$size ) ? false : ord( self::$buffer[ self::$cursor++ ] );
  460.  
  461.            
  462.         return ( self::$cursor + 1 >= self::$size ) ? false : ( (int) (
  463.             ( ord( self::$buffer[ self::$cursor++ ] ) >> self::$bits ) |
  464.             ( ord( self::$buffer[ self::$cursor   ] ) &  self::$bits_table << ( 8 - self::$bits ) )
  465.         ) );
  466.    
  467.     }
  468.  
  469.     static function ReadBool32() {
  470.    
  471.         $ret = self::ReadDWord();
  472.        
  473.         if ( $ret === false )
  474.        
  475.             return false;
  476.            
  477.         return ( $ret ) ? 1 : 0;
  478.    
  479.     }
  480.     static function ReadBool16() {
  481.    
  482.         $ret = self::ReadWord();
  483.        
  484.         if ( $ret === false )
  485.        
  486.             return false;
  487.            
  488.         return ( $ret ) ? 1 : 0;
  489.    
  490.     }
  491.     static function ReadBool8() {
  492.    
  493.         $ret = self::ReadByte();
  494.        
  495.         if ( $ret === false )
  496.        
  497.             return false;
  498.            
  499.         return ( $ret ) ? 1 : 0;
  500.    
  501.     }
  502.     static function ReadBool1() {
  503.    
  504.         $ret = self::ReadBits( 1 );
  505.        
  506.         if ( $ret === false )
  507.        
  508.             return false;
  509.            
  510.         return ( $ret ) ? 1 : 0;
  511.    
  512.     }
  513.    
  514.     static function ReadChar() {
  515.        
  516.         if ( self::$bits === 0 )
  517.        
  518.             return ( self::$cursor >= self::$size ) ? false : self::$buffer[ self::$cursor++ ];
  519.  
  520.         return ( self::$cursor + 1 >= self::$size ) ? false : chr( (int) (
  521.             ( ord( self::$buffer[ self::$cursor++ ] ) >> self::$bits ) |
  522.             ( ord( self::$buffer[ self::$cursor   ] ) &  self::$bits_table << ( 8 - self::$bits ) )
  523.         ) );
  524.  
  525.     }
  526.     static function ReadPString() {
  527.    
  528.         if ( self::$bits === 0 ) {
  529.        
  530.             $begin = self::$cursor;
  531.        
  532.             while ( ( self::$cursor < self::$size ) && ( self::$buffer[ self::$cursor++ ] !== "\x00" ) );
  533.  
  534.             return ( self::$buffer[ self::$cursor - 1 ] === "\x00" ) ? substr( self::$buffer , $begin , self::$cursor - $begin - 1 ) : substr( self::$buffer , $begin , self::$cursor - $begin );
  535.        
  536.         }
  537.        
  538.         $ret = "";
  539.        
  540.         $c = self::ReadChar();
  541.        
  542.         while ( !( ( $c === false ) || ( $c === "\x00" ) ) ) {
  543.    
  544.             $ret .= $c;
  545.    
  546.             $c = self::ReadChar();
  547.    
  548.         }
  549.        
  550.         return $ret;
  551.        
  552.     }
  553.     static function ReadString( $len = false ) {
  554.    
  555.         if ( $len === 0 )
  556.        
  557.             return "";
  558.    
  559.         if ( self::$bits === 0 ) {
  560.    
  561.             if ( self::$cursor + $len > self::$size )
  562.            
  563.                 return false;
  564.    
  565.             if ( $len === false )
  566.                
  567.                 $len = self::$size - self::$cursor;
  568.  
  569.             $ret = substr( self::$buffer , self::$cursor , $len );
  570.            
  571.             self::$cursor += $len;
  572.            
  573.             return $ret;
  574.        
  575.         }
  576.        
  577.         if ( self::$cursor + $len + 1 > self::$size )
  578.            
  579.             return false;
  580.        
  581.         $ret = "";
  582.  
  583.         while ( $len ) {
  584.    
  585.             $ret .= self::ReadChar();
  586.            
  587.             $len--;
  588.    
  589.         }
  590.        
  591.         return $ret;   
  592.    
  593.     }
  594.  
  595. }
  596. class TBUF {
  597.  
  598.     public $buf = "";
  599.     public $bufPos = 0;
  600.     public $bufSize = 0;
  601.    
  602.     public $posBit = 0;
  603.    
  604.     public function movBufL( $i = 0 ) {
  605.  
  606.         $this->setBuf( $this -> getBuf( $i ) );
  607.    
  608.     }
  609.     public function movR( $i = 0 ) {
  610.    
  611.         $this -> bufPos += $i;
  612.        
  613.         if ( $this -> bufPos >= $this -> bufSize )
  614.             $this -> bufSize = $this -> bufPos + 1;
  615.    
  616.     }
  617.     public function movL( $i = 0 ) {
  618.    
  619.         $this -> bufPos -= $i;
  620.    
  621.     }
  622.     public function movE() {
  623.    
  624.         $this -> bufPos = $this -> bufSize;
  625.    
  626.     }
  627.     public function movB() {
  628.    
  629.         $this -> bufPos = 0;
  630.    
  631.     }
  632.     public function ifEnd() {
  633.    
  634.         return (bool)( $this -> bufPos >= $this -> bufSize );
  635.    
  636.     }
  637.     public function ifEmpty() {
  638.    
  639.         return ((bool)( $this -> bufSize === 0 ));
  640.    
  641.     }
  642.     public function ifPos( $b = Null , $search ) {
  643.    
  644.         $b = ( $b === Null ) ? $this -> bufPos : $b;
  645.    
  646.         return ( (bool) ( substr( $this -> buf , $b , strlen( $search ) ) === $search ) );
  647.    
  648.     }
  649.     public function setCursor( $i = 0 ) {
  650.        
  651.         $this -> bufPos = $i;
  652.    
  653.     }
  654.     public function setBuf( $buf = "" ) {
  655.    
  656.         $this->buf = $buf;
  657.         $this->bufPos = 0;
  658.         $this->bufSize = strlen( $buf );
  659.    
  660.     }
  661.     public function addBuf( $buf ) {
  662.    
  663.         $this->buf .= $buf;
  664.         $this->bufSize = strlen( $this->buf );
  665.         $this->bufPos = $this->bufSize;
  666.    
  667.     }
  668.     public function getBuf( $b = 0 , $l = 65535 ) {
  669.    
  670.         return substr( $this->buf , $b , $l );
  671.    
  672.     }
  673.     public function readPString( $len = 65535 ) {
  674.    
  675.         $res = "";
  676.        
  677.         $len += $this->bufPos;
  678.        
  679.         $posNull = strpos( $this->buf , "\x00" , $this->bufPos );
  680.        
  681.         if ( !( $posNull === false ) ) {
  682.            
  683.             if ( $posNull < $len ) {
  684.            
  685.                 $res = substr( $this->buf , $this->bufPos , $posNull - $this->bufPos );
  686.                
  687.                 $this->bufPos = $posNull + 1;
  688.                 return $res;
  689.            
  690.             }
  691.            
  692.            
  693.             $res = substr( $this->buf , $this->bufPos , $len - $this->bufPos );
  694.                
  695.             $this->bufPos = $len;
  696.            
  697.             return $res;
  698.                
  699.         }
  700.        
  701.            
  702.         $res = substr( $this->buf , $this->bufPos , $len );
  703.                
  704.         $this->bufPos = $this->bufSize;
  705.        
  706.         return $res;
  707.    
  708.     }
  709.     public function readString( $len = true ) {
  710.    
  711.         $res = "";
  712.        
  713.         if ( $len === true ) {
  714.        
  715.             $res = $this -> getBuf( $this -> bufPos );
  716.        
  717.             $this -> bufPos = $this -> bufSize;
  718.  
  719.         } else {
  720.        
  721.             $res = $this -> getBuf( $this -> bufPos , $len );
  722.            
  723.             $this -> movR( $len );
  724.        
  725.         }
  726.        
  727.         return $res;
  728.    
  729.     }
  730.     public function readInt32() {
  731.    
  732.         $res = unpack( "l" , substr( $this->buf , $this->bufPos , 4 ) )[1];
  733.         $this->bufPos += 4;
  734.         return $res;
  735.    
  736.     }
  737.     public function readInt16() {
  738.    
  739.         $res = ord( $this->buf[ $this->bufPos ] ) + ord( $this->buf[ $this->bufPos+1 ] ) * 256;
  740.         $this->bufPos += 2;
  741.         return $res;
  742.    
  743.     }      
  744.     public function readInt8() {
  745.    
  746.         $res = ord( $this->buf[ $this->bufPos ] );
  747.         $this->bufPos++;
  748.         return $res;
  749.    
  750.     }  
  751.     public function readFloat32() {
  752.    
  753.         $res = unpack( "f" , substr( $this->buf , $this->bufPos , 4 ) )[1];
  754.         $this->bufPos += 4;
  755.         return $res;
  756.        
  757.     }
  758.    
  759.     private function __ReadOneBit() {
  760.    
  761.         $byte = ord( $this->buf[ $this->bufPos ] );
  762.    
  763.         $bit = ( $byte >> ($this->posBit++) ) & 0x01;
  764.         //return $bit;
  765.         if ( $this->posBit === 8 ) {
  766.        
  767.             $this->posBit = 0;
  768.  
  769.             $this->bufPos++;
  770.            
  771.         }
  772.        
  773.         return $bit;
  774.  
  775.     }
  776.  
  777.     private function readBits_sys( $count = 0 ) {//max 24 bit
  778.        
  779.         if ( ( $count < 1 ) || ( $count > 24 ) )
  780.             return false;
  781.            
  782.             /*
  783.         $res = 0;
  784.    
  785.         for ( $i = 0; $i < $count; $i++ )
  786.        
  787.             $res |= ( $this->__ReadOneBit() << $i );
  788.    
  789.         return $res;   
  790.             */
  791.            
  792.            
  793.            
  794.        
  795.            
  796.         $r_byte = $count >> 3;
  797.        
  798.         if ( $this->bufPos + 4 > $this->bufSize ) {
  799.             $st = $this->readString();
  800.             $len = strlen( $st );
  801.             for( $i=0; $i<(4-$len); $i++ )
  802.                 $st .= "\x00";
  803.                
  804.             $b = unpack( "l" , $st )[1];
  805.             $this->movL($len - $r_byte);
  806.         } else {
  807.             $b = $this->readInt32();
  808.             $this->movL(4 - $r_byte);
  809.         }
  810.        
  811.         $bits = ( $b >> $this->posBit ) & ( ~( ((int)0xFFFFFFFF) << $count ) );
  812.  
  813.         $this->posBit += ( $count - ( $r_byte << 3 ) );
  814.        
  815.         if ( $this->posBit >= 8 ) {
  816.             $this->posBit -= 8;
  817.             $this->movR(1);    
  818.         }
  819.         //echo "posBit = " . $this->posBit." | posByte = " . $this->bufPos. "\n";
  820.    
  821.         return $bits;
  822.        
  823.     }
  824.     public function readBits( $count = 0 ) {//max 32 bit
  825.    
  826.         if ( ( $count < 1 ) || ( $count > 32 ) )
  827.             return false;
  828.            
  829.         if ( $count > 24 ) {
  830.        
  831.             return ( $this->readBits_sys( 24 ) | ( $this->readBits_sys( $count - 24 ) << 24 ) );
  832.        
  833.         } else
  834.        
  835.             return $this->readBits_sys( $count );
  836.    
  837.     }
  838.     public function readOneBitBool() {
  839.         return ( $this->readBits(1) === 1 );   
  840.     }
  841.     public function readBitsBegin() {
  842.         $this->posBit = 0;
  843.     }  
  844.     public function readBitsEnd() {
  845.         if ( $this->posBit > 0 ) {
  846.             $this->posBit = 0;
  847.             $this->movR(1);            
  848.         }  
  849.     }  
  850.     public function readBitsRelease() {
  851.         if ( $this->posBit > 0 ) {
  852.             $this->posBit = 0;
  853.             $this->movR(1);            
  854.         }  
  855.     }
  856.     public function readBitPString() {
  857.    
  858.         $result = "";
  859.  
  860.         while( ($byte = $this->readBits( 8 )) !== 0 )
  861.        
  862.             $result .= chr($byte);
  863.            
  864.         return $result;
  865.    
  866.     }
  867.     public function readBitBufferByte( $byte ) {
  868.    
  869.         $res = "";
  870.    
  871.         for ( $i = 0; $i < $byte; $i++ )
  872.        
  873.             $res .= chr( $this->readBits(8) );
  874.            
  875.         return $res;
  876.    
  877.     }
  878.    
  879.     private $ReadBitNum = 0;
  880.     private function readBitOne_sys() {
  881.    
  882.         $byte = ord($this->buf[$this->bufPos]);
  883.    
  884.         $bit = ( $byte >> $this->ReadBitNum ) & 0x01;
  885.    
  886.         if ( $this->ReadBitNum === 8 ) {
  887.  
  888.             $this->bufPos++;
  889.        
  890.             $this->ReadBitNum = 0;
  891.            
  892.         }
  893.        
  894.         return $bit;
  895.        
  896.     }
  897.     public function readBitsM( $n ) {
  898.    
  899.         $res = 0;
  900.    
  901.         for ( $i = 0; $i < $n; $i++ )
  902.        
  903.             $res |= ( $this->readBitOne_sys() << $i );
  904.        
  905.         return $res;
  906.    
  907.     }
  908.     public function readBitsEndM() {
  909.    
  910.         if ( !( $this->ReadBitNum === 0 ) ) {
  911.  
  912.             $this->bufPos++;
  913.        
  914.             $this->ReadBitNum = 0;
  915.            
  916.         }
  917.    
  918.     }
  919.    
  920.     public function writePString( $str ) {
  921.            
  922.         $this -> writeString( $str . "\x00" );
  923.        
  924.         $this -> movR( strlen($str) + 1 );     
  925.    
  926.     }  
  927.     public function writeString( $str , $bPos = false ) {
  928.        
  929.         if ( $bPos === false )
  930.             $bPos = $this -> bufPos;
  931.            
  932.         $buf1 = $this -> getBuf( 0 , $bPos );   //substr( $this->buf , 0 , $bPos );
  933.         $buf2 = $this -> getBuf( $bPos     );   //substr( $this->buf , 0 , $bPos );
  934.        
  935.         $this -> buf = $buf1 . $str . $buf2;
  936.        
  937.         $this -> movR( strlen($str) );
  938.    
  939.     }
  940.     public function writeInt32( $option ) {
  941.        
  942.         $res = pack( "l" , ( (int) $option ) );
  943.        
  944.         $this -> writeString( $res );
  945.    
  946.     }  
  947.     public function writeInt16( $option ) {
  948.    
  949.         $f1 = ( (int) $option ) & 0xFF;
  950.         $f2 = ( ( (int) $option ) >> 8 ) & 0xFF;
  951.    
  952.         $res = chr( $f1 ) . chr( $f2 );
  953.        
  954.         $this -> writeString( $res );
  955.    
  956.     }  
  957.     public function writeInt8( $option ) {
  958.    
  959.         $res = chr( ( ( (int) $option ) & 0xFF ) );
  960.        
  961.         $this -> writeString( $res );
  962.    
  963.     }      
  964.     public function writeFloat32( $option ) {
  965.    
  966.         $res = pack( "f" , ( (float) $option ) );
  967.        
  968.         $this -> writeString( $res );
  969.    
  970.     }
  971.    
  972. }
  973. class SVC_CMD {
  974.  
  975.     public $_list_ = Array (
  976.         Array( "Name" => "BAD" , "Index" => 0 , "params_type" => "1" , "Size" => Null ) ,
  977.         Array( "Name" => "NOP" , "Index" => 1 , "params_type" => "1" , "Size" => Null ) ,
  978.         Array( "Name" => "DISCONNECT" , "Index" => 2 , "params_type" => "p" , "Size" => Null ) ,
  979.         Array( "Name" => "EVENT" , "Index" => 3 , "params_type" => "_default" , "Size" => Null ) ,
  980.         Array( "Name" => "VERSION" , "Index" => 4 , "params_type" => "_default" , "Size" => Null ) ,
  981.         Array( "Name" => "SETVIEW" , "Index" => 5 , "params_type" => "_default" , "Size" => Null ) ,
  982.         Array( "Name" => "SOUND" , "Index" => 6 , "params_type" => "_default" , "Size" => Null ) ,
  983.         Array( "Name" => "TIME" , "Index" => 7 , "params_type" => "Float" , "Size" => Null ) ,
  984.         Array( "Name" => "PRINT" , "Index" => 8 , "params_type" => "n" , "Size" => Null ) ,
  985.         Array( "Name" => "STUFFTEXT" , "Index" => 9 , "params_type" => "n" , "Size" => Null ) ,
  986.         Array( "Name" => "SETANGLE" , "Index" => 10 , "params_type" => "_default" , "Size" => Null ) ,
  987.         Array( "Name" => "SERVERINFO" , "Index" => 11 , "params_type" => "_SERVERINFO" , "Size" => Null ) ,
  988.         Array( "Name" => "LIGHTSTYLE" , "Index" => 12 , "params_type" => "_default" , "Size" => Null ) ,
  989.         Array( "Name" => "UPDATEUSERINFO" , "Index" => 13 , "params_type" => "_default" , "Size" => Null ) ,
  990.         Array( "Name" => "DELTADESCRIPTION" , "Index" => 14 , "params_type" => "_DELTADESCRIPTION" , "Size" => Null ) ,
  991.         Array( "Name" => "CLIENTDATA" , "Index" => 15 , "params_type" => "_default" , "Size" => Null ) ,
  992.         Array( "Name" => "STOPSOUND" , "Index" => 16 , "params_type" => "_default" , "Size" => Null ) ,
  993.         Array( "Name" => "PINGS" , "Index" => 17 , "params_type" => "_default" , "Size" => Null ) ,
  994.         Array( "Name" => "PARTICLE" , "Index" => 18 , "params_type" => "_default" , "Size" => Null ) ,
  995.         Array( "Name" => "DAMAGE" , "Index" => 19 , "params_type" => "_default" , "Size" => Null ) ,
  996.         Array( "Name" => "SPAWNSTATIC" , "Index" => 20 , "params_type" => "_default" , "Size" => Null ) ,
  997.         Array( "Name" => "EVENT_RELIABLE" , "Index" => 21 , "params_type" => "_default" , "Size" => Null ) ,
  998.         Array( "Name" => "SPAWNBASELINE" , "Index" => 22 , "params_type" => "_default" , "Size" => Null ) ,
  999.         Array( "Name" => "TEMPENTITY" , "Index" => 23 , "params_type" => "_default" , "Size" => Null ) ,
  1000.         Array( "Name" => "SETPAUSE" , "Index" => 24 , "params_type" => "_default" , "Size" => Null ) ,
  1001.         Array( "Name" => "SIGNONNUM" , "Index" => 25 , "params_type" => "_default" , "Size" => Null ) ,
  1002.         Array( "Name" => "CENTERPRINT" , "Index" => 26 , "params_type" => "_default" , "Size" => Null ) ,
  1003.         Array( "Name" => "KILLEDMONSTER" , "Index" => 27 , "params_type" => "_default" , "Size" => Null ) ,
  1004.         Array( "Name" => "FOUNDSECRET" , "Index" => 28 , "params_type" => "_default" , "Size" => Null ) ,
  1005.         Array( "Name" => "SPAWNSTATICSOUND" , "Index" => 29 , "params_type" => "_default" , "Size" => Null ) ,
  1006.         Array( "Name" => "INTERMISSION" , "Index" => 30 , "params_type" => "_default" , "Size" => Null ) ,
  1007.         Array( "Name" => "FINALE" , "Index" => 31 , "params_type" => "_default" , "Size" => Null ) ,
  1008.         Array( "Name" => "CDTRACK" , "Index" => 32 , "params_type" => "_default" , "Size" => Null ) ,
  1009.         Array( "Name" => "RESTORE" , "Index" => 33 , "params_type" => "_default" , "Size" => Null ) ,
  1010.         Array( "Name" => "CUTSCENE" , "Index" => 34 , "params_type" => "_default" , "Size" => Null ) ,
  1011.         Array( "Name" => "WEAPONANIM" , "Index" => 35 , "params_type" => "_default" , "Size" => Null ) ,
  1012.         Array( "Name" => "DECALNAME" , "Index" => 36 , "params_type" => "_default" , "Size" => Null ) ,
  1013.         Array( "Name" => "ROOMTYPE" , "Index" => 37 , "params_type" => "_default" , "Size" => Null ) ,
  1014.         Array( "Name" => "ADDANGLE" , "Index" => 38 , "params_type" => "_default" , "Size" => Null ) ,
  1015.         Array( "Name" => "NEWUSERMSG" , "Index" => 39 , "params_type" => "_default" , "Size" => Null ) ,
  1016.         Array( "Name" => "PACKETENTITIES" , "Index" => 40 , "params_type" => "_default" , "Size" => Null ) ,
  1017.         Array( "Name" => "DELTAPACKETENTITIES" , "Index" => 41 , "params_type" => "_default" , "Size" => Null ) ,
  1018.         Array( "Name" => "CHOKE" , "Index" => 42 , "params_type" => "_default" , "Size" => Null ) ,
  1019.         Array( "Name" => "RESOURCELIST" , "Index" => 43 , "params_type" => "_default" , "Size" => Null ) ,
  1020.         Array( "Name" => "NEWMOVEVARS" , "Index" => 44 , "params_type" => "_default" , "Size" => Null ) ,
  1021.         Array( "Name" => "RESOURCEREQUEST" , "Index" => 45 , "params_type" => "_default" , "Size" => Null ) ,
  1022.         Array( "Name" => "CUSTOMIZATION" , "Index" => 46 , "params_type" => "_default" , "Size" => Null ) ,
  1023.         Array( "Name" => "CROSSHAIRANGLE" , "Index" => 47 , "params_type" => "_default" , "Size" => Null ) ,
  1024.         Array( "Name" => "SOUNDFADE" , "Index" => 48 , "params_type" => "_default" , "Size" => Null ) ,
  1025.         Array( "Name" => "FILETXFERFAILED" , "Index" => 49 , "params_type" => "_default" , "Size" => Null ) ,
  1026.         Array( "Name" => "HLTV" , "Index" => 50 , "params_type" => "_default" , "Size" => Null ) ,
  1027.         Array( "Name" => "DIRECTOR" , "Index" => 51 , "params_type" => "_default" , "Size" => Null ) ,
  1028.         Array( "Name" => "VOICEINIT" , "Index" => 52 , "params_type" => "_default" , "Size" => Null ) ,
  1029.         Array( "Name" => "VOICEDATA" , "Index" => 53 , "params_type" => "_default" , "Size" => Null ) ,
  1030.         Array( "Name" => "SENDEXTRAINFO" , "Index" => 54 , "params_type" => "_default" , "Size" => Null ) ,
  1031.         Array( "Name" => "TIMESCALE" , "Index" => 55 , "params_type" => "_default" , "Size" => Null ) ,
  1032.         Array( "Name" => "RESOURCELOCATION" , "Index" => 56 , "params_type" => "_default" , "Size" => Null ) ,
  1033.         Array( "Name" => "SENDCVARVALUE" , "Index" => 57 , "params_type" => "p" , "Size" => Null ) ,
  1034.         Array( "Name" => "SENDCVARVALUE2" , "Index" => 58 , "params_type" => "ip" )
  1035.     );
  1036.    
  1037.     public $buf;
  1038.  
  1039.     public function checkCMD( $name ) {
  1040.  
  1041.         foreach ( $this -> _list_ as &$cmd ) {
  1042.    
  1043.             if ( $cmd["Name"] === $name )
  1044.                 return true;
  1045.  
  1046.         }
  1047.        
  1048.         return false;
  1049.        
  1050.     }
  1051.     public function getCMD( $search ) {
  1052.    
  1053.         if ( getType( $search ) === "string" ) {
  1054.  
  1055.             foreach ( $this -> _list_ as &$cmd ) {
  1056.        
  1057.                 if ( $cmd["Name"] === $search )
  1058.                     return $cmd;
  1059.  
  1060.             }
  1061.        
  1062.         } else {
  1063.        
  1064.             foreach( $this->_list_ as &$cmd ) {
  1065.            
  1066.                 if ( $cmd["Index"] === $search )
  1067.                     return $cmd;
  1068.            
  1069.             }              
  1070.        
  1071.         }
  1072.    
  1073.         return false;
  1074.  
  1075.     }
  1076.     public function getCMDName ( $id ) {
  1077.    
  1078.         $t = $this -> getCMD( $id );
  1079.    
  1080.         return ( $t ) ? $t["Name"] : false;
  1081.    
  1082.     }
  1083.     public function writeCMD( $cmd , $options , $my_type = false ) {
  1084.  
  1085.         $cmd = $this -> getCMD( $cmd );
  1086.         if ( $cmd === false )
  1087.             return false;
  1088.  
  1089.         if ( $my_type )
  1090.             return chr( $cmd["Index"] ) . ( (string) $options );
  1091.  
  1092.         if ( $cmd["params_type"] === "PString" )
  1093.             return chr( $cmd["Index"] ) . ( (string) $options ) . "\x00";
  1094.  
  1095.         if ( $cmd["params_type"] === "PStringNewLine" )
  1096.             return chr( $cmd["Index"] ) . ( (string) $options ) . "\x0A\x00";
  1097.  
  1098.         if ( $cmd["params_type"] === "Int32_PString" )
  1099.             return chr( $cmd["Index"] ) . pack( "l" , ( (int) $options [0] ) ) . ( (string) $options [1] ) . "\x00";
  1100.  
  1101.     }
  1102.     public function parseFormatRead( $buf , $cmd , $i ) {
  1103.    
  1104.         switch ( substr( $cmd["params_type"] , $i ) ) {
  1105.             case "_SERVERINFO":
  1106.                 $prev = $buf -> bufPos;
  1107.                 $options = Array(
  1108.                     $buf -> readInt32() ,
  1109.                     $buf -> readInt32() ,
  1110.                     $buf -> readInt32() ,
  1111.                     $buf -> readInt8() ,
  1112.                     $buf -> readInt8() ,
  1113.                     $buf -> readInt16() ,
  1114.                     $buf -> readPString() ,
  1115.                     $buf -> readPString() ,
  1116.                     //$buf -> readInt8() ,
  1117.                     $buf -> readPString() ,
  1118.                     //$buf -> readInt32() ,
  1119.                     $buf -> readInt32()
  1120.                 );
  1121.                 return Array( "cmd" => $cmd , "options" => $options , "options_string" => $buf->getBuf( $prev , $buf->bufPos - $prev ) );  
  1122.                 break;
  1123.             case "_DELTADESCRIPTION":
  1124.                 $prev = $buf -> bufPos;
  1125.                 $options = Array(
  1126.                     $buf -> readPString()
  1127.                 );
  1128.                 return Array( "cmd" => $cmd , "options" => $options , "options_string" => $buf->getBuf( $prev , $buf->bufPos - $prev ) );  
  1129.             case "_default":
  1130.                 return Array( "cmd" => $cmd , "options" => Null , "options_string" => $buf->readString() );            
  1131.             break;
  1132.             default:
  1133.                 $buf->movL( 1 );
  1134.                 return -1;             
  1135.         }
  1136.    
  1137.     }
  1138.     public function readCMD( $buf ) {
  1139.        
  1140.         $cmd = $buf->readInt8();
  1141.        
  1142.         if ( $cmd === 0 )      
  1143.             return -1;     
  1144.        
  1145.         $cmd = $this -> getCMD( $cmd );
  1146.         if ( $cmd === false ) {
  1147.             $buf->movL( 1 );            
  1148.             return 0;      
  1149.         }
  1150.  
  1151.         $t_len = strlen( $cmd["params_type"] );
  1152.         $prevPos = $buf -> bufPos;
  1153.        
  1154.         $options = Array();
  1155.        
  1156.         for ( $i = 0; $i < $t_len; $i++ ) {
  1157.             switch ( $cmd["params_type"][$i] ) {
  1158.                 case "1":
  1159.                     return Array( "cmd" => $cmd , "options" => Null , "options_string" => substr( $buf->buf , $prevPos , $buf -> bufPos - $prevPos ) );
  1160.                     break;
  1161.                 case "i":
  1162.                     $options[] = $buf->readInt32();
  1163.                     break;
  1164.                 case "s":
  1165.                     $options[] = $buf->readInt16();    
  1166.                     break;
  1167.                 case "b":
  1168.                     $options[] = $buf->readInt8();     
  1169.                     break;
  1170.                 case "p":
  1171.                     $options[] = $buf->readPString();
  1172.                     break;
  1173.                 case "n":
  1174.                     $options[] = $buf->readPString();
  1175.                     break;
  1176.                 case "_":
  1177.                     return $this -> parseFormatRead( $buf ,  $cmd , $i );
  1178.                     break;
  1179.                 default:
  1180.                     return -1;     
  1181.             }          
  1182.         }
  1183.        
  1184.         return Array( "cmd" => $cmd , "options" => $options , "options_string" => substr( $buf->buf , $prevPos , $buf -> bufPos - $prevPos ) );
  1185.            
  1186.     }
  1187.    
  1188.     public function __construct() {
  1189.    
  1190.         $this -> buf = NET_BUFER_IN::getCL();
  1191.    
  1192.     }
  1193.  
  1194.     public static $thisCL = Null;  
  1195.     public static function getCL() {
  1196.  
  1197.         ( self::$thisCL === Null ) &&
  1198.         ( self::$thisCL = new self() );
  1199.  
  1200.         return self::$thisCL;
  1201.  
  1202.     }
  1203.  
  1204. }
  1205. class USER_MESSAGE extends TBUF {
  1206.  
  1207.     public $_list_ = Array(
  1208.         Array( "Name" => "ReqState" , "Index" => 65 , "Size" => 0 ) ,
  1209.         Array( "Name" => "VoiceMask" , "Index" => 64 , "Size" => 8 ) ,
  1210.         Array( "Name" => "ShowMenu" , "Index" => 96 , "Size" => -1 ) ,
  1211.         Array( "Name" => "Scenario" , "Index" => 134 , "Size" => -1 ) ,
  1212.         Array( "Name" => "TaskTime" , "Index" => 133 , "Size" => 4 ) ,
  1213.         Array( "Name" => "BarTime2" , "Index" => 138 , "Size" => 4 ) ,
  1214.         Array( "Name" => "BarTime" , "Index" => 108 , "Size" => 2 ) ,
  1215.         Array( "Name" => "RoundTime" , "Index" => 101 , "Size" => 2 ) ,
  1216.         Array( "Name" => "BlinkAcct" , "Index" => 104 , "Size" => 1 ) ,
  1217.         Array( "Name" => "Money" , "Index" => 102 , "Size" => 5 ) ,
  1218.         Array( "Name" => "StatusIcon" , "Index" => 107 , "Size" => -1 ) ,
  1219.         Array( "Name" => "TextMsg" , "Index" => 77 , "Size" => -1 ) ,
  1220.         Array( "Name" => "SecAmmoIcon" , "Index" => 0 , "Size" => 0 ) ,
  1221.         Array( "Name" => "SecAmmoVal" , "Index" => 0 , "Size" => 0 ) ,
  1222.         Array( "Name" => "DeathMsg" , "Index" => 83 , "Size" => -1 ) ,
  1223.         Array( "Name" => "StatusValue" , "Index" => 105 , "Size" => -1 ) ,
  1224.         Array( "Name" => "StatusText" , "Index" => 106 , "Size" => -1 ) ,
  1225.         Array( "Name" => "GameTitle" , "Index" => 82 , "Size" => 1 ) ,
  1226.         Array( "Name" => "HudTextArgs" , "Index" => 145 , "Size" => -1 ) ,
  1227.         Array( "Name" => "HudTextPro" , "Index" => 74 , "Size" => -1 ) ,
  1228.         Array( "Name" => "HudText" , "Index" => 75 , "Size" => -1 ) ,
  1229.         Array( "Name" => "FlashBat" , "Index" => 69 , "Size" => 1 ) ,
  1230.         Array( "Name" => "Flashlight" , "Index" => 68 , "Size" => 2 ) ,
  1231.         Array( "Name" => "ArmorType" , "Index" => 103 , "Size" => 1 ) ,
  1232.         Array( "Name" => "Battery" , "Index" => 72 , "Size" => 2 ) ,
  1233.         Array( "Name" => "Train" , "Index" => 73 , "Size" => 1 ) ,
  1234.         Array( "Name" => "Geiger" , "Index" => 67 , "Size" => 1 ) ,
  1235.         Array( "Name" => "SendAudio" , "Index" => 100 , "Size" => -1 ) ,
  1236.         Array( "Name" => "SayText" , "Index" => 76 , "Size" => -1 ) ,
  1237.         Array( "Name" => "ReceiveW" , "Index" => 129 , "Size" => 1 ) ,
  1238.         Array( "Name" => "ClCorpse" , "Index" => 122 , "Size" => -1 ) ,
  1239.         Array( "Name" => "ScoreAttrib" , "Index" => 84 , "Size" => 2 ) ,
  1240.         Array( "Name" => "Radar" , "Index" => 112 , "Size" => 7 ) ,
  1241.         Array( "Name" => "Damage" , "Index" => 71 , "Size" => 12 ) ,
  1242.         Array( "Name" => "Health" , "Index" => 70 , "Size" => 1 ) ,
  1243.         Array( "Name" => "Crosshair" , "Index" => 110 , "Size" => 1 ) ,
  1244.         Array( "Name" => "AmmoX" , "Index" => 99 , "Size" => 2 ) ,
  1245.         Array( "Name" => "HideWeapon" , "Index" => 94 , "Size" => 1 ) ,
  1246.         Array( "Name" => "ItemPickup" , "Index" => 93 , "Size" => -1 ) ,
  1247.         Array( "Name" => "WeapPickup" , "Index" => 92 , "Size" => 1 ) ,
  1248.         Array( "Name" => "AmmoPickup" , "Index" => 91 , "Size" => 2 ) ,
  1249.         Array( "Name" => "WeaponList" , "Index" => 78 , "Size" => -1 ) ,
  1250.         Array( "Name" => "CurWeapon" , "Index" => 66 , "Size" => 3 ) ,
  1251.         Array( "Name" => "NVGToggle" , "Index" => 111 , "Size" => 1 ) ,
  1252.         Array( "Name" => "ItemStatus" , "Index" => 139 , "Size" => 1 ) ,
  1253.         Array( "Name" => "BotProgress" , "Index" => 141 , "Size" => -1 ) ,
  1254.         Array( "Name" => "SpecHealth2" , "Index" => 137 , "Size" => 2 ) ,
  1255.         Array( "Name" => "BuyClose" , "Index" => 136 , "Size" => 0 ) ,
  1256.         Array( "Name" => "TutorClose" , "Index" => 118 , "Size" => -1 ) ,
  1257.         Array( "Name" => "TutorState" , "Index" => 117 , "Size" => -1 ) ,
  1258.         Array( "Name" => "TutorLine" , "Index" => 116 , "Size" => -1 ) ,
  1259.         Array( "Name" => "TutorText" , "Index" => 115 , "Size" => -1 ) ,
  1260.         Array( "Name" => "VGUIMenu" , "Index" => 114 , "Size" => -1 ) ,
  1261.         Array( "Name" => "ForceCam" , "Index" => 127 , "Size" => 3 ) ,
  1262.         Array( "Name" => "AllowSpec" , "Index" => 119 , "Size" => 1 ) ,
  1263.         Array( "Name" => "Spectator" , "Index" => 113 , "Size" => 2 ) ,
  1264.         Array( "Name" => "Location" , "Index" => 140 , "Size" => -1 ) ,
  1265.         Array( "Name" => "TeamInfo" , "Index" => 86 , "Size" => -1 ) ,
  1266.         Array( "Name" => "TeamScore" , "Index" => 87 , "Size" => -1 ) ,
  1267.         Array( "Name" => "ScoreInfo" , "Index" => 85 , "Size" => 9 ) ,
  1268.         Array( "Name" => "ServerName" , "Index" => 90 , "Size" => -1 ) ,
  1269.         Array( "Name" => "RandomPC" , "Index" => 0 , "Size" => 0 ) ,
  1270.         Array( "Name" => "BuildSt" , "Index" => 0 , "Size" => 0 ) ,
  1271.         Array( "Name" => "MOTD" , "Index" => 89 , "Size" => -1 ) ,
  1272.         Array( "Name" => "Detpack" , "Index" => 0 , "Size" => 0 ) ,
  1273.         Array( "Name" => "Feign" , "Index" => 0 , "Size" => 0 ) ,
  1274.         Array( "Name" => "TeamNames" , "Index" => 0 , "Size" => 0 ) ,
  1275.         Array( "Name" => "ShowTimer" , "Index" => 144 , "Size" => 0 ) ,
  1276.         Array( "Name" => "Fog" , "Index" => 143 , "Size" => 7 ) ,
  1277.         Array( "Name" => "Brass" , "Index" => 142 , "Size" => -1 ) ,
  1278.         Array( "Name" => "BotVoice" , "Index" => 135 , "Size" => 2 ) ,
  1279.         Array( "Name" => "ShadowIdx" , "Index" => 132 , "Size" => 4 ) ,
  1280.         Array( "Name" => "CZCareerHUD" , "Index" => 131 , "Size" => -1 ) ,
  1281.         Array( "Name" => "HostageK" , "Index" => 124 , "Size" => 1 ) ,
  1282.         Array( "Name" => "HostagePos" , "Index" => 123 , "Size" => 8 ) ,
  1283.         Array( "Name" => "ADStop" , "Index" => 128 , "Size" => 0 ) ,
  1284.         Array( "Name" => "BombPickup" , "Index" => 121 , "Size" => 0 ) ,
  1285.         Array( "Name" => "BombDrop" , "Index" => 120 , "Size" => 7 ) ,
  1286.         Array( "Name" => "ReloadSound" , "Index" => 109 , "Size" => 2 ) ,
  1287.         Array( "Name" => "Concuss" , "Index" => 0 , "Size" => 0 ) ,
  1288.         Array( "Name" => "SpecHealth" , "Index" => 126 , "Size" => 1 ) ,
  1289.         Array( "Name" => "HLTV" , "Index" => 125 , "Size" => 2 ) ,
  1290.         Array( "Name" => "SetFOV" , "Index" => 95 , "Size" => 1 ) ,
  1291.         Array( "Name" => "ViewMode" , "Index" => 81 , "Size" => 0 ) ,
  1292.         Array( "Name" => "InitHUD" , "Index" => 80 , "Size" => 0 ) ,
  1293.         Array( "Name" => "GameMode" , "Index" => 88 , "Size" => 1 ) ,
  1294.         Array( "Name" => "ResetHUD" , "Index" => 79 , "Size" => 0 ) ,
  1295.         Array( "Name" => "Logo" , "Index" => 0 , "Size" => 0 ) ,
  1296.         Array( "Name" => "ScreenFade" , "Index" => 98 , "Size" => 10 )     
  1297.     );
  1298.    
  1299.     public $buf;
  1300.    
  1301.     public function checkCMD( $name ) {
  1302.  
  1303.         foreach ( $this -> _list_ as &$cmd ) {
  1304.    
  1305.             if ( $cmd["Name"] === $name )
  1306.                 return true;
  1307.  
  1308.         }
  1309.        
  1310.         return false;
  1311.        
  1312.     }
  1313.     public function getCMD( $search ) {
  1314.    
  1315.         if ( getType( $search ) === "string" ) {
  1316.  
  1317.             foreach ( $this -> _list_ as &$cmd ) {
  1318.        
  1319.                 if ( $cmd["Name"] === $search )
  1320.                     return $cmd;
  1321.  
  1322.             }
  1323.        
  1324.         } else {
  1325.        
  1326.             foreach( $this->_list_ as &$cmd ) {
  1327.            
  1328.                 if ( $cmd["Index"] === $search )
  1329.                     return $cmd;
  1330.            
  1331.             }              
  1332.        
  1333.         }
  1334.    
  1335.         return false;
  1336.  
  1337.     }
  1338.     public function getCMDName ( $id ) {
  1339.    
  1340.         $t = $this -> getCMD( $id );
  1341.    
  1342.         return ( $t ) ? $t["Name"] : false;
  1343.    
  1344.     }
  1345.     public function writeCMD( $cmd , $options , $my_type = true/*false*/ ) {
  1346.  
  1347.         $cmd = $this -> getCMD( $cmd );
  1348.         if ( $cmd === false )
  1349.             return false;
  1350.  
  1351.         if ( $my_type )
  1352.             return chr( $cmd["Index"] ) . ( (string) $options );
  1353.        
  1354.         /*
  1355.        
  1356.         if ( $cmd["params_type"] === "PString" )
  1357.             return chr( $cmd["Index"] ) . ( (string) $options ) . "\x00";
  1358.  
  1359.         if ( $cmd["params_type"] === "PStringNewLine" )
  1360.             return chr( $cmd["Index"] ) . ( (string) $options ) . "\x0A\x00";
  1361.  
  1362.         if ( $cmd["params_type"] === "Int32_PString" )
  1363.             return chr( $cmd["Index"] ) . pack( "l" , ( (int) $options [0] ) ) . ( (string) $options [1] ) . "\x00";
  1364.            
  1365.         */
  1366.  
  1367.     }
  1368.     public function readCMD( $buf ) {
  1369.        
  1370.         $cmdId = $this->readInt8();
  1371.        
  1372.         $cmd = $this -> getCMD( $cmdId );
  1373.        
  1374.         if ( ( $cmd === false ) || ( $cmd["Index"] === 0 ) ) {
  1375.             $buf->movL( 1 );
  1376.             return false;
  1377.         }
  1378.            
  1379.         $Size = ( $cmd["Size"] === -1 ) ? $this->readInt8() : $cmd["Size"];
  1380.        
  1381.         $res = $this -> readString( $Size );
  1382.  
  1383.         return Array( "cmd" => $cmd , "options" => Null , "options_string" => $res );
  1384.  
  1385.     }
  1386.     public function read() {
  1387.    
  1388.    
  1389.     }
  1390.        
  1391.    
  1392.     public static $thisCL = Null;  
  1393.     public static function getCL() {
  1394.  
  1395.         ( self::$thisCL === Null ) &&
  1396.         ( self::$thisCL = new self() );
  1397.  
  1398.         return self::$thisCL;
  1399.  
  1400.     }
  1401.  
  1402. }
  1403. class CLC_CMD extends TBUF {
  1404.  
  1405.     public $_list_ = Array(
  1406.         Array( "Name" => "BAD" , "Index" => 0 , "params_type" => "1" , "Size" => Null ) ,
  1407.         Array( "Name" => "NOP" , "Index" => 1 , "params_type" => "1" , "Size" => Null ) ,
  1408.         Array( "Name" => "MOVE" , "Index" => 2 , "params_type" => "_MOVE" , "Size" => Null ) ,
  1409.         Array( "Name" => "STRINGCMD" , "Index" => 3 , "params_type" => "n" , "Size" => Null ) ,
  1410.         Array( "Name" => "DELTA" , "Index" => 4 , "params_type" => "b" , "Size" => Null ) ,
  1411.         Array( "Name" => "RESOURCELIST" , "Index" => 5 , "params_type" => "_RESOURCELIST" , "Size" => Null ) ,
  1412.         Array( "Name" => "USERINFO" , "Index" => 6 , "params_type" => "p" , "Size" => Null ) ,
  1413.         Array( "Name" => "FILECONSISTENCY" , "Index" => 7 , "params_type" => "_Fileconsistency_Format" , "Size" => Null ) ,
  1414.         Array( "Name" => "VOICEDATA" , "Index" => 8 , "params_type" => "_VOICEDATA" , "Size" => Null ) ,
  1415.         Array( "Name" => "REQUESTCVARVALUE" , "Index" => 10 , "params_type" => "p" , "Size" => Null ) ,
  1416.         Array( "Name" => "REQUESTCVARVALUE2" , "Index" => 11 , "params_type" => "ipp" , "Size" => Null )    
  1417.     );
  1418.    
  1419.     public function checkCMD( $name ) {
  1420.  
  1421.         foreach ( $this -> _list_ as &$cmd ) {
  1422.    
  1423.             if ( $cmd["Name"] === $name )
  1424.                 return true;
  1425.  
  1426.         }
  1427.        
  1428.         return false;
  1429.        
  1430.     }
  1431.     public function getCMD( $search ) {
  1432.    
  1433.         if ( getType( $search ) === "string" ) {
  1434.  
  1435.             foreach ( $this -> _list_ as &$cmd ) {
  1436.        
  1437.                 if ( $cmd["Name"] === $search )
  1438.                     return $cmd;
  1439.  
  1440.             }
  1441.        
  1442.         } else {
  1443.        
  1444.             foreach( $this->_list_ as &$cmd ) {
  1445.            
  1446.                 if ( $cmd["Index"] === $search )
  1447.                     return $cmd;
  1448.            
  1449.             }              
  1450.        
  1451.         }
  1452.    
  1453.         return false;
  1454.  
  1455.     }
  1456.     public function getCMDName ( $id ) {
  1457.    
  1458.         $t = $this -> getCMD( $id );
  1459.    
  1460.         return ( $t ) ? $t["Name"] : false;
  1461.    
  1462.     }
  1463.     public function parseFormat( $format , &$options , $optI , $ifWrite = false ) {
  1464.    
  1465.         $format = substr( $format , $optI );
  1466.        
  1467.         switch ( $format ) {
  1468.             case "_Move_Format":
  1469.            
  1470.                 break;
  1471.             case "_Fileconsistency_Format":
  1472.                 if ( $ifWrite ) {
  1473.                     $this -> writeInt8($options[$optI]);
  1474.                     $this -> writeInt8($options[$optI+1]);
  1475.                     $this -> writeString($options[$optI+2]);               
  1476.                 }
  1477.                    
  1478.                 break;
  1479.             case "_Voicedata_Format":
  1480.                 if ( $ifWrite ) {
  1481.                     $this -> writeInt8($options[$optI]);
  1482.                     $this -> writeInt8($options[$optI+1]);
  1483.                     $this -> writeString($options[$optI+2]);               
  1484.                 }
  1485.            
  1486.                 break;     
  1487.         }
  1488.    
  1489.     }
  1490.     public function parseFormatWrite( $format , &$options ) {
  1491.    
  1492.         switch ( $format ) {
  1493.             case "_RESOURCELIST":
  1494.                 $count = count( $options );
  1495.                 $this -> writeInt16( $count );
  1496.                 for( $i = 0; $i <= $count; $i++ ) {
  1497.                     $this -> writePString( $options[$i][0] );
  1498.                     $this -> writeInt8( $options[$i][1] );
  1499.                     $this -> writeInt16( $options[$i][2] );
  1500.                     $this -> writeInt32( $options[$i][3] );
  1501.                     $this -> writeInt8( $ucFlags = $options[$i][4] );
  1502.                     $ucFlags &= 0xFD;
  1503.                     if ( ( $ucFlags & 0x04 ) !== 0 )
  1504.                         $this -> writeInt16( $options[$i][5] );
  1505.                 }
  1506.                 return $this -> getBuf();
  1507.                 break;
  1508.             case "__MOVE":             
  1509.                 $this -> writeInt8( strlen($options[0]) );     
  1510.                 COM::setAsistMungeTable(1);
  1511.                 $this -> writeString( COM::Munge( $options[0] , $options[1] ) );   
  1512.                 COM::setAsistMungeTable(2);
  1513.                 return $this -> getBuf();      
  1514.                 break;
  1515.             case "_Fileconsistency_Format":
  1516.            
  1517.                 return $this -> getBuf();                  
  1518.                 break;
  1519.             case "_VOICEDATA":
  1520.                 $this -> writeInt16( strlen( $options[0] ) );
  1521.                 $this -> writeString( $options[0] );   
  1522.                 return $this -> getBuf();      
  1523.                 break;     
  1524.         }
  1525.        
  1526.         return $this -> getBuf();      
  1527.    
  1528.     }
  1529.     public function parseFormatRead( $buf , $cmd ) {
  1530.    
  1531.         $format = substr( $format , $optI );
  1532.        
  1533.         switch ( $cmd["params_type"] ) {
  1534.             case "__MOVE":             
  1535.                 $size = $buf -> readInt16();
  1536.                 $prevPos = $buf->bufPos;
  1537.                 $buf -> writeString( $size );
  1538.                 $options  = Array( $buf -> readString( $size ) );
  1539.                 return Array( "cmd" => $cmd , "options" => $options , "options_string" => substr( $buf->buf , $prevPos , $buf -> bufPos - $prevPos ) );    
  1540.                 break;
  1541.             case "_VOICEDATA":
  1542.                 $size = $buf -> readInt16();
  1543.                 $prevPos = $buf->bufPos;
  1544.                 $buf -> writeString( $size );
  1545.                 $options  = Array( $buf -> readString( $size ) );
  1546.                 return Array( "cmd" => $cmd , "options" => $options , "options_string" => substr( $buf->buf , $prevPos , $buf -> bufPos - $prevPos ) );
  1547.                 break;     
  1548.         }
  1549.        
  1550.         return -1;
  1551.    
  1552.     }
  1553.                
  1554.     public function writeCMD( $cmd , $options , $my_type = false ) {
  1555.  
  1556.         $cmd = $this -> getCMD( $cmd );
  1557.         if ( $cmd === false )
  1558.             return false;
  1559.            
  1560.         if ( gettype( $options ) === "string" )
  1561.             $options = Array( $options );
  1562.        
  1563.         $this -> setBuf();
  1564.        
  1565.         $this -> writeInt8( $cmd["Index"] );
  1566.        
  1567.         if ( $my_type ) {
  1568.             $this -> writeString( $options [0] );
  1569.             return $this -> getBuf();
  1570.         }
  1571.                
  1572.         $t_len = strlen( $cmd["params_type"] );
  1573.         $o_len = count( $options );
  1574.        
  1575.         $noParse = false;
  1576.        
  1577.         for ( $i = 0; $i < $t_len; $i++ ) {
  1578.             switch ( $cmd["params_type"][$i] ) {
  1579.                 case "1":
  1580.                     return $this -> getBuf();
  1581.                     break;
  1582.                 case "i":
  1583.                     $this -> writeInt32( $options [$i] );                  
  1584.                     break;
  1585.                 case "s":
  1586.                     $this -> writeInt16( $options [$i] );                  
  1587.                     break;
  1588.                 case "b":
  1589.                     $this -> writeInt8( $options [$i] );                   
  1590.                     break;
  1591.                 case "p":
  1592.                     $this -> writePString( $options [$i] );                
  1593.                     break;
  1594.                 case "n":
  1595.                     $this -> writePString( $options [$i] . "\x0A" );                   
  1596.                     break;
  1597.                 case "_":
  1598.                     return $this -> parseFormatWrite( $cmd["params_type"] , $options );
  1599.                     break;
  1600.                 default:
  1601.                     return false;
  1602.             }          
  1603.         }
  1604.  
  1605.         return $this -> getBuf();
  1606.  
  1607.     }
  1608.     public function readCMD( $buf ) {
  1609.    
  1610.         $cmd = $buf->readInt8();
  1611.        
  1612.         if ( $cmd === 0 )      
  1613.             return -1;     
  1614.        
  1615.         $cmd = $this -> getCMD( $cmd );
  1616.         if ( $cmd === false ) {
  1617.             $buf->movL( 1 );            
  1618.             return 0;      
  1619.         }
  1620.  
  1621.         $t_len = strlen( $cmd["params_type"] );
  1622.         $prevPos = $buf -> bufPos;
  1623.        
  1624.         $options = Array();
  1625.        
  1626.         for ( $i = 0; $i < $t_len; $i++ ) {
  1627.             switch ( $cmd["params_type"][$i] ) {
  1628.                 case "1":
  1629.                     return Array( "cmd" => $cmd , "options" => Null , "options_string" => substr( $buf->buf , $prevPos , $buf -> bufPos - $prevPos ) );
  1630.                     break;
  1631.                 case "i":
  1632.                     $options[] = $buf->readInt32();
  1633.                     break;
  1634.                 case "s":
  1635.                     $options[] = $buf->readInt16();    
  1636.                     break;
  1637.                 case "b":
  1638.                     $options[] = $buf->readInt8();     
  1639.                     break;
  1640.                 case "p":
  1641.                     $options[] = $buf->readPString();
  1642.                     break;
  1643.                 case "n":
  1644.                     $options[] = $buf->readPString();
  1645.                     break;
  1646.                 case "_":
  1647.                     return $this -> parseFormatRead( $buf ,  $cmd );
  1648.                     break;
  1649.                 default:
  1650.                     return -1;     
  1651.             }          
  1652.         }
  1653.        
  1654.         return Array( "cmd" => $cmd , "options" => $options , "options_string" => substr( $buf->buf , $prevPos , $buf -> bufPos - $prevPos ) );
  1655.            
  1656.            
  1657.     }
  1658.    
  1659.  
  1660.     public static $thisCL = Null;  
  1661.     public static function getCL() {
  1662.  
  1663.         ( self::$thisCL === Null ) &&
  1664.         ( self::$thisCL = new self() );
  1665.  
  1666.         return self::$thisCL;
  1667.  
  1668.     }
  1669.    
  1670. }
  1671.  
  1672. class CLIENT_USER_INFO_LIST {
  1673.  
  1674.     public $engine;
  1675.    
  1676.     public $_list_ = Array(
  1677.         "prot" => Array( "string" => "3" , "int" => Null , "float" => Null ) ,
  1678.         "unique" => Array( "string" => "-1" , "int" => Null , "float" => Null ) ,
  1679.         "raw" => Array( "string" => "steam" , "int" => Null , "float" => Null ) ,
  1680.         "cdkey" => Array( "string" => "gqrgoiugerg5487hfgddjfgjfgj4tyru" , "int" => Null , "float" => Null ) ,
  1681.         "prot" => Array( "string" => "3" , "int" => Null , "float" => Null ) ,
  1682.     );
  1683.    
  1684.     public $cvar = Array( "_cl_autowepswitch" , "bottomcolor" , "cl_dlmax" , "cl_lc" , "cl_lw" , "cl_updaterate" , "cl_cmdrate" , "model" , "name" , "topcolor" , "rate" );
  1685. //  $hexSTRING .= "connect 48 ".$unicalID." \"\prot\\3\unique\-1\\raw\steam\cdkey\gqrgoiugerg5487hfgddjfgjfgj4tyru\"
  1686. //  \"\_cl_autowepswitch\\1\bottomcolor\\6\cl_dlmax\\128\cl_lc\\1\cl_lw\\1\cl_updaterate\\20\model\gordon\\name\\".$nick ."\\topcolor\\30\\rate\\1000\"";
  1687.        
  1688.     public function get( $name ) {
  1689.    
  1690.         if ( getType( $name ) === "string" ) {
  1691.        
  1692.             $name = strtolower( $name );
  1693.  
  1694.             return empty( $this -> _list_[$name] ) ? false : $this -> _list_[$name];
  1695.        
  1696.         }
  1697.    
  1698.         return false;
  1699.    
  1700.     }
  1701.     public function check( $name ) {
  1702.  
  1703.         $name = strtolower( $name );
  1704.        
  1705.         return empty( $this -> _list_[$name] ) ? false : true;
  1706.        
  1707.     }
  1708.     public function add( $name , $val ) {
  1709.    
  1710.         $name = strtolower( $name );
  1711.        
  1712.         if ( empty( $this -> _list_[$name] ) ){
  1713.            
  1714.             $this -> _list_[$name] = Array(
  1715.                 "string"    =>  ( (string) $val ) ,
  1716.                 "int"       =>  ( (float) $val ) ,
  1717.                 "float"     =>  ( (float) $val )
  1718.             );
  1719.            
  1720.             return true;
  1721.            
  1722.         } else
  1723.        
  1724.             return false;
  1725.     }
  1726.     public function remove( $name ) {
  1727.    
  1728.         $name = strtolower( $name );
  1729.    
  1730.         if ( empty( $this -> _list_[$name] ) ){
  1731.            
  1732.             unset( $this -> _list_[$name] );
  1733.            
  1734.             return true;
  1735.            
  1736.         } else
  1737.        
  1738.             return false;
  1739.    
  1740.     }
  1741.     public function set( $name , $val ) {
  1742.    
  1743.         $name = strtolower( $name );
  1744.  
  1745.         $this -> _list_[$name] = Array(
  1746.             "string"    =>  ( (string) $val ) ,
  1747.             "int"       =>  ( (float) $val ) ,
  1748.             "float"     =>  ( (float) $val )
  1749.         );         
  1750.            
  1751.         return true;
  1752.        
  1753.     }
  1754.     public function addCVAR( $name ) {
  1755.    
  1756.         $name = strtolower( $name );
  1757.        
  1758.         foreach ( $this->cvar as &$val )
  1759.             if ( $val === $name )
  1760.                 return true;
  1761.            
  1762.         $this->cvar[] = $name;
  1763.            
  1764.         return true;
  1765.        
  1766.     }
  1767.     public function removeCVAR( $name ) {
  1768.    
  1769.         $name = strtolower( $name );
  1770.    
  1771.         foreach ( $this->cvar as $i => &$val )
  1772.             if ( $val === $name ) {
  1773.                 unset($this->cvar[$i]);
  1774.                 return true;
  1775.             }          
  1776.        
  1777.        
  1778.         return false;
  1779.    
  1780.     }
  1781.  
  1782.     public function release() {
  1783.    
  1784.         foreach( $this -> _list_ as &$val ) {
  1785.        
  1786.             $val["int"]     = ( (int) $val["string"] );
  1787.             $val["float"]   = ( (float) $val["string"] );
  1788.        
  1789.         }
  1790.    
  1791.     }
  1792.  
  1793.     public function __construct() {
  1794.    
  1795.         $this -> release();
  1796.    
  1797.     }
  1798.    
  1799.     public static $thisCL = Null;  
  1800.     public static function getCL() {
  1801.  
  1802.         ( self::$thisCL === Null ) &&
  1803.         ( self::$thisCL = new self() );
  1804.  
  1805.         return self::$thisCL;
  1806.  
  1807.     }
  1808.    
  1809. }
  1810. class CLIENT_CVAR_LIST {
  1811.  
  1812.     public $_list_ = Array(
  1813.         "_cl_autowepswitch" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1814.         "_snd_mixahead" => Array( "string" => "0.100" , "int" => Null , "float" => Null ) ,
  1815.         "ambient_fade" => Array( "string" => "100" , "int" => Null , "float" => Null ) ,
  1816.         "ambient_level" => Array( "string" => "0.300" , "int" => Null , "float" => Null ) ,
  1817.         "ati_npatch" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1818.         "bannedcfgfile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1819.         "bgmvolume" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1820.         "bottomcolor" => Array( "string" => "6" , "int" => Null , "float" => Null ) ,
  1821.         "brightness" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1822.         "c_maxdistance" => Array( "string" => "200" , "int" => Null , "float" => Null ) ,
  1823.         "c_maxpitch" => Array( "string" => "90" , "int" => Null , "float" => Null ) ,
  1824.         "c_maxyaw" => Array( "string" => "135" , "int" => Null , "float" => Null ) ,
  1825.         "c_mindistance" => Array( "string" => "30" , "int" => Null , "float" => Null ) ,
  1826.         "c_minpitch" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1827.         "c_minyaw" => Array( "string" => "-135" , "int" => Null , "float" => Null ) ,
  1828.         "cam_command" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1829.         "cam_idealdist" => Array( "string" => "64" , "int" => Null , "float" => Null ) ,
  1830.         "cam_idealpitch" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1831.         "cam_idealyaw" => Array( "string" => "90" , "int" => Null , "float" => Null ) ,
  1832.         "cam_snapto" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1833.         "chase_active" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1834.         "chase_back" => Array( "string" => "100" , "int" => Null , "float" => Null ) ,
  1835.         "chase_right" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1836.         "chase_up" => Array( "string" => "16" , "int" => Null , "float" => Null ) ,
  1837.         "cl_allowdownload" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1838.         "cl_allowupload" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1839.         "cl_anglespeedkey" => Array( "string" => "0.670" , "int" => Null , "float" => Null ) ,
  1840.         "cl_backspeed" => Array( "string" => "400" , "int" => Null , "float" => Null ) ,
  1841.         "cl_bob" => Array( "string" => "0.010" , "int" => Null , "float" => Null ) ,
  1842.         "cl_bobcycle" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  1843.         "cl_bobup" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  1844.         "cl_chasedist" => Array( "string" => "112" , "int" => Null , "float" => Null ) ,
  1845.         "cl_clockreset" => Array( "string" => "0.100" , "int" => Null , "float" => Null ) ,
  1846.         "cl_cmdbackup" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  1847.         "cl_cmdrate" => Array( "string" => "60" , "int" => Null , "float" => Null ) ,
  1848.         "cl_corpsestay" => Array( "string" => "600" , "int" => Null , "float" => Null ) ,
  1849.         "cl_crosshair_color" => Array( "string" => "50" , "int" => Null , "float" => Null ) ,
  1850.         "cl_crosshair_size" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1851.         "cl_crosshair_translucent" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1852.         "cl_dlmax" => Array( "string" => "80" , "int" => Null , "float" => Null ) ,
  1853.         "cl_download_ingame" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1854.         "cl_dynamiccrosshair" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1855.         "cl_filterstuffcmd" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1856.         "cl_fixtimerate" => Array( "string" => "7.500" , "int" => Null , "float" => Null ) ,
  1857.         "cl_forwardspeed" => Array( "string" => "400" , "int" => Null , "float" => Null ) ,
  1858.         "cl_gaitestimation" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1859.         "cl_gg" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1860.         "cl_himodels" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1861.         "cl_idealpitchscale" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  1862.         "cl_lc" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1863.         "cl_logocolor" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1864.         "cl_logofile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1865.         "cl_lw" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1866.         "cl_min_ct" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  1867.         "cl_min_t" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1868.         "cl_minmodels" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1869.         "cl_mousegrab" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1870.         "cl_movespeedkey" => Array( "string" => "0.520" , "int" => Null , "float" => Null ) ,
  1871.         "cl_needinstanced" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1872.         "cl_nosmooth" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1873.         "cl_observercrosshair" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1874.         "cl_pitchdown" => Array( "string" => "89" , "int" => Null , "float" => Null ) ,
  1875.         "cl_pitchspeed" => Array( "string" => "225" , "int" => Null , "float" => Null ) ,
  1876.         "cl_pitchup" => Array( "string" => "89" , "int" => Null , "float" => Null ) ,
  1877.         "cl_pmanstats" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1878.         "cl_radartype" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1879.         "cl_resend" => Array( "string" => "6" , "int" => Null , "float" => Null ) ,
  1880.         "cl_righthand" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1881.         "cl_shadows" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1882.         "cl_showerror" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1883.         "cl_showevents" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1884.         "cl_showfps" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1885.         "cl_showmessages" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1886.         "cl_shownet" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1887.         "cl_sidespeed" => Array( "string" => "400" , "int" => Null , "float" => Null ) ,
  1888.         "cl_slist" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  1889.         "cl_smoothtime" => Array( "string" => "0.100" , "int" => Null , "float" => Null ) ,
  1890.         "cl_solid_players" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1891.         "cl_timeout" => Array( "string" => "60" , "int" => Null , "float" => Null ) ,
  1892.         "cl_updaterate" => Array( "string" => "60" , "int" => Null , "float" => Null ) ,
  1893.         "cl_upspeed" => Array( "string" => "320" , "int" => Null , "float" => Null ) ,
  1894.         "cl_vsmoothing" => Array( "string" => "0.050" , "int" => Null , "float" => Null ) ,
  1895.         "cl_waterdist" => Array( "string" => "4" , "int" => Null , "float" => Null ) ,
  1896.         "cl_weaponlistfix" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1897.         "cl_weather" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1898.         "cl_yawspeed" => Array( "string" => "210" , "int" => Null , "float" => Null ) ,
  1899.         "clientport" => Array( "string" => "27005" , "int" => Null , "float" => Null ) ,
  1900.         "clockwindow" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  1901.         "con_color" => Array( "string" => "255" , "int" => Null , "float" => Null ) ,
  1902.         "con_fastmode" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1903.         "con_mono" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1904.         "con_notifytime" => Array( "string" => "4" , "int" => Null , "float" => Null ) ,
  1905.         "con_shifttoggleconsole" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1906.         "console" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1907.         "coop" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1908.         "crosshair" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1909.         "d_spriteskip" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1910.         "deathmatch" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1911.         "default_fov" => Array( "string" => "90" , "int" => Null , "float" => Null ) ,
  1912.         "dev_overview" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1913.         "developer" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1914.         "direct" => Array( "string" => "0.900" , "int" => Null , "float" => Null ) ,
  1915.         "edgefriction" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  1916.         "ex_interp" => Array( "string" => "0.100" , "int" => Null , "float" => Null ) ,
  1917.         "fakelag" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1918.         "fakeloss" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1919.         "fastsprites" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1920.         "fps_max" => Array( "string" => "101" , "int" => Null , "float" => Null ) ,
  1921.         "fps_override" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1922.         "fs_lazy_precache" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1923.         "fs_perf_warnings" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1924.         "fs_precache_timings" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1925.         "fs_startup_timings" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1926.         "gamma" => Array( "string" => "2.500" , "int" => Null , "float" => Null ) ,
  1927.         "gl_affinemodels" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1928.         "gl_alphamin" => Array( "string" => "0.250" , "int" => Null , "float" => Null ) ,
  1929.         "gl_ansio" => Array( "string" => "16" , "int" => Null , "float" => Null ) ,
  1930.         "gl_clear" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1931.         "gl_cull" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1932.         "gl_dither" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1933.         "gl_flipmatrix" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1934.         "gl_fog" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1935.         "gl_keeptjunctions" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1936.         "gl_lightholes" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1937.         "gl_max_size" => Array( "string" => "512" , "int" => Null , "float" => Null ) ,
  1938.         "gl_monolights" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1939.         "gl_overbright" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1940.         "gl_palette_tex" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1941.         "gl_picmip" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1942.         "gl_polyoffset" => Array( "string" => "0.100" , "int" => Null , "float" => Null ) ,
  1943.         "gl_round_down" => Array( "string" => "3" , "int" => Null , "float" => Null ) ,
  1944.         "gl_spriteblend" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1945.         "gl_vsync" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1946.         "gl_wateramp" => Array( "string" => "0.300" , "int" => Null , "float" => Null ) ,
  1947.         "gl_wireframe" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1948.         "gl_zmax" => Array( "string" => "4096" , "int" => Null , "float" => Null ) ,
  1949.         "gl_ztrick_old" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1950.         "graphheight" => Array( "string" => "64" , "int" => Null , "float" => Null ) ,
  1951.         "hisound" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1952.         "host_framerate" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1953.         "host_killtime" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1954.         "host_limitlocal" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1955.         "host_profile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1956.         "host_speeds" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1957.         "HostMap" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1958.         "hostname" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1959.         "hostport" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1960.         "hpk_maxsize" => Array( "string" => "4" , "int" => Null , "float" => Null ) ,
  1961.         "hud_capturemouse" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1962.         "hud_centerid" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1963.         "hud_deathnotice_time" => Array( "string" => "6" , "int" => Null , "float" => Null ) ,
  1964.         "hud_draw" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1965.         "hud_drawhistory_time" => Array( "string" => "5" , "int" => Null , "float" => Null ) ,
  1966.         "hud_fastswitch" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1967.         "hud_saytext_internal" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1968.         "hud_saytext_time" => Array( "string" => "5" , "int" => Null , "float" => Null ) ,
  1969.         "hud_takesshots" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1970.         "ip" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1971.         "ip_clientport" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1972.         "ip_hostport" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1973.         "ipx_clientport" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1974.         "ipx_hostport" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1975.         "joyadvanced" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1976.         "joyadvaxisr" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1977.         "joyadvaxisu" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1978.         "joyadvaxisv" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1979.         "joyadvaxisx" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1980.         "joyadvaxisy" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1981.         "joyadvaxisz" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1982.         "joyforwardsensitivity" => Array( "string" => "-1" , "int" => Null , "float" => Null ) ,
  1983.         "joyforwardthreshold" => Array( "string" => "0.150" , "int" => Null , "float" => Null ) ,
  1984.         "joyname" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1985.         "joypitchsensitivity" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  1986.         "joypitchthreshold" => Array( "string" => "0.150" , "int" => Null , "float" => Null ) ,
  1987.         "joysidesensitivity" => Array( "string" => "-1" , "int" => Null , "float" => Null ) ,
  1988.         "joysidethreshold" => Array( "string" => "0.150" , "int" => Null , "float" => Null ) ,
  1989.         "joystick" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1990.         "joywwhack1" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1991.         "joywwhack2" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1992.         "joyyawsensitivity" => Array( "string" => "-1" , "int" => Null , "float" => Null ) ,
  1993.         "joyyawthreshold" => Array( "string" => "0.150" , "int" => Null , "float" => Null ) ,
  1994.         "lambert" => Array( "string" => "1.500" , "int" => Null , "float" => Null ) ,
  1995.         "lightgamma" => Array( "string" => "2.500" , "int" => Null , "float" => Null ) ,
  1996.         "loadas8bit" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1997.         "logsdir" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1998.         "lookspring" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  1999.         "lookstrafe" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2000.         "lservercfgfile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2001.         "m_customaccel" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2002.         "m_customaccel_exponent" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2003.         "m_customaccel_max" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2004.         "m_customaccel_scale" => Array( "string" => "0.040" , "int" => Null , "float" => Null ) ,
  2005.         "m_filter" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2006.         "m_forward" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2007.         "m_mousethread_sleep" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  2008.         "m_pitch" => Array( "string" => "0.022" , "int" => Null , "float" => Null ) ,
  2009.         "m_rawinput" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2010.         "m_side" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  2011.         "m_yaw" => Array( "string" => "0.022" , "int" => Null , "float" => Null ) ,
  2012.         "mapchangecfgfile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2013.         "mapcyclefile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2014.         "max_queries_sec" => Array( "string" => "3" , "int" => Null , "float" => Null ) ,
  2015.         "max_queries_sec_global" => Array( "string" => "30" , "int" => Null , "float" => Null ) ,
  2016.         "max_queries_window" => Array( "string" => "60" , "int" => Null , "float" => Null ) ,
  2017.         "max_shells" => Array( "string" => "120" , "int" => Null , "float" => Null ) ,
  2018.         "max_smokepuffs" => Array( "string" => "120" , "int" => Null , "float" => Null ) ,
  2019.         "model" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2020.         "motdfile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2021.         "MP3FadeTime" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  2022.         "MP3Volume" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  2023.         "mp_consistency" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2024.         "mp_decals" => Array( "string" => "300" , "int" => Null , "float" => Null ) ,
  2025.         "mp_footsteps" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2026.         "mp_logecho" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2027.         "mp_logfile" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2028.         "multicastport" => Array( "string" => "27025" , "int" => Null , "float" => Null ) ,
  2029.         "name" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2030.         "net_address" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2031.         "net_chokeloop" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2032.         "net_drawslider" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2033.         "net_graph" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2034.         "net_graphpos" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2035.         "net_graphwidth" => Array( "string" => "150" , "int" => Null , "float" => Null ) ,
  2036.         "net_log" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2037.         "net_scale" => Array( "string" => "5" , "int" => Null , "float" => Null ) ,
  2038.         "net_showdrop" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2039.         "net_showpackets" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2040.         "nosound" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2041.         "password" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2042.         "pausable" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2043.         "port" => Array( "string" => "27015" , "int" => Null , "float" => Null ) ,
  2044.         "r_bmodelinterp" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2045.         "r_cachestudio" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2046.         "r_cullsequencebox" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2047.         "r_decals" => Array( "string" => "4096" , "int" => Null , "float" => Null ) ,
  2048.         "r_detailtextures" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2049.         "r_detailtexturessupported" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2050.         "r_drawentities" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2051.         "r_drawviewmodel" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2052.         "r_dynamic" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2053.         "r_fullbright" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2054.         "r_glowshellfreq" => Array( "string" => "2.200" , "int" => Null , "float" => Null ) ,
  2055.         "r_lightmap" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2056.         "r_mirroralpha" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2057.         "r_mmx" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2058.         "r_norefresh" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2059.         "r_novis" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2060.         "r_speeds" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2061.         "r_traceglow" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2062.         "r_wadtextures" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2063.         "r_wateralpha" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2064.         "rate" => Array( "string" => "25000" , "int" => Null , "float" => Null ) ,
  2065.         "rcon_address" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2066.         "rcon_password" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2067.         "rcon_port" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2068.         "room_delay" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2069.         "room_dlylp" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  2070.         "room_feedback" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2071.         "room_left" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2072.         "room_lp" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2073.         "room_mod" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2074.         "room_off" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2075.         "room_refl" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2076.         "room_rvblp" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2077.         "room_size" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2078.         "room_type" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2079.         "s_show" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2080.         "scr_centertime" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  2081.         "scr_connectmsg" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2082.         "scr_connectmsg1" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2083.         "scr_connectmsg2" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2084.         "scr_ofsx" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2085.         "scr_ofsy" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2086.         "scr_ofsz" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2087.         "scr_printspeed" => Array( "string" => "8" , "int" => Null , "float" => Null ) ,
  2088.         "sdl_double_click_size" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  2089.         "sdl_double_click_time" => Array( "string" => "400" , "int" => Null , "float" => Null ) ,
  2090.         "sensitivity" => Array( "string" => "3" , "int" => Null , "float" => Null ) ,
  2091.         "servercfgfile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2092.         "showpause" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2093.         "skill" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2094.         "skin" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2095.         "snd_noextraupdate" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2096.         "snd_show" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2097.         "speak_enabled" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2098.         "spec_autodirector_internal" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2099.         "spec_drawcone_internal" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2100.         "spec_drawnames_internal" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2101.         "spec_drawstatus_internal" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2102.         "spec_mode_internal" => Array( "string" => "4" , "int" => Null , "float" => Null ) ,
  2103.         "spec_pip" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2104.         "spec_scoreboard" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2105.         "suitvolume" => Array( "string" => "0.250" , "int" => Null , "float" => Null ) ,
  2106.         "sv_accelerate" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  2107.         "sv_aim" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2108.         "sv_airaccelerate" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  2109.         "sv_allow_dlfile" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2110.         "sv_allowdownload" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2111.         "sv_allowupload" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2112.         "sv_bounce" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2113.         "sv_cheats" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2114.         "sv_clienttrace" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2115.         "sv_contact" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2116.         "sv_downloadurl" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2117.         "sv_enableoldqueries" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2118.         "sv_failuretime" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  2119.         "sv_filetransfercompression" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2120.         "sv_filetransfermaxsize" => Array( "string" => "10485760" , "int" => Null , "float" => Null ) ,
  2121.         "sv_filterban" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2122.         "sv_friction" => Array( "string" => "4" , "int" => Null , "float" => Null ) ,
  2123.         "sv_gravity" => Array( "string" => "800" , "int" => Null , "float" => Null ) ,
  2124.         "sv_instancedbaseline" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2125.         "sv_lan" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2126.         "sv_lan_rate" => Array( "string" => "20000" , "int" => Null , "float" => Null ) ,
  2127.         "sv_log_onefile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2128.         "sv_log_singleplayer" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2129.         "sv_logbans" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2130.         "sv_logblocks" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2131.         "sv_logrelay" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2132.         "sv_logsecret" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2133.         "sv_maxrate" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2134.         "sv_maxspeed" => Array( "string" => "320" , "int" => Null , "float" => Null ) ,
  2135.         "sv_maxunlag" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  2136.         "sv_maxupdaterate" => Array( "string" => "30" , "int" => Null , "float" => Null ) ,
  2137.         "sv_maxvelocity" => Array( "string" => "2000" , "int" => Null , "float" => Null ) ,
  2138.         "sv_minrate" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2139.         "sv_minupdaterate" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  2140.         "sv_newunit" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2141.         "sv_outofdatetime" => Array( "string" => "1800" , "int" => Null , "float" => Null ) ,
  2142.         "sv_password" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2143.         "sv_proxies" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2144.         "sv_rcon_banpenalty" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2145.         "sv_rcon_maxfailures" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  2146.         "sv_rcon_minfailures" => Array( "string" => "5" , "int" => Null , "float" => Null ) ,
  2147.         "sv_rcon_minfailuretime" => Array( "string" => "30" , "int" => Null , "float" => Null ) ,
  2148.         "sv_send_logos" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2149.         "sv_send_resources" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2150.         "sv_skycolor_b" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2151.         "sv_skycolor_g" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2152.         "sv_skycolor_r" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2153.         "sv_skyname" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2154.         "sv_skyvec_x" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2155.         "sv_skyvec_y" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2156.         "sv_skyvec_z" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2157.         "sv_spectatormaxspeed" => Array( "string" => "500" , "int" => Null , "float" => Null ) ,
  2158.         "sv_stats" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2159.         "sv_stepsize" => Array( "string" => "18" , "int" => Null , "float" => Null ) ,
  2160.         "sv_stopspeed" => Array( "string" => "100" , "int" => Null , "float" => Null ) ,
  2161.         "sv_timeout" => Array( "string" => "60" , "int" => Null , "float" => Null ) ,
  2162.         "sv_unlag" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2163.         "sv_unlagpush" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2164.         "sv_unlagsamples" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2165.         "sv_uploadmax" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  2166.         "sv_version" => Array( "string" => "112.700" , "int" => Null , "float" => Null ) ,
  2167.         "sv_visiblemaxplayers" => Array( "string" => "-1" , "int" => Null , "float" => Null ) ,
  2168.         "sv_voiceenable" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2169.         "sv_wateraccelerate" => Array( "string" => "10" , "int" => Null , "float" => Null ) ,
  2170.         "sv_wateramp" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2171.         "sv_waterfriction" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2172.         "sv_zmax" => Array( "string" => "4096" , "int" => Null , "float" => Null ) ,
  2173.         "sys_ticrate" => Array( "string" => "100" , "int" => Null , "float" => Null ) ,
  2174.         "team" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2175.         "texgamma" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  2176.         "topcolor" => Array( "string" => "30" , "int" => Null , "float" => Null ) ,
  2177.         "traceralpha" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  2178.         "tracerblue" => Array( "string" => "0.400" , "int" => Null , "float" => Null ) ,
  2179.         "tracergreen" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  2180.         "tracerlength" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  2181.         "traceroffset" => Array( "string" => "30" , "int" => Null , "float" => Null ) ,
  2182.         "tracerred" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  2183.         "tracerspeed" => Array( "string" => "6000" , "int" => Null , "float" => Null ) ,
  2184.         "v_centermove" => Array( "string" => "0.150" , "int" => Null , "float" => Null ) ,
  2185.         "v_centerspeed" => Array( "string" => "500" , "int" => Null , "float" => Null ) ,
  2186.         "v_dark" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2187.         "viewsize" => Array( "string" => "120" , "int" => Null , "float" => Null ) ,
  2188.         "violence_ablood" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2189.         "violence_agibs" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2190.         "violence_hblood" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2191.         "violence_hgibs" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2192.         "voice_avggain" => Array( "string" => "0.500" , "int" => Null , "float" => Null ) ,
  2193.         "voice_clientdebug" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2194.         "voice_dsound" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2195.         "voice_enable" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2196.         "voice_fadeouttime" => Array( "string" => "0.100" , "int" => Null , "float" => Null ) ,
  2197.         "voice_forcemicrecord" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2198.         "voice_inputfromfile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2199.         "voice_loopback" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2200.         "voice_maxgain" => Array( "string" => "5" , "int" => Null , "float" => Null ) ,
  2201.         "voice_modenable" => Array( "string" => "1" , "int" => Null , "float" => Null ) ,
  2202.         "voice_overdrive" => Array( "string" => "2" , "int" => Null , "float" => Null ) ,
  2203.         "voice_overdrivefadetime" => Array( "string" => "0.400" , "int" => Null , "float" => Null ) ,
  2204.         "voice_profile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2205.         "voice_recordtofile" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2206.         "voice_scale" => Array( "string" => "0.750" , "int" => Null , "float" => Null ) ,
  2207.         "voice_showchannels" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2208.         "voice_showincoming" => Array( "string" => "0" , "int" => Null , "float" => Null ) ,
  2209.         "volume" => Array( "string" => "0.800" , "int" => Null , "float" => Null ) ,
  2210.         "waterroom_type" => Array( "string" => "14" , "int" => Null , "float" => Null ) ,
  2211.         "zoom_sensitivity_ratio" => Array( "string" => "1.200" , "int" => Null , "float" => Null ) ,
  2212.     );
  2213.    
  2214.     public $engine;
  2215.    
  2216.     public function getCVAR( $name ) {
  2217.    
  2218.         if ( getType( $name ) === "string" ) {
  2219.        
  2220.             $name = strtolower( $name );
  2221.  
  2222.             return empty( $this -> _list_[$name] ) ? false : $this -> _list_[$name];
  2223.        
  2224.         }
  2225.    
  2226.         return false;
  2227.    
  2228.     }
  2229.     public function checkCVAR( $name ) {
  2230.  
  2231.         $name = strtolower( $name );
  2232.        
  2233.         return empty( $this -> _list_[$name] ) ? false : true;
  2234.        
  2235.     }
  2236.     public function addCVAR( $name , $val ) {
  2237.    
  2238.         $name = strtolower( $name );
  2239.        
  2240.         if ( empty( $this -> _list_[$name] ) ){
  2241.            
  2242.             $this -> _list_[$name] = Array(
  2243.                 "string"    =>  ( (string) $val ) ,
  2244.                 "int"       =>  ( (float) $val ) ,
  2245.                 "float"     =>  ( (float) $val )
  2246.             );
  2247.            
  2248.             return true;
  2249.            
  2250.         } else
  2251.        
  2252.             return false;
  2253.     }
  2254.     public function removeCVAR( $name ) {
  2255.    
  2256.         $name = strtolower( $name );
  2257.    
  2258.         if ( empty( $this -> _list_[$name] ) ){
  2259.            
  2260.             unset( $this -> _list_[$name] );
  2261.            
  2262.             return true;
  2263.            
  2264.         } else
  2265.        
  2266.             return false;
  2267.    
  2268.     }
  2269.     public function setCVAR( $name , $val ) {
  2270.    
  2271.         $name = strtolower( $name );
  2272.  
  2273.         $this -> _list_[$name] = Array(
  2274.             "string"    =>  ( (string) $val ) ,
  2275.             "int"       =>  ( (float) $val ) ,
  2276.             "float"     =>  ( (float) $val )
  2277.         );         
  2278.            
  2279.         return true;
  2280.        
  2281.     }
  2282.     public function releaseCVAR() {
  2283.    
  2284.         foreach( $this -> _list_ as &$val ) {
  2285.        
  2286.             $val["int"]     = ( (int) $val["string"] );
  2287.             $val["float"]   = ( (float) $val["string"] );
  2288.        
  2289.         }
  2290.    
  2291.     }
  2292.  
  2293.     public function __construct() {
  2294.    
  2295.         $this -> releaseCVAR();
  2296.    
  2297.     }
  2298.    
  2299.     public static $thisCL = Null;  
  2300.     public static function getCL() {
  2301.  
  2302.         ( self::$thisCL === Null ) &&
  2303.         ( self::$thisCL = new self() );
  2304.  
  2305.         return self::$thisCL;
  2306.  
  2307.     }
  2308.    
  2309. }
  2310. class CLIENT_CMD_LIST {
  2311.    
  2312.     public $_list_ = Array(
  2313.         "appenddemo" => Null ,
  2314.         "cl_messages" => Null ,
  2315.         "commentator" => Null ,
  2316.         "connect" => "connect" ,
  2317.         "disconnect" => "disconnect" ,
  2318.         "endmovie" => Null ,
  2319.         "entities" => Null ,
  2320.         "fullserverinfo" => Null ,
  2321.         "gamedir" => Null ,
  2322.         "gg" => Null ,
  2323.         "httpstop" => Null ,
  2324.         "list" => Null ,
  2325.         "listdemo" => Null ,
  2326.         "listen" => Null ,
  2327.         "pingservers" => Null ,
  2328.         "playdemo" => Null ,
  2329.         "rcon" => Null ,
  2330.         "record" => Null ,
  2331.         "removedemo" => Null ,
  2332.         "retry" => Null ,
  2333.         "setdemoinfo" => Null ,
  2334.         "slist" => Null ,
  2335.         "snapshot" => Null ,
  2336.         "spec_pos" => Null ,
  2337.         "startmovie" => Null ,
  2338.         "stop" => Null ,
  2339.         "swapdemo" => Null ,
  2340.         "timedemo" => Null ,
  2341.         "upload" => Null ,
  2342.         "viewdemo" => Null ,
  2343.         "voice_showbanned" => Null ,
  2344.         "spec_autodirecto" => Null ,
  2345.         "spec_drawstatus" => Null ,
  2346.         "spec_drawcone" => Null ,
  2347.         "spec_drawnames" => Null ,
  2348.         "togglescores" => Null ,
  2349.         "spec_menu" => Null ,
  2350.         "spec_help" => Null ,
  2351.         "spec_decal" => Null ,
  2352.         "spec_toggleinset" => Null ,
  2353.         "spec_mode" => Null ,
  2354.         "hud_saytext" => Null ,
  2355.         "hideradar" => Null ,
  2356.         "drawradar" => Null ,
  2357.         "clearplayers" => Null ,
  2358.         "trackplayer" => Null ,
  2359.         "adjust_crosshair" => Null ,
  2360.         "invprev" => Null ,
  2361.         "invnext" => Null ,
  2362.         "cancelselect" => Null ,
  2363.         "slot10" => Null ,
  2364.         "slot9" => Null ,
  2365.         "slot8" => Null ,
  2366.         "slot7" => Null ,
  2367.         "slot6" => Null ,
  2368.         "slot5" => Null ,
  2369.         "slot4" => Null ,
  2370.         "slot3" => Null ,
  2371.         "slot2" => Null ,
  2372.         "slot1" => Null ,
  2373.         "-nvgadjust" => Null ,
  2374.         "+nvgadjust" => Null ,
  2375.         "buy" => Null ,
  2376.         "rebuy" => Null ,
  2377.         "autobuy" => Null ,
  2378.         "gunsmoke" => Null ,
  2379.         "-commandmenu" => Null ,
  2380.         "+commandmenu" => Null ,
  2381.         "joyadvancedupdat" => Null ,
  2382.         "force_centerview" => Null ,
  2383.         "snapto" => Null ,
  2384.         "-camdistance" => Null ,
  2385.         "+camdistance" => Null ,
  2386.         "-cammousemove" => Null ,
  2387.         "+cammousemove" => Null ,
  2388.         "firstperson" => Null ,
  2389.         "thirdperson" => Null ,
  2390.         "-camout" => Null ,
  2391.         "+camout" => Null ,
  2392.         "-camin" => Null ,
  2393.         "+camin" => Null ,
  2394.         "-camyawright" => Null ,
  2395.         "+camyawright" => Null ,
  2396.         "-camyawleft" => Null ,
  2397.         "+camyawleft" => Null ,
  2398.         "-campitchdown" => Null ,
  2399.         "+campitchdown" => Null ,
  2400.         "-campitchup" => Null ,
  2401.         "+campitchup" => Null ,
  2402.         "-break" => Null ,
  2403.         "+break" => Null ,
  2404.         "-graph" => Null ,
  2405.         "+graph" => Null ,
  2406.         "-showscores" => Null ,
  2407.         "+showscores" => Null ,
  2408.         "-score" => Null ,
  2409.         "+score" => Null ,
  2410.         "-alt1" => Null ,
  2411.         "+alt1" => Null ,
  2412.         "-reload" => Null ,
  2413.         "+reload" => Null ,
  2414.         "-duck" => Null ,
  2415.         "+duck" => Null ,
  2416.         "-jlook" => Null ,
  2417.         "+jlook" => Null ,
  2418.         "-mlook" => Null ,
  2419.         "+mlook" => Null ,
  2420.         "-klook" => Null ,
  2421.         "+klook" => Null ,
  2422.         "impulse" => Null ,
  2423.         "-jump" => Null ,
  2424.         "+jump" => Null ,
  2425.         "-use" => Null ,
  2426.         "+use" => Null ,
  2427.         "-attack2" => Null ,
  2428.         "+attack2" => Null ,
  2429.         "-attack" => Null ,
  2430.         "+attack" => Null ,
  2431.         "-speed" => Null ,
  2432.         "+speed" => Null ,
  2433.         "-moveright" => Null ,
  2434.         "+moveright" => Null ,
  2435.         "-moveleft" => Null ,
  2436.         "+moveleft" => Null ,
  2437.         "-strafe" => Null ,
  2438.         "+strafe" => Null ,
  2439.         "-lookdown" => Null ,
  2440.         "+lookdown" => Null ,
  2441.         "-lookup" => Null ,
  2442.         "+lookup" => Null ,
  2443.         "-back" => Null ,
  2444.         "+back" => Null ,
  2445.         "-forward" => Null ,
  2446.         "+forward" => Null ,
  2447.         "-right" => Null ,
  2448.         "+right" => Null ,
  2449.         "-left" => Null ,
  2450.         "+left" => Null ,
  2451.         "-movedown" => Null ,
  2452.         "+movedown" => Null ,
  2453.         "-moveup" => Null ,
  2454.         "+moveup" => Null ,
  2455.         "dem_save" => Null ,
  2456.         "dem_start" => Null ,
  2457.         "dem_speed" => Null ,
  2458.         "dem_pause" => Null ,
  2459.         "dem_forcehltv" => Null ,
  2460.         "dem_jump" => Null ,
  2461.         "condump" => Null ,
  2462.         "+voicerecord" => Null ,
  2463.         "-voicerecord" => Null ,
  2464.         "_careeraudio" => Null ,
  2465.         "_restart" => Null ,
  2466.         "_set_vid_level" => Null ,
  2467.         "_setaddons_folde" => Null ,
  2468.         "_setgamedir" => Null ,
  2469.         "_sethdmodels" => Null ,
  2470.         "_setrenderer" => Null ,
  2471.         "_setvideomode" => Null ,
  2472.         "addip" => Null ,
  2473.         "alias" => Null ,
  2474.         "autosave" => Null ,
  2475.         "banid" => Null ,
  2476.         "bind" => Null ,
  2477.         "career" => Null ,
  2478.         "cd" => Null ,
  2479.         "changelevel" => Null ,
  2480.         "changelevel2" => Null ,
  2481.         "clear" => Null ,
  2482.         "cmd" => Null ,
  2483.         "cmdlist" => Null ,
  2484.         "condebug" => Null ,
  2485.         "contimes" => Null ,
  2486.         "cvarlist" => Null ,
  2487.         "delta_clear" => Null ,
  2488.         "delta_stats" => Null ,
  2489.         "demos" => Null ,
  2490.         "dlfile" => Null ,
  2491.         "dropclient" => Null ,
  2492.         "echo" => "echo" ,
  2493.         "envmap" => Null ,
  2494.         "escape" => Null ,
  2495.         "exec" => Null ,
  2496.         "exit" => Null ,
  2497.         "flush" => Null ,
  2498.         "fly" => Null ,
  2499.         "fullinfo" => Null ,
  2500.         "fullupdate" => Null ,
  2501.         "gl_dump" => Null ,
  2502.         "gl_texels" => Null ,
  2503.         "gl_texturemode" => Null ,
  2504.         "god" => Null ,
  2505.         "heartbeat" => Null ,
  2506.         "hideconsole" => Null ,
  2507.         "hpkextract" => Null ,
  2508.         "hpklist" => Null ,
  2509.         "hpkremove" => Null ,
  2510.         "hpkval" => Null ,
  2511.         "interp" => Null ,
  2512.         "kick" => Null ,
  2513.         "kill" => Null ,
  2514.         "listid" => Null ,
  2515.         "listip" => Null ,
  2516.         "load" => Null ,
  2517.         "localinfo" => Null ,
  2518.         "log" => Null ,
  2519.         "logaddress" => Null ,
  2520.         "logaddress_add" => Null ,
  2521.         "logaddress_del" => Null ,
  2522.         "map" => Null ,
  2523.         "maps" => Null ,
  2524.         "maxplayers" => Null ,
  2525.         "mcache" => Null ,
  2526.         "messagemode" => Null ,
  2527.         "messagemode2" => Null ,
  2528.         "motd" => Null ,
  2529.         "motd_write" => Null ,
  2530.         "mp3" => Null ,
  2531.         "new" => Null ,
  2532.         "noclip" => Null ,
  2533.         "notarget" => Null ,
  2534.         "pause" => Null ,
  2535.         "ping" => Null ,
  2536.         "play" => Null ,
  2537.         "playvol" => Null ,
  2538.         "pointfile" => Null ,
  2539.         "quit" => Null ,
  2540.         "reconnect" => Null ,
  2541.         "reload" => Null ,
  2542.         "removeid" => Null ,
  2543.         "removeip" => Null ,
  2544.         "resetrcon" => Null ,
  2545.         "restart" => Null ,
  2546.         "save" => Null ,
  2547.         "say" => "say" ,
  2548.         "say_team" => Null ,
  2549.         "screenshot" => Null ,
  2550.         "sendents" => Null ,
  2551.         "sendres" => Null ,
  2552.         "serverinfo" => Null ,
  2553.         "setinfo" => "setinfo" ,
  2554.         "setmaster" => Null ,
  2555.         "setpause" => Null ,
  2556.         "showinfo" => Null ,
  2557.         "shutdownserver" => Null ,
  2558.         "sizedown" => Null ,
  2559.         "sizeup" => Null ,
  2560.         "soundfade" => Null ,
  2561.         "soundinfo" => Null ,
  2562.         "soundlist" => Null ,
  2563.         "spawn" => Null ,
  2564.         "speak" => Null ,
  2565.         "spk" => Null ,
  2566.         "startdemos" => Null ,
  2567.         "stat" => Null ,
  2568.         "stats" => Null ,
  2569.         "status" => Null ,
  2570.         "stopdemo" => Null ,
  2571.         "stopsound" => Null ,
  2572.         "stuffcmds" => Null ,
  2573.         "tell" => Null ,
  2574.         "timerefresh" => Null ,
  2575.         "toggleconsole" => Null ,
  2576.         "unbind" => Null ,
  2577.         "unbindall" => Null ,
  2578.         "unpause" => Null ,
  2579.         "user" => Null ,
  2580.         "users" => Null ,
  2581.         "version" => Null ,
  2582.         "viewframe" => Null ,
  2583.         "viewmodel" => Null ,
  2584.         "viewnext" => Null ,
  2585.         "viewprev" => Null ,
  2586.         "wait" => Null ,
  2587.         "waveplaylen" => Null ,
  2588.         "writecfg" => Null ,
  2589.         "writeid" => Null ,
  2590.         "writeip" => Null ,
  2591.     );
  2592.    
  2593.    
  2594.     public function getCMD( $name ) {
  2595.    
  2596.         $name = strtolower( $name );
  2597.  
  2598.         return ( empty( $this->_list_[$name] ) ? false : $this->_list_[$name] );
  2599.            
  2600.     }
  2601.     public function checkCMD( $name ) {
  2602.    
  2603.         $name = strtolower( $name );
  2604.  
  2605.         return ( empty( $this->_list_[$name] ) ? false : true );
  2606.        
  2607.     }
  2608.     public function addCMD( $name , $val ) {
  2609.    
  2610.         $name = strtolower( $name );
  2611.        
  2612.         if ( empty( $this->_list_[$name] ) ) {
  2613.        
  2614.             $this->_list_[$name] = $val;
  2615.        
  2616.             return true;
  2617.  
  2618.         } else
  2619.        
  2620.             return false;  
  2621.    
  2622.     }
  2623.     public function removeCMD( $name ) {
  2624.    
  2625.         $name = strtolower( $name );
  2626.        
  2627.         if ( empty( $this->_list_[$name] ) ) {
  2628.        
  2629.             unset( $this->_list_[$name] );
  2630.        
  2631.             return true;
  2632.  
  2633.         } else
  2634.        
  2635.             return false;  
  2636.    
  2637.     }
  2638.    
  2639.     public static $thisCL = Null;  
  2640.     public static function getCL() {
  2641.  
  2642.         ( self::$thisCL === Null ) &&
  2643.         ( self::$thisCL = new self() );
  2644.  
  2645.         return self::$thisCL;
  2646.  
  2647.     }
  2648.  
  2649. }
  2650.  
  2651. class GET_USER_INFO {
  2652.  
  2653.     public $engine;
  2654.     public $userinfolist;
  2655.     public $cvarlist;
  2656.    
  2657.     public function getUserInfoString( $id ) {
  2658.    
  2659.         $user_info_1 = "\"";
  2660.         $user_info_2 = "\"";
  2661.    
  2662.         $protocol = "connect " . $this -> engine -> cl -> protocol . " " . $id;
  2663.    
  2664.         foreach ( $this -> userinfolist -> _list_ as $name => &$val ) {
  2665.        
  2666.             $user_info_1 .= "\\" . $name . "\\" . $val["string"];
  2667.        
  2668.         }
  2669.         $user_info_1 .= "\"";
  2670.        
  2671.         foreach ( $this -> userinfolist -> cvar as &$name ) {
  2672.        
  2673.             $cmd = $this -> cvarlist -> getCVAR( $name );
  2674.            
  2675.             if ( $cmd )
  2676.                 $user_info_2 .= "\\" . $name . "\\" . $cmd["string"];
  2677.        
  2678.         }
  2679.         $user_info_2 .= "\"";
  2680.        
  2681.         return $protocol . " " . $user_info_1 . " " . $user_info_2 . "\x0A";
  2682.    
  2683.     }
  2684.    
  2685.     public function __construct() {
  2686.    
  2687.         global $engine;
  2688.         $this -> engine = $engine;     
  2689.    
  2690.         $this -> userinfolist = CLIENT_USER_INFO_LIST::getCL();
  2691.         $this -> cvarlist = CLIENT_CVAR_LIST::getCL();
  2692.     }  
  2693.    
  2694.     public static $thisCL = Null;
  2695.     public static function getCL() {
  2696.  
  2697.         ( self::$thisCL === Null ) &&
  2698.         ( self::$thisCL = new self() );
  2699.  
  2700.         return self::$thisCL;
  2701.  
  2702.     }
  2703.  
  2704. }
  2705.  
  2706. class TEXECUTE {
  2707.  
  2708.     public $engine;
  2709.  
  2710.     public function execute( $name , $opitons = Null ) {
  2711.    
  2712.         if ( !( gettype( $name ) === "string" ) )
  2713.             return false;
  2714.  
  2715.         if ( (  $opitons ) && ( gettype( $opitons ) === "string" ) )
  2716.             $opitons = Array( $opitons );
  2717.            
  2718.         $name = strtolower( $name );   
  2719.         $name = "exe_" . $name;
  2720.        
  2721.         if ( method_exists ( $this , $name ) ) {
  2722.             if ( $opitons === Null )
  2723.                 $this -> {$name}();
  2724.             else
  2725.                 $this -> {$name}($opitons);
  2726.            
  2727.             return true;
  2728.        
  2729.         } else
  2730.            
  2731.             return false;
  2732.        
  2733.     }
  2734.    
  2735.     public function __construct() {
  2736.    
  2737.         global $engine;
  2738.        
  2739.         $this -> engine = $engine;
  2740.    
  2741.     }
  2742.  
  2743. }
  2744. class CLIENT_CMD_FUNCTIONS extends TEXECUTE {
  2745.  
  2746.     public function exe_setinfo() {
  2747.    
  2748.         if ( $this -> engine -> Cmd_Argc < 2 )
  2749.             return false;
  2750.  
  2751.         $cvar = $this -> engine -> Cvar_Get( $this -> engine -> Cmd_Argv[1] );
  2752.        
  2753.         if ( !$cvar )
  2754.             $this -> engine -> cvarlist -> addCVAR( $this -> engine -> Cmd_Argv[1] , $this -> engine -> Cmd_Argv[2] );
  2755.         else
  2756.             $this -> engine -> Cvar_Set( $this -> engine -> Cmd_Argv[1] , $this -> engine -> Cmd_Argv[2] );
  2757.            
  2758.         $this -> engine -> userinfolist -> addCVAR( $this -> engine -> Cmd_Argv[1] );
  2759.        
  2760.     }
  2761.     public function exe_echo() {
  2762.    
  2763.         if ( $this -> engine -> Cmd_Argc < 1 )
  2764.             return false;
  2765.    
  2766.         $text = "";
  2767.    
  2768.         for( $i = 1; $i < $this -> engine -> Cmd_Argc; $i++ )
  2769.             $text .= $this -> engine -> Cmd_Argv[$i] . " ";
  2770.        
  2771.         $this -> engine -> console -> print_str( $text );
  2772.    
  2773.     }
  2774.     public function exe_say() {
  2775.    
  2776.         $this -> engine -> clc -> execute( "STRINGCMD" , $this -> engine -> Cmd_Args );
  2777.        
  2778.     }
  2779.     public function exe_connect() {
  2780.    
  2781.         if ( $this -> engine -> server -> set( preg_replace( "/\s*connect\s*/si" , "" , $this -> engine -> Cmd_Args ) ) ) {
  2782.        
  2783.             $this -> engine -> net -> connect();
  2784.            
  2785.             return true;
  2786.        
  2787.         } else
  2788.             return false;
  2789.    
  2790.     }
  2791.     public function exe_disconnect() {
  2792.    
  2793.         $this -> engine -> net -> disconnect();
  2794.    
  2795.     }
  2796.    
  2797.    
  2798.     public static $thisCL = Null;  
  2799.     public static function getCL() {
  2800.  
  2801.         ( self::$thisCL === Null ) &&
  2802.         ( self::$thisCL = new self() );
  2803.  
  2804.         return self::$thisCL;
  2805.  
  2806.     }
  2807.    
  2808. }
  2809. class CLIENT_CLC_FUNCTIONS extends TEXECUTE {
  2810.    
  2811.     private $clc;
  2812.     private $net;
  2813.  
  2814.     public function exe_stringcmd( $opitons ) {
  2815.    
  2816.         $cmdString = $this -> clc -> writeCMD( "STRINGCMD" , $opitons );
  2817.  
  2818.         $this -> net -> add( $cmdString );
  2819.    
  2820.     }
  2821.     public function exe_resourcelist( $options ) {
  2822.  
  2823.         $cmdString = $this -> clc -> writeCMD( "RESOURCELIST" , $options );
  2824.        
  2825.         $this -> net -> add( $cmdString ); 
  2826.        
  2827.     }
  2828.     public function exe_voicedata( $opitons ) {
  2829.  
  2830.         $cmdString = $this -> clc -> writeCMD( "VOICEDATA" , $opitons );
  2831.        
  2832.         $this -> net -> add( $cmdString );
  2833.        
  2834.     }
  2835.     public function exe_requestcvarvalue( $opitons ) {
  2836.    
  2837.         $cmdString = $this -> clc -> writeCMD( "REQUESTCVARVALUE" , $opitons );
  2838.        
  2839.         $this -> net -> add( $cmdString );
  2840.        
  2841.     }
  2842.     public function exe_requestcvarvalue2( $opitons ) {
  2843.    
  2844.         $cmdString = $this -> clc -> writeCMD( "REQUESTCVARVALUE2" , $opitons );
  2845.         //echo COM::showHtmlContent($cmdString)."\n";
  2846.         $this -> net -> add( $cmdString );
  2847.        
  2848.     }
  2849.    
  2850.     public function __construct() {
  2851.    
  2852.         $this -> clc = CLC_CMD::getCL();
  2853.         $this -> net = NET::getCL();
  2854.    
  2855.         parent::__construct();
  2856.        
  2857.     }
  2858.    
  2859.     public static $thisCL = Null;  
  2860.     public static function getCL() {
  2861.  
  2862.         ( self::$thisCL === Null ) &&
  2863.         ( self::$thisCL = new self() );
  2864.  
  2865.         return self::$thisCL;
  2866.  
  2867.     }
  2868.    
  2869. }
  2870. class CLIENT_SVC_FUNCTIONS_old extends TEXECUTE {
  2871.    
  2872.     public function exe_bad() {
  2873.    
  2874.         $this -> engine -> console -> print_str( "SERVER send BAD command" );
  2875.    
  2876.     }
  2877.     public function exe_nop() {
  2878.    
  2879.    
  2880.     }
  2881.     public function exe_stufftext( $options ) {
  2882.    
  2883.         if ( !( gettype($options) === "string" ) )
  2884.             $options = $options[0];
  2885.            
  2886.         echo "SVC_STUFFTEXT " . $options ."\n";
  2887.        
  2888.         $this -> engine -> CBuf_AddText( $options , "svc_stufftext" );
  2889.    
  2890.     }
  2891.     public function exe_print( $options ) {
  2892.    
  2893.         if ( !( gettype($options) === "string" ) )
  2894.             $options = $options[0];
  2895.            
  2896.         $this -> engine -> console -> print_str( $options );
  2897.    
  2898.     }
  2899.     public function exe_sendcvarvalue( $options ) {
  2900.    
  2901.         if ( empty( $options[0] ) )
  2902.             return false;
  2903.        
  2904.         $name = $options[0];
  2905.        
  2906.         $cvar = $this -> engine -> Cvar_Get( $name );      
  2907.         if ( !$cmd )
  2908.             return false;
  2909.            
  2910.         $cvar = $cvar["string"];
  2911.        
  2912.         $this -> engine -> clc -> execute( "REQUESTCVARVALUE" , Array( $cvar ) );
  2913.    
  2914.     }
  2915.     public function exe_sendcvarvalue2( $options ) {
  2916.    
  2917.         if ( empty( $options[1] ) )
  2918.             return false;
  2919.        
  2920.         $request_id = $options[0];
  2921.         $name = $options[1];
  2922.        
  2923.         $cvar = $this -> engine -> Cvar_Get( $name );      
  2924.  
  2925.         if ( !$cvar )
  2926.             return false;
  2927.            
  2928.         $cvar = $cvar["string"];
  2929.  
  2930.         echo "SVC_SENDCVARVALUE2 " . $name ."\n";  
  2931.        
  2932.         $this -> engine -> clc -> execute( "REQUESTCVARVALUE2" , Array( $request_id , $name , $cvar ) );
  2933.    
  2934.     }
  2935.     public function exe_disconnect( $options ) {
  2936.    
  2937.         if ( !( gettype($options) === "string" ) )
  2938.             $options = $options[0];
  2939.            
  2940.         $this -> engine -> CBuf_AddText( "disconnect" , "svc_disconnect" );
  2941.            
  2942.         $this -> engine -> console -> print_str( $options );
  2943.    
  2944.     }  
  2945.     public function exe_serverinfo( $options ) {
  2946.         var_dump($options);
  2947.         $this -> engine -> cl -> servercount = $options[1];
  2948.         $this -> engine -> cl -> checksum = $options[2];
  2949.         $this -> engine -> cl -> playernum = $options[3];
  2950.         $this -> engine -> cl -> maxclients = $options[4];
  2951.         $this -> engine -> clgame -> maxEntities = $options[5];
  2952.         $this -> engine -> clgame -> mapname = $options[6];
  2953.         $this -> engine -> clgame -> maptitle = $options[7];
  2954.         $this -> engine -> clgame -> maptitle = $options[8];
  2955.         $this -> engine -> cl -> background = $options[9];
  2956.         $this -> engine -> clgame -> gamefolder = $options[10];
  2957.         $this -> engine -> clgame -> features = $options[11];  
  2958.     }
  2959.    
  2960.     public function __construct() {
  2961.        
  2962.         parent::__construct();
  2963.        
  2964.     }
  2965.    
  2966.     public static $thisCL = Null;  
  2967.     public static function getCL() {
  2968.  
  2969.         ( self::$thisCL === Null ) &&
  2970.         ( self::$thisCL = new self() );
  2971.  
  2972.         return self::$thisCL;
  2973.  
  2974.     }
  2975.    
  2976. }
  2977.  
  2978. class CLIENT_SVC_FUNCTIONS {   
  2979.     public $engine;
  2980.     public $buf;
  2981.     static $svc_list = Array( 0=>"svc_bad",1=>"svc_nop",2=>"svc_disconnect",3=>"svc_event",4=>"svc_version",5=>"svc_setview",6=>"svc_sound",7=>"svc_time",8=>"svc_print",9=>"svc_stufftext",10=>"svc_setangle",11=>"svc_serverinfo",12=>"svc_lightstyle",13=>"svc_updateuserinfo",14=>"svc_deltadescription",15=>"svc_clientdata",16=>"svc_stopsound",17=>"svc_pings",18=>"svc_particle",19=>"svc_damage",20=>"svc_spawnstatic",21=>"svc_event_reliable",22=>"svc_spawnbaseline",23=>"svc_tempentity",24=>"svc_setpause",25=>"svc_signonnum",26=>"svc_centerprint",27=>"svc_killedmonster",28=>"svc_foundsecret",29=>"svc_spawnstaticsound",30=>"svc_intermission",31=>"svc_finale",32=>"svc_cdtrack",33=>"svc_restore",34=>"svc_cutscene",35=>"svc_weaponanim",36=>"svc_decalname",37=>"svc_roomtype",38=>"svc_addangle",39=>"svc_newusermsg",40=>"svc_packetentities",41=>"svc_deltapacketentities",42=>"svc_choke",43=>"svc_resourcelist",44=>"svc_newmovevars",45=>"svc_resourcerequest",46=>"svc_customization",47=>"svc_crosshairangle",48=>"svc_soundfade",49=>"svc_filetxferfailed",50=>"svc_hltv",51=>"svc_director",52=>"svc_voiceinit",53=>"svc_voicedata",54=>"svc_sendextrainfo",55=>"svc_timescale",56=>"svc_resourcelocation",57=>"svc_sendcvarvalue",58=>"svc_sendcvarvalue2" );
  2982.     public function setBuf( $buf ) {
  2983.    
  2984.         $this->buf = $buf;
  2985.    
  2986.     }
  2987.     public function read( $cmdID = false ) {
  2988.    
  2989.         if ( $cmdID === false )
  2990.             $cmd = $this->buf->readInt8();
  2991.         else
  2992.             $cmd = $cmdID;
  2993.    
  2994.         if ( empty( self::$svc_list[$cmd] ) ) {
  2995.             if ( $cmdID === false )
  2996.                 $this->buf->movL(1);
  2997.             return false;
  2998.         }
  2999.        
  3000.         $name = strtolower( self::$svc_list[$cmd] );
  3001.        
  3002.         echo " >>>  " . $name . "\n";
  3003.        
  3004.         if ( method_exists( $this , $name ) )
  3005.             $this->{$name}();
  3006.         else
  3007.             return 0;
  3008.        
  3009.         return true;
  3010.    
  3011.     }
  3012.     public function __construct() {
  3013.    
  3014.         global $engine;
  3015.        
  3016.         $this -> engine = $engine;
  3017.        
  3018.         $this -> buf = NET_BUFER_IN::getCL();
  3019.        
  3020.     }
  3021.     public static $thisCL = Null;  
  3022.     public static function getCL() {
  3023.  
  3024.         ( self::$thisCL === Null ) &&
  3025.         ( self::$thisCL = new self() );
  3026.  
  3027.         return self::$thisCL;
  3028.  
  3029.     }
  3030.    
  3031.    
  3032.    
  3033.     public function svc_stufftext() {
  3034.    
  3035.         $s = $this->buf->readPString();
  3036.    
  3037.         echo "SVC_STUFFTEXT " . $s ."\n";  
  3038.         //--------------------------------------------
  3039.         if ( strpos( "connect" , $s ) !== false )
  3040.             return;
  3041.         //--------------------------------------------
  3042.         $this -> engine -> CBuf_AddText( $s , "svc_stufftext" );
  3043.    
  3044.     }
  3045.     public function svc_print() {
  3046.        
  3047.         $s = $this->buf->readPString();
  3048.        
  3049.         $this -> engine -> console -> print_str( $s );
  3050.    
  3051.     }
  3052.     public function svc_sendcvarvalue() {
  3053.    
  3054.         $name = $this->buf->readPString();     
  3055.        
  3056.         $cvar = $this -> engine -> Cvar_Get( $name );      
  3057.         if ( !$cmd )
  3058.             return false;
  3059.            
  3060.         $cvar = $cvar["string"];
  3061.        
  3062.         $this -> engine -> clc -> execute( "REQUESTCVARVALUE" , Array( $cvar ) );
  3063.    
  3064.     }
  3065.     public function svc_sendcvarvalue2() {
  3066.    
  3067.         $request_id = $this->buf->readInt32();
  3068.         $name = $this->buf->readPString();
  3069.        
  3070.         $cvar = $this -> engine -> Cvar_Get( $name );      
  3071.  
  3072.         if ( !$cvar )
  3073.             return false;
  3074.            
  3075.         $cvar = $cvar["string"];
  3076.  
  3077.         echo "SVC_SENDCVARVALUE2 " . $name ."\n";  
  3078.        
  3079.         $this -> engine -> clc -> execute( "REQUESTCVARVALUE2" , Array( $request_id , $name , $cvar ) );
  3080.    
  3081.     }
  3082.     public function svc_disconnect() {
  3083.            
  3084.         $s = $this->buf->readPString();
  3085.        
  3086.         $this -> engine -> CBuf_AddText( "disconnect" , "svc_disconnect" );
  3087.            
  3088.         $this -> engine -> console -> print_str( $s );
  3089.    
  3090.     }
  3091.     public function svc_serverinfo( $options ) {
  3092.        
  3093.         $protocol = $this->buf->readInt32();
  3094.         $this -> engine -> cl -> servercount = $this->buf->readInt32();
  3095.         $this -> engine -> cl -> checksum = $this->buf->readInt32();
  3096.         $usedpadding = $this->buf->readString(0x10);       
  3097.         $this -> engine -> cl -> playernum = $this->buf->readInt8();
  3098.         $this -> engine -> cl -> maxclients = $this->buf->readInt8();
  3099.         $this -> engine -> clgame -> maxEntities = $this->buf->readInt8();
  3100.        
  3101.         $this -> engine -> clgame -> maptitle = $this->buf->readPString();
  3102.         $this -> engine -> clgame -> hostname = $this->buf->readPString();
  3103.         $this -> engine -> cl -> background = $this->buf->readPString();
  3104.         $this -> engine -> clgame -> gamefolder = $this->buf->readPString();
  3105.         $this -> engine -> clgame -> features = $this->buf->readInt8();
  3106.        
  3107.        
  3108.         echo $this -> engine -> clgame -> maptitle."\n";
  3109.         echo $this -> engine -> clgame -> hostname."\n";
  3110.         echo $this -> engine -> cl -> background."\n";
  3111.         echo $this -> engine -> clgame -> gamefolder."\n";
  3112.        
  3113.     }
  3114.     public function svc_sendextrainfo() {
  3115.        
  3116.         $this->buf->readPString();
  3117.         $this->buf->readInt8();
  3118.    
  3119.     }
  3120.     public function _svc_deltadescription() {
  3121.        
  3122.         $event_name = $this->buf->readPString();
  3123.        
  3124.         $head = $this->buf->readInt8();
  3125.         $name = $this->buf->readPString();
  3126.        
  3127.         $numDelta = $this->buf->readInt16();
  3128.        
  3129.         $c = $this->buf->getBuf();
  3130.         $this->buf->setBuf( substr( $c , strpos( $c , "\x09fullserverinfo" ) ) );
  3131.         $this->buf->setCursor(0);
  3132.        
  3133.         //echo COM::showHex($c)."\n";
  3134.         //echo COM::showHtmlContent( substr( $c , strpos( $c , "\x09fullserverinfo" ) ) )."\n";
  3135.        
  3136.        
  3137.         /*
  3138.         echo $event_name."\n";
  3139.         echo $head."\n";
  3140.         echo $name."\n";
  3141.         echo $numDelta."\n";
  3142.         */
  3143.            
  3144.     }
  3145.     public function svc_updateuserinfo() {
  3146.        
  3147.         $player_id = $this->buf->readInt8();
  3148.         $player_uid = $this->buf->readInt32();
  3149.         $player_info = $this->buf->readPString();
  3150.         $player_info_2 = $this->buf->readString(16);
  3151.        
  3152.         //echo $player_id."\n";
  3153.         //echo $player_uid."\n";
  3154.         echo $player_info."\n";
  3155.         //echo $player_info_2."\n";
  3156.    
  3157.     }
  3158.     public function svc_resourcerequest() {
  3159.        
  3160.         $ServerCount = $this->buf->readInt32();
  3161.         $Nil_Var = $this->buf->readInt32();
  3162.         $Sign = $this->buf->readInt8();
  3163.        
  3164.         if ( $Sign === 0x2B ) {
  3165.        
  3166.             $Site = "";
  3167.        
  3168.         } else
  3169.         if ( $Sign === 0x38 ) {
  3170.        
  3171.             $Site = $this->buf->readPString();
  3172.        
  3173.             $Sign = $this->buf->readInt8();
  3174.  
  3175.         }
  3176.        
  3177.         $this->buf->readBitsBegin();
  3178.  
  3179.         $SomeMaxValue = $this->buf->readBits( 0x0C );
  3180.  
  3181.         echo "ServerCount => " . $ServerCount . "\n";
  3182.         echo "Nil_Var => " . $Nil_Var . "\n";
  3183.         echo "Sign => " . $Sign . "\n";
  3184.         echo "Site => " . $Site . "\n";
  3185.         echo "SomeMaxValue => " . $SomeMaxValue . "\n";
  3186.  
  3187.         $ConsistencyData = Array();
  3188.        
  3189.         for ( $i = 0; $i < $SomeMaxValue; $i++ ) {
  3190.        
  3191.             $ConsistencyData[$i] = Array();
  3192.            
  3193.             $ConsistencyData[$i]["type"] = $this->buf->readBits( 0x04 );
  3194.            
  3195.             //$this->buf->readBitsEnd();
  3196.            
  3197.             $ConsistencyData[$i]["szFileName"] = $this->buf->readBitPString();//readPString();
  3198.        
  3199.             //$this->buf->readBitsBegin();
  3200.        
  3201.             $ConsistencyData[$i]["nIndex"] = $this->buf->readBits( 0x0C );
  3202.        
  3203.             $ConsistencyData[$i]["nDownloadSize"] = $this->buf->readBits( 0x18 );
  3204.        
  3205.             $ConsistencyData[$i]["ucFlags"] = $this->buf->readBits( 0x03 );
  3206.                
  3207.             if ( $this->buf->readBits( 0x01 ) === 1 )
  3208.                
  3209.                 $ConsistencyData[$i]["rguc_reserved"] = $this->buf->readBitBufferByte( 0x20 );
  3210.            
  3211.             else
  3212.            
  3213.                 $ConsistencyData[$i]["rguc_reserved"] = false;
  3214.            
  3215.            
  3216.             echo "ConsistencyData[ ".$i." ]->type => " . $ConsistencyData[$i]["type"] . "\n";
  3217.             echo "ConsistencyData[ ".$i." ]->szFileName => " . $ConsistencyData[$i]["szFileName"] . "\n";
  3218.             echo "ConsistencyData[ ".$i." ]->nIndex => " . $ConsistencyData[$i]["nIndex"] . "\n";
  3219.             echo "ConsistencyData[ ".$i." ]->nDownloadSize => " . $ConsistencyData[$i]["nDownloadSize"] . "\n";
  3220.             echo "ConsistencyData[ ".$i." ]->ucFlags => " . $ConsistencyData[$i]["ucFlags"] . "\n";
  3221.             echo "ConsistencyData[ ".$i." ]->rguc_reserved => " . $ConsistencyData[$i]["rguc_reserved"] . "\n";
  3222.            
  3223.         }
  3224.                
  3225.         $id = 0;
  3226.    
  3227.         if ( $this->buf->readBits( 0x01 ) === 1 )
  3228.            
  3229.             while( $this->buf->readBits( 0x01 ) === 1 ) {
  3230.                    
  3231.                 if ( !( $this->buf->readBits( 0x01 ) === 1 ) )
  3232.                
  3233.                     $id = ( $m = $this->buf->readBits( 0x0A ) );
  3234.                
  3235.                 else
  3236.                
  3237.                     $id += ( $d = $this->buf->readBits( 0x05 ) );
  3238.        
  3239.                 $ConsistencyData[$id]["advr"] = true;
  3240.                 echo "ConsistencyData[ ".$id." ] = true;\n";
  3241.  
  3242.             }
  3243.            
  3244.         $this->buf->readBitsEnd();
  3245.         $Sign = $this->buf->readInt8();
  3246.  
  3247.     }
  3248.     public function svc_resourcelist() {
  3249.         //return false;
  3250.        
  3251.         echo ":D:D:D:D\n";
  3252.         echo ":D:D:D:D\n";
  3253.         echo ":D:D:D:D\n";
  3254.        
  3255.         echo COM::showHex($this->buf->readString(128)) . "\n";
  3256.         $this->buf->movL(128);
  3257.         echo $this->buf->readString(128) . "\n";
  3258.         $this->buf->movL(128);
  3259.        
  3260.         $resource = Array();
  3261.        
  3262.         $this->buf->readBitsBegin();
  3263.        
  3264.         $count = $this->buf->readBits( 0x0C );
  3265.         echo $count."\n";
  3266.        
  3267.         for ( $i=0; $i<$count; $i++ ) {
  3268.        
  3269.             //$this->buf->readBitsBegin();
  3270.             $resource[$i]["type"] = $this->buf->readBits( 4 ); 
  3271.             $this->buf->readBitsEnd();
  3272.             $resource[$i]["name"] = $this->buf->readPString();
  3273.         echo COM::showHex($this->buf->readString(128)) . "\n";
  3274.         $this->buf->movL(128);
  3275.             $this->buf->readBitsBegin();
  3276.             $resource[$i]["index"] = $this->buf->readBits( 12 );           
  3277.             $resource[$i]["download_size"] = $this->buf->readBits( 24 );
  3278.             $resource[$i]["uc_flags"] = $this->buf->readBits( 3 );
  3279.            
  3280.             if ( $resource[$i]["uc_flags"] & 4 <> 0 ) {
  3281.                 $resource[$i]["rgucMD5_hash"] = $this->buf->readBits( 16 );
  3282.             }
  3283.            
  3284.             $resource[$i]["if_rguc_reserved"] = $this->buf->readOneBitBool();
  3285.             if ( $resource[$i]["if_rguc_reserved"] ) {
  3286.                 $resource[$i]["rguc_reserved"] = $this->buf->readBits( 32 );           
  3287.             }
  3288.            
  3289.             $this->buf->readBitsEnd();
  3290.         echo COM::showHex($this->buf->readString(128)) . "\n";
  3291.         $this->buf->movL(128);
  3292.            
  3293.  
  3294.             echo $resource[$i]["type"] . "\n";
  3295.             echo $resource[$i]["name"] . "\n";
  3296.             echo $resource[$i]["index"] . "\n";
  3297.             echo $resource[$i]["download_size"] . "\n";
  3298.             echo $resource[$i]["uc_flags"] . "\n";
  3299.             echo "\n";
  3300.            
  3301.            
  3302.         }
  3303.        
  3304.         if ( $this->buf->readOneBitBool() ) {
  3305.             while( $this->buf->readOneBitBool() ) {
  3306.                 if ( $this->buf->readOneBitBool() ) {
  3307.                     $this->buf->readBits( 5 );                 
  3308.                 } else {
  3309.                     $this->buf->readBits( 10 );                        
  3310.                 }          
  3311.             }          
  3312.         }
  3313.            
  3314.         $this->buf->readBitsEnd();
  3315.    
  3316.         echo ":Ds:D:D:D\n";
  3317.         echo ":Ds:D:D:D\n";
  3318.         echo ":Ds:D:D:D\n";
  3319.     }
  3320.    
  3321. }
  3322. class CLIENT_USER_MESSAGE_FUNCTIONS {  
  3323.     public $engine;
  3324.     public $buf;
  3325.     public $user_message_list = Array( 65=>Array("Name"=>"ReqState","Size"=>"0"),64=>Array("Name"=>"VoiceMask","Size"=>"8"),96=>Array("Name"=>"ShowMenu","Size"=>"-1"),134=>Array("Name"=>"Scenario","Size"=>"-1"),133=>Array("Name"=>"TaskTime","Size"=>"4"),138=>Array("Name"=>"BarTime2","Size"=>"4"),108=>Array("Name"=>"BarTime","Size"=>"2"),101=>Array("Name"=>"RoundTime","Size"=>"2"),104=>Array("Name"=>"BlinkAcct","Size"=>"1"),102=>Array("Name"=>"Money","Size"=>"5"),107=>Array("Name"=>"StatusIcon","Size"=>"-1"),77=>Array("Name"=>"TextMsg","Size"=>"-1"),83=>Array("Name"=>"DeathMsg","Size"=>"-1"),105=>Array("Name"=>"StatusValue","Size"=>"-1"),106=>Array("Name"=>"StatusText","Size"=>"-1"),82=>Array("Name"=>"GameTitle","Size"=>"1"),145=>Array("Name"=>"HudTextArgs","Size"=>"-1"),74=>Array("Name"=>"HudTextPro","Size"=>"-1"),75=>Array("Name"=>"HudText","Size"=>"-1"),69=>Array("Name"=>"FlashBat","Size"=>"1"),68=>Array("Name"=>"Flashlight","Size"=>"2"),103=>Array("Name"=>"ArmorType","Size"=>"1"),72=>Array("Name"=>"Battery","Size"=>"2"),73=>Array("Name"=>"Train","Size"=>"1"),67=>Array("Name"=>"Geiger","Size"=>"1"),100=>Array("Name"=>"SendAudio","Size"=>"-1"),76=>Array("Name"=>"SayText","Size"=>"-1"),129=>Array("Name"=>"ReceiveW","Size"=>"1"),122=>Array("Name"=>"ClCorpse","Size"=>"-1"),84=>Array("Name"=>"ScoreAttrib","Size"=>"2"),112=>Array("Name"=>"Radar","Size"=>"7"),71=>Array("Name"=>"Damage","Size"=>"12"),70=>Array("Name"=>"Health","Size"=>"1"),110=>Array("Name"=>"Crosshair","Size"=>"1"),99=>Array("Name"=>"AmmoX","Size"=>"2"),94=>Array("Name"=>"HideWeapon","Size"=>"1"),93=>Array("Name"=>"ItemPickup","Size"=>"-1"),92=>Array("Name"=>"WeapPickup","Size"=>"1"),91=>Array("Name"=>"AmmoPickup","Size"=>"2"),78=>Array("Name"=>"WeaponList","Size"=>"-1"),66=>Array("Name"=>"CurWeapon","Size"=>"3"),111=>Array("Name"=>"NVGToggle","Size"=>"1"),139=>Array("Name"=>"ItemStatus","Size"=>"1"),141=>Array("Name"=>"BotProgress","Size"=>"-1"),137=>Array("Name"=>"SpecHealth2","Size"=>"2"),136=>Array("Name"=>"BuyClose","Size"=>"0"),118=>Array("Name"=>"TutorClose","Size"=>"-1"),117=>Array("Name"=>"TutorState","Size"=>"-1"),116=>Array("Name"=>"TutorLine","Size"=>"-1"),115=>Array("Name"=>"TutorText","Size"=>"-1"),114=>Array("Name"=>"VGUIMenu","Size"=>"-1"),127=>Array("Name"=>"ForceCam","Size"=>"3"),119=>Array("Name"=>"AllowSpec","Size"=>"1"),113=>Array("Name"=>"Spectator","Size"=>"2"),140=>Array("Name"=>"Location","Size"=>"-1"),86=>Array("Name"=>"TeamInfo","Size"=>"-1"),87=>Array("Name"=>"TeamScore","Size"=>"-1"),85=>Array("Name"=>"ScoreInfo","Size"=>"9"),90=>Array("Name"=>"ServerName","Size"=>"-1"),89=>Array("Name"=>"MOTD","Size"=>"-1"),144=>Array("Name"=>"ShowTimer","Size"=>"0"),143=>Array("Name"=>"Fog","Size"=>"7"),142=>Array("Name"=>"Brass","Size"=>"-1"),135=>Array("Name"=>"BotVoice","Size"=>"2"),132=>Array("Name"=>"ShadowIdx","Size"=>"4"),131=>Array("Name"=>"CZCareerHUD","Size"=>"-1"),124=>Array("Name"=>"HostageK","Size"=>"1"),123=>Array("Name"=>"HostagePos","Size"=>"8"),128=>Array("Name"=>"ADStop","Size"=>"0"),121=>Array("Name"=>"BombPickup","Size"=>"0"),120=>Array("Name"=>"BombDrop","Size"=>"7"),109=>Array("Name"=>"ReloadSound","Size"=>"2"),126=>Array("Name"=>"SpecHealth","Size"=>"1"),125=>Array("Name"=>"HLTV","Size"=>"2"),95=>Array("Name"=>"SetFOV","Size"=>"1"),81=>Array("Name"=>"ViewMode","Size"=>"0"),80=>Array("Name"=>"InitHUD","Size"=>"0"),88=>Array("Name"=>"GameMode","Size"=>"1"),79=>Array("Name"=>"ResetHUD","Size"=>"0"),98=>Array("Name"=>"ScreenFade","Size"=>"10",) );
  3326.     public function setBuf( $buf ) {
  3327.    
  3328.         $this->buf = $buf;
  3329.    
  3330.     }
  3331.     public function read( $cmdID = false ) {
  3332.    
  3333.         if ( $cmdID === false )
  3334.             $cmd = $this->buf->readInt8();
  3335.         else
  3336.             $cmd = $cmdID;
  3337.    
  3338.         if ( empty( self::$user_message_list[$cmd] ) ) {
  3339.             if ( $cmdID === false )
  3340.                 $this->buf->movL(1);
  3341.             return false;
  3342.         }
  3343.        
  3344.         $name = "user_msg_".stretolower( self::$user_message_list[$cmd]["Name"] );
  3345.         $size = ( self::$user_message_list[$cmd]["Size"] === -1 ) ? $this->buf->readInt8() : self::$user_message_list[$cmd]["Size"];
  3346.         $data = $this->buf->readString( $size );
  3347.    
  3348.         echo " >>>  " . $name . "\n";
  3349.        
  3350.        
  3351.         if ( method_exists( $this , $name ) )
  3352.             $this->{$name}( $name , $size , $data );
  3353.         else
  3354.             return 0;
  3355.        
  3356.         return true;
  3357.    
  3358.     }
  3359.     public function __construct() {
  3360.    
  3361.         global $engine;
  3362.        
  3363.         $this -> engine = $engine;
  3364.        
  3365.         $this -> buf = NET_BUFER_IN::getCL();
  3366.        
  3367.     }
  3368.     public static $thisCL = Null;  
  3369.     public static function getCL() {
  3370.  
  3371.         ( self::$thisCL === Null ) &&
  3372.         ( self::$thisCL = new self() );
  3373.  
  3374.         return self::$thisCL;
  3375.  
  3376.     }
  3377.    
  3378.    
  3379.    
  3380.  
  3381. }
  3382.  
  3383. class CL_SERVER {
  3384.  
  3385.     public $ip = "";
  3386.     public $port = "";
  3387.     public $addr = "";
  3388.    
  3389.     public function set( $ip , $port = Null ) {
  3390.    
  3391.         if ( $port === Null ) {
  3392.             $this -> addr = $ip;
  3393.             preg_match( "/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\:([0-9]{1,5})/si" , $ip , $res );
  3394.             if ( ( empty( $res [ 1 ] ) ) || ( empty( $res [ 2 ] ) ) )
  3395.                 return false;
  3396.             $this -> ip = $res [ 1 ];
  3397.             $this -> port = $res [ 2 ];
  3398.             return true;
  3399.         } else {
  3400.             $this -> ip = $ip;
  3401.             $this -> port = $port;
  3402.             $this -> addr = $ip . ":" . $port;     
  3403.             return true;
  3404.         }
  3405.    
  3406.     }
  3407.    
  3408.     public function __construct( $ip = Null , $port = Null ) {
  3409.    
  3410.         $this -> ip = $ip;
  3411.        
  3412.         $this -> port = $port;
  3413.        
  3414.         $this -> addr = $ip . ":" . $port;
  3415.    
  3416.     }
  3417.    public static $thisCL = Null;
  3418.    public static function getCL() {
  3419.  
  3420.        ( self::$thisCL === Null ) &&
  3421.        ( self::$thisCL = new self() );
  3422.  
  3423.        return self::$thisCL;
  3424.  
  3425.    }
  3426.  
  3427. }
  3428.  
  3429. class NET_MESSAGE_FRAGMENTS extends TBUF {
  3430.  
  3431.     public $fragments_total;
  3432.     public $fragments_get = false;
  3433.     public $fragments_last = false;
  3434.     public $fragments_now_fragments = false;
  3435.     public $fragments_fragments = Array();
  3436.     public $fragments_count = 0;
  3437.    
  3438.     private $fragments_curr_head;
  3439.     private $fragments_curr_total;
  3440.     private $fragments_curr_sequence;
  3441.     private $fragments_curr_size;
  3442.     private $fragments_curr_part;
  3443.     private $fragments_curr_last;
  3444.    
  3445.     private function fragments_setLast() {
  3446.  
  3447.         if ( $this -> fragments_curr_last ) {
  3448.                        
  3449.             $this -> addBuf( $this -> fragments_curr_last );
  3450.                        
  3451.             $this -> fragments_last = true;
  3452.                        
  3453.         } else
  3454.             $this -> fragments_last = false;
  3455.            
  3456.     }
  3457.     private function fragments_newFragments() {
  3458.    
  3459.         $this -> fragments_destroyFragments();
  3460.         $this -> fragments_total = $this -> fragments_curr_total;
  3461.         $this -> fragments_now_fragments = true;
  3462.         $this -> fragments_fragments = Array();
  3463.         $this -> fragments_addFragments();
  3464.  
  3465.     }
  3466.     private function fragments_addFragments() {
  3467.         //echo " part " . $this -> fragments_curr_sequence ."/" . $this->fragments_curr_total . "\n";
  3468.         $this -> fragments_fragments[$this -> fragments_curr_sequence] = $this -> fragments_curr_part;             
  3469.         $this -> fragments_count = count( $this -> fragments_fragments );
  3470.    
  3471.     }
  3472.     private function fragments_destroyFragments() {
  3473.    
  3474.         $this -> fragments_total = Null;
  3475.         $this -> fragments_now_fragments = false;
  3476.         $this -> fragments_fragments = Array();
  3477.    
  3478.     }
  3479.     private function fragments_get() {
  3480.        
  3481.         $this -> setBuf();
  3482.  
  3483.         if ( ( !$this -> fragments_now_fragments ) || ( $this -> fragments_total > $this -> fragments_count ) )
  3484.             return false;
  3485.            
  3486.         ksort( $this -> fragments_fragments );
  3487.        
  3488.         $r_str =  implode( $this -> fragments_fragments );
  3489.        
  3490.         $this -> setBuf( ( substr( $r_str , 0 , 4 ) === "BZ2\x00" ) ? bzdecompress( substr( $r_str , 4 ) ) : $r_str );
  3491.  
  3492.         $this -> fragments_destroyFragments();
  3493.                
  3494.         return true;
  3495.    
  3496.     }
  3497.     public function fragments_process() {
  3498.  
  3499.         $this -> fragments_curr_head  = $this -> readInt8();
  3500.         $this -> fragments_curr_total = $this -> readInt16();
  3501.         $this -> fragments_curr_sequence  = $this -> readInt16();
  3502.         $this -> movR( 2 );
  3503.         $this -> fragments_curr_size  = $this -> readInt16();  
  3504.         $this -> movR( 1 );
  3505.         $this -> fragments_curr_part = $this -> readString( $this -> fragments_curr_size );
  3506.         $this -> fragments_curr_last = $this -> readString();
  3507.  
  3508.         if ( $this -> fragments_now_fragments ) {
  3509.             if ( ( $this -> fragments_total === $this -> fragments_curr_total ) ) {
  3510.                 if ( empty( $this -> fragments_fragments[$this -> fragments_curr_sequence] ) )
  3511.                     $this -> fragments_addFragments(); 
  3512.                 else {
  3513.                     if ( !( $this -> fragments_fragments[$this -> fragments_curr_sequence] === $this -> fragments_curr_part ) )
  3514.                         $this -> fragments_newFragments();                 
  3515.                 }
  3516.             } else
  3517.                 $this -> fragments_newFragments();     
  3518.         } else     
  3519.             $this -> fragments_newFragments();
  3520.        
  3521.         if ( $this -> fragments_get() ) {
  3522.  
  3523.             $this -> fragments_setLast();
  3524.            
  3525.             $this -> setCursor( 0 );
  3526.            
  3527.             return true;       
  3528.            
  3529.         }
  3530.        
  3531.         $this -> setBuf();
  3532.         if ( $this -> fragments_setLast() ) {
  3533.             $this -> setCursor( 0 );           
  3534.             return true;
  3535.         } else
  3536.             return false;
  3537.    
  3538.     }
  3539.  
  3540. }
  3541. class NET_BUFER_IN extends NET_MESSAGE_FRAGMENTS {
  3542.  
  3543.     public $sequence = 1;
  3544.     public $acknowledgement = 0x00000000;
  3545.     public $reliable_message = false;
  3546.     public $reliable_ack = false;
  3547.     public $message_contains_fragments = false;
  3548.     public $state;  //  0 => no_pack | 1 => no_sequence | 2 => full_nops | 3 => sequence
  3549.     public $buf_out;
  3550.    
  3551.     public static $full_nop_pack = "\x01\x01\x01\x01\x01\x01\x01\x01";
  3552.        
  3553.     public function read() {    //  return 0 if false , 1 if no_sequence , 2 if full_nops , 3 if sequence
  3554.             //echo "IN  PACK >>> " . COM::showHex( substr( $this->getBuf() , 0,8 ) ) . "\n";
  3555.         $sequence_p = $this -> readInt32();    
  3556.         if ( $sequence_p === ((int)0xFFFFFFFF) ) {
  3557.             $this -> state = 1;
  3558.             return 1;          
  3559.         }
  3560.            
  3561.         $acknowledgement_p = $this -> readInt32();
  3562.        
  3563.         $this -> sequence = $sequence_p & ((int)0x00FFFFFF);
  3564.         $this -> acknowledgement = $acknowledgement_p & ((int)0x00FFFFFF);
  3565.        
  3566.         $this -> reliable_message = ( ( $sequence_p & ((int)0x80000000) ) === ((int)0x80000000) );
  3567.         $this -> reliable_ack = ( ( $acknowledgement_p & ((int)0x80000000) ) === ((int)0x80000000) );
  3568.        
  3569.         if ( $this -> reliable_message )
  3570.             $this -> buf_out -> acknowledgement = $this -> sequence;
  3571.         else
  3572.             $this -> buf_out -> acknowledgement++;
  3573.  
  3574.         $this -> message_contains_fragments = ( ( $sequence_p & ((int)0xC0000000) ) === ((int)0xC0000000) );
  3575.                    
  3576.         $this -> setBuf( COM::UnMunge( $this -> readString() , $this -> sequence ) );      
  3577.             //echo "             " . COM::showHex( $this->getBuf() ) . "\n";
  3578.             //echo "             " . COM::showHtmlContent( $this->getBuf() ) . "\n";   
  3579.  
  3580.         //if ( $this -> message_contains_fragments )
  3581.         //  echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ message contains fragments ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
  3582.  
  3583.  
  3584.         if ( $this -> message_contains_fragments )
  3585.             $this -> fragments_process();
  3586.  
  3587.         //if ( $this -> message_contains_fragments )
  3588.         //  echo "In frament ".$this->fragments_count." / ".$this->fragments_total."\n";
  3589.        
  3590.         if ( $this -> ifEmpty() ) {
  3591.             $this -> state = 0;
  3592.             return 0;  
  3593.         }
  3594.        
  3595.         if ( $this -> ifPos( 0 , self::$full_nop_pack ) ) {
  3596.             $this -> state = 2;
  3597.             return 2;      
  3598.         }
  3599.        
  3600.         $this -> state = 3;
  3601.         return 3;          
  3602.            
  3603.     }
  3604.  
  3605.     public function __construct() {
  3606.    
  3607.         $this -> buf_out = NET_BUFER_OUT::getCL();
  3608.    
  3609.     }
  3610.    
  3611.     public static $thisCL = Null;  
  3612.    public static function getCL() {
  3613.  
  3614.        ( self::$thisCL === Null ) &&
  3615.        ( self::$thisCL = new self() );
  3616.  
  3617.        return self::$thisCL;
  3618.  
  3619.    }
  3620.    
  3621. }
  3622. class NET_BUFER_OUT extends TBUF {
  3623.  
  3624.     public $sequence = 1;
  3625.     public $min_size = 8;
  3626.     public $max_size = 1024;
  3627.     public $acknowledgement = 0;
  3628.     public $receiving_is_reliable = true;
  3629.     public $run_validation = false;
  3630.     public $reliable_confirmation = false;
  3631.     public $require_security = false;
  3632.    
  3633.  
  3634.     public $packReadId = 1;
  3635.     public $packs = Array();
  3636.  
  3637.     public function add( $str ) {
  3638.    
  3639.         if ( $this -> bufSize + strlen( $str ) > $this -> max_size )
  3640.             $this -> release();    
  3641.    
  3642.         $this -> addBuf( $str );
  3643.  
  3644.     }
  3645.     public function get() {
  3646.    
  3647.         if ( $this -> packReadId >= $this -> sequence )
  3648.             $this -> release();
  3649.            
  3650.         $res = $this -> packs[$this->packReadId];
  3651.        
  3652.         unset( $this -> packs[$this->packReadId] );
  3653.        
  3654.         $this->packReadId++;
  3655.            
  3656.         return $res;
  3657.        
  3658.     }
  3659.     public function begin() {
  3660.    
  3661.         $this -> setBuf();
  3662.         $this -> sequence = 1;
  3663.         $this -> packReadId = 1;
  3664.         $this -> packs = Array();
  3665.    
  3666.     }
  3667.     public function release() {
  3668.        
  3669.         $to_nop_c = $this -> min_size - $this -> bufSize;
  3670.                
  3671.         for ( $i = 0; $i < $to_nop_c; $i++ )
  3672.             $this -> writeInt8( 0x01 );
  3673.                    
  3674.         $buf = $this -> getBuf();
  3675.        
  3676.         $this -> setBuf();
  3677.        
  3678.         $this -> reliable_confirmation = !$this -> reliable_confirmation;
  3679.        
  3680.         $sequence_p = $this -> sequence;
  3681.         $acknowledgement_p = $this -> acknowledgement;
  3682.        
  3683.         if ( $this -> receiving_is_reliable )
  3684.             $sequence_p |= ((int)0x80000000);
  3685.         if ( $this -> run_validation )
  3686.             $sequence_p |= ((int)0x40000000);
  3687.         if ( $this -> reliable_confirmation )
  3688.             $acknowledgement_p |= ((int)0x80000000);
  3689.         if ( $this -> require_security )
  3690.             $acknowledgement_p |= ((int)0x40000000);
  3691.        
  3692.         $this -> writeInt32( $sequence_p );
  3693.         $this -> writeInt32( $acknowledgement_p );
  3694.        
  3695.     //echo "OUT PACK >>> " . COM::showHex( $this->getBuf() ) . "\n";
  3696.     //echo "             " . COM::showHex( $buf ) . "\n";
  3697.     //echo "             " . COM::showHtmlContent( $buf ) . "\n";
  3698.    
  3699.         $this -> addBuf( COM::Munge( $buf , $this -> sequence ) );
  3700.            
  3701.         $this -> packs[$this -> sequence] = $this -> getBuf();
  3702.    
  3703.         $this -> sequence++;
  3704.         $this -> setBuf();
  3705.        
  3706.     }
  3707.        
  3708.     public static $thisCL = Null;  
  3709.    public static function getCL() {
  3710.  
  3711.        ( self::$thisCL === Null ) &&
  3712.        ( self::$thisCL = new self() );
  3713.  
  3714.        return self::$thisCL;
  3715.  
  3716.    }
  3717.    
  3718. }
  3719. class NET_READ_COMMAND {
  3720.  
  3721.     public $engine;
  3722.     public $buf_in;
  3723.     public $svc;
  3724.     public $user_msg;
  3725.     public $svc_exe;
  3726.    
  3727.     public function checkWord( $str ) {
  3728.    
  3729.         if ( !$str )
  3730.             return false;
  3731.            
  3732.         $len = strlen( $str );
  3733.        
  3734.         if ( $len == 0 )
  3735.             return false;
  3736.            
  3737.         for( $i=0; $i<$len; $i++ ) {
  3738.        
  3739.             $c = $str[$i];
  3740.            
  3741.             if ( ( ord($c) <= ((int)0x20) ) && ( $c !== "\r" ) && ( $c !== "\n" ) && ( $c !== "\x00" ) )
  3742.                 return false;
  3743.        
  3744.         }
  3745.        
  3746.         return true;
  3747.    
  3748.     }
  3749.     public function getStuffTextAllVariants( $pos = 0 ) {
  3750.  
  3751.         $buf = $this->buf_in->getBUf();
  3752.         while( !( ( $pos = strpos( $buf , "\x09" , $pos ) ) === false ) ) {
  3753.  
  3754.             $this->buf_in->setCursor( $pos + 1 );
  3755.            
  3756.             $s_t = $this->buf_in->readPString();
  3757.            
  3758.                 if ( !preg_match( "/^[^a-zA-Z0-9\_]/si" , $s_t ) ) {
  3759.                     $this->buf_in->setCursor( $pos );
  3760.                     $this -> svc -> read();
  3761.                 }
  3762.            
  3763.            
  3764.             $pos++;
  3765.        
  3766.         }
  3767.  
  3768.         $this->buf_in->setCursor( 0 );
  3769.    
  3770.     }
  3771.     public function getQcc2AllVariants( $pos = 0 ) {
  3772.    
  3773.         $buf = $this->buf_in->getBUf();
  3774.         while( !( ( $pos = strpos( $buf , chr(58) , $pos ) ) === false ) ) {
  3775.  
  3776.             $this->buf_in->setCursor( $pos+4 );
  3777.            
  3778.             $s_t = $this->buf_in->readPString();
  3779.             if ( $this->checkWord( $s_t ) ) {
  3780.                
  3781.                 if ( !preg_match( "/[^a-zA-Z0-9\_]/si" , $s_t ) ) {        
  3782.                     $this->buf_in->setCursor( $pos );
  3783.                     $this -> svc -> read();
  3784.                 }
  3785.            
  3786.             }
  3787.            
  3788.             $pos++;
  3789.        
  3790.         }
  3791.  
  3792.         $this->buf_in->setCursor( 0 ); 
  3793.        
  3794.     }
  3795.     public function readOne() {
  3796.    
  3797.         if ( $this->buf_in->ifEnd() )
  3798.             return false;
  3799.    
  3800.         $svc = $this -> svc -> readCMD( $this->buf_in );
  3801.        
  3802.         if ( $svc === -1 ) {/*
  3803.                 $this->buf_in->movL(0);
  3804.                 echo COM::showHex( $this->buf_in->readString() )."\n";
  3805.                 echo COM::showHtmlContent( $this->buf_in->readPString() )."\n";
  3806.                 echo COM::showHtmlContent( $this->buf_in->readPString() )."\n";
  3807.                 echo COM::showHtmlContent( $this->buf_in->readPString() )."\n";
  3808.                 echo COM::showHtmlContent( $this->buf_in->readPString() )."\n";
  3809.                 return false;
  3810.                 */
  3811.             $this -> engine -> console -> print_str( "BAD SVC Message" );
  3812.             return false;      
  3813.         }
  3814.        
  3815.         if ( $svc === 0 ) {
  3816.        
  3817.             $user_msg = $this -> user_msg -> readCMD( $this->buf_in );
  3818.            
  3819.             if ( $user_msg ) {
  3820.            
  3821.                 echo $user_msg["cmd"]["Name"] . " " . $user_msg["options_string"] ."\n";
  3822.                    
  3823.             } else
  3824.                 return false;
  3825.            
  3826.         } else {
  3827.             /*
  3828.             $i = $this->buf_in->bufPos;
  3829.             while( $i < $this->buf_in->bufSize ) {
  3830.                 $this->buf_in->setCursor( $i );
  3831.                 $cmd = $this -> svc -> getCMD( $this->buf_in->readInt8() );
  3832.                 if ( $cmd ) {
  3833.                     echo $cmd["Name"] . " " . COM::showHtmlContent( $this->buf_in->readString() )."\n";                            
  3834.                 }
  3835.                 $i++;
  3836.             }
  3837.             */
  3838.        
  3839.             echo $svc["cmd"]["Name"] . " " . $svc["options_string"] ."\n";
  3840.             //echo COM::showHtmlContent( $svc["options_string"] )."\n";
  3841.            
  3842.             $this -> svc_exe -> execute( $svc["cmd"]["Name"] , $svc["options"] );
  3843.             return true;       
  3844.         }
  3845.        
  3846.         return false;
  3847.    
  3848.     }
  3849.     public function read() {
  3850.    
  3851.         $this->buf_in->setCursor(0);
  3852.  
  3853.         while( !$this->buf_in->ifEnd() ) {
  3854.             $cmdID = $this->buf_in->readInt8();
  3855.                 echo "Curr CMD :: " . $cmdID . "\n";
  3856.             $res = $this->svc->read( $cmdID );
  3857.             if ( $res === false )
  3858.                 $res = $this->user_msg->read( $cmdID );
  3859.            
  3860.             if ( !$res ) {
  3861.                 $this -> getStuffTextAllVariants( $this->buf_in->bufPos );
  3862.                 $this -> getQcc2AllVariants( $this->buf_in->bufPos );              
  3863.                 return false;                  
  3864.             }
  3865.         }
  3866.                 echo "Curr END CMD :: " . $cmdID . "\n";
  3867.    
  3868.     }
  3869.    
  3870.     public function __construct() {
  3871.    
  3872.         global $engine;
  3873.         $this -> engine = $engine;
  3874.        
  3875.        $this -> buf_in = NET_BUFER_IN::getCL();
  3876.         $this -> svc = CLIENT_SVC_FUNCTIONS::getCL();
  3877.         $this -> user_msg = USER_MESSAGE::getCL();
  3878.    
  3879.     }
  3880.    
  3881.     public static $thisCL = Null;  
  3882.    public static function getCL() {
  3883.  
  3884.        ( self::$thisCL === Null ) &&
  3885.        ( self::$thisCL = new self() );
  3886.  
  3887.        return self::$thisCL;
  3888.  
  3889.    }
  3890.    
  3891. }
  3892.  
  3893. class CL_SOCKET {
  3894.  
  3895.    public $developer = false;
  3896.  
  3897.     public $engine;
  3898.    
  3899.    public $server;
  3900.     public $buf_in;
  3901.     public $buf_out;
  3902.  
  3903.  
  3904.    public $maxRecvSize = 4096;
  3905.    
  3906.     public $recvTime = 500000;  //  mcr seck
  3907.     public $recvInterval = 1000;    //  mcr seck ( 1/10^6 )
  3908.  
  3909.    private function developer( $info , $head ) {
  3910.  
  3911.        echo
  3912.            "\n>>>>>>>>============================================== ".$head." ==============================================>>>>>>>>\n".
  3913.                COM::showHex( $info ) . "\n" . COM::showHtmlContent( $info ) .
  3914.            "\n<<<<<<<<============================================== ".$head." ==============================================<<<<<<<<\n";
  3915.  
  3916.    }
  3917.  
  3918.    function open () {
  3919.  
  3920.        if ( !( $this -> socket = @socket_create ( AF_INET, SOCK_DGRAM, SOL_UDP ) ) )
  3921.            return Array ( "ERROR" => 1, "msg" => "Ошибка создания сокета" );
  3922.  
  3923.        if ( !socket_set_nonblock ( $this -> socket ) )
  3924.            return Array ( "ERROR" => 1, "msg" => "Ошибка... Невозможна перевести сокет в неблокирующий режим" );
  3925.  
  3926.        return Array ( "ERROR" => 0 );
  3927.  
  3928.    }
  3929.     function release() {
  3930.    
  3931.         $this -> close();
  3932.        
  3933.         $this -> open();
  3934.        
  3935.     }
  3936.    function send () {
  3937.    
  3938.         if ( $this -> engine -> state >= 2 ) {
  3939.        
  3940.             $pack = $this -> buf_out -> get();
  3941.        
  3942.             if ( $this -> developer ) $this -> developer( $pack , "PACK OUT" );
  3943.  
  3944.             @socket_sendto ( $this -> socket , $pack , strlen( $pack ) , 0 , $this -> server -> ip , $this -> server -> port );
  3945.  
  3946.             return true;
  3947.            
  3948.         } elseif ( $this -> engine -> state === 1 ) {
  3949.  
  3950.             if ( $this -> developer ) $this -> developer( $this -> buf_out -> getBuf() , "PACK OUT" );
  3951.  
  3952.             @socket_sendto ( $this -> socket , $this -> buf_out -> getBuf() , $this -> buf_out -> bufSize , 0 , $this -> server -> ip , $this -> server -> port );
  3953.                
  3954.             return true;
  3955.            
  3956.         }
  3957.        
  3958.         return false;
  3959.        
  3960.    }
  3961.    function recv ( $time = Null ) {
  3962.    
  3963.         if ( $this -> engine -> state >= 2 ) {
  3964.                
  3965.             $recvCount = ( $time === Null ) ? 0 : floor( $time / $this -> recvInterval );
  3966.    
  3967.             for ( $i = 0; $i <= $recvCount; $i++ ) {
  3968.    
  3969.                 socket_recvfrom ( $this -> socket, $temp, $this->maxRecvSize, 0, $ip, $port );
  3970.                
  3971.                 if ( !( ( $temp === false ) || ( $temp === Null ) ) ) {
  3972.                
  3973.                     $this->buf_in->setBuf( $temp );            
  3974.            
  3975.                     if ( $this -> developer )
  3976.                         $this -> developer( $temp , "PACK IN" );
  3977.                        
  3978.                     return true;
  3979.                
  3980.                 }
  3981.                
  3982.                 if ( $time === Null )
  3983.                     return false;
  3984.                
  3985.                 usleep( $this -> recvInterval );
  3986.            
  3987.             }
  3988.             return false;
  3989.            
  3990.         } elseif ( $this -> engine -> state === 1  ) {
  3991.            
  3992.             $time = ( $time === Null ) ? $this -> recvTime : $time;
  3993.        
  3994.             $recvCount = floor( $time / $this -> recvInterval );
  3995.            
  3996.             for ( $i = 0; $i <= $recvCount; $i++ ) {
  3997.        
  3998.                 socket_recvfrom ( $this -> socket, $temp, $this->maxRecvSize, 0, $ip, $port );
  3999.                
  4000.                 if ( !( ( $temp === false ) || ( $temp === Null ) ) ) {
  4001.                
  4002.                     $this->buf_in->setBuf( $temp );            
  4003.            
  4004.                     if ( $this -> developer )
  4005.                         $this -> developer( $temp , "PACK IN" );
  4006.                        
  4007.                     return true;
  4008.                
  4009.                 }
  4010.                
  4011.                 usleep( $this -> recvInterval );
  4012.            
  4013.             }
  4014.            
  4015.             if ( $this -> developer )
  4016.                 $this -> developer( "ERROR recv TimeOut" , "PACK IN" );
  4017.            
  4018.             return false;
  4019.            
  4020.         }
  4021.        
  4022.         return false;
  4023.  
  4024.    }
  4025.    function close() {
  4026.  
  4027.        @socket_close( $this -> socket );
  4028.  
  4029.    }
  4030.  
  4031.    public function __construct() {
  4032.    
  4033.         global $engine;
  4034.         $this -> engine = $engine;
  4035.  
  4036.        $this -> server = CL_SERVER::getCL();
  4037.        $this -> buf_in = NET_BUFER_IN::getCL();
  4038.        $this -> buf_out = NET_BUFER_OUT::getCL();
  4039.        
  4040.    }
  4041.  
  4042.    public static $thisCL = Null;
  4043.    public static function getCL() {
  4044.  
  4045.        ( self::$thisCL === Null ) &&
  4046.        ( self::$thisCL = new self() );
  4047.  
  4048.        return self::$thisCL;
  4049.  
  4050.    }
  4051.  
  4052. }
  4053. class GET_TICKET extends TBUF {
  4054.  
  4055.     public static $DEFAULT_STEAM_PACK = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00";
  4056.    
  4057.     public function getRandomHash( $minL = 6 , $maxL = 16 ) {
  4058.    
  4059.         $len = mt_rand( $minL , $maxL );
  4060.    
  4061.         $hash = "";
  4062.        
  4063.         $mTable = Array (
  4064.             Array ( ord( "a" ) , ord("z") ) ,
  4065.             Array ( ord( "A" ) , ord("Z") ) ,
  4066.             Array ( ord( "0" ) , ord("9") )
  4067.         );
  4068.         $cTable = count( $mTable )-1;
  4069.    
  4070.         for ( $i = 0; $i < $len; $i++ ) {
  4071.             $j = mt_rand( 0 , $cTable );       
  4072.             $hash .= chr( mt_rand( $mTable[$j][0] , $mTable[$j][1] ) );
  4073.         }
  4074.                
  4075.         return $hash;
  4076.    
  4077.     }
  4078.     public function getIdRevEmu( $hash ) {
  4079.        
  4080.         $len = strlen( $hash );
  4081.        
  4082.         $steam = ((int)0x4E67C6A7);
  4083.        
  4084.         for( $i = 0; $i < $len; $i++ ) {
  4085.                
  4086.             $ch = ord( $hash[$i] );
  4087.            
  4088.             if ( $ch === 0 )
  4089.                 return $steam;
  4090.            
  4091.             //  Hash ^= (Hash >> 2) + CurChar + 32 * Hash;
  4092.            
  4093.             $steam ^= ( ( ( ( ((int)$steam >> 2) ) + $ch ) + ( ((int)$steam << 5 )) ) & ((int)0xFFFFFFFF) );
  4094.  
  4095.         }
  4096.        
  4097.         return $steam;
  4098.    
  4099.     }
  4100.     public function getTicketRevEmu( $hash = Null ) {
  4101.    
  4102.         if ( $hash === Null )
  4103.             $hash = $this -> getRandomHash();
  4104.            
  4105.         $steam = $this -> getIdRevEmu( $hash );
  4106.        
  4107.         $this -> setBuf();
  4108.    
  4109.         $this -> writeInt32( ((int)0x0000004A) );
  4110.         $this -> writeInt32( ((int)$steam) );
  4111.         $this -> writePString( "ver" );
  4112.         $this -> writeInt32( ((int)0x00000000)      );
  4113.         $this -> writeInt32( ((int)( $steam << 1 )) );
  4114.         $this -> writeInt32( ((int)0x01100001)      );
  4115.         $this -> writePString( $hash );
  4116.         $this -> writeString( self::$DEFAULT_STEAM_PACK );
  4117.  
  4118.         return $this -> getBuf();
  4119.        
  4120.     }
  4121.     public function getTicketGreenLuma( $steam = Null , $mod2steam64 = 0 ) {
  4122.    
  4123.         $steam = (int)( ( (((int)$steam) & ((int)0xFFFFFFFF) ) << 1 ) >> 1 );
  4124.    
  4125.         if ( $steam === 0 )
  4126.             return $this -> getTicketGreenLuma( (int)( (mt_rand(0,10)+1)*100000000 + 702354683 + mt_rand(0,100000000) ) , mt_rand(0,1) );
  4127.                    
  4128.         $this -> setBuf();
  4129.    
  4130.         $this -> writeInt32( ((int)0x00000014) );
  4131.         for ( $i=0; $i < 8; $i++ )
  4132.             $this -> writeInt8( mt_rand( 0,255 ) & 0xFF );
  4133.            
  4134.         $this -> writeInt32( ( ((int)$steam) << 2 ) + $mod2steam64 );
  4135.         $this -> writeInt32( ((int)0x01100001) );
  4136.  
  4137.         for ( $i=0; $i < 4; $i++ )
  4138.             $this -> writeInt8( mt_rand( 0,255 ) & 0xFF );
  4139.         $this -> writeInt32( ((int)0x00000000) );
  4140.    
  4141.         return $this -> getBuf();
  4142.    
  4143.     }
  4144.    
  4145.     public function getTicket( $emul = "revemu" , $hash = Null , $mod2steam64 = 0 ) {
  4146.    
  4147.         switch ( $emul ) {
  4148.             case "revemu":
  4149.                 return $this -> getTicketRevEmu( $hash );
  4150.                 break;
  4151.             case "greenluma":
  4152.                 return $this -> getTicketGreenLuma( $hash , $mod2steam64  );
  4153.                 break;
  4154.         }
  4155.        
  4156.     }
  4157.  
  4158.    public static $thisCL = Null;
  4159.    public static function getCL() {
  4160.  
  4161.        ( self::$thisCL === Null ) &&
  4162.        ( self::$thisCL = new self() );
  4163.  
  4164.        return self::$thisCL;
  4165.  
  4166.    }
  4167.  
  4168. }
  4169. class FIRST_PACKETS {
  4170.  
  4171.     public $engine;
  4172.     public $userinfo;
  4173.     public $socket;
  4174.    public $server;    
  4175.     public $buf_in;
  4176.     public $buf_out;
  4177.     public $ticket;
  4178.  
  4179.     public function chalenge() {
  4180.  
  4181.         $this -> buf_out -> setBuf();
  4182.        
  4183.         $this -> buf_out -> writeInt32( 0xFFFFFFFF );
  4184.        
  4185.         $this -> buf_out -> writePString( "getchallenge steam" );
  4186.        
  4187.     }
  4188.     public function connect( $id ) {
  4189.    
  4190.         $this -> buf_out -> setBuf();
  4191.        
  4192.         $this -> buf_out -> writeInt32( 0xFFFFFFFF );
  4193.        
  4194.         $this -> buf_out -> writeString( $this -> userinfo -> getUserInfoString( $id ) );
  4195.        
  4196.         $this -> buf_out -> writeString( $this -> ticket -> getTicketGreenLuma() );
  4197.        
  4198.     }
  4199.    
  4200.     public function __construct() {
  4201.    
  4202.         global $engine;
  4203.         $this -> engine = $engine;
  4204.    
  4205.         $this -> userinfo = GET_USER_INFO::getCL();
  4206.         $this -> socket = CL_SOCKET::getCL();
  4207.        $this -> server = CL_SERVER::getCL();
  4208.        $this -> buf_in = NET_BUFER_IN::getCL();
  4209.        $this -> buf_out = NET_BUFER_OUT::getCL();
  4210.         $this -> ticket = GET_TICKET::getCL();
  4211.    
  4212.     }
  4213.    
  4214.    public static $thisCL = Null;
  4215.    public static function getCL() {
  4216.  
  4217.        ( self::$thisCL === Null ) &&
  4218.        ( self::$thisCL = new self() );
  4219.  
  4220.        return self::$thisCL;
  4221.  
  4222.    }
  4223.  
  4224. }
  4225. class NET {
  4226.  
  4227.     public $engine;
  4228.     public $socket;
  4229.    public $server;    
  4230.     public $buf_in;
  4231.     public $buf_out;
  4232.     public $first_packets;
  4233.     public $readCMD;
  4234.    
  4235.     public $time = Null;
  4236.     public $maxOutTime = 8; // sec
  4237.     public $lastTime = 0;
  4238.        
  4239.     public function getTime() {
  4240.    
  4241.         $time = microtime();
  4242.        
  4243.         $time = explode ( " " , $time );
  4244.        
  4245.         return ((float)$time[0]) + ((float)$time[1]);
  4246.    
  4247.     }
  4248.     public function needSleep() {
  4249.  
  4250.             $interval = ( ( 1 / $this -> engine -> Cvar_Get( "cl_cmdrate" )["int"] ) * 1000000 );
  4251.            
  4252.             $time_s = $this -> getTime();  
  4253.            
  4254.             if ( $this -> time === Null ) {        
  4255.                 $this -> time = $time_s;               
  4256.                 return false;              
  4257.             }
  4258.                
  4259.             $time = $interval - ( ( $time_s - $this -> time ) * 1000000 );
  4260.            
  4261.             $this -> time = $time_s;
  4262.            
  4263.             if ( $time > 0 )
  4264.                 usleep( $time );   
  4265.    
  4266.     }
  4267.     public function add( $str ) {
  4268.    
  4269.         $this -> buf_out -> add( $str );
  4270.    
  4271.     }
  4272.     public function connect() {
  4273.        
  4274.         $this -> engine -> state = 1;
  4275.        
  4276.         $this -> socket -> release();
  4277.        
  4278.         $this -> first_packets -> chalenge();
  4279.  
  4280.         $this -> socket -> send();
  4281.        
  4282.         if ( !$this -> socket -> recv() ) {
  4283.             $this->engine->console->print_str("Нет ответа от сервера на покет getchalenge");  
  4284.             $this -> disconnect();         
  4285.             return false;              
  4286.         }
  4287.        
  4288.         $head = $this -> buf_in -> readString( 4 );
  4289.         $A_1_head = $this -> buf_in -> readString( 1 );
  4290.         $A_2_head = $this -> buf_in -> readString( 8 );
  4291.         $A_3_head = $this -> buf_in -> readString( 1 );
  4292.            
  4293.         if ( $head == "\xFF\xFF\xFF\xFF" ) {
  4294.        
  4295.             if ( ( $A_1_head === "\x6C" ) || ( $A_1_head === "\x39" ) ) {
  4296.                 $this -> engine -> console -> print_str( $this -> buf_in -> getBuf( 5 ) );
  4297.                 $this -> disconnect();         
  4298.                 return false;          
  4299.             }
  4300.        
  4301.             if ( !( ( $A_1_head === "A" ) && ( $A_2_head === "00000000" ) && ( $A_3_head === "\x20" ) ) ) {
  4302.                 $this -> disconnect();         
  4303.                 return false;
  4304.             }
  4305.            
  4306.         } else {   
  4307.             $this->engine->console->print_str("Нее верный фармат ответа от сервера на покет getchalenge");
  4308.             $this -> disconnect();         
  4309.             return false;
  4310.         }
  4311.        
  4312.         $buf = $this -> buf_in -> getBuf( 14 );
  4313.         $connect_try_id = trim( substr( $buf , 0 , strpos( $buf , "\x20" ) ) );
  4314.        
  4315.         if ( $connect_try_id === "" ) {
  4316.             $this -> disconnect;           
  4317.             return false;              
  4318.         }
  4319.        
  4320.         $this -> first_packets -> connect( $connect_try_id );
  4321.                
  4322.         $this -> socket -> send();
  4323.        
  4324.         if ( !$this -> socket -> recv() ) {    
  4325.             $this->engine->console->print_str("Нет ответа от сервера на покет connect");  
  4326.             $this -> disconnect();         
  4327.             return false;              
  4328.         }
  4329.        
  4330.         $head = $this -> buf_in -> readString( 4 );
  4331.         $A_1_head = $this -> buf_in -> readString( 1 );
  4332.         $A_2_head = $this -> buf_in -> readString( 8 );
  4333.         $A_3_head = $this -> buf_in -> readString( 1 );
  4334.        
  4335.         if ( $head == "\xFF\xFF\xFF\xFF" ) {
  4336.        
  4337.             if ( ( $A_1_head === "\x6C" ) || ( $A_1_head === "\x39" ) ) {
  4338.                 $this -> engine -> console -> print_str( $this -> buf_in -> getBuf( 5 ) );
  4339.                 $this -> disconnect();     
  4340.                 return false;          
  4341.             }
  4342.            
  4343.         } else {   
  4344.             $this->engine->console->print_str("Нее верный фармат ответа от сервера на покет connect");
  4345.             $this -> disconnect();         
  4346.             return false;
  4347.         }
  4348.  
  4349.         $this -> lastTime = time();
  4350.         $this -> engine -> state = 2;
  4351.         $this -> buf_out -> begin();
  4352.         $this -> run();
  4353.        
  4354.     }
  4355.     public function disconnect() {
  4356.    
  4357.         if ( $this -> engine -> state >= 2 ) {
  4358.        
  4359.             $this -> engine -> clc -> execute( "STRINGCMD" , "dropclient" );
  4360.            
  4361.             $len = $this -> buf_out -> sequence - $this -> buf_out -> packReadId;
  4362.            
  4363.             for( $i=0; $i<=$len; $i++ )    
  4364.                 $this -> socket -> send();
  4365.        
  4366.         }
  4367.  
  4368.         $this -> engine -> state = 0;
  4369.        
  4370.         $this -> socket -> close();
  4371.            
  4372.         return true;   
  4373.    
  4374.     }
  4375.  
  4376.     public function run() {
  4377.    
  4378.         $this -> engine -> NET_FRAME_FIRST();
  4379.            
  4380.         $this -> socket -> send();
  4381.        
  4382.         $this -> needSleep();
  4383.         while( $this -> engine -> state >= 2 ) {
  4384.            
  4385.             while ( $this -> socket -> recv() ) {
  4386.                 $this -> lastTime = time();
  4387.                
  4388.                 if ( $this -> buf_in -> read() >= 3 ) {
  4389.                     echo "size in buffer = ".$this->buf_in->bufSize."\n";
  4390.                     $this -> readCMD -> read();
  4391.            
  4392.                     //echo $this -> buf_in -> state . "\n";
  4393.                     //echo COM::showHtmlContent( $this->buf_in->getBuf() ) . "\n";         
  4394.            
  4395.                 }
  4396.            
  4397.             }
  4398.        
  4399.             if ( $this->lastTime + $this->maxOutTime < time() ) {
  4400.            
  4401.                 $this -> disconnect();
  4402.                 $this->engine->console->print_str("Нет ответа от сервера ".$this->maxOutTime." sec");
  4403.                 return;
  4404.            
  4405.             }
  4406.        
  4407.             $this -> engine -> NET_FRAME();
  4408.            
  4409.             $this -> socket -> send();     
  4410.  
  4411.             $this -> needSleep();
  4412.        
  4413.         }
  4414.    
  4415.     }
  4416.    
  4417.     public function __construct() {
  4418.    
  4419.         global $engine;
  4420.         $this -> engine = $engine;
  4421.        
  4422.         $this -> socket = CL_SOCKET::getCL();
  4423.        $this -> server = CL_SERVER::getCL();
  4424.        $this -> buf_in = NET_BUFER_IN::getCL();
  4425.        $this -> buf_out = NET_BUFER_OUT::getCL();
  4426.         $this -> first_packets = FIRST_PACKETS::getCL();
  4427.         $this -> readCMD = NET_READ_COMMAND::getCL();
  4428.    
  4429.     }
  4430.    
  4431.     public static $thisCL = Null;  
  4432.    public static function getCL() {
  4433.  
  4434.        ( self::$thisCL === Null ) &&
  4435.        ( self::$thisCL = new self() );
  4436.  
  4437.        return self::$thisCL;
  4438.  
  4439.    }
  4440.    
  4441. }
  4442. class COM {
  4443.  
  4444.    private static $MungeTable = Array(
  4445.            Array( 0x7A, 0x64, 0x05, 0xF1, 0x1B, 0x9B, 0xA0, 0xB5, 0xCA, 0xED, 0x61, 0x0D, 0x4A, 0xDF, 0x8E, 0xC7 ) ,
  4446.            Array( 0x05, 0x61, 0x7A, 0xED, 0x1B, 0xCA, 0x0D, 0x9B, 0x4A, 0xF1, 0x64, 0xC7, 0xB5, 0x8E, 0xDF, 0xA0 ) ,
  4447.            Array( 0x20, 0x07, 0x13, 0x61, 0x03, 0x45, 0x17, 0x72, 0x0A, 0x2D, 0x48, 0x0C, 0x4A, 0x12, 0xA9, 0xB5 )
  4448.    );
  4449.    private static $NeedMungeTable = Array( 0x05, 0x61, 0x7A, 0xED, 0x1B, 0xCA, 0x0D, 0x9B, 0x4A, 0xF1, 0x64, 0xC7, 0xB5, 0x8E, 0xDF, 0xA0 );
  4450.  
  4451.    public static function Munge ( $pack , $sequence ) {
  4452.  
  4453.        $size_b = strlen ( $pack );
  4454.        $size = floor ( $size_b / 4 );
  4455.  
  4456.        $sequence &= 0xFF;
  4457.        $notSequence = ( ~$sequence ) & 0xFF;
  4458.  
  4459.        $res = "";
  4460.  
  4461.        for ( $i=0; $i<$size; $i++ ) {
  4462.  
  4463.            $res .=
  4464.                chr( ~( ord( $pack[$i*4+3] ) ^ ( self::$NeedMungeTable[ ( $i     ) & 0x0F ] | 165 ) ) ^ $sequence ) .
  4465.                chr( ~( ord( $pack[$i*4+2] ) ^ ( self::$NeedMungeTable[ ( $i + 1 ) & 0x0F ] | 167 ) )             ) .
  4466.                chr( ~( ord( $pack[$i*4+1] ) ^ ( self::$NeedMungeTable[ ( $i + 2 ) & 0x0F ] | 175 ) )             ) .
  4467.                chr( ~( ord( $pack[$i*4  ] ) ^ ( self::$NeedMungeTable[ ( $i + 3 ) & 0x0F ] | 191 ) ) ^ $sequence ) ;
  4468.  
  4469.        }
  4470.  
  4471.        if ( $size * 4 < $size_b )
  4472.            $res .= substr( $pack , $size * 4 );
  4473.  
  4474.        return $res;
  4475.  
  4476.    }
  4477.    public static function UnMunge ( $pack , $sequence ) {
  4478.  
  4479.        $size_b = strlen ( $pack );
  4480.        $size = floor ( $size_b / 4 );
  4481.  
  4482.        $sequence &= 0xFF;
  4483.  
  4484.        $res = "";
  4485.  
  4486.        for ( $i=0; $i<$size; $i++ ) {
  4487.  
  4488.            $res .=
  4489.                chr( ~( ord( $pack[$i*4+3] ) ^ ( self::$NeedMungeTable[ ( $i + 3 ) & 0x0F ] | 191 ) ) ^ $sequence   ) .
  4490.                chr( ~( ord( $pack[$i*4+2] ) ^ ( self::$NeedMungeTable[ ( $i + 2 ) & 0x0F ] | 175 ) )               ) .
  4491.                chr( ~( ord( $pack[$i*4+1] ) ^ ( self::$NeedMungeTable[ ( $i + 1 ) & 0x0F ] | 167 ) )               ) .
  4492.                chr( ~( ord( $pack[$i*4  ] ) ^ ( self::$NeedMungeTable[ ( $i     ) & 0x0F ] | 165 ) ) ^ $sequence   ) ;
  4493.  
  4494.        }
  4495.  
  4496.        if ( $size * 4 < $size_b )
  4497.            $res .= substr( $pack , $size * 4 );
  4498.  
  4499.        return $res;
  4500.  
  4501.  
  4502.    }
  4503.    public static function setAsistMungeTable( $tbId = 2 ) {
  4504.  
  4505.        self::$NeedMungeTable = &self::$MungeTable[$tbId-1];
  4506.  
  4507.    }
  4508.  
  4509.    public static function getStructurePacket( $pack = Null ) {
  4510.  
  4511.        if ( $pack === Null ) {
  4512.  
  4513.            CL_BUFER::getCL()->setCursor( 0 );
  4514.            $num1  = CL_BUFER::getCL()->readInt32();
  4515.            $num2  = CL_BUFER::getCL()->readInt32();
  4516.            $pack  = CL_BUFER::getCL()->readString();
  4517.            $count = $num1 & 0x00FFFFFF;
  4518.  
  4519.            $res = new CL_StructurePacket( $num1 , $num2 , $count , $pack );
  4520.  
  4521.        } else {
  4522.  
  4523.            $num1  = unpack( "l" , substr( $pack , 0 , 4) )[1];
  4524.            $num2  = unpack( "l" , substr( $pack , 4 , 4) )[1];
  4525.            $pack  = substr( $pack , 8);
  4526.            $count = $num1 & 0x00FFFFFF;
  4527.  
  4528.            $num = unpack( "l" , substr( $pack , 0 , 4) )[1];
  4529.  
  4530.            $res = new CL_StructurePacket( $num1 , $num2 , $count , $pack );
  4531.  
  4532.        }
  4533.  
  4534.        return $res;
  4535.  
  4536.    }
  4537.    public static function getPacket( $struct ) {
  4538.  
  4539.        return pack( "l" , $struct->num ) . pack( "l" , $struct->num2 ) . $struct->content;
  4540.  
  4541.    }
  4542.  
  4543.    public static function showHex ( $st, $rd = " ", $type = false ) {
  4544.  
  4545.        $len = strlen ( $st .= "" );
  4546.        if ( $type )
  4547.            for ( $i = $len - 1; $i >= 0; $i-- )
  4548.                $res .= ( ( ( $buf = ord ( $st [ $i ] ) ) > 15 ) ? base_convert ( $buf, 10, 16 ) : "0" . base_convert ( $buf, 10, 16 ) ) . $rd;
  4549.        else
  4550.            for ( $i = 0; $i < $len; $i++ )
  4551.                $res .= ( ( ( $buf = ord ( $st [ $i ] ) ) > 15 ) ? base_convert ( $buf, 10, 16 ) : "0" . base_convert ( $buf, 10, 16 ) ) . $rd;
  4552.  
  4553.        return strtoupper ( $res );
  4554.  
  4555.    }
  4556.    public static function showHex2 ( $st, $rd = " ", $type = false ) {
  4557.  
  4558.        $len = strlen ( $st .= "" );
  4559.        if ( $type )
  4560.            for ( $i = $len - 1; $i >= 0; $i-- )
  4561.                $res .= "\x" . strtoupper( ( ( $buf = ord ( $st [ $i ] ) ) > 15 ) ? base_convert ( $buf, 10, 16 ) : "0" . base_convert ( $buf, 10, 16 ) ) . $rd;
  4562.        else
  4563.            for ( $i = 0; $i < $len; $i++ )
  4564.                $res .= "\x" . strtoupper( ( ( $buf = ord ( $st [ $i ] ) ) > 15 ) ? base_convert ( $buf, 10, 16 ) : "0" . base_convert ( $buf, 10, 16 ) ) . $rd;
  4565.  
  4566.        return ( $res );
  4567.  
  4568.     }  
  4569.     public static function showHtmlContent( $st ) {
  4570.    
  4571.         $res = "";
  4572.        
  4573.        
  4574.         //$res = "<style type=\"text/css\" >.normalViev{ color: #424242; display: inline;}.hexViev{ color: #3000FF;display: inline; }</style>";
  4575.         //$nameClassText = "normalViev";
  4576.         //$nameClassHexViev = "hexViev";
  4577.    
  4578.         $len = strlen( $st );
  4579.         $firstFL = true;
  4580.         $endFL = false;
  4581.         for ( $i = 0; $i < $len; $i++ ) {
  4582.        
  4583.             $ch = ord($st[$i]);
  4584.        
  4585.             if (
  4586.                 ( ( $ch >= 97 ) && ( $ch <= 127 ) ) ||
  4587.                 ( ( $ch >= 65 ) && ( $ch <= 90 ) ) ||
  4588.                 ( ( $ch >= 48 ) && ( $ch <= 57 ) ) ||
  4589.                 ( $ch === 0x20 ) ||
  4590.                 ( $ch === 47 ) //||
  4591.                 //( ( $ch > 0x0A ) && ( $ch < 150 ) )
  4592.                 || ( $ch >= 32 )
  4593.             ) {
  4594.                 /*
  4595.                 if ( $firstFL ) {
  4596.                     $res .= "<p class=\"".$nameClassText."\" >";
  4597.                     $firstFL = false;
  4598.                     $endFL = true;
  4599.                 }
  4600.                 */
  4601.                 $res .= $st[$i];               
  4602.            
  4603.             } else {   
  4604.                 /*
  4605.                 if ( $endFL ) {
  4606.                     $res .= "</p>";
  4607.                     $firstFL = true;
  4608.                     $endFL = false;
  4609.                 }
  4610.                 */
  4611.                 //$res .= "<p class=\"".$nameClassHexViev."\">\x".COM::showHex($st[$i] , "" )."</p>";  
  4612.                 $res .= "\\x".COM::showHex($st[$i] , "" );
  4613.            
  4614.             }
  4615.        
  4616.         }
  4617.        
  4618.         return $res;
  4619.    
  4620.     }
  4621.    
  4622.     public static function getPartBuildPack( $buf ) {  
  4623.    
  4624.         $head  = ord($buf[0]);
  4625.         $total = ord($buf[1]) + ord($buf[2]) * 256;
  4626.         $curr  = ord($buf[3]) + ord($buf[4]) * 256;
  4627.         $size  = ord($buf[7]) + ord($buf[8]) * 256;
  4628.  
  4629.     //echo substr( $buf , 10 , $size ) . "\n";
  4630.         //          head    total   curr                 size  
  4631.         //  pack = \x01  \x01\x00  \x01\x00  \x00\x00  \x1A\x00 \x00    09 65 63 68 6F 20 22 2A 20 50 72 69 76 69 6C 65 67 65 73 20 73 65 74 22 0A 00
  4632.         //  pack = \x01  \x06\x00  \x01\x00  \x00\x00  \x00\x04 \x00    BZ2\x00BZh91AY&SYэЌ­
  4633.         //  pack = \x01  \x01\x00  \x01\x00  \x00\x00  \x5C\x00 \x00    09 65 63 68 6F 20 22 2A 20 D0 9F D1 80 D0 B0 D0 B2 D0 B0 20 D0 B4 D0 BE D1 81 D1 82 D1 83 D0 BF D0 B0 20 D0 BF D1 80 D0 B5 D0 B4 D0 BE D1 81 D1 82 D0 B0 D0 B2 D0 BB D0 B5 D0 BD D1 8B 21 22 0A 00 09 62 69 6E 64 20 22 46 33 22 20 22 6D 65 6E 75 5F 73 65 72 76 65 72 61 22 0A 00
  4634.  
  4635.         return Array(
  4636.             "total" => $total ,
  4637.             "curr"  => $curr ,
  4638.             "size"  => $size ,
  4639.             "part"  => substr( $buf , 10 , $size ) ,
  4640.             "last"  => substr( $buf , 10 + $size )
  4641.         );
  4642.  
  4643.     }
  4644.     public static function addPartToArrayPartsPack( &$parts , $buf ) {
  4645.    
  4646.         if ( empty( $buf["total"] ) || empty( $buf["curr"] ) )
  4647.             return false;
  4648.            
  4649.         if ( empty( $parts ) )
  4650.             $parts = Array(
  4651.                 "total" => $buf["total"] ,
  4652.                 "parts" => Array( $buf["curr"] => $buf )
  4653.             );
  4654.         else {
  4655.        
  4656.             if ( $parts["parts"]["total"] === $buf["total"] )
  4657.                 $parts["parts"][$buf["curr"]] = $buf;
  4658.             else
  4659.                 return false;
  4660.        
  4661.         }
  4662.    
  4663.         return true;
  4664.    
  4665.     }
  4666.     public static function getBuildPack( &$buf ) {
  4667.    
  4668.         $count = count( $buf["parts"] );
  4669.         if ( $count !== count( $buf["total"] ) )
  4670.             return false;
  4671.        
  4672.         ksort( $buf["parts"] );    
  4673.        
  4674.         $res = "";
  4675.        
  4676.         foreach( $buf["parts"] as &$val )  
  4677.             $res .= $val["part"];
  4678.        
  4679.         return ( substr( $res , 0 , 4 ) === "BZ2\x00" ) ? bzdecompress( substr( $res , 4 ) ) : $res;
  4680.    
  4681.     }
  4682.    
  4683.     public static function ParseFile( $data , &$token ) {
  4684.         $i = 0;
  4685.         $len = 0;
  4686.         $token = "";
  4687.         $dataLen = strlen( $data );
  4688.         if ( !$data )
  4689.             return false;
  4690.            
  4691.         // skip whitespace
  4692.         $skipwhite = true;
  4693.         while( $skipwhite ) {
  4694.             $skipwhite = false;
  4695.            
  4696.             while( ( $c = ord( $ch = $data[$i] ) ) <= 32 ) {
  4697.                 if ( $c === 0 )
  4698.                     return false;
  4699.                 $i++;      
  4700.             }
  4701.            
  4702.             if ( ( $ch === "/" ) && ( $data[$i+1] === "/" ) ) {
  4703.                 while( ( $data[$i] === "\x00" ) || ( $data[$i] === "\n" ) )
  4704.                     $i++;
  4705.                 $skipwhite = true;
  4706.             }
  4707.         }
  4708.  
  4709.         // handle quoted strings specially     
  4710.         if ( $ch === "\"" ) {
  4711.             $i++;
  4712.             while( true ) {
  4713.                 $c = ord( $ch = $data[$i] );
  4714.                 $i++;
  4715.                 if ( ( $ch === "\"" ) || ( $c === 0 ) )
  4716.                     return ( $data = substr( $data , $i ) ) ? $data : "";
  4717.                
  4718.                 $token .= $ch;
  4719.                 $len++;
  4720.             }  
  4721.         }
  4722.        
  4723.         // parse single characters 
  4724.         if ( ( $ch == '{' ) || ( $ch == '}' ) || ( $ch == ')' ) || ( $ch == '(' ) || ( $ch == '\'' ) || ( $ch == ',' ) ) {
  4725.             $token .= $ch;
  4726.             $len++;
  4727.             return ( $data = substr( $data , $i + 1 ) ) ? $data : "";
  4728.         }
  4729.        
  4730.         // parse a regular word
  4731.         do {
  4732.             $token .= $ch;
  4733.             $len++;
  4734.             $i++;
  4735.             $c = ord( $ch = $data[$i] );
  4736.             if ( ( $ch == '{' ) || ( $ch == '}' ) || ( $ch == ')' ) || ( $ch == '(' ) || ( $ch == '\'' ) || ( $ch == ',' ) )
  4737.                 break;
  4738.         } while( $c > 32 );
  4739.        
  4740.         return ( $data = substr( $data , $i ) ) ? $data : "";
  4741.  
  4742.     }
  4743.    
  4744. }
  4745. class CONSOLE {
  4746.  
  4747.     public $text = "";
  4748.    
  4749.     public $event_out = true;
  4750.     public $new_line = true;
  4751.    
  4752.     public function event_out_f( $line , $new_line ) {
  4753.    
  4754.         echo ( ( $new_line ) ? "CONSOLE: " : "" ) . $line;
  4755.    
  4756.     }
  4757.     public function print_str( $text , $new_line = Null ) {
  4758.    
  4759.         $new_line = ( $new_line === Null ) ? $this -> new_line : $new_line;
  4760.    
  4761.         $line = $text . ( ( $new_line ) ? "\n" : "" );
  4762.        
  4763.         if ( $this -> event_out )
  4764.             $this -> event_out_f( $line , $new_line );
  4765.            
  4766.         $this -> text .= $line;
  4767.    
  4768.     }
  4769.  
  4770.     public static $thisCL = Null;  
  4771.     public static function getCL() {
  4772.  
  4773.         ( self::$thisCL === Null ) &&
  4774.         ( self::$thisCL = new self() );
  4775.  
  4776.         return self::$thisCL;
  4777.  
  4778.     }
  4779.    
  4780. }
  4781. class CLIENT_CLGAME {
  4782.     public $engine;
  4783.  
  4784.     public $maxEntities;
  4785.     public $mapname;
  4786.     public $maptitle;
  4787.     public $gamefolder;
  4788.     public $features;
  4789.    
  4790.     public function __construct() {
  4791.    
  4792.         global $engine;    
  4793.         $this->engine = $engine;
  4794.        
  4795.     }
  4796.    
  4797.     public static $thisCL = Null;  
  4798.     public static function getCL() {
  4799.  
  4800.         ( self::$thisCL === Null ) &&
  4801.         ( self::$thisCL = new self() );
  4802.  
  4803.         return self::$thisCL;
  4804.  
  4805.     }
  4806.    
  4807. }
  4808. class CLIENT_CL {
  4809.     public $engine;
  4810.    
  4811.     public $protocol = 48;
  4812.     public $servercount;
  4813.     public $checksum;
  4814.     public $playernum;
  4815.     public $maxclients;
  4816.     public $background;
  4817.  
  4818.     public function __construct() {
  4819.    
  4820.         global $engine;    
  4821.         $this->engine = $engine;
  4822.        
  4823.     }
  4824.    
  4825.     public static $thisCL = Null;  
  4826.     public static function getCL() {
  4827.  
  4828.         ( self::$thisCL === Null ) &&
  4829.         ( self::$thisCL = new self() );
  4830.  
  4831.         return self::$thisCL;
  4832.  
  4833.     }
  4834.    
  4835. }
  4836. class SOUND_VOICE {
  4837.  
  4838.     public $voice_data;
  4839.     public $curr_id = 0;
  4840.     public $min_time = 0;
  4841.     public $last_time = 0;
  4842.     public $need_interval = 2147483640;
  4843.     public $speed = 20;
  4844.     public $begin_run = true;
  4845.     public $voice_count = 0;
  4846.  
  4847.     public function getTime() {
  4848.    
  4849.         $time = microtime();
  4850.         $time = explode( " " , $time );
  4851.         return (int)( ($time[1] + $time[0] )*1000 );
  4852.        
  4853.     }
  4854.     public function get() {
  4855.         $time = $this->getTime();
  4856.        
  4857.         if ( $this -> begin_run ) {    
  4858.             $this->last_time = $time - $this->voice_data[$this->curr_id]["t"];     
  4859.             $this->curr_id = 0;
  4860.             $this->voice_count = count($this->voice_data);
  4861.             $this->begin_run = false;
  4862.         }
  4863.         if ( $time - $this->last_time > $this->voice_data[$this->curr_id+1]["t"] ) {
  4864.             $this->curr_id++;
  4865.             if ( $this->curr_id >= $this->voice_count ) {
  4866.                 $this->begin_run = true;
  4867.                 return false;
  4868.             }              
  4869.             return $this->voice_data[$this->curr_id-1]["d"];           
  4870.         }
  4871.  
  4872.         return false;
  4873.        
  4874.     }
  4875.  
  4876.     public function __construct() {
  4877.    
  4878.         global $VOICE_DATA;
  4879.         $this -> voice_data = &$VOICE_DATA;
  4880.    
  4881.     }
  4882.    
  4883.     public static $thisCL = Null;  
  4884.     public static function getCL() {
  4885.  
  4886.         ( self::$thisCL === Null ) &&
  4887.         ( self::$thisCL = new self() );
  4888.  
  4889.         return self::$thisCL;
  4890.  
  4891.     }
  4892.    
  4893. }
  4894. class CLIENT_ENGINE {
  4895.  
  4896.     public $cvarlist;
  4897.     public $cmdlist;
  4898.     public $userinfolist;
  4899.     public $cmdExecute;
  4900.     public $svc;
  4901.     public $user_msg;
  4902.     public $clc;
  4903.     public $net;
  4904.     public $server;
  4905.     public $console;
  4906.     public $cl;
  4907.     public $clgame;
  4908.     public $voice;
  4909.     public $max_frame = 100;
  4910.    
  4911.     public $state = 0;  //  0 => disconnected | 1 => connect_first | 2 => connect
  4912.    
  4913.     private $NET_FRAME_LIST = Array();
  4914.     public $NET_FRAME_COUNT = 1;
  4915.    
  4916.     public $Cmd_Args = "";
  4917.     public $Cmd_Argv = Array();
  4918.     public $Cmd_Argc = 0;
  4919.    
  4920.     public function Cvar_Get( $name ) {
  4921.    
  4922.         return $this -> cvarlist -> getCVAR( $name , $val );   
  4923.    
  4924.     }
  4925.     public function Cvar_Set( $name , $val ) {
  4926.    
  4927.         return $this -> cvarlist -> setCVAR( $name , $val );
  4928.    
  4929.     }
  4930.  
  4931.     public function Cmd_TokenizeString( $text ) {
  4932.        
  4933.         $MAX_CMD_TOKENS = 255;
  4934.         $this -> Cmd_Argf = "";
  4935.         $this -> Cmd_Args = "";
  4936.         $this -> Cmd_Argv = Array();
  4937.         $this -> Cmd_Argc = 0;
  4938.        
  4939.         if( !$text )
  4940.             return;
  4941.        
  4942.         $this -> Cmd_Argf = $text;
  4943.        
  4944.         $i = 0;
  4945.         while( strlen( $text ) > 0 ) {
  4946.             // skip whitespace up to a /n
  4947.             while( ( $text[$i] ) && ( ( $c = ord( $ch = $text[$i] ) ) > 0 ) && ( $c <= 32 ) && ( $ch !== "\n" ) )
  4948.                 $i++;
  4949.            
  4950.             if ( $ch === "\n" ) {
  4951.                 // a newline seperates commands in the buffer
  4952.                 $i++;
  4953.                 break;
  4954.             }
  4955.  
  4956.             if ( !( $text[$i] ) )
  4957.                 return;
  4958.        
  4959.             if ( $this -> Cmd_Argc === 1 )
  4960.                 $this -> Cmd_Args = $text;
  4961.            
  4962.             $cmd_token = "";
  4963.            
  4964.             $text = COM::ParseFile( $text , $cmd_token );
  4965.            
  4966.             if ( $text === false )
  4967.                 return;
  4968.  
  4969.             if( $this -> Cmd_Argc < $MAX_CMD_TOKENS ) {
  4970.                 $this -> Cmd_Argv[$this -> Cmd_Argc] = $cmd_token;
  4971.                 $this -> Cmd_Argc++;
  4972.             }
  4973.         }
  4974.     }  
  4975.     public function Cmd_ExecuteString( $text, $source = "Cmd_ExecuteString", $notFWD = false ) {
  4976.    
  4977.         if ( !$text )
  4978.             return false;
  4979.  
  4980.         $text = trim( $text );
  4981.        
  4982.         $this -> Cmd_TokenizeString( $text );
  4983.        
  4984.         if ( ( $this -> Cmd_Argc === 0 ) || ( !$this -> Cmd_Argc ) )
  4985.             return false;
  4986.    
  4987.         $cmd = $this -> cmdlist ->getCMD( $this -> Cmd_Argv[0] );
  4988.        
  4989.         if ( $cmd ) {
  4990.             $this -> cmdExecute -> execute( $cmd );    
  4991.             return true;
  4992.         }      
  4993.    
  4994.         $cvar = $this -> cvarlist ->getCVAR( $this -> Cmd_Argv[0] );
  4995.  
  4996.         if ( $cvar ) {
  4997.             $this -> cvarlist -> setCvar( $this -> Cmd_Argv[0] , $this -> Cmd_Argv[1] );
  4998.             return true;
  4999.         }      
  5000.        
  5001.         if ( ( $this -> state >= 2 ) && ( !$notFWD ) )
  5002.             $this -> Cmd_ForwardToServer( $source );   
  5003.  
  5004.         return false;
  5005.            
  5006.     }
  5007.     public function Cbuf_Execute( $text , $source = "Cbuf_Execute" ) {
  5008.  
  5009.         $not_quotes = true;
  5010.         $i = 0;
  5011.         $len = strlen( $text );
  5012.        
  5013.         while( $i < $len ) {
  5014.        
  5015.             $b = $i;
  5016.             while( $i < $len ) {
  5017.            
  5018.                 $ch = $text[$i];
  5019.                 $i++;
  5020.                
  5021.                 if ( $ch === "\"" )
  5022.                     $not_quotes = !$not_quotes;
  5023.                
  5024.                 if ( ( $not_quotes ) &&  ( $ch === ";" ) )
  5025.                     break; // don't break if inside a quoted string
  5026.                
  5027.                 if ( ( ord($ch) === 0 ) || ( $ch === "\n" ) || ( $ch === "\r" ) )
  5028.                     break;
  5029.                                            
  5030.             }
  5031.             $this -> Cmd_ExecuteString( substr( $text , $b , $i - $b ) , $source );    
  5032.         }
  5033.    
  5034.     }
  5035.  
  5036.     public function ClientCmd( $text , $source = "ClientCmd" ) {
  5037.    
  5038.         $this -> Cmd_ExecuteString( $text , $source , false );
  5039.    
  5040.     }
  5041.     public function CBuf_AddText( $text , $source = "CBuf_AddText" ) {
  5042.        
  5043.         $text = trim( $text );
  5044.    
  5045.         $this -> Cbuf_Execute( $text , $source );      
  5046.    
  5047.     }
  5048.     public function Cmd_ForwardToServer( $source = "Cmd_ForwardToServer" ) {
  5049.  
  5050.         if ( $this -> state >= 2 )             
  5051.             return $this -> clc -> execute( "STRINGCMD" , $this -> Cmd_Argv[0] . $this -> Cmd_Args );
  5052.         else
  5053.             return false;
  5054.        
  5055.     }
  5056.  
  5057.     public function NET_FRAME_FIRST() {
  5058.        
  5059.         $this -> NET_FRAME_COUNT = 1;
  5060.  
  5061.         $this -> clc -> execute( "STRINGCMD" , "new" );
  5062.        
  5063.     }
  5064.     public function NET_FRAME() {
  5065.  
  5066.         if ( $this -> NET_FRAME_COUNT >= $this -> max_frame )
  5067.             $this -> net -> disconnect();
  5068.  
  5069.         if ( $this -> NET_FRAME_COUNT == 40 )
  5070.             $this -> clc -> execute( "STRINGCMD" , "sendres" );
  5071.  
  5072.            
  5073.         $this -> NET_FRAME_EXECUTE();      
  5074.         $this -> NET_FRAME_COUNT++;
  5075.    
  5076.     }  
  5077.     public function NET_FRAME_ADD( $c1 , $c2 = Null ) {
  5078.    
  5079.         $id = $this -> NER_FRAME_GET_ID( $c1 , $c2 );
  5080.         if ( !( $id === false ) )
  5081.             return false;
  5082.    
  5083.         if ( $c2 === Null ) {
  5084.        
  5085.             if ( function_exists( $c1 ) ) {
  5086.  
  5087.                 $this -> NET_FRAME_LIST[] = Array( "type" => "function" , "c1" => $c1 );
  5088.            
  5089.                 return true;
  5090.                
  5091.             }
  5092.            
  5093.             return false;
  5094.            
  5095.         } else {
  5096.            
  5097.             if ( method_exists( $c1 , $c2 ) ) {
  5098.  
  5099.                 $this -> NET_FRAME_LIST[] = Array( "type" => "method" , "c1" => $c1 , "c2" => $c2 );
  5100.            
  5101.                 return true;
  5102.                
  5103.             }      
  5104.        
  5105.         }
  5106.    
  5107.     }
  5108.     public function NET_FRAME_REMOVE( $c1 , $c2 = Null , $index = Null ) {
  5109.    
  5110.         if ( !( $index === Null ) ) {
  5111.             if ( empty( $this -> NET_FRAME_LIST[$index] ) )        
  5112.                 return false;              
  5113.             else {
  5114.                
  5115.                 unset( $this -> NET_FRAME_LIST[$index] );
  5116.                
  5117.                 return true;
  5118.             }
  5119.         }
  5120.        
  5121.         $id = $this -> NER_FRAME_GET_ID( $c1 , $c2 );
  5122.         if ( $id === false )
  5123.             return false;
  5124.            
  5125.         unset( $this -> NET_FRAME_LIST[$id] );
  5126.        
  5127.         return true;
  5128.    
  5129.     }
  5130.     private function NER_FRAME_GET_ID( $c1 , $c2 = Null ) {
  5131.  
  5132.         if ( $c2 === Null ) {  
  5133.             foreach ( $this -> NET_FRAME_LIST as $id => &$val )
  5134.                 if ( ( $val["type"] === "function" ) && ( $val["c1"] === $c1 ) )                                           
  5135.                     return $id;
  5136.         } else {       
  5137.             foreach ( $this -> NET_FRAME_LIST as $id => &$val )
  5138.                 if ( ( $val["type"] === "method" ) && ( $val["c1"] === $c1 ) && ( $val["c2"] === $c2 ) )
  5139.                     return $id;
  5140.         }
  5141.        
  5142.         return false;
  5143.    
  5144.     }
  5145.     private function NET_FRAME_EXECUTE() {
  5146.  
  5147.         foreach ( $this -> NET_FRAME_LIST as &$val ) {
  5148.        
  5149.             if ( $val["type"] === "function" ) {
  5150.                
  5151.                 $val["c1"]();
  5152.            
  5153.             } elseif ( $val["type"] === "method" ) {
  5154.            
  5155.                 $val["c1"]->{$val["c2"]}();
  5156.            
  5157.             }
  5158.        
  5159.         }  
  5160.    
  5161.     }
  5162.    
  5163.     public function __construct() {
  5164.    
  5165.         global $engine;    
  5166.         $engine = $this;
  5167.    
  5168.         $this -> userinfolist = CLIENT_USER_INFO_LIST::getCL();
  5169.         $this -> cvarlist = CLIENT_CVAR_LIST::getCL();
  5170.         $this -> cmdlist = CLIENT_CMD_LIST::getCL();
  5171.         $this -> cmdExecute = CLIENT_CMD_FUNCTIONS::getCL();
  5172.         //$this -> svs = SVC_CMD::getCL();
  5173.         //$this -> user_msg = USER_MESSAGE::getCL();
  5174.         $this -> net = NET::getCL();
  5175.         $this -> clc = CLIENT_CLC_FUNCTIONS::getCL();
  5176.         $this -> server = CL_SERVER::getCL();
  5177.         $this -> console = CONSOLE::getCL();
  5178.         $this -> cl = CLIENT_CL::getCL();
  5179.         $this -> clgame = CLIENT_CLGAME::getCL();
  5180.         $this -> voice = SOUND_VOICE::getCL();
  5181.    
  5182.     }
  5183.    
  5184.     public static $thisCL = Null;  
  5185.     public static function getCL() {
  5186.  
  5187.         ( self::$thisCL === Null ) &&
  5188.         ( self::$thisCL = new self() );
  5189.  
  5190.         return self::$thisCL;
  5191.  
  5192.     }
  5193.    
  5194. }
  5195.  
  5196.  
  5197. echo "<pre>";
  5198.  
  5199. $engine = CLIENT_ENGINE::getCL();
  5200.  
  5201. $engine -> max_frame = 1000;
  5202.  
  5203. $engine -> CBuf_AddText( "name \"dfgsdg\"" );
  5204.  
  5205. $engine -> CBuf_AddText( "cl_cmdrate 80" );
  5206.  
  5207. $engine -> CBuf_AddText( "setinfo _pw \"asf\"" );
  5208.  
  5209. $engine -> CBuf_AddText( "connect 127.0.0.1:43" );
  5210.  
  5211. $if_voice_enabled = false;
  5212.  
  5213. $say_count_add = 123;
  5214.  
  5215. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement