Net_GameServerQuery
[ class tree: Net_GameServerQuery ] [ index: Net_GameServerQuery ] [ all elements ]

Source for file example5.php

Documentation is available at example5.php

  1. <html>
  2. <head>
  3.     <title>Net_GameServerQuery Example 5: A more advanced server listing</title>
  4. </head>
  5. <body>
  6. <h1>Net_GameServerQuery Example 5: A more advanced server listing</h1>
  7. <p>This example, like Example 4, shows how you could use Net_GameServerQuery to show a list of your favorite servers.</p>
  8. <p>However, in this example, we go a little further showing the rules and players in each server.</p>
  9. <p>We also sort the players by kill, and the server list by the game.</p>
  10. <?php
  11. require_once 'Net/GameServerQuery.php';
  12.  
  13. // Add servers
  14. $gsq = new Net_GameServerQuery;
  15. $gsq->addServer('callofduty',   'games01.syd.optusnet.com.au',  '24020');
  16. $gsq->addServer('callofduty',   'games01.syd.optusnet.com.au',  '24000');
  17. $gsq->addServer('halflife',     'games07.syd.optusnet.com.au',  '24000');
  18. $gsq->addServer('halflife',     'games07.syd.optusnet.com.au',  '24010');
  19. $gsq->addServer('halflife',     'games07.syd.optusnet.com.au',  '24020');
  20. $gsq->addServer('halflife',     'games07.syd.optusnet.com.au',  '24030');
  21. $gsq->addServer('halflife',     'games12.syd.optusnet.com.au',  '24020');
  22. $gsq->addServer('halflife',     'games06.syd.optusnet.com.au',  '24280');
  23. $gsq->addServer('quake3',       'games02.syd.optusnet.com.au',  '22020');
  24. $gsq->addServer('quake3',       'games02.syd.optusnet.com.au',  '22070');
  25. $gsq->addServer('quake3',       'games02.syd.optusnet.com.au',  '22000');
  26. $gsq->addServer('quake3',       'games02.syd.optusnet.com.au',  '22010');
  27.  
  28. // Execute
  29. $results $gsq->execute();
  30.  
  31. // Sort the data by the game
  32. foreach ($results as $result{
  33.     $data[$result['meta']['game']][$result;
  34. }
  35. $template['data'$data;
  36.  
  37. // Check if we need to make additional queries
  38. if (isset($_GET['view'])) {
  39.     $serverkey $gsq->addServer($_GET['game']$_GET['view']$_GET['port']'players|rules');
  40.     $result $gsq->execute();
  41.     $template['moreinfo'$result[$serverkey];
  42. }
  43.  
  44. // Let the template file handle the display
  45. require 'example5.tpl.php';
  46.  
  47. ?>
  48. </body>
  49. </html>

Documentation generated on Mon, 11 Mar 2019 15:39:46 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.