Example #1
0
function ShowPlanetMenu($CurrentUser)
{
    global $dpath, $lang;
    $planets = SortUserPlanets($CurrentUser);
    while ($p = mysql_fetch_array($planets)) {
        if ($p["destruyed"] == 0) {
            $ct = $p["field_max"] + $p["terraformer"] * FIELDS_BY_TERRAFORMER;
            if ($p['planet_type'] == 3) {
                $ct = $p["field_max"];
            }
            if ($p['b_building'] != 0) {
                UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                if ($p['b_building'] != 0) {
                    $BuildQueue = $p['b_building_id'];
                    $QueueArray = explode(";", $BuildQueue);
                    $CurrentBuild = explode(",", $QueueArray[0]);
                    $BuildElement = $CurrentBuild[0];
                    $BuildLevel = $CurrentBuild[1];
                    $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                    $construccion = "" . $lang['tech'][$BuildElement] . "<br>(Construyendo nivel " . $BuildLevel . ")<br>Tiempo restante:" . $BuildRestTime . "";
                } else {
                    CheckPlanetUsedFields($p);
                    $construccion = $lang['ov_free'];
                }
            } else {
                $construccion = $lang['ov_free'];
            }
            $popup = "" . $p['name'] . "&nbsp;[" . $p['galaxy'] . ":" . $p['system'] . ":" . $p['planet'] . "]<br>Campos&nbsp;ocupados:&nbsp;" . $p['field_current'] . "/" . $ct . "<br>" . $construccion . "";
            if ($t == 0) {
                $parse['mplanet'] .= "<th text-decoration:none>";
            }
            if ($p['planet_type'] == 1 && $p["id"] != $CurrentUser["current_planet"]) {
                $parse['mplanet'] .= "<div align=center><a class=mplanet href=game.php?page={$_GET['page']}&gid={$_GET['gid']}&cp=" . $p['id'] . "&mode=" . $_GET['mode'] . "&re=0 onmouseover=\"return overlib('" . $popup . "', CENTER, OFFSETX, -80, OFFSETY, 20, WIDTH, 200)\" onmouseout=\"return nd();\"><img src=" . $dpath . "/planeten/" . $p['image'] . ".jpg border=0 height=78 width=78><br><font color=#2E9AFE>" . $p['name'] . "&nbsp;</font><font color=#58FA58><br>[" . $p['galaxy'] . ":" . $p['system'] . ":" . $p['planet'] . "]</font></a>";
            } elseif ($p['planet_type'] == 3 && $p["id"] != $CurrentUser["current_planet"]) {
                $parse['mplanet'] .= "<div align=center><a class=mplanet href=game.php?page={$_GET['page']}&gid={$_GET['gid']}&cp=" . $p['id'] . "&mode=" . $_GET['mode'] . "&re=0 onmouseover=\"return overlib('" . $popup . "', CENTER, OFFSETX, -80, OFFSETY, 20, WIDTH, 200)\" onmouseout=\"return nd();\"><img src=" . $dpath . "/planeten/" . $p['image'] . ".jpg border=0 height=78 width=78><br>" . $p['name'] . " (Luna)&nbsp;<font color=#58FA58><br>[" . $p['galaxy'] . ":" . $p['system'] . ":" . $p['planet'] . "]</font></a>";
            } else {
                $parse['mplanet'] .= "<div align=center><a class=mplanet href=# onmouseover=\"return overlib('" . $popup . "', CENTER, OFFSETX, -80, OFFSETY, 20, WIDTH, 200)\" onmouseout=\"return nd();\"><img src=" . $dpath . "/planeten/" . $p['image'] . ".jpg border=0 height=78 width=78><br><font color=#FFFF00>" . $p['name'] . "&nbsp;</font><font color=#FE9A2E><br>[" . $p['galaxy'] . ":" . $p['system'] . ":" . $p['planet'] . "]</font></a></div>";
            }
            if ($t == 6) {
                $parse['mplanet'] .= "</th>";
                $t = 0;
            } else {
                $t = $t + 1;
            }
        }
    }
    $parse['mplanet'] .= "</center></table>";
    return parsetemplate(gettemplate('planet_menu'), $parse);
}
Example #2
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;
    }
}
 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));
 }
Example #4
0
 * overview.php
 * @Licence GNU (GPL)
 * @version 3.0
 * @copyright 2009
 * @Team Space Beginner
 *
 **/
