xml_config_creator.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. ?>
  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_once 'protocol/GameQ/Autoloader.php';
  65. // Define the protocols path
  66. $protocols_path = "protocol/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->nameLong(),
  91. );
  92. // Unset the class
  93. unset($class);
  94. }
  95. // Close the directory
  96. unset($dir);
  97. ksort($protocols);
  98. echo "GameQ Query Name</td><td><select name='query_name'>";
  99. foreach ($protocols AS $gameq => $info)
  100. {
  101. echo "<option value='".$gameq."'>".htmlentities($info['name'])."</option>";
  102. }
  103. }
  104. echo "
  105. </select>
  106. </td>
  107. </tr>";
  108. }
  109. else
  110. ?>
  111. <tr>
  112. <td>
  113. OS:
  114. </td>
  115. <td>
  116. <select name="os">
  117. <option value="linux">Linux</option>
  118. <option value="win">Windows</option>
  119. </select>
  120. </td>
  121. </tr>
  122. <tr>
  123. <td>
  124. Architecture
  125. </td>
  126. <td>
  127. <select name="arch">
  128. <option value="32">32bit</option>
  129. <option value="64">64bit</option>
  130. </select>
  131. </td>
  132. </tr>
  133. <tr>
  134. <td>
  135. Installer
  136. </td>
  137. <td>
  138. <select name="installer">
  139. <option value="">None</option>
  140. <option value="steam">HLDSUpdateTool</option>
  141. </select>
  142. </td>
  143. </tr>
  144. <tr>
  145. <td>
  146. <input name="main" type="submit"/>
  147. </form>
  148. </td>
  149. </tr>
  150. </table>
  151. <?php
  152. }