rcon_presets.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. global $db;
  26. if(isset($_GET['home_id']))
  27. {
  28. $user_id = $_SESSION['user_id'];
  29. $home_id = $_GET['home_id'];
  30. $mod_id = $_GET['mod_id'];
  31. $isAdmin = $db->isAdmin($user_id);
  32. if($isAdmin)
  33. $home_info = $db->getGameHome($home_id);
  34. else
  35. $home_info = $db->getUserGameHome($user_id,$home_id);
  36. $mods = $home_info['mods'];
  37. $current_mod_info = $mods[$mod_id];
  38. $mod_name = $current_mod_info['mod_name'];
  39. $mod_key = $current_mod_info['mod_key'];
  40. if ( strtolower($mod_name) == "none")
  41. $mod = $mod_key;
  42. else
  43. $mod = $mod_name;
  44. $game = $home_info['game_name'];
  45. $home_cfg_id = $current_mod_info['home_cfg_id'];
  46. $mod_cfg_id = $current_mod_info['mod_cfg_id'];
  47. if($home_cfg_id === null && $mod_cfg_id === null){
  48. print_failure(get_lang('invalid_game_mod_id'));
  49. return;
  50. }
  51. echo "<h2>".get_lang_f( "presets_for_game_and_mod",$game,$mod)."</h2>";
  52. if(isset($_POST['add_rcon_preset']))
  53. {
  54. $name = $_POST['name'];
  55. $command = $_POST['command'];
  56. $db->addRconPreset($name,$command,$home_cfg_id,$mod_cfg_id);
  57. }
  58. if(isset($_POST['del_rcon_preset']))
  59. {
  60. $preset_id = $_POST['preset_id'];
  61. $db->delRconPreset($preset_id);
  62. }
  63. if(isset($_POST['change_rcon_preset']))
  64. {
  65. $name = $_POST['name'];
  66. $command = $_POST['command'];
  67. $preset_id = $_POST['preset_id'];
  68. $db->changeRconPreset($name,$command,$preset_id);
  69. }
  70. ?>
  71. <table>
  72. <tr>
  73. <td>
  74. <form action="" method="post">
  75. <?php print_lang('name'); ?>
  76. </td>
  77. <td>
  78. <input type="text" name="name" style="width:120px;" />
  79. </td>
  80. <td>
  81. <?php print_lang('command'); ?>
  82. </td>
  83. <td>
  84. <input type="text" name="command" style="width:430px;" />
  85. </td>
  86. <td>
  87. <input type="submit" value="<?php print_lang('add_preset'); ?>" name="add_rcon_preset" />
  88. </form>
  89. </td>
  90. </tr>
  91. </table>
  92. <br>
  93. <?php
  94. $presets = $db->getRconPresets($home_cfg_id,$mod_cfg_id);
  95. if($presets > 0)
  96. {
  97. echo "<h2>".get_lang("edit_presets")."</h2>";
  98. echo "<table>";
  99. foreach ($presets as $preset)
  100. {
  101. ?>
  102. <tr>
  103. <td>
  104. <form action="" method="post">
  105. <?php print_lang('name'); ?>
  106. </td>
  107. <td>
  108. <input type="text" name="name" style="width:120px;" value="<?php echo $preset['name']; ?>" />
  109. </td>
  110. <td>
  111. <?php print_lang('command'); ?>
  112. </td>
  113. <td>
  114. <input type="text" name="command" style="width:430px;" value="<?php echo $preset['command']; ?>"/>
  115. </td>
  116. <td>
  117. <input type="hidden" name="preset_id" value="<?php echo $preset['preset_id']; ?>" />
  118. <input type="submit" value="<?php print_lang('change_preset'); ?>" name="change_rcon_preset" />
  119. <input type="submit" value="<?php print_lang('del_preset'); ?>" name="del_rcon_preset" />
  120. </form>
  121. </td>
  122. </tr>
  123. <?php
  124. }
  125. }
  126. echo "</table>";
  127. echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_id."'><< ".get_lang('back')."</a></td></tr></table>";
  128. }
  129. }
  130. ?>