define('INSIDE', true);
define('INSTALL', false);
$xnova_root_path = './';
include $xnova_root_path . 'extension.inc';
include $xnova_root_path . 'common.' . $phpEx;
includeLang('resources');
includeLang('menu_01/ubersicht');
$lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $planetrow['id_owner'] . "' AND `galaxy` = '" . $planetrow['galaxy'] . "' AND `system` = '" . $planetrow['system'] . "' AND `lunapos` = '" . $planetrow['planet'] . "';", 'lunas', true);
CheckPlanetUsedFields($lunarow);
$mode = $_GET['mode'];
$pl = mysql_escape_string($_GET['pl']);
$_POST['deleteid'] = intval($_POST['deleteid']);
if ($game_config['enable_bot'] == 1) {
    $multi = $user['multi_validated'];
    $ip = $user['user_lastip'];
    $time = time();
    $duree = $time + stripslashes($game_config['ban_duration']) * 86400;
    $op = stripslashes($game_config['bot_name']);
    $mail = stripslashes($game_config['bot_adress']);
    $sql = mysql_query("SELECT * FROM game_users WHERE `user_lastip`='{$ip}'");
    $boucle = 0;
    $username = '';
    $v = ',&nbsp;';
    while ($m = mysql_fetch_array($sql)) {
Example #5
0
/**
 * BuildRessourcePage.php
 *
 * @version 1.0
 * @copyright 2008 by ShadoV for XNova
 */
function BuildRessourcePage($CurrentUser, $CurrentPlanet)
{
    global $lang, $ProdGrid, $resource, $reslist, $game_config, $_POST;
    CheckPlanetUsedFields($CurrentPlanet);
    $RessBodyTPL = gettemplate('resources');
    $RessRowTPL = gettemplate('resources_row');
    // Si c'est une lune ... pas de ressources produites
    if ($CurrentPlanet['planet_type'] == 3) {
        $game_config['metal_basic_income'] = 0;
        $game_config['crystal_basic_income'] = 0;
        $game_config['deuterium_basic_income'] = 0;
    }
    $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
    $SubQry = "";
    if ($_POST) {
        foreach ($_POST as $Field => $Value) {
            $FieldName = $Field . "_porcent";
            if (isset($CurrentPlanet[$FieldName])) {
                if (!in_array($Value, $ValidList['percent'])) {
                    header("Location: ?action=internalHome");
                    exit;
                }
                $Values = $Value / 10;
                $CurrentPlanet[$FieldName] = $Values;
                $SubQry .= ", `" . $FieldName . "` = '" . $Values . "'";
            }
        }
    }
    $parse = $lang;
    $production_level = 100;
    if ($CurrentPlanet['energy_max'] == 0 && $CurrentPlanet['energy_used'] > 0) {
        $post_porcent = 0;
        if ($CurrentPlanet['energy_max'] > 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
            $post_porcent = floor($CurrentPlanet['energy_max'] / abs($CurrentPlanet['energy_used']) * 100);
        } elseif ($CurrentPlanet['energy_max'] == 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
            $post_porcent = 0;
        }
    } else {
        $post_porcent = 100;
    }
    if ($post_porcent > 100) {
        $post_porcent = 100;
    }
    // -------------------------------------------------------------------------------------------------------
    // Mise a jour de l'espace de stockage
    $CurrentPlanet['metal_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[22]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    $CurrentPlanet['crystal_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[23]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    $CurrentPlanet['deuterium_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[24]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    // -------------------------------------------------------------------------------------------------------
    $parse['resource_row'] = "";
    $CurrentPlanet['metal_perhour'] = 0;
    $CurrentPlanet['crystal_perhour'] = 0;
    $CurrentPlanet['deuterium_perhour'] = 0;
    $CurrentPlanet['energy_max'] = 0;
    $CurrentPlanet['energy_used'] = 0;
    $BuildTemp = $CurrentPlanet['temp_max'];
    foreach ($reslist['prod'] as $ProdID) {
        if ($CurrentPlanet[$resource[$ProdID]] > 0 && isset($ProdGrid[$ProdID])) {
            $BuildLevelFactor = $CurrentPlanet[$resource[$ProdID] . "_porcent"];
            $BuildLevel = $CurrentPlanet[$resource[$ProdID]];
            $metal = floor(eval($ProdGrid[$ProdID]['formule']['metal']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05));
            $crystal = floor(eval($ProdGrid[$ProdID]['formule']['crystal']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05));
            $deuterium = floor(eval($ProdGrid[$ProdID]['formule']['deuterium']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05));
            $energy = floor(eval($ProdGrid[$ProdID]['formule']['energy']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_ingenieur'] * 0.05));
            if ($energy > 0) {
                $CurrentPlanet['energy_max'] += $energy;
            } else {
                $CurrentPlanet['energy_used'] += $energy;
            }
            $CurrentPlanet['metal_perhour'] += $metal;
            $CurrentPlanet['crystal_perhour'] += $crystal;
            $CurrentPlanet['deuterium_perhour'] += $deuterium;
            $metal_ref = $metal * 0.01 * $post_porcent;
            $crystal_ref = $crystal * 0.01 * $post_porcent;
            $deuterium_ref = $deuterium * 0.01 * $post_porcent;
            $energy_ref = $energy;
            $Field = $resource[$ProdID] . "_porcent";
            $CurrRow = array();
            $CurrRow['name'] = $resource[$ProdID];
            $CurrRow['porcent'] = $CurrentPlanet[$Field];
            for ($Option = 10; $Option >= 0; $Option--) {
                $OptValue = $Option * 10;
                if ($Option == $CurrRow['porcent']) {
                    $OptSelected = " selected=selected";
                } else {
                    $OptSelected = "";
                }
                $CurrRow['option'] .= "<option value=\"" . $OptValue . "\"" . $OptSelected . ">" . $OptValue . "%</option>";
            }
            $CurrRow['type'] = $lang['tech'][$ProdID];
            $CurrRow['level'] = $ProdID > 200 ? $lang['quantity'] : $lang['level'];
            $CurrRow['level_type'] = $CurrentPlanet[$resource[$ProdID]];
            $metal_type = pretty_number(abs($metal_ref));
            $crystal_type = pretty_number(abs($crystal_ref));
            $deuterium_type = pretty_number(abs($deuterium_ref));
            $CurrRow['energy_type'] = pretty_number($energy_ref);
            $CurrRow['metal_type'] = colorNumber($metal_type);
            $CurrRow['crystal_type'] = colorNumber($crystal_type);
            $CurrRow['deuterium_type'] = colorNumber($deuterium_type);
            if (abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
                $CurrRow['energy_type'] = colorNumber($CurrRow['energy_type'] * -1);
            } elseif (abs($CurrentPlanet['energy_used']) > 0 && $CurrentPlanet['energy_max'] == 0) {
                $CurrRow['energy_type'] = colorNumber($CurrRow['energy_type'] * -1);
            } else {
                $CurrRow['energy_type'] = colorNumber($CurrRow['energy_type']);
            }
            if ($CurrRow['type'] == "M") {
                $CurrRow['energy_type'] = colorNumber($CurrRow['energy_type'] * -1);
            }
            $parse['resource_row'] .= parsetemplate($RessRowTPL, $CurrRow);
        }
    }
    $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $CurrentPlanet['name'], $lang['Production_of_resources_in_the_planet']);
    if ($CurrentPlanet['energy_max'] == 0 && $CurrentPlanet['energy_used'] > 0) {
        $production_level = 0;
    } elseif ($CurrentPlanet['energy_max'] > 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
        $production_level = floor($CurrentPlanet['energy_max'] / abs($CurrentPlanet['energy_used']) * 100);
    } elseif ($CurrentPlanet['energy_max'] == 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
        $production_level = 0;
    } else {
        $production_level = 100;
    }
    if ($production_level > 100) {
        $production_level = 100;
    }
    $parse['metal_basic_income'] = $game_config['metal_basic_income'] * $game_config['resource_multiplier'];
    $parse['crystal_basic_income'] = $game_config['crystal_basic_income'] * $game_config['resource_multiplier'];
    $parse['deuterium_basic_income'] = $game_config['deuterium_basic_income'] * $game_config['resource_multiplier'];
    $parse['energy_basic_income'] = $game_config['energy_basic_income'] * $game_config['resource_multiplier'];
    if ($CurrentPlanet['metal_max'] < $CurrentPlanet['metal']) {
        $parse['metal_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['metal_max'] = "<font color=\"#00ff00\">";
    }
    $parse['metal_max'] .= pretty_number($CurrentPlanet['metal_max'] / 1000) . " " . $lang['k'] . "</font>";
    if ($CurrentPlanet['crystal_max'] < $CurrentPlanet['crystal']) {
        $parse['crystal_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['crystal_max'] = "<font color=\"#00ff00\">";
    }
    $parse['crystal_max'] .= pretty_number($CurrentPlanet['crystal_max'] / 1000) . " " . $lang['k'] . "</font>";
    if ($CurrentPlanet['deuterium_max'] < $CurrentPlanet['deuterium']) {
        $parse['deuterium_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['deuterium_max'] = "<font color=\"#00ff00\">";
    }
    $parse['deuterium_max'] .= pretty_number($CurrentPlanet['deuterium_max'] / 1000) . " " . $lang['k'] . "</font>";
    $metal_total = abs(floor($CurrentPlanet['metal_perhour'] * 0.01 * $production_level)) + $parse['metal_basic_income'];
    $crystal_total = abs(floor($CurrentPlanet['crystal_perhour'] * 0.01 * $production_level)) + $parse['crystal_basic_income'];
    $deuterium_total = abs(floor($CurrentPlanet['deuterium_perhour'] * 0.01 * $production_level)) + $parse['deuterium_basic_income'];
    $parse['energy_total'] = colorNumber(pretty_number(floor($CurrentPlanet['energy_max'] + $parse['energy_basic_income'] + $CurrentPlanet['energy_used'])));
    $parse['metal_total'] = colorNumber(pretty_number($metal_total));
    $parse['crystal_total'] = colorNumber(pretty_number($crystal_total));
    $parse['deuterium_total'] = colorNumber(pretty_number($deuterium_total));
    $parse['daily_metal'] = colorNumber(pretty_number($metal_total * 24));
    $parse['weekly_metal'] = colorNumber(pretty_number($metal_total * 24 * 7));
    $parse['monthly_metal'] = colorNumber(pretty_number($metal_total * 24 * 30));
    $parse['daily_crystal'] = colorNumber(pretty_number($crystal_total * 24));
    $parse['weekly_crystal'] = colorNumber(pretty_number($crystal_total * 24 * 7));
    $parse['monthly_crystal'] = colorNumber(pretty_number($crystal_total * 24 * 30));
    $parse['daily_deuterium'] = colorNumber(pretty_number($deuterium_total * 24));
    $parse['weekly_deuterium'] = colorNumber(pretty_number($deuterium_total * 24 * 7));
    $parse['monthly_deuterium'] = colorNumber(pretty_number($deuterium_total * 24 * 30));
    $parse['metal_storage'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) . $lang['o/o'];
    $parse['crystal_storage'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100) . $lang['o/o'];
    $parse['deuterium_storage'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) . $lang['o/o'];
    $parse['metal_storage_bar'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100 * 2.5);
    $parse['crystal_storage_bar'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100 * 2.5);
    $parse['deuterium_storage_bar'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100 * 2.5);
    if ($parse['metal_storage_bar'] > 100 * 2.5) {
        $parse['metal_storage_bar'] = 250;
        $parse['metal_storage_barcolor'] = '#C00000';
    } elseif ($parse['metal_storage_bar'] > 80 * 2.5) {
        $parse['metal_storage_barcolor'] = '#C0C000';
    } else {
        $parse['metal_storage_barcolor'] = '#00C000';
    }
    if ($parse['crystal_storage_bar'] > 100 * 2.5) {
        $parse['crystal_storage_bar'] = 250;
        $parse['crystal_storage_barcolor'] = '#C00000';
    } elseif ($parse['crystal_storage_bar'] > 80 * 2.5) {
        $parse['crystal_storage_barcolor'] = '#C0C000';
    } else {
        $parse['crystal_storage_barcolor'] = '#00C000';
    }
    if ($parse['deuterium_storage_bar'] > 100 * 2.5) {
        $parse['deuterium_storage_bar'] = 250;
        $parse['deuterium_storage_barcolor'] = '#C00000';
    } elseif ($parse['deuterium_storage_bar'] > 80 * 2.5) {
        $parse['deuterium_storage_barcolor'] = '#C0C000';
    } else {
        $parse['deuterium_storage_barcolor'] = '#00C000';
    }
    $parse['production_level_bar'] = $production_level * 2.5;
    $parse['production_level'] = "{$production_level}%";
    $parse['production_level_barcolor'] = '#00ff00';
    $QryUpdatePlanet = "UPDATE {{table}} SET ";
    $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "' ";
    $QryUpdatePlanet .= $SubQry;
    $QryUpdatePlanet .= "WHERE ";
    $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';";
    doquery($QryUpdatePlanet, 'planets');
    $page = parsetemplate($RessBodyTPL, $parse);
    display($page, '');
}
Example #6
0
            $missiontype[5] = $lang['type_mission'][5];
        }
    } elseif ($_POST['ship209'] >= 1 || $_POST['ship208']) {
        $missiontype[3] = $lang['type_mission'][3];
    }
    if ($YourPlanet) {
        $missiontype[4] = $lang['type_mission'][4];
    }
    if ($_POST['planettype'] == 3 && ($_POST['ship214'] || $_POST['ship213']) && !$YourPlanet && $UsedPlanet) {
        $missiontype[2] = $lang['type_mission'][2];
    }
}
if (empty($missiontype[$fleetmission])) {
    message("<font color=\"red\"><b>" . $lang['fl_bad_mission'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
}
CheckPlanetUsedFields($CurrentPlanet);
if ($TargetPlanet['id_owner'] == '') {
    $HeDBRec = $MyDBRec;
} elseif ($TargetPlanet['id_owner'] != '') {
    $HeDBRec = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $TargetPlanet['id_owner'] . "';", 'users', true);
}
$UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $MyDBRec['id'] . "';", 'statpoints', true);
$User2Points = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';", 'statpoints', true);
$MyGameLevel = $UserPoints['total_points'];
$HeGameLevel = $User2Points['total_points'];
$VacationMode = $HeDBRec['urlaubs_modus'];
//假期模式
if ($user['authlevel'] < 1) {
    if ($MyGameLevel > $HeGameLevel * $protectionmulti and $TargetPlanet['id_owner'] != '' and $_POST['mission'] == 1 and $protection == 1 and $HeGameLevel < $protectiontime * 500) {
        message("<font color=\"lime\"><b>1." . $lang['fl_noob_mess_n'] . "</b></font>", $lang['fl_noob_title'], "fleet." . $phpEx, 2);
    }
Example #7
0
 function Play()
 {
     global $resource;
     $this->HandleOwnFleets();
     $iPlanetCount = doquery("SELECT count(*) AS `total` FROM {{table}} WHERE `id_owner` = '" . $this->user['id'] . "' AND `planet_type` = '1'", 'planets', true);
     $maxfleet = doquery("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '" . $this->user['id'] . "';", 'fleets', true);
     $maxcolofleet = doquery("SELECT COUNT(fleet_owner) AS `total` FROM {{table}} WHERE `fleet_owner` = '" . $this->user['id'] . "' AND `fleet_mission` = '7';", 'fleets', true);
     $MaxFlyingFleets = $maxfleet['actcnt'];
     $MaxFlottes = $this->user[$resource[108]];
     $planetselected = false;
     $planetwork = false;
     $planetquery = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $this->user['id'] . "' AND `planet_type` = '1' ORDER BY `id` ASC;", 'planets', false);
     while ($this->CurrentPlanet = $planetquery->fetch_array()) {
         if ($planetselected == true and $this->CurrentPlanet['id_owner'] == $this->user['id']) {
             CheckPlanetUsedFields($this->CurrentPlanet);
             if (!is_null($this->log)) {
                 $this->log .= $this->user['username'] . ' - Hora: ' . date('H:i:s - j/n/Y') . ' - Planeta: ' . $this->CurrentPlanet['name'] . ' [' . $this->CurrentPlanet['id'] . ']' . "\n";
             }
             $this->BuildStores();
             $Rand = mt_rand(0, 1);
             if ($Rand == 1 or $this->CurrentPlanet[$resource[4]] <= 5) {
                 $this->BuildBuildings();
             } else {
                 $this->BuildSpecialBuildings();
             }
             if ($this->CurrentPlanet[$resource[31]] > 0) {
                 $this->ResearchTechs();
             }
             $Rand = mt_rand(0, 1);
             if ($Rand == 1) {
                 $this->BuildFleet();
             } else {
                 $this->BuildDefense();
             }
             if ($iPlanetCount['total'] < MAX_PLAYER_PLANETS and $maxcolofleet['total'] < MAX_PLAYER_PLANETS - $maxcolofleet['total'] and $MaxFlyingFleets < $MaxFlottes and $this->CurrentPlanet[$resource[208]] >= 1) {
                 $this->Colonize($iPlanetCount['total']);
             }
             if ($this->CurrentPlanet['id'] == $this->user['id_planet']) {
                 if ($MaxFlyingFleets < $MaxFlottes + 1) {
                     $this->HandleOtherFleets();
                 }
             } elseif ($MaxFlyingFleets < $MaxFlottes) {
                 $this->GetFleet();
             }
             $this->Update();
             $planetselected = false;
             $planetwork = true;
             $planetid = $this->CurrentPlanet['id'];
         } else {
             if ($this->CurrentPlanet['id'] == $this->Bot['last_planet']) {
                 $planetselected = true;
             }
         }
     }
     if ($planetwork == false) {
         $this->CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $this->user['id_planet'] . "';", 'planets', true);
         CheckPlanetUsedFields($this->CurrentPlanet);
         if (!is_null($this->log)) {
             $this->log .= $this->user['username'] . ' - Hora: ' . date('H:i:s - j/n/Y') . ' - Planeta: ' . $this->CurrentPlanet['name'] . ' [' . $this->CurrentPlanet['id'] . ']' . "\n";
         }
         $this->BuildStores();
         $Rand = mt_rand(0, 1);
         if ($Rand == 1 or $this->CurrentPlanet[$resource[4]] <= 5) {
             $this->BuildBuildings();
         } else {
             $this->BuildSpecialBuildings();
         }
         if ($this->CurrentPlanet[$resource[31]] > 0) {
             $this->ResearchTechs();
         }
         $Rand = mt_rand(0, 1);
         if ($Rand == 1) {
             $this->BuildFleet();
         } else {
             $this->BuildDefense();
         }
         if ($iPlanetCount['total'] < MAX_PLAYER_PLANETS and $maxcolofleet['total'] < MAX_PLAYER_PLANETS - $maxcolofleet['total'] and $MaxFlyingFleets < $MaxFlottes and $this->CurrentPlanet[$resource[208]] >= 1) {
             $this->Colonize($iPlanetCount['total']);
         }
         if ($this->CurrentPlanet['id'] == $this->user['id_planet']) {
             if ($MaxFlyingFleets < $MaxFlottes + 1) {
                 $this->HandleOtherFleets();
             }
         } elseif ($MaxFlyingFleets < $MaxFlottes) {
             $this->GetFleet();
         }
         $this->Update();
         $planetid = $this->user['id_planet'];
     }
     $this->end_planet = $planetid;
 }
Example #8
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;
    }
}
Example #9
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']);
}
 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');
 }
