PageRenderTime 24ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/outpost_fill.php

http://pos-tracker-temar.googlecode.com/
PHP | 273 lines | 198 code | 33 blank | 42 comment | 22 complexity | 912a517acf06efb6ff8d17aa5c83d608 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0
  1. <?php
  2. /*
  3. * Pos-Tracker2
  4. *
  5. * Outpost fill page
  6. *
  7. * PHP version 5
  8. *
  9. * LICENSE: This file is part of POS-Tracker2.
  10. * POS-Tracker2 is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, version 3 of the License.
  13. *
  14. * POS-Tracker2 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 POS-Tracker2. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @author Stephen Gulickk <stephenmg12@gmail.com>
  23. * @author DeTox MinRohim <eve@onewayweb.com>
  24. * @author Andy Snowden <forumadmin@eve-razor.com>
  25. * @copyright 2007-2009 (C) Stephen Gulick, DeTox MinRohim, and Andy Snowden
  26. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
  27. * @package POS-Tracker2
  28. * @version SVN: $Id$
  29. * @link https://sourceforge.net/projects/pos-tracker2/
  30. * @link http://www.eve-online.com/
  31. */
  32. if(!$index)
  33. die('Hack Attempt...');
  34. require_once 'config.php'; // doesnt exists.. old file??
  35. require_once 'functions.php';
  36. require_once 'header.php';
  37. include_once 'includes/pos_val.php';
  38. /* --- By default the form is displayed --- */
  39. if ($_SESSION['access'] >= "2") {
  40. /* -- Data settings and controls -- */
  41. $outpost_to_refuel = (integer) $_POST['outpost_to_refuel'] ;
  42. $days_to_refuel = (integer) $_POST['days'] ;
  43. $hours_to_refuel = (integer) $_POST['hours'] ;
  44. $use_current_levels = (boolean) $_POST['use_current_levels'] ;
  45. $size_of_hauler = (integer) $_POST['size'] ;
  46. /* -- check for varible entry -- */
  47. if ($outpost_to_refuel > 0) {
  48. /* -- Fuel calculation -- */
  49. $current_isotope = $current_oxygen = $current_mechanical_parts = $current_coolant = $current_robotics = $current_uranium = $current_ozone = $current_heavy_water = $current_strontium = $current_charters = 0;
  50. $sql = "SELECT * FROM ".TBL_PREFIX."outpost_info WHERE outpost_id = '" . my_escape($outpost_to_refuel) . "'";
  51. $result = mysql_query($sql)
  52. or die('Error retrieving from pos_info in function uptimecal1;' . mysql_error()) ;
  53. $uptimecalc=outpost($outpost_to_refuel);
  54. // new code to support difference raical full
  55. $required_heisotope = $uptimecalc["required_heisotope"];
  56. $required_hyisotope = $uptimecalc["required_hyisotope"];
  57. $required_oxisotope = $uptimecalc["required_oxisotope"];
  58. $required_niisotope = $uptimecalc["required_niisotope"];
  59. // end new code
  60. $required_oxygen = $uptimecalc["required_oxy"];
  61. $required_mechanical_parts = $uptimecalc["required_mech"];
  62. $required_coolant = $uptimecalc["required_cool"];
  63. $required_robotics = $uptimecalc["required_robo"];
  64. $required_uranium = $uptimecalc["required_ura"];
  65. $required_ozone2 = $uptimecalc["required_ozo"];
  66. $required_heavy_water2 = $uptimecalc["required_hea"];
  67. $required_strontium = $uptimecalc["required_stront"];
  68. $required_charters = $uptimecalc["required_chart"];
  69. $outpost_heisotope = $uptimecalc["overall_heisotope"];
  70. $outpost_hyisotope = $uptimecalc["overall_hyisotope"];
  71. $outpost_oxisotope = $uptimecalc["overall_oxisotope"];
  72. $outpost_niisotope = $uptimecalc["overall_niisotope"];
  73. $outpost_oxygen = $uptimecalc["overall_oxy"];
  74. $outpost_mechanical_parts = $uptimecalc["overall_mech"];
  75. $outpost_coolant = $uptimecalc["overall_cool"];
  76. $outpost_robotics = $uptimecalc["overall_robo"];
  77. $outpost_uranium = $uptimecalc["overall_uran"];
  78. $outpost_ozone = $uptimecalc["overall_ozo"];
  79. $outpost_heavy_water = $uptimecalc["overall_heavy"];
  80. $outpost_strontium = $uptimecalc["overall_stron"];
  81. $overall_total_strontium_hanger = $uptimecalc["overall_stron_hanger"];
  82. $outpost_charters = $uptimecalc["overall_chart"];
  83. $current_pg = $uptimecalc["current_pg"];
  84. $current_cpu = $uptimecalc["current_cpu"];
  85. $total_pg = $uptimecalc["total_pg"];
  86. $total_cpu = $uptimecalc["total_cpu"];
  87. #added to allow for info on the refill page
  88. $sql = "SELECT * FROM ".TBL_PREFIX."outpost_info WHERE outpost_id = '" . my_escape($outpost_to_refuel) . "'";
  89. $result = mysql_query($sql)
  90. or die('Error retrieving from outpost_info in function uptimecalc;' . mysql_error());
  91. if ($row = mysql_fetch_array($result)) {
  92. $outpost_name = $row['outpost_name'];
  93. $systemID=$row['systemID'];
  94. $hoursago = outposthoursago($outpost_to_refuel, 1);
  95. }
  96. /* --- Needed fuel calculation --- */
  97. $needed_hours = (integer) (abs($days_to_refuel*24) + abs($hours_to_refuel)) ;
  98. $real_required_ozone = ceil(($current_pg / $total_pg) * $required_ozone2) ;
  99. $real_required_heavy_water = ceil(($current_cpu / $total_cpu) * $required_heavy_water2) ;
  100. $total_uranium = $required_uranium * $needed_hours ;
  101. $total_oxygen = $required_oxygen * $needed_hours ;
  102. $total_mechanical_parts = $required_mechanical_parts * $needed_hours ;
  103. $total_coolant = $required_coolant * $needed_hours ;
  104. $total_robotics = $required_robotics * $needed_hours ;
  105. $total_heisotopes = $required_heisotope * $needed_hours ;
  106. $total_hyisotopes = $required_hyisotope * $needed_hours ;
  107. $total_oxisotopes = $required_oxisotope * $needed_hours ;
  108. $total_niisotopes = $required_niisotope * $needed_hours ;
  109. $total_ozone = $real_required_ozone * $needed_hours ;
  110. $total_heavy_water = $real_required_heavy_water * $needed_hours ;
  111. $total_charters = $required_charters * $needed_hours;
  112. $total_stront = $required_strontium * $needed_hours;
  113. $needed_uranium = $required_uranium * $needed_hours ;
  114. $needed_oxygen = $required_oxygen * $needed_hours ;
  115. $needed_mechanical_parts = $required_mechanical_parts * $needed_hours ;
  116. $needed_coolant = $required_coolant * $needed_hours ;
  117. $needed_robotics = $required_robotics * $needed_hours ;
  118. $needed_heisotopes = $required_heisotope * $needed_hours ;
  119. $needed_hyisotopes = $required_hyisotope * $needed_hours ;
  120. $needed_oxisotopes = $required_oxisotope * $needed_hours ;
  121. $needed_niisotopes = $required_niisotope * $needed_hours ;
  122. $needed_ozone = $real_required_ozone * $needed_hours ;
  123. $needed_heavy_water = $real_required_heavy_water * $needed_hours ;
  124. $needed_charters = $required_charters * $needed_hours;
  125. $needed_stront = $required_strontium * $needed_hours;
  126. if ($use_current_levels) {
  127. $needed_uranium = $needed_uranium - $outpost_uranium ;
  128. $needed_oxygen = $needed_oxygen - $outpost_oxygen ;
  129. $needed_mechanical_parts = $needed_mechanical_parts - $outpost_mechanical_parts ;
  130. $needed_coolant = $needed_coolant - $outpost_coolant ;
  131. $needed_robotics = $needed_robotics - $outpost_robotics ;
  132. $needed_heisotope = $needed_heisotopes - $outpost_heisotope ;
  133. $needed_hyisotope = $needed_hyisotopes - $outpost_hyisotope ;
  134. $needed_oxisotope = $needed_oxisotopes - $outpost_oxisotope ;
  135. $needed_niisotope = $needed_niisotopes - $outpost_niisotope ;
  136. $needed_ozone = $needed_ozone - $outpost_ozone ;
  137. $needed_heavy_water = $needed_heavy_water - $outpost_heavy_water ;
  138. $needed_charters = $needed_charters - $outpost_charters;
  139. $needed_stront = $needed_stront - $outpost_strontium;
  140. }
  141. if ($needed_uranium < 0) {
  142. $needed_uranium = 0;
  143. }
  144. if ($needed_oxygen < 0) {
  145. $needed_oxygen = 0;
  146. }
  147. if ($needed_mechanical_parts < 0) {
  148. $needed_mechanical_parts = 0;
  149. }
  150. if ($needed_coolant < 0) {
  151. $needed_coolant = 0;
  152. }
  153. if ($needed_robotics < 0) {
  154. $needed_robotics = 0;
  155. }
  156. if ($needed_heisotopes < 0) {
  157. $needed_heisotopes = 0;
  158. }
  159. if ($needed_hyisotopes < 0) {
  160. $needed_hyisotopes = 0;
  161. }
  162. if ($needed_oxisotopes < 0) {
  163. $needed_oxisotopes = 0;
  164. }
  165. if ($needed_niisotopes < 0) {
  166. $needed_niisotopes = 0;
  167. }
  168. if ($needed_ozone < 0) {
  169. $needed_ozone = 0;
  170. }
  171. if ($needed_heavy_water < 0) {
  172. $needed_heavy_water = 0;
  173. }
  174. if ($needed_charters < 0 ) {
  175. $needed_charters = 0;
  176. }
  177. if ($needed_stront < 0 ) {
  178. $needed_stront = 0;
  179. }
  180. $needed_uranium_size = $needed_uranium * $pos_Ura;
  181. $needed_oxygen_size = $needed_oxygen * $pos_Oxy;
  182. $needed_mechanical_parts_size = $needed_mechanical_parts * $pos_Mec;
  183. $needed_coolant_size = $needed_coolant * $pos_Coo;
  184. $needed_robotics_size = $needed_robotics * $pos_Rob;
  185. $needed_heisotopes_size = $needed_heisotopes * $pos_Iso;
  186. $needed_hyisotopes_size = $needed_hyisotopes * $pos_Iso;
  187. $needed_oxisotopes_size = $needed_oxisotopes * $pos_Iso;
  188. $needed_niisotopes_size = $needed_niisotopes * $pos_Iso;
  189. $needed_ozone_size = $needed_ozone * $pos_Ozo;
  190. $needed_heavy_water_size = $needed_heavy_water * $pos_Hea;
  191. $needed_charter_size = $needed_charters * $pos_Cha;
  192. $needed_stront_size = $needed_stront * $pos_Str;
  193. $total_volume = 0 ;
  194. $total_volume = $needed_uranium_size + $needed_oxygen_size + $needed_mechanical_parts_size + $needed_coolant_size + $needed_robotics_size + $needed_heisotopes_size + $needed_hyisotopes_size + $needed_oxisotopes_size + $needed_biisotopes_size + $needed_ozone_size + $needed_heavy_water_size + $needed_charter_size + $needed_stront_size ;
  195. // pulls the date of last update for display purposes
  196. $sql = "SELECT * FROM ".TBL_PREFIX."outpost_update_log WHERE outpost_id = '" . my_escape($outpost_to_refuel) . "' ORDER BY id DESC";
  197. $result2 = mysql_query($sql)
  198. or die('Could not select from outpost_update_log; ' . mysql_error());
  199. $row2 = mysql_fetch_array($result2);
  200. // added more details to be displayed sence there will be more than 1 outpost being shown
  201. $last_update = gmdate("Y-m-d H:i:s", $row2['datetime']);
  202. echo "<table width='893' border='0'><tr><td width='120' height='15'><div align='left'>Last Updated: </div></td><td width='210'><div align='left'>" . $last_update . "</div></td><td width='509'><div align='left'></div></td></tr>";
  203. echo "<tr><td><div align='left'>Was updated: </div></td><td><div align='left'>" . $hoursago . " Hours Ago</div></td><td><div align='left'></div></td></tr>";
  204. echo "<tr><td><div align='left'>Outpost Name: </div></td><td><div align='left'>" .$outpost_name . "</div></td><td><div align='left'></div></td></tr>";
  205. //Print System name and outpost Name
  206. echo "<tr><td><div align='left'>System Name: </div></td><td><div align='left'>" . $systemID . "</div></td><td><div align='left'></div></td></tr></table><br>";
  207. echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"310\">";
  208. echo "<tr><td>Fuel</td><td>Total Required</td><td>You need</td><td><div style=\"text-align: center; float; center\">Volume</div></td></tr>";
  209. echo "<tr><td>Enriched Uranium</td><td>" . $total_uranium . "</td><td>" . $needed_uranium . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_uranium_size)*1),2)." m3)</div></td></tr>";
  210. echo "<tr><td>Oxygen</td><td>" . $total_oxygen . "</td><td>" . $needed_oxygen . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_oxygen_size)*1),2)." m3)</div></td></tr>";
  211. echo "<tr><td>Mechanical Parts</td><td>" . $total_mechanical_parts . "</td><td>" . $needed_mechanical_parts . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_mechanical_parts_size)*1),2)." m3)</div></td></tr>";
  212. echo "<tr><td>Coolant</td><td>" . $total_coolant . "</td><td>" . $needed_coolant . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_coolant_size)*1),2)." m3)</div></td></tr>";
  213. echo "<tr><td>Robotics</td><td>" . $total_robotics . "</td><td>" . $needed_robotics . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_robotics_size)*1),2)." m3)</div></td></tr>";
  214. echo "<tr><td>" . $race_isotope . "Helium Isotopes</td><td>" . $total_heisotopes . "</td><td>" . $needed_heisotopes . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_heisotopes_size)*1),2)." m3)</div></td></tr>";
  215. echo "<tr><td>" . $race_isotope . "Hydrogen Isotopes</td><td>" . $total_hyisotopes . "</td><td>" . $needed_hyisotopes . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_hyisotopes_size)*1),2)." m3)</div></td></tr>";
  216. echo "<tr><td>" . $race_isotope . "Oxygen Isotopes</td><td>" . $total_oxisotopes . "</td><td>" . $needed_oxisotopes . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_oxisotopes_size)*1),2)." m3)</div></td></tr>";
  217. echo "<tr><td>" . $race_isotope . "Nitrogen Isotopes</td><td>" . $total_niisotopes . "</td><td>" . $needed_niisotopes . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_niisotopes_size)*1),2)." m3)</div></td></tr>";
  218. echo "<tr><td>Liquid Ozone</td><td>" . $total_ozone . "</td><td>" . $needed_ozone . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_ozone_size)*1),2)." m3)</div></td></tr>";
  219. echo "<tr><td>Heavy Water</td><td>" . $total_heavy_water . "</td><td>" . $needed_heavy_water . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_heavy_water_size)*1),2)." m3)</div></td></tr>";
  220. if ($charters_needed) {
  221. echo "<tr><td>Charters</td><td>" . $total_charters . "</td><td>" . $needed_charters . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_charters)*0.1),2)." m3)</div></td></tr>";
  222. }
  223. echo "<tr><td>Strontium</td><td>" . $total_stront . "</td><td>" . $needed_stront . "</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($needed_stront_size)*1),2)." m3)</div></td></tr>";
  224. echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>Total</td><td width=\"85\"><div style=\"text-align: right; float: right\">(".number_format((($total_volume)*1),2)." m3)</div></td></tr>";
  225. echo "</table>";
  226. echo "<br>";
  227. $trips = ceil($total_volume / $size_of_hauler);
  228. if ($trips > 1) {
  229. $ending = " trips";
  230. } else {
  231. $ending = " trip";
  232. }
  233. echo "Given a hauler size of " . $size_of_hauler . "m3 you will need to make " . $trips . $ending;
  234. #end part of the check for empty data
  235. } else {
  236. echo "You did not select a Outpost to refill, Please go back and try again.";
  237. }
  238. }
  239. require_once 'footer.php';
  240. ?>