create.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. @$arch = $_POST['arch'];
  26. @$os = $_POST['os'];
  27. @$protocol = $_POST['protocol'];
  28. @$query_name = $_POST['query_name'];
  29. @$installer = $_POST['installer'];
  30. @$control_protocol_type = $_POST['control_protocol_type'];
  31. @$control_protocol = $_POST['control_protocol'];
  32. @$query_diff = $_POST['query_diff'];
  33. @$map_location = $_POST['map_location'];
  34. @$maplist_file = $_POST['maplist_file'];
  35. @$max_players_amount = $_POST['max_players_amount'];
  36. @$exec_path = $_POST['exec_path'];
  37. @$server_exec_name = $_POST['server_exec_name'];
  38. @$key_name = $_POST['key_name'];
  39. @$game_name = $_POST['game_name'];
  40. @$pid_file_cli = $_POST['pid_file_cli'];
  41. @$hostname_cli = $_POST['hostname_cli'];
  42. @$players_cli = $_POST['players_cli'];
  43. @$map_cli = $_POST['map_cli'];
  44. @$query_port_cli = $_POST['query_port_cli'];
  45. @$port_cli = $_POST['port_cli'];
  46. @$ip_cli = $_POST['ip_cli'];
  47. @$game_type_cli = $_POST['game_type_cli'];
  48. @$cli_option = $_POST['cli_option'];
  49. @$separator = $_POST['separator'];
  50. @$main_params = $_POST['main_params'];
  51. $template = "
  52. <game_config>
  53. <game_key>$key_name"."_"."$os$arch</game_key>";
  54. if($protocol != "" )
  55. {
  56. $template .= "
  57. <protocol>$protocol</protocol>
  58. <".$protocol."_query_name>$query_name</".$protocol."_query_name>";
  59. }
  60. if($installer != "" )
  61. {
  62. $template .= "<installer>$installer</installer>";
  63. }
  64. $template .= "
  65. <game_name>$game_name</game_name>
  66. <server_exec_name>$server_exec_name</server_exec_name>";
  67. if($query_diff != "" )
  68. {
  69. $template .= "
  70. <query_port type='add'>$query_diff</query_port>";
  71. }
  72. $template .= "
  73. <cli_template>%GAME_TYPE%$separator%IP%$separator%PORT%$separator%QUERY_PORT%$separator%MAP%$separator%PLAYERS%$separator%HOSTNAME%$separator%PID_FILE%</cli_template>
  74. <cli_params>
  75. <cli_param id='GAME_TYPE' cli_string='$game_type_cli' options='$cli_option'/>
  76. <cli_param id='IP' cli_string='$ip_cli' options='$cli_option'/>
  77. <cli_param id='PORT' cli_string='$port_cli' options='$cli_option'/>
  78. <cli_param id='QUERY_PORT' cli_string='$query_port_cli' options='$cli_option'/>
  79. <cli_param id='MAP' cli_string='$map_cli' options='$cli_option'/>
  80. <cli_param id='PLAYERS' cli_string='$players_cli' options='$cli_option'/>
  81. <cli_param id='HOSTNAME' cli_string='$hostname_cli' options='$cli_option'/>
  82. <cli_param id='PID_FILE' cli_string='$pid_file_cli' options='$cli_option' />
  83. </cli_params>";
  84. if($map_location != "" )
  85. {
  86. $template .= "
  87. <maps_location>$map_location</maps_location>";
  88. }
  89. if($maplist_file != "" )
  90. {
  91. $template .= "
  92. <map_list>$maplist_file</map_list>";
  93. }
  94. if($exec_path != "" )
  95. {
  96. $template .= "
  97. <exe_location>$exec_path</exe_location>";
  98. }
  99. if($max_players_amount != "" )
  100. {
  101. $template .= "
  102. <max_user_amount>$max_players_amount</max_user_amount>";
  103. }
  104. if($control_protocol != "" )
  105. {
  106. $template .= "
  107. <control_protocol>$control_protocol</control_protocol>";
  108. }
  109. if($control_protocol_type != "" )
  110. {
  111. $template .= "
  112. <control_protocol_type>$control_protocol_type</control_protocol_type>";
  113. }
  114. $template .= "
  115. <mods>";
  116. if(!isset($_SESSION['mods']))
  117. {
  118. $_SESSION['mods'][1]['mod_name'] = "none";
  119. $_SESSION['mods'][1]['mod_key'] = $key_name;
  120. $_SESSION['mods'][1]['mod_installer_name'] = $key_name;
  121. }
  122. $mods = $_SESSION['mods'];
  123. foreach($mods as $mod)
  124. {
  125. $template .= "
  126. <mod key='".$mod['mod_key']."'>
  127. <name>".$mod['mod_name']."</name>
  128. <installer_name>".$mod['mod_installer_name']."</installer_name>
  129. </mod>";
  130. }
  131. unset($_SESSION['mods']);
  132. $template .= "
  133. </mods>";
  134. if(isset($_SESSION['params']))
  135. {
  136. $template .= "
  137. <server_params>";
  138. $params = $_SESSION['params'];
  139. foreach($params as $param)
  140. {
  141. $template .= "
  142. <param key='".$param['param_key']."' type='".$param['param_type']."'>
  143. <option>".$param['no_space']."</option>
  144. <default>".$param['default']."</default>
  145. <caption>".$param['caption']."</caption>
  146. <desc>".$param['description']."</desc>
  147. </param>";
  148. }
  149. unset($_SESSION['params']);
  150. $template .= "
  151. </server_params>";
  152. }
  153. $template .= "
  154. </game_config>
  155. ";
  156. $myXML = "modules/config_games/server_configs/".$key_name."_".$os.$arch.".xml";
  157. echo "<b>".$myXML."</b>";
  158. echo "<xmp>".$template."</xmp>";
  159. $myXML = "modules/config_games/server_configs/".$key_name."_".$os.$arch.".xml";
  160. $fh = fopen($myXML, 'w') or die("No Write Permission.");
  161. fwrite($fh, $template);
  162. fclose($fh);
  163. }