Example #11
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;
    }
}
 public function __construct()
 {
     global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.' . PHP_EXT;
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.' . PHP_EXT;
     CheckPlanetUsedFields($PLANET);
     $TheCommand = request_var('cmd', '');
     $Element = request_var('building', 0);
     $ListID = request_var('listid', 0);
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     if (!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']]) && ($Element == 31 && $USER["b_tech_planet"] == 0 || $Element != 31) && (($Element == 15 || $Element == 21) && empty($PLANET['b_hangar_id']) || ($Element != 15 || $Element != 21))) || $TheCommand == "cancel" || $TheCommand == "remove") {
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue($PlanetRess);
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID, $PlanetRess);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
     }
     $PlanetRess->SavePlanetToDB();
     $Queue = $this->ShowBuildingQueue();
     $template = new template();
     $template->page_header();
     $template->page_topnav();
     $template->page_leftmenu();
     $template->page_planetmenu();
     $template->page_footer();
     $CanBuildElement = count($Queue) < MAX_BUILDING_QUEUE_SIZE ? true : false;
     $BuildingPage = "";
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET["field_current"] < $CurrentMaxFields - count($Queue) ? true : false;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     foreach ($reslist['allow'][$PLANET['planet_type']] as $ID => $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, false);
         if (in_array($Element, $reslist['prod'])) {
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + $USER['rpg_ingenieur'] * 0.05);
             $BuildLevel += 1;
             $Prod = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + $USER['rpg_ingenieur'] * 0.05);
             $EnergyNeed = $Prod - $Need;
         } else {
             unset($EnergyNeed);
         }
         $parse['click'] = '';
         $NextBuildLevel = $PLANET[$resource[$Element]] + 1;
         if ($RoomIsOk && $CanBuildElement) {
             $parse['click'] = $HaveRessources == true ? "<a href=\"game.php?page=buildings&amp;cmd=insert&amp;building=" . $Element . "\"><span style=\"color:#00FF00\">" . ($PLANET['b_building'] != 0 ? $LNG['bd_add_to_list'] : ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)) . "</span></a>" : "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>";
         } elseif ($RoomIsOk && !$CanBuildElement) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>";
         } else {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_no_more_fields'] . "</span>";
         }
         if ($Element == 31 && $USER['b_tech'] > TIMESTAMP) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>";
         } elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>";
         }
         $BuildInfoList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'level' => $PLANET[$resource[$Element]], 'destroyress' => array_map('pretty_number', GetBuildingPrice($USER, $PLANET, $Element, true, true)), 'destroytime' => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)), 'price' => GetElementPrice($USER, $PLANET, $Element, true), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'EnergyNeed' => isset($EnergyNeed) ? sprintf($EnergyNeed < 0 ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'], pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "", 'BuildLink' => $parse['click'], 'restprice' => $this->GetRestPrice($Element));
     }
     if ($PLANET['b_building'] != 0) {
         $template->execscript('ReBuildView();Buildlist();');
         $template->loadscript('buildlist.js');
         $template->assign_vars(array('data' => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue))));
     }
     $template->assign_vars(array('BuildInfoList' => $BuildInfoList, 'bd_lvl' => $LNG['bd_lvl'], 'bd_next_level' => $LNG['bd_next_level'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Darkmatter' => $LNG['Darkmatter'], 'bd_dismantle' => $LNG['bd_dismantle'], 'fgf_time' => $LNG['fgf_time'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_jump_gate_action' => $LNG['bd_jump_gate_action']));
     $template->show("buildings_overview.tpl");
 }
 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));
 }
