示例#1
0
function IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, $Incremental = true, $ForDestroy = false)
{
    global $pricelist, $resource, $xgp_root, $phpEx;
    include_once $xgp_root . 'includes/functions/IsVacationMode.' . $phpEx;
    if (IsVacationMode($CurrentUser)) {
        return false;
    }
    if ($Incremental) {
        $level = $CurrentPlanet[$resource[$Element]] ? $CurrentPlanet[$resource[$Element]] : $CurrentUser[$resource[$Element]];
    }
    $RetValue = true;
    $array = array('metal', 'crystal', 'deuterium', 'energy_max');
    foreach ($array as $ResType) {
        if ($pricelist[$Element][$ResType] != 0) {
            if ($Incremental) {
                $cost[$ResType] = floor($pricelist[$Element][$ResType] * pow($pricelist[$Element]['factor'], $level));
            } else {
                $cost[$ResType] = floor($pricelist[$Element][$ResType]);
            }
            if ($ForDestroy) {
                $cost[$ResType] = floor($cost[$ResType] / 2);
            }
            if ($cost[$ResType] > $CurrentPlanet[$ResType]) {
                $RetValue = false;
            }
        }
    }
    return $RetValue;
}
示例#2
0
function IsElementBuyable($USER, $PLANET, $Element, $Incremental = true, $ForDestroy = false)
{
    global $pricelist, $resource;
    include_once ROOT_PATH . 'includes/functions/IsVacationMode.' . PHP_EXT;
    if (IsVacationMode($USER)) {
        return false;
    }
    if ($Incremental) {
        $level = isset($PLANET[$resource[$Element]]) ? $PLANET[$resource[$Element]] : $USER[$resource[$Element]];
    }
    $array = array('metal', 'crystal', 'deuterium', 'energy_max', 'darkmatter');
    foreach ($array as $ResType) {
        if (empty($pricelist[$Element][$ResType])) {
            continue;
        }
        if ($Incremental) {
            $cost[$ResType] = floor($pricelist[$Element][$ResType] * pow($pricelist[$Element]['factor'], $level));
        } else {
            $cost[$ResType] = floor($pricelist[$Element][$ResType]);
        }
        if ($ForDestroy) {
            $cost[$ResType] = floor($cost[$ResType] / 2);
        }
        if (isset($PLANET[$ResType]) && $cost[$ResType] > $PLANET[$ResType] || isset($USER[$ResType]) && $cost[$ResType] > $USER[$ResType]) {
            return false;
        }
    }
    return true;
}
    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'] . " ...");
    }
 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');
 }
