show_homes.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 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, $view, $loggedInUserInfo;
  27. $page_GameHomes = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  28. $limit_GameHomes = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  29. $searchString = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
  30. $searchTypes = array('ip_port' => 'IP / Port', 'ownedBy' => 'Server Owner', 'rserver' => 'Remote Server', 'home_name' => 'Server Name');
  31. $searchType = isset($_GET['searchType']) ? $_GET['searchType'] : false;
  32. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !(isset($_GET['limit']) and !empty($_GET['limit']))){
  33. $limit_GameHomes = $loggedInUserInfo["users_page_limit"];
  34. }
  35. $game_homes = $db->getGameHomes_limit($page_GameHomes, $limit_GameHomes, $searchType, $searchString);
  36. echo "<h2>".get_lang('game_servers')."</h2>";
  37. echo '<table style="width: 100%; margin-bottom: 50px;">
  38. <tr>
  39. <td style="width: 50%; vertical-align: middle; text-align: left;">
  40. <p><a href="?m=user_games&amp;p=add">'.get_lang("add_new_game_home").'</a></p>
  41. </td>
  42. <td style="width: 50%; vertical-align: middle; text-align: right;">
  43. <form action="home.php" method="GET" style="float:right;">
  44. <input type ="hidden" name="m" value="user_games" />
  45. '. create_drop_box_from_array($searchTypes, 'searchType', $searchType, false) .'
  46. <input name="search" type="text" id="search" value="' . $searchString . '" />
  47. <input type="submit" value="'.get_lang('search').'" />
  48. </form>
  49. </td>
  50. </tr>
  51. </table>';
  52. if (empty($game_homes)) {
  53. if (!empty($search_field)) {
  54. print_failure(get_lang_f('no_results_found', htmlentities($search_field)));
  55. $view->refresh("?m=user_games", 5);
  56. } else {
  57. print_failure(get_lang('no_game_homes_found'));
  58. }
  59. return;
  60. }
  61. echo "<h2>".get_lang('available_game_homes')."</h2>";
  62. echo '<table class="center">';
  63. echo "<tr><th>".get_lang('home_id')."</th><th>".get_lang('game_server')."</th>
  64. <th>".get_lang('game_type')."</th>
  65. <th align='center'>".get_lang('game_home')."</th>
  66. <th>".get_lang('game_home_name')."</th>
  67. <th>".get_lang('server_expiration_date')."</th>
  68. <th>".get_lang('actions')."</th></tr>";
  69. $i = 0;
  70. // sort($game_homes);
  71. foreach( $game_homes as $row )
  72. {
  73. $display_ip = checkDisplayPublicIP($row['display_public_ip'], (isset($row['ip']) and $row['ip'] != $row['agent_ip']) ? $row['ip'] : $row['agent_ip']);
  74. $os_arch = preg_match('/win/',$row['game_key']) ? "(Windows" : "(Linux";
  75. $os_arch .= preg_match('/(win|linux)64/',$row['game_key']) ? " 64bit)" : ")";
  76. echo "<tr class='tr".($i++%2)."'><td class='tdh'>" . $row['home_id'] . "</td><td>".$display_ip."</td>".
  77. "<td class='tdh'>" . $row['game_name'] . $os_arch . "</td><td>" . $row['home_path'] . "<br><div class='size' id='".$row["home_id"].
  78. "' style='cursor:pointer;' >[".get_lang('get_size')."]</div></td><td class='tdh'>";
  79. echo empty($row['home_name']) ? get_lang('not_available') : htmlentities($row['home_name']);
  80. $expiration_date = $row['server_expiration_date'] == "X" ? "X" : date('d/m/Y H:i:s', $row['server_expiration_date']);
  81. echo "</td><td>".$expiration_date."</td><td>
  82. <a href='?m=user_games&amp;p=del&amp;home_id=" . $row['home_id'] . "'>[".get_lang('delete')."]</a>
  83. <a href='?m=user_games&amp;p=edit&amp;home_id=" . $row['home_id'] . "'>[".get_lang('edit')."]</a>
  84. <a href='?m=user_games&amp;p=clone&amp;home_id=" . $row['home_id'] . "'>[".get_lang('clone')."]</a>
  85. </td></tr>";
  86. }
  87. 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' ".
  88. "style='cursor:pointer;float:left;margin-left:5px;' >[".get_lang('get_size')."]</div></td><td colspan='2' style='border:none;' ></td></tr>";
  89. echo "</table>";
  90. $count_GameHomes = $db->get_GameHomes_count($searchType, $searchString);
  91. if (isset($_GET['search']) && !empty($_GET['search'])) {
  92. $uri = '?m=user_games&search='.$_GET['search'].'&limit='.$limit_GameHomes.'&page=';
  93. } else {
  94. $uri = '?m=user_games&limit='.$limit_GameHomes.'&page=';
  95. }
  96. echo paginationPages($count_GameHomes[0]['total'], $page_GameHomes, $limit_GameHomes, $uri, 3, 'userGames');
  97. ?>
  98. <script type="text/javascript">
  99. $('.size').click(function(){
  100. var $id = $(this).attr('id');
  101. $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id="+$id, function( data ) {
  102. $('#'+$id+".size").text( data );
  103. });
  104. });
  105. </script>
  106. <?php
  107. }
  108. ?>