Example #14
0
function ResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
{
    global $lang, $resource, $reslist, $pricelist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        $TheCommand = $_GET['cmd'];
        $Techno = idstring($_GET['tech']);
        if (is_numeric($Techno)) {
            if (in_array($Techno, $reslist['tech'])) {
                // Bon quand on arrive ici ... On sait deja qu'on a une technologie valide
                if (is_array($ThePlanet)) {
                    $WorkingPlanet = $ThePlanet;
                } else {
                    $WorkingPlanet = $CurrentPlanet;
                }
                switch ($TheCommand) {
                    case 'cancel':
                        if ($ThePlanet['b_tech_id'] == $Techno) {
                            $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                            $WorkingPlanet['metal'] += $costs['metal'];
                            $WorkingPlanet['crystal'] += $costs['crystal'];
                            $WorkingPlanet['deuterium'] += $costs['deuterium'];
                            $WorkingPlanet['b_tech_id'] = 0;
                            $WorkingPlanet["b_tech"] = 0;
                            $CurrentUser['b_tech_planet'] = 0;
                            $UpdateData = true;
                            $InResearch = false;
                        }
                        break;
                    case 'search':
                        if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno) && !$InResearch) {
                            $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                            $WorkingPlanet['metal'] -= $costs['metal'];
                            $WorkingPlanet['crystal'] -= $costs['crystal'];
                            $WorkingPlanet['deuterium'] -= $costs['deuterium'];
                            $WorkingPlanet["b_tech_id"] = $Techno;
                            $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno);
                            $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"];
                            $UpdateData = true;
                            $InResearch = true;
                        }
                        break;
                }
                if ($UpdateData == true) {
                    $QryUpdatePlanet = "UPDATE {{table}} SET ";
                    $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
                    $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
                    $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', ";
                    $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', ";
                    $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "' ";
                    $QryUpdatePlanet .= "WHERE ";
                    $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';";
                    doquery($QryUpdatePlanet, 'planets');
                    $QryUpdateUser = "******";
                    $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' ";
                    $QryUpdateUser .= "WHERE ";
                    $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
                    doquery($QryUpdateUser, 'users');
                }
                if (is_array($ThePlanet)) {
                    $ThePlanet = $WorkingPlanet;
                } else {
                    $CurrentPlanet = $WorkingPlanet;
                    if ($TheCommand == 'search') {
                        $ThePlanet = $CurrentPlanet;
                    }
                }
            }
        } else {
            $bContinue = false;
        }
    }
    $TechScrTPL = gettemplate('buildings_research_script');
    $SubTemplate = gettemplate('buildings/research_buttonz');
    $parse = array();
    $infopg = array();
    foreach ($lang['names'] as $Tech => $TechName) {
        if ($Tech > 105 && $Tech <= 199) {
            if (!IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
                $parse['state_' . $Tech] = "off";
                $parse['mes_' . $Tech] = "Requirements are not met";
            } elseif (!IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech)) {
                $parse['state_' . $Tech] = "disabled";
                $parse['mes_' . $Tech] = "Not enough resources!";
            } else {
                $parse['state_' . $Tech] = "on";
                $parse['mes_' . $Tech] = "";
            }
        } else {
            $parse['state_' . $Tech] = "off";
            $parse['mes_' . $Tech] = "Not availble";
        }
        $parse['name_' . $Tech] = $TechName;
        $parse['count_' . $Tech] = $CurrentUser[$resource[$Tech]];
    }
    //Anything currently building?
    if ($CurrentUser['b_tech_planet']) {
        $WorkingPlanet = doquery("SELECT `id`,`name`,`b_tech_id`,`b_tech` FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true);
        //Whats currently building
        $curbuild = $WorkingPlanet['b_tech_id'];
        $parse['countdown_' . $curbuild] = "\r\n\t\t\t\t\t\t\t\t\t\t<div class=\"pusher\" id=\"b_research" . $curbuild . "\" style=\"height:80px;margin-bottom:-80px;\">\n\r\n\t\t\t\t\t\t\t\t\t\t\t<a><span class=\"time\" id=\"test\" name=\"zeit\">" . parsecountdown($WorkingPlanet['b_tech']) . "</span></a>\n\r\n\t\t\t\t\t\t\t\t\t\t</div>\n";
    } else {
        $curbuild = 0;
    }
    $Buttonz = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['names'][$Element];
    $de_planettype = PlanetType($CurrentPlanet['image']);
    $parse['type'] = $de_planettype['type'];
    if ($Element) {
        if (in_array($Element, $reslist['tech'])) {
            /*
            $RowParse['dpath']       = $dpath;
            $RowParse['tech_id']     = $Tech;
            $building_level          = $CurrentUser[$resource[$Tech]];
            $RowParse['tech_level']  = ($building_level == 0) ? "" : "( ". $lang['level']. " ".$building_level." )";
            $RowParse['tech_name']   = $TechName;
            $RowParse['tech_descr']  = $lang['res']['descriptions'][$Tech];
            $RowParse['tech_price']  = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech);
            $SearchTime              = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech);
            $RowParse['search_time'] = ShowBuildTime($SearchTime);
            $RowParse['tech_restp']  = $lang['Rest_ress'] ." ". GetRestPrice ($CurrentUser, $CurrentPlanet, $Tech, true);
            $CanBeDone               = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech);
            */
            $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element);
            $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'] = '';
            $buildlink = "./?page=research&cmd=search&id=" . $Element . "&tech=" . $Element;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                if ($NextBuildLevel == 1) {
                    if ($HaveRessources == true) {
                        $infopg['build_link'] = $buildlink;
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    }
                } else {
                    if ($HaveRessources == true) {
                        $infopg['build_link'] = $buildlink;
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    } else {
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                }
            } elseif ($InResearch) {
                $parse['click'] = "<font color=#FF0000>" . $lang['InResearch'] . "</font>";
                $infopg['build_text'] = $lang['InResearch'];
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = $lang['Improve'];
            } elseif ($InResearch) {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = $lang['InResearch'];
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $CurrentUser[$resource[$Element]];
            //Current research
            if ($curbuild == $Element) {
                $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=cancel&id=" . $Element . "&tech=" . $Element;
                if ($WorkingPlanet['id'] == $CurrentPlanet['id']) {
                    $infopg['title'] = "Cancel";
                } else {
                    //$infopg['title'] = "Cancel on ".$WorkingPlanet['name'];
                    $infopg['title'] = "Cancel";
                }
            } else {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['sdesc'][$Element];
            $infopg['skin'] = $CurrentUser['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            if ($infopg['cost_m'] > $CurrentPlanet['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $CurrentPlanet['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $CurrentPlanet['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
            if ($_GET['axah_section'] == '1') {
                makeAXAH($parse['info']);
                die;
            }
        }
    }
    $parse['buttonz'] = $Buttonz;
    $parse['planetname'] = $CurrentPlanet['name'];
    $page .= parsetemplate(gettemplate('buildings/research'), $parse);
    if ($_GET['axah']) {
        makeAXAH($page);
    } else {
        displaypage($page, $lang['Research']);
    }
}
 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));
 }
