public function __construct(&$CurrentPlanet, $CurrentUser)
 {
     global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
     include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
     include_once $xgp_root . 'includes/functions/CheckPlanetUsedFields.' . $phpEx;
     CheckPlanetUsedFields($CurrentPlanet);
     $parse = $lang;
     $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
     $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
     if (isset($_GET['cmd'])) {
         $bDoItNow = false;
         $TheCommand = $_GET['cmd'];
         $Element = $_GET['building'];
         $ListID = $_GET['listid'];
         if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
             unset($Element);
         }
         if (isset($Element)) {
             if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
                 if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                     $bDoItNow = true;
                 }
             } else {
                 header("location:game.php?page=buildings");
             }
         } elseif (isset($ListID)) {
             $bDoItNow = true;
         }
         if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
             $bDoItNow = false;
         }
         if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
             $bDoItNow = false;
         }
         if ($bDoItNow == true) {
             switch ($TheCommand) {
                 case 'cancel':
                     $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                     break;
                 case 'remove':
                     $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                     break;
                 case 'insert':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                     break;
                 case 'destroy':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                     break;
             }
         }
         if ($_GET['r'] == 'overview') {
             header('location:game.php?page=overview');
         } else {
             header("Location: game.php?page=buildings&mode=buildings");
         }
     }
     SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
     // $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); // OLD CODE
     // START FIX BY JSTAR
     $Sprice = array();
     $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser, $Sprice);
     // END FIX BY JSTAR
     $this->BuildingSavePlanetRecord($CurrentPlanet);
     if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
         $CanBuildElement = true;
     } else {
         $CanBuildElement = false;
     }
     $BuildingPage = "";
     $zaehler = 1;
     foreach ($lang['tech'] as $Element => $ElementName) {
         if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
             $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
             if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                 $RoomIsOk = true;
             } else {
                 $RoomIsOk = false;
             }
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                 $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                 $parse = array();
                 $parse = $lang;
                 $parse['dpath'] = $dpath;
                 $parse['i'] = $Element;
                 $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                 $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
                 $parse['n'] = $ElementName;
                 $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                 /* OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- //
                 					$ElementBuildTime      	= GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 					$parse['time']         	= ShowBuildTime($ElementBuildTime);
                 					$parse['price']        	= GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                    OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- //
                 */
                 // START FIX BY JSTAR
                 $really_lvl = isset($Sprice[$Element]) ? $Sprice[$Element] : $BuildingLevel;
                 $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element, $really_lvl);
                 $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, $really_lvl);
                 $parse['time'] = ShowBuildTime($ElementBuildTime);
                 // END FIX BY JSTAR
                 $parse['click'] = '';
                 $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                 if ($RoomIsOk && $CanBuildElement) {
                     if ($Queue['lenght'] == 0) {
                         if ($NextBuildLevel == 1) {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                             }
                         } else {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                             }
                         }
                     } else {
                         $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>";
                     }
                 } elseif ($RoomIsOk && !$CanBuildElement) {
                     if ($NextBuildLevel == 1) {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                     } else {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                     }
                 } else {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>";
                 }
                 if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse);
             }
         }
     }
     if ($Queue['lenght'] > 0) {
         include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
         $parse['BuildListScript'] = InsertBuildListScript("buildings");
         $parse['BuildList'] = $Queue['buildlist'];
     } else {
         $parse['BuildListScript'] = "";
         $parse['BuildList'] = "";
     }
     $parse['BuildingsList'] = $BuildingPage;
     display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse));
 }
