function show() { global $USER, $PLANET, $LNG, $UNI; $PlayerID = HTTP::_GP('id', 1); $query = $GLOBALS['DATABASE']->getFirstRow("SELECT \n\t\t\t\t\t\tu.user_deleted, u.immunity_until, u.onlinetime, u.banaday, u.urlaubs_modus, u.multi_spotted, u.username, u.galaxy, u.system, u.sexe, u.planet, u.date_of_birth, u.register_time, u.avatar, u.wons, u.loos, u.draws, u.kbmetal, u.kbcrystal, u.lostunits, u.desunits, u.ally_id, \n\t\t\t\t\t\tp.name, \n\t\t\t\t\t\ts.tech_rank, s.tech_points, s.popu_rank, s.popu_points, s.build_rank, s.build_points, s.defs_rank, s.defs_points, s.fleet_rank, s.fleet_points, s.total_rank, s.total_points, \n\t\t\t\t\t\ta.ally_name, a.ally_tag \n\t\t\t\t\t\tFROM " . USERS . " u \n\t\t\t\t\t\tINNER JOIN " . PLANETS . " p ON p.id = u.id_planet \n\t\t\t\t\t\tLEFT JOIN " . STATPOINTS . " s ON s.id_owner = u.id AND s.stat_type = 1 \n\t\t\t\t\t\tLEFT JOIN " . ALLIANCE . " a ON a.id = u.ally_id\n\t\t\t\t\t\tWHERE u.id = " . $PlayerID . " AND u.universe = " . $UNI . ";"); $totalfights = $query['wons'] + $query['loos'] + $query['draws']; if ($totalfights == 0) { $siegprozent = 0; $loosprozent = 0; $drawsprozent = 0; } else { $siegprozent = 100 / $totalfights * $query['wons']; $loosprozent = 100 / $totalfights * $query['loos']; $drawsprozent = 100 / $totalfights * $query['draws']; } $IsNoobProtec = CheckNoobProtec($USER, $query, $query); $Class = array(); if ($query['user_deleted'] == 1) { $Class = array('supprimer_serveur'); } elseif ($query['banaday'] > TIMESTAMP && $query['urlaubs_modus'] == 1) { $Class = array('banni_serveur', 'violet'); } elseif ($query['banaday'] > TIMESTAMP) { $Class = array('banni_serveur'); } elseif ($query['multi_spotted'] == 1) { $Class = array('bleu'); } elseif ($query['urlaubs_modus'] == 1) { $Class = array('violet'); } elseif ($query['immunity_until'] > TIMESTAMP) { $Class = array('jaune'); } elseif ($IsNoobProtec['NoobPlayer']) { $Class = array('vert'); } elseif ($IsNoobProtec['StrongPlayer']) { $Class = array('rouge'); } $this->tplObj->assign_vars(array('class' => $Class, 'id' => $PlayerID, 'yourid' => $USER['id'], 'name' => $query['username'], 'avatar' => $query['avatar'], 'homeplanet' => $query['name'], 'galaxy' => $query['galaxy'], 'system' => $query['system'], 'sexe' => $query['sexe'], 'planet' => $query['planet'], 'allyid' => $query['ally_id'], 'date_of_birth' => $query['date_of_birth'], 'tech_rank' => pretty_number($query['tech_rank']), 'tech_points' => pretty_number($query['tech_points']), 'pop_rank' => pretty_number($query['popu_rank']), 'pop_points' => pretty_number($query['popu_points']), 'build_rank' => pretty_number($query['build_rank']), 'build_points' => pretty_number($query['build_points']), 'defs_rank' => pretty_number($query['defs_rank']), 'defs_points' => pretty_number($query['defs_points']), 'fleet_rank' => pretty_number($query['fleet_rank']), 'fleet_points' => pretty_number($query['fleet_points']), 'total_rank' => pretty_number($query['total_rank']), 'total_points' => pretty_number($query['total_points']), 'allyname' => $query['ally_name'], 'allytag' => $query['ally_tag'], 'ddates' => date('m.d.y', $query['register_time']), 'playerdestory' => sprintf($LNG['pl_destroy'], $query['username']), 'wons' => pretty_number($query['wons']), 'loos' => pretty_number($query['loos']), 'draws' => pretty_number($query['draws']), 'kbmetal' => pretty_number($query['kbmetal']), 'kbcrystal' => pretty_number($query['kbcrystal']), 'lostunits' => pretty_number($query['lostunits']), 'desunits' => pretty_number($query['desunits']), 'totalfights' => pretty_number($totalfights), 'siegprozent' => round($siegprozent, 2), 'loosprozent' => round($loosprozent, 2), 'drawsprozent' => round($drawsprozent, 2))); $this->display('page.playerCard.default.tpl'); }
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); }
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'] . " ..."); }
/** FLEET FUNCTIONS **/ function SendFleet($FleetData) { $FleetData = array_merge(array('mission' => 3, 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'planettype' => 0, 'fleetgroup' => 0, 'speed' => 10, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0, 'holdingtime' => 0, 'fleet' => array()), $FleetData); $mission = $FleetData['mission']; $galaxy = $FleetData['galaxy']; $system = $FleetData['system']; $planet = $FleetData['planet']; $planettype = $FleetData['planettype']; $fleet_group = $FleetData['fleetgroup']; $GenFleetSpeed = $FleetData['speed']; $TransportMetal = $FleetData['metal']; $TransportCrystal = $FleetData['crystal']; $TransportDeuterium = $FleetData['deuterium']; $holdingtime = $FleetData['holdingtime']; $rawfleetarray = $FleetData['fleet']; if ($planettype != 1 && $planettype != 3) { return false; } if ($this->PLANET['galaxy'] == $galaxy && $this->PLANET['system'] == $system && $this->PLANET['planet'] == $planet && $this->PLANET['planet_type'] == $planettype) { return false; } if ($galaxy > $CONF['max_galaxy'] || $galaxy < 1 || $system > $CONF['max_system'] || $system < 1 || $planet > $CONF['max_planets'] + 1 || $planet < 1) { return false; } if (empty($mission)) { return false; } $ActualFleets = parent::GetCurrentFleets($USER['id']); if (parent::GetMaxFleetSlots($USER) <= $ActualFleets) { return false; } $fleet_group_mr = 0; if (!empty($fleet_group) && $mission == 2) { $aks_count_mr = $db->uniquequery("SELECT COUNT(*) as state FROM " . AKS . " WHERE `id` = '" . $fleet_group . "' AND `eingeladen` LIKE '%" . $USER['id'] . "%';"); if ($aks_count_mr['state'] > 0) { $fleet_group_mr = $fleet_group; } else { $mission = 1; } } $ActualFleets = parent::GetCurrentFleets($USER['id']); $TargetPlanet = $db->uniquequery("SELECT `id`, `id_owner`,`destruyed`,`ally_deposit` FROM " . PLANETS . " WHERE `universe` = '" . $UNI . "' AND `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '" . ($planettype == 2 ? 1 : $planettype) . "';"); if ($mission != 15 && $TargetPlanet["destruyed"] != 0 || $mission != 15 && $mission != 7 && empty($TargetPlanet['id_owner'])) { return false; } $MyDBRec = $USER; $FleetArray = parent::GetFleetArray($rawfleetarray); if (!is_array($FleetArray)) { return false; } $FleetStorage = 0; $FleetShipCount = 0; $fleet_array = ""; $FleetSubQRY = ""; foreach ($FleetArray as $Ship => $Count) { if ($Count > $this->PLANET[$resource[$Ship]] || $Count < 0) { return false; } $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; $FleetShipCount += $Count; $fleet_array .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - '" . floattostring($Count) . "', "; } $error = 0; $fleetmission = $mission; $YourPlanet = false; $UsedPlanet = false; if ($mission == 11) { $maxexpde = parent::GetCurrentFleets($USER['id'], 11); if ($maxexpde >= $CONF['max_dm_missions']) { return false; } } elseif ($mission == 15) { $MaxExpedition = $USER[$resource[124]]; if ($MaxExpedition == 0) { return false; } $ExpeditionEnCours = parent::GetCurrentFleets($USER['id'], 15); $EnvoiMaxExpedition = floor(sqrt($MaxExpedition)); if ($ExpeditionEnCours >= $EnvoiMaxExpedition) { return false; } } $YourPlanet = isset($TargetPlanet['id_owner']) && $TargetPlanet['id_owner'] == $USER['id'] ? true : false; $UsedPlanet = isset($TargetPlanet['id_owner']) ? true : false; $HeDBRec = $YourPlanet ? $MyDBRec : GetUserByID($TargetPlanet['id_owner'], array('id', 'onlinetime', 'ally_id', 'urlaubs_modus', 'banaday', 'authattack')); if ($HeDBRec['urlaubs_modus'] && $mission != 8) { return false; } if (!$YourPlanet && ($mission == 1 || $mission == 2 || $mission == 5 || $mission == 6 || $mission == 9)) { if ($CONF['adm_attack'] == 1 && $UsedPlanet['authattack'] > $USER['authlevel']) { return false; } $UserPoints = $USER; $User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';"); $IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $HeDBRec); if ($IsNoobProtec['NoobPlayer']) { return false; } elseif ($IsNoobProtec['StrongPlayer']) { return false; } } if ($mission == 5) { if ($TargetPlanet['ally_deposit'] < 1) { return false; } $buddy = $db->uniquequery("SELECT COUNT(*) as state FROM " . BUDDY . " WHERE `active` = '1' AND (`owner` = '" . $HeDBRec['id'] . "' AND `sender` = '" . $MyDBRec['id'] . "') OR (`owner` = '" . $MyDBRec['id'] . "' AND `sender` = '" . $HeDBRec['id'] . "');"); if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $buddy['state'] == 0) { return false; } } if (!parent::CheckUserSpeed($GenFleetSpeed) || !array_key_exists($mission, parent::GetAvailableMissions(array('CurrentUser' => $USER, 'galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'planettype' => $planettype, 'IsAKS' => $fleet_group, 'Ship' => $FleetArray)))) { return false; } $MaxFleetSpeed = parent::GetFleetMaxSpeed($FleetArray, $USER); $SpeedFactor = parent::GetGameSpeedFactor(); $distance = parent::GetTargetDistance($this->PLANET['galaxy'], $galaxy, $this->PLANET['system'], $system, $this->PLANET['planet'], $planet); $duration = parent::GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor, $USER); $consumption = parent::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $SpeedFactor); $fleet['start_time'] = $duration + TIMESTAMP; if ($mission == 15) { $StayDuration = max($holdingtime, 1) * 3600 / $CONF['halt_speed']; $StayTime = $fleet['start_time'] + $StayDuration; } elseif ($mission == 5) { $StayDuration = $holdingtime * 3600; $StayTime = $fleet['start_time'] + $StayDuration; } elseif ($mission == 11) { $StayDuration = 3600 / $CONF['halt_speed']; $StayTime = $fleet['start_time'] + $StayDuration; } else { $StayDuration = 0; $StayTime = 0; } $fleet['end_time'] = $StayDuration + 2 * $duration + TIMESTAMP; $FleetStorage -= $consumption; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $TransportMetal = min($TransportMetal, $this->PLANET['metal']); $TransportCrystal = min($TransportCrystal, $this->PLANET['crystal']); $TransportDeuterium = min($TransportDeuterium, $this->PLANET['deuterium'] - $consumption); $StorageNeeded = $TransportMetal + $TransportCrystal + $TransportDeuterium; $StockMetal = $this->PLANET['metal']; $StockCrystal = $this->PLANET['crystal']; $StockDeuterium = $this->PLANET['deuterium']; $StockDeuterium -= $consumption; if ($this->PLANET['deuterium'] < $consumption) { return false; } if ($StorageNeeded > $FleetStorage) { return false; } $this->PLANET['metal'] -= $TransportMetal; $this->PLANET['crystal'] -= $TransportCrystal; $this->PLANET['deuterium'] -= $TransportDeuterium + $consumption; if ($fleet_group_mr != 0) { $AksStartTime = $db->uniquequery("SELECT MAX(`fleet_start_time`) AS Start FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "' AND '" . $CONF['max_fleets_per_acs'] . "' > (SELECT COUNT(*) FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "');"); if (isset($AksStartTime)) { if ($AksStartTime['Start'] >= $fleet['start_time']) { $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time']; $fleet['start_time'] = $AksStartTime['Start']; } else { $SQLFleets = "UPDATE " . FLEETS . " SET "; $SQLFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $SQLFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' "; $SQLFleets .= "WHERE "; $SQLFleets .= "`fleet_group` = '" . $fleet_group_mr . "';"; $db->query($SQLFleets); $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start']; } } else { $mission = 1; } } $QryInsertFleet = "LOCK TABLE " . FLEETS . " WRITE, " . PLANETS . " WRITE;\n\t\t\t\t\t\t\tINSERT INTO " . FLEETS . " SET \n\t\t\t\t\t\t\t`fleet_owner` = '" . $USER['id'] . "', \n\t\t\t\t\t\t\t`fleet_mission` = '" . $mission . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\n\t\t\t\t\t\t `fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t `fleet_universe` = '" . $UNI . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_id` = '" . $this->PLANET['id'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $this->PLANET['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . $this->PLANET['system'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . $this->PLANET['planet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . $this->PLANET['planet_type'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_id` = '" . (int) $TargetPlanet['id'] . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . $galaxy . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . $system . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . $planet . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . $planettype . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . floattostring($TransportMetal) . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . floattostring($TransportCrystal) . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . floattostring($TransportDeuterium) . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . ($planettype == 2 ? 0 : (int) $TargetPlanet['id_owner']) . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . $fleet_group_mr . "',\n\t\t\t\t\t\t\t`start_time` = '" . TIMESTAMP . "';\n\t\t\t\t\t\t\tUPDATE `" . PLANETS . "` SET\n\t\t\t\t\t\t\t" . substr($FleetSubQRY, 0, -2) . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`id` = " . $this->PLANET['id'] . " LIMIT 1;\n\t\t\t\t\t\t\tUNLOCK TABLES;"; $db->multi_query($QryInsertFleet); return true; }
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, $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); }
protected function getPlayerData() { global $USER, $LNG; $IsNoobProtec = CheckNoobProtec($USER, $this->galaxyRow, $this->galaxyRow); $Class = array(); if ($this->galaxyRow['banaday'] > TIMESTAMP && $this->galaxyRow['urlaubs_modus'] == 1) { $Class = array('vacation', 'banned'); } elseif ($this->galaxyRow['banaday'] > TIMESTAMP) { $Class = array('banned'); } elseif ($this->galaxyRow['urlaubs_modus'] == 1) { $Class = array('vacation'); } elseif ($this->galaxyRow['onlinetime'] < TIMESTAMP - INACTIVE_LONG) { $Class = array('inactive', 'longinactive'); } elseif ($this->galaxyRow['onlinetime'] < TIMESTAMP - INACTIVE) { $Class = array('inactive'); } elseif ($IsNoobProtec['NoobPlayer']) { $Class = array('noob'); } elseif ($IsNoobProtec['StrongPlayer']) { $Class = array('strong'); } $this->galaxyData[$this->galaxyRow['planet']]['user'] = array('id' => $this->galaxyRow['userid'], 'username' => htmlspecialchars($this->galaxyRow['username'], ENT_QUOTES, "UTF-8"), 'rank' => $this->galaxyRow['total_rank'], 'points' => pretty_number($this->galaxyRow['total_points']), 'playerrank' => isModuleAvailable(25) ? sprintf($LNG['gl_in_the_rank'], htmlspecialchars($this->galaxyRow['username'], ENT_QUOTES, "UTF-8"), $this->galaxyRow['total_rank']) : htmlspecialchars($this->galaxyRow['username'], ENT_QUOTES, "UTF-8"), 'class' => $Class, 'isBuddy' => $this->galaxyRow['buddy'] == 0); }
public function GalaxyRowUser($GalaxyRowPlanet) { global $CONF, $USER, $LNG, $db; $protection = $CONF['noobprotection']; $protectiontime = $CONF['noobprotectiontime']; $protectionmulti = $CONF['noobprotectionmulti']; $CurrentPoints = $USER['total_points']; $RowUserPoints = $GalaxyRowPlanet['total_points']; $IsNoobProtec = CheckNoobProtec($USER, $GalaxyRowPlanet, $GalaxyRowPlanet); if ($GalaxyRowPlanet['banaday'] > TIMESTAMP && $GalaxyRowPlanet['urlaubs_modus'] == 1) { $Systemtatus2 = $LNG['gl_v'] . " <a href=\"game.php?page=banned\"><span class=\"banned\">" . $LNG['gl_b'] . "</span></a>"; $Systemtatus = "<span class=\"vacation\">"; } elseif ($GalaxyRowPlanet['banaday'] > TIMESTAMP) { $Systemtatus2 = "<span class=\"banned\">" . $LNG['gl_b'] . "</span>"; $Systemtatus = ""; } elseif ($GalaxyRowPlanet['urlaubs_modus'] == 1) { $Systemtatus2 = "<span class=\"vacation\">" . $LNG['gl_v'] . "</span>"; $Systemtatus = "<span class=\"vacation\">"; } elseif ($GalaxyRowPlanet['onlinetime'] < TIMESTAMP - 60 * 60 * 24 * 7 && $GalaxyRowPlanet['onlinetime'] > TIMESTAMP - 60 * 60 * 24 * 28) { $Systemtatus2 = "<span class=\"inactive\">" . $LNG['gl_i'] . "</span>"; $Systemtatus = "<span class=\"inactive\">"; } elseif ($GalaxyRowPlanet['onlinetime'] < TIMESTAMP - 60 * 60 * 24 * 28) { $Systemtatus2 = "<span class=\"inactive\">" . $LNG['gl_i'] . "</span><span class=\"longinactive\">" . $LNG['gl_I'] . "</span>"; $Systemtatus = "<span class=\"longinactive\">"; } elseif ($IsNoobProtec['NoobPlayer']) { $Systemtatus2 = "<span class=\"noob\">" . $LNG['gl_w'] . "</span>"; $Systemtatus = "<span class=\"noob\">"; } elseif ($IsNoobProtec['StrongPlayer']) { $Systemtatus2 = $LNG['gl_s']; $Systemtatus = "<span class=\"strong\">"; } else { $Systemtatus2 = ""; $Systemtatus = ""; } if (!empty($Systemtatus2)) { $Systemtatus2 = "<span style=\"color:white\">(</span>" . $Systemtatus2 . "<span style=\"color:white\">)</span>"; } $Result = array('id' => $GalaxyRowPlanet['userid'], 'username' => htmlspecialchars($GalaxyRowPlanet['username'], ENT_QUOTES, "UTF-8"), 'rank' => $GalaxyRowPlanet['total_rank'], 'points' => pretty_number($GalaxyRowPlanet['total_points']), 'playerrank' => sprintf($LNG['gl_in_the_rank'], htmlspecialchars($GalaxyRowPlanet['username'], ENT_QUOTES, "UTF-8"), $GalaxyRowPlanet['total_rank']), 'Systemtatus' => $Systemtatus, 'Systemtatus2' => $Systemtatus2, 'isown' => $GalaxyRowPlanet['userid'] != $USER['id'] ? true : false); return $Result; }
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); }
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); }
function show() { global $USER, $CONF, $LNG, $UNI; $who = HTTP::_GP('who', 1); $type = HTTP::_GP('type', 1); $range = HTTP::_GP('range', 1); $CurrentUserPoints = $GLOBALS['DATABASE']->uniquequery("SELECT *FROM " . STATPOINTS . " where `id_owner` = " . $USER['id'] . " and `stat_type` = '1';"); switch ($type) { case 2: $Order = "fleet_rank"; $Points = "fleet_points"; $Rank = "fleet_rank"; $OldRank = "fleet_old_rank"; break; case 3: $Order = "tech_rank"; $Points = "tech_points"; $Rank = "tech_rank"; $OldRank = "tech_old_rank"; break; case 4: $Order = "build_rank"; $Points = "build_points"; $Rank = "build_rank"; $OldRank = "build_old_rank"; break; case 5: $Order = "defs_rank"; $Points = "defs_points"; $Rank = "defs_rank"; $OldRank = "defs_old_rank"; break; case 6: $Order = "ach_rank"; $Points = "ach_points"; $Rank = "ach_rank"; $OldRank = "ach_old_rank"; break; default: $Order = "total_rank"; $Points = "total_points"; $Rank = "total_rank"; $OldRank = "total_old_rank"; break; } $RangeList = array(); switch ($who) { case 1: $MaxUsers = Config::get('users_amount'); $range = min($range, $MaxUsers); $LastPage = max(1, ceil($MaxUsers / 100)); for ($Page = 0; $Page < $LastPage; $Page++) { $PageValue = $Page * 100 + 1; $PageRange = $PageValue + 99; $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange; } $start = max(floor(($range - 1) / 100) * 100, 0); $stats_sql = 'SELECT DISTINCT s.*, u.id, u.race, u.username,u.urlaubs_modus, u.ally_id,u.bana,u.banaday,u.onlinetime,a.fraction,a.FraLevel, a.ally_name FROM ' . STATPOINTS . ' as s INNER JOIN ' . USERS . ' as u ON u.id = s.id_owner LEFT JOIN ' . ALLIANCE . ' as a ON a.id = s.id_ally WHERE s.`universe` = ' . $UNI . ' AND s.`stat_type` = 1 ' . (Config::get('stat') == 2 ? 'AND u.`authlevel` < ' . Config::get('stat_level') . ' ' : '') . ' ORDER BY `' . $Order . '` ASC LIMIT ' . $start . ',100;'; $query = $GLOBALS['DATABASE']->query($stats_sql); $RangeList = array(); $fraction = $GLOBALS['DATABASE']->getFirstCell("SELECT fraction FROM " . ALLIANCE . " WHERE id = " . $USER['ally_id'] . ";"); $fra1 = '<img src="styles/images/alliance/fraction_' . $fraction . '.png" alt="1" width="19" height="18">'; while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query)) { $isFriend = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . BUDDY . " WHERE (sender = " . $USER['id'] . " AND owner = " . $StatRow['id'] . " ) OR (sender = " . $StatRow['id'] . " AND owner = " . $USER['id'] . ");"); $isEnnemie = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM uni1_ennemies WHERE sender = " . $USER['id'] . " AND owner = " . $StatRow['id'] . ";"); $Noob = CheckNoobProtec($CurrentUserPoints, $StatRow, $StatRow); if (empty($Noob['NoobPlayer']) && empty($Noob['StrongPlayer'])) { $isNoob = 0; } else { if ($Noob['NoobPlayer']) { $isNoob = 1; } elseif ($Noob['StrongPlayer']) { $isNoob = 2; } } $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['username'], 'race' => $StatRow['race'], 'points' => pretty_number($StatRow[$Points]), 'fraction2' => $fraction, 'allyid' => $StatRow['ally_id'], 'level' => $StatRow['FraLevel'], 'fraction' => $StatRow['fraction'] ? $fra1 : '', 'rank' => $StatRow[$Rank], 'allyname' => $StatRow['ally_name'], 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank], 'isFriend' => $isFriend, 'isEnnemie' => $isEnnemie, 'isnoob' => $isNoob, 'isVac' => $StatRow['urlaubs_modus'] == 1 ? 0 : 1, 'isInac' => $StatRow['onlinetime'] < TIMESTAMP - 7 * 24 * 60 * 60 ? 0 : 1); } $GLOBALS['DATABASE']->free_result($query); break; case 2: $MaxAllys = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . ALLIANCE . " WHERE `ally_universe` = '" . $UNI . "';"); $range = min($range, $MaxAllys); $LastPage = max(1, ceil($MaxAllys / 100)); for ($Page = 0; $Page < $LastPage; $Page++) { $PageValue = $Page * 100 + 1; $PageRange = $PageValue + 99; $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange; } $start = max(floor(($range - 1) / 100) * 100, 0); $stats_sql = 'SELECT DISTINCT s.*, a.id, a.ally_members, a.ally_name FROM ' . STATPOINTS . ' as s INNER JOIN ' . ALLIANCE . ' as a ON a.id = s.id_owner WHERE `universe` = ' . $UNI . ' AND `stat_type` = 2 ORDER BY `' . $Order . '` ASC LIMIT ' . $start . ',100;'; $query = $GLOBALS['DATABASE']->query($stats_sql); while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query)) { $isWar = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . DIPLO . " WHERE (owner_1 = " . $USER['ally_id'] . " AND owner_2 = " . $StatRow['id'] . ") OR (owner_1 = " . $StatRow['id'] . " AND owner_2 = " . $USER['ally_id'] . ") AND accept = '1' AND level = '5';"); $isUnion = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . DIPLO . " WHERE (owner_1 = " . $USER['ally_id'] . " AND owner_2 = " . $StatRow['id'] . ") OR (owner_1 = " . $StatRow['id'] . " AND owner_2 = " . $USER['ally_id'] . ") AND accept = '1' AND level = '2';"); $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['ally_name'], 'members' => $StatRow['ally_members'], 'rank' => $StatRow[$Rank], 'mppoints' => pretty_number(floor($StatRow[$Points] / $StatRow['ally_members'])), 'points' => pretty_number($StatRow[$Points]), 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank], 'isWar' => $isWar, 'isUnion' => $isUnion); } $GLOBALS['DATABASE']->free_result($query); break; } $Selector['who'] = array(1 => $LNG['st_player'], 2 => $LNG['st_alliance']); $Selector['type'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh'], 4 => $LNG['st_buildings'], 5 => $LNG['st_defenses'], 6 => 'Achievements'); $statkai = $GLOBALS['DATABASE']->uniquequery("SELECT nextTime FROM " . CRONJOBS . " WHERE cronjobID = 2;"); $this->tplObj->loadscript("jquery.countdown.js"); $this->tplObj->assign_vars(array('Selectors' => $Selector, 'who' => $who, 'type' => $type, 'range' => floor(($range - 1) / 100) * 100 + 1, 'RangeList' => $RangeList, 'CUser_ally' => $USER['ally_id'], 'CUser_id' => $USER['id'], 'stat_date' => _date($LNG['php_tdformat'], Config::get('stat_last_update'), $USER['timezone']), 'st_out' => $statkai['nextTime'] - TIMESTAMP)); $this->display('page.statistics.default.tpl'); }
protected function getPlayerData() { global $USER, $LNG; $IsNoobProtec = CheckNoobProtec($USER, $this->galaxyRow, $this->galaxyRow); $Class = array(); if ($this->galaxyRow['user_deleted'] == 1) { $Class = array('supprimer_serveur'); } elseif ($this->galaxyRow['banaday'] > TIMESTAMP && $this->galaxyRow['urlaubs_modus'] == 1) { $Class = array('banni_serveur', 'violet'); } elseif ($this->galaxyRow['banaday'] > TIMESTAMP) { $Class = array('banni_serveur'); } elseif ($this->galaxyRow['multi_spotted'] == 1) { $Class = array('bleu'); } elseif ($this->galaxyRow['urlaubs_modus'] == 1) { $Class = array('violet'); } elseif ($this->galaxyRow['immunity_until'] > TIMESTAMP) { $Class = array('jaune'); } elseif ($IsNoobProtec['NoobPlayer']) { $Class = array('vert'); } elseif ($IsNoobProtec['StrongPlayer']) { $Class = array('rouge'); } $this->galaxyData[$this->galaxyRow['planet']]['user'] = array('id' => $this->galaxyRow['userid'], 'planetshow' => $this->galaxyRow['planet'], 'username' => htmlspecialchars($this->galaxyRow['username'], ENT_QUOTES, "UTF-8"), 'rank' => $this->galaxyRow['total_rank'], 'points' => pretty_number($this->galaxyRow['total_points']), 'playerrank' => isModulAvalible(25) ? sprintf($LNG['gl_in_the_rank'], htmlspecialchars($this->galaxyRow['username'], ENT_QUOTES, "UTF-8"), $this->galaxyRow['total_rank']) : htmlspecialchars($this->galaxyRow['username'], ENT_QUOTES, "UTF-8"), 'class' => $Class, 'isBuddy' => $this->galaxyRow['buddy'] == 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); 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); }
function show() { global $USER, $CONF, $LNG, $UNI; $who = HTTP::_GP('who', 1); $type = HTTP::_GP('type', 1); $range = HTTP::_GP('range', 1); switch ($type) { case 2: $Order = "fleet_rank"; $Points = "fleet_points"; $Rank = "fleet_rank"; $OldRank = "fleet_old_rank"; break; case 3: $Order = "tech_rank"; $Points = "tech_points"; $Rank = "tech_rank"; $OldRank = "tech_old_rank"; break; case 4: $Order = "build_rank"; $Points = "build_points"; $Rank = "build_rank"; $OldRank = "build_old_rank"; break; case 5: $Order = "defs_rank"; $Points = "defs_points"; $Rank = "defs_rank"; $OldRank = "defs_old_rank"; break; case 6: $Order = "popu_rank"; $Points = "popu_points"; $Rank = "popu_rank"; $OldRank = "popu_old_rank"; break; default: $Order = "total_rank"; $Points = "total_points"; $Rank = "total_rank"; $OldRank = "total_old_rank"; break; } $RangeList = array(); switch ($who) { case 1: $MaxUsers = Config::get('users_amount'); $range = min($range, $MaxUsers); $LastPage = max(1, ceil($MaxUsers / 100)); for ($Page = 0; $Page < $LastPage; $Page++) { $PageValue = $Page * 100 + 1; $PageRange = $PageValue + 99; $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange; } $start = max(floor(($range - 1) / 100) * 100, 0); $stats_sql = 'SELECT DISTINCT s.*, h.*, u.id, u.onlinetime, u.username, u.user_deleted, u.immunity_until, u.banaday, u.urlaubs_modus, u.multi_spotted, u.avatar, p.name, u.id_planet, u.galaxy, u.system, u.planet, u.ally_id, a.ally_tag, a.ally_name FROM ' . STATPOINTS . ' as s INNER JOIN ' . USERS . ' as u ON u.id = s.id_owner INNER JOIN ' . STATHISTORY . ' as h ON h.id_owner = u.id AND h.universe = ' . $UNI . ' LEFT JOIN ' . ALLIANCE . ' as a ON a.id = s.id_ally LEFT JOIN ' . PLANETS . ' as p ON p.id = u.id_planet WHERE s.`universe` = ' . $UNI . ' AND s.`stat_type` = 1 ' . (Config::get('stat') == 2 ? 'AND u.`authlevel` < ' . Config::get('stat_level') . ' ' : '') . ' ORDER BY `' . $Order . '` ASC LIMIT ' . $start . ',100;'; $query = $GLOBALS['DATABASE']->query($stats_sql); $RangeList = array(); while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query)) { $IsNoobProtec = CheckNoobProtec($USER, $StatRow, $StatRow); $Class = array(); if ($StatRow['user_deleted'] == 1) { $Class = array('supprimer_serveur'); } elseif ($StatRow['banaday'] > TIMESTAMP && $StatRow['urlaubs_modus'] == 1) { $Class = array('banni_serveur', 'violet'); } elseif ($StatRow['banaday'] > TIMESTAMP) { $Class = array('banni_serveur'); } elseif ($StatRow['multi_spotted'] == 1) { $Class = array('bleu'); } elseif ($StatRow['urlaubs_modus'] == 1) { $Class = array('violet'); } elseif ($StatRow['immunity_until'] > TIMESTAMP) { $Class = array('jaune'); } elseif ($IsNoobProtec['NoobPlayer']) { $Class = array('vert'); } elseif ($IsNoobProtec['StrongPlayer']) { $Class = array('rouge'); } $RangeList[] = array('class' => $Class, 'id' => $StatRow['id'], 'name' => $StatRow['username'], 'points' => pretty_number($StatRow[$Points]), 'allyid' => $StatRow['ally_id'], 'avatar' => $StatRow['avatar'], 'rank' => $StatRow[$Rank], 'allyname' => $StatRow['ally_name'], 'galaxy' => $StatRow['galaxy'], 'system' => $StatRow['system'], 'planet' => $StatRow['planet'], 'planetname' => $StatRow['name'], 'allytag' => $StatRow['ally_tag'], 'ranking' => $StatRow['history_total_rank'] - $StatRow[$Rank]); } $GLOBALS['DATABASE']->free_result($query); break; case 2: $MaxAllys = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . ALLIANCE . " WHERE `ally_universe` = '" . $UNI . "';"); $range = min($range, $MaxAllys); $LastPage = max(1, ceil($MaxAllys / 100)); for ($Page = 0; $Page < $LastPage; $Page++) { $PageValue = $Page * 100 + 1; $PageRange = $PageValue + 99; $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange; } $start = max(floor(($range - 1) / 100) * 100, 0); $stats_sql = 'SELECT DISTINCT s.*, a.ally_request_notallow, a.ally_owner, a.ally_tag, a.id, a.ally_members, a.ally_name FROM ' . STATPOINTS . ' as s INNER JOIN ' . ALLIANCE . ' as a ON a.id = s.id_owner WHERE `universe` = ' . $UNI . ' AND `stat_type` = 2 ORDER BY `' . $Order . '` ASC LIMIT ' . $start . ',100;'; $query = $GLOBALS['DATABASE']->query($stats_sql); while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query)) { $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['ally_name'], 'ally_request_notallow' => $StatRow['ally_request_notallow'], 'tag' => $StatRow['ally_tag'], 'members' => $StatRow['ally_members'], 'ally_owner' => $StatRow['ally_owner'], 'rank' => $StatRow[$Rank], 'usernale' => $this->getUsername($StatRow['ally_owner']), 'mppoints' => pretty_number(floor($StatRow[$Points] / $StatRow['ally_members'])), 'points' => pretty_number($StatRow[$Points]), 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]); } $GLOBALS['DATABASE']->free_result($query); break; } $Selector['who'] = array(1 => $LNG['st_player'], 2 => $LNG['st_alliance']); $Selector['type'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh'], 4 => $LNG['st_buildings'], 5 => $LNG['st_defenses'], 6 => 'Population'); $Selector['type2'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh']); $this->tplObj->assign_vars(array('Selectors' => $Selector, 'who' => $who, 'type' => $type, 'range' => floor(($range - 1) / 100) * 100 + 1, 'RangeList' => $RangeList, 'CUser_ally' => $USER['ally_id'], 'CUser_id' => $USER['id'], 'stat_date' => _date($LNG['php_tdformat'], Config::get('stat_last_update'), $USER['timezone']))); $this->display('page.statistics.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); $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); }