Example #16
0
/**
* eco_build.php
*
* @version 1.5 - Using PTE (not everywhere) by Gorlum for http://supernova.ws
* @version 1.4 - Complying with PCG by Gorlum for http://supernova.ws
* @version 1.3 - Security checked for SQL-injection by Gorlum for http://supernova.ws
// 1.0 Mise en module initiale (creation)
// 1.1 FIX interception cheat +1
// 1.2 FIX interception cheat destruction a -1
* @version 1.1
* @copyright 2008 by Chlorel for XNova
*/
function eco_build($que_type, $user, &$planet, $que)
{
    global $sn_data, $lang, $config, $time_now;
    // start transaction here
    $template = gettemplate('buildings_builds', true);
    // Caching values that used more then one time into local variables
    $config_resource_multiplier = $config->resource_multiplier;
    $planet_type_structs = $sn_data['groups']['build_allow'][$planet['planet_type']];
    // Getting parameters
    $action = sys_get_param_escaped('action');
    $unit_id = sys_get_param_int('unit_id');
    $unit_level = sys_get_param_int('unit_level');
    $GET_listid = $_GET['listid'];
    $que_type = $que_type == SUBQUE_FLEET || $que_type == SUBQUE_DEFENSE ? QUE_HANGAR : $que_type;
    CheckPlanetUsedFields($planet);
    if ($action) {
        switch ($action) {
            case 'create':
                // Add unit to que for build
                $que = eco_que_add($user, $planet, $que, QUE_STRUCTURES, $unit_id);
                break;
            case 'destroy':
                // Add unit to que for remove
                $que = eco_que_add($user, $planet, $que, QUE_STRUCTURES, $unit_id, 1, BUILD_DESTROY);
                break;
            case 'trim':
                // Cancel unit from que
                $que = eco_que_clear($user, $planet, $que, QUE_STRUCTURES, true);
                break;
            case 'clear':
                // Clear que
                $que = eco_que_clear($user, $planet, $que, QUE_STRUCTURES);
                break;
        }
        header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}");
    }
    /*
      // Code for fully working new que system
      $hangar_busy = count($que['que'][QUE_HANGAR]);
      $lab_busy    = count($que['que'][QUE_RESEARCH]) && !$config->BuildLabWhileRun;
    */
    $que_length = count($que['que'][$que_type]);
    $can_que_element = $que_length < MAX_BUILDING_QUEUE_SIZE;
    $fleet_list = flt_get_fleets_to_planet($planet);
    $caps = ECO_getPlanetCaps($user, &$planet);
    $planet_fields_max = eco_planet_fields_max($planet);
    $planet_fields_current = $planet['field_current'];
    $planet_fields_que = -$que['amounts'][$que_type];
    $planet_fields_free = max(0, $planet_fields_max - $planet_fields_current + $planet_fields_que);
    $planet_fields_queable = $planet_fields_free > 0;
    $planet_temp_max = $planet['temp_max'];
    $GLOBALS['user_tech_energy'] = $user['energy_tech'];
    foreach ($planet_type_structs as $Element) {
        if (eco_can_build_unit($user, $planet, $Element)) {
            $element_name = $lang['tech'][$Element];
            $element_sn_data =& $sn_data[$Element];
            $element_level = $planet[$sn_data[$Element]['name']] + $que['in_que'][$Element];
            // show energy on BuildingPage
            //================================
            if ($element_sn_data['production']) {
                $element_production_energy = $element_sn_data['production'][RES_ENERGY];
                $energy_current = floor($element_production_energy($element_level, 10, $planet_temp_max));
                $energy_next = floor($element_production_energy($element_level + 1, 10, $planet_temp_max));
                if ($Element == STRUC_MINE_SOLAR || $Element == STRUC_MINE_FUSION) {
                    $energy_current = floor(mrc_modify_value($user, $planet, array(MRC_POWERMAN), $energy_current));
                    $energy_next = floor(mrc_modify_value($user, $planet, array(MRC_POWERMAN), $energy_next));
                }
                $energy_balance = floor($energy_next - $energy_current);
            } else {
                $energy_balance = 0;
            }
            //================================
            $build_data = eco_get_build_data($user, $planet, $Element, $element_level);
            $temp[RES_METAL] = floor($planet['metal'] + $fleet_list['own']['total'][RES_METAL] - $build_data[BUILD_CREATE][RES_METAL]);
            $temp[RES_CRYSTAL] = floor($planet['crystal'] + $fleet_list['own']['total'][RES_CRYSTAL] - $build_data[BUILD_CREATE][RES_CRYSTAL]);
            $temp[RES_DEUTERIUM] = floor($planet['deuterium'] + $fleet_list['own']['total'][RES_DEUTERIUM] - $build_data[BUILD_CREATE][RES_DEUTERIUM]);
            $template->assign_block_vars('production', array('ID' => $Element, 'NAME' => $element_name, 'DESCRIPTION' => $lang['info'][$Element]['description_short'], 'LEVEL' => $element_level, 'LEVEL_OLD' => $planet[$sn_data[$Element]['name']], 'LEVEL_CHANGE' => $que['in_que'][$Element], 'BUILD_CAN' => $build_data['CAN'][BUILD_CREATE], 'TIME' => pretty_time($build_data[BUILD_CREATE][RES_TIME]), 'METAL' => $build_data[BUILD_CREATE][RES_METAL], 'CRYSTAL' => $build_data[BUILD_CREATE][RES_CRYSTAL], 'DEUTERIUM' => $build_data[BUILD_CREATE][RES_DEUTERIUM], 'DESTROY_CAN' => $build_data['CAN'][BUILD_DESTROY], 'DESTROY_TIME' => pretty_time($build_data[BUILD_DESTROY][RES_TIME]), 'DESTROY_METAL' => $build_data[BUILD_DESTROY][RES_METAL], 'DESTROY_CRYSTAL' => $build_data[BUILD_DESTROY][RES_CRYSTAL], 'DESTROY_DEUTERIUM' => $build_data[BUILD_DESTROY][RES_DEUTERIUM], 'METAL_REST' => pretty_number($temp[RES_METAL], true, true), 'CRYSTAL_REST' => pretty_number($temp[RES_CRYSTAL], true, true), 'DEUTERIUM_REST' => pretty_number($temp[RES_DEUTERIUM], true, true), 'METAL_REST_NUM' => $temp[RES_METAL], 'CRYSTAL_REST_NUM' => $temp[RES_CRYSTAL], 'DEUTERIUM_REST_NUM' => $temp[RES_DEUTERIUM], 'METAL_BALANCE' => $caps['metal_perhour'][$Element], 'CRYSTAL_BALANCE' => $caps['crystal_perhour'][$Element], 'DEUTERIUM_BALANCE' => $caps['deuterium_perhour'][$Element], 'ENERGY_BALANCE' => $energy_balance, 'UNIT_BUSY' => eco_unit_busy($user, $planet, $que, $Element)));
        }
    }
    if (is_array($que['que'][$que_type])) {
        foreach ($que['que'][$que_type] as $que_element) {
            $template->assign_block_vars('que', $que_element);
        }
    }
    $template->assign_vars(array('TIME_NOW' => $time_now, 'QUE_ID' => $que_type, 'METAL' => $planet['metal'], 'CRYSTAL' => $planet['crystal'], 'DEUTERIUM' => $planet['deuterium'], 'METAL_INCOMING' => $fleet_list['own']['total'][RES_METAL], 'CRYSTAL_INCOMING' => $fleet_list['own']['total'][RES_CRYSTAL], 'DEUTERIUM_INCOMING' => $fleet_list['own']['total'][RES_DEUTERIUM], 'FIELDS_CURRENT' => $planet_fields_current, 'FIELDS_MAX' => $planet_fields_max, 'FIELDS_FREE' => $planet_fields_free, 'FIELDS_QUE' => $planet_fields_que == 0 ? '' : $planet_fields_que > 0 ? "+{$planet_fields_que}" : $planet_fields_que, 'QUE_HAS_PLACE' => $can_que_element, 'QUE_HAS_FIELDS' => $planet_fields_queable, 'FLEET_OWN' => $fleet_list['own']['count'], 'PAGE_HINT' => $lang['eco_bld_page_hint']));
    display(parsetemplate($template), $lang['Builds']);
}
Example #17
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']);
}
Example #18
0
         $AllPlanets .= "<th>" . $UserPlanet['name'] . "<br>";
         $AllPlanets .= "<a href=\"?cp=" . $UserPlanet['id'] . "&re=0\" title=\"" . $UserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $UserPlanet['image'] . ".jpg\" height=\"50\" width=\"50\"></a><br>";
         $AllPlanets .= "<center>";
         if ($UserPlanet['b_building'] != 0) {
             UpdatePlanetBatimentQueueList($UserPlanet, $user);
             if ($UserPlanet['b_building'] != 0) {
                 $BuildQueue = $UserPlanet['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($UserPlanet);
                 $AllPlanets .= $lang['Free'];
             }
         } else {
             $AllPlanets .= $lang['Free'];
         }
         $AllPlanets .= "</center></th>";
         if ($Colone <= 1) {
             $Colone++;
         } else {
             $AllPlanets .= "</tr><tr>";
             $Colone = 1;
         }
     }
 }
 // -----------------------------------------------------------------------------------------------
Example #19
0
 function Play()
 {
     global $resource, $BotString;
     $this->HandleOwnFleets();
     $iPlanetCount = doquery("SELECT count(*) AS `total` FROM {{table}} WHERE `id_owner` = '" . $this->player['id'] . "' AND `planet_type` = '1'", 'planets', true);
     $maxfleet = doquery("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '" . $this->player['id'] . "';", 'fleets', true);
     $maxcolofleet = doquery("SELECT COUNT(fleet_owner) AS `total` FROM {{table}} WHERE `fleet_owner` = '" . $this->player['id'] . "' AND `fleet_mission` = '7';", 'fleets', true);
     $MaxFlyingFleets = $maxfleet['actcnt'];
     $MaxFlottes = $this->player[$resource[108]];
     $planetselected = false;
     $planetwork = false;
     $planetquery = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $this->player['id'] . "' AND `planet_type` = '1' ORDER BY `id` ASC;", 'planets', false);
     while ($this->CurrentPlanet = mysql_fetch_array($planetquery)) {
         if ($planetselected == true and $this->CurrentPlanet['id_owner'] == $this->player['id']) {
             CheckPlanetUsedFields($this->CurrentPlanet);
             if ($BotString) {
                 $BotString .= "\r\n" . '<tr><td colspan="2" class="c">' . $this->player['username'] . '</td></tr><tr><th>Hora</th><th>' . date(DATE_RFC822) . '</th></tr><tr><th>Planeta actual</th><th>' . $this->CurrentPlanet['name'] . ' [' . $this->CurrentPlanet['id'] . ']</th></tr></tr>';
             }
             $this->BuildStores();
             $Rand = mt_rand(0, 1);
             if ($Rand == 1 or $this->CurrentPlanet[$resource[4]] <= 5) {
                 $this->BuildBuildings();
             } else {
                 $this->BuildSpecialBuildings();
             }
             if ($this->CurrentPlanet[$resource[31]] > 0) {
                 $this->ResearchTechs();
             }
             $Rand = mt_rand(0, 1);
             if ($Rand == 1) {
                 $this->BuildFleet();
             } else {
                 $this->BuildDefense();
             }
             if ($iPlanetCount['total'] < MAX_PLAYER_PLANETS and $maxcolofleet['total'] < MAX_PLAYER_PLANETS - $maxcolofleet['total'] and $MaxFlyingFleets < $MaxFlottes and $this->CurrentPlanet[$resource[208]] >= 1) {
                 $this->Colonize($iPlanetCount['total']);
             }
             if ($this->CurrentPlanet['id'] == $this->player['id_planet']) {
                 if ($MaxFlyingFleets < $MaxFlottes + 1) {
                     $this->HandleOtherFleets();
                 }
             } elseif ($MaxFlyingFleets < $MaxFlottes) {
                 $this->GetFleet();
             }
             $this->Update();
             $planetselected = false;
             $planetwork = true;
             $planetid = $this->CurrentPlanet['id'];
         } else {
             if ($this->CurrentPlanet['id'] == $this->Bot['last_planet']) {
                 $planetselected = true;
             }
         }
     }
     if ($planetwork == false) {
         $this->CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $this->player['id_planet'] . "';", 'planets', true);
         CheckPlanetUsedFields($this->CurrentPlanet);
         if ($BotString) {
             $BotString .= '<tr><td colspan="2" class="c">' . $this->player['username'] . '</td><tr><th>Planeta actual</th><th>' . $this->CurrentPlanet['name'] . ' [' . $this->CurrentPlanet['id'] . ']</th></tr></tr>';
         }
         $this->BuildStores();
         $Rand = mt_rand(0, 1);
         if ($Rand == 1 or $this->CurrentPlanet[$resource[4]] <= 5) {
             $this->BuildBuildings();
         } else {
             $this->BuildSpecialBuildings();
         }
         if ($this->CurrentPlanet[$resource[31]] > 0) {
             $this->ResearchTechs();
         }
         $Rand = mt_rand(0, 1);
         if ($Rand == 1) {
             $this->BuildFleet();
         } else {
             $this->BuildDefense();
         }
         if ($iPlanetCount['total'] < MAX_PLAYER_PLANETS and $maxcolofleet['total'] < MAX_PLAYER_PLANETS - $maxcolofleet['total'] and $MaxFlyingFleets < $MaxFlottes and $this->CurrentPlanet[$resource[208]] >= 1) {
             $this->Colonize($iPlanetCount['total']);
         }
         if ($this->CurrentPlanet['id'] == $this->player['id_planet']) {
             if ($MaxFlyingFleets < $MaxFlottes + 1) {
                 $this->HandleOtherFleets();
             }
         } elseif ($MaxFlyingFleets < $MaxFlottes) {
             $this->GetFleet();
         }
         $this->Update();
         $planetid = $this->player['id_planet'];
     }
     $this->End($planetid);
 }