示例#6
0
function ShowFleet3Page($CurrentUser, $CurrentPlanet)
{
    global $resource, $pricelist, $reslist, $phpEx, $lang, $xgp_root, $game_config;
    include_once $xgp_root . 'includes/functions/IsVacationMode.' . $phpEx;
    $parse = $lang;
    if (IsVacationMode($CurrentUser)) {
        die(message($lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
    }
    $fleet_group_mr = 0;
    if ($_POST['fleet_group'] > 0) {
        if ($_POST['mission'] == 2) {
            $target = "g" . intval($_POST["galaxy"]) . "s" . intval($_POST["system"]) . "p" . intval($_POST["planet"]) . "t" . intval($_POST["planettype"]);
            if ($_POST['acs_target_mr'] == $target) {
                $aks_count_mr = doquery("SELECT * FROM {{table}} WHERE id = '" . intval($_POST['fleet_group']) . "'", 'aks');
                if (mysql_num_rows($aks_count_mr) > 0) {
                    $fleet_group_mr = $_POST['fleet_group'];
                }
            }
        }
    }
    if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
        $_POST['mission'] = 1;
    }
    $TargetPlanet = doquery("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM {{table}} WHERE `galaxy` = '" . intval($_POST['galaxy']) . "' AND `system` = '" . intval($_POST['system']) . "' AND `planet` = '" . intval($_POST['planet']) . "' AND `planet_type` = '" . intval($_POST['planettype']) . "';", 'planets', true);
    $MyDBRec = doquery("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . intval($CurrentUser['id']) . "';", 'users', true);
    $IsHereWormHole = doquery("SELECT * FROM {{table}} WHERE (`start_galaxy` = '" . $_POST['galaxy'] . "' AND `start_system` = '" . $_POST['system'] . "' AND `start_planet` = '" . $_POST['planet'] . "') OR (`end_galaxy` = '" . $_POST['galaxy'] . "' AND `end_system` = '" . $_POST['system'] . "' AND `end_planet` = '" . $_POST['planet'] . "');", 'wormholes', true);
    $protection = $game_config['noobprotection'];
    $protectiontime = $game_config['noobprotectiontime'];
    $protectionmulti = $game_config['noobprotectionmulti'];
    if ($protectiontime < 1) {
        $protectiontime = 9999999999999999;
    }
    $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"])));
    if ($TargetPlanet["destruyed"] != 0) {
        die(header("Location: game.php?page=fleet"));
    }
    if (!is_array($fleetarray)) {
        die(header("Location: game.php?page=fleet"));
    }
    foreach ($fleetarray as $Ship => $Count) {
        if ($Count > $CurrentPlanet[$resource[$Ship]]) {
            die(header("Location: game." . $phpEx . "?page=fleet"));
        }
    }
    $error = 0;
    $galaxy = intval($_POST['galaxy']);
    $system = intval($_POST['system']);
    $planet = intval($_POST['planet']);
    $planettype = intval($_POST['planettype']);
    $fleetmission = intval($_POST['mission']);
    if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($fleetmission == 8) {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "'", "planets");
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "' AND planet_type = '" . $planettype . "'", "planets");
    }
    if ($CurrentPlanet['galaxy'] == $galaxy && $CurrentPlanet['system'] == $system && $CurrentPlanet['planet'] == $planet && $CurrentPlanet['planet_type'] == $planettype) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['mission'] != 15) {
        if (mysql_num_rows($select) < 1 && $fleetmission != 7) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        }
    } else {
        $MaxExpedition = $CurrentUser[$resource[124]];
        if ($MaxExpedition >= 1) {
            $maxexpde = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "' AND `fleet_mission` = '15';", 'fleets', true);
            $ExpeditionEnCours = $maxexpde['expedi'];
            $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3);
        } else {
            $ExpeditionEnCours = 0;
            $EnvoiMaxExpedition = 0;
        }
        if ($EnvoiMaxExpedition == 0) {
            message("<font color=\"red\"><b>" . $lang['fl_expedition_tech_required'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
            message("<font color=\"red\"><b>" . $lang['fl_expedition_fleets_limit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $select = mysql_fetch_array($select);
    if ($select['id_owner'] == $CurrentUser['id']) {
        $YourPlanet = true;
        $UsedPlanet = true;
    } elseif (!empty($select['id_owner'])) {
        $YourPlanet = false;
        $UsedPlanet = true;
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
    }
    if (empty($fleetmission)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($TargetPlanet['id_owner'] == '') {
        $HeDBRec = $MyDBRec;
    } elseif ($TargetPlanet['id_owner'] != '') {
        $HeDBRec = doquery("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . intval($TargetPlanet['id_owner']) . "';", 'users', true);
    }
    $UserPoints = doquery("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($MyDBRec['id']) . "';", 'statpoints', true);
    $User2Points = doquery("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($HeDBRec['id']) . "';", 'statpoints', true);
    $MyGameLevel = $UserPoints['total_points'];
    $HeGameLevel = $User2Points['total_points'];
    if ($HeDBRec['onlinetime'] >= time() - 60 * 60 * 24 * 7) {
        if ($MyGameLevel > $HeGameLevel * $protectionmulti && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $HeGameLevel < $protectiontime * 1000) {
            message("<font color=\"lime\"><b>" . $lang['fl_week_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($MyGameLevel * $protectionmulti < $HeGameLevel && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $MyGameLevel < $protectiontime * 1000) {
            message("<font color=\"red\"><b>" . $lang['fl_strong_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    if ($HeDBRec['urlaubs_modus'] && $_POST['mission'] != 8) {
        message("<font color=\"lime\"><b>" . $lang['fl_in_vacation_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    $FlyingFleets = mysql_fetch_assoc(doquery("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='" . intval($CurrentUser['id']) . "'", 'fleets'));
    $ActualFleets = $FlyingFleets["Number"];
    if (1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * COMMANDANT <= $ActualFleets) {
        message($lang['fl_no_slots'], "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] + $_POST['resource4'] < 1 && $_POST['mission'] == 3) {
        message("<font color=\"lime\"><b>" . $lang['fl_empty_transport'] . "</b></font>", "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['mission'] != 15) {
        if ($TargetPlanet['id_owner'] == '' && $_POST['mission'] < 7) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet['id_owner'] != '' && $_POST['mission'] == 7) {
            message("<font color=\"red\"><b>" . $lang['fl_planet_populed'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($IsHereWormHole) {
            message("<font color=\"red\"><b>Hay un agujero de gusano en esa posicion</b></font>", "fleet." . $phpEx, 2);
        }
        if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $_POST['mission'] == 4) {
            message("<font color=\"red\"><b>" . $lang['fl_stay_not_on_enemy'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet['ally_deposit'] < 1 && $HeDBRec != $MyDBRec && $_POST['mission'] == 5) {
            message("<font color=\"red\"><b>" . $lang['fl_not_ally_deposit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] && ($_POST["mission"] == 1 or $_POST["mission"] == 6)) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] && $_POST["mission"] == 4) {
            message("<font color=\"red\"><b>" . $lang['fl_deploy_only_your_planets'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
    $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
    $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser);
    $GenFleetSpeed = $_POST['speed'];
    $SpeedFactor = $game_config['fleet_speed'] / 2500;
    $MaxFleetSpeed = min($AllFleetSpeed);
    if (!in_array($GenFleetSpeed, $speed_possible)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($MaxFleetSpeed != $_POST['speedallsmin']) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planettype']) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | $_POST['thissystem'] != $CurrentPlanet['system'] | $_POST['thisplanet'] != $CurrentPlanet['planet'] | $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!isset($fleetarray)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['wormhole'] == 'on') {
        $WormHole = doquery("SELECT * FROM {{table}} WHERE (`start_galaxy` = '" . $_POST['wormhole_galaxy'] . "' AND `start_system` = '" . $_POST['wormhole_system'] . "' AND `start_planet` = '" . $_POST['wormhole_planet'] . "') OR (`end_galaxy` = '" . $_POST['wormhole_galaxy'] . "' AND `end_system` = '" . $_POST['wormhole_system'] . "' AND `end_planet` = '" . $_POST['wormhole_planet'] . "');", 'wormholes', true);
        if ($WormHole) {
            if ($WormHole['state'] == 0) {
                message('El Agujero de gusano esta inestable', "game." . $phpEx . "?page=fleet");
            }
            if ($WormHole['time'] < time() and $WormHole['state'] == 1) {
                message('El Agujero de gusano esta inestable', "game." . $phpEx . "?page=fleet");
            }
            if ($fleetarray[210] >= 1) {
                message('Las Sondas de espionaje no pueden atravesar los Agujeros de gusano', "game." . $phpEx . "?page=fleet");
            }
            if ($WormHole['start_galaxy'] == $_POST['wormhole_galaxy'] and $WormHole['start_system'] == $_POST['wormhole_system'] and $WormHole['start_planet'] == $_POST['wormhole_planet']) {
                $Orientation = 'end';
            } else {
                $Orientation = 'start';
            }
            $distance1 = GetTargetDistance($_POST['thisgalaxy'], $_POST['wormhole_galaxy'], $_POST['thissystem'], $_POST['wormhole_system'], $_POST['thisplanet'], $_POST['wormhole_planet']);
            $distance2 = GetTargetDistance($WormHole[$Orientation . '_galaxy'], $_POST['galaxy'], $WormHole[$Orientation . '_system'], $_POST['system'], $WormHole[$Orientation . '_planet'], $_POST['planet']);
            $distance = $distance1 + $distance2;
            $wormhole_id = $WormHole['id'] . ',' . $Orientation;
        } else {
            message('El Agujero de gusano no existe', "game." . $phpEx . "?page=fleet");
        }
    } else {
        $wormhole_id = 0;
        $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
    }
    $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
    $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser);
    $fleet['start_time'] = $duration + time();
    if ($_POST['mission'] == 15) {
        $StayDuration = $_POST['expeditiontime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600;
    } elseif ($_POST['mission'] == 5) {
        $StayDuration = $_POST['holdingtime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
    } else {
        $StayDuration = 0;
        $StayTime = 0;
    }
    $fleet['end_time'] = $StayDuration + 2 * $duration + time();
    $FleetStorage = 0;
    $FleetShipCount = 0;
    $fleet_array = "";
    $FleetSubQRY = "";
    foreach ($fleetarray as $Ship => $Count) {
        $FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
        $FleetShipCount += $Count;
        $fleet_array .= $Ship . "," . $Count . ";";
        $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", ";
    }
    $FleetStorage -= $consumption;
    $StorageNeeded = 0;
    $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
    $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
    $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
    $_POST['resource4'] = max(0, (int) trim($_POST['resource4']));
    if ($_POST['resource1'] < 1) {
        $TransMetal = 0;
    } else {
        $TransMetal = $_POST['resource1'];
        $StorageNeeded += $TransMetal;
    }
    if ($_POST['resource2'] < 1) {
        $TransCrystal = 0;
    } else {
        $TransCrystal = $_POST['resource2'];
        $StorageNeeded += $TransCrystal;
    }
    if ($_POST['resource3'] < 1) {
        $TransDeuterium = 0;
    } else {
        $TransDeuterium = $_POST['resource3'];
        $StorageNeeded += $TransDeuterium;
    }
    if ($_POST['resource4'] < 1) {
        $TransTritium = 0;
    } else {
        $TransTritium = $_POST['resource4'];
        $StorageNeeded += $TransTritium;
    }
    $StockMetal = $CurrentPlanet['metal'];
    $StockCrystal = $CurrentPlanet['crystal'];
    $StockDeuterium = $CurrentPlanet['deuterium'];
    $StockTritium = $CurrentPlanet['tritium'];
    $StockDeuterium -= $consumption;
    $StockOk = false;
    if ($StockMetal >= $TransMetal) {
        if ($StockCrystal >= $TransCrystal) {
            if ($StockDeuterium >= $TransDeuterium) {
                if ($StockTritium >= $TransTritium) {
                    $StockOk = true;
                }
            }
        }
    }
    if (!$StockOk) {
        message("<font color=\"red\"><b>" . $lang['fl_no_enought_deuterium'] . pretty_number($consumption) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($StorageNeeded > $FleetStorage) {
        message("<font color=\"red\"><b>" . $lang['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($TargetPlanet['id_level'] > $CurrentUser['authlevel'] && $game_config['adm_attack'] == 0) {
        message($lang['fl_admins_cannot_be_attacked'], "game." . $phpEx . "?page=fleet", 2);
    }
    if ($fleet_group_mr != 0) {
        $AksStartTime = doquery("SELECT MAX(`fleet_start_time`) AS Start FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "';", "fleets", true);
        if ($AksStartTime['Start'] >= $fleet['start_time']) {
            $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time'];
            $fleet['start_time'] = $AksStartTime['Start'];
        } else {
            $QryUpdateFleets = "UPDATE {{table}} SET ";
            $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
            $QryUpdateFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' ";
            $QryUpdateFleets .= "WHERE ";
            $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "';";
            doquery($QryUpdateFleets, 'fleets');
            $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start'];
        }
    }
    $QryInsertFleet = "INSERT INTO {{table}} SET ";
    $QryInsertFleet .= "`fleet_owner` = '" . intval($CurrentUser['id']) . "', ";
    $QryInsertFleet .= "`fleet_mission` = '" . intval($_POST['mission']) . "',  ";
    $QryInsertFleet .= "`fleet_amount` = '" . intval($FleetShipCount) . "', ";
    $QryInsertFleet .= "`fleet_array` = '" . $fleet_array . "', ";
    $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
    $QryInsertFleet .= "`fleet_start_galaxy` = '" . intval($_POST['thisgalaxy']) . "', ";
    $QryInsertFleet .= "`fleet_start_system` = '" . intval($_POST['thissystem']) . "', ";
    $QryInsertFleet .= "`fleet_start_planet` = '" . intval($_POST['thisplanet']) . "', ";
    $QryInsertFleet .= "`fleet_start_type` = '" . intval($_POST['thisplanettype']) . "', ";
    $QryInsertFleet .= "`fleet_end_time` = '" . intval($fleet['end_time']) . "', ";
    $QryInsertFleet .= "`fleet_end_stay` = '" . intval($StayTime) . "', ";
    $QryInsertFleet .= "`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "', ";
    $QryInsertFleet .= "`fleet_end_system` = '" . intval($_POST['system']) . "', ";
    $QryInsertFleet .= "`fleet_end_planet` = '" . intval($_POST['planet']) . "', ";
    $QryInsertFleet .= "`fleet_end_type` = '" . intval($_POST['planettype']) . "', ";
    $QryInsertFleet .= "`fleet_resource_metal` = '" . $TransMetal . "', ";
    $QryInsertFleet .= "`fleet_resource_crystal` = '" . $TransCrystal . "', ";
    $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $TransDeuterium . "', ";
    $QryInsertFleet .= "`fleet_resource_tritium` = '" . $TransTritium . "', ";
    $QryInsertFleet .= "`fleet_target_owner` = '" . intval($TargetPlanet['id_owner']) . "', ";
    $QryInsertFleet .= "`fleet_wormhole` = '" . $wormhole_id . "', ";
    $QryInsertFleet .= "`fleet_group` = '" . intval($fleet_group_mr) . "',  ";
    $QryInsertFleet .= "`start_time` = '" . time() . "';";
    doquery($QryInsertFleet, 'fleets');
    $QryUpdatePlanet = "UPDATE `{{table}}` SET ";
    $QryUpdatePlanet .= $FleetSubQRY;
    $QryUpdatePlanet .= "`metal` = `metal` - " . $TransMetal . ", ";
    $QryUpdatePlanet .= "`crystal` = `crystal` - " . $TransCrystal . ", ";
    $QryUpdatePlanet .= "`deuterium` = `deuterium` - " . ($TransDeuterium + $consumption) . ", ";
    $QryUpdatePlanet .= "`tritium` = `tritium` - " . $TransTritium . " ";
    $QryUpdatePlanet .= "WHERE ";
    $QryUpdatePlanet .= "`id` = " . intval($CurrentPlanet['id']) . " LIMIT 1;";
    doquery($QryUpdatePlanet, "planets");
    $parse['mission'] = $missiontype[$_POST['mission']];
    $parse['distance'] = pretty_number($distance);
    $parse['speedallsmin'] = pretty_number($_POST['speedallsmin']);
    $parse['consumption'] = pretty_number($consumption);
    $parse['from'] = $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'];
    $parse['destination'] = $_POST['galaxy'] . ":" . $_POST['system'] . ":" . $_POST['planet'];
    $parse['start_time'] = date("M D d H:i:s", $fleet['start_time']);
    $parse['end_time'] = date("M D d H:i:s", $fleet['end_time']);
    foreach ($fleetarray as $Ship => $Count) {
        $fleet_list .= "</tr><tr height=\"20\">";
        $fleet_list .= "<th>" . $lang['tech'][$Ship] . "</th>";
        $fleet_list .= "<th>" . pretty_number($Count) . "</th>";
    }
    $parse['fleet_list'] = $fleet_list;
    display(parsetemplate(gettemplate('fleet/fleet3_table'), $parse), false);
}
 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');
 }
 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);
     if (IsVacationMode($USER)) {
         $this->sendData(620, $LNG['fa_vacation_mode_current']);
     }
     $fleetArray = array();
     switch ($targetMission) {
         case 13:
             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;
         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.id as id, \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\tplanet.teleport_portal as teleport_portal, \n\t\t\t\t\t\t\t\t\t\tplanet.force_field_timer as force_field_timer, \n\t\t\t\t\t\t\t\t\t\ttotal_points, onlinetime, urlaubs_modus, banaday, forcefield_tech, 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 == 13) {
         if ($targetMission == 13) {
             if (FleetFunctions::CheckBashPortal($targetData['id_owner'])) {
                 $this->sendData('rouge', $LNG['fl_bash_protection']);
             }
         }
         if ($targetData['id_owner'] == $USER['id']) {
             $this->sendData('rouge', $LNG['fleet_ajax_19']);
         }
         if ($targetData['force_field_timer'] > TIMESTAMP && $USER['virus_tech'] < $targetData['forcefield_tech']) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_21'], $this->getUsername($targetData['id_owner'])));
         }
         if ($targetData['teleport_portal'] == 0) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_18'], $targetData['name'], $targetData['system'], $targetData['planet']));
         }
         if (FleetFunctions::CheckBashPortal($targetData['id'])) {
             $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']);
         }
     }
     if (connection_aborted()) {
         exit;
     }
     $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 = 1;
     $consumption = 0;
     $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 + 1;
     $shipID = array_keys($fleetArray);
     FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetData['id_owner'], $targetData['id'], $targetData['galaxy'], $targetData['system'], $targetData['planet'], $targetData['planet_type'], $fleetRessource, $fleetPopulation, $fleetStartTime, $fleetStayTime, $fleetEndTime);
     //$finalMsg = sprintf($LNG['fleet_ajax_17'], $targetData['name'], $targetData['system'],$targetData['planet'],$this->getUsername($targetData['id_owner']));
     $finalMsg = sprintf($LNG['fleet_ajax_20'], $targetData['name'], $targetData['system'], $targetData['planet'], $this->getUsername($targetData['id_owner']));
     $this->sendData('vert', $finalMsg);
 }
 public function show()
 {
     global $USER, $PLANET, $LNG, $CONF, $reslist, $resource, $UNI;
     $iraks = $PLANET['interplanetary_misil'];
     $targetGalaxy = HTTP::_GP('galaxy', 0);
     $targetSystem = HTTP::_GP('system', 0);
     $targetPlanet = HTTP::_GP('planet', 0);
     $targetType = HTTP::_GP('type', 0);
     $anz = min(HTTP::_GP('SendMI', 0), $iraks);
     $pziel = HTTP::_GP('Target', 0);
     $target = $GLOBALS['DATABASE']->getFirstRow("SELECT `id`, `id_owner` FROM " . PLANETS . " WHERE `universe` = '" . $UNI . "' AND  `galaxy` = '" . $targetGalaxy . "' AND `system` = '" . $targetSystem . "' AND `planet` = '" . $targetPlanet . "' AND `planet_type` = " . $targetType . ";");
     $Range = FleetFunctions::GetMissileRange($USER[$resource[117]]);
     $systemMin = $PLANET['system'] - $Range;
     $systemMax = $PLANET['system'] + $Range;
     $error = "";
     if (IsVacationMode($USER)) {
         $error = $LNG['fl_vacation_mode_active'];
     } elseif ($PLANET['silo'] < 4) {
         $error = $LNG['ma_silo_level'];
     } elseif ($USER['impulse_motor_tech'] == 0) {
         $error = $LNG['ma_impulse_drive_required'];
     } elseif ($targetGalaxy != $PLANET['galaxy'] || $targetSystem < $systemMin || $targetSystem > $systemMax) {
         $error = $LNG['ma_not_send_other_galaxy'];
     } elseif (!$target) {
         $error = $LNG['ma_planet_doesnt_exists'];
     } elseif (!in_array($pziel, $reslist['defense']) && $pziel != 0) {
         $error = $LNG['ma_wrong_target'];
     } elseif ($iraks == 0) {
         $error = $LNG['ma_no_missiles'];
     } elseif ($anz <= 0) {
         $error = $LNG['ma_add_missile_number'];
     }
     $targetUser = GetUserByID($target['id_owner'], array('onlinetime', 'banaday', 'urlaubs_modus', 'authattack'));
     if (Config::get('adm_attack') == 1 && $targetUser['authattack'] > $USER['authlevel']) {
         $error = $LNG['fl_admin_attack'];
     } elseif ($targetUser['urlaubs_modus']) {
         $error = $LNG['fl_in_vacation_player'];
     }
     $User2Points = $GLOBALS['DATABASE']->getFirstRow("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `id_owner` = '" . $target['id_owner'] . "';");
     $IsNoobProtec = CheckNoobProtec($USER, $User2Points, $targetUser);
     if ($IsNoobProtec['NoobPlayer']) {
         $error = $LNG['fl_week_player'];
     } elseif ($IsNoobProtec['StrongPlayer']) {
         $error = $LNG['fl_strong_player'];
     }
     if ($error != "") {
         $this->printMessage($error);
     }
     $Duration = FleetFunctions::GetMIPDuration($PLANET['system'], $targetSystem);
     $DefenseLabel = $pziel == 0 ? $LNG['ma_all'] : $LNG['tech'][$pziel];
     if (connection_aborted()) {
         exit;
     }
     $fleetArray = array(503 => $anz);
     $fleetStartTime = TIMESTAMP + $Duration;
     $fleetStayTime = $fleetStartTime;
     $fleetEndTime = $fleetStartTime;
     $fleetRessource = array(901 => 0, 902 => 0, 903 => 0);
     FleetFunctions::sendFleet($fleetArray, 10, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $target['id_owner'], $target['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, 0, $pziel);
     $this->printMessage("<b>" . $anz . "</b>" . $LNG['ma_missiles_sended'] . $DefenseLabel);
 }
示例#10
0
 public function show()
 {
     global $USER, $PLANET, $resource, $LNG, $CONF, $pricelist;
     $UserDeuterium = $PLANET['elyrium'];
     $planetID = HTTP::_GP('planetID', 0);
     $targetMission = HTTP::_GP('mission', 0);
     $galaxyC = HTTP::_GP('galaxyC', 0);
     $systemC = HTTP::_GP('systemC', 0);
     $planetC = HTTP::_GP('planetC', 0);
     if (IsVacationMode($USER)) {
         $this->sendData(620, $LNG['fa_vacation_mode_current']);
     }
     $fleetArray = array();
     switch ($targetMission) {
         case 14:
             if (!isModulAvalible(MODULE_MISSION_SPY)) {
                 $this->sendData('rouge', $LNG['sys_module_inactive']);
             }
             if ($PLANET['teleport_portal'] == 0) {
                 $this->sendData('rouge', $LNG['fleet_ajax_11']);
             }
             $ships = min($USER['spio_anz'], $PLANET[$resource[210]]);
             if (empty($ships)) {
                 $this->sendData('rouge', $LNG['fleet_ajax_22']);
             }
             $fleetArray = array(210 => $ships);
             $this->returnData['ships'][210] = $PLANET[$resource[210]] - $ships;
             break;
         case 7:
             if (!isModulAvalible(MODULE_MISSION_COLONY)) {
                 $this->sendData('rouge', $LNG['sys_module_inactive']);
             }
             if ($PLANET['teleport_portal'] == 0) {
                 $this->sendData('rouge', $LNG['fleet_ajax_11']);
             }
             if ($PLANET[$resource[303]] < 10 || $PLANET[$resource[306]] < 100) {
                 $this->sendData('rouge', sprintf($LNG['fleet_ajax_12'], $PLANET[$resource[303]], $PLANET[$resource[306]]));
             }
             $fleetArray = array(303 => 10, 306 => 100);
             break;
         default:
             $this->sendData('rouge', $LNG['fleet_ajax_22']);
             break;
     }
     $fleetArray = array_filter($fleetArray);
     if (empty($fleetArray)) {
         $this->sendData('rouge', $LNG['fleet_ajax_22']);
     }
     $iPlanetCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . PLANETS . " WHERE `id_owner` = '" . $USER['id'] . "' AND `planet_type` = '1' AND `destruyed` = '0';");
     $MaxPlanets = PlayerUtil::maxPlanetCount($USER);
     if ($iPlanetCount >= $MaxPlanets && $targetMission == 7) {
         $this->sendData('rouge', $LNG['fleet_ajax_14']);
     }
     $targetData = $GLOBALS['DATABASE']->getFirstRow("SELECT planet.id_owner as id_owner, \n\t\t\t\t\t\t\t\t\t\tplanet.id as id, \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\tplanet.force_field_timer as force_field_timer, \n\t\t\t\t\t\t\t\t\t\tplanet.teleport_portal as teleport_portal, \n\t\t\t\t\t\t\t\t\t\ttotal_points, onlinetime, forcefield_tech, 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.galaxy = " . $galaxyC . " AND planet.system = " . $systemC . " AND planet.planet = " . $planetC . ";");
     $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 ($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 == 14) {
         if ($targetData['id_owner'] == $USER['id']) {
             $this->sendData('rouge', $LNG['fleet_ajax_19']);
         }
         if ($targetData['force_field_timer'] > TIMESTAMP && $USER['virus_tech'] < $targetData['forcefield_tech']) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_21'], $this->getUsername($targetData['id_owner'])));
         }
         if ($targetData['teleport_portal'] == 0) {
             $this->sendData('rouge', sprintf($LNG['fleet_ajax_18'], $targetData['name'], $targetData['system'], $targetData['planet']));
         }
         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']);
         }
     }
     if (connection_aborted()) {
         exit;
     }
     $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 = 1;
     $consumption = 0;
     $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);
     if ($targetMission == 7) {
         $targetData = array('id' => 0, 'id_owner' => 0, 'planettype' => 1);
     }
     $fleetStartTime = $Duration + TIMESTAMP;
     $fleetStayTime = $fleetStartTime;
     $fleetEndTime = $fleetStayTime + 1;
     $shipID = array_keys($fleetArray);
     if ($targetMission == 7) {
         FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetData['id_owner'], 0, $galaxyC, $systemC, $planetC, 1, $fleetRessource, $fleetPopulation, $fleetStartTime, $fleetStayTime, $fleetEndTime);
     } else {
         FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetData['id_owner'], $targetData['id'], $targetData['galaxy'], $targetData['system'], $targetData['planet'], $targetData['planet_type'], $fleetRessource, $fleetPopulation, $fleetStartTime, $fleetStayTime, $fleetEndTime);
     }
     if ($targetMission == 7) {
         $finalMsg = sprintf($LNG['fleet_ajax_10'], $systemC, $planetC);
     } else {
         $finalMsg = sprintf($LNG['fleet_ajax_17'], $targetData['name'], $targetData['system'], $targetData['planet'], $this->getUsername($targetData['id_owner']));
     }
     $this->sendData('vert', $finalMsg);
 }
示例#11
0
function BuildRessourcePage($CurrentUser, $CurrentPlanet)
{
    global $pricelist, $lang, $ProdGrid, $resource, $reslist, $game_config, $_POST;
    includeLang('resources');
    if (IsVacationMode($CurrentUser)) {
        message($lang['Vacation_mode'], $lang['Error'], "overview.php", 1);
    }
    $RessBodyTPL = gettemplate('resources');
    $RessRowTPL = gettemplate('resources_row');
    // Si c'est une lune ... pas de ressources produites
    if ($CurrentPlanet['planet_type'] == 3) {
        $game_config['metal_basic_income'] = 0;
        $game_config['crystal_basic_income'] = 0;
        $game_config['deuterium_basic_income'] = 0;
    }
    $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
    $SubQry = "";
    if ($_POST) {
        foreach ($_POST as $Field => $Value) {
            $FieldName = $Field . "_porcent";
            if (isset($CurrentPlanet[$FieldName])) {
                if (!in_array($Value, $ValidList['percent'])) {
                    header("Location: overview.php");
                    exit;
                }
                $Value = $Value / 10;
                $CurrentPlanet[$FieldName] = $Value;
                $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
            }
        }
    }
    $parse = $lang;
    $parse['production_level'] = 100;
    if ($CurrentPlanet['energy_max'] == 0 && $CurrentPlanet['energy_used'] > 0) {
        $post_porcent = 0;
    } elseif ($CurrentPlanet['energy_max'] > 0 && $CurrentPlanet['energy_used'] + $CurrentPlanet['energy_max'] < 0) {
        $post_porcent = floor($CurrentPlanet['energy_max'] / $CurrentPlanet['energy_used'] * 100);
    } else {
        $post_porcent = 100;
    }
    if ($post_porcent > 100) {
        $post_porcent = 100;
    }
    // -------------------------------------------------------------------------------------------------------
    // Mise a jour de l'espace de stockage
    $CurrentPlanet['metal_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[22]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    $CurrentPlanet['crystal_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[23]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    $CurrentPlanet['deuterium_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[24]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    // -------------------------------------------------------------------------------------------------------
    $parse['resource_row'] = "";
    $CurrentPlanet['metal_perhour'] = 0;
    $CurrentPlanet['crystal_perhour'] = 0;
    $CurrentPlanet['deuterium_perhour'] = 0;
    $CurrentPlanet['energy_max'] = 0;
    $CurrentPlanet['energy_used'] = 0;
    $BuildTemp = $CurrentPlanet['temp_max'];
    foreach ($reslist['prod'] as $ProdID) {
        if ($CurrentPlanet[$resource[$ProdID]] > 0 && isset($ProdGrid[$ProdID])) {
            $BuildLevelFactor = $CurrentPlanet[$resource[$ProdID] . "_porcent"];
            $BuildLevel = $CurrentPlanet[$resource[$ProdID]];
            $metal = floor(eval($ProdGrid[$ProdID]['formule']['metal']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05));
            $crystal = floor(eval($ProdGrid[$ProdID]['formule']['crystal']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05));
            $deuterium = floor(eval($ProdGrid[$ProdID]['formule']['deuterium']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05));
            $energy = floor(eval($ProdGrid[$ProdID]['formule']['energy']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_ingenieur'] * 0.05));
            if ($energy > 0) {
                $CurrentPlanet['energy_max'] += $energy;
            } else {
                $CurrentPlanet['energy_used'] += $energy;
            }
            $CurrentPlanet['metal_perhour'] += $metal;
            $CurrentPlanet['crystal_perhour'] += $crystal;
            $CurrentPlanet['deuterium_perhour'] += $deuterium;
            $metal = $metal * 0.01 * $post_porcent;
            $crystal = $crystal * 0.01 * $post_porcent;
            $deuterium = $deuterium * 0.01 * $post_porcent;
            $energy = $energy * 0.01 * $post_porcent;
            $Field = $resource[$ProdID] . "_porcent";
            $CurrRow = array();
            $CurrRow['name'] = $resource[$ProdID];
            $CurrRow['porcent'] = $CurrentPlanet[$Field];
            for ($Option = 10; $Option >= 0; $Option--) {
                $OptValue = $Option * 10;
                if ($Option == $CurrRow['porcent']) {
                    $OptSelected = " selected=selected";
                } else {
                    $OptSelected = "";
                }
                $CurrRow['option'] .= "<option value=\"" . $OptValue . "\"" . $OptSelected . ">" . $OptValue . "%</option>";
            }
            $CurrRow['type'] = $lang['tech'][$ProdID];
            $CurrRow['level'] = $ProdID > 200 ? $lang['quantity'] : $lang['level'];
            $CurrRow['level_type'] = $CurrentPlanet[$resource[$ProdID]];
            $CurrRow['metal_type'] = pretty_number($metal);
            $CurrRow['crystal_type'] = pretty_number($crystal);
            $CurrRow['deuterium_type'] = pretty_number($deuterium);
            $CurrRow['energy_type'] = pretty_number($energy);
            $CurrRow['metal_type'] = colorNumber($CurrRow['metal_type']);
            $CurrRow['crystal_type'] = colorNumber($CurrRow['crystal_type']);
            $CurrRow['deuterium_type'] = colorNumber($CurrRow['deuterium_type']);
            $CurrRow['energy_type'] = colorNumber($CurrRow['energy_type']);
            $parse['resource_row'] .= parsetemplate($RessRowTPL, $CurrRow);
        }
    }
    $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $CurrentPlanet['name'], $lang['Production_of_resources_in_the_planet']);
    if ($CurrentPlanet['energy_max'] == 0 && $CurrentPlanet['energy_used'] > 0) {
        $parse['production_level'] = 0;
    } elseif ($CurrentPlanet['energy_max'] > 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
        $parse['production_level'] = floor($CurrentPlanet['energy_max'] / $CurrentPlanet['energy_used'] * 100);
    } elseif ($CurrentPlanet['energy_max'] == 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
        $parse['production_level'] = 0;
    } else {
        $parse['production_level'] = 100;
    }
    if ($parse['production_level'] > 100) {
        $parse['production_level'] = 100;
    }
    $parse['metal_basic_income'] = $game_config['metal_basic_income'] * $game_config['resource_multiplier'];
    $parse['crystal_basic_income'] = $game_config['crystal_basic_income'] * $game_config['resource_multiplier'];
    $parse['deuterium_basic_income'] = $game_config['deuterium_basic_income'] * $game_config['resource_multiplier'];
    $parse['energy_basic_income'] = $game_config['energy_basic_income'] * $game_config['resource_multiplier'];
    if ($CurrentPlanet['metal_max'] < $CurrentPlanet['metal']) {
        $parse['metal_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['metal_max'] = "<font color=\"#00ff00\">";
    }
    $parse['metal_max'] .= pretty_number($CurrentPlanet['metal_max'] / 1000) . " " . $lang['k'] . "</font>";
    if ($CurrentPlanet['crystal_max'] < $CurrentPlanet['crystal']) {
        $parse['crystal_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['crystal_max'] = "<font color=\"#00ff00\">";
    }
    $parse['crystal_max'] .= pretty_number($CurrentPlanet['crystal_max'] / 1000) . " " . $lang['k'] . "</font>";
    if ($CurrentPlanet['deuterium_max'] < $CurrentPlanet['deuterium']) {
        $parse['deuterium_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['deuterium_max'] = "<font color=\"#00ff00\">";
    }
    $parse['deuterium_max'] .= pretty_number($CurrentPlanet['deuterium_max'] / 1000) . " " . $lang['k'] . "</font>";
    $parse['metal_total'] = colorNumber(pretty_number(floor($CurrentPlanet['metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income'])));
    $parse['crystal_total'] = colorNumber(pretty_number(floor($CurrentPlanet['crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'])));
    $parse['deuterium_total'] = colorNumber(pretty_number(floor($CurrentPlanet['deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'])));
    $parse['energy_total'] = colorNumber(pretty_number(floor($CurrentPlanet['energy_max'] + $parse['energy_basic_income'] + $CurrentPlanet['energy_used'])));
    $parse['daily_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24);
    $parse['weekly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 7);
    $parse['monthly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 30);
    $parse['daily_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24);
    $parse['weekly_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 7);
    $parse['monthly_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 30);
    $parse['daily_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24);
    $parse['weekly_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 7);
    $parse['monthly_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 30);
    $parse['daily_metal'] = colorNumber(pretty_number($parse['daily_metal']));
    $parse['weekly_metal'] = colorNumber(pretty_number($parse['weekly_metal']));
    $parse['monthly_metal'] = colorNumber(pretty_number($parse['monthly_metal']));
    $parse['daily_crystal'] = colorNumber(pretty_number($parse['daily_crystal']));
    $parse['weekly_crystal'] = colorNumber(pretty_number($parse['weekly_crystal']));
    $parse['monthly_crystal'] = colorNumber(pretty_number($parse['monthly_crystal']));
    $parse['daily_deuterium'] = colorNumber(pretty_number($parse['daily_deuterium']));
    $parse['weekly_deuterium'] = colorNumber(pretty_number($parse['weekly_deuterium']));
    $parse['monthly_deuterium'] = colorNumber(pretty_number($parse['monthly_deuterium']));
    $parse['metal_storage'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) . $lang['o/o'];
    $parse['crystal_storage'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100) . $lang['o/o'];
    $parse['deuterium_storage'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) . $lang['o/o'];
    $parse['metal_storage_bar'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100 * 2.5);
    $parse['crystal_storage_bar'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100 * 2.5);
    $parse['deuterium_storage_bar'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100 * 2.5);
    if ($parse['metal_storage_bar'] > 100 * 2.5) {
        $parse['metal_storage_bar'] = 250;
        $parse['metal_storage_barcolor'] = '#C00000';
    } elseif ($parse['metal_storage_bar'] > 80 * 2.5) {
        $parse['metal_storage_barcolor'] = '#C0C000';
    } else {
        $parse['metal_storage_barcolor'] = '#00C000';
    }
    if ($parse['crystal_storage_bar'] > 100 * 2.5) {
        $parse['crystal_storage_bar'] = 250;
        $parse['crystal_storage_barcolor'] = '#C00000';
    } elseif ($parse['crystal_storage_bar'] > 80 * 2.5) {
        $parse['crystal_storage_barcolor'] = '#C0C000';
    } else {
        $parse['crystal_storage_barcolor'] = '#00C000';
    }
    if ($parse['deuterium_storage_bar'] > 100 * 2.5) {
        $parse['deuterium_storage_bar'] = 250;
        $parse['deuterium_storage_barcolor'] = '#C00000';
    } elseif ($parse['deuterium_storage_bar'] > 80 * 2.5) {
        $parse['deuterium_storage_barcolor'] = '#C0C000';
    } else {
        $parse['deuterium_storage_barcolor'] = '#00C000';
    }
    $parse['production_level_bar'] = $parse['production_level'] * 2.5;
    $parse['production_level'] = "{$parse['production_level']}%";
    $parse['production_level_barcolor'] = '#00ff00';
    $QryUpdatePlanet = "UPDATE {{table}} SET ";
    $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "' ";
    $QryUpdatePlanet .= $SubQry;
    $QryUpdatePlanet .= "WHERE ";
    $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';";
    doquery($QryUpdatePlanet, 'planets');
    ///////////////Naves////////////////
    $c = 202;
    //Contador inicio naves
    $m = 215;
    //final
    while ($c <= $m) {
        //naves
        $pemd = $pricelist[$c]['metal'];
        //precio de la nave
        $pecd = $pricelist[$c]['crystal'];
        //precio de la nave
        $pedd = $pricelist[$c]['deuterium'];
        //precio de la nave
        //recursos
        $recursosmetaldia = floor($CurrentPlanet['metal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24);
        $recursosmetalsemana = floor($CurrentPlanet['metal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 7);
        $recursosmetalmes = floor($CurrentPlanet['metal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 30);
        $recursoscristaldia = floor($CurrentPlanet['crystal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24);
        $recursoscristalsemana = floor($CurrentPlanet['crystal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 7);
        $recursoscristalmes = floor($CurrentPlanet['crystal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 30);
        $recursosdeudia = floor($CurrentPlanet['deuterium_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24);
        $recursosdeusemana = floor($CurrentPlanet['deuterium_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 7);
        $recursosdeumes = floor($CurrentPlanet['deuterium_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 30);
        //Calculamos
        //por dia
        $xmdia = @floor($recursosmetaldia / $pemd);
        //por dia
        $xcdia = @floor($recursoscristaldia / $pecd);
        //por dia
        $xddia = @floor($recursosdeudia / $pedd);
        //por dia
        //por mes
        $xmmes = @floor($recursosmetalmes / $pemd);
        //por mes
        $xcmes = @floor($recursoscristalmes / $pecd);
        //por mes
        $xdmes = @floor($recursosdeumes / $pedd);
        //por mes
        if ($xmdia > 0) {
            $ahimetal = "1";
            $xdia = $xcdia;
        } else {
            $ahimetal = "0";
        }
        if ($xcdia > 0) {
            $ahicristal = "1";
            $xdia = $xcdia;
        } else {
            $ahicristal = "0";
        }
        if ($xddia > 0) {
            $ahideuterio = "1";
            $xdia = $xddia;
        } else {
            $ahideuterio = "0";
        }
        //casos de por dia
        //Caso 1
        if ($ahimetal == 1 and $ahicristal == 1 and $ahideuterio == 0) {
            //Si existe cristal y metal
            if ($xmdia <= $xcdia) {
                //si metal es menor o igual que el cristal
                $xdia = $xmdia;
                //ponemos los que son ya
            } else {
                //si el cristal es menor que el metal
                $xdia = $xcdia;
                //ponemos los que son
            }
            //Fin
        }
        //Fin caso 1
        //Caso 2
        if ($ahimetal == 1 and $ahicristal == 1 and $ahideuterio == 1) {
            //Si existe cristal y metal
            if ($xmdia <= $xcdia) {
                //si metal es menor o igual que el cristal
                $xdia = $xmdia;
                //ponemos los que son ya
                if ($xmdia <= $xddia) {
                    //Si es menor o igual que el deuterio
                    $xdia = $xmdia;
                    //ponemos de nuevo los que son
                } else {
                    //si el deuterio es mayor
                    if ($xddia > 0) {
                        //y deuterio es mayor que 0 (en recursos para producirlo)
                        $xdia = $xddia;
                        //ponemos los que son
                    }
                    //Fin
                }
                //Fin final
            } else {
                //si el cristal es menor que el metal
                $xdia = $xcdia;
                //ponemos los que son
                if ($xcdia <= $xddia) {
                    //si es menor o igual que el deuterio
                    $xdia = $xcdia;
                    // ponemos ls que son
                } else {
                    //si no
                    if ($xddia > 0) {
                        //y el deuterio es mayor
                        $xdia = $xddia;
                        //ponemos los que son
                    }
                    //Fin
                }
                //Fin
            }
            //Fin
        }
        //Fin caso 2
        //Caso 3
        if ($ahimetal == 1 and $ahicristal == 0 and $ahideuterio == 1) {
            //Si existe cristal y metal
            if ($xmdia <= $xddia) {
                //si metal es menor o igual que el deuterio
                $xdia = $xmdia;
                //ponemos los que son ya
            } else {
                //si el deuterio es menor que el metal
                $xdia = $xddia;
                //ponemos los que son
            }
            //Fin
        }
        //Fin caso 3
        //Caso 4
        if ($ahimetal == 0 and $ahicristal == 1 and $ahideuterio == 1) {
            //Si existe cristal y metal
            if ($xcdia <= $xddia) {
                //si cristal es menor o igual que el deuterio
                $xdia = $xcdia;
                //ponemos los que son ya
            } else {
                //si el deuterio es menor que el metal
                $xdia = $xddia;
                //ponemos los que son
            }
            //Fin
        }
        //Fin caso 4
        //caso 5
        if ($ahimetal == 1 and $ahicristal == 0 and $ahideuterio == 0) {
            $xdia = $xmdia;
        }
        //caso 6
        if ($ahimetal == 0 and $ahicristal == 1 and $ahideuterio == 0) {
            $xdia = $xcdia;
        }
        //caso 7
        if ($ahimetal == 0 and $ahicristal == 0 and $ahideuterio == 1) {
            $xdia = $xddia;
        }
        //Fin de por dia
        $xsemana = floor($xdia * 7);
        $xmes = floor($xdia * 30);
        $parse['predu_fleet'] .= "<tr>";
        $parse['predu_fleet'] .= "<th>" . $lang['tech'][$c] . "</th>";
        $parse['predu_fleet'] .= "<th>" . $xdia . "</th>";
        $parse['predu_fleet'] .= "<th>" . $xsemana . "</th>";
        $parse['predu_fleet'] .= "<th>" . $xmes . "</th>";
        $parse['predu_fleet'] .= "</tr>";
        $c++;
    }
    ////////////////Defensas////////////////
    $c = 401;
    //Contador inicio naves
    $m = 503;
    //final
    while ($c <= $m) {
        //naves
        $pemd = $pricelist[$c]['metal'];
        //precio de la nave
        $pecd = $pricelist[$c]['crystal'];
        //precio de la nave
        $pedd = $pricelist[$c]['deuterium'];
        //precio de la nave
        //recursos
        $recursosmetaldia = floor($CurrentPlanet['metal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24);
        $recursosmetalsemana = floor($CurrentPlanet['metal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 7);
        $recursosmetalmes = floor($CurrentPlanet['metal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 30);
        $recursoscristaldia = floor($CurrentPlanet['crystal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24);
        $recursoscristalsemana = floor($CurrentPlanet['crystal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 7);
        $recursoscristalmes = floor($CurrentPlanet['crystal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 30);
        $recursosdeudia = floor($CurrentPlanet['deuterium_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24);
        $recursosdeusemana = floor($CurrentPlanet['deuterium_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 7);
        $recursosdeumes = floor($CurrentPlanet['deuterium_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 30);
        //Calculamos
        //por dia
        $xmdia = @floor($recursosmetaldia / $pemd);
        //por dia
        $xcdia = @floor($recursoscristaldia / $pecd);
        //por dia
        $xddia = @floor($recursosdeudia / $pedd);
        //por dia
        //por mes
        $xmmes = @floor($recursosmetalmes / $pemd);
        //por mes
        $xcmes = @floor($recursoscristalmes / $pecd);
        //por mes
        $xdmes = @floor($recursosdeumes / $pedd);
        //por mes
        if ($xmdia > 0) {
            $ahimetal = "1";
            $xdia = $xcdia;
        } else {
            $ahimetal = "0";
        }
        if ($xcdia > 0) {
            $ahicristal = "1";
            $xdia = $xcdia;
        } else {
            $ahicristal = "0";
        }
        if ($xddia > 0) {
            $ahideuterio = "1";
            $xdia = $xddia;
        } else {
            $ahideuterio = "0";
        }
        //casos de por dia
        //Caso 1
        if ($ahimetal == 1 and $ahicristal == 1 and $ahideuterio == 0) {
            //Si existe cristal y metal
            if ($xmdia <= $xcdia) {
                //si metal es menor o igual que el cristal
                $xdia = $xmdia;
                //ponemos los que son ya
            } else {
                //si el cristal es menor que el metal
                $xdia = $xcdia;
                //ponemos los que son
            }
            //Fin
        }
        //Fin caso 1
        //Caso 2
        if ($ahimetal == 1 and $ahicristal == 1 and $ahideuterio == 1) {
            //Si existe cristal y metal
            if ($xmdia <= $xcdia) {
                //si metal es menor o igual que el cristal
                $xdia = $xmdia;
                //ponemos los que son ya
                if ($xmdia <= $xddia) {
                    //Si es menor o igual que el deuterio
                    $xdia = $xmdia;
                    //ponemos de nuevo los que son
                } else {
                    //si el deuterio es mayor
                    if ($xddia > 0) {
                        //y deuterio es mayor que 0 (en recursos para producirlo)
                        $xdia = $xddia;
                        //ponemos los que son
                    }
                    //Fin
                }
                //Fin final
            } else {
                //si el cristal es menor que el metal
                $xdia = $xcdia;
                //ponemos los que son
                if ($xcdia <= $xddia) {
                    //si es menor o igual que el deuterio
                    $xdia = $xcdia;
                    // ponemos ls que son
                } else {
                    //si no
                    if ($xddia > 0) {
                        //y el deuterio es mayor
                        $xdia = $xddia;
                        //ponemos los que son
                    }
                    //Fin
                }
                //Fin
            }
            //Fin
        }
        //Fin caso 2
        //Caso 3
        if ($ahimetal == 1 and $ahicristal == 0 and $ahideuterio == 1) {
            //Si existe cristal y metal
            if ($xmdia <= $xddia) {
                //si metal es menor o igual que el deuterio
                $xdia = $xmdia;
                //ponemos los que son ya
            } else {
                //si el deuterio es menor que el metal
                $xdia = $xddia;
                //ponemos los que son
            }
            //Fin
        }
        //Fin caso 3
        //Caso 4
        if ($ahimetal == 0 and $ahicristal == 1 and $ahideuterio == 1) {
            //Si existe cristal y metal
            if ($xcdia <= $xddia) {
                //si cristal es menor o igual que el deuterio
                $xdia = $xcdia;
                //ponemos los que son ya
            } else {
                //si el deuterio es menor que el metal
                $xdia = $xddia;
                //ponemos los que son
            }
            //Fin
        }
        //Fin caso 4
        //caso 5
        if ($ahimetal == 1 and $ahicristal == 0 and $ahideuterio == 0) {
            $xdia = $xmdia;
        }
        //caso 6
        if ($ahimetal == 0 and $ahicristal == 1 and $ahideuterio == 0) {
            $xdia = $xcdia;
        }
        //caso 7
        if ($ahimetal == 0 and $ahicristal == 0 and $ahideuterio == 1) {
            $xdia = $xddia;
        }
        //Fin de por dia
        $xsemana = floor($xdia * 7);
        $xmes = floor($xdia * 30);
        $parse['predu_def'] .= "<tr>";
        $parse['predu_def'] .= "<th>" . $lang['tech'][$c] . "</th>";
        $parse['predu_def'] .= "<th>" . $xdia . "</th>";
        $parse['predu_def'] .= "<th>" . $xsemana . "</th>";
        $parse['predu_def'] .= "<th>" . $xmes . "</th>";
        $parse['predu_def'] .= "</tr>";
        if ($c == 408) {
            $c = 502;
        } else {
            $c++;
        }
    }
    $page = parsetemplate($RessBodyTPL, $parse);
    return $page;
}
示例#12
0
function ShowFleet3Page($CurrentUser, &$CurrentPlanet)
{
    global $resource, $pricelist, $reslist, $phpEx, $lang, $svn_root, $db, $displays;
    include_once $svn_root . 'includes/functions/IsVacationMode.' . $phpEx;
    //$parse = $lang;
    if (IsVacationMode($CurrentUser)) {
        exit($displays->message($lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
    }
    $displays->assignContent('fleet/fleet3_table');
    $fleet_group_mr = 0;
    if ($_POST['fleet_group'] != 0) {
        if ($_POST['mission'] == 2) {
            $aks_count_mr = $db->query("SELECT * FROM {{table}} WHERE id = '" . $_POST['fleet_group'] . "'", 'sac');
            if (mysql_num_rows($aks_count_mr) > 0) {
                $fleet_group_mr = $_POST['fleet_group'];
            }
        }
    }
    if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
        $_POST['mission'] = 1;
    }
    $TargetPlanet = $db->query("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM {{table}} WHERE `galaxy` = '" . $_POST['galaxy'] . "' AND `system` = '" . $_POST['system'] . "' AND `planet` = '" . $_POST['planet'] . "' AND `planet_type` = '" . $_POST['planettype'] . "';", 'planets', true);
    $MyDBRec = $db->query("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . $CurrentUser['id'] . "';", 'users', true);
    $protection = $db->game_config['noobprotection'];
    $protectiontime = $db->game_config['noobprotectiontime'];
    $protectionmulti = $db->game_config['noobprotectionmulti'];
    if ($protectiontime < 1) {
        $protectiontime = 9999999999999999;
    }
    $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"])));
    if ($TargetPlanet["destruyed"] != 0) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!is_array($fleetarray)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    foreach ($fleetarray as $Ship => $Count) {
        if ($Count > $CurrentPlanet[$resource[$Ship]]) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
    }
    $error = 0;
    $galaxy = intval($_POST['galaxy']);
    $system = intval($_POST['system']);
    $planet = intval($_POST['planet']);
    $planettype = intval($_POST['planettype']);
    $fleetmission = $_POST['mission'];
    if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($fleetmission == 8) {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = $db->query("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "'", "planets");
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = $db->query("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "' AND planet_type = '" . $planettype . "'", "planets");
    }
    if ($CurrentPlanet['galaxy'] == $galaxy && $CurrentPlanet['system'] == $system && $CurrentPlanet['planet'] == $planet && $CurrentPlanet['planet_type'] == $planettype) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['mission'] != 15) {
        if (mysql_num_rows($select) < 1 && $fleetmission != 7) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
    } else {
        $MaxExpedition = $CurrentUser[$resource[124]];
        if ($MaxExpedition >= 1) {
            $maxexpde = $db->query("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "' AND `fleet_mission` = '15';", 'fleets', true);
            $ExpeditionEnCours = $maxexpde['expedi'];
            $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3);
        } else {
            $ExpeditionEnCours = 0;
            $EnvoiMaxExpedition = 0;
        }
        if ($EnvoiMaxExpedition == 0) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_expedition_tech_required'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_expedition_fleets_limit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $select = mysql_fetch_array($select);
    if ($select['id_owner'] == $CurrentUser['id']) {
        $YourPlanet = true;
        $UsedPlanet = true;
    } elseif (!empty($select['id_owner'])) {
        $YourPlanet = false;
        $UsedPlanet = true;
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
    }
    if (empty($fleetmission)) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($TargetPlanet['id_owner'] == '') {
        $HeDBRec = $MyDBRec;
    } elseif ($TargetPlanet['id_owner'] != '') {
        $HeDBRec = $db->query("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . $TargetPlanet['id_owner'] . "';", 'users', true);
    }
    $UserPoints = $db->query("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $MyDBRec['id'] . "';", 'statpoints', true);
    $User2Points = $db->query("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';", 'statpoints', true);
    $MyGameLevel = $UserPoints['total_points'];
    $HeGameLevel = $User2Points['total_points'];
    //PROTECCION
    include_once "./includes/functions/classes/class.noobs.php";
    $noobs = new proteccion_noob();
    $noobs->prin = $MyGameLevel;
    $noobs->mission = $_POST['mission'];
    $noobs->seco = $HeGameLevel;
    $noobs->vacation = $HeDBRec['urlaubs_modus'];
    $noobs_users = $noobs->check();
    if ($noobs_users['status']) {
        $span = explode("_", $noobs_users['lang_g']);
        $array = array("s" => "red", "w" => "lime", "v" => "lime");
        //$ResultMessage = "{$array[$span[1]]}; ".$lang[$noobs_users['lang_f']]." |".$CurrentFlyingFleets." ".$UserSpyProbes." ".$UserRecycles." ".$UserMissiles;
        //die ( $ResultMessage );
        $displays->message("<font color=\"{$array[$span[1]]}\"><b>" . $lang[$noobs_users['lang_f']] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    /*
    	if($HeDBRec['onlinetime'] >= (time()-60 * 60 * 24 * 7))
    	{
    		if ($MyGameLevel > ($HeGameLevel * $protectionmulti)
    			&& $TargetPlanet['id_owner'] != ''
    			&& ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)
    			&& $protection == 1
    			&& $HeGameLevel < ($protectiontime * 1000))
    			$displays->message("<font color=\"lime\"><b>".$lang['fl_week_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2);
    
    		if (($MyGameLevel * $protectionmulti) < $HeGameLevel
    			&& $TargetPlanet['id_owner'] != ''
    			&& ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)
    			&& $protection == 1
    			&& $MyGameLevel < ($protectiontime * 1000))
    			$displays->message("<font color=\"red\"><b>".$lang['fl_strong_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2);
    	}
    
    	if ($HeDBRec['urlaubs_modus'] && $_POST['mission'] != 8)
    		$displays->message("<font color=\"lime\"><b>".$lang['fl_in_vacation_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2);
    */
    //FIN DE PROTECCION
    $FlyingFleets = mysql_fetch_assoc($db->query("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='{$CurrentUser['id']}'", 'fleets'));
    $ActualFleets = $FlyingFleets["Number"];
    if (1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * 3 <= $ActualFleets) {
        $displays->message($lang['fl_no_slots'], "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) {
        $displays->message("<font color=\"lime\"><b>" . $lang['fl_empty_transport'] . "</b></font>", "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['mission'] != 15) {
        if ($TargetPlanet['id_owner'] == '' && $_POST['mission'] < 7) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet['id_owner'] != '' && $_POST['mission'] == 7) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_planet_populed'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $_POST['mission'] == 4) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_stay_not_on_enemy'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet['ally_deposit'] < 1 && $HeDBRec != $MyDBRec && $_POST['mission'] == 5) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_not_ally_deposit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] && ($_POST["mission"] == 1 or $_POST["mission"] == 6)) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] && $_POST["mission"] == 4) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_deploy_only_your_planets'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
    $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
    $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser);
    $GenFleetSpeed = $_POST['speed'];
    $SpeedFactor = $_POST['speedfactor'];
    $MaxFleetSpeed = min($AllFleetSpeed);
    if (!in_array($GenFleetSpeed, $speed_possible)) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($MaxFleetSpeed != $_POST['speedallsmin']) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planettype']) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | $_POST['thissystem'] != $CurrentPlanet['system'] | $_POST['thisplanet'] != $CurrentPlanet['planet'] | $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!isset($fleetarray)) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
    $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
    $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser);
    $fleet['start_time'] = $duration + time();
    if ($_POST['mission'] == 15) {
        $StayDuration = $_POST['expeditiontime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600;
    } elseif ($_POST['mission'] == 5) {
        $StayDuration = $_POST['holdingtime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
    } else {
        $StayDuration = 0;
        $StayTime = 0;
    }
    $StorageNeeded = 0;
    $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
    $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
    $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
    if ($_POST['resource1'] < 1) {
        $TransMetal = 0;
    } else {
        $TransMetal = $_POST['resource1'];
        $StorageNeeded += $TransMetal;
    }
    if ($_POST['resource2'] < 1) {
        $TransCrystal = 0;
    } else {
        $TransCrystal = $_POST['resource2'];
        $StorageNeeded += $TransCrystal;
    }
    if ($_POST['resource3'] < 1) {
        $TransDeuterium = 0;
    } else {
        $TransDeuterium = $_POST['resource3'];
        $StorageNeeded += $TransDeuterium;
    }
    $FleetShipCount = 0;
    $FleetStorage = 0;
    $fleet_array = "";
    foreach ($fleetarray as $Ship => $Count) {
        $fleet_array .= $Ship . "," . $Count . ";";
        $FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
        $FleetShipCount += $Count;
        $CurrentPlanet[$resource[$Ship]] = $CurrentPlanet[$resource[$Ship]] - $Count;
    }
    $StockMetal = $CurrentPlanet['metal'];
    $StockCrystal = $CurrentPlanet['crystal'];
    $StockDeuterium = $CurrentPlanet['deuterium'];
    $StockDeuterium -= $consumption;
    $StockOk = false;
    if ($StockMetal >= $TransMetal) {
        if ($StockCrystal >= $TransCrystal) {
            if ($StockDeuterium >= $TransDeuterium) {
                $StockOk = true;
            }
        }
    }
    if (!$StockOk) {
        $displays->message("<font color=\"red\"><b>" . $lang['fl_no_enought_deuterium'] . pretty_number($consumption) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($StorageNeeded > $FleetStorage) {
        $displays->message("<font color=\"red\"><b>" . $lang['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($TargetPlanet['id_level'] > $CurrentUser['authlevel'] && $db->game_config['adm_attack'] == 0) {
        $displays->message($lang['fl_admins_cannot_be_attacked'], "game." . $phpEx . "?page=fleet", 2);
    }
    $fleet['end_time'] = $StayDuration + 2 * $duration + time();
    if ($fleet_group_mr != 0) {
        $AksStartTime = mysql_fetch_array($db->query("SELECT MAX(`fleet_start_time`) AS Start, MAX(`fleet_end_time`) AS End FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "';", 'fleets'));
        if ($AksStartTime['Start'] > $fleet['start_time']) {
            $fleet['start_time'] = $AksStartTime['Start'] + 1;
            $fleet['end_time'] = $AksStartTime['End'] + 1;
        } else {
            $AksTime = mysql_fetch_array($db->query("SELECT fleet_start_time, fleet_end_time FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "' AND `fleet_mission` = '1';", 'fleets'));
            if ($AksTime['fleet_start_time'] < $fleet['start_time']) {
                $QryUpdateFleets = "UPDATE {{table}} SET ";
                $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
                $QryUpdateFleets .= "`fleet_end_time` = '" . $fleet['end_time'] . "' ";
                $QryUpdateFleets .= "WHERE ";
                $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "' AND ";
                $QryUpdateFleets .= "`fleet_mission` = '1';";
                $db->query($QryUpdateFleets, "fleets");
                $SelectFleets = $db->query("SELECT * FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "' AND `fleet_mission` = '2' ORDER BY `fleet_id` ASC ;", 'fleets');
                $nb = mysql_num_rows($SelectFleets);
                $i = 0;
                if ($nb > 0) {
                    while ($row = mysql_fetch_array($SelectFleets)) {
                        $i++;
                        $row['fleet_start_time'] = $fleet['start_time'] + $i;
                        $row['fleet_end_time'] = $fleet['end_time'] + $i;
                        $QryUpdateFleets = "UPDATE {{table}} SET ";
                        $QryUpdateFleets .= "`fleet_start_time` = '" . $row['fleet_start_time'] . "', ";
                        $QryUpdateFleets .= "`fleet_end_time` = '" . $row['fleet_end_time'] . "' ";
                        $QryUpdateFleets .= "WHERE ";
                        $QryUpdateFleets .= "`fleet_id` = '" . $row['fleet_id'] . "';";
                        $db->query($QryUpdateFleets, "fleets");
                    }
                }
                $fleet['start_time'] = $fleet['start_time'] + $nb + 1;
                $fleet['end_time'] = $fleet['end_time'] + $nb + 1;
            }
        }
    }
    $CurrentPlanet["fleet"] = $fleetarray;
    $FleetStorage -= $consumption;
    $CurrentPlanet["metal"] -= $TransMetal;
    $CurrentPlanet["crystal"] -= $TransCrystal;
    $CurrentPlanet["deuterium"] -= $TransDeuterium + $consumption;
    $QryInsertFleet = "INSERT INTO {{table}} SET ";
    $QryInsertFleet .= "`fleet_owner` = '" . $CurrentUser['id'] . "', ";
    $QryInsertFleet .= "`fleet_mission` = '" . $_POST['mission'] . "', ";
    $QryInsertFleet .= "`fleet_amount` = '" . $FleetShipCount . "', ";
    $QryInsertFleet .= "`fleet_array` = '" . $fleet_array . "', ";
    $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
    $QryInsertFleet .= "`fleet_start_galaxy` = '" . intval($_POST['thisgalaxy']) . "', ";
    $QryInsertFleet .= "`fleet_start_system` = '" . intval($_POST['thissystem']) . "', ";
    $QryInsertFleet .= "`fleet_start_planet` = '" . intval($_POST['thisplanet']) . "', ";
    $QryInsertFleet .= "`fleet_start_type` = '" . intval($_POST['thisplanettype']) . "', ";
    $QryInsertFleet .= "`fleet_end_time` = '" . $fleet['end_time'] . "', ";
    $QryInsertFleet .= "`fleet_end_stay` = '" . $StayTime . "', ";
    $QryInsertFleet .= "`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "', ";
    $QryInsertFleet .= "`fleet_end_system` = '" . intval($_POST['system']) . "', ";
    $QryInsertFleet .= "`fleet_end_planet` = '" . intval($_POST['planet']) . "', ";
    $QryInsertFleet .= "`fleet_end_type` = '" . intval($_POST['planettype']) . "', ";
    $QryInsertFleet .= "`fleet_resource_metal` = '" . $TransMetal . "', ";
    $QryInsertFleet .= "`fleet_resource_crystal` = '" . $TransCrystal . "', ";
    $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $TransDeuterium . "', ";
    $QryInsertFleet .= "`fleet_target_owner` = '" . $TargetPlanet['id_owner'] . "', ";
    $QryInsertFleet .= "`fleet_group` = '" . $fleet_group_mr . "', ";
    $QryInsertFleet .= "`start_time` = '" . time() . "';";
    $db->query($QryInsertFleet, 'fleets');
    $parse['mission'] = $missiontype[$_POST['mission']];
    $parse['distance'] = pretty_number($distance);
    $parse['speedallsmin'] = pretty_number($_POST['speedallsmin']);
    $parse['consumption'] = pretty_number($consumption);
    $parse['from'] = $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'];
    $parse['destination'] = $_POST['galaxy'] . ":" . $_POST['system'] . ":" . $_POST['planet'];
    $parse['start_time'] = date("M D d H:i:s", $fleet['start_time']);
    $parse['end_time'] = date("M D d H:i:s", $fleet['end_time']);
    foreach ($fleetarray as $Ship => $Count) {
        $fleet_list .= "</tr><tr height=\"20\">";
        $fleet_list .= "<th>" . $lang['tech'][$Ship] . "</th>";
        $fleet_list .= "<th>" . pretty_number($Count) . "</th>";
    }
    $parse['fleet_list'] = $fleet_list;
    foreach ($parse as $key => $value) {
        $displays->assign($key, $value);
    }
    $displays->display();
}
示例#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');
 }
 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');
 }
示例#15
0
 * @version 1
 * @copyright 2008 By Chlorel for XNova
 */
define('INSIDE', true);
define('INSTALL', false);
$ugamela_root_path = './';
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
includeLang('galaxy');
includeLang('fleet');
// blocking non-users
if ($IsUserChecked == false) {
    includeLang('login');
    message($lang['Login_Ok'], $lang['log_numbreg']);
}
if (IsVacationMode($user)) {
    $ResultMessage = "620;" . $lang['gs_c620'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles;
    die($ResultMessage);
}
// PREVENT DOUBLE CLICKING :/
sleep(1);
$UserSpyProbes = $planetrow['spy_sonde'];
$UserRecycles = $planetrow['recycler'];
$UserDeuterium = $planetrow['deuterium'];
$UserMissiles = $planetrow['interplanetary_misil'];
$fleet = array();
$speedalls = array();
$PartialFleet = false;
// 610
$PartialCount = 0;
foreach ($reslist['fleet'] as $Node => $ShipID) {
    public function show()
    {
        global $USER, $PLANET, $LNG, $reslist, $resource;
        $missileCount = $PLANET['interplanetary_misil'];
        $targetGalaxy = HTTP::_GP('galaxy', 0);
        $targetSystem = HTTP::_GP('system', 0);
        $targetPlanet = HTTP::_GP('planet', 0);
        $targetType = HTTP::_GP('type', 0);
        $anz = min(HTTP::_GP('SendMI', 0), $missileCount);
        $primaryTarget = HTTP::_GP('Target', 0);
        $db = Database::get();
        $sql = "SELECT id, id_owner FROM %%PLANETS%%\n        WHERE universe = :universe AND galaxy = :targetGalaxy\n        AND system = :targetSystem AND planet = :targetPlanet AND planet_type = :targetType;";
        $target = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet, ':targetType' => $targetType));
        $Range = FleetFunctions::GetMissileRange($USER[$resource[117]]);
        $systemMin = $PLANET['system'] - $Range;
        $systemMax = $PLANET['system'] + $Range;
        $error = "";
        if (IsVacationMode($USER)) {
            $error = $LNG['fl_vacation_mode_active'];
        } elseif ($PLANET['silo'] < 4) {
            $error = $LNG['ma_silo_level'];
        } elseif ($USER['impulse_motor_tech'] == 0) {
            $error = $LNG['ma_impulse_drive_required'];
        } elseif ($targetGalaxy != $PLANET['galaxy'] || $targetSystem < $systemMin || $targetSystem > $systemMax) {
            $error = $LNG['ma_not_send_other_galaxy'];
        } elseif (!$target) {
            $error = $LNG['ma_planet_doesnt_exists'];
        } elseif (!in_array($primaryTarget, $reslist['defense']) && $primaryTarget != 0) {
            $error = $LNG['ma_wrong_target'];
        } elseif ($missileCount == 0) {
            $error = $LNG['ma_no_missiles'];
        } elseif ($anz <= 0) {
            $error = $LNG['ma_add_missile_number'];
        }
        $targetUser = GetUserByID($target['id_owner'], array('onlinetime', 'banaday', 'urlaubs_modus', 'authattack'));
        if (Config::get()->adm_attack == 1 && $targetUser['authattack'] > $USER['authlevel']) {
            $error = $LNG['fl_admin_attack'];
        } elseif ($targetUser['urlaubs_modus']) {
            $error = $LNG['fl_in_vacation_player'];
        }
        $sql = "SELECT total_points FROM %%STATPOINTS%% WHERE stat_type = '1' AND id_owner = :ownerId;";
        $User2Points = $db->selectSingle($sql, array(':ownerId' => $target['id_owner']));
        $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, $User2Points, $targetUser);
        if ($IsNoobProtec['NoobPlayer']) {
            $error = $LNG['fl_week_player'];
        } elseif ($IsNoobProtec['StrongPlayer']) {
            $error = $LNG['fl_strong_player'];
        }
        if ($error != "") {
            $this->printMessage($error);
        }
        $Duration = FleetFunctions::GetMIPDuration($PLANET['system'], $targetSystem);
        $DefenseLabel = $primaryTarget == 0 ? $LNG['ma_all'] : $LNG['tech'][$primaryTarget];
        $fleetArray = array(503 => $anz);
        $fleetStartTime = TIMESTAMP + $Duration;
        $fleetStayTime = $fleetStartTime;
        $fleetEndTime = $fleetStartTime;
        $fleetResource = array(901 => 0, 902 => 0, 903 => 0);
        FleetFunctions::sendFleet($fleetArray, 10, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $target['id_owner'], $target['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetResource, $fleetStartTime, $fleetStayTime, $fleetEndTime, 0, $primaryTarget);
        $this->printMessage("<b>" . $anz . "</b>" . $LNG['ma_missiles_sended'] . $DefenseLabel);
    }
示例#17
0
 public static function MissilesAjax()
 {
     global $USER, $PLANET, $LNG, $CONF, $db, $reslist, $resource;
     include_once ROOT_PATH . 'includes/functions/IsVacationMode.' . PHP_EXT;
     $iraks = $PLANET['interplanetary_misil'];
     $TargetGalaxy = request_var('galaxy', 0);
     $TargetSystem = request_var('system', 0);
     $TargetPlanet = request_var('planet', 0);
     $anz = min(request_var('SendMI', 0), $iraks);
     $pziel = request_var('Target', "");
     $PlanetRess = new ResourceUpdate($USER, $PLANET);
     $Target = $db->uniquequery("SELECT `id_owner`, `id_level` FROM " . PLANETS . " WHERE `galaxy` = '" . $TargetGalaxy . "' AND `system` = '" . $TargetSystem . "' AND `planet` = '" . $TargetPlanet . "' AND `planet_type` = '1';");
     $Distance = abs($TargetSystem - $PLANET['system']);
     require_once ROOT_PATH . 'includes/classes/class.GalaxyRows.' . PHP_EXT;
     $GalaxyRows = new GalaxyRows();
     if (IsVacationMode($USER)) {
         $error = $LNG['fl_vacation_mode_active'];
     } elseif ($PLANET['silo'] < 4) {
         $error = $LNG['ma_silo_level'];
     } elseif ($USER['impulse_motor_tech'] == 0) {
         $error = $LNG['ma_impulse_drive_required'];
     } elseif ($TargetGalaxy != $PLANET['galaxy'] || $Distance > $GalaxyRows->GetMissileRange($USER[$resource[117]])) {
         $error = $LNG['ma_not_send_other_galaxy'];
     } elseif (!$Target) {
         $error = $LNG['ma_planet_doesnt_exists'];
     } elseif (!in_array($pziel, $reslist['defense']) && $pziel != 0) {
         $error = $LNG['ma_wrong_target'];
     } elseif ($iraks == 0) {
         $error = $LNG['ma_no_missiles'];
     } elseif ($anz == 0) {
         $error = $LNG['ma_add_missile_number'];
     } elseif ($Target['id_level'] > $USER['authlevel'] && $CONF['adm_attack'] == 0) {
         $error = $LNG['fl_admins_cannot_be_attacked'];
     }
     $TargetUser = GetUserByID($Target['id_owner'], array('onlinetime'));
     $UserPoints = $USER;
     $User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $Target['id_owner'] . "';");
     $IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $TargetUser['onlinetime']);
     if ($IsNoobProtec['NoobPlayer']) {
         $error = $LNG['fl_week_player'];
     } elseif ($IsNoobProtec['StrongPlayer']) {
         $error = $LNG['fl_strong_player'];
     }
     $template = new template();
     $template->page_header();
     $template->page_topnav();
     $template->page_leftmenu();
     $template->page_planetmenu();
     $template->page_footer();
     if ($error != "") {
         $template->message($error);
         exit;
     }
     $SpeedFactor = parent::GetGameSpeedFactor();
     $Duration = max(round(30 + 60 * $Distance / $SpeedFactor), 30);
     $DefenseLabel = $pziel == 0 ? $LNG['ma_all'] : $LNG['tech'][$pziel];
     if (connection_aborted()) {
         exit;
     }
     $sql = "INSERT INTO " . FLEETS . " SET\r\n\t\t\t\tfleet_owner = '" . $USER['id'] . "',\r\n\t\t\t\tfleet_mission = '10',\r\n\t\t\t\tfleet_amount = '" . $anz . "',\r\n\t\t\t\tfleet_array = '503," . $anz . "',\r\n\t\t\t\tfleet_start_time = '" . (TIMESTAMP + $Duration) . "',\r\n\t\t\t\tfleet_start_galaxy = '" . $PLANET['galaxy'] . "',\r\n\t\t\t\tfleet_start_system = '" . $PLANET['system'] . "',\r\n\t\t\t\tfleet_start_planet ='" . $PLANET['planet'] . "',\r\n\t\t\t\tfleet_start_type = '1',\r\n\t\t\t\tfleet_end_time = '" . (TIMESTAMP + $Duration + 50) . "',\r\n\t\t\t\tfleet_end_stay = '0',\r\n\t\t\t\tfleet_end_galaxy = '" . $TargetGalaxy . "',\r\n\t\t\t\tfleet_end_system = '" . $TargetSystem . "',\r\n\t\t\t\tfleet_end_planet = '" . $TargetPlanet . "',\r\n\t\t\t\tfleet_end_type = '1',\r\n\t\t\t\tfleet_target_obj = '" . $db->sql_escape($pziel) . "',\r\n\t\t\t\tfleet_resource_metal = '0',\r\n\t\t\t\tfleet_resource_crystal = '0',\r\n\t\t\t\tfleet_resource_deuterium = '0',\r\n\t\t\t\tfleet_target_owner = '" . $Target["id_owner"] . "',\r\n\t\t\t\tfleet_group = '0',\r\n\t\t\t\tfleet_mess = '0',\r\n\t\t\t\tstart_time = " . TIMESTAMP . ";\r\n\t\t\t\tUPDATE " . PLANETS . " SET \r\n\t\t\t\tinterplanetary_misil = (interplanetary_misil - " . $anz . ") WHERE id = '" . $PLANET['id'] . "';";
     $db->multi_query($sql);
     $template->message("<b>" . $anz . "</b>" . $LNG['ma_missiles_sended'] . $DefenseLabel, "game.php?page=overview", 3);
 }
示例#18
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);
 }