Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl


mizii
Napisane: 19.10.2015, 10:33:09





Grupa: Zarejestrowani
Postów: 86
Dołączył: 19.10.2015

Ostrzeżenie: (0%)
-----

troche odkopany z forum z 2004r trafilem na taki kod nie wiem czy dziala


  1. <?php
  2.  
  3. /**
  4. * pobiera informacje z serwera i zwraca tablice z tymi danymi
  5. *
  6. * @param string $intServerIP Adres IP serwera
  7. * @param integer $intServerPort Port serwera
  8. * @return array
  9. */
  10. function RetriveInfo ( $strServerIP = '127.0.0.1', $intServerPort = 27015 )
  11. {
  12. $connection = fsockopen( \"udp://\" . $strServerIP, $intServerPort );
  13. fwrite( $connection, sprintf( '%c%c%c%c%s%c', 0xFF, 0xFF, 0xFF, 0xFF, \"infostring\", 0x00 ) );
  14. fread( $connection, 24 );
  15. $status = socket_get_status( $connection );
  16. if ( $status[\"unread_bytes\"] != 0 )
  17. {
  18. $return = \"\";
  19. while ( $status[\"unread_bytes\"] != 0 )
  20. {
  21. $return .= fread( $connection, 1 );
  22. $status = socket_get_status( $connection );
  23. }
  24.  
  25. $return = explode( '', $return );
  26.  
  27. $arr = array();
  28. $arr['ip'] = $intServerIP;
  29. $arr['port'] = $intServerPort;
  30. $arr['hostname'] = $return[19];
  31. $arr['game'] = $return[17];
  32. $arr['players'] = $return[5];
  33. $arr['maxplayers'] = $return[11];
  34. $arr['system'] = ( $return[25] == \"w\" ) ? \"Windows\" : \"Linux\";
  35. $arr['game_dir'] = $return[15];
  36. $arr['map'] = $return[21];
  37. $arr['password'] = ( $return[25] == \"0\" ) ? false : true;
  38. $arr['secure'] = $return[29];
  39. return $arr;
  40. }
  41. else
  42. {
  43. // blad?
  44. return $arr;
  45. }
  46. }
  47. ?>


  Forum: PHP · Podgląd postu: #1174139 · Odpowiedzi: 2 · Wyświetleń: 2 267


New Posts  Nowe odpowiedzi
No New Posts  Brak nowych odpowiedzi
Hot topic  Popularny temat (Nowe)
No new  Popularny temat (Brak nowych)
Poll  Sonda (Nowe)
No new votes  Sonda (Brak nowych)
Closed  Zamknięty temat
Moved  Przeniesiony temat
 

RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 19:28