Example #20
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']);
}
Example #21
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");
}
Example #22
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']);
}
Example #23
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']);
}
Example #24
0
/**
 * BuildingPage.php
 *
 * @version 1.0
 * @copyright 2009 by MadnessRed for XNova Redesigned
 */
function BuildingPage($a = 0, $b = 0)
{
    global $lang, $resource, $reslist, $pricelist, $dpath, $game_config, $_GET, $user, $planetrow;
    CheckPlanetUsedFields($planetrow);
    if (!$_GET['page']) {
        return false;
        die;
    }
    // Tables des batiments possibles par type de planete
    if ($_GET['page'] == 'station') {
        $Allowed[1] = array(14, 15, 21, 31, 33, 34, 44);
        $Allowed[3] = array(14, 21, 34, 41, 42, 43);
    } elseif ($_GET['page'] == 'resources') {
        $Allowed[1] = array(1, 2, 3, 4, 12, 212, 22, 23, 24);
        $Allowed[3] = array(212, 22, 23, 24);
    } else {
        die("Hacking attempt");
    }
    //Right, lets see what he has an generate him an image.
    $imgnum = '';
    if ($planetrow[$resource[1]] > 0) {
        $imgnum .= "_1";
    }
    if ($planetrow[$resource[2]] > 0) {
        $imgnum .= "_2";
    }
    if ($planetrow[$resource[3]] > 0) {
        $imgnum .= "_3";
    }
    if ($planetrow[$resource[4]] > 0) {
        $imgnum .= "_4";
    }
    // 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[$planetrow['planet_type']])) {
                        $bDoItNow = true;
                    } else {
                        //$bThisIsCheated = true;
                        $bDoItNow = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    //Remove last queue item
                    RemoveFromQueue();
                    break;
                case 'remove':
                    //Remove a specific queue item
                    RemoveFromQueue($ListID);
                    break;
                case 'insert':
                    //Insert into the queue a build
                    $fields_rem = $planetrow['field_max'] - $planetrow['field_current'] + $planetrow[$resource[33]] * 5;
                    if ($fields_rem >= 0) {
                        AddToQueue($Element, 1);
                    } else {
                        echo $fields_rem . " < 0";
                        die("Hacking Attempt!");
                    }
                    break;
                case 'destroy':
                    //Add a deconstrction to the queue
                    AddToQueue($Element, -1);
                    break;
            }
            // switch
        } elseif ($bThisIsCheated == true) {
            //ResetThisFuckingCheater ( $user['id'] );
        }
        //If they want axah_section
        if ($_GET['axah_box']) {
            $q = ShowQueue(false);
            makeAXAH($q['buildlist']);
            die;
        }
    }
    $Queue = ShowQueue(true);
    // On enregistre ce que l'on a modifi� dans planet !
    BuildingSavePlanetRecord($planetrow);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($user);
    $max_qs = MAX_BUILDING_QUEUE_SIZE;
    if ($max_qs > 0) {
        //fine :)
    } else {
        $max_qs = 10;
    }
    if ($Queue['length'] < $max_qs) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    if ($_GET['page'] == 'station') {
        if ($planetrow['planet_type'] == 3) {
            $SubTemplate = gettemplate('buildings/station-moon_buttonz');
        } else {
            $SubTemplate = gettemplate('buildings/station_buttonz');
        }
    } elseif ($_GET['page'] == 'resources') {
        $SubTemplate = gettemplate('buildings/resources_buttonz');
    } else {
        die("Hacking attempt");
    }
    $parse = array();
    $infopg = array();
    foreach ($lang['names'] as $Element => $ElementName) {
        if (!$planetrow['planet_type']) {
            die("no planet type");
        }
        if (in_array($Element, $Allowed[$planetrow['planet_type']]) || $_GET['page'] == 'station') {
            if (@in_array($Element, $Allowed[$planetrow['planet_type']])) {
                if (!IsTechnologieAccessible($user, $planetrow, $Element)) {
                    $parse['state_' . $Element] = "off";
                    $parse['mes_' . $Element] = "Requirements are not met";
                    $parse['canbuild_' . $Element] = "";
                } elseif (!IsElementBuyable($user, $planetrow, $Element, true, false) && $Queue['length'] == 0) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Not enough resources!";
                    $parse['canbuild_' . $Element] = "";
                } elseif (!$CanBuildElement) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Queue is full!";
                    $parse['canbuild_' . $Element] = "";
                } else {
                    $parse['state_' . $Element] = "on";
                    $parse['mes_' . $Element] = "";
                    $parse['canbuild_' . $Element] = "\n\t\t\t\t\t\t<a class=\"fastBuild tips\" href=\"#\" onclick=\"loadpage('./?page=" . $_GET['page'] . "&cmd=insert&building={$Element}&id={$Element}',document.title,document.body.id);\">\n\t\t\t\t\t\t\t<img src=\"" . GAME_SKIN . "/img/layout/sofort_bauen.gif\" height=\"14\" width=\"22\">\n\t\t\t\t\t\t</a>";
                }
            } else {
                $parse['state_' . $Element] = "off";
                $parse['mes_' . $Element] = "Not availble";
                $parse['canbuild_' . $Element] = "";
            }
            $parse['name_' . $Element] = $ElementName;
            $parse['count_' . $Element] = $planetrow[$resource[$Element]];
        }
    }
    //Countdowns
    if ($planetrow['b_building'] > 0) {
        $BuildQueue = explode(";", $planetrow['b_building_id']);
        $CurrBuild = explode(",", $BuildQueue[0]);
        $parse['countdown_' . $CurrBuild[0]] = "\n\t\t\t\t\t\t\t\t\t<div class=\"construction\">\n\n\t\t\t\t\t\t\t\t\t\t<div class=\"pusher\" style=\"height: 80px; margin-bottom: -80px;\">\n\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"time\" id=\"resource\">" . parsecountdown($planetrow['b_building']) . "</span>\n\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t</div>\n";
    }
    $BuildingPage = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['names'][$Element];
    // Faut il afficher la liste de construction ??
    if ($Queue['length'] > 0) {
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildList'] = "";
    }
    $de_planettype = PlanetType($planetrow['image']);
    $parse['type'] = $de_planettype['type'];
    if ($_GET['page'] == 'station') {
        $parse['bg'] = HEADER_CACHE . "station/" . $parse['type'] . ".png";
    } elseif ($_GET['page'] == 'resources') {
        if (url_exists(HEADER_CACHE . "resources/" . $parse['type'] . $imgnum . ".png")) {
            $parse['bg'] = HEADER_CACHE . "resources/" . $parse['type'] . $imgnum . ".png";
        } else {
            $parse['bg'] = HEADER_CACHE . "resources/default.png";
        }
    } else {
        die("Hacking attempt");
    }
    $parse['hideres'] = "display:none;";
    $parse['hidenorm'] = "";
    $parse['planetname'] = $planetrow['name'];
    if (!$Element) {
        if ($_GET['mode'] == "resources") {
            $parse['hideres'] = "";
            $parse['hidenorm'] = "display:none;";
        }
    } else {
        if (!is_array($Allowed[$planetrow['planet_type']])) {
            $message = $user['username'] . " (" . intval($user['id']) . ") does not have a propper planet_type, so \$Allowed[\$planetrow['planet_type']] was not an array, causing the error which is most likely directly below this.";
            trigger_error($message, E_USER_NOTICE);
        }
        if (in_array($Element, $Allowed[$planetrow['planet_type']])) {
            //Something else
            $HaveRessources = IsElementBuyable($user, $planetrow, $Element, true, false);
            $parse['i'] = $Element;
            $parse['dpath'] = $dpath;
            $BuildingLevel = $planetrow[$resource[$Element]];
            $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
            $parse['n'] = $ElementName;
            $parse['descriptions'] = $lang['res']['descriptions'][$Element];
            $ElementBuildTime = BuildingTime($Element, $BuildingLevel + 1, $planetrow);
            $parse['time'] = ShowBuildTime($ElementBuildTime);
            $parse['price'] = GetElementPrice($user, $planetrow, $Element);
            $parse['rest_price'] = GetRestPrice($user, $planetrow, $Element);
            $parse['click'] = '';
            $NextBuildLevel = $planetrow[$resource[$Element]] + 1;
            $CurrentMaxFields = CalculateMaxPlanetFields($planetrow);
            if ($planetrow["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if ($Element == 31) {
                // Sp�cial Laboratoire
                if ($user["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 (IsTechnologieAccessible($user, $planetrow, $Element)) {
                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=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                                $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            } else {
                                $parse['click'] = "<font color=#FF0000>4" . $lang['BuildFirstLevel'] . "</font>";
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                                $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                        $infopg['build_text'] = $lang['InBuildQueue'];
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>2" . $lang['BuildFirstLevel'] . "</font>";
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $parse['click'] = "<font color=#FF0000>1" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                    $infopg['build_text'] = $lang['NoMoreSpace'];
                }
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = "Improve";
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = "In queue";
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $planetrow[$resource[$Element]];
            if ($planetrow[$resource[$Element]] < 1) {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=destroy&id=" . $Element . "&building=" . $Element;
            $infopg['title'] = "Tear down";
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['sdesc'][$Element];
            $infopg['skin'] = $user['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            if ($infopg['cost_m'] > $planetrow['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $planetrow['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $planetrow['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
            if ($_GET['axah_section'] == '1') {
                makeAXAH($parse['info']);
                die;
            }
        }
    }
    $parse['planet_field_current'] = $planetrow["field_current"];
    $parse['planet_field_max'] = $planetrow['field_max'] + $planetrow[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $planetrow['field_current'];
    $parse['buttonz'] = $BuildingPage;
    $parse['BuildingsList'] = $BuildingPage;
    if ($_GET['page'] == 'station') {
        $page = parsetemplate(gettemplate('buildings/station'), $parse);
        $title = $lang['Facilities'];
    } elseif ($_GET['page'] == 'resources') {
        //Resources screen
        $parse['resources_section'] = BuildRessourcePage($user, $planetrow, $parse['hideres']);
        $page = parsetemplate(gettemplate('buildings/resources'), $parse);
        $title = $lang['Resources'];
    } else {
        die("Hacking attempt");
    }
    if ($_GET['axah']) {
        makeAXAH($page);
    } else {
        displaypage($page, $title);
    }
}
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function ProductionBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $pricelist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 212, 22, 23, 24);
    $Allowed['3'] = array(212, 22, 23, 24);
    //Right, lets see what he has an generate him an image.
    $imgnum = '';
    if ($CurrentPlanet[$resource[1]] > 0) {
        $imgnum .= "_1";
    }
    if ($CurrentPlanet[$resource[2]] > 0) {
        $imgnum .= "_2";
    }
    if ($CurrentPlanet[$resource[3]] > 0) {
        $imgnum .= "_3";
    }
    if ($CurrentPlanet[$resource[4]] > 0) {
        $imgnum .= "_4";
    }
    // 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;
                        $bDoItNow = 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
                    $fields_rem = $CurrentPlanet['field_max'] - $CurrentPlanet['field_current'] + $CurrentPlanet[$resource[33]] * 5;
                    if ($fields_rem >= 0) {
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    } else {
                        echo $fields_rem . " < 0";
                        die("Hacking Attempt!");
                    }
                    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� dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($CurrentUser);
    $max_qs = MAX_BUILDING_QUEUE_SIZE;
    if ($max_qs > 0) {
        //fine :)
    } else {
        $max_qs = 10;
    }
    if ($Queue['lenght'] < $max_qs) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_res_buttonz');
    $parse = array();
    $infopg = array();
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[1])) {
            if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
                if (!IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    $parse['state_' . $Element] = "off";
                    $parse['mes_' . $Element] = "Requirements are not met";
                } elseif (!IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false)) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Not enough resources!";
                } else {
                    $parse['state_' . $Element] = "on";
                    $parse['mes_' . $Element] = "";
                }
            } else {
                $parse['state_' . $Element] = "off";
                $parse['mes_' . $Element] = "Not availble";
            }
            $parse['name_' . $Element] = $ElementName;
            $parse['count_' . $Element] = $CurrentPlanet[$resource[$Element]];
        }
    }
    $BuildingPage = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['tech'][$Element];
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = '';
        //$parse['BuildListScript']  = InsertBuildListScript ( "buildings" );
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $de_planettype = PlanetType($CurrentPlanet['image']);
    $parse['type'] = $de_planettype['type'];
    $parse['bg'] = GAME_SKIN . "/img/header/resources/" . $parse['type'] . $imgnum . ".png";
    $parse['hideres'] = "display:none;";
    $parse['hidenorm'] = "";
    if (!$Element) {
        $parse['bg'] = GAME_SKIN . "/img/header/resources/" . $parse['type'] . $imgnum . ".png";
        if ($_GET['mode'] == "resources") {
            $parse['hideres'] = "";
            $parse['hidenorm'] = "display:none;";
            $parse['resources_section'] = BuildRessourcePage($CurrentUser, $CurrentPlanet);
        }
    } else {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            //Something else
            $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
            $parse['i'] = $Element;
            $parse['dpath'] = $dpath;
            $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'] = '';
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if ($Element == 31) {
                // Sp�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 (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                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=\"./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                                $infopg['build_link'] = "./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            } else {
                                $parse['click'] = "<font color=#FF0000>4" . $lang['BuildFirstLevel'] . "</font>";
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                                $infopg['build_link'] = "./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        $infopg['build_link'] = "./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element;
                        $infopg['build_text'] = $lang['InBuildQueue'];
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>2" . $lang['BuildFirstLevel'] . "</font>";
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $parse['click'] = "<font color=#FF0000>1" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                    $infopg['build_text'] = $lang['NoMoreSpace'];
                }
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //$parse['bg'] = GAME_SKIN."/img/header/resources/ice.png";
            $parse['gebaeude_inf'] = "<br /><blockquote style=\"margin-left: 15px; margin-right: 15px; filter:alpha(opacity=75); -moz-opacity:.75; opacity:.75; background-color: #000000;\">\r\n\t\t\t<div style=\"margin-left: 10px; margin-right: 10px;\">\r\n\t\t\t<table width=\"100%\"><tr>\r\n\t\t\t\t<td width=\"130\"><img src=\"" . $dpath . "/gebaeude/" . $parse['i'] . ".gif\" width=\"120\" border=\"0\" alt=\"" . $parse['n'] . "\" /></td>\r\n\t\t\t\t<td style=\"margin-left: 10px;\">\r\n\t\t\t\t<div style=\"text-align: center;\"><!--<a href=\"infos.php?gid=" . $parse['i'] . "\">-->" . $parse['n'] . "<!--</a>--></div>" . "<div style=\"text-align: left;\">" . $parse['nivel'] . "<br />" . $parse['descriptions'] . "<br /><br />" . $parse['price'] . $parse['time'] . $parse['rest_price'] . "<br /></div>" . "<div style=\"text-align: right;\">" . $parse['click'] . "</div>\r\n\t\t\t\t</td>\r\n\t\t\t</tr></table>\r\n\t\t\t</div>\r\n\t\t\t</blockquote>";
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = "Improve";
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = "In queue";
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $CurrentPlanet[$resource[$Element]];
            if ($CurrentPlanet[$resource[$Element]] < 1) {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=destroy&building=" . $Element;
            $infopg['title'] = "Tear down";
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['res']['descriptions'][$Element];
            $infopg['skin'] = $CurrentUser['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $CurrentPlanet[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $CurrentPlanet[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $CurrentPlanet[$resource[$Element]]));
            if ($infopg['cost_m'] > $CurrentPlanet['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $CurrentPlanet['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $CurrentPlanet['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
        }
    }
    $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['buttonz'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings/resources'), $parse);
    displaypage($page, $lang['Builds']);
}
Example #26
0
        include $xnova_root_path . 'rak.' . $phpEx;
        if (defined('IN_ADMIN')) {
            $UserSkin = $user['dpath'];
            $local = stristr($UserSkin, "http:");
            if ($local === false) {
                if (!$user['dpath']) {
                    $dpath = "../" . DEFAULT_SKINPATH;
                } else {
                    $dpath = "../" . $user["dpath"];
                }
            } else {
                $dpath = $UserSkin;
            }
        } else {
            $dpath = !$user["dpath"] ? DEFAULT_SKINPATH : $user["dpath"];
        }
        SetSelectedPlanet($user);
        $planetrow = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user['current_planet'] . "';", 'planets', true);
        $galaxyrow = doquery("SELECT * FROM {{table}} WHERE `id_planet` = '" . $planetrow['id'] . "';", 'galaxy', true);
        CheckPlanetUsedFields($planetrow);
        date_default_timezone_set($user['timezone']);
    } else {
        $dpath = "../" . DEFAULT_SKINPATH;
    }
    includeLang("lang_info", ".cfg");
    includeLang("system");
    includeLang('tech');
} else {
    includeLang("lang_info", ".cfg");
    $dpath = "../" . DEFAULT_SKINPATH;
}
Example #27
0
function ShowImperiumPage($CurrentUser)
{
    global $lang, $resource, $reslist, $dpath;
    $lang['imperium_vision'] = 'Visi&oacute;n general del Imperio';
    $lang['name'] = 'Planeta';
    $lang['coordinates'] = 'Coordenadas';
    $lang['fields'] = 'Campos';
    $lang['resources'] = 'Recursos';
    $lang['buildings'] = 'Edificios';
    $lang['investigation'] = 'Investigaciones';
    $lang['ships'] = 'Flotas';
    $lang['defense'] = 'Defensas';
    $parse = $lang;
    if (isset($_GET['planet_type'])) {
        if ($_GET['planet_type'] == 1) {
            $planettype = " AND `planet_type` = '1'";
            $parse['select1'] = ' selected';
        } elseif ($_GET['planet_type'] == 3) {
            $planettype = "AND `planet_type` = '3'";
            $parse['select3'] = ' selected';
        } else {
            $planettype = '';
            $parse['select0'] = ' selected';
        }
    } else {
        $planettype = '';
        $parse['select0'] = ' selected';
    }
    $planetsrow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentUser['id'] . "'{$planettype};", 'planets');
    $planet = array();
    while ($p = mysql_fetch_array($planetsrow)) {
        PlanetResourceUpdate($CurrentUser, $p, time());
        $planet['sum'] = sumar_array($planet['sum'], $p);
        $planet[] = $p;
    }
    uksort($planet, 'planet_empire_sort');
    $parse['mount'] = count($planet) + 3;
    // primera tabla, con las imagenes y coordenadas
    $row = gettemplate('empire/imperium_row');
    $row2 = gettemplate('empire/imperium_row2');
    foreach ($planet as $ID => $p) {
        if ($ID !== 'sum') {
            UpdatePlanetBatimentQueueList($p, $CurrentUser);
            $AllPlanets = '';
            if ($p['b_building'] != 0) {
                $BuildQueue = $p['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($p);
                $AllPlanets .= "<a href='game.php?page=buildings'>Libre</a>";
            }
            // {file_images}
            $parse['build'] .= '<th width="75">' . $AllPlanets . '</th>';
            $data['text'] = '<a href="game.php?page=overview&cp=' . $p['id'] . '&re=0"><img src="' . $dpath . 'planeten/' . $p['image'] . '.jpg" border="0" height="75" width="75"></a><br/>';
            $parse['file_images'] .= parsetemplate($row, $data);
            // {file_names}
            $data['text'] = '<a href="game.php?page=overview&cp=' . $p['id'] . '&re=0">' . $p['name'] . ' </a>';
            if ($p['planet_type'] == 3) {
                $data['text'] = '<a href="game.php?page=overview&cp=' . $p['id'] . '&re=0">' . $p['name'] . ' (Luna)</a>';
            }
            $parse['file_names'] .= parsetemplate($row2, $data);
            // {file_type}
            $data['text'] = GetPlanetType($p);
            $parse['file_type'] .= parsetemplate($row2, $data);
            // {file_coordinates}
            $data['text'] = "[<a href=\"game.php?page=galaxy&mode=3&galaxy={$p['galaxy']}&system={$p['system']}\">{$p['galaxy']}:{$p['system']}:{$p['planet']}</a>]";
            $parse['file_coordinates'] .= parsetemplate($row2, $data);
            // {file_fields}
            $data['text'] = $p['field_current'] . '/' . CalculateMaxPlanetFields($p) . '<br/>' . GetPercentBar($p['field_current'], CalculateMaxPlanetFields($p));
            $parse['file_fields'] .= parsetemplate($row2, $data);
            // {file_metal}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['metal']) . '</a><br/>' . GetPercentBar($p['metal'], $p['metal_max'] * MAX_OVERFLOW);
            $parse['file_metal'] .= parsetemplate($row2, $data);
            // {file_crystal}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['crystal']) . '</a><br/>' . GetPercentBar($p['crystal'], $p['crystal_max'] * MAX_OVERFLOW);
            $parse['file_crystal'] .= parsetemplate($row2, $data);
            // {file_deuterium}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['deuterium']) . '</a><br/>' . GetPercentBar($p['deuterium'], $p['deuterium_max'] * MAX_OVERFLOW);
            $parse['file_deuterium'] .= parsetemplate($row2, $data);
            // {file_hidrogeno}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['tritium']) . '</a><br/>' . GetPercentBar($p['tritium'], $p['tritium_max'] * MAX_OVERFLOW);
            $parse['file_tritium'] .= parsetemplate($row2, $data);
            // {file_energy}
            $data['text'] = pretty_number($p['energy_max'] - $p['energy_used']) . ' / ' . pretty_number($p['energy_max']) . '<br/>' . GetPercentBar($p['energy_max'], $p['energy_max'] - $p['energy_used']);
            $parse['file_energy'] .= parsetemplate($row2, $data);
            $Queue = ShowBuildingsPage::ShowBuildingQueue($p, $CurrentUser);
            foreach ($resource as $i => $res) {
                if (in_array($i, $reslist['build'])) {
                    if ($Queue['buildingarray'][$i] > $p[$resource[$i]]) {
                        $p[$resource[$i]] = $p[$resource[$i]] . " <span style='color:lime;'>+" . ($Queue['buildingarray'][$i] - $p[$resource[$i]]) . "</span>";
                    }
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">" . pretty_number($p[$resource[$i]]) . "</a>";
                    if (IsElementBuyable($CurrentUser, $p, $i, true, false) and IsTechnologieAccessible($CurrentUser, $p, $i) and $p["field_current"] < CalculateMaxPlanetFields($p)) {
                        $data['text'] .= " <a href=\"game.php?page=buildings&cmd=insert&cp={$p['id']}&re=0&building=" . $i . "\"><font color=lime>+</font></a>";
                    }
                } elseif (in_array($i, $reslist['tech'])) {
                    $data['text'] = $CurrentUser[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&mode=research&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">{$CurrentUser[$resource[$i]]}</a>";
                    if (IsElementBuyable($CurrentUser, $p, $i, true, false) and IsTechnologieAccessible($CurrentUser, $p, $i) and $CurrentUser["b_tech_planet"] == 0) {
                        $data['text'] .= " <a href=\"game.php?page=buildings&mode=research&cmd=search&cp={$p['id']}&re=0&tech=" . $i . "\"><font color=lime>+</font></a>";
                    }
                } elseif (in_array($i, $reslist['fleet'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&mode=fleet&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">" . pretty_number($p[$resource[$i]]) . "</a>";
                } elseif (in_array($i, $reslist['defense'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&mode=defense&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">" . pretty_number($p[$resource[$i]]) . "</a>";
                }
                $r[$i] .= parsetemplate($row2, $data);
            }
        } else {
            $parse['build'] .= '<th width="75">-</th>';
            $data['text'] = '<span style="font-size:48px;font-weight:normal;">&Sigma;</span><br/>';
            $parse['file_images'] .= parsetemplate($row, $data);
            // {file_names}
            $data['text'] = '-';
            $parse['file_names'] .= parsetemplate($row2, $data);
            // {file_type}
            $data['text'] = "-";
            $parse['file_type'] .= parsetemplate($row2, $data);
            // {file_coordinates}
            $data['text'] = "-";
            $parse['file_coordinates'] .= parsetemplate($row2, $data);
            // {file_fields}
            $data['text'] = $p['field_current'] . '/' . CalculateMaxPlanetFields($p) . '<br/>' . GetPercentBar($p['field_current'], CalculateMaxPlanetFields($p));
            $parse['file_fields'] .= parsetemplate($row2, $data);
            // {file_metal}
            $data['text'] = pretty_number($p['metal']) . '<br/>' . GetPercentBar($p['metal'], $p['metal_max'] * MAX_OVERFLOW);
            $parse['file_metal'] .= parsetemplate($row2, $data);
            // {file_crystal}
            $data['text'] = pretty_number($p['crystal']) . '<br/>' . GetPercentBar($p['crystal'], $p['crystal_max'] * MAX_OVERFLOW);
            $parse['file_crystal'] .= parsetemplate($row2, $data);
            // {file_deuterium}
            $data['text'] = pretty_number($p['deuterium']) . '<br/>' . GetPercentBar($p['deuterium'], $p['deuterium_max'] * MAX_OVERFLOW);
            $parse['file_deuterium'] .= parsetemplate($row2, $data);
            // {file_hidrogeno}
            $data['text'] = pretty_number($p['tritium']) . '<br/>' . GetPercentBar($p['tritium'], $p['tritium_max'] * MAX_OVERFLOW);
            $parse['file_tritium'] .= parsetemplate($row2, $data);
            // {file_energy}
            $data['text'] = pretty_number($p['energy_max'] - $p['energy_used']) . ' / ' . pretty_number($p['energy_max']) . '<br/>' . GetPercentBar($p['energy_max'], $p['energy_max'] - $p['energy_used']);
            $parse['file_energy'] .= parsetemplate($row2, $data);
            foreach ($resource as $i => $res) {
                if (in_array($i, $reslist['build'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : pretty_number($p[$resource[$i]]);
                } elseif (in_array($i, $reslist['tech'])) {
                    $data['text'] = $CurrentUser[$resource[$i]] == 0 ? '' : $CurrentUser[$resource[$i]];
                } elseif (in_array($i, $reslist['fleet'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : pretty_number($p[$resource[$i]]);
                } elseif (in_array($i, $reslist['defense'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : pretty_number($p[$resource[$i]]);
                }
                $r[$i] .= parsetemplate($row2, $data);
            }
        }
    }
    // {building_row}
    foreach ($reslist['build'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['building_row'] .= '<tr><th width="15"><span style="float:center;width: 16px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    // {technology_row}
    foreach ($reslist['tech'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['technology_row'] .= '<tr><th width="15"><span style="float:center;width: 16px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    // {fleet_row}
    foreach ($reslist['fleet'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['fleet_row'] .= '<tr><th width="15"><span style="float:center;width: 16px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    // {defense_row}
    foreach ($reslist['defense'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['defense_row'] .= '<tr><th width="15"><span style="float:center;width: 15px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    $page .= parsetemplate(gettemplate('empire/imperium_table'), $parse);
    display($page, false);
}
Example #28
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;
    }
}
Example #29
0
     includeLang('TECH');
     if ($USER['bana'] == 1) {
         trigger_error("<font size=\"6px\">" . $LNG['css_account_banned_message'] . "</font><br><br>" . sprintf($LNG['css_account_banned_expire'], date("d. M y H:i", $USER['banaday'])) . "<br><br>" . $LNG['css_goto_homeside'], E_USER_NOTICE);
         exit;
     }
     if (!defined('IN_ADMIN')) {
         require_once ROOT_PATH . 'includes/classes/class.PlanetRessUpdate.' . PHP_EXT;
         $PLANET = $db->uniquequery("SELECT * FROM `" . PLANETS . "` WHERE `id` = '" . $_SESSION['planet'] . "';");
         if (empty($PLANET)) {
             $PLANET = $db->uniquequery("SELECT * FROM `" . PLANETS . "` WHERE `id` = '" . $USER['id_planet'] . "';");
             if (empty($PLANET)) {
                 throw new Exception("Main Planet does not exist!");
             }
         }
         require_once ROOT_PATH . 'includes/functions/CheckPlanetUsedFields.' . PHP_EXT;
         CheckPlanetUsedFields($PLANET);
     } else {
         $USER['rights'] = unserialize($USER['rights']);
         includeLang('ADMIN');
     }
 } else {
     //Login
     if (isset($_REQUEST['lang']) && ctype_alnum($_REQUEST['lang']) && !isset($_REQUEST['lang'][3])) {
         $LANG = $_REQUEST['lang'];
     } elseif (isset($CONF['lang'])) {
         $LANG = $CONF['lang'];
     } else {
         $LANG = DEFAULT_LANG;
     }
     includeLang('INGAME');
 }