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

Source for file example5.tpl.php

Documentation is available at example5.tpl.php

  1. <?php
  2. /*
  3.  * This is part of Example 5.
  4.  *
  5.  * This file handles the display of information gathered in example5.php
  6.  */
  7. ?>
  8. <table border="1">
  9.     <tr>
  10.         <th>Server Name</th>
  11.         <th>Map</th>
  12.         <th>Players</th>
  13.         <th>View</th>
  14.     </tr>
  15.     <?php
  16.     $data $template['data'];
  17.     foreach ($data as $game):
  18.         ?>
  19.         <tr>
  20.             <th colspan="4"><?php echo $game[0]['meta']['gametitle']?></th>
  21.         </tr>
  22.         <?php
  23.         foreach ($game as $result):
  24.             $status $result['status'];
  25.             if ($status === false):
  26.                 ?>
  27.                 <tr>
  28.                     <td colspan="4">Server did not reply to request</td>
  29.                 </tr>
  30.                 <?php
  31.             else:
  32.                 ?>
  33.                 <tr>
  34.                     <td><?php echo $status['hostname'];?></td>
  35.                     <td><?php echo $status['map'];?></td>
  36.                     <td><?php echo (int) $status['numplayers'];?> / <?php echo (int) $status['maxplayers'];?></td>
  37.                     <td><a href="<?php
  38.                         $url $_SERVER['SCRIPT_NAME''?view=' $result['meta']['addr'.
  39.                         '&port=' $result['meta']['port''&game=' $result['meta']['game'];
  40.                         echo $url;?>">View</a></td>
  41.                 </tr>
  42.                 <?php
  43.             endif;
  44.         endforeach;
  45.     endforeach;
  46.     ?>
  47. </table>
  48.  
  49. <?php
  50. if (isset($template['moreinfo'])):
  51.     ?>
  52.     <h2>View Server</h2>
  53.     <h3>Players</h3>
  54.     <table border="1" cellpadding="0" cellspacing="0">
  55.         <tr>
  56.             <th>Nick</th>
  57.             <th>Score</th>
  58.         </tr>
  59.         <?php
  60.         $players $template['moreinfo']['players'];
  61.         
  62.         // Sort the players
  63.         $score = array();
  64.         foreach ($players as $player{
  65.             $score[$player['score'];
  66.         }
  67.         array_multisort($scoreSORT_DESCSORT_NUMERIC$players);
  68.         
  69.         // List the info
  70.         foreach ($players as $player):
  71.             ?>
  72.             <tr><td><?php echo $player['name'];?></td><td><?php echo $player['score'];?></td></tr>
  73.             <?php
  74.         endforeach;
  75.         ?>
  76.     </table>
  77.  
  78.     <h3>Rules</h3>
  79.     <table border="1" cellpadding="0" cellspacing="0">
  80.         <tr>
  81.             <th>Rule</th>
  82.             <th>Value</th>
  83.         </tr>
  84.         <?php
  85.         $rules $template['moreinfo']['rules'];
  86.         foreach ($rules as $rule => $value):
  87.             ?>
  88.             <tr><td><?php echo $rule;?></td><td><?php echo $value;?></td></tr>
  89.             <?php
  90.         endforeach;
  91.         ?>
  92.     </table>
  93.     <?php
  94. endif;
  95.  
  96. ?>

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