Esempio n. 2
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user, $resource;
    include_once $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentPlanet['id_owner'] . "' AND `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type`='3'", 'planets', true);
    if (empty($lunarow)) {
        unset($lunarow);
    }
    CheckPlanetUsedFields($lunarow);
    $parse = $lang;
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    $parse['dpath'] = $dpath;
    $parse['avatar'] = $user['avatar'];
    $online_users = doquery("SELECT COUNT(DISTINCT(id)) as `onlinenow` FROM {{table}} WHERE `onlinetime` > '" . (time() - 15 * 60) . "';", 'users', true);
    $parse['online_users'] = $online_users['onlinenow'];
    $QueryStat = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `stat_type` = '1'", "statpoints", true);
    $parse['puntos_defensa'] = pretty_number($QueryStat['defs_count']);
    $parse['puntos_edificios'] = pretty_number($QueryStat['build_points']);
    $parse['puntos_naves'] = pretty_number($QueryStat['fleet_count']);
    $parse['puntos_investigaciones'] = pretty_number($QueryStat['tech_count']);
    $StatRecord = doquery("SELECT `total_rank`,`total_points`,`defs_rank`,`build_rank`,`fleet_rank`,`tech_rank` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
    $parse['top_defensa'] = $StatRecord['defs_rank'];
    $parse['top_edificios'] = $StatRecord['build_rank'];
    $parse['top_naves'] = $StatRecord['fleet_rank'];
    $parse['top_investigaciones'] = $StatRecord['tech_rank'];
    $parse['top_total'] = $StatRecord['total_rank'];
    $parse['ally_name'] = $ally_name;
    $parse['ally_tag'] = $ally_tag;
    if ($Level > 0) {
        $parse['admin_link'] = "<tr><td><div align=\"center\"><a href=\"javascript:top.location.href='adm/index.php'\"> <font color=\"lime\">" . $lang['lm_administration'] . "</font></a></div></td></tr>";
    } else {
        $parse['admin_link'] = "";
    }
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . $CurrentUser['current_planet'] . "' LIMIT 1;", "planets");
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
            } elseif ($_POST['kolonieloeschen'] == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_owner = '{$user['id']}' AND fleet_start_galaxy='{$CurrentPlanet['galaxy']}' AND fleet_start_system='{$CurrentPlanet['system']}' AND fleet_start_planet='{$CurrentPlanet['planet']}'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $harabeyeri = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_target_owner = '{$user['id']}' AND fleet_end_galaxy='{$CurrentPlanet['galaxy']}' AND fleet_end_system='{$CurrentPlanet['system']}' AND fleet_end_planet='{$CurrentPlanet['planet']}'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $gezoay = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                if ($kendifilo > 0) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($digerfilo > 0 && $mess < 1 && $gezoay != 2) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                        doquery("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "' WHERE `id` = '" . mysql_real_escape_string($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                        doquery("UPDATE {{table}} SET `current_planet` = `id_planet` WHERE `id` = '" . mysql_real_escape_string($CurrentUser['id']) . "' LIMIT 1", "users");
                        doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = 3;", 'planets');
                        message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                    } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                        message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                    } else {
                        message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                    }
                }
            }
            return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
            break;
        default:
            if ($StatRecord['total_points'] >= 0 && $StatRecord['total_points'] < 100000) {
                $parse['rankgame'] = "Soldado";
                $parse['rankimg'] = "rank1.gif";
            } elseif ($StatRecord['total_points'] >= 100000 && $StatRecord['total_points'] < 250000) {
                $parse['rankgame'] = "Cabo Cazador";
                $parse['rankimg'] = "rank2.gif";
            } elseif ($StatRecord['total_points'] >= 250000 && $StatRecord['total_points'] < 500000) {
                $parse['rankgame'] = "Sargento Cazador";
                $parse['rankimg'] = "rank3.gif";
            } elseif ($StatRecord['total_points'] >= 500000 && $StatRecord['total_points'] < 1000000) {
                $parse['rankgame'] = "Teniente de Crucero";
                $parse['rankimg'] = "rank4.gif";
            } elseif ($StatRecord['total_points'] >= 1000000 && $StatRecord['total_points'] < 2500000) {
                $parse['rankgame'] = "Capitán Destructor";
                $parse['rankimg'] = "rank5.gif";
            } elseif ($StatRecord['total_points'] >= 2500000 && $StatRecord['total_points'] < 5000000) {
                $parse['rankgame'] = "Almirante Acorazado";
                $parse['rankimg'] = "rank6.gif";
            } elseif ($StatRecord['total_points'] >= 5000000 && $StatRecord['total_points'] < 10000000) {
                $parse['rankgame'] = "General Estrella";
                $parse['rankimg'] = "rank7.gif";
            } elseif ($StatRecord['total_points'] >= 10000000 && $StatRecord['total_points'] < 25000000) {
                $parse['rankgame'] = "General Supernova";
                $parse['rankimg'] = "rank8.gif";
            } elseif ($StatRecord['total_points'] >= 25000000 && $StatRecord['total_points'] < 50000000) {
                $parse['rankgame'] = "General de Flota";
                $parse['rankimg'] = "rank9.gif";
            } elseif ($StatRecord['total_points'] >= 50000000 && $StatRecord['total_points'] < 100000000) {
                $parse['rankgame'] = "General Interestelar";
                $parse['rankimg'] = "rank10.gif";
            } elseif ($StatRecord['total_points'] >= 100000000 && $StatRecord['total_points'] < 500000000) {
                $parse['rankgame'] = "Cónsul General";
                $parse['rankimg'] = "rank11.gif";
            } elseif ($StatRecord['total_points'] >= 500000000) {
                $parse['rankgame'] = "Emperador";
                $parse['rankimg'] = "rank12.gif";
            }
            if ($CurrentPlanet['planet'] >= 1 && $CurrentPlanet['planet'] < 4) {
                $parse['type_of_planet'] = "Desertico";
            } elseif ($CurrentPlanet['planet'] >= 4 && $CurrentPlanet['planet'] < 7) {
                $parse['type_of_planet'] = "Jungla";
            } elseif ($CurrentPlanet['planet'] >= 7 && $CurrentPlanet['planet'] < 10) {
                $parse['type_of_planet'] = "Gaseoso";
            } elseif ($CurrentPlanet['planet'] >= 10 && $CurrentPlanet['planet'] < 13) {
                $parse['type_of_planet'] = "Acuatico";
            } elseif ($CurrentPlanet['planet'] >= 13) {
                $parse['type_of_planet'] = "Congelado";
            }
            $CONSULTA = doquery("SELECT metal,crystal,darkmatter FROM {{table}} WHERE galaxy = '" . $CurrentPlanet['galaxy'] . "' AND system = '" . $CurrentPlanet['system'] . "' AND planet = '" . $CurrentPlanet['planet'] . "'", "galaxy", true);
            $parse['metal_debris'] = pretty_number($CONSULTA['metal']);
            $parse['crystal_debris'] = pretty_number($CONSULTA['crystal']);
            $parse['darkmatter_debris'] = pretty_number($CONSULTA['darkmatter']);
            if ($CurrentPlanet['recycler'] != 0 && ($CONSULTA['metal'] != 0 || $CONSULTA['crystal'] != 0 || $CONSULTA['darkmatter'] != 0)) {
                $parse['get_link'] = " (<a href=\"game.php?page=galaxy&mode=8&g=" . $CurrentPlanet['galaxy'] . "&s=" . $CurrentPlanet['system'] . "&p=" . $CurrentPlanet['planet'] . "&t=2\">asdasd</a>)";
            } else {
                $parse['get_link'] = '';
            }
            if ($CurrentUser['new_message'] != 0) {
                $Have_new_message .= "<tr>";
                if ($CurrentUser['new_message'] == 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>" . $lang['ov_have_new_message'] . "</a></th>";
                } elseif ($CurrentUser['new_message'] > 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>";
                    $Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
                    $Have_new_message .= "</a></th>";
                }
                $Have_new_message .= "</tr>";
            }
            $OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 0;
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $id = $FleetRow['fleet_id'];
                $EndTime = $FleetRow['fleet_end_time'];
                /////// // ### LUCKY , CODES ARE BELOW
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                //////
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
            }
            mysql_free_result($OwnFleets);
            //iss ye katilan filo////////////////////////////////////
            // ### LUCKY , CODES ARE BELOW
            $dostfilo = doquery("SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = '" . $hedefgalaksi . "' AND `fleet_end_system` = '" . $hedefsistem . "' AND `fleet_end_planet` = '" . $hedefgezegen . "' AND `fleet_group` = '" . $filogrubu . "';", 'fleets');
            $Record1 = 0;
            while ($FleetRow = mysql_fetch_array($dostfilo)) {
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $id = $FleetRow['fleet_id'];
                $EndTime = $FleetRow['fleet_end_time'];
                ///////
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                ///////
                if ($FleetRow['fleet_mission'] == 2 && $FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    $Record1++;
                    // if (($FleetRow['fleet_mission'] == 2) ){
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record1);
                    }
                    // }
                }
                ///""
                if ($FleetRow['fleet_mission'] == 1 && $FleetRow['fleet_owner'] != $CurrentUser['id'] && $filogrubu > 0) {
                    $Record++;
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                    }
                }
            }
            mysql_free_result($dostfilo);
            //
            //////////////////////////////////////////////////
            $OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            mysql_free_result($OtherFleets);
            $planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='{$CurrentUser['id']}' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $AllPlanets = "<tr>";
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th width='80'>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".gif\" height=\"50\" width=\"50\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Colone <= 5) {
                        $Colone++;
                    } else {
                        $AllPlanets .= "</tr><tr>";
                        $Colone = 1;
                    }
                }
            }
            mysql_free_result($planets_query);
            $AllPlanets .= "</tr>";
            if ($game_config['OverviewNewsFrame'] == '1') {
                $parse['NewsFrame'] = "<tr>" . $lang['ov_news_title'] . "<th colspan=\"4\">" . stripslashes($game_config['OverviewNewsText']) . "</th></tr>";
            }
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '3'", 'planets', true);
                    $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $moon['image'] . ".png\" height=\"90\" width=\"90\"></a>";
                    $parse['moon'] = $moon['name'] . "";
                } else {
                    $parse['moon_img'] = "";
                    $parse['moon'] = "";
                }
            } elseif ($CurrentPlanet['planet_type'] == 3) {
                $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '1'", 'planets', true);
                $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $moon['image'] . ".gif\" height=\"120\" width=\"120\"></a>";
                $parse['moon'] = $moon['name'] . "";
            } else {
                $parse['moon_img'] = "";
                $parse['moon'] = "";
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            $StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            // **** INICIA MOD {MOSTRAR TECNOLOGIA EN PROCESO EN VISTA GENERAL} ****
            if ($CurrentPlanet['b_building'] != 0) {
                include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("buildings");
                    $Build .= "<table>";
                    $Build .= " <tr>";
                    $Build .= " <td colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</td>";
                    $Build .= " </tr>";
                    $Build .= " <tr>";
                    $Build .= " <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"></td>";
                    $Build .= " <td>" . $lang['pr_subiendo'] . " <span style=\"color:#FF8C00;\">Nivel " . $CurrBuild[1] . "</span><br />";
                    $Build .= " " . $lang['pr_duracion'] . ":<div id=\"blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                    $Build .= " </td>";
                    $Build .= " </tr>";
                    $Build .= "</Table>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n pp = \"" . $RestTime . "\";\n";
                    $Build .= "\n pk = \"" . 1 . "\";\n";
                    $Build .= "\n pm = \"cancel\";\n";
                    $Build .= "\n pl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n t();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            $PlanetaQueInv = doquery("SELECT id, name, b_tech, b_tech_id FROM `{{table}}` WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `b_tech` != '0';", 'planets', true);
            if ($PlanetaQueInv['b_tech'] != 0) {
                include $xgp_root . 'includes/functions/InsertTechListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $NvlActual = $CurrentUser[$resource[$PlanetaQueInv['b_tech_id']]] + 1;
                $RestTime = $PlanetaQueInv['b_tech'] - time();
                $PlanetID = $PlanetaQueInv['id'];
                $NomPlaneta = "";
                if ($PlanetaQueInv['name'] != $CurrentPlanet['name']) {
                    $NomPlaneta = " de " . $PlanetaQueInv['name'];
                }
                $Tech = InsertTechListScript("buildings", $NomPlaneta);
                $Tech .= "<table>";
                $Tech .= " <tr>";
                $Tech .= " <td colspan=\"2\">" . $lang['tech'][$PlanetaQueInv['b_tech_id']] . "</td>";
                $Tech .= " </tr>";
                $Tech .= " <tr>";
                $Tech .= " <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $PlanetaQueInv['b_tech_id'] . ".gif\" width=\"40\" height=\"40\"></td>";
                $Tech .= " <td>" . $lang['pr_investigando'] . " <span style=\"color:#FF8C00;\">Nivel " . $NvlActual . "</span><br />";
                $Tech .= " " . $lang['pr_duracion'] . ":<div id=\"tec_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Tech .= " </td>";
                $Tech .= " </tr>";
                $Tech .= "</Table>";
                $Tech .= "\n<script language=\"JavaScript\">";
                $Tech .= "\n tec_pp = \"" . $RestTime . "\";\n";
                $Tech .= "\n tec_pk = \"" . 1 . "\";\n";
                $Tech .= "\n tec_pm = \"cancel\";\n";
                $Tech .= "\n tec_pl = \"" . $PlanetaQueInv['b_tech_id'] . "\";\n";
                $Tech .= "\n tec_t();\n";
                $Tech .= "\n</script>\n";
                $parse['tech_en_proceso'] .= $Tech;
            } else {
                $parse['tech_en_proceso'] = $lang['ov_tfree'];
            }
            if ($CurrentPlanet['b_hangar'] != 0) {
                include $xgp_root . 'includes/functions/InsertHangarListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $BuildQueue = explode(";", $CurrentPlanet['b_hangar_id']);
                $CurrBuild = explode(",", $BuildQueue[0]);
                $RealTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $CurrBuild[0]);
                $QueueTime = $RealTime * $CurrBuild[1];
                $RestTime = $QueueTime - $CurrentPlanet['b_hangar'];
                $PlanetID = $CurrentPlanet['id'];
                $Hangar = InsertHangarListScript("overview");
                $Hangar .= "<table>";
                $Hangar .= " <tr>";
                $Hangar .= " <td colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</td>";
                $Hangar .= " </tr>";
                $Hangar .= " <tr>";
                $Hangar .= " <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"><br />";
                $Hangar .= " </td>";
                $Hangar .= " <td>" . $lang['pr_tiempo_prod'] . "<br />";
                $Hangar .= " <div id=\"han_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Hangar .= " </td>";
                $Hangar .= " </tr>";
                $Hangar .= "</Table>";
                $Hangar .= "\n<script language=\"JavaScript\">";
                $Hangar .= "\n han_pp = \"" . $RestTime . "\";\n";
                $Hangar .= "\n han_pk = \"" . 1 . "\";\n";
                $Hangar .= "\n han_pm = \"cancel\";\n";
                $Hangar .= "\n han_pl = \"" . $PlanetID . "\";\n";
                $Hangar .= "\n han_t();\n";
                $Hangar .= "\n</script>\n";
                $parse['hangar_en_proceso'] .= $Hangar;
            } else {
                $parse['hangar_en_proceso'] = $lang['ov_hree'];
            }
            $parse['overview_produccion'] = parsetemplate(gettemplate('overview/overview_produccion'), $parse);
            // **** FIN MOD {MOSTRAR TECNOLOGIA EN PROCESO EN VISTA GENERAL} ****
            $parse['fleet_list'] = $flotten;
            $parse['Have_new_message'] = $Have_new_message;
            $parse['planet_image'] = $CurrentPlanet['image'];
            $parse['anothers_planets'] = $AllPlanets;
            $parse["dpath"] = $dpath;
            if ($game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } elseif ($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            setlocale(LC_ALL, 'es_ES');
            $parse['date_time'] = date("D M j H:i:s", time());
            if ($Level > 0) {
                $parse['admin_link'] = "<tr><td><div align=\"center\"><a href=\"javascript:top.location.href='adm/index.php'\"> <font color=\"lime\">" . $lang['lm_administration'] . "</font></a></div></td></tr>";
            } else {
                $parse['admin_link'] = "";
            }
            if ($user["new_message"] != 0) {
                $color = "color=\"red\"";
            } else {
                $color = "color=\"white\"";
            }
            $parse["new_message"] = ' (<font size="1px" ' . $color . ' > ' . $user["new_message"] . ' </font>)';
            return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
            break;
    }
}
Esempio n. 3
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 *
 * fix by vomi, zeus (team xorbit) for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
    $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
    // Boucle d'interpretation des eventuelles commandes
    if ($CurrentUser['urlaubs_modus'] == 0) {
        if (isset($_GET['cmd'])) {
            // On passe une commande
            $bDoItNow = false;
            $TheCommand = $_GET['cmd'];
            $Gebaude = false;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $_GET['building'])) {
                $Gebaude = IsElementBuyable($CurrentUser, $CurrentPlanet, $_GET['building'], true, false);
            }
            //Gebäude-Cheat-Fix Wolle1989
            //ändern für andere Bannzeiten in Sekunden
            $bannzeit = 60;
            // so lassen
            $time = time();
            $bantime = $time + $bannzeit;
            $Gebaude = false;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $_GET['building'])) {
                $Gebaude = IsElementBuyable($CurrentUser, $CurrentPlanet, $_GET['building'], true, false);
            }
            $Element = $_GET['building'];
            if (!$Gebaude) {
                doquery("UPDATE {{table}} SET bana='1', banaday='{$bantime}' WHERE id='{$CurrentUser['id']}'", "users");
                doquery("INSERT INTO {{table}} SET\r\n\t\t\t\t`who` = '{$CurrentUser['username']}',\r\n\t\t\t\t`theme`= 'Cheatversuch',\r\n\t\t\t\t`who2` = '{$CurrentUser['id']}',\r\n\t\t\t\t`time` = '{$time}',\r\n\t\t\t\t`longer` = '{$bantime}',\r\n\t\t\t\t`author` = 'SYSTEM: B',\r\n\t\t\t\t`email` = 'n'", 'banned');
                message($lang['CHEATATTEMPT'], $lang['CHEATATTEMPT_TITLE']);
                die;
            }
            $ListID = $_GET['listid'];
            if (isset($Element)) {
                if (!strchr($Element, ",")) {
                    if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                        $bDoItNow = true;
                    }
                }
            } elseif (isset($ListID)) {
                $bDoItNow = true;
            }
            //Hier wird geprüft ob ein ; in die URL(GET)Geschrieben wurde
            foreach ($_GET as $check_url) {
                if (eregi(";", $check_url)) {
                    die($lang['ANTICHEAT_MESSAGE']);
                }
            }
            //Hier wird gescheckt ob ein user das zeichen ; in einen INPUT schreibt
            foreach ($_POST as $check_pos) {
                if (eregi(";", $check_post, $check_url)) {
                    die($lang['ANTICHEAT_MESSAGE']);
                }
            }
            if ($bDoItNow == true) {
                switch ($TheCommand) {
                    case 'cancel':
                        // Interrompre le premier batiment de la queue
                        CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                        break;
                    case 'remove':
                        // Supprimer un element de la queue (mais pas le premier)
                        // $RemID -> element de la liste a supprimer
                        RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                        break;
                    case 'insert':
                        // Insere un element dans la queue
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                        break;
                    case 'destroy':
                        // Detruit un batiment deja construit sur la planete !
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                        break;
                    default:
                        break;
                }
                // switch
            }
        }
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // On enregistre ce que l'on a modifi� dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                // show energy on BuildingPage
                $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"];
                $BuildTemp = $CurrentPlanet['temp_max'];
                $CurrentBuildtLvl = $BuildingLevel;
                $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
                $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                $ActualNeed = floor($Prod[4]);
                $BuildLevel++;
                $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                $EnergyNeed = colorNumber(pretty_number(floor($Prod[4] - $ActualNeed)));
                if ($Element >= 1 && $Element <= 3) {
                    $parse['build_need_diff'] = "(" . "<font color=#FF0000>" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                } elseif ($Element == 4 || $Element == 12) {
                    $parse['build_need_diff'] = "(" . "<font color=#00FF00>+" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                }
                // end of 'show energy on BuildingPage'
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Special Laboratoire
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Variable qui contient le parametre
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                    // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        if ($HaveRessources == true) {
                            $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        } else {
                            $parse['click'] = "<font color=#FF0000>" . $lang['InBuildQueue'] . "</font>";
                        }
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("buildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
Esempio n. 4
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
    $Allowed['3'] = array(12, 14, 15, 21, 34, 41, 42, 43);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        // On passe une commande
        $bThisIsCheated = false;
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        $Element = $_GET['building'];
        $ListID = $_GET['listid'];
        if (isset($Element)) {
            if (!strchr($Element, " ")) {
                if (!strchr($Element, ",")) {
                    if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                        $bDoItNow = true;
                    } else {
                        $bThisIsCheated = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    // Interrompre le premier batiment de la queue
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    // Supprimer un element de la queue (mais pas le premier)
                    // $RemID -> element de la liste a supprimer
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    // Insere un element dans la queue
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    break;
                case 'destroy':
                    // Detruit un batiment deja construit sur la planete !
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                    break;
                default:
                    break;
            }
            // switch
        } elseif ($bThisIsCheated == true) {
            ResetThisFuckingCheater($CurrentUser['id']);
        }
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // On enregistre ce que l'on a modifi&eacute; dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi&eacute; dans users
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Sp&eacute;cial Laboratoire
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Variable qui contient le parametre
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                    // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("buildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
Esempio n. 5
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user;
    include_once $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . intval($CurrentPlanet['id_owner']) . "' AND `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND  `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type`='3'", 'planets', true);
    if (empty($lunarow)) {
        unset($lunarow);
    }
    CheckPlanetUsedFields($lunarow);
    $parse = $lang;
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . intval($CurrentUser['current_planet']) . "' LIMIT 1;", "planets");
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
            } elseif (intval($_POST['kolonieloeschen']) == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_owner = '" . intval($user['id']) . "' AND fleet_start_galaxy='" . intval($CurrentPlanet['galaxy']) . "' AND fleet_start_system='" . intval($CurrentPlanet['system']) . "' AND fleet_start_planet='" . intval($CurrentPlanet['planet']) . "'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $harabeyeri = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_target_owner = '" . intval($user['id']) . "' AND fleet_end_galaxy='" . intval($CurrentPlanet['galaxy']) . "' AND fleet_end_system='" . intval($CurrentPlanet['system']) . "' AND fleet_end_planet='" . intval($CurrentPlanet['planet']) . "'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $gezoay = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                if ($kendifilo > 0) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($digerfilo > 0 && $mess < 1 && $gezoay != 2) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                        doquery("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "' WHERE `id` = '" . intval($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                        doquery("UPDATE {{table}} SET `current_planet` = `id_planet` WHERE `id` = '" . intval($CurrentUser['id']) . "' LIMIT 1", "users");
                        doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type` = 3;", 'planets');
                        message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                    } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                        message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                    } else {
                        message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                    }
                }
            }
            return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
            break;
        default:
            if ($CurrentUser['new_message'] != 0) {
                $Have_new_message .= "<tr>";
                if ($CurrentUser['new_message'] == 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>" . $lang['ov_have_new_message'] . "</a></th>";
                } elseif ($CurrentUser['new_message'] > 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>";
                    $Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
                    $Have_new_message .= "</a></th>";
                }
                $Have_new_message .= "</tr>";
            }
            $OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets');
            $Record = 0;
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                /////// // ### LUCKY , CODES ARE BELOW
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                //////
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
                /**fix fleet table return by jstar**/
                if ($FleetRow['fleet_mission'] == 4 && $StartTime < time() && $EndTime > time()) {
                    $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, "fjstar", $Record);
                }
                /**end fix**/
            }
            mysql_free_result($OwnFleets);
            //iss ye katilan filo////////////////////////////////////
            // ### LUCKY , CODES ARE BELOW
            $dostfilo = doquery("SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = '" . intval($hedefgalaksi) . "' AND `fleet_end_system` = '" . intval($hedefsistem) . "' AND `fleet_end_planet` = '" . intval($hedefgezegen) . "' AND `fleet_group` = '" . intval($filogrubu) . "';", 'fleets');
            $Record1 = 0;
            while ($FleetRow = mysql_fetch_array($dostfilo)) {
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                ///////
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                ///////
                if ($FleetRow['fleet_mission'] == 2 && $FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    $Record1++;
                    //		if (($FleetRow['fleet_mission'] == 2) ){
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record1);
                    }
                    //	}
                }
                ///""
                if ($FleetRow['fleet_mission'] == 1 && $FleetRow['fleet_owner'] != $CurrentUser['id'] && $filogrubu > 0) {
                    $Record++;
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                    }
                }
            }
            mysql_free_result($dostfilo);
            //
            //////////////////////////////////////////////////
            $OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        $id = $FleetRow['fleet_id'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            mysql_free_result($OtherFleets);
            $planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='" . intval($CurrentUser['id']) . "' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $AllPlanets = "<tr>";
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".jpg\" height=\"50\" width=\"50\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Colone <= 1) {
                        $Colone++;
                    } else {
                        $AllPlanets .= "</tr><tr>";
                        $Colone = 1;
                    }
                }
            }
            mysql_free_result($planets_query);
            $AllPlanets .= "</tr>";
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type` = '3'", 'planets', true);
                    $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/" . $moon['image'] . ".jpg\" height=\"50\" width=\"50\"></a>";
                    $parse['moon'] = $moon['name'] . " (" . $lang['fcm_moon'] . ")";
                } else {
                    $parse['moon_img'] = "";
                    $parse['moon'] = "";
                }
            } else {
                $parse['moon_img'] = "";
                $parse['moon'] = "";
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            $StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($CurrentUser['id']) . "';", 'statpoints', true);
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            if ($CurrentPlanet['b_building'] != 0) {
                include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("overview");
                    $Build .= $lang['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')';
                    $Build .= "<br /><div id=\"blc\" class=\"z\">" . pretty_time($RestTime) . "</div>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n\tpp = \"" . $RestTime . "\";\n";
                    $Build .= "\n\tpk = \"" . 1 . "\";\n";
                    $Build .= "\n\tpm = \"cancel\";\n";
                    $Build .= "\n\tpl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n\tt();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            $parse['fleet_list'] = $flotten;
            $parse['Have_new_message'] = $Have_new_message;
            $parse['planet_image'] = $CurrentPlanet['image'];
            $parse['anothers_planets'] = $AllPlanets;
            $parse["dpath"] = $dpath;
            if ($game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } elseif ($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            $parse['date_time'] = date("D M j H:i:s", time());
            return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
            break;
    }
}
Esempio n. 6
0
 $parse['max_users'] = $game_config['users_amount'];
 $parse['metal_debris'] = pretty_number($galaxyrow['metal']);
 $parse['crystal_debris'] = pretty_number($galaxyrow['crystal']);
 if (($galaxyrow['metal'] != 0 || $galaxyrow['crystal'] != 0) && $planetrow[$resource[209]] != 0) {
     $parse['get_link'] = " (<a href=\"quickfleet.php?mode=8&g=" . $galaxyrow['galaxy'] . "&s=" . $galaxyrow['system'] . "&p=" . $galaxyrow['planet'] . "&t=2\">" . $lang['type_mission'][8] . "</a>)";
 } else {
     $parse['get_link'] = '';
 }
 if ($planetrow['b_building'] != 0) {
     UpdatePlanetBatimentQueueList($planetrow, $user);
     if ($planetrow['b_building'] != 0) {
         $BuildQueue = explode(";", $planetrow['b_building_id']);
         $CurrBuild = explode(",", $BuildQueue[0]);
         $RestTime = $planetrow['b_building'] - time();
         $PlanetID = $planetrow['id'];
         $Build = InsertBuildListScript("overview");
         $Build .= $lang['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')';
         $Build .= "<br /><div id=\"blc\" class=\"z\">" . pretty_time($RestTime) . "</div>";
         $Build .= "\n<script language=\"JavaScript\">";
         $Build .= "\n\tpp = \"" . $RestTime . "\";\n";
         // temps necessaire (a compter de maintenant et sans ajouter time() )
         $Build .= "\n\tpk = \"" . 1 . "\";\n";
         // id index (dans la liste de construction)
         $Build .= "\n\tpm = \"cancel\";\n";
         // mot de controle
         $Build .= "\n\tpl = \"" . $PlanetID . "\";\n";
         // id planete
         $Build .= "\n\tt();\n";
         $Build .= "\n</script>\n";
         $parse['building'] = $Build;
     } else {
Esempio n. 7
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $user;
    CheckPlanetUsedFields($CurrentPlanet);
    PlanetResourceUpdate($CurrentUser, $CurrentPlanet, time());
    // Was gebaut werden darf in Abhängikeit zum gewählten Volk.
    switch ($user['volk']) {
        case "A":
            $Allowed['1'] = array(1, 2, 3, 11, 12, 14, 15, 21, 22, 23, 24, 25, 26, 27, 31, 33, 34, 44);
            $Allowed['3'] = array(4, 12, 14, 15, 21, 25, 26, 34, 41, 42, 43);
            break;
        case "B":
            $Allowed['1'] = array(1, 2, 3, 11, 12, 14, 15, 21, 22, 23, 24, 25, 26, 31, 33, 34, 44, 45);
            $Allowed['3'] = array(4, 12, 14, 15, 21, 25, 26, 34, 41, 42, 43);
            break;
        case "C":
            $Allowed['1'] = array(1, 2, 3, 11, 12, 14, 15, 21, 22, 23, 24, 25, 26, 31, 33, 34, 44, 46);
            $Allowed['3'] = array(4, 12, 14, 15, 21, 25, 26, 34, 41, 42, 43, 46);
            break;
    }
    //Werte auf null setzen
    $bThisIsCheated = 0;
    $bDoItNow = 0;
    $TheCommand = 0;
    $Element = 0;
    $ListID = 0;
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        // On passe une commande
        $bThisIsCheated = false;
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        $Element = $_GET['building'];
        $ListID = $_GET['listid'];
        if (isset($Element)) {
            if (!strchr($Element, " ")) {
                if (!strchr($Element, ",")) {
                    if (!strchr($Element, ";")) {
                        if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                            $bDoItNow = true;
                        } else {
                            $bThisIsCheated = true;
                        }
                    } else {
                        $bThisIsCheated = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            $Element = abs($Element);
            switch ($TheCommand) {
                case 'cancel':
                    // Interrompre le premier batiment de la queue
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    // Supprimer un element de la queue (mais pas le premier)
                    // $RemID -> element de la liste a supprimer
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    // Insere un element dans la queue
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    break;
                case 'destroy':
                    // Detruit un batiment deja construit sur la planete !
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                    break;
                default:
                    break;
            }
            // switch
        } elseif ($bThisIsCheated == true) {
            ResetThisFuckingCheater($CurrentUser['id']);
        }
        sleep(1);
        // es wird 1 sekunde geschlafen
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // On enregistre ce que l'on a modifi&eacute; dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi&eacute; dans users
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    $zaehler = 1;
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet['field_current'] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                // show energy on BuildingPage
                //================================
                $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"];
                $BuildTemp = $CurrentPlanet['temp_max'];
                $CurrentBuildtLvl = $BuildingLevel;
                $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
                $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05);
                $Prod[11] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                if ($Element != 12) {
                    $ActualNeed = floor($Prod[11]);
                } else {
                    $ActualNeed = floor($Prod[3]);
                }
                $BuildLevel++;
                $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05);
                $Prod[11] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                if ($Element != 12) {
                    $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID]));
                    $bloc['build_prod_diff'] = colorNumber(pretty_number(floor($Prod[$BuildID] - $ActualProd)));
                    $bloc['build_need'] = colorNumber(pretty_number(floor($Prod[11])));
                    $EnergyNeed = colorNumber(pretty_number(floor($Prod[11] - $ActualNeed)));
                } else {
                    $bloc['build_prod'] = pretty_number(floor($Prod[11]));
                    $bloc['build_prod_diff'] = colorNumber(pretty_number(floor($Prod[11] - $ActualProd)));
                    $bloc['build_need'] = colorNumber(pretty_number(floor($Prod[3])));
                    $EnergyNeed = colorNumber(pretty_number(floor($Prod[3] - $ActualNeed)));
                }
                if ($Element >= 1 && $Element <= 4) {
                    $parse['build_need_diff'] = "(" . "<font color=#FF0000>" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                } elseif ($Element == 11 || $Element == 12) {
                    $parse['build_need_diff'] = "(" . "<font color=#00FF00>+" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                }
                //================================
                if ($Element == 31) {
                    // Sp&eacute;cial Laboratoire
                    if ($CurrentUser['b_tech_planet'] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Variable qui contient le parametre
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($Element == 15) {
                    // Spezialgebäude Nanitenfabrik
                    if ($CurrentPlanet['robot_factory'] <= 9) {
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['no Nani'] . "</font>";
                    }
                }
                if ($Element == 45) {
                    // Spezialgebäude Mondtransformer
                    if ($CurrentPlanet['mondtransformer'] == 1) {
                        // Es darf nur ein Mondtransformer pro Planet gebaut werden
                        $parse['click'] = "<font color=#FF0000>" . $lang['only_one_mondtransformer'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                    // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                }
                if ($zaehler % 3 == 0) {
                    $parse['trclose'] = '</tr>';
                    $zaehler++;
                } else {
                    $parse['trclose'] = '';
                    $zaehler++;
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("buildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet['field_current'];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'];
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
 public function ShowBuildingsPage(&$CurrentPlanet, $CurrentUser)
 {
     global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
     include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
     CheckPlanetUsedFields($CurrentPlanet);
     $parse = $lang;
     $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44);
     $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
     if (isset($_GET['cmd'])) {
         $bDoItNow = false;
         $TheCommand = $_GET['cmd'];
         $Element = $_GET['building'];
         $ListID = $_GET['listid'];
         if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
             unset($Element);
         }
         if (isset($Element)) {
             if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
                 if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                     $bDoItNow = true;
                 }
             } else {
                 header("location:game.php?page=buildings");
             }
         } elseif (isset($ListID)) {
             $bDoItNow = true;
         }
         if ($bDoItNow == true) {
             switch ($TheCommand) {
                 case 'cancel':
                     $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                     break;
                 case 'remove':
                     $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                     break;
                 case 'insert':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                     break;
                 case 'destroy':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                     break;
             }
         }
     }
     SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
     $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser);
     $this->BuildingSavePlanetRecord($CurrentPlanet);
     if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
         $CanBuildElement = true;
     } else {
         $CanBuildElement = false;
     }
     $BuildingPage = "";
     $zaehler = 1;
     $siguiente = 1;
     foreach ($lang['tech'] as $BuildID => $ElementName) {
         if (in_array($BuildID, $Allowed[$CurrentPlanet['planet_type']])) {
             $parse = $lang;
             $parse['dpath'] = $dpath;
             $parse['name'] = $lang['info'][$BuildID]['name'];
             $parse['image'] = $BuildID;
             $parse['description'] = $lang['info'][$BuildID]['description'];
             $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true);
             $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2;
             $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID;
             $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]];
             $parse['nfo_metal'] = $lang['Metal'];
             $parse['nfo_crysta'] = $lang['Crystal'];
             $parse['nfo_deuter'] = $lang['Deuterium'];
             $parse['metal'] = pretty_number($NeededRessources['metal']);
             $parse['crystal'] = pretty_number($NeededRessources['crystal']);
             $parse['deuterium'] = pretty_number($NeededRessources['deuterium']);
             $parse['destroytime'] = pretty_time($DestroyTime);
             $infodiv .= parsetemplate(gettemplate('buildings/buildings_info_row'), $parse);
         }
     }
     foreach ($lang['tech'] as $Element => $ElementName) {
         if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
             $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
             if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                 $RoomIsOk = true;
             } else {
                 $RoomIsOk = false;
             }
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                 $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                 $parse = array();
                 $parse = $lang;
                 $parse['dpath'] = $dpath;
                 if ($siguiente == 1) {
                     $parse['abrirtr'] = "<tr>";
                 }
                 $parse['i'] = $Element;
                 $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                 $parse['nivel'] = $BuildingLevel == 0 ? " (" . $lang['bd_lvl'] . " 0)" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
                 $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"];
                 $BuildTemp = $CurrentPlanet['temp_max'];
                 $CurrentBuildtLvl = $BuildingLevel;
                 $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
                 $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05);
                 $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                 if ($Element != 12) {
                     $ActualNeed = floor($Prod[4]);
                 } else {
                     $ActualNeed = floor($Prod[3]);
                 }
                 $BuildLevel++;
                 $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05);
                 $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                 if ($Element != 12) {
                     $EnergyNeed = pretty_number(abs(floor($Prod[4] - $ActualNeed)));
                 } else {
                     $EnergyNeed = pretty_number(abs(floor($Prod[3] - $ActualNeed)));
                 }
                 if ($Element >= 1 && $Element <= 3) {
                     $parse['build_need_diff'] = "Next Level:<br>Verbraucht <font color=#FF0000>" . $EnergyNeed . "</font> " . $lang['Energy'] . " mehr";
                     $BuildLevel = 0;
                 } elseif ($Element == 4 || $Element == 12) {
                     $parse['build_need_diff'] = "Next Level:<br>Produziert <font color=#00FF00>" . $EnergyNeed . "</font> mehr " . $lang['Energy'];
                     $BuildLevel = 0;
                 } elseif ($Element == 43 && $BuildingLevel != 0) {
                     $parse['build_need_diff'] = "<a href=\"javascript:f('game.php?page=infos&gid=43','');\">Springen</a>";
                     $BuildLevel = 0;
                 }
                 if ($BuildingLevel != 0) {
                     $parse['cancel'] = "<a href=\"javascript:infodiv('" . $Element . "-cancel');javascript:animatedcollapse.toggle('" . $Element . "-cancel')\">Abrei&szlig;en</a>";
                 }
                 $parse['n'] = $ElementName;
                 $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                 $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 $parse['time'] = ShowBuildTime($ElementBuildTime);
                 $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, true);
                 $parse['click'] = '';
                 $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                 if ($RoomIsOk && $CanBuildElement) {
                     if ($Queue['lenght'] == 0) {
                         if ($NextBuildLevel == 1) {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                             }
                         } else {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                             }
                         }
                     } else {
                         $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>";
                     }
                 } elseif ($RoomIsOk && !$CanBuildElement) {
                     if ($NextBuildLevel == 1) {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                     } else {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                     }
                 } else {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>";
                 }
                 if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if ($Element == 21 && $CurrentPlanet["b_hangar"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if ($siguiente == 3) {
                     $parse['cerrartr'] = "</tr>";
                     $siguiente = 1;
                 } else {
                     $siguiente++;
                 }
                 $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse);
             }
         }
     }
     if ($Queue['lenght'] > 0) {
         include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
         $parse['BuildListScript'] = InsertBuildListScript("buildings");
         $parse['BuildList'] = $Queue['buildlist'];
     } else {
         $parse['BuildListScript'] = "";
         $parse['BuildList'] = "";
     }
     $parse['BuildingsList'] = $BuildingPage;
     $parse['infodiv'] = $infodiv;
     display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse));
 }
