PageRenderTime 38ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/viewpos.php

http://pos-tracker-temar.googlecode.com/
PHP | 308 lines | 222 code | 39 blank | 47 comment | 27 complexity | 703ef0576adb5d4982adf394ee8bc9e7 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0
  1. <?php
  2. /*
  3. * Pos-Tracker2
  4. *
  5. * Starbase View 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: viewpos.php 305 2010-01-12 00:27:16Z stephenmg12 $
  29. * @link https://sourceforge.net/projects/pos-tracker2/
  30. * @link http://www.eve-online.com/
  31. */
  32. if(!$index)
  33. die('Hack Attempt...');
  34. EveDBInit();
  35. include_once 'includes/production.php';
  36. $eve->SessionSetVar('userlogged', 1);
  37. $userinfo = $posmgmt->GetUserInfo();
  38. $access = $eve->SessionGetVar('access');
  39. $eveRender->Assign('access', $access);
  40. $eveRender->Assign('config', $config);
  41. //echo '<pre>';print_r($_SESSION); echo '</pre>';exit;
  42. if ($access >= 1)
  43. {
  44. $pos_id = $eve->VarCleanFromInput('i');
  45. if (!empty($pos_id))
  46. {
  47. $tower = $posmgmt->GetTowerInfo($pos_id);
  48. if ($tower)
  49. {
  50. $current_isotope = $tower['isotope'];
  51. $outpost_id = $tower['outpost_id'];
  52. $current_oxygen = $tower['oxygen'];
  53. $current_mechanical_parts= $tower['mechanical_parts'];
  54. $current_coolant = $tower['coolant'];
  55. $current_robotics = $tower['robotics'];
  56. $current_uranium = $tower['uranium'];
  57. $current_ozone = $tower['ozone'];
  58. $current_heavy_water = $tower['heavy_water'];
  59. $current_strontium = $tower['strontium'];
  60. $current_charters = $tower['charters'];
  61. $pos_size = $tower['pos_size'];
  62. $pos_race = $tower['pos_race'];
  63. $towerName = $tower['towerName'];
  64. $systemID = $tower['systemID'];
  65. $location = $tower['moonName'];
  66. $tower_cpu = $tower['cpu'];
  67. $tower_pg = $tower['powergrid'];
  68. $systemName = $posmgmt->getSystemName($systemID); //New Call to Function to get System Name from database
  69. //New Sovereingty Function to retrieve Sovereingty Status
  70. $tower['sovereignty'] = $posmgmt->getSovereignty($systemID);
  71. //$sovereignty = $tower['sovereignty'] = $sov['sovereignty'];
  72. $allianceid = $tower['allianceid'];
  73. $tower['sovfriendly'] = $posmgmt->getSovereigntyStatus($systemID, $allianceid);
  74. //if ($_SESSION['allainceid'] == $sov['allianceID']) {
  75. // $sovfriendly = $tower['sovfriendly'] = true;
  76. $charters_needed = $tower['charters_needed'];
  77. //$system = $row['system'];
  78. $pos_id = $tower['pos_id'];
  79. // grabs the new allianceid off the table
  80. $owner_info=$posmgmt->GetUserInfofromID($tower['owner_id']);
  81. $tower['owner_name']=$owner_info['name'];
  82. $sec_owner_info=$posmgmt->GetUserInfofromID($tower['secondary_owner_id']);
  83. $tower['secondary_owner_name']=$sec_owner_info['name'];
  84. }
  85. $display_hangar = false;
  86. $hangars = $posmgmt->GetPosHangars($pos_id);
  87. $i = 0;
  88. if($hangars) {
  89. foreach ($hangars as $row) { //while ($row = mysql_fetch_assoc($res)) {
  90. $display_hangar = true;
  91. $hangar[$i]['online'] = $row['online'];
  92. $hangar[$i]['isotope'] = $row['isotope'];
  93. $hangar[$i]['oxygen'] = $row['oxygen'];
  94. $hangar[$i]['mechanical_parts'] = $row['mechanical_parts'];
  95. $hangar[$i]['coolant'] = $row['coolant'];
  96. $hangar[$i]['robotics'] = $row['robotics'];
  97. $hangar[$i]['uranium'] = $row['uranium'];
  98. $hangar[$i]['ozone'] = $row['ozone'];
  99. $hangar[$i]['heavy_water'] = $row['heavy_water'];
  100. $hangar[$i]['strontium'] = $row['strontium'];
  101. $hangar[$i]['charters'] = $row['charters'];
  102. $i++;
  103. }
  104. }
  105. //Feul table selection
  106. $db = $posmgmt->selectstaticdb($systemID, $allianceid);
  107. //End Fuel table selection
  108. $row = $posmgmt->GetStaticTowerInfo(array('pos_race' => $pos_race, 'pos_size' => $pos_size, 'db' => $db));
  109. if ($row) {
  110. $tower['required_isotope'] = $row['isotopes'];
  111. $tower['required_oxygen'] = $row['oxygen'];
  112. $tower['required_mechanical_parts'] = $row['mechanical_parts'];
  113. $tower['required_coolant'] = $row['coolant'];
  114. $tower['required_robotics'] = $row['robotics'];
  115. $tower['required_uranium'] = $row['uranium'];
  116. $tower['required_ozone'] = $row['ozone'];
  117. $tower['required_heavy_water'] = $row['heavy_water'];
  118. $tower['required_strontium'] = $row['strontium'];
  119. $tower['required_charters'] = $charters_needed?1:0;
  120. $tower['race_isotope'] = $result['race_isotope'];
  121. $tower['total_pg'] = $row['pg'];
  122. $tower['total_cpu'] = $row['cpu'];
  123. $required_isotope = $row['isotopes'];
  124. $required_oxygen = $row['oxygen'];
  125. $required_mechanical_parts = $row['mechanical_parts'];
  126. $required_coolant = $row['coolant'];
  127. $required_robotics = $row['robotics'];
  128. $required_uranium = $row['uranium'];
  129. $required_ozone = $row['ozone'];
  130. $required_heavy_water = $row['heavy_water'];
  131. $required_strontium = $row['strontium'];
  132. $required_charters = $charters_needed?1:0;
  133. $race_isotope = $result['race_isotope'];
  134. $total_pg = $row['pg'];
  135. $total_cpu = $row['cpu'];
  136. $tower['uptimecalc'] = $posmgmt->uptimecalc($pos_id);
  137. $tower['pos_capacity']=$tower['fuel_hangar']=$row['fuel_hangar'];
  138. $tower['strontium_capacity']=$row['strontium_hangar'];
  139. }
  140. //$mods = $posmgmt->GetPosStructures($pos_id);
  141. $mods = $posmgmt->GetAllPosMods($pos_id);
  142. //echo '<pre>';print_r($tower);echo '</pre>';exit;
  143. if ($mods) { //if (mysql_num_rows($result) != 0) {
  144. $current_pg = 0;
  145. $current_cpu = 0;
  146. foreach($mods as $row) { //while ($row = mysql_fetch_array($result)) {
  147. if ($row['online']) {
  148. $current_pg = $current_pg + $row['pg'];
  149. $current_cpu = $current_cpu + $row['cpu'];
  150. }
  151. }
  152. } else {
  153. $current_pg = 0;
  154. $current_cpu = 0;
  155. }
  156. if($current_cpu<=0 && $tower['cpu']>0) {
  157. $current_cpu=$tower_cpu;
  158. }
  159. if($current_pg<=0 && $tower_pg>0) {
  160. $current_pg=$tower_pg;
  161. }
  162. $tower['current_pg'] = $current_pg;
  163. $tower['current_cpu'] = $current_cpu;
  164. $row2 = $posmgmt->GetLastPosUpdate($pos_id);
  165. $last_update = gmdate("Y-m-d H:i:s", $row2['datetime']);
  166. $hoursago = $posmgmt->hoursago($pos_id, 1);
  167. $optimal=$posmgmt->posoptimaluptime($tower);
  168. $optimalDiff=$posmgmt->getOptimalDifference($optimal, $tower);
  169. // $avail_uranium = ($current_uranium - ($required_uranium * $hoursago)); - Old Version. Now using the API to handle what's in the DB.
  170. $avail_uranium = $current_uranium;
  171. $avail_oxygen = $current_oxygen;
  172. $avail_mechanical_parts = $current_mechanical_parts;
  173. $avail_coolant = $current_coolant;
  174. $avail_robotics = $current_robotics;
  175. $avail_isotope = $current_isotope;
  176. $avail_ozone = $current_ozone;
  177. $required_ozone2 = ceil(($current_pg / $total_pg) * $required_ozone);
  178. $avail_heavy_water = $current_heavy_water;
  179. $required_heavy_water2 = ceil(($current_cpu / $total_cpu) * $required_heavy_water);
  180. $avail_strontium = $current_strontium;
  181. $avail_charters = $current_charters;
  182. if ($avail_uranium <= 0) {
  183. $avail_uranium = ($current_uranium - ($required_uranium * (floor($current_uranium / $required_uranium))));
  184. }
  185. if ($avail_oxygen <= 0) {
  186. $avail_oxygen = ($current_oxygen - ($required_oxygen * (floor($current_oxygen / $required_oxygen))));
  187. }
  188. if ($avail_mechanical_parts <= 0) {
  189. $avail_mechanical_parts = ($current_mechanical_parts - ($required_mechanical_parts * (floor($current_mechanical_parts / $required_mechanical_parts))));
  190. }
  191. if ($avail_coolant <= 0) {
  192. $avail_coolant = ($current_coolant - ($required_coolant * (floor($current_coolant / $required_coolant))));
  193. }
  194. if ($avail_robotics <= 0) {
  195. $avail_robotics = ($current_robotics - ($required_robotics * (floor($current_robotics / $required_robotics))));
  196. }
  197. if ($avail_isotope <= 0) {
  198. $avail_isotope = ($current_isotope - ($required_isotope * (floor($current_isotope / $required_isotope))));
  199. }
  200. if ($avail_ozone <= 0 && $current_pg) {
  201. $avail_ozone = ($current_ozone - ((ceil(($current_pg / $total_pg) * $required_ozone)) * (floor($current_ozone / (ceil(($current_pg / $total_pg) * $required_ozone))))));
  202. }
  203. if ($avail_heavy_water <= 0 && $current_cpu) {
  204. $avail_heavy_water = ($current_heavy_water - ((ceil(($current_cpu / $total_cpu) * $required_heavy_water)) * (floor($current_heavy_water / (ceil(($current_cpu / $total_cpu) * $required_heavy_water))))));
  205. }
  206. if ($avail_charters <= 0 && $required_charters) {
  207. $avail_charters = ($current_charters - ($required_charters * (floor($current_charters / $required_charters))));
  208. }
  209. $tower['avail_uranium'] = $avail_uranium;
  210. $tower['avail_oxygen'] = $avail_oxygen;
  211. $tower['avail_mechanical_parts'] = $avail_mechanical_parts;
  212. $tower['avail_coolant'] = $avail_coolant;
  213. $tower['avail_robotics'] = $avail_robotics;
  214. $tower['avail_isotope'] = $avail_isotope;
  215. $tower['avail_ozone'] = $avail_ozone;
  216. $tower['required_ozone2'] = $required_ozone2;
  217. $tower['avail_heavy_water'] = $avail_heavy_water;
  218. $tower['required_heavy_water2'] = $required_heavy_water2;
  219. $tower['avail_strontium'] = $avail_strontium;
  220. $tower['avail_charters'] = $avail_charters;
  221. //Begin Silo Tracking Code
  222. //$sql0 = "SELECT * FROM ".TBL_PREFIX."silo_info WHERE pos_id=".my_escape($pos_id);
  223. //$res0 = mysql_query($sql0);
  224. silos($pos_id, $tower);
  225. $silo = $allsilos[$pos_id]['silos'];
  226. //End Silo Tracking Code
  227. $tower['silos'] = $silo;
  228. $tower['mods'] = $mods;
  229. $last_update = gmdate("Y-m-d H:i:s", $row2['datetime']);
  230. $eveRender->Assign('tower', $tower);
  231. $eveRender->Assign('last_update', $last_update);
  232. $eveRender->Assign('hoursago', $hoursago);
  233. $arrposize = array(1 => 'Small', 2 => 'Medium', 3 => 'Large');
  234. $arrporace = array(1 => 'Amarr CT',
  235. 2 => 'Caldari CT',
  236. 3 => 'Gallente CT',
  237. 4 => 'Minmatar CT',
  238. 5 => 'Angel CT',
  239. 6 => 'Blood CT',
  240. 7 => 'Dark Blood CT',
  241. 8 => 'Domination CT',
  242. 9 => 'Dread Guristas CT',
  243. 10 => 'Guristas CT',
  244. 11 => 'Sansha CT',
  245. 12 => 'Serpentis CT',
  246. 13 => 'Shadow CT',
  247. 14 => 'True Sansha CT');
  248. $tower['lines'] = $lines;
  249. $tower['linecount'] = $linecount;
  250. $eveRender->Assign('linecount', $linecount);
  251. $eveRender->Assign('lines', $lines);
  252. $eveRender->Assign('arrposize', $arrposize);
  253. $eveRender->Assign('arrporace', $arrporace);
  254. $eveRender->Assign('towerstatus', array(0 => 'Unanchored', 1 => 'Anchored', 2 => 'Onlining', 3 => 'Reinforced', 4 => 'Online'));
  255. $eveRender->Assign('display_hangar', $display_hangar);
  256. $eveRender->Assign('hangars', $hangar);
  257. $eveRender->Assign('optimal', $optimal);
  258. $eveRender->Assign('optimalDiff', $optimalDiff);
  259. $eveRender->Display('viewpos.tpl');
  260. } else {
  261. $eve->SessionSetVar('errormsg', 'You forgot something');
  262. $eve->RedirectUrl('index.php');
  263. }
  264. } else {
  265. $eve->SessionSetVar('errormsg', 'You do not have access, ask your CEO for access.');
  266. $eve->RedirectUrl('index.php');
  267. }
  268. ?>