install_cmds.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. require_once("modules/config_games/server_config_parser.php");
  25. function exec_ogp_module()
  26. {
  27. $home_id = $_GET['home_id'];
  28. $mod_id = $_GET['mod_id'];
  29. global $db;
  30. $home_info = $db->getGameHome($home_id);
  31. if ( array_key_exists($mod_id, $home_info['mods']) )
  32. {
  33. echo "<h2>".get_lang('cmds_for')." \"".htmlentities($home_info['home_name'])."\" [Mod:".$home_info['mods'][$mod_id]['mod_name']."]</h2>";
  34. $server_xml = read_server_config(SERVER_CONFIG_LOCATION.$home_info['home_cfg_file']);
  35. $mod_cfg_id = $home_info['mods'][$mod_id]['mod_cfg_id'];
  36. if(isset($_POST['edit_preinstall_cmds']))
  37. {
  38. $precmd = $db->real_escape_string($_POST['edit_preinstall_cmds']);
  39. if( isset( $_POST['save_as_default'] ) )
  40. {
  41. $game_mod_query = "UPDATE OGP_DB_PREFIXconfig_mods SET def_precmd='$precmd' WHERE mod_cfg_id='$mod_cfg_id'";
  42. $db->query($game_mod_query);
  43. }
  44. else
  45. {
  46. $game_mod_query = "UPDATE OGP_DB_PREFIXgame_mods SET precmd='$precmd' WHERE mod_id='$mod_id'";
  47. $db->query($game_mod_query);
  48. }
  49. $home_info = $db->getGameHome($home_id);
  50. }
  51. if(isset($_POST['edit_postinstall_cmds']))
  52. {
  53. $postcmd = $db->real_escape_string($_POST['edit_postinstall_cmds']);
  54. if( isset( $_POST['save_as_default'] ) )
  55. {
  56. $game_mod_query = "UPDATE OGP_DB_PREFIXconfig_mods SET def_postcmd='$postcmd' WHERE mod_cfg_id='$mod_cfg_id'";
  57. $db->query($game_mod_query);
  58. }
  59. else
  60. {
  61. $game_mod_query = "UPDATE OGP_DB_PREFIXgame_mods SET postcmd='$postcmd' WHERE mod_id='$mod_id'";
  62. $db->query($game_mod_query);
  63. }
  64. $home_info = $db->getGameHome($home_id);
  65. }
  66. $precmd = $home_info['mods'][$mod_id]['precmd'] == "" ?
  67. ( $home_info['mods'][$mod_id]['def_precmd'] == "" ? $server_xml->pre_install :
  68. $home_info['mods'][$mod_id]['def_precmd'] ) : $home_info['mods'][$mod_id]['precmd'];
  69. $postcmd = $home_info['mods'][$mod_id]['postcmd'] == "" ?
  70. ( $home_info['mods'][$mod_id]['def_postcmd'] == "" ? $server_xml->post_install :
  71. $home_info['mods'][$mod_id]['def_precmd'] ) : $home_info['mods'][$mod_id]['postcmd'];
  72. ?>
  73. <h2><?php
  74. print_lang('preinstall_cmds');
  75. ?></h2>
  76. <table class="center">
  77. <tr>
  78. <td>
  79. <form method="POST">
  80. <textarea name="edit_preinstall_cmds" placeholder="<?php echo "[".get_lang('empty')."]"; ?>" style="width:80%;height:200px;" ><?php
  81. echo $precmd;
  82. ?></textarea>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td>
  87. <button><?php
  88. print_lang('edit_preinstall_cmds');
  89. ?></button>
  90. <input type="checkbox" name="save_as_default" value="true"/><?php print_lang('save_as_default_for_this_mod');?>
  91. </form>
  92. </td>
  93. </tr>
  94. </table>
  95. <h2><?php
  96. print_lang('postinstall_cmds');
  97. ?></h2>
  98. <table class="center">
  99. <tr>
  100. <td>
  101. <form method="POST">
  102. <textarea name="edit_postinstall_cmds" placeholder="<?php echo "[".get_lang('empty')."]"; ?>" style="width:80%;height:200px;" ><?php
  103. echo $postcmd;
  104. ?></textarea>
  105. </td>
  106. </tr>
  107. <tr>
  108. <td>
  109. <button><?php
  110. print_lang('edit_postinstall_cmds');
  111. ?></button>
  112. <input type="checkbox" name="save_as_default" value="true"/><?php print_lang('save_as_default_for_this_mod');?>
  113. </form>
  114. </td>
  115. </tr>
  116. </table><?php
  117. }
  118. echo create_back_button('user_games','edit&amp;home_id='.$home_id);
  119. }
  120. ?>