Esempio n. 9
0
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
    $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
    if (isset($_GET['cmd'])) {
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        $Element = $_GET['building'];
        $ListID = $_GET['listid'];
        if (isset($Element)) {
            if (!strchr($Element, " ")) {
                if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                    $bDoItNow = true;
                }
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    break;
                case 'destroy':
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                    break;
                default:
                    break;
            }
        }
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    BuildingSavePlanetRecord($CurrentPlanet);
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("buildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
Esempio n. 10
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $svn_root, $phpEx, $dpath, $db, $lang, $planetrow, $users, $displays;
    $displays->assignContent('overview/overview');
    include_once $svn_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $svn_root . 'includes/functions/classes/class.FlyingFleetsTable.' . $phpEx;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = $db->query("SELECT `id`,`name`,`image`,`destruyed` FROM {{table}}\r\n\t\t\t   WHERE `id_owner` = '" . $CurrentPlanet['id_owner'] . "'\r\n\t\t\t   AND `galaxy` = '" . $CurrentPlanet['galaxy'] . "'\r\n\t\t\t   AND `system` = '" . $CurrentPlanet['system'] . "'\r\n\t\t\t   AND `planet` = '" . $CurrentPlanet['planet'] . "'\r\n\t\t\t   AND `planet_type`= '3';", 'planets', true);
    if (empty($lunarow)) {
        unset($lunarow);
    }
    CheckPlanetUsedFields($lunarow);
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['newname']) {
                $parse['planet_name'] = mysql_escape_string(strip_tags(trim($_POST['newname'])));
            }
            foreach ($parse as $name => $trans) {
                $displays->assignGlobal($name, $trans);
            }
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    $displays->message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    $db->query("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . $CurrentUser['current_planet'] . "' LIMIT 1;", "planets");
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                $displays->newblock('deleted');
            } elseif ($_POST['kolonieloeschen'] == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                    $db->query("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "'\r\n\t\t\t\t\t\tWHERE `id` = '" . mysql_real_escape_string($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                    $db->query("UPDATE {{table}} SET `current_planet` = `id_planet`\r\n\t\t\t\t\t\tWHERE `id` = '" . mysql_real_escape_string($CurrentUser['id']) . "' LIMIT 1", "users");
                    $db->query("DELETE FROM {{table}}\r\n\t\t\t\t\t\tWHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "'\r\n\t\t\t\t\t\tAND `system` = '" . $CurrentPlanet['system'] . "'\r\n\t\t\t\t\t\tAND `planet` = '" . $CurrentPlanet['planet'] . "'\r\n\t\t\t\t\t\tAND `planet_type` = 3;", 'planets');
                    $db->query("UPDATE {{table}} SET `id_luna` = '0'\r\n\t\t\t\t\t\tWHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "'\r\n\t\t\t\t\t\tAND `system` = '" . $CurrentPlanet['system'] . "'\r\n\t\t\t\t\t\tAND `planet` = '" . $CurrentPlanet['planet'] . "';", 'galaxy');
                    $displays->message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                    $displays->message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    $displays->message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                }
            }
            $displays->newblock('renameplanet');
            break;
        default:
            $displays->newblock('overview');
            if ($CurrentUser["db_deaktjava"] == "1") {
                $parse["delete"] = "<tr><th colspan=4 ><h1>" . $lang["deleted"] . gmdate("j-m-y  H:i:s", $CurrentUser["db_time"]) . "</h1></th></tr>";
            }
            $noticias = explode(";;", $db->game_config["information"]);
            if ($noticias[0] == 1) {
                $displays->newblock('noticias');
                $new = nl2br(stripslashes($noticias[1]));
                $new = str_replace(":name:", $CurrentUser['username'], $new);
                $new = str_replace(":server:", $db->game_config['game_name'], $new);
                $displays->assign('news', $new);
            }
            $OwnFleets = $db->query("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 0;
            $fpage = array();
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
            }
            $OtherFleets = $db->query("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            mysql_free_result($OtherFleets);
            $planets_query = $db->query("SELECT * FROM `{{table}}` WHERE id_owner='{$CurrentUser['id']}' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $PlanetaQueInv = array();
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["b_tech"] != 0) {
                    $PlanetaQueInv['b_tech'] = $CurrentUserPlanet["b_tech"];
                    $PlanetaQueInv['b_tech_id'] = $CurrentUserPlanet["b_tech_id"];
                    $PlanetaQueInv['name'] = $CurrentUserPlanet["name"];
                    $PlanetaQueInv['id'] = $CurrentUserPlanet["id"];
                }
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".jpg\" height=\"20\" width=\"20\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Coloneshow % 6 == 0) {
                        $AllPlanets .= "</tr><tr>";
                    }
                }
            }
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 0 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $displays->newblock('moon');
                    $displays->assign('moon_img', "<a href=\"game.php?page=overview&cp=" . $lunarow['id'] . "&re=0\" title=\"" . $lunarow['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $lunarow['image'] . ".png\" height=\"50\" width=\"50\"></a>");
                    $displays->assign('moon', $lunarow['name'] . " (" . $lang['fcm_moon'] . ")");
                }
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                $flotten = "";
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            if ($CurrentPlanet['b_building'] != 0) {
                include $svn_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $users->user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("buildings");
                    $Build .= "<table>";
                    $Build .= "    <tr>";
                    $Build .= "        <th colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</th>";
                    $Build .= "    </tr>";
                    $Build .= "    <tr>";
                    $Build .= "        <th class='anything' align=\"center\" style=\"background-image: url(" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif);background-repeat:no-repeat;width:60px; height:60;\"   valign=\"middle\"></th>";
                    $Build .= "        <th class='anything'>" . $lang['pr_subiendo'] . " <span style=\"color:#FF8C00;\">Nivel " . $CurrBuild[1] . "</span><br />";
                    $Build .= "            " . $lang['pr_duracion'] . ":<div id=\"blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                    $Build .= "        </th>";
                    $Build .= "    </tr>";
                    $Build .= "</Table>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n\tpp = \"" . $RestTime . "\";\n";
                    $Build .= "\n\tpk = \"" . 1 . "\";\n";
                    $Build .= "\n\tpm = \"cancel\";\n";
                    $Build .= "\n\tpl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n\tt();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            if ($PlanetaQueInv['b_tech'] != 0 && $PlanetaQueInv['b_tech_id']) {
                global $resource;
                include $svn_root . 'includes/functions/InsertTechListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $users->user);
                $NvlActual = $CurrentUser[$resource[$PlanetaQueInv['b_tech_id']]] + 1;
                $RestTime = $PlanetaQueInv['b_tech'] - time();
                $PlanetID = $PlanetaQueInv['id'];
                $NomPlaneta = "";
                if ($PlanetaQueInv['name'] != $CurrentPlanet['name']) {
                    $NomPlaneta = " de " . $PlanetaQueInv['name'];
                }
                $Tech = InsertTechListScript("buildings&mode=research", $NomPlaneta);
                $Tech .= "<table>";
                $Tech .= "    <tr>";
                $Tech .= "        <th colspan=\"2\">" . $lang['tech'][$PlanetaQueInv['b_tech_id']] . "</th>";
                $Tech .= "    </tr>";
                $Tech .= "    <tr>";
                $Tech .= "        <th class='anything' align=\"center\" style=\"background-image: url(" . $dpath . "gebaeude/" . $PlanetaQueInv['b_tech_id'] . ".gif);background-repeat:no-repeat;width:60px; height:60;\" valign=\"middle\"></th>";
                $Tech .= "        <th class='anything'>" . $lang['pr_investigando'] . " <span style=\"color:#FF8C00;\">Nivel " . $NvlActual . "</span><br />";
                $Tech .= "            " . $lang['pr_duracion'] . ":<div id=\"tec_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Tech .= "        </th>";
                $Tech .= "    </tr>";
                $Tech .= "</Table>";
                $Tech .= "\n<script language=\"JavaScript\">";
                $Tech .= "\n    tec_pp = \"" . $RestTime . "\";\n";
                $Tech .= "\n    tec_pk = \"" . 1 . "\";\n";
                $Tech .= "\n    tec_pm = \"cancel\";\n";
                $Tech .= "\n    tec_pl = \"" . $PlanetaQueInv['b_tech_id'] . "\";\n";
                $Tech .= "\n    tec_t();\n";
                $Tech .= "\n</script>\n";
                unset($resource);
                $parse['tech_en_proceso'] .= $Tech;
            } else {
                $parse['tech_en_proceso'] = $lang['ov_free'];
            }
            if ($CurrentPlanet['b_hangar'] != 0) {
                include $svn_root . 'includes/functions/InsertHangarListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $users->user);
                $BuildQueue = explode(";", $CurrentPlanet['b_hangar_id']);
                $CurrBuild = explode(",", $BuildQueue[0]);
                $RealTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $CurrBuild[0]);
                $QueueTime = $RealTime * $CurrBuild[1];
                $RestTime = $QueueTime - $CurrentPlanet['b_hangar'];
                $PlanetID = $CurrentPlanet['id'];
                $Hangar = InsertHangarListScript("fleet");
                $Hangar .= "<table>";
                $Hangar .= "    <tr>";
                $Hangar .= "        <th colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</th>";
                $Hangar .= "    </tr>";
                $Hangar .= "    <tr>";
                $Hangar .= "        <th class='anything' align=\"center\" style=\"background-image: url(" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif);background-repeat:no-repeat;width:60px; height:60;\" valign=\"middle\"><br />";
                $Hangar .= "        </th>";
                $Hangar .= "        <th class='anything'>" . $lang['pr_tiempo_prod'] . "<br />";
                $Hangar .= "            <div id=\"han_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Hangar .= "        </th>";
                $Hangar .= "    </tr>";
                $Hangar .= "</Table>";
                $Hangar .= "\n<script language=\"JavaScript\">";
                $Hangar .= "\n    han_pp = \"" . $RestTime . "\";\n";
                $Hangar .= "\n    han_pk = \"" . 1 . "\";\n";
                $Hangar .= "\n    han_pm = \"cancel\";\n";
                $Hangar .= "\n    han_pl = \"" . $PlanetID . "\";\n";
                $Hangar .= "\n    han_t();\n";
                $Hangar .= "\n</script>\n";
                $parse['hangar_en_proceso'] .= $Hangar;
            } else {
                $parse['hangar_en_proceso'] = $lang['ov_free'];
            }
            // Usuarios conectados
            $OnlineUsers = $db->query("SELECT COUNT(DISTINCT id) as count FROM {{table}} WHERE onlinetime>='" . (time() - 15 * 60) . "'", 'users', 'true');
            $parse['NumberMembersOnline'] = $OnlineUsers['count'];
            $parse['id'] = $CurrentPlanet['id'];
            $parse['fleet_list'] = $flotten;
            $parse['planet_image'] = $CurrentPlanet['image'];
            if (isset($AllPlanets)) {
                $displays->newblock('anothers_planets');
                $displays->assign('anothers_planets', $AllPlanets);
            }
            $parse["dpath"] = $dpath;
            if ($db->game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($users->user['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $users->user['total_rank'] . "\">" . $users->user['total_rank'] . "</a> " . $lang['ov_of'] . " " . $db->game_config['users_amount'] . ")";
            } elseif ($db->game_config['stat'] == 1 && $CurrentUser['authlevel'] < $db->game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($users->user['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $users->user['total_rank'] . "\">" . $users->user['total_rank'] . "</a> " . $lang['ov_of'] . " " . $db->game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            setlocale(LC_ALL, 'es_ES.UTF-8/UTF-8');
            $parse['date_time'] = strftime("Hoy es %A, %e de %B de %Y, son las %H:%M:%S", time());
            //$url=explode("game.php",$_SERVER[HTTP_REFERER]);
            $url = dirname("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) . "/";
            $parse['refer'] = '' . $url . 'index.php?ref=' . $users->user['username'] . '';
            $displays->gotoBlock('overview');
            foreach ($parse as $name => $trans) {
                $displays->assign($name, $trans);
            }
            break;
    }
    $displays->display("Overview");
}
Esempio n. 11
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
    $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        // On passe une commande
        $bThisIsCheated = false;
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        if (isset($_GET['building'])) {
            //Wenn Variable gefüllt ist
            $Element = intval($_GET['building']);
            // Muss ne Zahl sein
            if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                $bDoItNow = true;
                // Ist true wenns vorhanden ist und eine Zahl aus der Whitelist des jeweiligen Typs enthält.
            } else {
                $bThisIsCheated = true;
            }
        }
        if (isset($_GET['listid'])) {
            //Wenn Variable gefüllt ist...
            $ListID = intval($_GET['listid']);
            // Das hier muss ne Zahl sein
            $bDoItNow = true;
            // Und ist auch true wenn $ListID vorhanden ist
        }
        if ($bDoItNow == true) {
            // Wenn True dann mach hier weiter
            switch ($TheCommand) {
                case 'cancel':
                    // Bricht den aktuell laufenden Auftrag ab
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    // Entfernt ein wartendes Element aus der Bauschleife
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    // Fügt ein Element zur Bauschleife hinzu
                    if ($Element == 31) {
                        if ($CurrentUser["b_tech_planet"] == 0 || $game_config['BuildLabWhileRun'] == 1) {
                            AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                        }
                    } else {
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    }
                    break;
                case 'destroy':
                    // Baut ein Gebäude eine Stufe ab
                    if ($Element == 31) {
                        if ($CurrentUser["b_tech_planet"] == 0 || $game_config['BuildLabWhileRun'] == 1) {
                            AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                        }
                    } else {
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                    }
                    break;
                default:
                    break;
            }
        }
        header('Location: ?action=internalBuildings');
        //Nach nem Klick Weiterleitung auf die Bauseite um Doppelklicke zu vermeiden
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // Änderungen in den Planeten Rekorden übernehmen
    BuildingSavePlanetRecord($CurrentPlanet);
    // Änderungen in den Userrekorden übernehmen
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        //Solange noch Platz in der Bauischleife ist...
        $CanBuildElement = true;
        // ...kann man bauen
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $ElementBuildTimeWithoutTechs = GetBuildingTimeWithoutTechs($CurrentUser, $CurrentPlanet, $Element);
                //Bauzeiten parsen
                $parse['timewithouttechs'] = ShowBuildTimeWithoutTechs($ElementBuildTimeWithoutTechs);
                $parse['technobonus'] = ShowBuildTime($ElementBuildTimeWithoutTechs - $ElementBuildTime);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                //Sprachvariablen für die Bauzeit laden
                $parse['BuildingTime'] = $lang['BuildingTime'];
                $parse['NeededRess'] = $lang['NeededRess'];
                $parse['ConstructionTimeWithoutTechs'] = $lang['ConstructionTimeWithoutTechs'];
                $parse['TechBonus'] = $lang['TechBonus'];
                $parse['ConstructionTime'] = $lang['ConstructionTime'];
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Sonderstatus fürs FOrschungslabor
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Config Einstellung die das Forschen während des Ausbaus erlaubt
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;building=" . $Element . "\"><font color=\"#00FF00\">" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;building=" . $Element . "\"><font color=\"#00FF00\">" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;building=" . $Element . "\"><font color=\"#00FF00\">" . $lang['InBuildQueue'] . "</font></a>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=\"#FF0000\">" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("?action=internalBuildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
Esempio n. 12
0
 public function ShowBuildingsPage(&$CurrentPlanet, $CurrentUser)
 {
     global $ProdGrid, $lang, $resource, $reslist, $phpEx, $db, $svn_root, $displays;
     include_once $svn_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $svn_root . 'includes/functions/GetElementPrice.' . $phpEx;
     $displays->assignContent('buildings/buildings_building');
     CheckPlanetUsedFields($CurrentPlanet);
     $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44, 45);
     $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
     if (isset($_GET['cmd'])) {
         $bDoItNow = false;
         $TheCommand = $_GET['cmd'];
         $Element = $_GET['building'];
         $ListID = $_GET['listid'];
         if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
             unset($Element);
         }
         if (isset($Element)) {
             if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
                 if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                     $bDoItNow = true;
                 }
             } else {
                 header("location:game.php?page=buildings");
             }
         } elseif (isset($ListID)) {
             $bDoItNow = true;
         }
         if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
             $bDoItNow = false;
         }
         if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
             $bDoItNow = false;
         }
         if ($bDoItNow == true) {
             switch ($TheCommand) {
                 case 'cancel':
                     $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                     break;
                 case 'remove':
                     $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                     break;
                 case 'insert':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                     break;
                 case 'destroy':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                     break;
             }
             header("location:game.php?page=buildings");
         }
     }
     SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
     $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser);
     $this->BuildingSavePlanetRecord($CurrentPlanet);
     if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
         $CanBuildElement = true;
     } else {
         $CanBuildElement = false;
     }
     $siguiente = 1;
     foreach ($reslist['build'] as $Element) {
         if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
             $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
             if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                 $RoomIsOk = true;
             } else {
                 $RoomIsOk = false;
             }
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                 $displays->newblock('build');
                 $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                 $parse['i'] = $Element;
                 $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                 $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
                 $parse['n'] = $lang['tech'][$Element];
                 $parse['descriptionss'] = $lang['res']['descriptions'][$Element];
                 $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 $parse['time'] = ShowBuildTime($ElementBuildTime);
                 $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                 $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                 if ($RoomIsOk && $CanBuildElement) {
                     if ($Queue['lenght'] == 0) {
                         if ($NextBuildLevel == 1) {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                             }
                         } else {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                             }
                         }
                     } else {
                         $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>";
                     }
                 } elseif ($RoomIsOk && !$CanBuildElement) {
                     if ($NextBuildLevel == 1) {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                     } else {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                     }
                 } else {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>";
                 }
                 if ($siguiente % 3 == 0) {
                     $parse['cerrar'] = "</tr><tr>";
                 }
                 $siguiente++;
                 if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 foreach ($parse as $name => $trans) {
                     $displays->assign($name, $trans);
                 }
                 unset($parse);
             }
         }
     }
     if ($Queue['lenght'] > 0) {
         include $svn_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
         $parse['BuildListScript'] = InsertBuildListScript("buildings");
         $parse['BuildList'] = $Queue['buildlist'];
         $parse['ScriptList'] = $Queue['scriptlist'];
     } else {
         $parse['BuildListScript'] = "";
         $parse['BuildList'] = "";
     }
     $displays->gotoBlock("_ROOT");
     $displays->assign("planet_field_current", $CurrentPlanet['field_current']);
     $displays->assign("planet_field_max", CalculateMaxPlanetFields($CurrentPlanet));
     $displays->assign("BuildListScript", $parse['BuildListScript']);
     $displays->assign("BuildList", $Queue['buildlist']);
     $displays->assign("ScriptList", $Queue['scriptlist']);
     $displays->assign("time_time", time() * 1000);
     $displays->display('Construcciones');
 }
