xml_config_creator.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) Copyright (C) 2008 - 2013 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. <h2>XML Config Creator</h2>
  27. <table BORDER=1>
  28. <tr>
  29. <td>
  30. Query protocol
  31. </td>
  32. <form action="" method="POST">
  33. <td>
  34. <select name="protocol" onchange="this.form.submit()">
  35. <option value="">None</option>
  36. <option value="lgsl" <?php if(isset($_POST['protocol']) && $_POST['protocol'] == "lgsl") echo 'selected="selected"';?>>LGSL</option>
  37. <option value="gameq" <?php if(isset($_POST['protocol']) && $_POST['protocol'] == "gameq") echo 'selected="selected"';?>>GameQ</option>
  38. </select>
  39. </td>
  40. </form>
  41. </tr>
  42. <form action='home.php?m=config_games&p=cli-params&type=cleared' method='POST' name='xml_creator'>
  43. <?php
  44. if(isset($_POST['protocol']))
  45. {
  46. echo "
  47. <tr>
  48. <td>
  49. <input type='hidden' name='protocol' value='".$_POST['protocol']."'/>
  50. ";
  51. if($_POST['protocol'] == "lgsl")
  52. {
  53. echo "LGSL Query Name</td><td><select name='query_name'>";
  54. require('protocol/lgsl/lgsl_protocol.php');
  55. $lgsl_type_list = lgsl_type_list();
  56. asort($lgsl_type_list);
  57. foreach ($lgsl_type_list as $type => $description)
  58. {
  59. echo "<option value='$type'>$description</option>";
  60. }
  61. }
  62. elseif($_POST['protocol'] == "gameq")
  63. {
  64. require 'protocol/GameQ/GameQ.php';
  65. // Define the protocols path
  66. $protocols_path = "protocol/GameQ/gameq/protocols/";
  67. // Grab the dir with all the classes available
  68. $dir = dir($protocols_path);
  69. $protocols = array();
  70. // Now lets loop the directories
  71. while (false !== ($entry = $dir->read()))
  72. {
  73. if(!is_file($protocols_path.$entry))
  74. {
  75. continue;
  76. }
  77. // Figure out the class name
  78. $class_name = 'GameQ_Protocols_'.ucfirst(pathinfo($entry, PATHINFO_FILENAME));
  79. // Lets get some info on the class
  80. $reflection = new ReflectionClass($class_name);
  81. // Check to make sure we can actually load the class
  82. if(!$reflection->IsInstantiable())
  83. {
  84. continue;
  85. }
  86. // Load up the class so we can get info
  87. $class = new $class_name;
  88. // Add it to the list
  89. $protocols[$class->name()] = array(
  90. 'name' => $class->name_long(),
  91. 'port' => $class->port(),
  92. 'state' => $class->state(),
  93. );
  94. // Unset the class
  95. unset($class);
  96. }
  97. // Close the directory
  98. unset($dir);
  99. ksort($protocols);
  100. echo "GameQ Query Name</td><td><select name='query_name'>";
  101. foreach ($protocols AS $gameq => $info)
  102. {
  103. echo "<option value='".$gameq."'>".htmlentities($info['name'])."</option>";
  104. }
  105. }
  106. echo "
  107. </select>
  108. </td>
  109. </tr>";
  110. }
  111. else
  112. ?>
  113. <tr>
  114. <td>
  115. OS:
  116. </td>
  117. <td>
  118. <select name="os">
  119. <option value="linux">Linux</option>
  120. <option value="win">Windows</option>
  121. </select>
  122. </td>
  123. </tr>
  124. <tr>
  125. <td>
  126. Architecture
  127. </td>
  128. <td>
  129. <select name="arch">
  130. <option value="32">32bit</option>
  131. <option value="64">64bit</option>
  132. </select>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>
  137. Installer
  138. </td>
  139. <td>
  140. <select name="installer">
  141. <option value="">None</option>
  142. <option value="steam">HLDSUpdateTool</option>
  143. </select>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td>
  148. <input name="main" type="submit"/>
  149. </form>
  150. </td>
  151. </tr>
  152. </table>
  153. <?php
  154. }