示例#1
0
 public function show()
 {
     global $USER, $PLANET, $resource, $LNG, $reslist, $CONF;
     $this->tplObj->loadscript("jquery.countdown.js");
     $action = HTTP::_GP('action', '');
     $galaxyLeft = HTTP::_GP('galaxyLeft', '');
     $galaxyRight = HTTP::_GP('galaxyRight', '');
     $systemLeft = HTTP::_GP('systemLeft', '');
     $systemRight = HTTP::_GP('systemRight', '');
     $galaxy = min(max(HTTP::_GP('galaxy', (int) $PLANET['galaxy']), 1), Config::get('max_galaxy'));
     $system = min(max(HTTP::_GP('system', (int) $PLANET['system']), 1), Config::get('max_system'));
     $planet = min(max(HTTP::_GP('planet', (int) $PLANET['planet']), 1), Config::get('max_planets'));
     $type = HTTP::_GP('type', 1);
     $current = HTTP::_GP('current', 0);
     if (!empty($galaxyLeft)) {
         $galaxy = max($galaxy - 1, 1);
     } elseif (!empty($galaxyRight)) {
         $galaxy = min($galaxy + 1, Config::get('max_galaxy'));
     }
     if (!empty($systemLeft)) {
         $system = max($system - 1, 1);
     } elseif (!empty($systemRight)) {
         $system = min($system + 1, Config::get('max_system'));
     }
     if ($galaxy != $PLANET['galaxy'] || $system != $PLANET['system']) {
         if ($PLANET['deuterium'] < Config::get('deuterium_cost_galaxy')) {
             $this->printMessage($LNG['gl_no_deuterium_to_view_galaxy'], array("game.php?page=galaxy", 3));
             exit;
         } else {
             $PLANET['deuterium'] -= Config::get('deuterium_cost_galaxy');
         }
     }
     $targetDefensive = $reslist['defense'];
     $targetDefensive[] = 502;
     $MissleSelector[0] = $LNG['gl_all_defenses'];
     foreach ($targetDefensive as $Element) {
         $MissleSelector[$Element] = $LNG['tech'][$Element];
     }
     $galaxyRows = new GalaxyRows();
     $galaxyRows->setGalaxy($galaxy);
     $galaxyRows->setSystem($system);
     $Result = $galaxyRows->getGalaxyData();
     $tut_info = 1;
     $db_link = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 18) {
         $tut_info = 0;
         $db_link = 0;
     }
     $this->tplObj->loadscript('galaxy.js');
     $this->tplObj->assign_vars(array('man_p' => $USER['id_planet'], 'GalaxyRows' => $Result, 'tut_info' => $tut_info, 'db_link' => $db_link, 'planetcount' => $LNG['gl_populed_planets'], 'planetcount1' => count($Result), 'action' => $action, 'galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'type' => $type, 'current' => $current, 'maxfleetcount' => FleetFunctions::GetCurrentFleets($USER['id']), 'fleetmax' => FleetFunctions::GetMaxFleetSlots($USER), 'currentmip' => $PLANET[$resource[503]], 'grecyclers' => $PLANET[$resource[219]], 'recyclers' => $PLANET[$resource[209]], 'spyprobes' => $PLANET[$resource[210]], 'missile_count' => sprintf($LNG['gl_missil_to_launch'], $PLANET[$resource[503]]), 'spyShips' => array(210 => $USER['spio_anz']), 'settings_fleetactions' => $USER['settings_fleetactions'], 'current_galaxy' => $PLANET['galaxy'], 'immunity' => $LNG['gl_short_immunity'], 'current_system' => $PLANET['system'], 'current_planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'max_planets' => Config::get('max_planets'), 'MissleSelector' => $MissleSelector, 'ShortStatus' => array('vacation' => $LNG['gl_short_vacation'], 'banned' => $LNG['gl_short_ban'], 'inactive' => $LNG['gl_short_inactive'], 'longinactive' => $LNG['gl_short_long_inactive'], 'noob' => $LNG['gl_short_newbie'], 'strong' => $LNG['gl_short_strong'], 'enemy' => $LNG['gl_short_enemy'], 'friend' => $LNG['gl_short_friend'], 'member' => $LNG['gl_short_member'])));
     $this->display('page.galaxy2.default.tpl');
 }
