Exemple #1
0
        default:
            //Overview.
            // --------------------------------------------------------------------------------------------------
            $cpage = "overview";
            //includeLang('overview');
            getLang('overview');
            includeLang('tech');
            include "includes/overviewfunctions.php";
            $parse = array_merge($lang, $planetrow);
            $type_array = PlanetType($planetrow['image']);
            $parse['type'] = $type_array['type'];
            $parse['subtype'] = $type_array['subtype'];
            $alt = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '" . $planetrow['galaxy'] . "' AND `system` = '" . $planetrow['system'] . "' AND `planet` = '" . $planetrow['planet'] . "' AND `id` <> '" . $planetrow['id'] . "' AND `planet_type` <> '2' LIMIT 1 ;", 'planets', false);
            if (mysql_num_rows($alt) > 0) {
                $alt = FetchArray($alt);
                $alt_type_array = PlanetType($alt['image']);
                if ($alt['planet_type'] == 1) {
                    $parse['moonlink'] = '
			<div id="planet_as_moon"> 
		    	<a onclick="loadpage(\'./?cp=' . $alt['id'] . '&re=0\',\'' . $lang['Overview'] . ' - ' . $alt['name'] . '\',\'overview\'); document.getElementById(\'planet_ext\').value = \'\'; document.getElementById(\'resources_menu_link\').style.display = \'block\'; return false;" 
		        	href="./?cp=' . $alt['id'] . '&re=0" 
					class="tips" 
		            onmouseover="mr_tooltip(\'' . $alt['name'] . '\')" onmouseout="UnTip()">
		        	<img alt="" src="' . GAME_SKIN . '/img/planets/large/' . $alt_type_array['type'] . '.jpg">
		        </a>
		    </div>';
                } else {
                    $parse['moonlink'] = '
			<div id="moon"> 
				<a onclick="loadpage(\'./?cp=' . $alt['id'] . '&re=0\',\'' . $lang['Overview'] . ' - ' . $alt['name'] . '\',\'overview\'); document.getElementById(\'planet_ext\').value = \'-moon\'; document.getElementById(\'resources_menu_link\').style.display = \'none\'; return false;" 
					href="./?cp=' . $alt['id'] . '&re=0"
Exemple #2
0
/**
 * ShowGalaxyRows.php
 *
 * @version 1.0
 * @copyright 2008 By Chlorel for XNova
 */
function ShowGalaxyRows($Galaxy, $System)
{
    global $lang, $planetcount, $CurrentRC, $dpath, $user, $planetrow, $resource, $pricelist, $formulas;
    //Can we phalanx this system?
    $CanPhalanx = false;
    if (abs($planetrow['system'] - $System) <= eval($formulas['phalanx_range']) && $planetrow['galaxy'] == $Galaxy) {
        $CanPhalanx = true;
    }
    //Loop through planets
    $Result = "";
    for ($Planet = 1; $Planet <= MAX_PLANET_IN_SYSTEM; $Planet++) {
        unset($GalaxyRowPlanet);
        unset($GalaxyRowMoon);
        unset($GalaxyRowPlayer);
        unset($GalaxyRowAlly);
        //MadnessRed, reset some things to false.
        $noplanet = false;
        $moon = false;
        $moondest = false;
        $GalaxyRowPlanet = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '" . $Galaxy . "' AND `system` = '" . $System . "' AND `planet` = '" . $Planet . "' AND `planet_type` = '1' LIMIT 1 ;", 'planets', true);
        //If there is a planet here
        if ($GalaxyRowPlanet['id'] > 0) {
            //There is a planet
            if ($GalaxyRowPlanet['destruyed'] != 0 && $GalaxyRowPlanet['id_owner'] != '' && $GalaxyRowPlanet['id_owner'] != 0 && $GalaxyRow["id_planet"] != '') {
                CheckAbandonPlanetState($GalaxyRowPlanet);
            } else {
                $planetcount++;
                $GalaxyRowPlayer = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $GalaxyRowPlanet["id_owner"] . "';", 'users', true);
            }
            //Is there a moon?
            $GalaxyRowMoon = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '" . $Galaxy . "' AND `system` = '" . $System . "' AND `planet` = '" . $Planet . "' AND `planet_type` = '3' LIMIT 1 ;", 'planets', true);
            if ($GalaxyRowMoon["id"] > 0) {
                $moon = true;
                if ($GalaxyRowMoon["destruyed"] != 0) {
                    $moondest = true;
                    CheckAbandonMoonState($GalaxyRowMoon);
                }
            }
        } else {
            $noplanet = true;
        }
        //Clear $parse,
        $parse = array();
        $parse = $lang;
        //Some Basics
        //Galaxy & System
        $parse['galaxy'] = $Galaxy;
        $parse['system'] = $System;
        //Username and ID
        $parse['player_name'] = $GalaxyRowPlayer['username'];
        if ($GalaxyRowPlayer['urlaubs_modus'] == 1) {
            //Utente In Vacanza
            $parse['player_name'] = "<font color=#00CCFF><strong>" . $GalaxyRowPlayer['username'] . "&nbsp; ( V )</strong></font>";
        }
        //Controllo se � bannato
        if ($GalaxyRowPlayer['banned_until'] >= time()) {
            //Controllo se � stata attivata o meno la modalit� Vacanza
            if ($GalaxyRowPlayer['urlaubs_modus'] == 1) {
                //Utente In Vacanza
                $parse['player_name'] = "<font color=#00CCFF><strong><s>" . $GalaxyRowPlayer['username'] . "&nbsp; ( V B )</s></strong></font>";
            } else {
                //Utente Bannato SENZA VACANZA
                $parse['player_name'] = "<font color=#FFFFFF><strong><s>" . $GalaxyRowPlayer['username'] . "&nbsp; ( B )</s></strong></font>";
            }
        }
        //Controllo se il giocatore � Inattivo
        if ($GalaxyRowPlayer['onlinetime'] < time() - 60 * 60 * 24 * 7) {
            //Inattivo da 7 Giorni
            $parse['player_name'] = "<font color=#999999>" . $GalaxyRowPlayer['username'] . "&nbsp; ( i )</font>";
        }
        if ($GalaxyRowPlayer['onlinetime'] < time() - 60 * 60 * 24 * 28) {
            //Inattivo da 28 Giorni
            $parse['player_name'] = "<font color=#666666>" . $GalaxyRowPlayer['username'] . "&nbsp; ( i I )</font>";
        }
        $parse['player_id'] = $GalaxyRowPlayer['id'];
        //Alliance
        $Alliance = false;
        if ($GalaxyRowPlayer["ally_id"] > 0) {
            $Alliance = true;
            $GalaxyRowAlly = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $GalaxyRowPlayer["ally_id"] . "' ;", 'alliance', true);
            $parse['ally_name'] = $GalaxyRowAlly["ally_name"];
            $parse['ally_tag'] = $GalaxyRowAlly["ally_tag"];
            $parse['ally_id'] = $GalaxyRowAlly["id"];
            $parse['aly_members'] = $GalaxyRowAlly["ally_members"];
        }
        //Planet Number and Name
        $parse['pos'] = $Planet;
        $parse['planet_name_short'] = $GalaxyRowPlanet['name'];
        $parse['planet_name'] = $GalaxyRowPlanet['name'];
        //Debris field.
        $parse['df_metal'] = $GalaxyRowPlanet['debris_m'];
        $parse['df_crystal'] = $GalaxyRowPlanet['debris_c'];
        $parse['df_recs'] = ceil(($parse['df_metal'] + $parse['df_crystal']) / $pricelist[209]['capacity']);
        //Planet Type
        $pt = PlanetType($GalaxyRowPlanet['image']);
        $parse['micro_planet_img'] = "img/planets/micro/" . $pt['type'] . "_" . $pt['subtype'] . "_1.gif";
        //Player Stuff
        $parse['avatar_small'] = '<img src=' . GetAvatar($GalaxyRowPlayer['email'], 50) . ' alt=Player&nbsp;avatar border=0 />';
        //Visualizzo il Rank del Player :
        $Rank = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $GalaxyRowPlayer['id'] . "';", 'statpoints');
        $parse['rank'] = $Rank['total_rank'];
        //$parse['rank'] = "PRIMOOO";
        //Tooltip height
        $parse['tooltip_height'] = 75 + 31 * $Planet;
        //PlanetIMG
        if ($noplanet) {
            $parse['td_microplanet'] = "";
            $parse['td_microplanet_class'] = 'microplanet1';
            $parse['td_microplanet_extra'] = '';
            $parse['td_microplanet_style'] = '';
            $parse['td_playername'] = "";
        } else {
            if ($CanPhalanx && $GalaxyRowPlayer['id'] != $user['id']) {
                //$parse['phalanx'] = "<li><a href=# onclick=loadpage(\'./?page=phalanx\',\'".$lang['Phalanx']."\',\'fleet1\');>".$lang['Phalanx']."</a></li>";
                $parse['phalanx'] = "<li><a href=# onclick=mrbox(\\'./?page=phalanx\\');>" . $lang['Phalanx'] . "</a></li>";
                //(url,width,margintop,title,method)
            } else {
                $parse['phalanx'] = "";
            }
            $parse['td_microplanet'] = parsetemplate(gettemplate('galaxy/microplanet'), $parse);
            $parse['td_microplanet_class'] = 'TTgalaxy microplanet';
            $parse['td_microplanet_extra'] = 'rel="#planet{pos}"';
            $parse['td_microplanet_style'] = 'background:url(' . GAME_SKIN . '/' . $parse['micro_planet_img'] . ') no-repeat top center;';
            $parse['td_playername'] = parsetemplate(gettemplate('galaxy/playername'), $parse);
        }
        //Alliance?
        if ($Alliance) {
            $parse['td_alliance'] = parsetemplate(gettemplate('galaxy/alliance'), $parse);
        }
        //Moon?
        if ($moondest) {
            $parse['td_moon'] = '<img src="img/galaxy/moon_c.gif" width="30" height="30" />';
        } elseif ($moon) {
            $parse['moon_name'] = $GalaxyRowMoon['name'];
            $parse['diametre'] = $GalaxyRowMoon['diameter'];
            $parse['td_moon'] = parsetemplate(gettemplate('galaxy/moon'), $parse);
        }
        //DF?
        if ($parse['df_metal'] + $parse['df_crystal'] > 0) {
            $parse['td_df'] = parsetemplate(gettemplate('galaxy/df'), $parse);
        }
        //Actions
        $mes = '<a class="tips thickbox" onclick="mrbox(\'./?page=write&to={id}&iframe=1&iheight=800\',800)" style="position:relative;">
			<img src="{{skin}}/img/icons/mail.gif" width="16" height="16" title="Write Message" />
		</a>';
        $bud = '<a class="tips" href="./?page=networkbuddy&a=2&u={id}" style="position:relative;">
			<img src="{{skin}}/img/icons/user.gif" width="16" height="16" title="Buddy request" />
		</a>';
        if ($user['spio_anz'] > $planetrow[$resource[210]]) {
            $probes = $planetrow[$resource[210]];
        } else {
            $probes = $user['spio_anz'];
        }
        $spy = '<a class="tips thickbox" href="#" onclick="mr_alert(\'<img height=16 width=16 src=\\\'../skins/xr//img/ajax-loader.gif\\\' /> {Loading}...\',\'<img src=\\\'{{skin}}/img/icons/auge.gif\\\' width=16 height=16 title=Spy />\'); getAXAH(\'./?page=fleet4&galaxy={galaxy}&system={system}&planet={pos}&planettype=1&fleet_array=a:1:{i:210;s:1:\\%22' . $probes . '\\%22;}&speed=10&mission=6&holdingtime=0&resource1=0&resource2=0&resource3=0\',\'errorBoxNotifyContent\'); return false;" style="position:relative;">
			<img src="{{skin}}/img/icons/auge.gif" width="16" height="16" title="Spy" />
		</a>';
        $ipm = '<a class="tips" href="#" onclick="mrbox(\'./?page=ipm&gal={galaxy}&sys={system}&pos={pos}&pt=1\',650,150);" style="position:relative;">
			<img src="{{skin}}/img/icons/rakete.gif" width="16" height="16" title="Missile Attack" />
		</a>';
        if (!$noplanet && $GalaxyRowPlayer["id"] != $user["id"]) {
            $parse['id'] = $GalaxyRowPlayer["id"];
            $parse['act_message'] = parsetemplate($mes, $parse);
            $parse['act_buddy'] = parsetemplate($bud, $parse);
            if ($planetrow[$resource[210]] > 0 && !ProtectNoob(array($Galaxy, $System, $Planet))) {
                $parse['act_spy'] = parsetemplate($spy, $parse);
            }
            if ($planetrow[$resource[503]] > 0 && ($planetrow['galaxy'] = $Galaxy && eval($formulas['ipm_range']) > abs($planetrow['system'] - $System) && !ProtectNoob(array($Galaxy, $System, $Planet)))) {
                $parse['act_nuke'] = parsetemplate($ipm, $parse);
            }
        }
        //Now make the whole row
        $Result .= parsetemplate(gettemplate('galaxy/galaxyrow_div'), $parse);
    }
    return $Result;
}
Exemple #3
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']);
}
Exemple #5
0
function NewHeader($bodyid)
{
    global $planetrow, $user, $onload, $dpath, $game_config, $resource, $_GET, $lang, $cid;
    getLang('menu');
    $parse = $lang;
    $parse['bodyid'] = $bodyid;
    //Top Menu
    $parse['forum_url'] = $game_config['forum_url'];
    $parse['game_name'] = $game_config['game_name'];
    //Basics
    $de_planettype = PlanetType($planetrow['image']);
    $parse['type'] = $de_planettype['type'];
    $parse['de_type'] = $de_planettype;
    $parse['de_string'] = $planetrow['image'];
    $parse['user_name'] = $user['username'];
    $parse['skin'] = $user['skin'];
    $parse['dpath'] = $user['dpath'];
    $parse['dpath'] = $dpath;
    //Moon extention
    if ($planetrow['planet_type'] == 3) {
        $parse['planet_ext'] = '-moon';
    } else {
        $parse['planet_ext'] = '';
    }
    if ($user['authlevel'] > 1) {
        $parse['adminlink'] = '<li><a href="./?page=admin">' . $lang['Amdin'] . '</a></li>';
    }
    //To get planet sub type (01 to 10) well will remove all except numbers. To remove the leading zeros, times by 1.
    $parse['subtype'] = $de_planettype['subtype'];
    //Messages
    if (strlen($user['messages']) > 0) {
        $messages = explode(",", $user['messages']);
        $mess = 0;
        foreach ($messages as $c) {
            $mess += $c;
        }
        if ($mess > 0) {
            $parse['showmail'] = 'visible';
            $parse['messages_count'] = pretty_number($mess);
        } else {
            $parse['showmail'] = 'hidden';
        }
    } else {
        $parse['showmail'] = 'hidden';
    }
    //Officers
    for ($offi = 601; $offi <= 605; $offi++) {
        //echo $user[$resource[$offi]]."-";
        if ($user[$resource[$offi] . "_exp"] < time()) {
            $parse["un" . $offi] = "_un";
            $parse["hire" . $offi] = "Hire " . $lang['names'][$offi];
        } else {
            $parse["un" . $offi] = "";
            //$parse["hire".$offi] = "Expires: ".date($lang['daymonth']."/y H:i",$user[$resource[$offi]."_exp"]);
            $remain = $user[$resource[$offi] . "_exp"] - time();
            if ($remain >= 86400) {
                $parse["hire" . $offi] = $lang['expiresin'] . " " . floor($remain / 86400) . " " . $lang['days'];
            } elseif ($remain >= 3600) {
                $parse["hire" . $offi] = $lang['expiresin'] . " " . floor($remain / 3600) . " " . $lang['hours'];
            }
        }
    }
    //M/C/D/DM
    $parse['metal'] = pretty_number($planetrow['metal'] * 1);
    $parse['crystal'] = pretty_number($planetrow['crystal'] * 1);
    $parse['deut'] = pretty_number($planetrow['deuterium'] * 1);
    $parse['kmetal'] = KMnumber($planetrow['metal'] * 1);
    $parse['kcrystal'] = KMnumber($planetrow['crystal'] * 1);
    $parse['kdeut'] = KMnumber($planetrow['deuterium'] * 1);
    $parse['energy'] = KMnumber($planetrow['energy_used'] + $planetrow['energy_max']);
    $parse['energy_green'] = " color=\"green\"";
    if ($parse['energy'] <= 0) {
        $parse['energy_red'] = " color=\"red\"";
        $parse['energy_green'] = " color=\"red\"";
    }
    $parse['energy_used'] = pretty_number(floor($planetrow['energy_used'] * -1));
    $parse['energy_max'] = pretty_number(floor($planetrow['energy_max'] * 1));
    $parse['matter'] = KMnumber(floor($user['matter']) * DARK_MATTER_FACTOR * 1);
    $parse['players'] = USER_RANK;
    $fl_tbl = GetFleetInfo($user, $planet);
    if ($fl_tbl) {
        $parse['fleet_table'] = $fl_tbl[0];
        $parse['eventboxdisplay'] = 'block';
    } else {
        $parse['eventboxdisplay'] = 'none';
    }
    if ($fl_tbl[1] > 0) {
        $parse['attack_alert'] = 'visible';
    } else {
        $parse['attack_alert'] = 'hidden';
    }
    $parse['onload'] = $onload;
    $parse['note_show'] = "none";
    $parse['desc_show'] = "none";
    if ($_GET['message'] && $_GET['etype']) {
        $parse['ncont'] = $_GET['message'];
        $parse['nhead'] = $_GET['title'];
        $parse[$_GET['etype'] . '_show'] = "float";
        $parse['go_ok'] = $_GET['to'];
        $parse['go_yes'] = $_GET['ifyes'];
        $parse['go_no'] = $_GET['ifno'];
        //$parse['errorbox'] = parsetemplate(gettemplate('redesigned/errorbox'),$parse);
    }
    $part = parsetemplate(gettemplate('redesigned/header'), $parse);
    //echo $part;
    return $part;
}
Exemple #6
0
/**
 * PlanetList.php
 *
 * @version 1
 * @copyright 2008 By MadnessRed for XNova_Redisigned
 */
