Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. <?
  2. header("Content-type: text/plain");
  3. error_reporting(0);
  4. $host = 'localhost'; //put your host here
  5. $user = 'space'; //in general is root
  6. $password = 'space'; //use your password here
  7. $dbname = 'space'; //your database
  8.  
  9. mysql_connect($host, $user, $password) or die("Cant connect into database");
  10. mysql_select_db($dbname)or die("Cant connect into database");
  11.  
  12. if ($_REQUEST["sector"] <> "") {
  13. $selcmd = "SELECT * FROM planets where sector='".$_REQUEST["sector"]."'";
  14. $result = mysql_query($selcmd) or die (mysql_error());
  15.  
  16. while($row = mysql_fetch_array( $result )) {
  17. if ($row['ID'] > 0) {
  18.  
  19. echo "".$row['ID'].",";
  20. echo "".$row['x'].",";
  21. echo "".$row['y'].",";
  22. echo "".$row['z'].",";
  23. if ($row['guid'] > 0) {
  24. $xselcmd = "SELECT Username FROM account where ID='".$row['guid']."'";
  25. $xresult = mysql_query($xselcmd) or die (mysql_error());
  26. while($xrow = mysql_fetch_array( $xresult )) {
  27. echo "".$xrow['Username'].",";
  28. }
  29.  
  30. } else {
  31. echo ",";
  32. }
  33. echo "".$row['sector'].",";
  34. echo "".$row['name'].",";
  35. echo "".$row['type']."\n";
  36. }
  37. }
  38.  
  39. exit;
  40. }
  41.  
  42. if ($_REQUEST["planet"] > 0) {
  43. $selcmd = "SELECT * FROM resourcedata where guid='".$_REQUEST["planet"]."'";
  44. $result = mysql_query($selcmd) or die (mysql_error());
  45.  
  46. while($row = mysql_fetch_array( $result )) {
  47. if ($row['ID'] > 0) {
  48. echo $row['restype'].",";
  49. echo $row['ResourceCount']."\n";
  50. }
  51. }
  52.  
  53. exit;
  54. }
  55.  
  56. if ($_REQUEST["restypes"] <> "") {
  57. $selcmd = "SELECT * FROM restypes";
  58. $result = mysql_query($selcmd) or die (mysql_error());
  59.  
  60. while($row = mysql_fetch_array( $result )) {
  61. if ($row['ID'] > 0) {
  62. echo $row['ID'].",";
  63. echo $row['Type'].",";
  64. echo $row['resType']."\n";
  65. }
  66. }
  67.  
  68. exit;
  69. }
  70.  
  71. // *************************************************** ADDED ON - NOT IN JSON FILE
  72. if ($_REQUEST["buildingtypes"] <> "") {
  73. $selcmd = "SELECT * FROM buildingtypes";
  74. $result = mysql_query($selcmd) or die (mysql_error());
  75.  
  76. while($row = mysql_fetch_array( $result )) {
  77. if ($row['ID'] > 0) {
  78. echo $row['ID'].",";
  79. echo $row['Name'].",";
  80. echo $row['BuildTime'].",";
  81. echo $row['ResourceModifier'].",";
  82. echo $row['Requirement']."\n";
  83. }
  84. }
  85.  
  86. exit;
  87. }
  88.  
  89. if ($_REQUEST["displaycity"] <> "") {
  90. $selcmd = "SELECT * FROM cities WHERE PlanetID='".$_REQUEST["displaycity"]."'";
  91. $result = mysql_query($selcmd) or die (mysql_error());
  92.  
  93. while($row = mysql_fetch_array( $result )) {
  94. if ($row['ID'] > 0) {
  95. if ($row['x'] == '5') {
  96. if ($row['y'] == '10') {
  97. // 5,10 is command center - NEVER spit out another building for that spot
  98. }
  99. } else {
  100. echo $row['ID'].",";
  101. echo $row['UserID'].",";
  102. echo $row['BuildingEntry'].",";
  103. echo $row['x'].",";
  104. echo $row['y']."\n";
  105. }
  106. }
  107. }
  108.  
  109. exit;
  110. }
  111.  
  112. if ($_REQUEST["cityresources"] <> "") {
  113. $selcmd = "SELECT * FROM cityresources WHERE PlanetID='".$_REQUEST["cityresources"]."'";
  114. $result = mysql_query($selcmd) or die (mysql_error());
  115.  
  116. while($row = mysql_fetch_array( $result )) {
  117. //echo $row['ID'].",";
  118. //echo $row['UserID'].",";
  119. //echo $row['BuildingEntry'].",";
  120. echo $row['ResTypeID'].",";
  121. echo $row['ResCount']."\n";
  122. }
  123.  
  124. exit;
  125. }
  126.  
  127.  
  128. // Close mySQL Connection
  129. mysql_close();
  130. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement