show_homes.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function exec_ogp_module()
  25. {
  26. global $db, $loggedInUserInfo;
  27. $search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
  28. $page_GameHomes = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  29. $limit_GameHomes = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  30. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
  31. $limit_GameHomes = $loggedInUserInfo["users_page_limit"];
  32. }
  33. echo "<h2>".get_lang('game_servers')."</h2>";
  34. echo '<form action="home.php" method="GET" style="margin-bottom:10px;float:left;">
  35. <p><a href="?m=user_games&amp;p=add">'.get_lang("add_new_game_home").'</a></p>
  36. <input type ="hidden" name="m" value="user_games" />
  37. <input name="search" type="text" id="search" />
  38. <input type="submit" value="search" />
  39. </form>';
  40. $game_homes = $db->getGameHomes_limit($page_GameHomes,$limit_GameHomes,$search_field);
  41. if ( empty($game_homes) )
  42. {
  43. echo "<p>".get_lang('no_game_homes_found')."</p>";
  44. return;
  45. }
  46. echo "<h2>".get_lang('available_game_homes')."</h2>";
  47. echo '<table class="center">';
  48. echo "<tr><th>".get_lang('home_id')."</th><th>".get_lang('game_server')."</th>
  49. <th>".get_lang('game_type')."</th>
  50. <th align='center'>".get_lang('game_home')."</th>
  51. <th>".get_lang('game_home_name')."</th>
  52. <th>".get_lang('server_expiration_date')."</th>
  53. <th>".get_lang('actions')."</th></tr>";
  54. $i = 0;
  55. sort($game_homes);
  56. foreach( $game_homes as $row )
  57. {
  58. $os_arch = preg_match('/win/',$row['game_key']) ? "(Windows" : "(Linux";
  59. $os_arch .= preg_match('/(win|linux)64/',$row['game_key']) ? " 64bit)" : ")";
  60. echo "<tr class='tr".($i++%2)."'><td class='tdh'>$row[home_id]</td><td>".$row['agent_ip']."</td>".
  61. "<td class='tdh'>$row[game_name] $os_arch</td><td>$row[home_path]<br><div class='size' id='".$row["home_id"].
  62. "' style='cursor:pointer;' >[".get_lang('get_size')."]</div></td><td class='tdh'>";
  63. echo empty($row['home_name']) ? get_lang('not_available') : htmlentities($row['home_name']);
  64. $expiration_date = $row['server_expiration_date'] == "X" ? "X" : date('d/m/Y H:i:s', $row['server_expiration_date']);
  65. echo "</td><td>".$expiration_date."</td><td>
  66. <a href='?m=user_games&amp;p=del&amp;home_id=$row[home_id]'>[".get_lang('delete')."]</a>
  67. <a href='?m=user_games&amp;p=edit&amp;home_id=$row[home_id]'>[".get_lang('edit')."]</a>
  68. <a href='?m=user_games&amp;p=clone&amp;home_id=$row[home_id]'>[".get_lang('clone')."]</a>
  69. </td></tr>";
  70. }
  71. echo "<tr><td colspan='3' style='border:none;' ></td><td style='border:none;' ><div style='float:left;margin-left:5px;' >".get_lang('total_size').":</div><div class='size' id='total' ".
  72. "style='cursor:pointer;float:left;margin-left:5px;' >[".get_lang('get_size')."]</div></td><td colspan='2' style='border:none;' ></td></tr>";
  73. echo "</table>";
  74. $count_GameHomes = $db->get_GameHomes_count($search_field);
  75. if(isset($_GET['search']) && !empty($_GET['search'])){
  76. $uri = '?m=user_games&search='.$_GET['search'].'&limit='.$limit_GameHomes.'&page=';
  77. }
  78. else
  79. {
  80. $uri = '?m=user_games&limit='.$limit_GameHomes.'&page=';
  81. }
  82. echo paginationPages($count_GameHomes[0]['total'], $page_GameHomes, $limit_GameHomes, $uri, 3, 'userGames');
  83. ?>
  84. <script type="text/javascript">
  85. $('.size').click(function(){
  86. var $id = $(this).attr('id');
  87. $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id="+$id, function( data ) {
  88. $('#'+$id+".size").text( data );
  89. });
  90. });
  91. </script>
  92. <?php
  93. }
  94. ?>