Esempio n. 13
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user, $resource;
    include_once $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx;
    include_once $xgp_root . 'includes/functions/CheckPlanetUsedFields.' . $phpEx;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . intval($CurrentPlanet['id_owner']) . "' AND `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND  `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type`='3'", 'planets', true);
    if (empty($lunarow)) {
        unset($lunarow);
    }
    CheckPlanetUsedFields($lunarow);
    $parse = $lang;
    $parse['id'] = $user['id'];
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    $parse['dpath'] = $dpath;
    $parse['avatar'] = $user['avatar'];
    $QueryStat = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `stat_type` = '1'", "statpoints", true);
    $parse['puntos_defensa'] = pretty_number($QueryStat['defs_count']);
    $parse['puntos_edificios'] = pretty_number($QueryStat['build_points']);
    $parse['puntos_naves'] = pretty_number($QueryStat['fleet_count']);
    $parse['puntos_investigaciones'] = pretty_number($QueryStat['tech_count']);
    $StatRecord = doquery("SELECT `total_rank`,`total_points`,`defs_rank`,`build_rank`,`fleet_rank`,`tech_rank` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
    $parse['top_defensa'] = $StatRecord['defs_rank'];
    $parse['top_edificios'] = $StatRecord['build_rank'];
    $parse['top_naves'] = $StatRecord['fleet_rank'];
    $parse['top_investigaciones'] = $StatRecord['tech_rank'];
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . intval($CurrentUser['current_planet']) . "' LIMIT 1;", "planets");
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
            } elseif (intval($_POST['kolonieloeschen']) == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_owner = '" . intval($user['id']) . "' AND fleet_start_galaxy='" . intval($CurrentPlanet['galaxy']) . "' AND fleet_start_system='" . intval($CurrentPlanet['system']) . "' AND fleet_start_planet='" . intval($CurrentPlanet['planet']) . "'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $harabeyeri = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_target_owner = '" . intval($user['id']) . "' AND fleet_end_galaxy='" . intval($CurrentPlanet['galaxy']) . "' AND fleet_end_system='" . intval($CurrentPlanet['system']) . "' AND fleet_end_planet='" . intval($CurrentPlanet['planet']) . "'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $gezoay = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                if ($kendifilo > 0) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($digerfilo > 0 && $mess < 1 && $gezoay != 2) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                        doquery("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "' WHERE `id` = '" . intval($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                        doquery("UPDATE {{table}} SET `current_planet` = `id_planet` WHERE `id` = '" . intval($CurrentUser['id']) . "' LIMIT 1", "users");
                        doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type` = 3;", 'planets');
                        message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                    } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                        message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                    } else {
                        message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                    }
                }
            }
            return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
            break;
        default:
            $CONSULTA = doquery("SELECT metal,crystal FROM {{table}} WHERE galaxy = '" . $CurrentPlanet['galaxy'] . "' AND system = '" . $CurrentPlanet['system'] . "' AND planet = '" . $CurrentPlanet['planet'] . "'", "galaxy", true);
            $parse['metal_debris'] = pretty_number($CONSULTA['metal']);
            $parse['crystal_debris'] = pretty_number($CONSULTA['crystal']);
            if ($CurrentPlanet['recycler'] != 0 && ($CONSULTA['metal'] != 0 || $CONSULTA['crystal'] != 0)) {
                $parse['get_link'] = " (<a href=\"game.php?page=galaxy&mode=8&g=" . $CurrentPlanet['galaxy'] . "&s=" . $CurrentPlanet['system'] . "&p=" . $CurrentPlanet['planet'] . "&t=2\"> DF </a>)";
            } else {
                $parse['get_link'] = '';
            }
            if ($CurrentUser['new_message'] != 0) {
                $Have_new_message .= "<tr>";
                if ($CurrentUser['new_message'] == 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>" . $lang['ov_have_new_message'] . "</a></th>";
                } elseif ($CurrentUser['new_message'] > 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>";
                    $Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
                    $Have_new_message .= "</a></th>";
                }
                $Have_new_message .= "</tr>";
            }
            $OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets');
            $Record = 0;
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                /////// // ### LUCKY , CODES ARE BELOW
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                //////
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
                /**fix fleet table return by jstar**/
                if ($FleetRow['fleet_mission'] == 4 && $StartTime < time() && $EndTime > time()) {
                    $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, "fjstar", $Record);
                }
                /**end fix**/
            }
            mysql_free_result($OwnFleets);
            //iss ye katilan filo////////////////////////////////////
            // ### LUCKY , CODES ARE BELOW
            $dostfilo = doquery("SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = '" . intval($hedefgalaksi) . "' AND `fleet_end_system` = '" . intval($hedefsistem) . "' AND `fleet_end_planet` = '" . intval($hedefgezegen) . "' AND `fleet_group` = '" . intval($filogrubu) . "';", 'fleets');
            $Record1 = 0;
            while ($FleetRow = mysql_fetch_array($dostfilo)) {
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                ///////
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                ///////
                if ($FleetRow['fleet_mission'] == 2 && $FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    $Record1++;
                    //		if (($FleetRow['fleet_mission'] == 2) ){
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record1);
                    }
                    //	}
                }
                ///""
                if ($FleetRow['fleet_mission'] == 1 && $FleetRow['fleet_owner'] != $CurrentUser['id'] && $filogrubu > 0) {
                    $Record++;
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                    }
                }
            }
            mysql_free_result($dostfilo);
            //
            //////////////////////////////////////////////////
            //nome da aliança
            $ally_id = $user['ally_id'];
            if ($ally_id) {
                $allydata = doquery("SELECT `ally_name` FROM {{table}} WHERE `id` = '" . $ally_id . "'", "alliance", true);
                if ($allydata['ally_name'] != '') {
                    $parse['ally_name'] = $allydata['ally_name'];
                } else {
                    $parse['ally_name'] = "You dont have any alliance";
                }
            } else {
                $parse['ally_name'] = "You dont have any alliance";
            }
            //////////////////////////////////////////////////
            //Administración overview
            $OnlineAdmins = doquery("SELECT * FROM {{table}} WHERE onlinetime>='" . (time() - 10 * 60) . "' AND authlevel>=1", 'users');
            if ($OnlineAdmins) {
                $parse['OnlineAdmins'] = "";
                while ($oas = mysql_fetch_array($OnlineAdmins)) {
                    $parse['OnlineAdmins'] .= "<a href=\"game.php?page=messages&mode=write&id=" . $oas['id'] . "\" >" . $oas['username'] . "</a>&nbsp;&bull;&nbsp;";
                }
                if ($parse['OnlineAdmins'] == "") {
                    $parse['OnlineAdmins'] = "--";
                }
            }
            //Administración overview
            $OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        $id = $FleetRow['fleet_id'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            mysql_free_result($OtherFleets);
            $planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='" . intval($CurrentUser['id']) . "' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $AllPlanets = "<tr>";
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".jpg\" height=\"50\" width=\"50\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Colone <= 9) {
                        $Colone++;
                    } else {
                        $AllPlanets .= "</tr><tr>";
                        $Colone = 0;
                    }
                }
            }
            mysql_free_result($planets_query);
            $AllPlanets .= "</tr>";
            if ($game_config['OverviewNewsFrame'] == '1') {
                $parse['NewsFrame'] = "<tr>" . $lang['ov_news_title'] . "<th colspan=\"4\">" . stripslashes($game_config['OverviewNewsText']) . "</th></tr>";
            }
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type` = '3'", 'planets', true);
                    $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/" . $moon['image'] . ".jpg\" height=\"50\" width=\"50\"></a>";
                    $parse['moon'] = $moon['name'] . " (" . $lang['fcm_moon'] . ")";
                } else {
                    $parse['moon_img'] = "";
                    $parse['moon'] = "";
                }
            } else {
                $parse['moon_img'] = "";
                $parse['moon'] = "";
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            // Gouvernement
            $staatsform = $user['staatsform'];
            if ($staatsform == 2) {
                $parse['STAATSFORM_LINK'] = "\r\n<tr><center>\r\n    <th colspan=\"2\">Forma de gobierno:</th>\r\n    <th colspan=\"2\"><a href=\"game.php?page=gouv\" accesskey=\"d\" style=\"font-size:100%\">" . $lang['demokratie'] . "</a></th>\r\n</tr>";
            } elseif ($staatsform == 3) {
                $parse['STAATSFORM_LINK'] = "\r\n<tr><center>\r\n    <th colspan=\"2\">Forma de gobierno:</th>\r\n    <th colspan=\"2\"><a href=\"game.php?page=gouv\" accesskey=\"d\" style=\"font-size:100%\">" . $lang['monarchie'] . "</a></th>\r\n</tr>";
            } elseif ($staatsform == 4) {
                $parse['STAATSFORM_LINK'] = "\r\n<tr><center>\r\n    <th colspan=\"2\">Forma de gobierno:</th>\r\n    <th colspan=\"2\"><a href=\"game.php?page=gouv\" accesskey=\"d\" style=\"font-size:100%\">" . $lang['diktatur'] . "</a></th>\r\n</tr>";
            } elseif ($staatsform == 5) {
                $parse['STAATSFORM_LINK'] = "\r\n<tr><center>\r\n    <th colspan=\"2\">Forma de gobierno:</th>\r\n    <th colspan=\"2\"><a href=\"game.php?page=gouv\" accesskey=\"d\" style=\"font-size:100%\">" . $lang['imperialisme'] . "</a></th>\r\n</tr>";
            } elseif ($staatsform == 6) {
                $parse['STAATSFORM_LINK'] = "\r\n<tr><center>\r\n    <th colspan=\"2\">Forma de gobierno:</th>\r\n    <th colspan=\"2\"><a href=\"game.php?page=gouv\" accesskey=\"d\" style=\"font-size:100%\">" . $lang['aristocratie'] . "</a></th>\r\n</tr>";
            } else {
                $parse['STAATSFORM_LINK'] = "\r\n<tr><center>\r\n    <th colspan=\"2\">Forma de gobierno:</th>\r\n    <th colspan=\"2\"><a href=\"game.php?page=gouv\" accesskey=\"d\" style=\"font-size:100%\">" . $lang['barbarisch'] . "</a></th>\r\n</tr>";
            }
            if ($user['humano'] == 1) {
                $parse['race'] = 'Raza: Humano';
                $parse['imgrace'] = 'images/human.gif';
            } else {
                if ($user['vampiro'] == 1) {
                    $parse['race'] = 'Raza: Vampiro';
                    $parse['imgrace'] = 'images/vampiro.gif';
                } else {
                    if ($user['lobo'] == 1) {
                        $parse['race'] = 'Raza : Lobo';
                        $parse['imgrace'] = 'images/lobo.gif';
                    } else {
                        if ($user['asgard'] == 1) {
                            $parse['race'] = 'Raza : Asgard';
                            $parse['imgrace'] = 'images/asgard.gif';
                        }
                    }
                }
            }
            $StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($CurrentUser['id']) . "';", 'statpoints', true);
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            // **** INICIA MOD {MOSTRAR TECNOLOGIA EN PROCESO EN VISTA GENERAL} ****
            if ($CurrentPlanet['b_building'] != 0) {
                include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("buildings");
                    $Build .= "<table>";
                    $Build .= "    <tr>";
                    $Build .= "        <td colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</td>";
                    $Build .= "    </tr>";
                    $Build .= "    <tr>";
                    $Build .= "        <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"></td>";
                    $Build .= "        <td>" . $lang['pr_subiendo'] . " <span style=\"color:#FF8C00;\">Nivel " . $CurrBuild[1] . "</span><br />";
                    $Build .= "            " . $lang['pr_duracion'] . ":<div id=\"blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                    $Build .= "        </td>";
                    $Build .= "    </tr>";
                    $Build .= "</Table>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n    pp = \"" . $RestTime . "\";\n";
                    $Build .= "\n    pk = \"" . 1 . "\";\n";
                    $Build .= "\n    pm = \"cancel\";\n";
                    $Build .= "\n    pl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n    t();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            $PlanetaQueInv = doquery("SELECT id, name, b_tech, b_tech_id FROM `{{table}}` WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `b_tech` != '0';", 'planets', true);
            if ($PlanetaQueInv['b_tech'] != 0) {
                include $xgp_root . 'includes/functions/InsertTechListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $NvlActual = $CurrentUser[$resource[$PlanetaQueInv['b_tech_id']]] + 1;
                $RestTime = $PlanetaQueInv['b_tech'] - time();
                $PlanetID = $PlanetaQueInv['id'];
                $NomPlaneta = "";
                if ($PlanetaQueInv['name'] != $CurrentPlanet['name']) {
                    $NomPlaneta = " de " . $PlanetaQueInv['name'];
                }
                $Tech = InsertTechListScript("buildings", $NomPlaneta);
                $Tech .= "<table>";
                $Tech .= "    <tr>";
                $Tech .= "        <td colspan=\"2\">" . $lang['tech'][$PlanetaQueInv['b_tech_id']] . "</td>";
                $Tech .= "    </tr>";
                $Tech .= "    <tr>";
                $Tech .= "        <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $PlanetaQueInv['b_tech_id'] . ".gif\" width=\"40\" height=\"40\"></td>";
                $Tech .= "        <td>" . $lang['pr_investigando'] . " <span style=\"color:#FF8C00;\">Nivel " . $NvlActual . "</span><br />";
                $Tech .= "            " . $lang['pr_duracion'] . ":<div id=\"tec_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Tech .= "        </td>";
                $Tech .= "    </tr>";
                $Tech .= "</Table>";
                $Tech .= "\n<script language=\"JavaScript\">";
                $Tech .= "\n    tec_pp = \"" . $RestTime . "\";\n";
                $Tech .= "\n    tec_pk = \"" . 1 . "\";\n";
                $Tech .= "\n    tec_pm = \"cancel\";\n";
                $Tech .= "\n    tec_pl = \"" . $PlanetaQueInv['b_tech_id'] . "\";\n";
                $Tech .= "\n    tec_t();\n";
                $Tech .= "\n</script>\n";
                $parse['tech_en_proceso'] .= $Tech;
            } else {
                $parse['tech_en_proceso'] = $lang['ov_free'];
            }
            if ($CurrentPlanet['b_hangar'] != 0) {
                include $xgp_root . 'includes/functions/InsertHangarListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $BuildQueue = explode(";", $CurrentPlanet['b_hangar_id']);
                $CurrBuild = explode(",", $BuildQueue[0]);
                $RealTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $CurrBuild[0]);
                $QueueTime = $RealTime * $CurrBuild[1];
                $RestTime = $QueueTime - $CurrentPlanet['b_hangar'];
                $PlanetID = $CurrentPlanet['id'];
                $Hangar = InsertHangarListScript("overview");
                $Hangar .= "<table>";
                $Hangar .= "    <tr>";
                $Hangar .= "        <td colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</td>";
                $Hangar .= "    </tr>";
                $Hangar .= "    <tr>";
                $Hangar .= "        <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"><br />";
                $Hangar .= "        </td>";
                $Hangar .= "        <td>" . $lang['pr_tiempo_prod'] . "<br />";
                $Hangar .= "            <div id=\"han_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Hangar .= "        </td>";
                $Hangar .= "    </tr>";
                $Hangar .= "</Table>";
                $Hangar .= "\n<script language=\"JavaScript\">";
                $Hangar .= "\n    han_pp = \"" . $RestTime . "\";\n";
                $Hangar .= "\n    han_pk = \"" . 1 . "\";\n";
                $Hangar .= "\n    han_pm = \"cancel\";\n";
                $Hangar .= "\n    han_pl = \"" . $PlanetID . "\";\n";
                $Hangar .= "\n    han_t();\n";
                $Hangar .= "\n</script>\n";
                $parse['hangar_en_proceso'] .= $Hangar;
            } else {
                $parse['hangar_en_proceso'] = $lang['ov_free'];
            }
            $parse['overview_produccion'] = parsetemplate(gettemplate('overview/overview_produccion'), $parse);
            // **** FIN MOD {MOSTRAR TECNOLOGIA EN PROCESO EN VISTA GENERAL} ****
            $parse['fleet_list'] = $flotten;
            $parse['Have_new_message'] = $Have_new_message;
            $parse['planet_image'] = $CurrentPlanet['image'];
            $parse['anothers_planets'] = $AllPlanets;
            $parse["dpath"] = $dpath;
            if ($game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } elseif ($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            $parse['date_time'] = date("D M j H:i:s", time());
            // Rajout d'une barre pourcentage
            // Calcul du pourcentage de remplissage
            $parse['case_pourcentage'] = floor($planetrow["field_current"] / CalculateMaxPlanetFields($planetrow) * 100) . $lang['o/o'];
            // Barre de remplissage
            $parse['case_barre'] = floor($planetrow["field_current"] / CalculateMaxPlanetFields($planetrow) * 101) * 4.1;
            // Couleur de la barre de remplissage
            if ($parse['case_barre'] > 100 * 4.0) {
                $parse['case_barre'] = 400;
                $parse['case_barre_barcolor'] = '#C00000';
            } elseif ($parse['case_barre'] > 80 * 4.0) {
                $parse['case_barre_barcolor'] = '#C0C000';
            } else {
                $parse['case_barre_barcolor'] = '#00C000';
            }
            if ($StatRecord['total_points'] >= 0 && $StatRecord['total_points'] < 100000) {
                $parse['rankgame'] = "Soldado";
                $parse['rankimg'] = "rank1.gif";
            } elseif ($StatRecord['total_points'] >= 100000 && $StatRecord['total_points'] < 250000) {
                $parse['rankgame'] = "Cabo Cazador";
                $parse['rankimg'] = "rank2.gif";
            } elseif ($StatRecord['total_points'] >= 250000 && $StatRecord['total_points'] < 500000) {
                $parse['rankgame'] = "Sargento Cazador";
                $parse['rankimg'] = "rank3.gif";
            } elseif ($StatRecord['total_points'] >= 500000 && $StatRecord['total_points'] < 1000000) {
                $parse['rankgame'] = "Teniente de Crucero";
                $parse['rankimg'] = "rank4.gif";
            } elseif ($StatRecord['total_points'] >= 1000000 && $StatRecord['total_points'] < 2500000) {
                $parse['rankgame'] = "Capitán Destructor";
                $parse['rankimg'] = "rank5.gif";
            } elseif ($StatRecord['total_points'] >= 2500000 && $StatRecord['total_points'] < 5000000) {
                $parse['rankgame'] = "Almirante Acorazado";
                $parse['rankimg'] = "rank6.gif";
            } elseif ($StatRecord['total_points'] >= 5000000 && $StatRecord['total_points'] < 10000000) {
                $parse['rankgame'] = "General Estrella";
                $parse['rankimg'] = "rank7.gif";
            } elseif ($StatRecord['total_points'] >= 10000000 && $StatRecord['total_points'] < 25000000) {
                $parse['rankgame'] = "General Supernova";
                $parse['rankimg'] = "rank8.gif";
            } elseif ($StatRecord['total_points'] >= 25000000 && $StatRecord['total_points'] < 50000000) {
                $parse['rankgame'] = "General de Flota";
                $parse['rankimg'] = "rank9.gif";
            } elseif ($StatRecord['total_points'] >= 50000000 && $StatRecord['total_points'] < 100000000) {
                $parse['rankgame'] = "General Interestelar";
                $parse['rankimg'] = "rank10.gif";
            } elseif ($StatRecord['total_points'] >= 100000000 && $StatRecord['total_points'] < 500000000) {
                $parse['rankgame'] = "Cónsul General";
                $parse['rankimg'] = "rank11.gif";
            } elseif ($StatRecord['total_points'] >= 500000000) {
                $parse['rankgame'] = "Emperador";
                $parse['rankimg'] = "rank12.gif";
            }
            return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
            break;
    }
}
Esempio n. 14
0
 public function __construct(&$CurrentPlanet, $CurrentUser)
 {
     global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
     include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
     CheckPlanetUsedFields($CurrentPlanet);
     $parse = $lang;
     $Allowed['1'] = array(1, 2, 3, 4, 5, 12, 14, 15, 21, 22, 23, 24, 25, 31, 33, 34, 35, 44, 45);
     $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 25, 34, 41, 42, 43);
     if (isset($_GET['cmd'])) {
         $bDoItNow = false;
         $TheCommand = $_GET['cmd'];
         $Element = $_GET['building'];
         $ListID = $_GET['listid'];
         if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
             unset($Element);
         }
         if (isset($Element)) {
             if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
                 if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                     $bDoItNow = true;
                 }
             } else {
                 header("location:game.php?page=buildings");
             }
         } elseif (isset($ListID)) {
             $bDoItNow = true;
         }
         if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
             $bDoItNow = false;
         }
         if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
             $bDoItNow = false;
         }
         if ($bDoItNow == true) {
             switch ($TheCommand) {
                 case 'cancel':
                     $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                     break;
                 case 'remove':
                     $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                     break;
                 case 'insert':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                     break;
                 case 'destroy':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                     break;
             }
         }
         if ($_GET['r'] == 'overview') {
             header('location:game.php?page=overview');
         } else {
             header("Location: game.php?page=buildings&mode=buildings");
         }
     }
     SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
     if (empty($CurrentPlanet['b_building_id'])) {
         $CurrentPlanetID = intval($CurrentPlanet['id']);
         doquery("UPDATE {{table}} SET `b_building_id` = '0', `b_building` = '0' WHERE `id` = '{$CurrentPlanetID}';", 'planets');
         $CurrentPlanet['b_building_id'] = "0";
         $CurrentPlanet['b_building'] = 0;
     }
     $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser);
     $this->BuildingSavePlanetRecord($CurrentPlanet);
     if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
         $CanBuildElement = true;
     } else {
         $CanBuildElement = false;
     }
     $BuildingPage = "";
     $zaehler = 1;
     foreach ($lang['tech'] as $Element => $ElementName) {
         if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
             $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
             if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                 $RoomIsOk = true;
             } else {
                 $RoomIsOk = false;
             }
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                 $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                 $parse = array();
                 $parse = $lang;
                 $parse['dpath'] = $dpath;
                 $parse['i'] = $Element;
                 $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                 $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
                 $BuildLevelFactor = 10;
                 $BuildTemp = $CurrentPlanet['temp_max'];
                 $CurrentBuildtLvl = $BuildingLevel;
                 $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
                 $EnergyTechLevel = $CurrentUser["energy_tech"];
                 $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                 $ActualNeed = floor($Prod[4]);
                 $BuildLevel++;
                 $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                 $EnergyNeed = colorNumber(pretty_number(floor($Prod[4] - $ActualNeed)));
                 if ($Element >= 1 && $Element <= 3 or $Element == 5) {
                     $parse['energy'] = "&nbsp;<font color=#FF0000>" . $EnergyNeed . "</font>";
                     $BuildLevel = 0;
                 } elseif ($Element == 4 || $Element == 12) {
                     $parse['energy'] = "&nbsp;<font color=#00FF00>+" . $EnergyNeed . "</font>";
                     $BuildLevel = 0;
                 }
                 $parse['n'] = $ElementName;
                 $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                 $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 $parse['time'] = ShowBuildTime($ElementBuildTime);
                 $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                 $parse['click'] = '';
                 $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                 if ($RoomIsOk && $CanBuildElement) {
                     if ($Queue['lenght'] == 0) {
                         if ($NextBuildLevel == 1) {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                             }
                         } else {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                             }
                         }
                     } else {
                         if ($HaveRessources == true) {
                             $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>";
                         } else {
                             $parse['click'] = "<font color=#FF0000>" . $lang['bd_add_to_list'] . "</font>";
                         }
                     }
                 } elseif ($RoomIsOk && !$CanBuildElement) {
                     if ($NextBuildLevel == 1) {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                     } else {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                     }
                 } else {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>";
                 }
                 if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse);
             }
         }
     }
     if ($Queue['lenght'] > 0) {
         include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
         $parse['BuildListScript'] = InsertBuildListScript("buildings");
         $parse['BuildList'] = $Queue['buildlist'];
     } else {
         $parse['BuildListScript'] = "";
         $parse['BuildList'] = "";
     }
     $parse['BuildingsList'] = $BuildingPage;
     display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse));
 }