示例#2
0
    public function show()
    {
        global $USER, $PLANET, $resource, $LNG, $reslist;
        $config = Config::get();
        $action = HTTP::_GP('action', '');
        $galaxyLeft = HTTP::_GP('galaxyLeft', '');
        $galaxyRight = HTTP::_GP('galaxyRight', '');
        $systemLeft = HTTP::_GP('systemLeft', '');
        $systemRight = HTTP::_GP('systemRight', '');
        $galaxy = min(max(HTTP::_GP('galaxy', (int) $PLANET['galaxy']), 1), $config->max_galaxy);
        $system = min(max(HTTP::_GP('system', (int) $PLANET['system']), 1), $config->max_system);
        $planet = min(max(HTTP::_GP('planet', (int) $PLANET['planet']), 1), $config->max_planets);
        $type = HTTP::_GP('type', 1);
        $current = HTTP::_GP('current', 0);
        if (!empty($galaxyLeft)) {
            $galaxy = max($galaxy - 1, 1);
        } elseif (!empty($galaxyRight)) {
            $galaxy = min($galaxy + 1, $config->max_galaxy);
        }
        if (!empty($systemLeft)) {
            $system = max($system - 1, 1);
        } elseif (!empty($systemRight)) {
            $system = min($system + 1, $config->max_system);
        }
        if ($galaxy != $PLANET['galaxy'] || $system != $PLANET['system']) {
            if ($PLANET['deuterium'] < $config->deuterium_cost_galaxy) {
                $this->printMessage($LNG['gl_no_deuterium_to_view_galaxy'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=galaxy')));
            } else {
                $PLANET['deuterium'] -= $config->deuterium_cost_galaxy;
            }
        }
        $targetDefensive = $reslist['defense'];
        $targetDefensive[] = 502;
        $missileSelector[0] = $LNG['gl_all_defenses'];
        foreach ($targetDefensive as $Element) {
            $missileSelector[$Element] = $LNG['tech'][$Element];
        }
        $sql = 'SELECT total_points
		FROM %%STATPOINTS%%
		WHERE id_owner = :userId AND stat_type = :statType';
        $USER += Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
        $galaxyRows = new GalaxyRows();
        $galaxyRows->setGalaxy($galaxy);
        $galaxyRows->setSystem($system);
        $Result = $galaxyRows->getGalaxyData();
        $this->tplObj->loadscript('galaxy.js');
        $this->assign(array('GalaxyRows' => $Result, 'planetcount' => sprintf($LNG['gl_populed_planets'], count($Result)), 'action' => $action, 'galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'type' => $type, 'current' => $current, 'maxfleetcount' => FleetFunctions::GetCurrentFleets($USER['id']), 'fleetmax' => FleetFunctions::GetMaxFleetSlots($USER), 'currentmip' => $PLANET[$resource[503]], 'grecyclers' => $PLANET[$resource[219]], 'recyclers' => $PLANET[$resource[209]], 'spyprobes' => $PLANET[$resource[210]], 'missile_count' => sprintf($LNG['gl_missil_to_launch'], $PLANET[$resource[503]]), 'spyShips' => array(210 => $USER['spio_anz']), 'settings_fleetactions' => $USER['settings_fleetactions'], 'current_galaxy' => $PLANET['galaxy'], 'current_system' => $PLANET['system'], 'current_planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'max_planets' => $config->max_planets, 'missileSelector' => $missileSelector, 'ShortStatus' => array('vacation' => $LNG['gl_short_vacation'], 'banned' => $LNG['gl_short_ban'], 'inactive' => $LNG['gl_short_inactive'], 'longinactive' => $LNG['gl_short_long_inactive'], 'noob' => $LNG['gl_short_newbie'], 'strong' => $LNG['gl_short_strong'], 'enemy' => $LNG['gl_short_enemy'], 'friend' => $LNG['gl_short_friend'], 'member' => $LNG['gl_short_member'])));
        $this->display('page.galaxy.default.tpl');
    }
示例#3
0
 public static function FleetAjax()
 {
     global $USER, $PLANET, $db, $resource, $LNG;
     $UserSpyProbes = $PLANET[$resource[210]];
     $UserRecycles = $PLANET[$resource[209]];
     $UserGRecycles = $PLANET[$resource[219]];
     $UserDeuterium = $PLANET['deuterium'];
     $UserMissiles = $PLANET['interplanetary_misil'];
     $thisgalaxy = $PLANET['galaxy'];
     $thissystem = $PLANET['system'];
     $thisplanet = $PLANET['planet'];
     $thisplanettype = $PLANET['planet_type'];
     $galaxy = request_var('galaxy', 0);
     $system = request_var('system', 0);
     $planet = request_var('planet', 0);
     $planettype = request_var('planettype', 0);
     $mission = request_var('mission', 0);
     $CurrentFlyingFleets = parent::GetCurrentFleets($USER['id']);
     switch ($mission) {
         case 6:
             $SpyProbes = request_var('ships', 0);
             $SpyProbes = min($SpyProbes, $PLANET[$resource[210]]);
             if (empty($SpyProbes)) {
                 exit($ResultMessage = "611; " . $LNG['fa_no_spios'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
             }
             $FleetArray = array(210 => $SpyProbes);
             break;
         case 8:
             $SRecycles = explode("|", request_var('ships', ''));
             $GRecycles = min($SRecycles[0], $PLANET[$resource[219]]);
             $Recycles = min($SRecycles[1], $PLANET[$resource[209]]);
             if (empty($Recycles) && empty($GRecycles)) {
                 exit($ResultMessage = "611; " . $LNG['fa_no_recyclers'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
             }
             $FleetArray = array(219 => $GRecycles, 209 => $Recycles);
             break;
         default:
             exit("610; " . $LNG['fa_not_enough_probes'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
             break;
     }
     parent::CleanFleetArray($FleetArray);
     if (empty($FleetArray)) {
         exit("610; " . $LNG['fa_not_enough_probes'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
     }
     if (parent::GetMaxFleetSlots($USER) <= $CurrentFlyingFleets) {
         $ResultMessage = "612; " . $LNG['fa_no_more_slots'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
         die($ResultMessage);
     }
     if ($galaxy > MAX_GALAXY_IN_WORLD || $galaxy < 1) {
         $ResultMessage = "602; " . $LNG['fa_galaxy_not_exist'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
         die($ResultMessage);
     }
     if ($system > MAX_SYSTEM_IN_GALAXY || $system < 1) {
         $ResultMessage = "602; " . $LNG['fa_system_not_exist'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
         die($ResultMessage);
     }
     if ($planet > MAX_PLANET_IN_SYSTEM || $planet < 1) {
         $ResultMessage = "602; " . $LNG['fa_planet_not_exist'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
         die($ResultMessage);
     }
     $QrySelectEnemy = "SELECT id_level, id_owner FROM " . PLANETS . " ";
     $QrySelectEnemy .= "WHERE ";
     $QrySelectEnemy .= "`galaxy` = '" . $galaxy . "' AND ";
     $QrySelectEnemy .= "`system` = '" . $system . "' AND ";
     $QrySelectEnemy .= "`planet` = '" . $planet . "' AND ";
     $QrySelectEnemy .= "`planet_type` = '" . $planettype . "';";
     $TargetRow = $db->uniquequery($QrySelectEnemy);
     if ($TargetRow['id_level'] > $USER['authlevel'] && $mission == 6 && $CONF['adm_attack'] == 0) {
         exit("619; " . $LNG['fa_action_not_allowed'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
     }
     $TargetUser = GetUserByID($TargetRow['id_owner'], array('id', 'onlinetime', 'urlaubs_modus'));
     if ($USER['urlaubs_modus'] == 1) {
         $ResultMessage = "620; " . $LNG['fa_vacation_mode_current'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
         die($ResultMessage);
     }
     if ($mission == 6) {
         $TargetVacat = $TargetUser['urlaubs_modus'];
         if ($TargetVacat) {
             $ResultMessage = "605; " . $LNG['fa_vacation_mode'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
             die($ResultMessage);
         }
         $UserPoints = $USER;
         $User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $TargetRow['id_owner'] . "';");
         $IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $TargetUser['onlinetime']);
         if ($IsNoobProtec['NoobPlayer']) {
             exit("603; " . $LNG['fa_week_player'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
         } elseif ($IsNoobProtec['StrongPlayer']) {
             exit("604; " . $LNG['fa_strong_player'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
         }
         if (empty($TargetRow['id_owner'])) {
             $ResultMessage = "601; " . $LNG['fa_planet_not_exist'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
             die($ResultMessage);
         }
         if ($TargetRow["id_owner"] == $PLANET["id_owner"]) {
             $ResultMessage = "618; " . $LNG['fa_not_spy_yourself'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles;
             die($ResultMessage);
         }
     }
     $SpeedFactor = parent::GetGameSpeedFactor();
     $Distance = parent::GetTargetDistance($thisgalaxy, $galaxy, $thissystem, $system, $thisplanet, $planet);
     $SpeedAllMin = parent::GetFleetMaxSpeed($FleetArray, $USER);
     $Duration = parent::GetMissionDuration(10, $SpeedAllMin, $Distance, $SpeedFactor, $USER);
     $consumption = parent::GetFleetConsumption($FleetArray, $Duration, $Distance, $SpeedAllMin, $USER, $SpeedFactor);
     $UserDeuterium -= $consumption;
     if ($UserDeuterium < 0) {
         exit("613; " . $LNG['fa_not_enough_fuel'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
     } elseif ($consumption > parent::GetFleetRoom($FleetArray)) {
         exit("613; " . $LNG['fa_no_fleetroom'] . " |" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserGRecycles . " " . $UserMissiles);
     }
     $fleet['fly_time'] = $Duration;
     $fleet['start_time'] = $Duration + TIMESTAMP;
     $fleet['end_time'] = $Duration * 2 + TIMESTAMP;
     $FleetShipCount = 0;
     $FleetDBArray = "";
     $FleetSubQRY = "";
     foreach ($FleetArray as $Ship => $Count) {
         $FleetShipCount += $Count;
         $FleetDBArray .= $Ship . "," . $Count . ";";
         $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . " , ";
     }
     if (connection_aborted()) {
         exit;
     }
     $QryUpdate = "LOCK TABLE " . FLEETS . " WRITE, " . PLANETS . " WRITE;";
     $QryUpdate .= "INSERT INTO " . FLEETS . " SET ";
     $QryUpdate .= "`fleet_owner` = '" . $USER['id'] . "', ";
     $QryUpdate .= "`fleet_mission` = '" . $mission . "', ";
     $QryUpdate .= "`fleet_amount` = '" . $FleetShipCount . "', ";
     $QryUpdate .= "`fleet_array` = '" . $FleetDBArray . "', ";
     $QryUpdate .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
     $QryUpdate .= "`fleet_start_galaxy` = '" . $thisgalaxy . "', ";
     $QryUpdate .= "`fleet_start_system` = '" . $thissystem . "', ";
     $QryUpdate .= "`fleet_start_planet` = '" . $thisplanet . "', ";
     $QryUpdate .= "`fleet_start_type` = '" . $thisplanettype . "', ";
     $QryUpdate .= "`fleet_end_time` = '" . $fleet['end_time'] . "', ";
     $QryUpdate .= "`fleet_end_galaxy` = '" . $galaxy . "', ";
     $QryUpdate .= "`fleet_end_system` = '" . $system . "', ";
     $QryUpdate .= "`fleet_end_planet` = '" . $planet . "', ";
     $QryUpdate .= "`fleet_end_type` = '" . $planettype . "', ";
     $QryUpdate .= "`fleet_target_owner` = '" . $TargetRow['id_owner'] . "', ";
     $QryUpdate .= "`start_time` = '" . TIMESTAMP . "';";
     $QryUpdate .= "UPDATE " . PLANETS . " SET ";
     $QryUpdate .= $FleetSubQRY;
     $QryUpdate .= "`deuterium` = '" . floattostring($UserDeuterium) . "' ";
     $QryUpdate .= "WHERE ";
     $QryUpdate .= "`id` = '" . $PLANET['id'] . "';";
     $QryUpdate .= "UNLOCK TABLES;";
     $db->multi_query($QryUpdate);
     $CurrentFlyingFleets++;
     $ResultMessage = "600; " . $LNG['fa_sending'] . " " . $FleetShipCount . " " . $LNG['tech'][$Ship] . " a " . $galaxy . ":" . $system . ":" . $planet . "...|";
     $ResultMessage .= $CurrentFlyingFleets . " " . ($UserSpyProbes - $SpyProbes) . " " . ($UserRecycles - $Recycles) . " " . ($UserGRecycles - $GRecycles) . " " . $UserMissiles;
     die($ResultMessage);
 }
    public function show()
    {
        global $USER, $PLANET, $resource, $LNG;
        if (IsVacationMode($USER)) {
            FleetFunctions::GotoFleetPage(0);
        }
        $targetMission = HTTP::_GP('mission', 3);
        $TransportMetal = max(0, round(HTTP::_GP('metal', 0.0)));
        $TransportCrystal = max(0, round(HTTP::_GP('crystal', 0.0)));
        $TransportDeuterium = max(0, round(HTTP::_GP('deuterium', 0.0)));
        $stayTime = HTTP::_GP('staytime', 0);
        $token = HTTP::_GP('token', '');
        $config = Config::get();
        if (!isset($_SESSION['fleet'][$token])) {
            FleetFunctions::GotoFleetPage(1);
        }
        if ($_SESSION['fleet'][$token]['time'] < TIMESTAMP - 600) {
            unset($_SESSION['fleet'][$token]);
            FleetFunctions::GotoFleetPage(0);
        }
        $formData = $_SESSION['fleet'][$token];
        unset($_SESSION['fleet'][$token]);
        $distance = $formData['distance'];
        $targetGalaxy = $formData['targetGalaxy'];
        $targetSystem = $formData['targetSystem'];
        $targetPlanet = $formData['targetPlanet'];
        $targetType = $formData['targetType'];
        $fleetGroup = $formData['fleetGroup'];
        $fleetArray = $formData['fleet'];
        $fleetStorage = $formData['fleetRoom'];
        $fleetSpeed = $formData['fleetSpeed'];
        if ($targetMission != 2) {
            $fleetGroup = 0;
        }
        if ($PLANET['galaxy'] == $targetGalaxy && $PLANET['system'] == $targetSystem && $PLANET['planet'] == $targetPlanet && $PLANET['planet_type'] == $targetType) {
            $this->printMessage($LNG['fl_error_same_planet'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        if ($targetGalaxy < 1 || $targetGalaxy > $config->max_galaxy || $targetSystem < 1 || $targetSystem > $config->max_system || $targetPlanet < 1 || $targetPlanet > $config->max_planets + 1 || $targetType !== 1 && $targetType !== 2 && $targetType !== 3) {
            $this->printMessage($LNG['fl_invalid_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        if ($targetMission == 3 && $TransportMetal + $TransportCrystal + $TransportDeuterium < 1) {
            $this->printMessage($LNG['fl_no_noresource'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet2')));
        }
        $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
        if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
            $this->printMessage($LNG['fl_no_slots'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
        }
        $ACSTime = 0;
        $db = Database::get();
        if (!empty($fleetGroup)) {
            $sql = "SELECT ankunft FROM %%USERS_ACS%% INNER JOIN %%AKS%% ON id = acsID\n\t\t\tWHERE acsID = :acsID AND :maxFleets > (SELECT COUNT(*) FROM %%FLEETS%% WHERE fleet_group = :acsID);";
            $ACSTime = $db->selectSingle($sql, array(':acsID' => $fleetGroup, ':maxFleets' => $config->max_fleets_per_acs), 'ankunft');
            if (empty($ACSTime)) {
                $fleetGroup = 0;
                $targetMission = 1;
            }
        }
        $sql = "SELECT id, id_owner, der_metal, der_crystal, destruyed, ally_deposit FROM %%PLANETS%% WHERE universe = :universe AND galaxy = :targetGalaxy AND system = :targetSystem AND planet = :targetPlanet AND planet_type = :targetType;";
        $targetPlanetData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet, ':targetType' => $targetType == 2 ? 1 : $targetType));
        if ($targetMission == 7) {
            if (!empty($targetPlanetData)) {
                $this->printMessage($LNG['fl_target_exists'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
            if ($targetType != 1) {
                $this->printMessage($LNG['fl_only_planets_colonizable'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
        }
        if ($targetMission == 7 || $targetMission == 15) {
            $targetPlanetData = array('id' => 0, 'id_owner' => 0, 'planettype' => 1);
        } else {
            if ($targetPlanetData["destruyed"] != 0) {
                $this->printMessage($LNG['fl_no_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
            if (empty($targetPlanetData)) {
                $this->printMessage($LNG['fl_no_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
        }
        foreach ($fleetArray as $Ship => $Count) {
            if ($Count > $PLANET[$resource[$Ship]]) {
                $this->printMessage($LNG['fl_not_all_ship_avalible'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        if ($targetMission == 11) {
            $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 11, true);
            $maxExpedition = FleetFunctions::getDMMissionLimit($USER);
            if ($activeExpedition >= $maxExpedition) {
                $this->printMessage($LNG['fl_no_expedition_slot'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        } elseif ($targetMission == 15) {
            $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15, true);
            $maxExpedition = FleetFunctions::getExpeditionLimit($USER);
            if ($activeExpedition >= $maxExpedition) {
                $this->printMessage($LNG['fl_no_expedition_slot'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        $usedPlanet = isset($targetPlanetData['id_owner']);
        $myPlanet = $usedPlanet && $targetPlanetData['id_owner'] == $USER['id'];
        $targetPlayerData = array();
        if ($targetMission == 7 || $targetMission == 15) {
            $targetPlayerData = array('id' => 0, 'onlinetime' => TIMESTAMP, 'ally_id' => 0, 'urlaubs_modus' => 0, 'authattack' => 0, 'total_points' => 0);
        } elseif ($myPlanet) {
            $targetPlayerData = $USER;
        } elseif (!empty($targetPlanetData['id_owner'])) {
            $sql = "SELECT user.id, user.onlinetime, user.ally_id, user.urlaubs_modus, user.banaday, user.authattack,\n                stat.total_points\n                FROM %%USERS%% as user\n                LEFT JOIN %%STATPOINTS%% as stat ON stat.id_owner = user.id AND stat.stat_type = '1'\n                WHERE user.id = :ownerID;";
            $targetPlayerData = $db->selectSingle($sql, array(':ownerID' => $targetPlanetData['id_owner']));
        }
        if (empty($targetPlayerData)) {
            $this->printMessage($LNG['fl_empty_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        $MisInfo = array();
        $MisInfo['galaxy'] = $targetGalaxy;
        $MisInfo['system'] = $targetSystem;
        $MisInfo['planet'] = $targetPlanet;
        $MisInfo['planettype'] = $targetType;
        $MisInfo['IsAKS'] = $fleetGroup;
        $MisInfo['Ship'] = $fleetArray;
        $availableMissions = FleetFunctions::GetFleetMissions($USER, $MisInfo, $targetPlanetData);
        if (!in_array($targetMission, $availableMissions['MissionSelector'])) {
            $this->printMessage($LNG['fl_invalid_mission'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet2')));
        }
        if ($targetMission != 8 && IsVacationMode($targetPlayerData)) {
            $this->printMessage($LNG['fl_target_exists'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        if ($targetMission == 1 || $targetMission == 2 || $targetMission == 9) {
            if (FleetFunctions::CheckBash($targetPlanetData['id'])) {
                $this->printMessage($LNG['fl_bash_protection'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        if ($targetMission == 1 || $targetMission == 2 || $targetMission == 5 || $targetMission == 6 || $targetMission == 9) {
            if (Config::get()->adm_attack == 1 && $targetPlayerData['authattack'] > $USER['authlevel']) {
                $this->printMessage($LNG['fl_admin_attack'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
            $sql = 'SELECT total_points
			FROM %%STATPOINTS%%
			WHERE id_owner = :userId AND stat_type = :statType';
            $USER += Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
            $IsNoobProtec = CheckNoobProtec($USER, $targetPlayerData, $targetPlayerData);
            if ($IsNoobProtec['NoobPlayer']) {
                $this->printMessage($LNG['fl_player_is_noob'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
            if ($IsNoobProtec['StrongPlayer']) {
                $this->printMessage($LNG['fl_player_is_strong'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        if ($targetMission == 5) {
            if ($targetPlayerData['ally_id'] != $USER['ally_id']) {
                $sql = "SELECT COUNT(*) as state FROM %%BUDDY%%\n\t\t\t\tWHERE id NOT IN (SELECT id FROM %%BUDDY_REQUEST%% WHERE %%BUDDY_REQUEST%%.id = %%BUDDY%%.id) AND\n\t\t\t\t(owner = :ownerID AND sender = :userID) OR (owner = :userID AND sender = :ownerID);";
                $buddy = $db->selectSingle($sql, array(':ownerID' => $targetPlayerData['id'], ':userID' => $USER['id']), 'state');
                if ($buddy == 0) {
                    $this->printMessage($LNG['fl_no_same_alliance'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
                }
            }
        }
        $fleetMaxSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
        $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
        $duration = FleetFunctions::GetMissionDuration($fleetSpeed, $fleetMaxSpeed, $distance, $SpeedFactor, $USER);
        $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $USER, $SpeedFactor);
        if ($PLANET[$resource[903]] < $consumption) {
            $this->printMessage($LNG['fl_not_enough_deuterium'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
        }
        $StayDuration = 0;
        if ($targetMission == 5 || $targetMission == 11 || $targetMission == 15) {
            if (!isset($availableMissions['StayBlock'][$stayTime])) {
                $this->printMessage($LNG['fl_hold_time_not_exists'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
            $StayDuration = round($availableMissions['StayBlock'][$stayTime] * 3600, 0);
        }
        $fleetStorage -= $consumption;
        $fleetResource = array(901 => min($TransportMetal, floor($PLANET[$resource[901]])), 902 => min($TransportCrystal, floor($PLANET[$resource[902]])), 903 => min($TransportDeuterium, floor($PLANET[$resource[903]] - $consumption)));
        $StorageNeeded = array_sum($fleetResource);
        if ($StorageNeeded > $fleetStorage) {
            $this->printMessage($LNG['fl_not_enough_space'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
        }
        $PLANET[$resource[901]] -= $fleetResource[901];
        $PLANET[$resource[902]] -= $fleetResource[902];
        $PLANET[$resource[903]] -= $fleetResource[903] + $consumption;
        $fleetStartTime = $duration + TIMESTAMP;
        $timeDifference = round(max(0, $fleetStartTime - $ACSTime));
        if ($fleetGroup != 0) {
            if ($timeDifference != 0) {
                FleetFunctions::setACSTime($timeDifference, $fleetGroup);
            } else {
                $fleetStartTime = $ACSTime;
            }
        }
        $fleetStayTime = $fleetStartTime + $StayDuration;
        $fleetEndTime = $fleetStayTime + $duration;
        FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetPlanetData['id_owner'], $targetPlanetData['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetResource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $fleetGroup);
        foreach ($fleetArray as $Ship => $Count) {
            $fleetList[$LNG['tech'][$Ship]] = $Count;
        }
        $this->tplObj->gotoside('game.php?page=fleetTable');
        $this->assign(array('targetMission' => $targetMission, 'distance' => $distance, 'consumption' => $consumption, 'from' => $PLANET['galaxy'] . ":" . $PLANET['system'] . ":" . $PLANET['planet'], 'destination' => $targetGalaxy . ":" . $targetSystem . ":" . $targetPlanet, 'fleetStartTime' => _date($LNG['php_tdformat'], $fleetStartTime, $USER['timezone']), 'fleetEndTime' => _date($LNG['php_tdformat'], $fleetEndTime, $USER['timezone']), 'MaxFleetSpeed' => $fleetMaxSpeed, 'FleetList' => $fleetArray));
        $this->display('page.fleetStep3.default.tpl');
    }
    public function show()
    {
        global $USER, $PLANET, $resource, $LNG, $pricelist;
        $UserDeuterium = $PLANET['deuterium'];
        $planetID = HTTP::_GP('planetID', 0);
        $targetMission = HTTP::_GP('mission', 0);
        $activeSlots = FleetFunctions::GetCurrentFleets($USER['id']);
        $maxSlots = FleetFunctions::GetMaxFleetSlots($USER);
        $this->returnData['slots'] = $activeSlots;
        if (IsVacationMode($USER)) {
            $this->sendData(620, $LNG['fa_vacation_mode_current']);
        }
        if (empty($planetID)) {
            $this->sendData(601, $LNG['fa_planet_not_exist']);
        }
        if ($maxSlots <= $activeSlots) {
            $this->sendData(612, $LNG['fa_no_more_slots']);
        }
        $fleetArray = array();
        $db = Database::get();
        switch ($targetMission) {
            case 6:
                if (!isModuleAvailable(MODULE_MISSION_SPY)) {
                    $this->sendData(699, $LNG['sys_module_inactive']);
                }
                $ships = min($USER['spio_anz'], $PLANET[$resource[210]]);
                if (empty($ships)) {
                    $this->sendData(611, $LNG['fa_no_spios']);
                }
                $fleetArray = array(210 => $ships);
                $this->returnData['ships'][210] = $PLANET[$resource[210]] - $ships;
                break;
            case 8:
                if (!isModuleAvailable(MODULE_MISSION_RECYCLE)) {
                    $this->sendData(699, $LNG['sys_module_inactive']);
                }
                $sql = "SELECT (der_metal + der_crystal) as sum FROM %%PLANETS%% WHERE id = :planetID;";
                $totalDebris = $db->selectSingle($sql, array(':planetID' => $planetID), 'sum');
                $recElementIDs = array(219, 209);
                $fleetArray = array();
                foreach ($recElementIDs as $elementID) {
                    $shipsNeed = min(ceil($totalDebris / $pricelist[$elementID]['capacity']), $PLANET[$resource[$elementID]]);
                    $totalDebris -= $shipsNeed * $pricelist[$elementID]['capacity'];
                    $fleetArray[$elementID] = $shipsNeed;
                    $this->returnData['ships'][$elementID] = $PLANET[$resource[$elementID]] - $shipsNeed;
                    if ($totalDebris <= 0) {
                        break;
                    }
                }
                if (empty($fleetArray)) {
                    $this->sendData(611, $LNG['fa_no_recyclers']);
                }
                break;
            default:
                $this->sendData(610, $LNG['fa_not_enough_probes']);
                break;
        }
        $fleetArray = array_filter($fleetArray);
        if (empty($fleetArray)) {
            $this->sendData(610, $LNG['fa_not_enough_probes']);
        }
        $sql = "SELECT planet.id_owner as id_owner,\n\t\tplanet.galaxy as galaxy,\n\t\tplanet.system as system,\n\t\tplanet.planet as planet,\n\t\tplanet.planet_type as planet_type,\n\t\ttotal_points, onlinetime, urlaubs_modus, banaday, authattack\n\t\tFROM %%PLANETS%% planet\n\t\tINNER JOIN %%USERS%% user ON planet.id_owner = user.id\n\t\tLEFT JOIN %%STATPOINTS%% as stat ON stat.id_owner = user.id AND stat.stat_type = '1'\n\t\tWHERE planet.id = :planetID;";
        $targetData = $db->selectSingle($sql, array(':planetID' => $planetID));
        if (empty($targetData)) {
            $this->sendData(601, $LNG['fa_planet_not_exist']);
        }
        if ($targetMission == 6) {
            if (Config::get()->adm_attack == 1 && $targetData['authattack'] > $USER['authlevel']) {
                $this->sendData(619, $LNG['fa_action_not_allowed']);
            }
            if (IsVacationMode($targetData)) {
                $this->sendData(605, $LNG['fa_vacation_mode']);
            }
            $sql = 'SELECT total_points
			FROM %%STATPOINTS%%
			WHERE id_owner = :userId AND stat_type = :statType';
            $USER += Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
            $IsNoobProtec = CheckNoobProtec($USER, $targetData, $targetData);
            if ($IsNoobProtec['NoobPlayer']) {
                $this->sendData(603, $LNG['fa_week_player']);
            }
            if ($IsNoobProtec['StrongPlayer']) {
                $this->sendData(604, $LNG['fa_strong_player']);
            }
            if ($USER['id'] == $targetData['id_owner']) {
                $this->sendData(618, $LNG['fa_not_spy_yourself']);
            }
        }
        $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
        $Distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($targetData['galaxy'], $targetData['system'], $targetData['planet']));
        $SpeedAllMin = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
        $Duration = FleetFunctions::GetMissionDuration(10, $SpeedAllMin, $Distance, $SpeedFactor, $USER);
        $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $Duration, $Distance, $USER, $SpeedFactor);
        $UserDeuterium -= $consumption;
        if ($UserDeuterium < 0) {
            $this->sendData(613, $LNG['fa_not_enough_fuel']);
        }
        if ($consumption > FleetFunctions::GetFleetRoom($fleetArray)) {
            $this->sendData(613, $LNG['fa_no_fleetroom']);
        }
        if (connection_aborted()) {
            exit;
        }
        $this->returnData['slots']++;
        $fleetResource = array(901 => 0, 902 => 0, 903 => 0);
        $fleetStartTime = $Duration + TIMESTAMP;
        $fleetStayTime = $fleetStartTime;
        $fleetEndTime = $fleetStayTime + $Duration;
        $shipID = array_keys($fleetArray);
        FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetData['id_owner'], $planetID, $targetData['galaxy'], $targetData['system'], $targetData['planet'], $targetData['planet_type'], $fleetResource, $fleetStartTime, $fleetStayTime, $fleetEndTime);
        $this->sendData(600, $LNG['fa_sending'] . " " . array_sum($fleetArray) . " " . $LNG['tech'][$shipID[0]] . " " . $LNG['gl_to'] . " " . $targetData['galaxy'] . ":" . $targetData['system'] . ":" . $targetData['planet'] . " ...");
    }
示例#6
0
 function isFleetSlotFree()
 {
     global $FLEET;
     if (!isset($this->USER['slots'])) {
         $this->USER['slots'] = FleetFunctions::GetMaxFleetSlots($this->USER) - FleetFunctions::GetCurrentFleets($this->USER['id']);
     }
     return $this->USER['slots'];
 }
 public function show()
 {
     global $USER, $PLANET, $reslist, $resource, $LNG;
     $acsData = array();
     $FleetID = HTTP::_GP('fleetID', 0);
     $GetAction = HTTP::_GP('action', "");
     $db = Database::get();
     $this->tplObj->loadscript('flotten.js');
     if (!empty($FleetID) && !IsVacationMode($USER)) {
         switch ($GetAction) {
             case "sendfleetback":
                 FleetFunctions::SendFleetBack($USER, $FleetID);
                 break;
             case "acs":
                 $acsData = $this->getACSPageData($FleetID);
                 break;
         }
     }
     $techExpedition = $USER[$resource[124]];
     if ($techExpedition >= 1) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15, true);
         $maxExpedition = floor(sqrt($techExpedition));
     } else {
         $activeExpedition = 0;
         $maxExpedition = 0;
     }
     $maxFleetSlots = FleetFunctions::GetMaxFleetSlots($USER);
     $targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
     $targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
     $targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
     $targetType = HTTP::_GP('planettype', (int) $PLANET['planet_type']);
     $targetMission = HTTP::_GP('target_mission', 0);
     $sql = "SELECT * FROM %%FLEETS%% WHERE fleet_owner = :userID AND fleet_mission <> 10 ORDER BY fleet_end_time ASC;";
     $fleetResult = $db->select($sql, array(':userID' => $USER['id']));
     $activeFleetSlots = $db->rowCount();
     $FlyingFleetList = array();
     foreach ($fleetResult as $fleetsRow) {
         $FleetList[$fleetsRow['fleet_id']] = FleetFunctions::unserialize($fleetsRow['fleet_array']);
         if ($fleetsRow['fleet_mission'] == 4 && $fleetsRow['fleet_mess'] == FLEET_OUTWARD) {
             $returnTime = $fleetsRow['fleet_start_time'];
         } else {
             $returnTime = $fleetsRow['fleet_end_time'];
         }
         $FlyingFleetList[] = array('id' => $fleetsRow['fleet_id'], 'mission' => $fleetsRow['fleet_mission'], 'state' => $fleetsRow['fleet_mess'], 'startGalaxy' => $fleetsRow['fleet_start_galaxy'], 'startSystem' => $fleetsRow['fleet_start_system'], 'startPlanet' => $fleetsRow['fleet_start_planet'], 'startTime' => _date($LNG['php_tdformat'], $fleetsRow['fleet_start_time'], $USER['timezone']), 'endGalaxy' => $fleetsRow['fleet_end_galaxy'], 'endSystem' => $fleetsRow['fleet_end_system'], 'endPlanet' => $fleetsRow['fleet_end_planet'], 'endTime' => _date($LNG['php_tdformat'], $fleetsRow['fleet_end_time'], $USER['timezone']), 'amount' => pretty_number($fleetsRow['fleet_amount']), 'returntime' => $returnTime, 'resttime' => $returnTime - TIMESTAMP, 'FleetList' => $FleetList[$fleetsRow['fleet_id']]);
     }
     $FleetsOnPlanet = array();
     foreach ($reslist['fleet'] as $FleetID) {
         if ($PLANET[$resource[$FleetID]] == 0) {
             continue;
         }
         $FleetsOnPlanet[] = array('id' => $FleetID, 'speed' => FleetFunctions::GetFleetMaxSpeed($FleetID, $USER), 'count' => $PLANET[$resource[$FleetID]]);
     }
     $this->assign(array('FleetsOnPlanet' => $FleetsOnPlanet, 'FlyingFleetList' => $FlyingFleetList, 'activeExpedition' => $activeExpedition, 'maxExpedition' => $maxExpedition, 'activeFleetSlots' => $activeFleetSlots, 'maxFleetSlots' => $maxFleetSlots, 'targetGalaxy' => $targetGalaxy, 'targetSystem' => $targetSystem, 'targetPlanet' => $targetPlanet, 'targetType' => $targetType, 'targetMission' => $targetMission, 'acsData' => $acsData, 'isVacation' => IsVacationMode($USER), 'bonusAttack' => $USER[$resource[109]] * 10 + (1 + abs($USER['factor']['Attack'])) * 100, 'bonusDefensive' => $USER[$resource[110]] * 10 + (1 + abs($USER['factor']['Defensive'])) * 100, 'bonusShield' => $USER[$resource[111]] * 10 + (1 + abs($USER['factor']['Shield'])) * 100, 'bonusCombustion' => $USER[$resource[115]] * 10, 'bonusImpulse' => $USER[$resource[117]] * 20, 'bonusHyperspace' => $USER[$resource[118]] * 30));
     $this->display('page.fleetTable.default.tpl');
 }
 public function show()
 {
     global $USER, $PLANET, $resource, $pricelist, $reslist, $CONF, $LNG, $UNI;
     if (IsVacationMode($USER)) {
         FleetFunctions::GotoFleetPage(0);
     }
     $targetMission = HTTP::_GP('mission', 3);
     $TransportMetal = max(0, round(HTTP::_GP('metal', 0.0)));
     $TransportCrystal = max(0, round(HTTP::_GP('crystal', 0.0)));
     $TransportDeuterium = max(0, round(HTTP::_GP('deuterium', 0.0)));
     $TransportElyrium = max(0, round(HTTP::_GP('elyrium', 0.0)));
     $TransportPopulation301 = max(0, round(HTTP::_GP('population301', 0.0)));
     $TransportPopulation302 = max(0, round(HTTP::_GP('population302', 0.0)));
     $TransportPopulation303 = max(0, round(HTTP::_GP('population303', 0.0)));
     $TransportPopulation304 = max(0, round(HTTP::_GP('population304', 0.0)));
     $TransportPopulation305 = max(0, round(HTTP::_GP('population305', 0.0)));
     $TransportPopulation306 = max(0, round(HTTP::_GP('population306', 0.0)));
     $TransportPopulation307 = max(0, round(HTTP::_GP('population307', 0.0)));
     $TransportPopulation309 = max(0, round(HTTP::_GP('population309', 0.0)));
     $stayTime = HTTP::_GP('staytime', 0);
     $speed = HTTP::_GP('speed', 10);
     $token = HTTP::_GP('tokens', '');
     if (!isset($_SESSION['fleet'][$token])) {
         FleetFunctions::GotoFleetPage(1);
     }
     if ($_SESSION['fleet'][$token]['time'] < TIMESTAMP - 600) {
         unset($_SESSION['fleet'][$token]);
         FleetFunctions::GotoFleetPage(0);
     }
     $maxFleetSpeed = $_SESSION['fleet'][$token]['speed'];
     $distance = $_SESSION['fleet'][$token]['distance'];
     $targetGalaxy = $_SESSION['fleet'][$token]['targetGalaxy'];
     $targetSystem = $_SESSION['fleet'][$token]['targetSystem'];
     $targetPlanet = $_SESSION['fleet'][$token]['targetPlanet'];
     $targetType = $_SESSION['fleet'][$token]['targetType'];
     $fleetGroup = $_SESSION['fleet'][$token]['fleetGroup'];
     $fleetArray = $_SESSION['fleet'][$token]['fleet'];
     $fleetStorage = $_SESSION['fleet'][$token]['fleetRoom'];
     $fleetSpeed = $speed;
     unset($_SESSION['fleet'][$token]);
     if ($targetMission != 2) {
         $fleetGroup = 0;
     }
     if ($PLANET['galaxy'] == $targetGalaxy && $PLANET['system'] == $targetSystem && $PLANET['planet'] == $targetPlanet && $PLANET['planet_type'] == $targetType) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_error_same_planet'] . '</span>');
     }
     if ($targetGalaxy < 1 || $targetGalaxy > Config::get('max_galaxy') || $targetSystem < 1 || $targetSystem > Config::get('max_system') || $targetPlanet < 1 || $targetPlanet > Config::get('max_planets') + 1 || $targetType !== 1 && $targetType !== 2 && $targetType !== 3) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_invalid_target'] . '</span>');
     }
     if ($targetMission == 3 && $TransportMetal + $TransportCrystal + $TransportDeuterium + $TransportElyrium < 1) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_no_noresource'] . '</span>');
     }
     $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
     if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_no_slots'] . '</span>');
     }
     $ACSTime = 0;
     if (!empty($fleetGroup)) {
         $ACSTime = $GLOBALS['DATABASE']->getFirstCell("SELECT ankunft\n\t\t\tFROM " . USERS_ACS . " \n\t\t\tINNER JOIN " . AKS . " ON id = acsID\n\t\t\tWHERE acsID = " . $fleetGroup . "\n\t\t\tAND " . Config::get('max_fleets_per_acs') . " > (SELECT COUNT(*) FROM " . FLEETS . " WHERE fleet_group = " . $fleetGroup . ");");
         if (empty($ACSTime)) {
             $fleetGroup = 0;
             $targetMission = 1;
         }
     }
     $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
     $targetPlanetData = $GLOBALS['DATABASE']->getFirstRow("SELECT id, id_owner, der_metal, der_crystal, destruyed, ally_deposit FROM " . PLANETS . " WHERE universe = " . $UNI . " AND galaxy = " . $targetGalaxy . " AND system = " . $targetSystem . " AND planet = " . $targetPlanet . " AND planet_type = '" . ($targetType == 2 ? 1 : $targetType) . "';");
     if ($targetMission == 1 || $targetMission == 6 || $targetMission == 3 || $targetMission == 14) {
         $ipCheck = $GLOBALS['DATABASE']->query("SELECT userID, secondID FROM uni1_ipblock WHERE userID = " . $USER['id'] . " OR secondID = '" . $USER['id'] . "';");
         if ($GLOBALS['DATABASE']->numRows($ipCheck) > 0) {
             while ($xb = $GLOBALS['DATABASE']->fetch_array($ipCheck)) {
                 if ($targetPlanetData['id_owner'] == $xb['userID'] || $targetPlanetData['id_owner'] == $xb['secondID']) {
                     $this->printMessage(sprintf($LNG['fleet_multi_block'], $this->getUsername($targetPlanetData['id_owner'])));
                 }
             }
         }
     }
     if ($targetMission == 7) {
         if (isset($targetPlanetData)) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_target_exists'] . '</span>');
         }
         if ($targetType != 1) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_only_planets_colonizable'] . '</span>');
         }
     }
     if ($targetMission == 7 || $targetMission == 15) {
         $targetPlanetData = array('id' => 0, 'id_owner' => 0, 'planettype' => 1);
     } else {
         if ($targetPlanetData["destruyed"] != 0) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_no_target'] . '</span>');
         }
         if (!isset($targetPlanetData)) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_no_target'] . '</span>');
         }
     }
     foreach ($fleetArray as $Ship => $Count) {
         if ($Count > $PLANET[$resource[$Ship]]) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_not_all_ship_avalible'] . '</span>');
         }
     }
     if ($targetMission == 11) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 11);
         $maxExpedition = FleetFunctions::getDMMissionLimit($USER);
         if ($activeExpedition >= $maxExpedition) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_no_expedition_slot'] . '</span>');
         }
     } elseif ($targetMission == 15) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15);
         $maxExpedition = FleetFunctions::getExpeditionLimit($USER);
         if ($activeExpedition >= $maxExpedition) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_no_expedition_slot'] . '</span>');
         }
     }
     $usedPlanet = isset($targetPlanetData['id_owner']);
     $myPlanet = $usedPlanet && $targetPlanetData['id_owner'] == $USER['id'];
     if ($targetMission == 7 || $targetMission == 15) {
         $targetPlayerData = array('id' => 0, 'onlinetime' => TIMESTAMP, 'ally_id' => 0, 'urlaubs_modus' => 0, 'authattack' => 0, 'total_points' => 0);
     } elseif ($myPlanet) {
         $targetPlayerData = $USER;
     } elseif (!empty($targetPlanetData['id_owner'])) {
         $targetPlayerData = $GLOBALS['DATABASE']->getFirstRow("SELECT \n\t\t\tuser.id, user.onlinetime, user.ally_id, user.urlaubs_modus, user.banaday, user.authattack, \n\t\t\tstat.total_points\n\t\t\tFROM " . USERS . " as user \n\t\t\tLEFT JOIN " . STATPOINTS . " as stat ON stat.id_owner = user.id AND stat.stat_type = '1' \n\t\t\tWHERE user.id = " . $targetPlanetData['id_owner'] . ";");
     } else {
         $this->printMessage('<span class="rouge">' . $LNG['fl_empty_target'] . '</span>');
     }
     $MisInfo = array();
     $MisInfo['galaxy'] = $targetGalaxy;
     $MisInfo['system'] = $targetSystem;
     $MisInfo['planet'] = $targetPlanet;
     $MisInfo['planettype'] = $targetType;
     $MisInfo['IsAKS'] = $fleetGroup;
     $MisInfo['Ship'] = $fleetArray;
     $avalibleMissions = FleetFunctions::GetFleetMissions($USER, $MisInfo, $targetPlanetData);
     if (!in_array($targetMission, $avalibleMissions['MissionSelector'])) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_invalid_mission'] . '</span>');
     }
     if ($targetMission != 8 && IsVacationMode($targetPlayerData)) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_target_exists'] . '</span>');
     }
     if ($targetMission == 1 || $targetMission == 2 || $targetMission == 9) {
         if (FleetFunctions::CheckBash($targetPlanetData['id'])) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_bash_protection'] . '</span>');
         }
     }
     if ($targetMission == 1 || $targetMission == 2 || $targetMission == 5 || $targetMission == 6 || $targetMission == 9) {
         if (Config::get('adm_attack') == 1 && $targetPlayerData['authattack'] > $USER['authlevel']) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_admin_attack'] . '</span>');
         }
         $IsNoobProtec = CheckNoobProtec($USER, $targetPlayerData, $targetPlayerData);
         if ($IsNoobProtec['NoobPlayer']) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_player_is_noob'] . '</span>');
         }
         if ($IsNoobProtec['StrongPlayer']) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_player_is_strong'] . '</span>');
         }
     }
     if ($targetMission == 5) {
         if ($targetPlayerData['ally_id'] != $USER['ally_id']) {
             $buddy = $GLOBALS['DATABASE']->getFirstCell("\n\t\t\t\tSELECT COUNT(*) FROM " . BUDDY . " \n\t\t\t\tWHERE id NOT IN (SELECT id FROM " . BUDDY_REQUEST . " WHERE " . BUDDY_REQUEST . ".id = " . BUDDY . ".id) AND \n\t\t\t\t(owner = " . $targetPlayerData['id'] . " AND sender = " . $USER['id'] . ") OR\n\t\t\t\t(owner = " . $USER['id'] . " AND sender = " . $targetPlayerData['id'] . ");");
             if ($buddy == 0) {
                 $this->printMessage('<span class="rouge">' . $LNG['fl_no_same_alliance'] . '</span>');
             }
         }
     }
     $fleetMaxSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
     $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $duration = FleetFunctions::GetMissionDuration($fleetSpeed, $fleetMaxSpeed, $distance, $SpeedFactor, $USER);
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $fleetMaxSpeed, $USER, $SpeedFactor);
     if ($PLANET[$resource[904]] < $consumption) {
         $this->printMessage('<span class="rouge">Not enough elyrium</span>');
     }
     $StayDuration = 0;
     if ($targetMission == 5 || $targetMission == 11 || $targetMission == 15) {
         if (!isset($avalibleMissions['StayBlock'][$stayTime])) {
             $this->printMessage('<span class="rouge">' . $LNG['fl_hold_time_not_exists'] . '</span>');
         }
         $StayDuration = round($avalibleMissions['StayBlock'][$stayTime] * 3600, 0);
     }
     $fleetStorage -= $consumption;
     $fleetRessource = array(901 => min($TransportMetal, floor($PLANET[$resource[901]])), 902 => min($TransportCrystal, floor($PLANET[$resource[902]])), 903 => min($TransportDeuterium, floor($PLANET[$resource[903]])), 904 => min($TransportElyrium, floor($PLANET[$resource[904]] - $consumption)));
     $Diplo = 0;
     $Soldi = 0;
     if ($targetMission == 12) {
         $Diplo = 5;
         $Soldi = 10;
     }
     $fleetPopulation = array(301 => min($TransportPopulation301, floor($PLANET[$resource[301]])), 302 => min($TransportPopulation302, floor($PLANET[$resource[302]])), 303 => min($TransportPopulation303, floor($PLANET[$resource[303]])), 304 => min($TransportPopulation304, floor($PLANET[$resource[304]])), 305 => min($TransportPopulation305 + $Diplo, floor($PLANET[$resource[305]])), 306 => min($TransportPopulation306 + $Soldi, floor($PLANET[$resource[306]])), 307 => min($TransportPopulation307, floor($PLANET[$resource[307]])), 309 => min($TransportPopulation309, floor($PLANET[$resource[309]])));
     $StorageNeeded = array_sum($fleetRessource);
     if ($StorageNeeded > $fleetStorage) {
         $this->printMessage('<span class="rouge">' . $LNG['fl_not_enough_space'] . '</span>');
     }
     $PLANET[$resource[901]] -= $fleetRessource[901];
     $PLANET[$resource[902]] -= $fleetRessource[902];
     $PLANET[$resource[903]] -= $fleetRessource[903];
     $PLANET[$resource[904]] -= $fleetRessource[904] + $consumption;
     $PLANET[$resource[301]] -= $fleetPopulation[301];
     $PLANET[$resource[302]] -= $fleetPopulation[302];
     $PLANET[$resource[303]] -= $fleetPopulation[303];
     $PLANET[$resource[304]] -= $fleetPopulation[304];
     $PLANET[$resource[305]] -= $fleetPopulation[305];
     $PLANET[$resource[306]] -= $fleetPopulation[306];
     $PLANET[$resource[307]] -= $fleetPopulation[307];
     $PLANET[$resource[309]] -= $fleetPopulation[309];
     if (connection_aborted()) {
         exit;
     }
     $fleetStartTime = $duration + TIMESTAMP;
     $timeDifference = round(max(0, $fleetStartTime - $ACSTime));
     if ($fleetGroup != 0) {
         if ($timeDifference != 0) {
             FleetFunctions::setACSTime($timeDifference, $fleetGroup);
         } else {
             $fleetStartTime = $ACSTime;
         }
     }
     $fleetStayTime = $fleetStartTime + $StayDuration;
     $fleetEndTime = $fleetStayTime + $duration;
     FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetPlanetData['id_owner'], $targetPlanetData['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetRessource, $fleetPopulation, $fleetStartTime, $fleetStayTime, $fleetEndTime, $fleetGroup);
     foreach ($fleetArray as $Ship => $Count) {
         $fleetList[$LNG['tech'][$Ship]] = $Count;
     }
     $this->tplObj->loadscript('flotten.js');
     $this->tplObj->gotoside('game.php?page=fleetTable');
     $this->tplObj->assign_vars(array('targetMission' => $targetMission, 'distance' => $distance, 'consumption' => $consumption, 'from' => $PLANET['galaxy'] . ":" . $PLANET['system'] . ":" . $PLANET['planet'], 'destination' => $targetGalaxy . ":" . $targetSystem . ":" . $targetPlanet, 'fleetStartTime' => _date($LNG['php_tdformat'], $fleetStartTime, $USER['timezone']), 'fleetEndTime' => _date($LNG['php_tdformat'], $fleetEndTime, $USER['timezone']), 'MaxFleetSpeed' => $fleetMaxSpeed, 'FleetList' => $fleetArray, 'arraysum' => array_sum($fleetArray)));
     $this->display('page.fleetStep3.default.tpl');
 }
    function checkTarget()
    {
        global $PLANET, $LNG, $USER, $resource;
        $targetGalaxy = HTTP::_GP('galaxy', 0);
        $targetSystem = HTTP::_GP('system', 0);
        $targetPlanet = HTTP::_GP('planet', 0);
        $targetPlanetType = HTTP::_GP('planet_type', 1);
        if ($targetGalaxy == $PLANET['galaxy'] && $targetSystem == $PLANET['system'] && $targetPlanet == $PLANET['planet'] && $targetPlanetType == $PLANET['planet_type']) {
            $this->sendJSON($LNG['fl_error_same_planet']);
        }
        // If target is expedition
        if ($targetPlanet != Config::get()->max_planets + 1) {
            $db = Database::get();
            $sql = "SELECT u.id, u.urlaubs_modus, u.user_lastip, u.authattack,\n            \tp.destruyed, p.der_metal, p.der_crystal, p.destruyed\n                FROM %%USERS%% as u, %%PLANETS%% as p WHERE\n                p.universe = :universe AND\n                p.galaxy = :targetGalaxy AND\n                p.system = :targetSystem AND\n                p.planet = :targetPlanet  AND\n                p.planet_type = :targetType AND\n                u.id = p.id_owner;";
            $planetData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet, ':targetType' => $targetPlanetType == 2 ? 1 : $targetPlanetType));
            if ($targetPlanetType == 3 && !isset($planetData)) {
                $this->sendJSON($LNG['fl_error_no_moon']);
            }
            if ($targetPlanetType != 2 && $planetData['urlaubs_modus']) {
                $this->sendJSON($LNG['fl_in_vacation_player']);
            }
            if ($planetData['id'] != $USER['id'] && Config::get()->adm_attack == 1 && $planetData['authattack'] > $USER['authlevel']) {
                $this->sendJSON($LNG['fl_admin_attack']);
            }
            if ($planetData['destruyed'] != 0) {
                $this->sendJSON($LNG['fl_error_not_avalible']);
            }
            if ($targetPlanetType == 2 && $planetData['der_metal'] == 0 && $planetData['der_crystal'] == 0) {
                $this->sendJSON($LNG['fl_error_empty_derbis']);
            }
            $sql = 'SELECT (
				(SELECT COUNT(*) FROM %%MULTI%% WHERE userID = :userID) +
				(SELECT COUNT(*) FROM %%MULTI%% WHERE userID = :dataID)
			) as count;';
            $multiCount = $db->selectSingle($sql, array(':userID' => $USER['id'], ':dataID' => $planetData['id']), 'count');
            if (ENABLE_MULTIALERT && $USER['id'] != $planetData['id'] && $USER['authlevel'] != AUTH_ADM && $USER['user_lastip'] == $planetData['user_lastip'] && $multiCount != 2) {
                $this->sendJSON($LNG['fl_multi_alarm']);
            }
        } else {
            if ($USER[$resource[124]] == 0) {
                $this->sendJSON($LNG['fl_target_not_exists']);
            }
            $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15, true);
            if ($activeExpedition >= FleetFunctions::getExpeditionLimit($USER)) {
                $this->sendJSON($LNG['fl_no_expedition_slot']);
            }
        }
        $this->sendJSON('OK');
    }
 function checkTarget()
 {
     global $PLANET, $LNG, $UNI, $CONF, $USER, $resource;
     $TargetGalaxy = HTTP::_GP('galaxy', 0);
     $TargetSystem = HTTP::_GP('system', 0);
     $TargetPlanet = HTTP::_GP('planet', 0);
     $TargetPlanettype = HTTP::_GP('planet_type', 1);
     if ($TargetGalaxy == $PLANET['galaxy'] && $TargetSystem == $PLANET['system'] && $TargetPlanet == $PLANET['planet'] && $TargetPlanettype == $PLANET['planet_type']) {
         $this->sendJSON($LNG['fl_error_same_planet']);
     }
     if ($TargetPlanet != Config::get('max_planets') + 1) {
         $Data = $GLOBALS['DATABASE']->getFirstRow("SELECT u.id, u.urlaubs_modus, u.user_lastip, u.authattack, u.immunity_until, p.destruyed, p.planet_protection, p.der_metal, p.der_crystal, p.destruyed FROM " . USERS . " as u, " . PLANETS . " as p WHERE p.universe = " . $UNI . " AND p.galaxy = " . $TargetGalaxy . " AND p.system = " . $TargetSystem . " AND p.planet = " . $TargetPlanet . "  AND p.planet_type = '" . ($TargetPlanettype == 2 ? 1 : $TargetPlanettype) . "' AND u.id = p.id_owner;");
         if ($TargetPlanettype == 3 && !isset($Data)) {
             $this->sendJSON($LNG['fl_error_no_moon']);
         } elseif ($TargetPlanettype != 2 && $Data['urlaubs_modus']) {
             $this->sendJSON($LNG['fl_in_vacation_player']);
         } elseif ($TargetPlanettype != 2 && $Data['immunity_until'] > TIMESTAMP && $USER['id'] != $Data['id']) {
             $this->sendJSON($LNG['fl_in_immunity_player']);
         } elseif ($Data['id'] != $USER['id'] && Config::get('adm_attack') == 1 && $Data['authattack'] > $USER['authlevel']) {
             $this->sendJSON($LNG['fl_admin_attack']);
         } elseif ($Data['destruyed'] != 0) {
             $this->sendJSON($LNG['fl_error_not_avalible']);
         } elseif ($TargetPlanettype == 2 && $Data['der_metal'] == 0 && $Data['der_crystal'] == 0) {
             $this->sendJSON($LNG['fl_error_empty_derbis']);
         } elseif (ENABLE_MULTIALERT && $USER['id'] != $Data['id'] && $USER['authlevel'] != AUTH_ADM && $USER['user_lastip'] == $Data['user_lastip'] && $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . MULTI . " WHERE userID = " . $USER['id'] . ") + (SELECT COUNT(*) FROM " . MULTI . " WHERE userID = " . $Data['id'] . ")") != 2) {
             $this->sendJSON($LNG['fl_multi_alarm']);
         }
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 20);
         if ($activeExpedition >= FleetFunctions::getFortressLimit($USER)) {
             $this->sendJSON($LNG['fl_no_expedition_slot']);
         }
     } else {
         if ($USER[$resource[124]] == 0) {
             $this->sendJSON($LNG['fl_target_not_exists']);
         }
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15);
         if ($activeExpedition >= FleetFunctions::getExpeditionLimit($USER)) {
             $this->sendJSON($LNG['fl_no_expedition_slot']);
         }
     }
     $this->sendJSON('OK');
 }
 function reduce()
 {
     global $USER, $PLANET, $LNG, $UNI;
     if (!isset($_POST['palanets'])) {
         $this->redirectTo('game.php?page=Reducefleet');
     }
     if (!isset($_POST['palanets'])) {
         $_POST['palanets'] = array();
     }
     foreach ($_POST['palanets'] as $ID => $Value) {
         $sur = $GLOBALS['DATABASE']->uniquequery("SELECT deuterium, small_ship_cargo, lune_noir, big_ship_cargo, light_hunter, heavy_hunter, crusher, battle_ship, recycler, bomber_ship, destructor, battleship, galleon, destroyer, frigate, black_wanderer, id_owner, id, galaxy, system, planet FROM " . PLANETS . " where `id` = '" . $Value . "';");
         $ships1 = $sur['small_ship_cargo'];
         $ships2 = $sur['big_ship_cargo'];
         $ships3 = $sur['light_hunter'];
         $ships4 = $sur['heavy_hunter'];
         $ships5 = $sur['crusher'];
         $ships6 = $sur['battle_ship'];
         $ships7 = $sur['recycler'];
         $ships8 = $sur['bomber_ship'];
         $ships9 = $sur['destructor'];
         $ships10 = $sur['battleship'];
         $ships11 = $sur['galleon'];
         $ships12 = $sur['destroyer'];
         $ships13 = $sur['frigate'];
         $ships14 = $sur['black_wanderer'];
         $ships15 = $sur['lune_noir'];
         $mission = 4;
         $galaxy = $PLANET['galaxy'];
         $system = $PLANET['system'];
         $planet = $PLANET['planet'];
         $planettype = 1;
         $fleet_group = 0;
         $GenFleetSpeed = 10;
         $TransportMetal = 0;
         $TransportCrystal = 0;
         $TransportDeuterium = 0;
         $holdingtime = 0;
         $rawfleetarray = array(202 => $ships1, 203 => $ships2, 204 => $ships3, 205 => $ships4, 206 => $ships5, 207 => $ships6, 209 => $ships7, 211 => $ships8, 213 => $ships9, 215 => $ships10, 225 => $ships11, 226 => $ships12, 227 => $ships13, 228 => $ships14, 216 => $ships15);
         $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
         if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
             return false;
         }
         $FleetArray = $rawfleetarray;
         $GameSpeedFactor = FleetFunctions::GetGameSpeedFactor();
         $MaxFleetSpeed = FleetFunctions::GetFleetMaxSpeed($FleetArray, $USER);
         $distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($sur['galaxy'], $sur['system'], $sur['planet']));
         $duration = FleetFunctions::GetMissionDuration(10, $MaxFleetSpeed, $distance, $GameSpeedFactor, $USER);
         $consumption = FleetFunctions::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $GameSpeedFactor);
         $StayDuration = 0;
         if ($sur['deuterium'] < $consumption) {
             continue;
         }
         $PlanetRess = new ResourceUpdate();
         $PlanetRess->CalcResource();
         $fleetRessource = array(901 => $TransportMetal, 902 => $TransportCrystal, 903 => $TransportDeuterium);
         $GLOBALS['DATABASE']->multi_query("UPDATE " . PLANETS . " SET deuterium = deuterium - " . $consumption . " where `id` = '" . $sur['id'] . "';");
         $fleetStartTime = $duration + TIMESTAMP;
         $timeDifference = round(max(0, $fleetStartTime - 0));
         if ($fleet_group != 0) {
             if ($timeDifference != 0) {
                 FleetFunctions::setACSTime($timeDifference, $fleet_group);
             } else {
                 $fleetStartTime = $ACSTime;
             }
         }
         $fleetStayTime = $fleetStartTime + $StayDuration;
         $fleetEndTime = $fleetStayTime + $duration;
         FleetFunctions::sendFleet($FleetArray, $mission, $sur['id_owner'], $sur['id'], $sur['galaxy'], $sur['system'], $sur['planet'], 1, $PLANET['id_owner'], $PLANET['id'], $galaxy, $system, $planet, $planettype, $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $fleet_group);
     }
     $this->printMessage('Fleets Succesfully Send', true, array('game.php?page=Reducefleet', 4));
 }
 function reduce()
 {
     global $USER, $PLANET, $LNG, $UNI;
     $tickinicial = buscarTick();
     if (!isset($_POST['palanets'])) {
         $this->redirectTo('game.php?page=reduceresources');
     }
     if (!isset($_POST['palanets'])) {
         $_POST['palanets'] = array();
     }
     foreach ($_POST['palanets'] as $ID => $Value) {
         $sur = $GLOBALS['DATABASE']->uniquequery("SELECT metal, crystal, deuterium, ev_transporter, id_owner, id, galaxy, system, planet FROM " . PLANETS . " where `id` = '" . $Value . "';");
         $total_res = $sur['metal'] + $sur['crystal'] + $sur['deuterium'];
         $needed_ships = ($sur['metal'] + $sur['crystal'] + $sur['deuterium']) / 390000000;
         if ($needed_ships < 1) {
             $needed_ships = 1;
         }
         $ships1 = min($needed_ships, $sur['ev_transporter']);
         $shipscapa = $ships1 * 390000000;
         $RecycledGoods = array('metal' => 0, 'crystal' => 0, 'deuterium' => 0);
         if ($total_res <= $shipscapa) {
             $RecycledGoods['metal'] = $sur['metal'];
             $RecycledGoods['crystal'] = $sur['crystal'];
             $RecycledGoods['deuterium'] = $sur['deuterium'];
         } elseif ($sur['metal'] > $shipscapa / 2 && $sur['crystal'] > $shipscapa / 2 && $sur['deuterium'] > $shipscapa / 2) {
             $RecycledGoods['metal'] = $shipscapa / 2;
             $RecycledGoods['crystal'] = $shipscapa / 2;
             $RecycledGoods['deuterium'] = $shipscapa / 2;
         } elseif ($sur['metal'] > $sur['crystal']) {
             $RecycledGoods['crystal'] = $sur['crystal'];
             if ($sur['metal'] > $shipscapa - $RecycledGoods['crystal']) {
                 $RecycledGoods['metal'] = $shipscapa - $RecycledGoods['crystal'];
             } else {
                 $RecycledGoods['metal'] = $sur['metal'];
             }
         } else {
             $RecycledGoods['metal'] = $sur['metal'];
             if ($sur['crystal'] > $shipscapa - $RecycledGoods['metal']) {
                 $RecycledGoods['crystal'] = $shipscapa - $RecycledGoods['metal'];
             } else {
                 $RecycledGoods['crystal'] = $sur['crystal'];
             }
         }
         if ($RecycledGoods['metal'] < 0) {
             $RecycledGoods['metal'] = 0;
         }
         if ($RecycledGoods['crystal'] < 0) {
             $RecycledGoods['crystal'] = 0;
         }
         if ($RecycledGoods['deuterium'] < 0) {
             $RecycledGoods['deuterium'] = 0;
         }
         $mission = 3;
         $galaxy = $PLANET['galaxy'];
         $system = $PLANET['system'];
         $planet = $PLANET['planet'];
         $planettype = 1;
         $fleet_group = 0;
         $GenFleetSpeed = 10;
         $TransportMetal = $RecycledGoods['metal'];
         $TransportCrystal = $RecycledGoods['crystal'];
         $TransportDeuterium = $RecycledGoods['deuterium'];
         $holdingtime = 0;
         $rawfleetarray = array(217 => $ships1);
         $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
         if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
             return false;
         }
         $FleetArray = $rawfleetarray;
         $GameSpeedFactor = FleetFunctions::GetGameSpeedFactor();
         $MaxFleetSpeed = FleetFunctions::GetFleetMaxSpeed($FleetArray, $USER);
         $distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($sur['galaxy'], $sur['system'], $sur['planet']));
         $duration = FleetFunctions::GetMissionDuration(10, $MaxFleetSpeed, $distance, $GameSpeedFactor, $USER);
         $consumption = FleetFunctions::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $GameSpeedFactor);
         $StayDuration = 0;
         if ($sur['deuterium'] < $consumption) {
             continue;
         }
         $PlanetRess = new ResourceUpdate();
         $PlanetRess->CalcResource();
         $fleetRessource = array(901 => $TransportMetal, 902 => $TransportCrystal, 903 => $TransportDeuterium);
         $GLOBALS['DATABASE']->multi_query("UPDATE " . PLANETS . " SET metal = metal - " . $RecycledGoods['metal'] . ", crystal = crystal - " . $RecycledGoods['crystal'] . ", deuterium = deuterium - " . $RecycledGoods['deuterium'] . " where `id` = '" . $sur['id'] . "';");
         $fleetStartTime = $duration + TIMESTAMP;
         $timeDifference = round(max(0, $fleetStartTime - 0));
         if ($fleet_group != 0) {
             if ($timeDifference != 0) {
                 FleetFunctions::setACSTime($timeDifference, $fleet_group);
             } else {
                 $fleetStartTime = $ACSTime;
             }
         }
         $fleetStayTime = $fleetStartTime + $StayDuration;
         $fleetEndTime = $fleetStayTime + $duration;
         if ($sur['system'] == $system) {
             $tickfinal = $tickinicial + 9;
         } else {
             $tickfinal = $tickinicial + 11;
         }
         FleetFunctions::sendFleet($FleetArray, $mission, $sur['id_owner'], $sur['id'], $sur['galaxy'], $sur['system'], $sur['planet'], 1, $PLANET['id_owner'], $PLANET['id'], $galaxy, $system, $planet, $planettype, $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $tickinicial, $tickfinal, $fleet_group);
     }
     $this->printMessage('Fleets Succesfully Send', true, array('game.php?page=reduceresources', 4));
 }
示例#13
0
 public function show()
 {
     global $USER, $PLANET, $reslist, $resource, $LNG;
     $acsData = array();
     $FleetID = HTTP::_GP('fleetID', 0);
     $GetAction = HTTP::_GP('action', "");
     $this->tplObj->loadscript('flotten.js');
     if (!empty($FleetID) && !IsVacationMode($USER)) {
         switch ($GetAction) {
             case "sendfleetback":
                 FleetFunctions::SendFleetBack($USER, $FleetID);
                 break;
             case "acs":
                 $acsData = $this->getACSPageData($FleetID);
                 break;
         }
     }
     $techExpedition = $USER[$resource[124]];
     if ($techExpedition >= 1) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15);
         $maxExpedition = floor(sqrt($techExpedition));
     } else {
         $activeExpedition = 0;
         $maxExpedition = 0;
     }
     $maxFleetSlots = FleetFunctions::GetMaxFleetSlots($USER);
     $targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
     $targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
     $targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
     $targetType = HTTP::_GP('planettype', (int) $PLANET['planet_type']);
     $targetMission = HTTP::_GP('target_mission', 0);
     $fleetResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_owner = " . $USER['id'] . " AND fleet_mission <> 10 ORDER BY fleet_end_time ASC;");
     $activeFleetSlots = $GLOBALS['DATABASE']->numRows($fleetResult);
     $FlyingFleetList = array();
     while ($fleetsRow = $GLOBALS['DATABASE']->fetch_array($fleetResult)) {
         $fleet = explode(";", $fleetsRow['fleet_array']);
         $FleetList = array();
         foreach ($fleet as $shipDetail) {
             if (empty($shipDetail)) {
                 continue;
             }
             $ship = explode(",", $shipDetail);
             $FleetList[$fleetsRow['fleet_id']][$ship[0]] = $ship[1];
         }
         if ($fleetsRow['fleet_mission'] == 4 && $fleetsRow['fleet_mess'] == FLEET_OUTWARD) {
             $returnTime = $fleetsRow['fleet_start_time'];
         } else {
             $returnTime = $fleetsRow['fleet_end_time'];
         }
         $FlyingFleetList[] = array('id' => $fleetsRow['fleet_id'], 'mission' => $fleetsRow['fleet_mission'], 'state' => $fleetsRow['fleet_mess'], 'startGalaxy' => $fleetsRow['fleet_start_galaxy'], 'startSystem' => $fleetsRow['fleet_start_system'], 'startPlanet' => $fleetsRow['fleet_start_planet'], 'startTime' => _date($LNG['php_tdformat'], $fleetsRow['fleet_start_time'], $USER['timezone']), 'endGalaxy' => $fleetsRow['fleet_end_galaxy'], 'endSystem' => $fleetsRow['fleet_end_system'], 'endPlanet' => $fleetsRow['fleet_end_planet'], 'endTime' => _date($LNG['php_tdformat'], $fleetsRow['fleet_end_time'], $USER['timezone']), 'amount' => pretty_number($fleetsRow['fleet_amount']), 'returntime' => $returnTime, 'resttime' => $returnTime - TIMESTAMP, 'FleetList' => $FleetList[$fleetsRow['fleet_id']]);
     }
     $GLOBALS['DATABASE']->free_result($fleetResult);
     $FleetsOnPlanet = array();
     $avaible_fleets = array(202, 203, 209, 223, 219, 210, 224, 204, 205, 206, 207, 211, 214, 215, 216);
     foreach ($avaible_fleets as $FleetID) {
         if ($PLANET[$resource[$FleetID]] == 0) {
             continue;
         }
         $FleetsOnPlanet[] = array('id' => $FleetID, 'speed' => FleetFunctions::GetFleetMaxSpeed($FleetID, $USER), 'count' => $PLANET[$resource[$FleetID]]);
     }
     $this->tplObj->assign_vars(array('FleetsOnPlanet' => $FleetsOnPlanet, 'FlyingFleetList' => $FlyingFleetList, 'activeExpedition' => $activeExpedition, 'maxExpedition' => $maxExpedition, 'activeFleetSlots' => $activeFleetSlots, 'maxFleetSlots' => $maxFleetSlots, 'targetGalaxy' => $targetGalaxy, 'targetSystem' => $targetSystem, 'targetPlanet' => $targetPlanet, 'targetType' => $targetType, 'targetMission' => $targetMission, 'acsData' => $acsData, 'isVacation' => IsVacationMode($USER), 'bonusAttack' => $USER[$resource[109]] * 10 + (1 + abs($USER['factor']['Attack'])) * 100, 'bonusDefensive' => $USER[$resource[110]] * 10 + (1 + abs($USER['factor']['Defensive'])) * 100, 'bonusShield' => $USER[$resource[111]] * 10 + (1 + abs($USER['factor']['Shield'])) * 100, 'bonusCombustion' => $USER[$resource[115]] * 10, 'bonusImpulse' => $USER[$resource[117]] * 20, 'bonusHyperspace' => $USER[$resource[118]] * 30));
     $this->display('page.fleetTable.default.tpl');
 }
示例#14
0
 function checkTarget()
 {
     global $PLANET, $LNG, $UNI, $CONF, $USER, $resource;
     $TargetGalaxy = HTTP::_GP('galaxy', 0);
     $TargetSystem = HTTP::_GP('system', 0);
     $TargetPlanet = HTTP::_GP('planet', 0);
     $TargetPlanettype = HTTP::_GP('planet_type', 1);
     $missions = HTTP::_GP('mission', 1);
     $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
     $ipCheck = $GLOBALS['DATABASE']->query("SELECT userID, secondID FROM uni1_ipblock WHERE userID = " . $USER['id'] . " OR secondID = '" . $USER['id'] . "';");
     if ($TargetGalaxy == $PLANET['galaxy'] && $TargetSystem == $PLANET['system'] && $TargetPlanet == $PLANET['planet'] && $TargetPlanettype == $PLANET['planet_type']) {
         $this->sendJSON('<span class=rouge>' . $LNG['fl_error_same_planet'] . '</span>');
     }
     if ($TargetPlanet != Config::get('max_planets') + 1) {
         $Data = $GLOBALS['DATABASE']->getFirstRow("SELECT u.id, u.urlaubs_modus, u.immunity_until, u.user_lastip, u.authattack, p.id_owner, p.destruyed, p.der_metal, p.der_crystal, p.destruyed FROM " . USERS . " as u, " . PLANETS . " as p WHERE p.universe = " . $UNI . " AND p.galaxy = " . $TargetGalaxy . " AND p.system = " . $TargetSystem . " AND p.planet = " . $TargetPlanet . "  AND p.planet_type = '" . ($TargetPlanettype == 2 ? 1 : $TargetPlanettype) . "' AND u.id = p.id_owner;");
         $BuddyCheck = $GLOBALS['DATABASE']->query("SELECT * FROM uni1_buddy WHERE (sender = '" . $USER['id'] . "' AND owner = '" . $Data['id_owner'] . "' AND state = '1') OR (owner = '" . $USER['id'] . "' AND sender = '" . $Data['id_owner'] . "' AND state = '1');");
         if ($missions == 1 || $missions == 6 || $missions == 3 || $missions == 14) {
             if ($GLOBALS['DATABASE']->numRows($ipCheck) > 0 && isset($Data)) {
                 while ($xb = $GLOBALS['DATABASE']->fetch_array($ipCheck)) {
                     if ($Data['id_owner'] == $xb['userID'] || $Data['id_owner'] == $xb['secondID']) {
                         $this->sendJSON(sprintf($LNG['fleet_multi_block'], $this->getUsername($Data['id_owner'])));
                     }
                 }
             }
             if ($GLOBALS['DATABASE']->numRows($BuddyCheck) >= 1 && isset($Data)) {
                 $this->sendJSON(sprintf($LNG['fleet_pact'], $this->getUsername($Data['id_owner'])));
             }
         }
         if ($missions == 3 || $missions == 14) {
             if ($GLOBALS['DATABASE']->numRows($BuddyCheck) == 0 && isset($Data)) {
                 $this->sendJSON(sprintf($LNG['fleet_no_pact'], $this->getUsername($Data['id_owner'])));
             }
         }
         if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_no_slots'] . '</span>');
         } elseif ($TargetPlanettype == 3 && !isset($Data)) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_error_no_moon'] . '</span>');
         } elseif ($TargetPlanettype != 2 && $Data['urlaubs_modus'] == 1) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_in_vacation_player'] . '</span>');
         } elseif ($Data['id'] != $USER['id'] && Config::get('adm_attack') == 1 && $Data['authattack'] > $USER['authlevel']) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_admin_attack'] . '</span>');
         } elseif ($Data['destruyed'] != 0) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_error_not_avalible'] . '</span>');
         } elseif ($TargetPlanettype == 2 && $Data['der_metal'] == 0 && $Data['der_crystal'] == 0) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_error_empty_derbis'] . '</span>');
         } elseif (ENABLE_MULTIALERT && $USER['id'] != $Data['id'] && $USER['authlevel'] != AUTH_ADM && $USER['user_lastip'] == $Data['user_lastip'] && $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . MULTI . " WHERE userID = " . $USER['id'] . ") + (SELECT COUNT(*) FROM " . MULTI . " WHERE userID = " . $Data['id'] . ")") != 2) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_multi_alarm'] . '</span>');
         }
     } else {
         if ($USER[$resource[124]] == 0) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_target_not_exists'] . '</span>');
         }
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15);
         if ($activeExpedition >= FleetFunctions::getExpeditionLimit($USER)) {
             $this->sendJSON('<span class=rouge>' . $LNG['fl_no_expedition_slot'] . '</span>');
         }
     }
     $this->sendJSON('OK');
 }
 public function show()
 {
     global $USER, $PLANET, $reslist, $resource, $LNG;
     $acsData = array();
     $FleetID = HTTP::_GP('fleetID', 0);
     $GetAction = HTTP::_GP('action', "");
     $this->tplObj->loadscript('flotten.js');
     if (!empty($FleetID) && !IsVacationMode($USER)) {
         switch ($GetAction) {
             case "sendfleetback":
                 FleetFunctions::SendFleetBack($USER, $FleetID);
                 break;
             case "acs":
                 $acsData = $this->getACSPageData($FleetID);
                 break;
         }
     }
     $techExpedition = $USER[$resource[124]];
     if ($techExpedition >= 1) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15);
         $maxExpedition = floor(sqrt($techExpedition));
     } else {
         $activeExpedition = 0;
         $maxExpedition = 0;
     }
     $maxFleetSlots = FleetFunctions::GetMaxFleetSlots($USER);
     $targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
     $targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
     $targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
     $targetType = HTTP::_GP('planettype', (int) $PLANET['planet_type']);
     $targetMission = HTTP::_GP('target_mission', 0);
     $fleetResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . FLEETS . " WHERE fleet_owner = " . $USER['id'] . " AND fleet_mission <> 10 ORDER BY fleet_end_time ASC;");
     $activeFleetSlots = $GLOBALS['DATABASE']->numRows($fleetResult);
     $FlyingFleetList = array();
     while ($fleetsRow = $GLOBALS['DATABASE']->fetch_array($fleetResult)) {
         $fleet = explode(";", $fleetsRow['fleet_array']);
         $FleetList = array();
         foreach ($fleet as $shipDetail) {
             if (empty($shipDetail)) {
                 continue;
             }
             $ship = explode(",", $shipDetail);
             $FleetList[$fleetsRow['fleet_id']][$ship[0]] = $ship[1];
         }
         if ($fleetsRow['fleet_mission'] == 4 && $fleetsRow['fleet_mess'] == FLEET_OUTWARD) {
             $returnTime = $fleetsRow['fleet_start_time'];
         } else {
             $returnTime = $fleetsRow['fleet_end_time'];
         }
         $FlyingFleetList[] = array('id' => $fleetsRow['fleet_id'], 'mission' => $fleetsRow['fleet_mission'], 'state' => $fleetsRow['fleet_mess'], 'startGalaxy' => $fleetsRow['fleet_start_galaxy'], 'startSystem' => $fleetsRow['fleet_start_system'], 'startPlanet' => $fleetsRow['fleet_start_planet'], 'startTime' => _date($LNG['php_tdformat'], $fleetsRow['fleet_start_time'], $USER['timezone']), 'endGalaxy' => $fleetsRow['fleet_end_galaxy'], 'endSystem' => $fleetsRow['fleet_end_system'], 'endPlanet' => $fleetsRow['fleet_end_planet'], 'endTime' => _date($LNG['php_tdformat'], $fleetsRow['fleet_end_time'], $USER['timezone']), 'amount' => pretty_number($fleetsRow['fleet_amount']), 'returntime' => $returnTime, 'resttime' => $returnTime - TIMESTAMP, 'FleetList' => $FleetList[$fleetsRow['fleet_id']]);
     }
     $GLOBALS['DATABASE']->free_result($fleetResult);
     $FleetsOnPlanet = array();
     $FleetsOnPlanetTransport = array();
     $FleetsOnPlanetProccesors = array();
     $FleetsOnPlanetSpecial = array();
     $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);
     $elementPlanet = array(204, 205, 229, 206, 207, 215, 213, 211, 224, 225, 226, 214, 216, 230, 227, 228, 218, 222, 221);
     $elementPlanetTransport = array(202, 203, 217);
     $elementPlanetProccesors = array(209, 219);
     $elementPlanetSpecial = array(208, 210, 220, 223);
     $getch3 = $GLOBALS['DATABASE']->query("SELECT SUM(" . $PLANET[$resource[202]] . " + " . $PLANET[$resource[203]] . " + " . $PLANET[$resource[204]] . " + " . $PLANET[$resource[205]] . " + " . $PLANET[$resource[206]] . " + " . $PLANET[$resource[207]] . " + " . $PLANET[$resource[208]] . " + " . $PLANET[$resource[209]] . " + " . $PLANET[$resource[210]] . " + " . $PLANET[$resource[211]] . " + " . $PLANET[$resource[212]] . " + " . $PLANET[$resource[213]] . " + " . $PLANET[$resource[214]] . " + " . $PLANET[$resource[215]] . " + " . $PLANET[$resource[216]] . " + " . $PLANET[$resource[217]] . " + " . $PLANET[$resource[218]] . " + " . $PLANET[$resource[219]] . " + " . $PLANET[$resource[220]] . " + " . $PLANET[$resource[221]] . " + " . $PLANET[$resource[222]] . " + " . $PLANET[$resource[223]] . " + " . $PLANET[$resource[224]] . " + " . $PLANET[$resource[225]] . " + " . $PLANET[$resource[226]] . " + " . $PLANET[$resource[227]] . " + " . $PLANET[$resource[228]] . ") as fleet3 FROM " . PLANETS . " where `id` = '" . $PLANET['id'] . "'");
     while ($x3 = $GLOBALS['DATABASE']->fetch_array($getch3)) {
         $resp3 = $x3['fleet3'];
     }
     $getch = $GLOBALS['DATABASE']->query("SELECT SUM(" . $PLANET[$resource[202]] . " + " . $PLANET[$resource[203]] . " + " . $PLANET[$resource[217]] . ") as fleet FROM " . PLANETS . " where `id` = '" . $PLANET['id'] . "'");
     while ($x = $GLOBALS['DATABASE']->fetch_array($getch)) {
         $resp = $x['fleet'];
     }
     $getch1 = $GLOBALS['DATABASE']->query("SELECT SUM(" . $PLANET[$resource[209]] . " + " . $PLANET[$resource[219]] . ") as fleet1 FROM " . PLANETS . " where `id` = '" . $PLANET['id'] . "'");
     while ($x1 = $GLOBALS['DATABASE']->fetch_array($getch1)) {
         $resp1 = $x1['fleet1'];
     }
     $getch2 = $GLOBALS['DATABASE']->query("SELECT SUM(" . $PLANET[$resource[208]] . " + " . $PLANET[$resource[210]] . " + " . $PLANET[$resource[220]] . " + " . $PLANET[$resource[223]] . ") as fleet2 FROM " . PLANETS . " where `id` = '" . $PLANET['id'] . "'");
     while ($x2 = $GLOBALS['DATABASE']->fetch_array($getch2)) {
         $resp2 = $x2['fleet2'];
     }
     $xxx = $resp2;
     $ttt = $resp;
     if ($targetMission != 12) {
         foreach ($elementPlanet as $FleetID) {
             if ($PLANET[$resource[$FleetID]] == 0) {
                 continue;
             }
             $FleetsOnPlanet[] = array('id' => $FleetID, 'speed' => FleetFunctions::GetFleetMaxSpeed($FleetID, $USER), 'count' => $PLANET[$resource[$FleetID]]);
         }
         foreach ($elementPlanetTransport as $FleetID) {
             if ($PLANET[$resource[$FleetID]] == 0) {
                 continue;
             }
             $FleetsOnPlanetTransport[] = array('id' => $FleetID, 'speed' => FleetFunctions::GetFleetMaxSpeed($FleetID, $USER), 'count' => $PLANET[$resource[$FleetID]]);
         }
     }
     foreach ($elementPlanetProccesors as $FleetID) {
         if ($PLANET[$resource[$FleetID]] == 0) {
             continue;
         }
         $FleetsOnPlanetProccesors[] = array('id' => $FleetID, 'speed' => FleetFunctions::GetFleetMaxSpeed($FleetID, $USER), 'count' => $PLANET[$resource[$FleetID]]);
     }
     foreach ($elementPlanetSpecial as $FleetID) {
         if ($PLANET[$resource[$FleetID]] == 0) {
             continue;
         }
         $FleetsOnPlanetSpecial[] = array('id' => $FleetID, 'speed' => FleetFunctions::GetFleetMaxSpeed($FleetID, $USER), 'count' => $PLANET[$resource[$FleetID]]);
     }
     $SC = round(($PLANET['metal'] + $PLANET['crystal'] + $PLANET['deuterium']) / 5000);
     $LC = round(($PLANET['metal'] + $PLANET['crystal'] + $PLANET['deuterium']) / 25000);
     $UT = round(($PLANET['metal'] + $PLANET['crystal'] + $PLANET['deuterium']) / 400000000);
     $GR = round(($PLANET['metal'] + $PLANET['crystal'] + $PLANET['deuterium']) / 200000000);
     $REC = round(($PLANET['metal'] + $PLANET['crystal'] + $PLANET['deuterium']) / 20000);
     $this->tplObj->assign_vars(array('FleetsOnPlanet' => $FleetsOnPlanet, 'FleetsOnPlanetTransport' => $FleetsOnPlanetTransport, 'FleetsOnPlanetProccesors' => $FleetsOnPlanetProccesors, 'FleetsOnPlanetSpecial' => $FleetsOnPlanetSpecial, 'FlyingFleetList' => $FlyingFleetList, 'activeExpedition' => $activeExpedition, 'maxExpedition' => $maxExpedition, 'activeFleetSlots' => $activeFleetSlots, 'maxFleetSlots' => $maxFleetSlots, 'targetGalaxy' => $targetGalaxy, 'targetSystem' => $targetSystem, 'targetPlanet' => $targetPlanet, 'targetType' => $targetType, 'targetMission' => $targetMission, 'acsData' => $acsData, 'isVacation' => IsVacationMode($USER), 'bonusAttack' => $USER[$resource[109]] + getbonusOne(1102, $USER['academy_1102']) + getbonusOne(1101, $USER['academy_1101']) + abs($USER['factor']['Attack']) * 100, 'bonusDefensive' => $USER[$resource[110]] + abs($USER['factor']['Defensive']) * 100, 'bonusShield' => $USER[$resource[111]] + abs($USER['factor']['Shield']) * 100, 'bonusCombustion' => $USER[$resource[115]] * 10, 'bonusImpulse' => $USER[$resource[117]] * 20, 'bonusHyperspace' => $USER[$resource[118]] * 30, 'sc' => $SC, 'lc' => $LC, 'ut' => $UT, 'gr' => $GR, 'rec' => $REC, 'resp' => $resp, 'resp1' => $resp1, 'xxx' => $xxx, 'ttt' => $ttt, 'resp3' => $resp3));
     $this->display('page.fleetTable.default.tpl');
 }
示例#16
0
 public function show()
 {
     global $USER, $PLANET, $resource, $LNG, $CONF, $pricelist;
     $UserDeuterium = $PLANET['elyrium'];
     $planetID = HTTP::_GP('planetID', 0);
     $targetMission = HTTP::_GP('mission', 0);
     $select = HTTP::_GP('select', 0);
     $activeSlots = FleetFunctions::GetCurrentFleets($USER['id']);
     $maxSlots = FleetFunctions::GetMaxFleetSlots($USER);
     $this->returnData['slots'] = $activeSlots;
     if (IsVacationMode($USER)) {
         $this->sendData('rouge', $LNG['fa_vacation_mode_current']);
     }
     if (empty($planetID)) {
         $this->sendData('rouge', $LNG['fa_planet_not_exist']);
     }
     if ($maxSlots <= $activeSlots) {
         $this->sendData('rouge', $LNG['fa_no_more_slots']);
     }
     $fleetArray = array();
     switch ($targetMission) {
         case 1:
             if (!isModulAvalible(MODULE_MISSION_ATTACK)) {
                 $this->sendData('rouge', $LNG['sys_module_inactive']);
             }
             $GetuserComp = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_fleets_manage` WHERE userID = " . $USER['id'] . " AND manageID = " . $select . ";");
             $num_rows = $GLOBALS['DATABASE']->numRows($GetuserComp);
             if ($num_rows == 0) {
                 $this->sendData('rouge', 'You need to create a fleet shortcut first');
             } else {
                 while ($xb = $GLOBALS['DATABASE']->fetch_array($GetuserComp)) {
                     $ship202 = min($xb['ship202'], $PLANET[$resource[202]]);
                     $ship203 = min($xb['ship203'], $PLANET[$resource[203]]);
                     $ship204 = min($xb['ship204'], $PLANET[$resource[204]]);
                     $ship205 = min($xb['ship205'], $PLANET[$resource[205]]);
                     $ship206 = min($xb['ship206'], $PLANET[$resource[206]]);
                     $ship207 = min($xb['ship207'], $PLANET[$resource[207]]);
                     $ship211 = min($xb['ship211'], $PLANET[$resource[211]]);
                     $ship214 = min($xb['ship214'], $PLANET[$resource[214]]);
                     $ship215 = min($xb['ship215'], $PLANET[$resource[215]]);
                     $ship216 = min($xb['ship216'], $PLANET[$resource[216]]);
                     if (empty($ship202) && $xb['ship202'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship203) && $xb['ship203'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship204) && $xb['ship204'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship205) && $xb['ship205'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship206) && $xb['ship206'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship207) && $xb['ship207'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship211) && $xb['ship211'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship214) && $xb['ship214'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship215) && $xb['ship215'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     } elseif (empty($ship216) && $xb['ship216'] > 0) {
                         $this->sendData(611, sprintf($LNG['fleet_ajax_15'], $LNG['tech'][202]));
                     }
                     $fleetArray = array(202 => $ship202, 203 => $ship203, 204 => $ship204, 205 => $ship205, 206 => $ship206, 207 => $ship207, 211 => $ship211, 214 => $ship214, 215 => $ship215, 216 => $ship216);
                     $this->returnData['ships'][202] = $PLANET[$resource[202]] - $ship202;
                     $this->returnData['ships'][203] = $PLANET[$resource[203]] - $ship203;
                     $this->returnData['ships'][204] = $PLANET[$resource[204]] - $ship204;
                     $this->returnData['ships'][205] = $PLANET[$resource[205]] - $ship205;
                     $this->returnData['ships'][206] = $PLANET[$resource[206]] - $ship206;
                     $this->returnData['ships'][207] = $PLANET[$resource[207]] - $ship207;
                     $this->returnData['ships'][211] = $PLANET[$resource[211]] - $ship211;
                     $this->returnData['ships'][214] = $PLANET[$resource[214]] - $ship214;
                     $this->returnData['ships'][215] = $PLANET[$resource[215]] - $ship215;
                     $this->returnData['ships'][216] = $PLANET[$resource[216]] - $ship216;
                 }
             }
             break;
         case 6:
             if (!isModulAvalible(MODULE_MISSION_SPY)) {
                 $this->sendData('rouge', $LNG['sys_module_inactive']);
             }
             $ships = min($USER['spio_anz'], $PLANET[$resource[224]]);
             if (empty($ships)) {
                 $this->sendData('rouge', $LNG['fleet_ajax_2']);
             }
             $fleetArray = array(224 => $ships);
             $this->returnData['ships'][224] = $PLANET[$resource[224]] - $ships;
             break;
         case 8:
             if (!isModulAvalible(MODULE_MISSION_RECYCLE)) {
                 $this->sendData('rouge', $LNG['sys_module_inactive']);
             }
             $totalDebris = $GLOBALS['DATABASE']->getFirstCell("SELECT der_metal + der_crystal + der_deuterium FROM " . PLANETS . " WHERE id = " . $planetID . ";");
             $usedDebris = 0;
             $recElementIDs = array(219, 209, 223);
             $fleetArray = array();
             foreach ($recElementIDs as $elementID) {
                 $shipsNeed = min(ceil($totalDebris / $pricelist[$elementID]['capacity']), $PLANET[$resource[$elementID]]);
                 $totalDebris -= $shipsNeed * $pricelist[$elementID]['capacity'];
                 $fleetArray[$elementID] = $shipsNeed;
                 $this->returnData['ships'][$elementID] = $PLANET[$resource[$elementID]] - $shipsNeed;
                 if ($totalDebris <= 0) {
                     break;
                 }
             }
             if (empty($fleetArray)) {
                 $this->sendData('rouge', $LNG['fleet_ajax_1']);
             }
             if ($PLANET[$resource[219]] == 0 && $PLANET[$resource[209]] == 0 && $PLANET[$resource[223]] == 0) {
                 $this->sendData('rouge', $LNG['fleet_ajax_1']);
             }
             break;
         default:
             $this->sendData('rouge', $LNG['fleet_ajax_2']);
             break;
     }
     $fleetArray = array_filter($fleetArray);
     if (empty($fleetArray)) {
         $this->sendData('rouge', $LNG['fleet_ajax_2']);
     }
     $targetData = $GLOBALS['DATABASE']->getFirstRow("SELECT planet.id_owner as id_owner, \n\t\t\t\t\t\t\t\t\t\tplanet.name as name, \n\t\t\t\t\t\t\t\t\t\tplanet.galaxy as galaxy, \n\t\t\t\t\t\t\t\t\t\tplanet.system as system, \n\t\t\t\t\t\t\t\t\t\tplanet.planet as planet,\n\t\t\t\t\t\t\t\t\t\tplanet.planet_type as planet_type, \n\t\t\t\t\t\t\t\t\t\ttotal_points, onlinetime, urlaubs_modus, banaday, authattack, user_deleted, username\n\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " planet\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS . " user ON planet.id_owner = user.id\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . STATPOINTS . " as stat ON stat.id_owner = user.id AND stat.stat_type = '1' \n\t\t\t\t\t\t\t\t\t\tWHERE planet.id = " . $planetID . ";");
     $BuddyCheck = $GLOBALS['DATABASE']->query("SELECT * FROM uni1_buddy WHERE (sender = '" . $USER['id'] . "' AND owner = '" . $targetData['id_owner'] . "' AND state = '1') OR (owner = '" . $USER['id'] . "' AND sender = '" . $targetData['id_owner'] . "' AND state = '1');");
     if (empty($targetData)) {
         $this->sendData('rouge', $LNG['fa_planet_not_exist']);
     }
     if ($targetMission == 1 || $targetMission == 6 || $targetMission == 3 || $targetMission == 14 || $targetMission == 13) {
         $ipCheck = $GLOBALS['DATABASE']->query("SELECT userID, secondID FROM uni1_ipblock WHERE userID = " . $USER['id'] . " OR secondID = '" . $USER['id'] . "';");
         if ($GLOBALS['DATABASE']->numRows($ipCheck) > 0) {
             while ($xb = $GLOBALS['DATABASE']->fetch_array($ipCheck)) {
                 if ($targetData['id_owner'] == $xb['userID'] || $targetData['id_owner'] == $xb['secondID']) {
                     $this->sendData('rouge', '<span class=rouge>' . sprintf($LNG['fleet_multi_block'], $this->getUsername($targetData['id_owner'])) . '</span>');
                 }
             }
         }
         if ($GLOBALS['DATABASE']->numRows($BuddyCheck) >= 1) {
             $this->sendData('rouge', sprintf($LNG['fleet_pact'], $this->getUsername($targetData['id_owner'])));
         }
     }
     if ($targetMission == 6 || $targetMission == 1) {
         if ($targetMission == 1) {
             if (FleetFunctions::CheckBash($targetData['id_owner'])) {
                 $this->sendData('rouge', $LNG['fl_bash_protection']);
             }
         }
         if ($targetData['user_deleted'] == 1) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_3'], $targetData['username']));
         }
         if ($targetData['banaday'] > TIMESTAMP) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_4'], $targetData['username']));
         }
         if (Config::get('adm_attack') == 1 && $targetData['authattack'] > $USER['authlevel']) {
             $this->sendData('rouge', $LNG['fa_action_not_allowed']);
         }
         if (IsVacationMode($targetData)) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_5'], $targetData['username']));
         }
         $IsNoobProtec = CheckNoobProtec($USER, $targetData, $targetData);
         if ($IsNoobProtec['NoobPlayer']) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_6'], $targetData['username']));
         }
         if ($IsNoobProtec['StrongPlayer']) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_7'], $targetData['username']));
         }
         if ($USER['id'] == $targetData['id_owner']) {
             $this->sendData('rouge', $LNG['fleet_ajax_8']);
         }
     }
     $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $Distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($targetData['galaxy'], $targetData['system'], $targetData['planet']));
     $SpeedAllMin = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
     $Duration = FleetFunctions::GetMissionDuration(10, $SpeedAllMin, $Distance, $SpeedFactor, $USER);
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $Duration, $Distance, $SpeedAllMin, $USER, $SpeedFactor);
     $UserDeuterium -= $consumption;
     if ($UserDeuterium < 0) {
         $this->sendData('rouge', $LNG['fa_not_enough_fuel']);
     }
     if ($consumption > FleetFunctions::GetFleetRoom($fleetArray)) {
         $this->sendData('rouge', $LNG['fa_no_fleetroom']);
     }
     if (connection_aborted()) {
         exit;
     }
     $this->returnData['slots']++;
     $fleetRessource = array(901 => 0, 902 => 0, 903 => 0, 904 => 0);
     $fleetPopulation = array(301 => 0, 302 => 0, 303 => 0, 304 => 0, 305 => 0, 306 => 0, 307 => 0, 309 => 0);
     $fleetStartTime = $Duration + TIMESTAMP;
     $fleetStayTime = $fleetStartTime;
     $fleetEndTime = $fleetStayTime + $Duration;
     $shipID = array_keys($fleetArray);
     FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetData['id_owner'], $planetID, $targetData['galaxy'], $targetData['system'], $targetData['planet'], $targetData['planet_type'], $fleetRessource, $fleetPopulation, $fleetStartTime, $fleetStayTime, $fleetEndTime);
     if ($targetMission == 6) {
         $finalMsg = sprintf($LNG['fleet_ajax_9'], $targetData['name'], $targetData['galaxy'], $targetData['system'], $targetData['planet']);
     } else {
         $finalMsg = sprintf($LNG['fleet_ajax_16'], array_sum($fleetArray), $targetData['name'], $targetData['system'], $targetData['planet'], $LNG['type_missionbis'][$targetMission]);
     }
     $this->sendData('vert', $finalMsg);
 }