@@ -207,20 +207,15 @@ private function authorize()
207
207
*/
208
208
protected function getResponse ()
209
209
{
210
- $ get = function () {
211
- return substr (fread ($ this ->socket , 102400 ), strlen ($ this ->head ));
212
- };
213
-
214
- $ output = '' ;
215
- do {
216
- $ answer = $ get ();
217
- while (strpos ($ answer , 'RCon admin ' ) !== false ) {
218
- $ answer = $ get ();
219
- }
220
-
221
- $ output .= $ answer ;
222
- } while (!empty ($ answer ));
223
-
210
+ $ output = '' ;
211
+
212
+ $ temp = fread ($ this ->socket , 102400 );
213
+ while ($ temp )
214
+ {
215
+ $ output .= $ this ->splitPacket ($ temp );
216
+ $ temp = fread ($ this ->socket , 102400 );
217
+ }
218
+
224
219
return $ output ;
225
220
}
226
221
@@ -269,7 +264,7 @@ private function writeToSocket($message)
269
264
*/
270
265
private function getAuthCRC ()
271
266
{
272
- $ authCRC = sprintf ( ' %x ' , crc32 ( chr (255 ).chr (00 ).trim ($ this ->rconPassword ) ));
267
+ $ authCRC = hash ( ' crc32b ' , chr (255 ).chr (00 ).trim ($ this ->rconPassword ));
273
268
$ authCRC = array (substr ($ authCRC ,-2 ,2 ), substr ($ authCRC ,-4 ,2 ), substr ($ authCRC ,-6 ,2 ), substr ($ authCRC ,0 ,2 ));
274
269
275
270
return $ authCRC ;
@@ -284,7 +279,7 @@ private function getAuthCRC()
284
279
*/
285
280
private function getMsgCRC ($ command )
286
281
{
287
- $ msgCRC = sprintf ( ' %x ' , crc32 ( chr (255 ).chr (01 ).chr (hexdec (sprintf ('%01b ' , 0 ))).$ command) );
282
+ $ msgCRC = hash ( ' crc32b ' , chr (255 ).chr (01 ).chr (hexdec (sprintf ('%01b ' , 0 ))).$ command );
288
283
$ msgCRC = array (substr ($ msgCRC ,-2 ,2 ),substr ($ msgCRC ,-4 ,2 ),substr ($ msgCRC ,-6 ,2 ),substr ($ msgCRC ,0 ,2 ));
289
284
290
285
return $ msgCRC ;
@@ -898,4 +893,23 @@ private function cleanList($str)
898
893
{
899
894
return preg_replace ('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/ ' , '' , $ str );
900
895
}
896
+
897
+ public function splitPacket ( $ data )
898
+ {
899
+ $ responseCode = $ this ->readPackageRaw ($ data );
900
+
901
+ if ($ responseCode [1 ] == "01 " )
902
+ {
903
+ if ($ responseCode [3 ] !== "00 " )
904
+ {
905
+ return substr ($ data , 9 );
906
+ }
907
+ else
908
+ {
909
+ return substr ($ data , 12 );
910
+ }
911
+ }
912
+
913
+ return '' ;
914
+ }
901
915
}
0 commit comments