Esempio n. 15
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user;
    include_once $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx;
    $parse = $lang;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentPlanet['id_owner'] . "' AND `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `lunapos` = '" . $CurrentPlanet['planet'] . "';", 'lunas', true);
    CheckPlanetUsedFields($lunarow);
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . $CurrentUser['current_planet'] . "' LIMIT 1;", "planets");
                    if ($CurrentPlanet['planet_type'] == 3) {
                        doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `lunapos` = '" . $CurrentPlanet['planet'] . "' LIMIT 1;", "lunas");
                    }
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
            } elseif ($_POST['kolonieloeschen'] == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                    doquery("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "' WHERE `id` = '" . mysql_real_escape_string($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                    doquery("UPDATE {{table}} SET `current_planet` = `id_planet` WHERE `id` = '" . mysql_real_escape_string($CurrentUser['id']) . "' LIMIT 1", "users");
                    doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = 3;", 'planets');
                    doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `lunapos` = '" . $CurrentPlanet['planet'] . "';", 'lunas');
                    message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                    message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                }
            }
            return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
            break;
        default:
            if ($game_config['ts_modon'] == 1) {
                include_once $xgp_root . 'includes/classes/class.cyts.' . $phpEx;
                $ts = new cyts();
                if ($ts->connect($game_config['ts_server'], $game_config['ts_tcpport'], $game_config['ts_udpport'], $game_config['ts_timeout'])) {
                    $tsdata = $ts->info_serverInfo();
                    $tsdata2 = $ts->info_globalInfo();
                    $maxusers = $tsdata["server_maxusers"];
                    $useronline = $tsdata["server_currentusers"];
                    $channels = $tsdata["server_currentchannels"];
                    $seconds = $tsdata["server_uptime"];
                    $os = $tsdata2["total_server_platform"];
                    $version = $tsdata2["total_server_version"];
                    $trafin = round($tsdata2["total_bytesreceived"] / 1024 / 1024, 2);
                    $trafout = round($tsdata2["total_bytessend"] / 1024 / 1024, 2);
                    $trafges = $trafin + $trafout;
                    $parse['ov_ts'] = "<tr><th>Teamspeak</th><th colspan=\"3\"><a href=\"teamspeak://" . $game_config['ts_server'] . ":" . $game_config['ts_udpport'] . "?username="******"\" alt=\"Teamspeak Connect\" name=\"Teamspeak Connect\">Connect</a> &bull; Online: " . $useronline . "/" . $maxusers . " &bull; Channels: " . $channels . " &bull; Traffic IN: " . $trafin . " MB &bull; Traffic Out: " . $trafout . " MB &bull; Traffic ges.: " . $trafges . " MB</th></tr>";
                } else {
                    $parse['ov_ts'] = "<tr><th>Teamspeak</th><th colspan=\"3\">Server zurzeit nicht erreichbar. Wir bitten um verst&auml;ndnis.</th></tr>";
                }
            }
            $OnlineAdmins = doquery("SELECT * FROM {{table}} WHERE onlinetime>='" . (time() - 10 * 60) . "' AND authlevel > 1", 'users');
            if ($OnlineAdmins) {
                $AdminsNr = 1;
                $parse['OnlineAdmins'] = "";
                while ($oas = mysql_fetch_array($OnlineAdmins)) {
                    if ($AdminsNr == 1) {
                        $parse['OnlineAdmins'] .= "<a href=\"game.php?page=messages&mode=write&id=" . $oas['id'] . "\" >" . $oas['username'] . "</a>";
                    } else {
                        $parse['OnlineAdmins'] .= "&nbsp;&bull;&nbsp;<a href=\"game.php?page=messages&mode=write&id=" . $oas['id'] . "\" >" . $oas['username'] . "</a>";
                    }
                    $AdminsNr++;
                }
            } else {
                $parse['OnlineAdmins'] = "-";
            }
            if ($CurrentUser['new_message'] != 0) {
                $Have_new_message .= "<tr>";
                if ($CurrentUser['new_message'] == 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>" . $lang['ov_have_new_message'] . "</a></th>";
                } elseif ($CurrentUser['new_message'] > 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>";
                    $Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
                    $Have_new_message .= "</a></th>";
                }
                $Have_new_message .= "</tr>";
            }
            $OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 0;
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
            }
            $OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            $planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='{$CurrentUser['id']}' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $AllPlanets = "<tr>";
            if ($game_config['OverviewNewsFrame'] == '1') {
                $parse['NewsFrame'] = "<tr><th>" . $lang['ov_news_title'] . "</th><th colspan=\"3\">" . stripslashes($game_config['OverviewNewsText']) . "</th></tr>";
            }
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".jpg\" height=\"50\" width=\"50\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Colone <= 1) {
                        $Colone++;
                    } else {
                        $AllPlanets .= "</tr><tr>";
                        $Colone = 1;
                    }
                }
            }
            $AllPlanets .= "</tr>";
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '3'", 'planets', true);
                    $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/" . $moon['image'] . ".jpg\" height=\"50\" width=\"50\"></a>";
                    $parse['moon'] = $moon['name'] . " (" . $lang['fcm_moon'] . ")";
                } else {
                    $parse['moon_img'] = "";
                    $parse['moon'] = "";
                }
            } else {
                $parse['moon_img'] = "";
                $parse['moon'] = "";
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            $StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            if ($CurrentPlanet['b_building'] != 0) {
                include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("overview");
                    $Build .= $lang['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')';
                    $Build .= "<br /><div id=\"blc\" class=\"z\">" . pretty_time($RestTime) . "</div>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n\tpp = \"" . $RestTime . "\";\n";
                    $Build .= "\n\tpk = \"" . 1 . "\";\n";
                    $Build .= "\n\tpm = \"cancel\";\n";
                    $Build .= "\n\tpl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n\tt();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            $parse['fleet_list'] = $flotten;
            $parse['Have_new_message'] = $Have_new_message;
            $parse['planet_image'] = $CurrentPlanet['image'];
            $parse['anothers_planets'] = $AllPlanets;
            $parse["dpath"] = $dpath;
            if ($game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } elseif ($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            $parse['date_time'] = date("D M j H:i:s", time());
            return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
            break;
    }
}