show_homes.php 4.3 KB

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