function ShowPlanetList($axah = false, $debug = false)
{
    global $lang, $_GET, $user, $formulas, $resource;
    if ($debug) {
        echo "Started function<br /><br />";
    }
    if ($user) {
        //Make a lsit of player planets.
        $planetlist = '<br />';
        $ThisUsersPlanets = SortUserPlanets($user);
        if ($debug) {
            print_r(mysql_fetch_array($ThisUsersPlanets));
        }
        $c = 0;
        while ($CurPlanet = mysql_fetch_array($ThisUsersPlanets)) {
            if ($CurPlanet["destruyed"] == 0) {
                if ($CurPlanet['planet_type'] == 1) {
                    $CurMoon = doquery("SELECT `id`,`name`,`galaxy`,`system`,`planet`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurPlanet['galaxy'] . "' AND `system` = '" . $CurPlanet['system'] . "' AND `planet` = '" . $CurPlanet['planet'] . "' AND `planet_type` = '3' LIMIT 1 ;", 'planets', true);
                    if ($CurPlanet['id'] == $user['current_planet'] || $CurMoon['id'] == $user['current_planet']) {
                        $active = ' active';
                    } else {
                        $active = '';
                    }
                    $c++;
                    $img = PlanetType($CurPlanet['image']);
                    $pl_img = "/img/planets/" . $img['type'] . "_" . $img['subtype'] . "_{size}.gif";
                    //is there a moon
                    if ($CurMoon['id'] > 0) {
                        $moon_type_array = PlanetType($CurMoon['image']);
                        $moonlink = "\t\t\t\t<a class=\"moonlink\" onclick=\"loadpage(this.href,'" . $lang['Overview'] . " - " . $CurMoon['name'] . "','overview'); document.getElementById('planet_ext').value = '-moon'; document.getElementById('resources_menu_link').style.display = 'none'; return false;\" href=\"./?cp=" . $CurMoon['id'] . "&re=0\" onmouseover=\"mrtooltip_large('" . $CurMoon['name'] . " [" . $CurMoon['galaxy'] . ":" . $CurMoon['system'] . ":" . $CurMoon['planet'] . "]')\" onmouseout=\"UnTip()\">\n";
                        $moonlink .= "\t\t\t\t\t<img class=\"icon-moon\" src=\"" . GAME_SKIN . "/img/planets/moon/" . $moon_type_array['type'] . "_" . $moon_type_array['subtype'] . "_small.gif\" />\n";
                        $moonlink .= "\t\t\t\t</a>\n";
                    } else {
                        $moonlink = "";
                    }
                    $planetlist .= "\n";
                    $planetlist .= "\t\t\t<div class=\"smallplanet\">\n";
                    $planetlist .= "\t\t\t\t<a onclick=\"loadpage(this.href,'" . $lang['Overview'] . " - " . $CurPlanet['name'] . "','overview'); document.getElementById('planet_ext').value = ''; document.getElementById('resources_menu_link').style.display = 'block'; return false;\" href=\"./?cp=" . $CurPlanet['id'] . "&re=0\" onmouseover=\"mrtooltip_large('" . $CurPlanet['name'] . " [" . $CurPlanet['galaxy'] . ":" . $CurPlanet['system'] . ":" . $CurPlanet['planet'] . "]')\" onmouseout=\"UnTip()\" class=\"planetlink" . $active . " tips reloadTips\">\n";
                    $planetlist .= "\t\t\t\t\t<img class=\"planetPic\" src=\"" . GAME_SKIN . $pl_img . "\" />\n";
                    $planetlist .= "\t\t\t\t\t<span class=\"planet-name\">" . $CurPlanet['name'] . "</span>\n";
                    $planetlist .= "\t\t\t\t\t<span class=\"planet-koords\">[" . $CurPlanet['galaxy'] . ":" . $CurPlanet['system'] . ":" . $CurPlanet['planet'] . "]</span>\n";
                    $planetlist .= "\t\t\t\t</a>\n";
                    $planetlist .= $moonlink;
                    $planetlist .= "\t\t\t</div>\n";
                }
            }
        }
        if ($c > 5) {
            $mode = 'cutty';
            $name = 'myPlanets';
            $size = '1';
        } else {
            $mode = 'norm';
            $name = 'myWorlds';
            $size = '3';
        }
        $planetlist = str_replace('{size}', $size, $planetlist);
        if ($axah) {
            $return = "\t<div id=\"" . $mode . "\">\n\t\t<div id=\"" . $name . "\">\n\n\t\t\t<div id=\"countColonies\">\n\t\t\t\t<p class=\"textCenter tips\" title=\"|\">\n\t\t\t\t\t<span>" . $c . "/" . eval($formulas['max_planets']) . "</span> Planets\n\t\t\t\t</p>\n\t\t\t</div>" . $planetlist . "\n\n\t\t</div>\n\t</div>\n";
        } else {
            $return = "<!-- RIGHTMENU -->\n<div id=\"rechts\">\n\n\t<div id=\"" . $mode . "\">\n\t\t<div id=\"" . $name . "\">\n\n\t\t\t<div id=\"countColonies\">\n\t\t\t\t<p class=\"textCenter tips\" title=\"|\">\n\t\t\t\t\t<span>" . $c . "/" . eval($formulas['max_planets']) . "</span> Planets\n\t\t\t\t</p>\n\t\t\t</div>" . $planetlist . "\n\n\t\t</div>\n\t</div>\n</div>\n<!-- END RIGHTMENU -->\n";
        }
    } else {
        $return = "";
        if ($debug) {
            echo "\$user returned <font color=blue><b>false</b></font><br /><br />";
            print_r($user);
        }
    }
    return $return;
}
Exemple #7
0
								<img src="{{skin}}/img/planets{moon}/{type}_{subtype}_7.jpg" width="156" height="156" />
							</div>
							<div id="coords[{n}]" class="coords">
								<a href="./?page=galaxy&galaxy={gal}&system={sys}">[{gal}:{sys}:{pos}]</a>
							</div>
							<div id="" class="fields tips" title="|Current fields / max fields">
								<span id="space[{n}]">{current_feild}/{max_feild}</span>
							</div>
							<div class="clearfloat"></div>
						</td>';
$parse['planets'] = '';
$array = array();
$n = 0;
while ($p = FetchArray($planetsrow)) {
    $n++;
    $pl = PlanetType($p['image']);
    $pl['n'] = $n;
    $pl['gal'] = $p['galaxy'];
    $pl['sys'] = $p['system'];
    $pl['pos'] = $p['planet'];
    $pl['current_feild'] = $p['field_current'];
    $pl['max_feild'] = $p['field_max'];
    $pl['name'] = $p['name'];
    $pl['moon'] = '';
    if ($p['planet_type'] == 3) {
        $pl['moon'] = '/moon';
    }
    $parse['planets'] .= parsetemplate($planetsTPL, $pl);
    $array['resources']['metal']['n'] = $lang['Metal'];
    $array['resources']['metal'][$n] = KMnumber($p['metal']) . " / " . KMnumber($p['metal_max']);
    $array['resources']['crystal']['n'] = $lang['Crystal'];
Exemple #8
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']);
    }
}