public function show()
 {
     global $USER, $PLANET, $LNG, $resource, $dpath, $reslist, $requeriments, $CONF;
     $fmenge = isset($_POST['fmenge']) ? $_POST['fmenge'] : array();
     $action = HTTP::_GP('action', '');
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = unserialize($PLANET['b_building_id']);
         foreach ($CurrentQueue as $ElementArray) {
             if ($ElementArray[0] == 21 || $ElementArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     if (empty($ElementQueue)) {
         $Count = 0;
     } else {
         $Count = count($ElementQueue);
     }
     if ($USER['urlaubs_modus'] == 0) {
         if (!empty($fmenge) && $NotBuilding == true) {
             if (Config::get('max_elements_ships') != 0 && $Count >= Config::get('max_elements_ships')) {
                 $this->printMessage(sprintf($LNG['bd_max_builds'], Config::get('max_elements_ships')));
                 exit;
             }
             $this->BuildAuftr($fmenge);
         }
         if ($action == "delete") {
             $this->CancelAuftr();
         }
     }
     $elementInQueue = array();
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     $Buildlist = array();
     if (!empty($ElementQueue)) {
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $Element) {
             if (empty($Element)) {
                 continue;
             }
             $elementInQueue[$Element[0]] = true;
             $ElementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime, $Element[0]);
         }
         $this->tplObj->loadscript('bcmath.js');
         $this->tplObj->execscript('ShipyardInit();');
         $Buildlist = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0)));
     }
     $mode = HTTP::_GP('mode', 'fleet');
     if ($mode != 'defense' && $PLANET['planet_type'] == 4) {
         $this->printMessage("You cant acces this page on a fortress");
     }
     if ($mode == 'defense' && $CONF['fleetconf'] == 1 && $CONF['purchase_bonus_timer'] > TIMESTAMP) {
         $elementALL = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422, 502, 503);
         $elementIDs = array(407, 408, 409, 411, 502, 503);
         $elementIDd = array(401, 402, 403, 420);
         $elementIDa = array(405, 404, 406, 416, 417, 421);
         $elementIDq = array(418, 412, 410, 413, 419, 414, 422, 415);
     } elseif ($mode == 'defense') {
         $elementALL = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422, 502, 503);
         $elementIDs = array(407, 408, 409, 411, 502, 503);
         $elementIDd = array(401, 402, 403);
         $elementIDa = array(405, 404, 406, 416, 417);
         $elementIDq = array(418, 412, 410, 413, 419, 414, 415);
     } elseif ($mode == 'fleet' && $CONF['fleetconf'] == 1 && $CONF['purchase_bonus_timer'] > TIMESTAMP) {
         $elementALL = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230);
         $elementIDs = array(208, 210, 220, 223);
         $elementIDd = array(212, 202, 203, 204, 205, 229);
         $elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219, 224);
         $elementIDq = array(225, 226, 214, 216, 230, 227, 228, 222, 218, 221);
     } elseif ($mode == 'fleet') {
         $elementALL = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230);
         $elementIDs = array(208, 210, 220, 223);
         $elementIDd = array(212, 202, 203, 204, 205);
         $elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219);
         $elementIDq = array(225, 226, 214, 216, 227, 228, 222, 218, 221);
     }
     $Missiles = array();
     $Domes = array();
     $Orbits = array();
     foreach ($reslist['missile'] as $elementID) {
         $Missiles[$elementID] = $PLANET[$resource[$elementID]];
     }
     foreach ($reslist['defense'] as $elementID) {
         $Domes[$elementID] = $PLANET[$resource[$elementID]];
         $Orbits[$elementID] = $PLANET[$resource[$elementID]];
     }
     $MaxMissiles = BuildFunctions::getMaxConstructibleRockets($USER, $PLANET, $Missiles);
     $MaxDomes = BuildFunctions::getMaxConstructibleDomes($USER, $PLANET, $Domes);
     $MaxOrbits = BuildFunctions::getMaxConstructibleOrbits($USER, $PLANET, $Orbits);
     foreach ($elementALL as $Element) {
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementListall[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDs as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDq as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementListq[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDa as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementLista[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDd as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementListd[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $manual_step_9 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 9 && ($PLANET['misil_launcher'] < 25 || $PLANET['small_laser'] < 10)) {
         $manual_step_9 = 0;
     }
     $manual_step_10 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 9 && $PLANET['misil_launcher'] >= 25 && $PLANET['small_laser'] >= 10) {
         $manual_step_10 = 0;
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '11' WHERE `id` = " . $USER['id'] . ";");
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `experience_peace` = `experience_peace` + '650' WHERE `id` = '" . $USER['id'] . "';");
         require_once 'includes/classes/class.FleetFunctions.php';
         $rawfleetarray = array(204 => 8, 205 => 5, 206 => 3);
         $fleetRessource = array(901 => 0, 902 => 0, 903 => 0);
         FleetFunctions::sendFleet($rawfleetarray, '1', 1, 1, 1, 1, 1, 1, $PLANET['id_owner'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $fleetRessource, TIMESTAMP + 58, TIMESTAMP + 58, TIMESTAMP + 116, 0);
     }
     $manual_step_16 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 16) {
         $manual_step_16 = 0;
     }
     if ($USER['training'] == 0 && $USER['training_step'] == 16 && $PLANET['recycler'] >= 5) {
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '17' WHERE `id` = " . $USER['id'] . ";");
     }
     $this->tplObj->loadscript('shipyard.js');
     $this->tplObj->assign_vars(array('manual_step_16' => $manual_step_16, 'manual_step_10' => $manual_step_10, 'manual_step_9' => $manual_step_9, 'elementListall' => $elementListall, 'elementList' => $elementList, 'elementListd' => $elementListd, 'elementLista' => $elementLista, 'elementListq' => $elementListq, 'NotBuilding' => $NotBuilding, 'BuildList' => $Buildlist, 'maxlength' => strlen(Config::get('max_fleet_per_build')), 'mode' => $mode));
     $this->display('page.shipyard.default.tpl');
 }