Пример #1
0
/**
 * RecallFleet.php
 *
 * @version 1.0
 * @copyright 2010 By MadnessRed for XNova Redesigned
 */
function RecallFleet($id, $key = 'x', $user = '******')
{
    global $lang;
    //Get the lang strings
    getLang('fleet_management');
    //See what validation is needed
    $and = '';
    if ($key != 'x') {
        $and .= " AND `passkey` = '" . idstring($key) . "'";
    }
    if ($user != 'x') {
        $and .= " AND `owner_userid` = '" . idstring($user) . "'";
    }
    //First get said fleet:
    $fleetrow = doquery("SELECT *, COUNT('fleet_id') AS `count` FROM {{table}} WHERE `fleet_id` = '" . idstring($id) . "'" . $and . " AND `fleet_mess` = '0' AND `mission` <> '0' ;", 'fleets', true);
    //Check we found the fleet:
    if ($fleetrow['count'] == 1) {
        //Incase script takes over a second, lets keep now constant.
        $now = time();
        //Duration in flight
        $duration = $now - $fleetrow['departure'];
        //ok, lets update the fleet
        doquery("UPDATE {{table}} SET `departure` = '" . $now . "', `arrival` = '" . ($now + $duration) . "', `target_id` = '" . $fleetrow['owner_id'] . "', `target_userid` = '" . $fleetrow['owner_userid'] . "', `owner_id` = '" . $fleetrow['target_id'] . "', `owner_userid` = '" . $fleetrow['target_userid'] . "', `fleet_mess` = '1', `mission` = '0' WHERE `fleet_id` = '" . $fleetrow['fleet_id'] . "' ;", 'fleets', false);
        //Remove any partner fleets
        doquery("DELETE FROM {{table}} WHERE `partner_fleet` = '" . $fleetrow['fleet_id'] . "' ;", 'fleets', false);
        //Update menus
        doquery("UPDATE {{table}} SET `menus_update` = '" . time() . "' WHERE `id` = '" . $fleetrow['owner_userid'] . "' LIMIT 1 ;", 'users', false);
        doquery("UPDATE {{table}} SET `menus_update` = '" . time() . "' WHERE `id` = '" . $fleetrow['target_userid'] . "' LIMIT 1 ;", 'users', false);
        //Thats it
        return $lang['fleet_recall'];
    } else {
        return $lang['fleet_not_fnd'];
    }
}
Пример #2
0
/**
 * PM.php
 *
 * @version 1.1
 * @copyright 2009 by MadnessRed for XNova Redeisgned
 */
function PM($to, $from, $message, $subject = '', $sender = '', $type = 0)
{
    //Add the message to the databas (xnova code) with a bit of security modification
    $QryInsertMessage = "INSERT INTO {{table}} SET ";
    $QryInsertMessage .= "`message_owner` = '" . idstring($to) . "', ";
    $QryInsertMessage .= "`message_sender` = '" . idstring($from) . "', ";
    $QryInsertMessage .= "`message_text` = '" . mysql_real_escape_string(addslashes($message)) . "', ";
    $QryInsertMessage .= "`message_subject` = '" . mysql_escape_string(addslashes($subject)) . "', ";
    $QryInsertMessage .= "`message_from` = '" . mysql_real_escape_string(addslashes($sender)) . "', ";
    $QryInsertMessage .= "`message_type` = '" . idstring($type) . "', ";
    $QryInsertMessage .= "`message_time` = '" . time() . "';";
    doquery($QryInsertMessage, 'messages');
    //Get the target
    $target = doquery("SELECT `id`,`messages` FROM {{table}} WHERE `id` = '" . idstring($to) . "' LIMIT 1 ;", 'users', true);
    //Set messages of this type to +1
    if (strlen($target['messages']) == 0) {
        $target['messages'] = '0,0,0,0,0,0';
    }
    $messages = explode(",", $target['messages'], 6);
    if ($type < 0 || $time > 5) {
        $type = 5;
    }
    $messages[$type] += 1;
    $newmessages = implode(",", $messages);
    //$newmessages = $messages[0].",".$messages[1].",".$messages[2].",".$messages[3].",".$messages[4].",".$messages[5];
    doquery("UPDATE {{table}} SET `messages` = '" . $newmessages . "', `menus_update` = '" . time() . "' WHERE `id` = '" . $target['id'] . "' LIMIT 1 ;", 'users');
}
Пример #3
0
function AddMoon($galaxy, $system, $planet, $chance = 20, $name = '_DEFAULT_', $CurrentPlanet = false, $num = 0)
{
    global $lang;
    if ($name == '_DEFAULT_') {
        $name = $lang['sys_moon'];
    }
    if (idstring($num) < 1 || idstring($num) < 5) {
        $num = mt_rand(1, 5);
    }
    $num = '0' . idstring($num);
    //Firsly is there already a moon here?
    $moons = mysql_num_rows(doquery("SELECT `id` FROM {{table}} WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '3' LIMIT 1 ;", 'planets', false));
    if ($moons > 0) {
        return "There is already a moon in orbit here.";
    } else {
        //First get the homeplanet
        if (!is_array($CurrentPlanet)) {
            $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '1' LIMIT 1 ;", 'planets', true);
        }
        //Get min and max temps
        $tempmin = $CurrentPlanet['temp_min'] - rand(10, 45);
        $tempmax = $CurrentPlanet['temp_max'] - rand(10, 45);
        //It is possible that min temp becomes greater than max temp, if so just flip them
        if ($tempmin > $tempmax) {
            $temp = $tempmin;
            $tempmin = $tempmax;
            $tempmax = $temp;
        }
        //Now the long query...
        $qry = "INSERT INTO {{table}} SET ";
        $qry .= "`name` = '" . mysql_real_escape_string($name) . "', ";
        $qry .= "`id_owner` = '" . idstring($CurrentPlanet['id_owner']) . "', ";
        $qry .= "`galaxy` = '" . idstring($galaxy) . "', ";
        $qry .= "`system` = '" . idstring($system) . "', ";
        $qry .= "`planet` = '" . idstring($planet) . "', ";
        $qry .= "`planet_type` = '3', ";
        $qry .= "`last_update` = '" . time() . "', ";
        $qry .= "`image` = 'mond" . $num . "', ";
        $qry .= "`diameter` = '" . idstring(rand(2000 + $chance * 100, 6000 + $chance * 200)) . "', ";
        $qry .= "`field_max` = '1', ";
        $qry .= "`temp_min` = '" . idstring($tempmin) . "', ";
        $qry .= "`temp_max` = '" . idstring($tempmax) . "', ";
        $qry .= "`metal` = '0', ";
        $qry .= "`metal_perhour` = '0', ";
        $qry .= "`metal_max` = '" . BASE_STORAGE_SIZE . "', ";
        $qry .= "`crystal` = '0', ";
        $qry .= "`crystal_perhour` = '0', ";
        $qry .= "`crystal_max` = '" . BASE_STORAGE_SIZE . "', ";
        $qry .= "`deuterium` = '0', ";
        $qry .= "`deuterium_perhour` = '0', ";
        $qry .= "`deuterium_max` = '" . BASE_STORAGE_SIZE . "' ;";
        //Do the query and return the result.
        $temp = true;
        doquery($qry, 'planets') or write_to_temp(mysql_error());
        //Tell the user to update his planetlist
        doquery("UPDATE {{table}} SET `menus_update` = '" . time() . "' WHERE `id` = '" . idstring($CurrentPlanet['id_owner']) . "' LIMIT 1;", 'users');
        return $temp;
    }
}
Пример #4
0
function AddToPlanet($CurrentPlanet, $element, $mode, $charge = false)
{
    global $resources, $resource, $reslist;
    //Well, we need to work out the cost for the points and edit the planets table
    //Standard construction
    //Get the cost
    $cost = BuildingCost($element, $CurrentPlanet[$resource[$element]] + $mode);
    $chargestr = '';
    if ($charge) {
        //If we are changine
        foreach ($resources as $res) {
            //loop through resources
            //Now add to query
            $chargestr .= ", `" . $res . "` = `" . $res . "` - '" . $cost[$res] . "' ";
        }
    }
    //And we will want a + in the query
    $p_sign = "+";
    //If its deconstruction though..
    if ($mode < 0) {
        //Deconstructon
        //Get the cost
        $cost = BuildingCost($element, $CurrentPlanet[$resource[$element]]);
        //And we will want a - in the query
        $p_sign = "-";
    }
    //start total cost
    $tcost = 0;
    //Now the resources which count towards points
    foreach ($resources as $res) {
        //Add them to the total
        $tcost += $cost[$res];
    }
    //Now update the table
    $qry = "UPDATE {{table}} SET `" . $resource[$element] . "` = `" . $resource[$element] . "` " . $p_sign . " " . idstring(abs($mode)) . " " . $chargestr . " WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;";
    $return = doquery($qry, 'planets', false);
    //If it is less than 100, update slots used
    if ($element < 100) {
        doquery("UPDATE {{table}} SET `field_current` = `field_current` " . $p_sign . " " . idstring(abs($mode)) . " WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;", 'planets', false);
    }
    //Now update the users stats
    //	Are we making fleet?
    $fleet_points = 0;
    if (in_array($element, $reslist['fleet'])) {
        $fleet_points += $mode;
    }
    //Update in database
    doquery("UPDATE {{table}} SET `total_points` = `total_points` + '" . $tcost . "', `fleet_points` = `fleet_points` + '" . $fleet_points . "' WHERE `id` = '" . $CurrentPlanet['id_owner'] . "' LIMIT 1 ;", 'users');
    //Return the result
    return $return;
}
Пример #5
0
function AddPoints($points, $perma = false, $id = false)
{
    global $user;
    if (!$id) {
        $id = $user['id'];
    }
    //echo "Adding ".$points." to user ".$user['username']."<br />";
    if ($points < 0) {
        $sign = "-";
        $points = mod(idstring($points));
    } else {
        $sign = "+";
    }
    if ($perma) {
        $permapart = ", `perma_points` = `perma_points` " . $sign . " '" . idstring($points) . "'";
    }
    doquery("UPDATE {{table}} SET `total_points` = `total_points` " . $sign . " '" . idstring($points) . "'" . $permapart . " WHERE `id` = '" . idstring($id) . "' ;", 'users');
}
Пример #6
0
/**
 * ProtectNoob.php
 *
 * @version 1
 * @copyright 2009 By MadnessRed for XNova Redesigned
 */
function ProtectNoob($input, $currentuser = false)
{
    if ($currentuser) {
        global $game_config;
        //We need to get the current user.
        if (is_array($currentuser)) {
            //We have co-ords
            $qry = doquery("SELECT `id_owner` FROM {{table}} WHERE `galaxy` = '" . idstring($input[0]) . "' AND `galaxy` = '" . idstring($input[1]) . "' AND `galaxy` = '" . idstring($input[2]) . "' LIMIT 1 ;", 'planets', true);
            $uid = $qry['id_owner'];
        } else {
            //We have an id.
            $uid = $currentuser;
        }
        $user = doquery("SELECT `total_points` FROM {{table}} WHERE `id` = '" . idstring($uid) . "' LIMIT 1 ;", 'users', true);
    } else {
        global $user, $game_config;
    }
    if (is_array($input)) {
        //We have co-ords
        $qry = doquery("SELECT `id_owner` FROM {{table}} WHERE `galaxy` = '" . idstring($input[0]) . "' AND `galaxy` = '" . idstring($input[1]) . "' AND `galaxy` = '" . idstring($input[2]) . "' LIMIT 1 ;", 'planets', true);
        $id = $qry['id_owner'];
    } else {
        //We have an id.
        $id = $input;
    }
    //How many poitns does the attack have?
    $att_pts = $user['total_points'];
    //How many points does the defender have?
    $def_pts = doquery("SELECT `total_points` FROM {{table}} WHERE `id` = '" . idstring($id) . "' LIMIT 1 ;", 'users', true);
    $def_pts = $def_pts['total_points'];
    //Now what the the noob protection threshold?
    $th = $game_config['stat_settings'] * $game_config['noobprotectiontime'];
    if ($def_pts >= $th && $def_pts * $game_config['noobprotectionmulti'] <= $att_pts) {
        //The defender is under the threshold and is less than 20% of the attackers score
        return true;
    } elseif ($att_pts >= $th && $att_pts * $game_config['noobprotectionmulti'] <= $def_pts) {
        //The attacker is under the threshold and is less than 20% of the defenders score
        return true;
    } else {
        //Neither of hte above to, we are clear to attack.
        return false;
    }
}
Пример #7
0
            doquery($QryUpdatemsg, "supp");
        }
        $parse['actionpage'] = 'admin&link=supp';
        displaypage(parsetemplate(gettemplate('supp_answ_send'), $parse), 'Support', true);
    }
} elseif ($_GET['schliessen'] == "1") {
    $QryUpdatemsg = "UPDATE {{table}} SET `status` = '0' WHERE `id` = '" . idstring($_GET['ticket']) . "' ";
    doquery($QryUpdatemsg, "supp");
    info($lang['close_t'], $lang['close_ticket'], "./?page=admin&link=supp");
} elseif ($_GET['open'] == "1") {
    $QryUpdatemsg = "UPDATE {{table}} SET `status` = '2' WHERE `id` = '" . idstring($_GET['ticket']) . "' ";
    doquery($QryUpdatemsg, "supp");
    info($lang['open_t'], $lang['open_ticket'], "./?page=admin&link=supp");
} else {
    /// Listenanzeige der eigenen tickets
    $query2 = doquery("SELECT * FROM {{table}} WHERE `ID` = '" . idstring($_GET['ticket']) . "'", "supp");
    while ($ticket2 = mysql_fetch_array($query2)) {
        if ($ticket2['status'] == 0) {
            $status = colourred($lang['statusc']);
            $parse['answer_new'] = $lang['close_t'];
        } elseif ($ticket2['status'] == 1) {
            $status = colourgreen($lang['statuso']);
            $parse['eintrag'] = '
			<textarea name="senden_antwort_text" class="textBox" rows="30" cols="20" onFocus="this.value=\'\'; this.onfocus=null;"></textarea>
			<center><input class="button188" type="submit" name="send" value="' . $lang['send'] . '"></center>';
        } else {
            $status = colourred($lang['statusa']);
            $parse['eintrag'] = '
			<textarea name="senden_antwort_text" class="textBox" rows="30" cols="20" onFocus="this.value=\'\'; this.onfocus=null;"></textarea>
			<center><input class="button188" type="submit" name="send" value="' . $lang['send'] . '"></center>';
        }
Пример #8
0
/**
 * 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']);
}
Пример #9
0
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $phpEx, $dpath, $_POST, $reslist, $pricelist;
    if (isset($_POST['fmenge'])) {
        // On vient de Cliquer ' Construire '
        // Et y a une liste de doléances
        // Ici, on sait precisement ce qu'on aimerait bien construire ...
        // Gestion de la place disponible dans les silos !
        $Missiles[502] = $CurrentPlanet[$resource[502]];
        $Missiles[503] = $CurrentPlanet[$resource[503]];
        $SiloSize = $CurrentPlanet[$resource[44]];
        $MaxMissiles = $SiloSize * 10;
        // On prend les missiles deja dans la queue de fabrication aussi (ca aide)
        $BuildQueue = $CurrentPlanet['b_hangar_id'];
        $BuildArray = explode(";", $BuildQueue);
        for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
            $ElmentArray = explode(",", $BuildArray[$QElement]);
            if ($ElmentArray[502] != 0) {
                $Missiles[502] += $ElmentArray[502];
            } elseif ($ElmentArray[503] != 0) {
                $Missiles[503] += $ElmentArray[503];
            }
        }
        foreach ($_POST as $Element => $Count) {
            $Element = idstring($Element);
            if (in_array($Element, $reslist['fleet'])) {
                $Element = intval($Element);
                $Count = intval($Count);
                if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                    $Count = MAX_FLEET_OR_DEFS_PER_ROW;
                }
                if ($Count != 0) {
                    // Cas particulier (Petit Bouclier et Grand Bouclier
                    // ne peuvent exister qu'une seule et unique fois
                    $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
                    $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false;
                    if ($Element == 407 || $Element == 408) {
                        if ($InQueue === false && !$IsBuild) {
                            $Count = 1;
                        }
                    }
                    // On verifie si on a les technologies necessaires a la construction de l'element
                    if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                        // On verifie combien on sait faire de cet element au max
                        $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                        // Testons si on a de la place pour ces nouveaux missiles !
                        if ($Element == 502 || $Element == 503) {
                            // Cas particulier des missiles
                            $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                            $MissilesSpace = $MaxMissiles - $ActuMissiles;
                            if ($Element == 502) {
                                if ($Count > $MissilesSpace) {
                                    $Count = $MissilesSpace;
                                }
                            } else {
                                if ($Count > floor($MissilesSpace / 2)) {
                                    $Count = floor($MissilesSpace / 2);
                                }
                            }
                            if ($Count > $MaxElements) {
                                $Count = $MaxElements;
                            }
                            $Missiles[$Element] += $Count;
                        } else {
                            // Si pas assez de ressources, on ajuste le nombre d'elements
                            if ($Count > $MaxElements) {
                                $Count = $MaxElements;
                            }
                        }
                        $Ressource = GetElementRessources($Element, $Count);
                        $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                        if ($Count >= 1) {
                            $CurrentPlanet['metal'] -= $Ressource['metal'];
                            $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                            $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                            $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
                        }
                    }
                }
            }
        }
    }
    // -------------------------------------------------------------------------------------------------------
    // S'il n'y a pas de Chantier ...
    if ($CurrentPlanet[$resource[21]] == 0) {
        $shipyard = false;
    } else {
        $shipyard = true;
    }
    // -------------------------------------------------------------------------------------------------------
    // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ...
    $TabIndex = 0;
    $PageTable = "";
    $SubTemplate = gettemplate('buildings/defense_buttonz');
    $parse = array();
    $infopg = array();
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $reslist['defense'])) {
            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] = "";
            }
            $parse['name_' . $Element] = $ElementName;
            $parse['count_' . $Element] = $CurrentPlanet[$resource[$Element]];
        } else {
            $parse['state_' . $Element] = "off";
            $parse['mes_' . $Element] = "Not availble";
        }
    }
    $Buttonz = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['tech'][$Element];
    if (!$Element) {
        $parse['bg'] = "../img/headerCache/station/" . $parse['type'] . ".png";
    } else {
        if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element) && IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false)) {
            $infopg['build_link'] = '#" onclick="document.forms.shipyard.submit()';
        }
        //Building Info
        if ($infopg['build_link']) {
            $infopg['buildit_class'] = "build-it";
            $infopg['build_text'] = "Build";
        } else {
            $infopg['buildit_class'] = "build-it_disabled";
            $infopg['build_text'] = "Build";
        }
        $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&id=" . $Element . "&building=" . $Element;
        $infopg['title'] = "Tear down";
        $infopg['level1'] = $infopg['level'] + 1;
        $infopg['duration'] = pretty_time(GetBuildingTime($CurrentUser, $CurrentPlanet, $Element));
        $infopg['shortdesc'] = $lang['res']['descriptions'][$Element];
        $infopg['skin'] = $CurrentUser['skin'];
        $infopg['cost_m'] = $pricelist[$Element]['metal'];
        $infopg['cost_c'] = $pricelist[$Element]['crystal'];
        $infopg['cost_d'] = $pricelist[$Element]['deuterium'];
        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/sy_info'), $infopg);
        $parse['extra'] = "style=\"display:none\"";
    }
    $parse['buttonz'] = $Buttonz;
    $page = parsetemplate(gettemplate('buildings/shipyard'), $parse);
    displaypage($page, $lang['Defense']);
}
Пример #10
0
/**
 * MissionCaseDestroy.php
 *
 * @version 1.0
 * @copyright 2009 By MadnessRed for XNova Redesigned
 */
function MissionCaseDestroy($FleetRow, $CurrentPlanet)
{
    global $resource, $lang, $CombatCaps, $pricelist;
    //Get the fleet
    $fleet = array();
    foreach (explode(';', $FleetRow['array']) as $r) {
        $r = explode(',', $r);
        $fleet[$r[0]] = $r[1];
    }
    //Check we still have Deathstarts
    if ($fleet[214] > 0) {
        $destroyed = array(false, false);
        //Firstly is the moon destroyed:
        $chance_m = (100 - pow($moonsize, 0.5)) * pow($fleet[214], 0.5);
        if ($chance_m > mt_rand(0, 100)) {
            //Any fleet going to the moon should be recalled
            $tomoon = doquery("SELECT `fleet_id` FROM {{table}} WHERE `target_id` = '" . $CurrentPlanet['id'] . "' AND `fleet_mess` = '0' ;", 'fleets', false);
            while ($row = FetchArray($tomoon)) {
                $fleetrow = doquery("SELECT *, COUNT('fleet_id') AS `count` FROM {{table}} WHERE `fleet_id` = '" . idstring($row['fleet_id']) . "' AND `fleet_mess` = '0' AND `mission` <> '0' ;", 'fleets', true);
                //Check we found the fleet:
                if ($fleetrow['count'] == 1) {
                    //Incase script takes over a second, lets keep now constant.
                    $now = time();
                    //Duration in flight
                    $duration = $now - $fleetrow['departure'];
                    //ok, lets update the fleet
                    doquery("UPDATE {{table}} SET `departure` = '" . $now . "', `arrival` = '" . ($now + $duration) . "', `target_id` = '" . $fleetrow['owner_id'] . "', `target_userid` = '" . $fleetrow['owner_userid'] . "', `owner_id` = '" . $fleetrow['target_id'] . "', `owner_userid` = '" . $fleetrow['target_userid'] . "', `fleet_mess` = '1', `mission` = '0' WHERE `fleet_id` = '" . $fleetrow['fleet_id'] . "' ;", 'fleets', false);
                    //Remove any partner fleets
                    doquery("DELETE FROM {{table}} WHERE `partner_fleet` = '" . $fleetrow['fleet_id'] . "' ;", 'fleets', false);
                    //Update menus
                    doquery("UPDATE {{table}} SET `menus_update` = '" . time() . "' WHERE `id` = '" . $fleetrow['owner_userid'] . "' LIMIT 1 ;", 'users', false);
                }
            }
            //And fleets returning to the moon should go the planet
            $planet = doquery("SELECT `id` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '1' LIMIT 1 ;", 'planets', true);
            doquery("UPDATE {{table}} SET `target_id` = '" . $planet['id'] . "' WHERE `target_id` = '" . $CurrentPlanet['id'] . "' ;", 'fleets', false);
            doquery("UPDATE {{table}} SET `owner_id` = '" . $planet['id'] . "' WHERE `owner_id` = '" . $CurrentPlanet['id'] . "' ;", 'fleets', false);
            //Delete the moon
            doquery("DELETE FROM {{table}} WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;", 'planets', false);
            //Mark it as destroyed for the message
            $destroyed[0] = true;
        }
        //Secondly are the Deathstars destroyed.
        $chance_k = 0.5 * pow($moonsize, 0.5);
        if ($chance_k > mt_rand(0, 100)) {
            //Are there any other ships in the fleet?
            if (array_sum($fleet) > $fleet[214]) {
                //Remove rips from the fleet
                unset($fleet[214]);
                //Compile fleet array
                $array = array();
                foreach ($fleet as $id => $c) {
                    $array[] = $id . "," . $c;
                }
                $array = implode(";", $array);
                //Update row
                doquery("UPDATE {{table}} SET `array` = '" . $array . "', `count` = `count` - '" . array_sum($fleet) . "' WHERE `fleet_id` = '" . $FleetRow['fleet_id'] . "' LIMIT 1 ;", 'fleets', false);
            } else {
                //Just remove the fleet
                DeleteFleet($FleetRow['fleet_id']);
            }
            //Mark it as destroyed for the message
            $destroyed[1] = true;
        }
        //Start the message
        $HomePlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $row['target_id'] . "' LIMIT 1 ;", 'planets', true);
        $message = '';
        $message .= sprintf($lang['fleet_9_mess1'], $HomePlanet['name'] . " [" . $HomePlanet['galaxy'] . ":" . $HomePlanet['system'] . ":" . $HomePlanet['planet'] . "]", "[" . $CurrentPlanet['galaxy'] . ":" . $CurrentPlanet['system'] . ":" . $CurrentPlanet['planet'] . "]");
        $message .= sprintf($lang['fleet_9_moon'], $chance_m . '%') . "<br />";
        $message .= sprintf($lang['fleet_9_rips'], $chance_k . '%') . "<br />";
        $message .= $lang['fleet_9_mess2'];
        //So what happen (for the message?)
        if ($destroyed[0] && $destroyed[1]) {
            //Both moon and RIPs destroyed
            $message .= $lang['fleet_9_messD'];
            $message .= $lang['fleet_9_messK'];
        } elseif ($destroyed[0]) {
            //Moon Destroyed
            $message .= $lang['fleet_9_messD'];
        } elseif ($destroyed[1]) {
            //RIPs destroyed
            $message .= $lang['fleet_9_messK'];
        } else {
            //Nothing destroyed
            $message .= $lang['fleet_9_messN'];
        }
        PM($FleetRow['owner_userid'], 0, $message, sprintf($lang['fleet_9_tit'], $CurrentPlanet['name']), $lang['fleet_control'], 2);
        PM($FleetRow['target_userid'], 0, $message, sprintf($lang['fleet_9_tit'], $CurrentPlanet['name']), $lang['fleet_control'], 2);
    }
}
Пример #11
0
includeLang('admin');
$parse = $lang;
//Server root?
$server_root = "/home/evo/public_html/new/";
// Supprimer les erreurs
extract($_GET);
if ($group == 1) {
    $query = doquery("SELECT error_page, error_text, COUNT(error_id) FROM {{table}} WHERE `error_type` = 'ANTI-CHEAT' GROUP BY error_page ;", 'errors');
    $parse['errors_list'] = "<tr>\r\n\t<th colspan=\"1\" style=\"border-width:1px;border-color:#888888;border-style:solid;width:25px;\">\r\n\t\tCount\r\n\t</th>\r\n\t<th colspan=\"4\" style=\"border-width:1px;border-color:#888888;border-style:solid;width:527px;\">\r\n\t\tError\r\n\t</th>\r\n</tr>";
    $parse['group_errors'] = '<a href="./?page=admin&link=errors&group=0">Ungroup Errors</a>';
    while ($u = mysql_fetch_array($query)) {
        $parse['errors_list'] .= "\r\n\t\t<tr>\r\n\t\t\t<td width=\"25\" style=\"border-width:1px;border-color:#888888;border-style:solid;\">" . $u['COUNT(error_id)'] . "</td>\r\n\t\t\t<td colspan=\"4\" style=\"border-width:1px;border-color:#888888;border-style:solid;\">" . str_replace($server_root, "./", $u['error_page']) . "</td>\r\n\t\t</tr>\r\n\t\t<tr><td colspan=\"5\" style=\"border-width:1px;border-color:#888888;border-style:solid;\">" . nl2br($u['error_text']) . "</td></tr>";
    }
} else {
    if (isset($delete)) {
        doquery("DELETE FROM {{table}} WHERE `error_id`='" . idstring($delete) . "'", 'errors');
    } elseif ($deleteall == 'yes') {
        doquery("TRUNCATE TABLE {{table}}", 'errors');
    }
    // Afficher les erreurs
    $sort = $_GET['sort'];
    if (strlen($sort) == 0) {
        $sort = "error_id";
    }
    if ($_GET['ord'] == 2) {
        $ord = "DESC";
        $parse['oth_ord'] = 1;
    } else {
        $ord = "ASC";
        $parse['oth_ord'] = 2;
    }
Пример #12
0
/**
* This file manages the output from the battle, it formats the cr, it makes the debris field, and then sends the fleets home.
* Here is the expected imput
	$results = array(
		[debrcry] => num
		[debrmet] => num
		[attlost] => num
		[deflost] => num
		[won]	 => char //(d)raw, (a)ttacker ,(v)defender
		[data] => array(
			[$roundno] => array(
				[attfires] => num
				[attpower] => num
				[attblock] => num
				[deffires] => num
				[defpower] => num
				[defblock] => num
				[attack_fleets] => array(
					[$fleetid] => array(
	either:				[$shiptype] => array('count' => num)
	or:					[$shiptype] => num
					)
				)
				[defend_fleets] => array(
					[$fleetid] => array(
	either:				[$shiptype] => array('count' => num)
	or:					[$shiptype] => num
					)
				)
			)
		)
	)
*/
function ManageCR($results, $CurrentPlanet)
{
    global $resource, $lang, $CombatCaps, $pricelist, $reslist;
    //The usual...
    $parse = $lang;
    //This will be poulated with planet and user data later.
    $fleets = array();
    $permafleets = array();
    //Loop through the rounds:
    $parse['rounds'] = '';
    foreach ($results['data'] as $roundno => $round) {
        $rparse = array();
        //List attackers and defenders fleets.
        $rparse['attackers'] = '';
        foreach ($round['attack_fleets'] as $id => $attacker) {
            //Lets get some info about this guy
            if ($roundno == 0) {
                $fleets[$id] = array();
                $fleets[$id]['side'] = 'a';
                if ($id > 0) {
                    $fleets[$id]['user'] = doquery("SELECT * FROM {{table}} WHERE `id` = (SELECT `owner_userid` FROM {{prefix}}fleets WHERE `fleet_id` = '" . idstring($id) . "') LIMIT 1 ;", 'users', true);
                } else {
                    $fleets[$id]['user'] = doquery("SELECT * FROM {{table}} WHERE `{{table}}`.`id` = '" . idstring($CurrentPlanet['id_owner']) . "' LIMIT 1 ;", 'users', true);
                }
            }
            $aparse = $lang;
            $aparse['td_types'] = '';
            $aparse['td_count'] = '';
            $aparse['td_weapons'] = '';
            $aparse['td_shields'] = '';
            $aparse['td_armour'] = '';
            $aparse['weap_pc'] = $fleets[$id]['user'][$resource[109]] * 10;
            $aparse['shield_pc'] = $fleets[$id]['user'][$resource[111]] * 10;
            $aparse['hull_pc'] = $fleets[$id]['user'][$resource[110]] * 10;
            $aparse['mode'] = 'attacker';
            $aparse['name'] = $lang['Attacker'] . " " . $fleets[$id]['user']['username'] . " <a>[" . $fleets[$id]['user']['galaxy'] . ":" . $fleets[$id]['user']['system'] . ":" . $fleets[$id]['user']['planet'] . "]</a>";
            foreach ($attacker as $id => $count) {
                if (is_array($count)) {
                    $count = $count['count'];
                }
                $aparse['td_types'] .= "\t\t\t\t\t\t\t\t\t\t<th class=\"textGrow\">" . $lang['cr_names'][$id] . "</th>\n";
                $aparse['td_count'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($count) . "</td>\n";
                $aparse['td_weapons'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($CombatCaps[$id]['attack']) . "</td>\n";
                $aparse['td_shields'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($CombatCaps[$id]['shield']) . "</td>\n";
                $aparse['td_armour'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($pricelist[$id]['metal'] + $pricelist[$id]['crystal']) . "</td>\n";
            }
            $rparse['attackers'] .= parsetemplate(gettemplate('fleet/combatattacker'), $aparse);
        }
        $rparse['defenders'] = '';
        foreach ($round['defend_fleets'] as $id => $defender) {
            //Lets get some info about this guy
            if ($roundno == 0) {
                $fleets[$id] = array();
                $fleets[$id]['side'] = 'd';
                if ($id > 0) {
                    $fleets[$id]['user'] = doquery("SELECT * FROM {{table}} WHERE `id` = (SELECT `owner_userid` FROM {{prefix}}fleets WHERE `fleet_id` = '" . idstring($id) . "') LIMIT 1 ;", 'users', true);
                } else {
                    $fleets[$id]['user'] = doquery("SELECT * FROM {{table}} WHERE `{{table}}`.`id` = '" . idstring($CurrentPlanet['id_owner']) . "' LIMIT 1 ;", 'users', true);
                }
            }
            $aparse = $lang;
            $aparse['td_types'] = '';
            $aparse['td_count'] = '';
            $aparse['td_weapons'] = '';
            $aparse['td_shields'] = '';
            $aparse['td_armour'] = '';
            $aparse['weap_pc'] = $fleets[$id]['user'][$resource[109]] * 10;
            $aparse['shield_pc'] = $fleets[$id]['user'][$resource[111]] * 10;
            $aparse['hull_pc'] = $fleets[$id]['user'][$resource[110]] * 10;
            $aparse['mode'] = 'defender';
            $aparse['name'] = $lang['Defender'] . " " . $fleets[$id]['user']['username'] . " <a>[" . $fleets[$id]['user']['galaxy'] . ":" . $fleets[$id]['user']['system'] . ":" . $fleets[$id]['user']['planet'] . "]</a>";
            foreach ($defender as $id => $count) {
                if (is_array($count)) {
                    $count = $count['count'];
                }
                $aparse['td_types'] .= "\t\t\t\t\t\t\t\t\t\t<th class=\"textGrow\">" . $lang['cr_names'][$id] . "</th>\n";
                $aparse['td_count'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($count) . "</td>\n";
                $aparse['td_weapons'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($CombatCaps[$id]['attack']) . "</td>\n";
                $aparse['td_shields'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($CombatCaps[$id]['shield']) . "</td>\n";
                $aparse['td_armour'] .= "\t\t\t\t\t\t\t\t\t\t<td>" . pretty_number($pricelist[$id]['metal'] + $pricelist[$id]['crystal']) . "</td>\n";
            }
            $rparse['defenders'] .= parsetemplate(gettemplate('fleet/combatattacker'), $aparse);
        }
        //We need to keep a note on who is in the battle, as well as showing any destroyed fleets.
        $peeps = array(array(), array());
        foreach ($fleets as $id => $array) {
            //We need a list of members for the title
            if ($roundno == 0) {
                if ($array['side'] == 'a') {
                    $peeps[0][] = $array['user']['username'];
                } else {
                    $peeps[1][] = $array['user']['username'];
                }
                $permafleets = $fleets;
            }
            //Look for fleets which are no more and list them as destroyed.
            if (!(in_array($id, array_keys($round['defend_fleets'])) || in_array($id, array_keys($round['attack_fleets'])))) {
                if ($array['side'] == 'a') {
                    $rparse['attackers'] .= '
		<td class="round_attacker textCenter"> 
			<table cellpadding="0" cellspacing="0"> 
				<tr>
					<td class="newBack"> 
						<center> 
							<span class="destroyed textBeefy">' . $lang['Attacker'] . ' ' . $array['user']['username'] . ' ' . $lang['destroyed'] . '.</span> 
						</center> 
					</td> 
				</tr> 
			</table> 
		</td>';
                } else {
                    $rparse['defenders'] .= '
		<td class="round_defender textCenter"> 
			<table cellpadding="0" cellspacing="0"> 
				<tr>
					<td class="newBack"> 
						<center> 
							<span class="destroyed textBeefy">' . $lang['Defender'] . ' ' . $array['user']['username'] . ' ' . $lang['destroyed'] . '.</span> 
						</center> 
					</td> 
				</tr> 
			</table> 
		</td>';
                }
                //If its been destroyed, we only want to show the destroyed message once, so remove the destroyed fleets.
                unset($fleets[$id]);
            }
        }
        //The round info, if its rounf one then we introduce the battle, otherwise its shots fired.
        if ($roundno == 0) {
            $rparse['roundinfo'] = "\t\t<p class=\"start\">" . sprintf($lang['report_start'], date("j.n.Y H:i:s")) . "</p>\n\t\t<p class=\"start opponents\">" . implode(', ', $peeps[0]) . ' ' . $lang['report_vs'] . ' ' . implode(', ', $peeps[1]) . "</p>\n";
        } else {
            $rparse['roundinfo'] = sprintf($lang['report_rinfo'], pretty_number($round['attfires']), pretty_number($round['attpower']), pretty_number($round['defblock']), pretty_number($round['deffires']), pretty_number($round['defpower']), pretty_number($round['attblock']));
        }
        $parse['rounds'] .= parsetemplate(gettemplate('fleet/combatround'), $rparse);
    }
    //Phew, lets deal with all the fleets:
    $end = $results['data'][sizeof($results['data']) - 1];
    $owners = array();
    foreach ($permafleets as $id => $array) {
        if ($id == 0) {
            //This is the planet...
            $set = array();
            foreach (array_merge($reslist['dbattle'], $reslist['fleet']) as $e) {
                $count = $end['defend_fleets'][0][$e];
                if (is_array($count)) {
                    $count = $count['count'];
                }
                if ($count > 0) {
                    $set[] = '`' . $resource[$e] . '` = \'' . idstring($count) . '\'';
                } else {
                    $set[] = '`' . $resource[$e] . '` = 0';
                }
            }
            doquery("UPDATE {{table}} SET " . implode(', ', $set) . " WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;", 'planets', true);
            //Note the user
            $owners[] = idstring($CurrentPlanet['id_owner']);
        } else {
            if ($array['side'] == 'a') {
                $mode = 'attack';
            } else {
                $mode = 'defend';
            }
            $fleetarray = array();
            $fleetcount = 0;
            foreach ($end[$mode . '_fleets'][$id] as $ship => $count) {
                if (is_array($count)) {
                    $count = $count['count'];
                }
                $fleetarray[] = idstring($ship) . ',' . idstring($count);
                $fleetcount += idstring($count);
            }
            $fleetarray = implode(';', $fleetarray);
            $fleetrow = doquery("SELECT * FROM {{table}} WHERE `fleet_id` = '" . idstring($id) . "' ;", 'fleets', true);
            $permafleets[$id]['row'] = $fleetrow;
            doquery("UPDATE {{table}} SET `array` = '" . $fleetarray . "', `shipcount` = '" . $fleetcount . "' WHERE `partner_fleet` = '" . idstring($id) . "' LIMIT 1 ;", 'fleets', false);
            DeleteFleet($id);
            $owners[] = idstring($fleetrow['owner_userid']);
        }
    }
    //Who won?
    if ($results['won'] == 'a') {
        //Need to deal with raiding.
        $stealmax = array($CurrentPlanet['metal'] * MAX_ATTACK_RAID, $CurrentPlanet['crystal'] * MAX_ATTACK_RAID, $CurrentPlanet['deuterium'] * MAX_ATTACK_RAID);
        //How much cargo space do we have?
        $cargo = array('total' => 0);
        foreach ($end['attack_fleets'] as $id => $attacker) {
            $cargo[$id] = 0;
            foreach ($attacker as $ship => $count) {
                if (is_array($count)) {
                    $count = $count['count'];
                }
                $space = $pricelist[$ship]['capacity'] * $count;
                $space -= $permafleets[$id]['row']['metal'];
                $space -= $permafleets[$id]['row']['crystal'];
                $space -= $permafleets[$id]['row']['deuterium'];
                if ($space > 0) {
                    $cargo[$id] += $space;
                    $cargo['total'] += $pricelist[$ship]['capacity'] * $count;
                }
            }
        }
        //So how much can we take?
        $totaltake = $stealmax[0] + $stealmax[1] + $stealmax[2];
        //Is there enough res to go around?
        if ($totaltake > $cargo['total']) {
            //We can fill all the cargo holds in the ratios:
            $ratio_m = $stealmax[0] / $totaltake;
            $ratio_c = $stealmax[1] / $totaltake;
            $ratio_d = $stealmax[2] / $totaltake;
        } else {
            //We can take the following ratios of resources: (nb its a bit late, so I haven't worked out why the below works but basically the $totaltake cancels so I just removed it)
            $ratio_m = $stealmax[0] / $cargo;
            $ratio_c = $stealmax[1] / $cargo;
            $ratio_d = $stealmax[2] / $cargo;
        }
        //Right lets start filling up the fleets:
        $stolen = array(0, 0, 0);
        foreach ($cargo as $id => $space) {
            if ($id != 'total') {
                $take_m = floor($ratio_m * $space);
                $take_c = floor($ratio_c * $space);
                $take_d = floor($ratio_d * $space);
                $stolen[0] += $take_m;
                $stolen[1] += $take_c;
                $stolen[2] += $take_d;
                doquery("UPDATE {{table}} SET `metal` = `metal` + '" . $take_m . "', `crystal` = `crystal` + '" . $take_c . "', `deuterium` = `deuterium` + '" . $take_d . "' WHERE `partner_fleet` = '" . idstring($id) . "' LIMIT 1 ;", 'fleets', false);
            }
        }
        $parse['result'] = sprintf($lang['A_won'], pretty_number($stolen[0]), $lang['Metal'], pretty_number($stolen[1]), $lang['Crystal'], pretty_number($stolen[2]), $lang['Deuterium']);
    } elseif ($results['won'] == 'v') {
        $parse['result'] = $lang['D_won'];
    } else {
        $results['won'] = 'd';
        $parse['result'] = $lang['Draw'];
    }
    //Results, attlost, defost debris ect.
    $parse['alost'] = sprintf($lang['AttLost'], pretty_number($results['attlost']));
    $parse['dlost'] = sprintf($lang['DefLost'], pretty_number($results['deflost']));
    $parse['debris'] = sprintf($lang['DebrisF'], pretty_number($results['debrmet']), $lang['Metal'], pretty_number($results['debrcry']), $lang['Crystal']);
    //Now the exiting bit!!! Moons stuff
    $debris_pc = floor(($results['debrmet'] + $results['debrcry']) / DEBRIS_PER_PERCENT);
    if ($debris_pc > MIN_MOON_PERCENT) {
        if ($debris_pc > MAX_MOON_PERCENT) {
            $debris_pc = MAX_MOON_PERCENT;
        }
        $parse['moon'] = sprintf($lang['MoonChance'], $debris_pc . '%');
        //So does he get a moon?
        $need = rand(0, 100);
        if ($debris_pc > $nees) {
            //Got a moon
            $pl_name = $CurrentPlanet['name'] . ' [' . $CurrentPlanet['galaxy'] . ':' . $CurrentPlanet['system'] . ':' . $CurrentPlanet['planet'] . ']';
            $parse['moon_got'] = sprintf($lang['GotMoon'], $pl_name);
            AddMoon($CurrentPlanet['galaxy'], $CurrentPlanet['system'], $CurrentPlanet['planet']);
        }
    }
    //Now we need to generate the report:
    $report = parsetemplate(gettemplate('fleet/combatreport'), $parse);
    //Add the report to the database
    doquery("INSERT INTO {{table}} (`report`, `owners`, `wonby`, `damage`, `time`) VALUES ('" . mysql_real_escape_string($report) . "', '" . implode(",", $owners) . "', '" . $results['won'] . "', '" . ($results['attlost'] + $results['deflost']) . "', '" . time() . "');", 'cr', false);
    //Now we need to message the user...
    $message = "<a href=\"./?page=report&raport=" . $rid . "\" target=\"_new\"><center>";
    $message2 = "<a href=\"./?page=report&raport=" . $rid . "\" target=\"_new\"><center>";
    if ($results['won'] == 'a') {
        $message .= "<font color=\"green\">";
        $message2 .= "<font color=\"red\">";
    } elseif ($results['won'] == 'v') {
        $message .= "<font color=\"red\">";
        $message2 .= "<font color=\"green\">";
    } else {
        $message .= "<font color=\"orange\">";
        $message2 .= "<font color=\"orange\">";
    }
    $message .= $lang['fleet_1_tit'] . " [" . $CurrentPlanet['galaxy'] . ":" . $CurrentPlanet['system'] . ":" . $CurrentPlanet['planet'] . "] </font></a>";
    $message2 .= $lang['fleet_1_tit'] . " [" . $CurrentPlanet['galaxy'] . ":" . $CurrentPlanet['system'] . ":" . $CurrentPlanet['planet'] . "] </font></a>";
    PM($FleetRow['owner_userid'], 0, $message, $lang['fleet_1_tit'], $lang['fleet_control'], 2);
    PM($FleetRow['target_userid'], 0, $message2, $lang['fleet_1_tit'], $lang['fleet_control'], 2);
}
Пример #13
0
/**
 * ShowGalaxySelector.php
 *
 * @version 1.0
 * @copyright 2008 By Chlorel for XNova
 */
function ShowGalaxySelector($Galaxy, $System)
{
    global $lang;
    $Galaxy = idstring($Galaxy);
    $System = idstring($System);
    if ($Galaxy > MAX_GALAXY_IN_WORLD) {
        $Galaxy = MAX_GALAXY_IN_WORLD;
    }
    if ($Galaxy < 1) {
        $Galaxy = 1;
    }
    if ($System > MAX_SYSTEM_IN_GALAXY) {
        $System = MAX_SYSTEM_IN_GALAXY;
    }
    if ($System < 1) {
        $System = 1;
    }
    $parse = $lang;
    $parse['cur_gal'] = $Galaxy;
    $parse['cur_sys'] = $System;
    //Galaxy
    if ($Galaxy != 1) {
        $parse['agb'] = '<a href="#"
				onmouseover="image1.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links-a.gif\';"
				onmouseout="image1.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links.gif\';"
                onclick="loadpage(\'./?page=galaxy&mode=1&galaxy=' . ($Galaxy - 1) . '&system=' . $System . '\',document.title,\'galaxy\');">';
    } else {
        $parse['agb'] = '<a href="#"
                onmouseover="image1.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links_inaktiv.gif\';"
                onmouseout="image1.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links_inaktiv.gif\';">';
    }
    if ($Galaxy != MAX_GALAXY_IN_WORLD) {
        $parse['agn'] = '<a href="#"
				onmouseover="image2.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts-a.gif\';"
				onmouseout="image2.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts.gif\';"
                onclick="loadpage(\'./?page=galaxy&mode=1&galaxy=' . ($Galaxy + 1) . '&system=' . $System . '\',document.title,\'galaxy\');">';
    } else {
        $parse['agn'] = '<a href="#"
                onmouseover="image2.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts_inaktiv.gif\';"
                onmouseout="image2.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts_inaktiv.gif\';">';
    }
    //Now for system
    if ($System != 1) {
        $parse['asb'] = '<a href="#"
				onmouseover="image3.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links-a.gif\';"
				onmouseout="image3.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links.gif\';"
                onclick="loadpage(\'./?page=galaxy&mode=1&galaxy=' . $Galaxy . '&system=' . ($System - 1) . '\',document.title,\'galaxy\');">';
    } else {
        $parse['asb'] = '<a href="#"
                onmouseover="image3.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links_inaktiv.gif\';"
                onmouseout="image3.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_links_inaktiv.gif\';">';
    }
    if ($System != MAX_SYSTEM_IN_WORLD) {
        $parse['asn'] = '<a href="#"
				onmouseover="image4.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts-a.gif\';"
				onmouseout="image4.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts.gif\';"
                onclick="loadpage(\'./?page=galaxy&mode=1&galaxy=' . $Galaxy . '&system=' . ($System + 1) . '\',document.title,\'galaxy\');">';
    } else {
        $parse['asn'] = '<a href="#"
                onmouseover="image4.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts_inaktiv.gif\';"
                onmouseout="image4.src=\'' . GAME_SKIN . '/img/galaxy/pfeil_rechts_inaktiv.gif\';">';
    }
    return parsetemplate(gettemplate('galaxy/galaxy_head'), $parse);
}
Пример #14
0
 }
 // Si l'on verifiait que l'adresse email n'existe pas encore ???
 $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . mysql_escape_string($_POST['email']) . "' LIMIT 1;", 'users', true);
 if ($ExistMail) {
     $errorlist .= $lang['error_emailexist'];
     $errors++;
 }
 if ($_POST['avatar'] == '') {
     $avatar = "[X]";
 } else {
     $avatar = $_POST['avatar'];
 }
 if (preg_match("/[^A-z0-9]/", $_POST['ref_name']) == 1) {
     $errorlist .= $lang['bad_referal'];
 }
 $refid = idstring($_GET['refid']);
 $sec_qu = $_POST['sec_qu'];
 $sec_ans = $_POST['sec_ans'];
 if ($_POST['side'] == 'light') {
     $ally_id = "1";
     $ally_name = "Light";
 } else {
     $ally_id = "2";
     $ally_name = "Dark";
 }
 $ally_register_time = time();
 $ally_rank_id = 1;
 if ($errors != 0) {
     message($errorlist, $lang['Register']);
 } else {
     $newpass = $_POST['passwrd'];
Пример #15
0
<?php

/**
 * fleetrecall.php
 *
 * @version 2.0
 * @copyright 2010 by MadnessRed for XNova Redesigned
 */
//Not really worth the file anymore, since its been moved to a function.
header('Content-Type: text/plain');
die(RecallFleet(idstring($_GET['fleet_id']), idstring($_GET['passkey']), $user['id']));
Пример #16
0
               			{if_wrong_email}<br />
               			{note_new}<br />';
        $lang['email'] = $user['email'];
        $lang['validate_content'] = parsetemplate($ContentTPL, $lang);
    } else {
        $lang['validate_content'] = $lang['already_validated'];
    }
    $page = parsetemplate(gettemplate('redesigned/validate'), $lang);
    makeAXAH($page);
} elseif ($user['validate'] > 0) {
    //Is user already validated?
    //Need to validate ths account
    //Do we have a code?
    if ($_GET['code']) {
        if ($_GET['code'] == $user['validate']) {
            doquery("UPDATE {{table}} SET `validate` = '0' WHERE `id` = '" . idstring($_GET['user']) . "' LIMIT 1 ;", 'users');
            intercom_add($lang['acc_validated'], $user['id'], 0, 20);
            header("Location: " . AddUniToString("./"));
        } else {
            intercom_add($lang['bad_code'], $user['id'], 0, 20);
            header("Location: " . AddUniToString("./"));
        }
    } else {
        die("No code");
        header("Location: " . AddUniToString("./"));
    }
} else {
    //He is already validated
    intercom_add($lang['already_validated'], $user['id'], 0, 20);
    header("Location: " . AddUniToString("./"));
}
Пример #17
0
/**
 * showmessage.php
 *
 * @version 1
 * @copyright 2009 by Anthony for XNova Redesigned
 */
$message = doquery("SELECT * FROM {{table}} WHERE `message_id` = '" . idstring($_GET['id']) . "' AND (`message_owner` = '" . $user['id'] . "' OR `message_sender` = '" . $user['id'] . "') LIMIT 1 ;", 'messages', true);
$parse = $lang;
$bb = new Simple_BB_Code();
if ($message['message_sender'] > 0) {
    $messagetext = $bb->parse(htmlentities(stripslashes($message['message_text']), ENT_QUOTES));
} else {
    $messagetext = stripslashes($message['message_text']);
}
$parse['message'] = $messagetext;
$parse['subject'] = htmlentities(stripslashes($message['message_subject']), ENT_QUOTES);
$parse['from'] = htmlentities($message['message_from'], ENT_QUOTES);
$parse['username'] = htmlentities($user['username'], ENT_QUOTES);
$parse['date'] = date("jS F H:i:s", $message['message_time']);
//Thats the basic parts, now lets get previous/next message.
$parse['num'] = $_GET['n'];
$parse['count'] = $_GET['count'];
$parse['next'] = $_GET['next'];
$parse['prev'] = $_GET['prev'];
//now the mesage id
$parse['id'] = idstring($_GET['id']);
//Now links
$parse['l_reply'] = "href=\"./?page=write&to=" . $message['message_sender'] . "&subject=RE:" . $parse['subject'] . "\" rel=\"ibox&width=785&height=490\"";
$parse['l_reply'] = "href=\"./?page=write&to=" . $message['message_sender'] . "&subject=RE:" . $parse['subject'] . "\" target=\"_self\"";
echo AddUniToLinks(parsetemplate(gettemplate('network/show'), $parse));
Пример #18
0
} elseif ($_GET['check'] == 'planet') {
    $g = idstring($_GET['g']);
    $s = idstring($_GET['s']);
    $p = idstring($_GET['p']);
    $t = idstring($_GET['t']);
    $ExistPl = doquery("SELECT `id` FROM {{table}} WHERE `galaxy` = '" . $g . "' AND `system` = '" . $s . "' AND `planet` = '" . $p . "' AND `planet_type` = '" . $t . "' LIMIT 1;", 'planets', true);
    if ($ExistPl['id'] > 0) {
        $good = false;
    } else {
        $good = true;
    }
} elseif ($_GET['check'] == 'planetopp') {
    $g = idstring($_GET['g']);
    $s = idstring($_GET['s']);
    $p = idstring($_GET['p']);
    $t = idstring($_GET['t']);
    $ExistPl = doquery("SELECT `id` FROM {{table}} WHERE `galaxy` = '" . $g . "' AND `system` = '" . $s . "' AND `planet` = '" . $p . "' AND `planet_type` = '" . $t . "' LIMIT 1;", 'planets', true);
    if ($ExistPl['id'] > 0) {
        $good = true;
    } else {
        $good = false;
    }
}
if ($unused) {
    $image = "./check/no.gif";
} elseif ($good) {
    $image = "./check/ok.gif";
} else {
    $image = "./check/err.gif";
}
//New part, echo te image
Пример #19
0
</select>
<span id="usercheck"><image src="./check/ok.gif" width="16" height="14" /></span><br />

<input type="button" class="button188" value="Go" onclick="getAXAH(\'./?page=admin&link=edit&section={section}&g=\'+document.getElementById(\'g\').value+\'&s=\'+document.getElementById(\'s\').value+\'&p=\'+document.getElementById(\'p\').value+\'&t=\'+document.getElementById(\'t\').options[document.getElementById(\'t\').options.selectedIndex].value,\'section\');" />';
            makeAXAH(parsetemplate($template, $parse));
        }
        break;
    case "submit":
        $count = 0;
        $query = "UPDATE {{table}} SET ";
        foreach ($_POST as $key => $val) {
            if (is_numeric($key)) {
                if (is_numeric($val)) {
                    if (strlen($resource[$key]) > 0) {
                        $count++;
                        $query .= "`" . $resource[$key] . "` = '" . idstring($val) . "' , ";
                    }
                }
            }
        }
        if ($count > 0) {
            $query = substr_replace($query, '', -2) . " WHERE `id` = '" . idstring($_GET['id']) . "' LIMIT 1 ;";
            doquery($query, mysql_real_escape_string($_POST['table']));
        }
        info("User Edited", "Success", './?page=admin&link=edit', '<<');
        break;
    default:
        $bloc['content'] = parsetemplate(gettemplate('admin/edit_ovr'), $parse);
        $bloc['title'] = $lang['sys_overview'];
        break;
}
Пример #20
0
<?php

/**
 * techdata.php
 *
 * @version 1.1
 * @copyright 2008 by MadnessRed for XNova Redesigned
 */
includeLang('techdata');
$parse = $lang;
$Element = idstring($_GET['id']);
$ElementName = $lang['tech'][$Element];
switch ($_GET['opt']) {
    case 'detail':
        $Template = gettemplate('buildings/techinfo');
        break;
    case 'tree':
        $heightajusts = array(43 => 60, 214 => 100);
        $divheightajusts = array(1 => 100, 2 => 100, 3 => 100, 4 => 100, 5 => 160, 12 => 160, 14 => 100, 15 => 160, 21 => 100, 22 => 100, 23 => 100, 24 => 100, 31 => 100, 33 => 310, 34 => 100, 41 => 100, 42 => 100, 43 => 360, 44 => 100, 106 => 100, 108 => 100, 109 => 100, 110 => 160, 111 => 100, 113 => 100, 114 => 370, 115 => 160, 117 => 160, 118 => 360, 120 => 160, 121 => 370, 122 => 810, 123 => 560, 124 => 410, 199 => 100, 214 => 1000);
        if (!in_array($Element, array_keys($heightajusts))) {
            $heightajusts[$Element] = 10;
        }
        if (!in_array($Element, array_keys($divheightajusts))) {
            $divheightajusts[$Element] = 800;
        }
        $n = 0;
        function get_req($id, $from = '-1', $req = 1)
        {
            global $requeriments, $lang, $user, $planetrow, $resource, $n;
            //See if this item has requirements, if so give it space for the +/-
            if (is_array($requeriments[$id])) {
Пример #21
0
 //Skin
 if (strlen($_GET["dpath"]) > 0) {
     $dpath = $_GET["dpath"];
 } else {
     $dpath = GAME_SKIN;
 }
 // Gestion des options speciales pour les admins
 if ($user['authlevel'] > 0) {
     if ($_GET['adm_pl_prot'] == 'on') {
         doquery("UPDATE {{table}} SET `id_level` = '" . $user['authlevel'] . "' WHERE `id_owner` = '" . $user['id'] . "';", 'planets');
     } else {
         doquery("UPDATE {{table}} SET `id_level` = '0' WHERE `id_owner` = '" . $user['id'] . "';", 'planets');
     }
 }
 // Forum ID
 $forum_id = idstring($_GET['forum_id']);
 // Mostrar skin
 if (isset($_GET["design"]) && $_GET["design"] == 'on') {
     $design = "1";
 } else {
     $design = "0";
 }
 // Desactivar comprobaci? de IP
 if (isset($_GET["noipcheck"]) && $_GET["noipcheck"] == 'on') {
     $noipcheck = "1";
 } else {
     $noipcheck = "0";
 }
 // Nombre de usuario
 if (isset($_GET["db_character"]) && $_GET["db_character"] != '') {
     $username = CheckInputStrings($_GET['db_character']);
Пример #22
0
<?php

/**
 * write.php
 *
 * @version 1
 * @copyright 2009 by Anthony for XNova Redesigned
 */
//Get the target user
$lang = doquery("SELECT `id`,`username`,`galaxy`,`system`,`planet` FROM {{table}} WHERE `id` = '" . idstring($_GET['to']) . "' LIMIT 1;", 'users', true);
//Start the parse array
$parse = $lang;
$parse['subject'] = htmlentities($_GET['subject']);
$parse['date'] = date("j<\\s\\up>S</\\s\\up> F Y");
echo AddUniToLinks(parsetemplate(gettemplate('network/write'), $parse));
Пример #23
0
 case "kick":
     //So they want to remove this guy?
     if (idstring($_GET['id']) != $allyrow['ally_owner']) {
         //Admin can't leave
         doquery("UPDATE {{table}} SET `ally_id` = '0' , `ally_name` = '' , `ally_register_time` = '0' , `ally_rank` = '0' , `ally_rank_name` = 'Newbie' WHERE `id` = '" . idstring($_GET['id']) . "' AND `ally_id` = '" . $user['ally_id'] . "' LIMIT 1 ;", 'users');
         doquery("UPDATE {{table}} SET `ally_members` = `ally_members` - " . mysql_affected_rows() . " WHERE `id` = '" . $user['ally_id'] . "' LIMIT 1 ;", 'alliance');
     }
     //Back to alliance page
     header("Location: " . AddUniToString('./?page=network&axah=' . $_GET['axah']));
     die;
     break;
 default:
     $parse['name'] = $allyrow['ally_name'];
     $parse['tag'] = $allyrow['ally_tag'];
     $parse['www'] = addslashes($allyrow['ally_web']);
     $parse['members'] = idstring($allyrow['ally_members']);
     $parse['yourrank'] = addslashes($user['ally_rank_name']);
     $parse['internal'] = $bb->parse(addslashes($allyrow['ally_text']));
     $parse['external'] = $bb->parse(addslashes($allyrow['ally_description']));
     $parse['image'] = addslashes($allyrow['ally_image']);
     $members = $lang;
     $membersort = 'ally_register_time';
     $memberquery = doquery("SELECT \r\n\t\t\t`id`,`username`,`galaxy`,`system`,`planet`,\r\n\t\t\t`ally_register_time`,`ally_rank_name`,`total_points`,`onlinetime` \r\n\t\t\tFROM {{table}} WHERE `ally_id` = '" . $allyrow['id'] . "' ORDER BY `" . $membersort . "` ASC ;", 'users');
     $n = 0;
     while ($row = FetchArray($memberquery)) {
         $n++;
         $lastclick = time() - $row['onlinetime'];
         if (!$user['permisions'][2]) {
             $activeon = ' - ';
             $activeover = '';
         } elseif ($lastclick > 20) {
Пример #24
0
            //echo "SELECT * FROM {{table}} WHERE `message_owner` = '".$user['id']."' AND `message_type` = '".idstring($messcat)."' ORDER BY `message_time` DESC;";
            //Set messages of this type to 0
            $usermessages[$messcat] = 0;
            foreach ($usermessages as $type => $count) {
                if ($type < 0 || $type > 5 || intval($type) != $type || idstring($type) != $type) {
                    unset($usermessages[$type]);
                }
            }
            doquery("UPDATE {{table}} SET `messages` = '" . implode(",", $usermessages) . "', `menus_update` = '" . time() . "' WHERE `id` = '" . $user['id'] . "' LIMIT 1 ;", 'users');
        }
        if (mysql_num_rows($messages) > 0) {
            $parse['content'] = "\r\n\t\t\t\t\t<form action=\"./?page=messages&mode=delete&messcat=" . $_GET['messcat'] . "\" method=\"GET\" id=\"messagesform\" name=\"messagesform\">\n\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"messages\" />\n\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"mode\" value=\"delete\" />\n\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"messcat\" value=\"" . $_GET['messcat'] . "\" />\n\r\n\t\t\t\t\t\t<table class=\"list\" id=\"mailz\" cellpadding=\"0\" cellspacing=\"0\">\n\r\n\t\t\t\t\t\t<tbody>\n\r\n\t\t\t\t\t\t<tr class=\"first alt\">\n\r\n\t\t\t\t\t\t\t<th class=\"check\">\n\r\n\t\t\t\t\t\t\t\t<input class=\"checker\" id=\"checkAll\"onclick=\"likenAll(document.messagesform,'checkAll');\" type=\"checkbox\">\n\r\n\t\t\t\t\t\t\t</th>\n\r\n\t\t\t\t\t\t\t\t<th class=\"from\">Sender</th>\n\r\n\t\t\t\t\t\t\t\t<th class=\"subject\">Subject</th>\n\r\n\t\t\t\t\t\t\t<th class=\"date\">Date</th>\n\r\n\t\t\t\t\t\t\t<th class=\"action\"></th>\n\r\n\t\t\t\t\t\t</tr>\n";
            $n = 0;
            while ($row = mysql_fetch_array($messages)) {
                $n++;
                $parse['content'] .= "\r\n\t\t\t\t\t\t\t<input name=\"showmes" . $row['message_id'] . "\" type=\"hidden\" value=\"1\" />\r\n\t\t\t\t\t\t\t<tr class=\"trigger alt new\" id=\"" . $row['message_id'] . "TR\">\n\r\n\t\t\t\t\t\t\t\t<td class=\"check\">\n\r\n\t\t\t\t\t\t\t\t\t<input class=\"checker\" name=\"delmes" . $row['message_id'] . "\" id=\"delmes" . $row['message_id'] . "\" type=\"checkbox\">\n\r\n\t\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t\t<td class=\"from\">" . $row['message_from'] . "</td>\n\r\n\t\t\t\t\t\t\t\t<td class=\"subject\">\n\r\n\t\t\t\t\t\t\t\t\t<a class=\"ajax_thickbox\" id=\"" . $row['message_id'] . "\" href=\"#\" onclick=\"mrbox('./?page=showmessage&id=" . $row['message_id'] . "&cat=" . idstring($messcat) . "&n=" . $n . "&count=" . mysql_num_rows($messages) . "&iframe=1&iheight=800',800)\">\n\r\n\t\t\t\t\t\t\t\t\t\t" . $row['message_subject'] . "\n\r\n\t\t\t\t\t\t\t\t\t</a>\n\r\n\t\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t\t<td class=\"date\">" . date("jS F H:i", $row['message_time']) . "</td>\n\r\n\t\t\t\t\t\t\t\t<td class=\"actions\" id=\"test\">\n\r\n\t\t\t\t\t\t\t\t\t<a href=\"#\" rel=\"" . $row['message_id'] . "\" class=\"del tips deleteIt\" onmouseover=\"mr_tooltip('Delete this message');\" onclick=\"document.getElementById('delmes" . $row['message_id'] . "').checked=true;document.getElementById('delmethod').value='marked';document.getElementById('okbutton').style.display='inline';\" id=\"2\">\n\r\n\t\t\t\t\t\t\t\t\t\t<img src=\"" . GAME_SKIN . "/img/icons/" . $trash . ".gif\">\n\r\n\t\t\t\t\t\t\t\t\t</a>\n\r\n\t\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t</tr>\n";
            }
            $parse['content'] .= "\r\n\t\t\t\t\t\t</tr>\n\r\n\t\t\t\t\t\t<tr class=\"last alt\">\n\r\n\t\t\t\t\t\t\t<td colspan=\"3\" align=\"left\">\n\r\n\t\t\t\t\t\t\t\t<select class=\"choose\" id=\"delmethod\" name=\"delete\" onchange=\"document.getElementById('okbutton').style.display='inline';\">\n\r\n\t\t\t\t\t\t\t\t\t<option class=\"underlined\">" . $lang['DelAktion'] . "</option>\n\r\n\t\t\t\t\t\t\t\t\t<option class=\"method\" value=\"marked\">" . $lang[$Del . 'Mark'] . "</option>\n\r\n\t\t\t\t\t\t\t\t\t<option class=\"method\" value=\"unmarked\">" . $lang[$Del . 'Unmark'] . "</option>\n\r\n\t\t\t\t\t\t\t\t\t<option class=\"method\" value=\"shown\">" . $lang[$Del . 'Shown'] . "</option>\n\r\n\t\t\t\t\t\t\t\t\t<option class=\"method\" value=\"all\">" . $lang[$Del . 'All'] . "</option>\n\r\n\t\t\t\t\t\t\t\t\t</select>\n\r\n\t\t\t\t\t\t\t\t\t<!--<input name=\"submit\" value=\"OK2\" class=\"buttonOK deleteIt\" id=\"okbutton\" style=\"display: none;\" type=\"submit\">-->\n\n\t\t\t\t\t\t\t\t\t<input type=\"button\" class=\"buttonOK deleteIt\" id=\"okbutton\" value=\"OK\" onclick=\"mr_alert('<img height=16 width=16 src=\\'{{skin}}/img/ajax-loader.gif\\' /> {Loading}...'); getAXAH(form2get('messagesform'),'errorBoxNotifyContent');\" style=\"display: none;\" />\n\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td colspan=\"2\">\n\r\n\t\t\t\t\t\t\t\t<div class=\"selectContainer\">\n\r\n\t\t\t\t\t\t\t\t</div>\n\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\n\r\n\t\t\t\t\t\t</tbody>\n\r\n\t\t\t\t\t\t</table>\n\r\n\t\t\t\t\t</form>\n";
        } else {
            $parse['content'] .= "No messages found";
        }
}
if ($_GET['axah_section']) {
    echo $parse['catag'];
    echo '<div id="messageContent" class="msg_content textBeefy textCenter">';
    echo $parse['content'];
    echo '</div>';
    die;
} elseif ($_GET['axah']) {
    makeAXAH(parsetemplate(gettemplate('network/messages'), $parse));
} else {
Пример #25
0
function intercom_add($message, $to, $from = 0, $duration = 120)
{
    $to = idstring($to);
    $from = idstring($from);
    $duration = idstring($duration);
    $message = EscapeString($message);
    doquery("INSERT INTO {{table}} (`to`,`from`,`time`,`expires`,`message`) VALUES ('" . $to . "', '" . $from . "', '" . time() . "', '" . (time() + $duration) . "', '" . $message . "');", 'im');
}
Пример #26
0
function MissionCaseColonisation($FleetRow)
{
    global $lang, $resource, $formulas;
    //Get the current user (note it must be $currentUser for the $formulas eval'd code to work, see includes/formulas.php
    $CurrentUser = doquery("SELECT * FROM {{table}} WHERE `id` = '" . idstring($FleetRow['owner_userid']) . "' LIMIT 1 ;", 'users', true);
    //How many planets do we have?
    $userplanets = mysql_num_rows(doquery("SELECT `id` FROM {{table}} WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `planet_type` = '1'", 'planets'));
    //How many planets are allowed?
    $maxplanets = eval($formulas['max_planets_c']);
    //If we have less than (but not equal to) the max planets count.
    if ($userplanets < $maxplanets) {
        //Now the slightly trickbit, as we were not messing around with gal sys and planet in the database we now had to have a numeric id for the gsp.
        $g = strlen(MAX_GALAXY_IN_WORLD);
        $s = strlen(MAX_SYSTEM_IN_GALAXY);
        $p = strlen(MAX_PLANET_IN_SYSTEM);
        $galaxy = substr($FleetRow['target_id'], 0, $g) * 1;
        $system = substr($FleetRow['target_id'], $g, $s) * 1;
        $planet = substr($FleetRow['target_id'], $g + $s, $p) * 1;
        unset($g, $s, $p);
        //Check that these planets are within the allowed range
        if ($CurrentUser[$resource[124]] < 4) {
            $minpos = 4;
        } elseif ($CurrentUser[$resource[124]] < 6) {
            $minpos = 3;
        } elseif ($CurrentUser[$resource[124]] < 8) {
            $minpos = 2;
        } else {
            $minpos = 1;
        }
        $maxpos = MAX_PLANET_IN_SYSTEM + 1 - $minpos;
        if ($planet >= $minpos && $planet <= $maxpos) {
            //Now get the target position
            $TargetAdress = sprintf($lang['sys_adress_planet'], $galaxy, $system, $planet);
            //See if we have a planet here already?
            $cur = doquery("SELECT `id` FROM {{table}} WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "';", 'planets', true);
            if ($cur['id'] > 0) {
                $message = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_notfree'];
                PM($CurrentUser['id'], 0, $message, $lang['sys_colo_mess_report'], $lang['sys_colo_mess_from'], 2);
            } else {
                //No planet lets carry on.
                if (CreateOnePlanetRecord($galaxy, $system, $planet, $CurrentUser['id'], $lang['sys_colo_defaultname'], false)) {
                    //Message them that the planet has been made.
                    $message = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_allisok'];
                    PM($CurrentUser['id'], 0, $message, $lang['sys_colo_mess_report'], $lang['sys_colo_mess_from'], 2);
                    //If there is more than just a colony ship then we should put that fleet on the planet.
                    if ($FleetRow['shipcount'] > 0) {
                        $fleet = explode(";", $FleetRow['array']);
                        $sql = "";
                        $upd = 0;
                        foreach ($fleet as $info) {
                            if (strlen($info) > 0) {
                                $ship = explode(",", $info);
                                if ($ship[0] == 208) {
                                    $ship[1]--;
                                }
                                if ($ship[1] > 0) {
                                    $sql .= "`" . $resource[$ship[0]] . "` = '" . idstring($ship[1]) . "' , ";
                                    $upd += $ship[1];
                                }
                            }
                        }
                        if ($upd > 0 && strlen(substr_replace($sql, '', -2)) > 3) {
                            doquery("UPDATE {{table}} SET " . substr_replace($sql, '', -2) . " WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' ;", 'planets');
                        }
                    }
                    //And put resources on the planet.
                    doquery("UPDATE {{table}} SET `metal` = '" . $FleetRow['metal'] . "' , `crystal` = '" . $FleetRow['crystal'] . "' , `deuterium` = '" . $FleetRow['deuterium'] . "'  WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' LIMIT 1 ;", 'planets');
                } else {
                    //We could not make the colony
                    $message = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_badpos'];
                    PM($CurrentUser['id'], 0, $message, $lang['sys_colo_mess_report'], $lang['sys_colo_mess_from'], 2);
                }
            }
        } else {
            //We don't have astro-physics high enough
            $message = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_outside_range'] . $lang['sys_colo_slots'] . "[" . $minpos . "-" . $maxpos . "]!";
            PM($CurrentUser['id'], 0, $message, $lang['sys_colo_mess_report'], $lang['sys_colo_mess_from'], 2);
        }
    } else {
        //We don't have astro-physics high enough
        $message = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_maxcolo'] . $maxplanets . $lang['sys_colo_planet'];
        PM($CurrentUser['id'], 0, $message, $lang['sys_colo_mess_report'], $lang['sys_colo_mess_from'], 2);
    }
}
Пример #27
0
//Language
getLang('notes');
switch ($_GET['mode']) {
    case 'read':
    case 'write':
        //Do we have a note?
        if (idstring($_GET['note']) > 0) {
            //Get the note
            $note = doquery("SELECT * FROM {{table}} WHERE `owner` = '" . $user['id'] . "' AND `id` = '" . idstring($_GET['note']) . "' LIMIT 1 ;", 'notes', true);
        } else {
            //No note
        }
        break;
    case 'add':
        //Add note to the database
        doquery("INSERT INTO {{table}} SET `owner` = '" . $user['id'] . "', `time` = '" . time() . "', `priority` = '" . idstring($_GET['pri']) . "', `title` = '" . mysql_real_escape_string($_GET['subject']) . "', `text` = '" . mysql_real_escape_string($_GET['note']) . "' ;", "notes");
        break;
    default:
        //Get the notes first.
        //`id`, `owner`, `time`, `priority`, `title`, `text`
        $query = doquery("SELECT * FROM {{table}} WHERE `owner` = '" . $user['id'] . "' LIMIT 1 ;", 'notes');
        //New note button
        $parse['page'] .= '
		<table cellspacing="0" cellpadding="0" id="notizen">
			<tr>
				<th colspan=4>
					<div style="margin-left:32px;">
						<a id="newNote" class="button188" href="#" onclick="getAXAH(\'./?page=notes&mode=write\',\'notesbody\');"><span>' . $lang['newnote'] . '</span></a>
					</div>
				</th>
			</tr>';
Пример #28
0
function DeletePartnerFleet($id)
{
    if ($id > 0) {
        doquery("DELETE FROM {{table}} WHERE `partner_fleet` = '" . idstring($id) . "' LIMIT 1 ;", 'fleets', false, true);
    }
}
Пример #29
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);
    }
}
Пример #30
0
function ModuleMarchand($CurrentUser, &$CurrentPlanet)
{
    global $lang, $_GET;
    $trade = array('m' => 4, 'c' => 2, 'd' => 1);
    $parse = $lang;
    if ($_GET['ress']) {
        $PageTPL = gettemplate('trader/main');
        $Error = false;
        $Metal = idstring($_GET['metal']);
        $Crystal = idstring($_GET['crystal']);
        $Deuterium = idstring($_GET['deuterium']);
        if ($Metal < 0) {
            $Metal = 0;
        }
        if ($Crystal < 0) {
            $Crystal = 0;
        }
        if ($Deuterium < 0) {
            $Deuterium = 0;
        }
        $maxm = floor($CurrentPlanet['crystal_max'] - $CurrentPlanet['crystal']);
        $maxc = floor($CurrentPlanet['metal_max'] - $CurrentPlanet['metal']);
        $maxd = floor($CurrentPlanet['deuterium_max'] - $CurrentPlanet['deuterium']);
        if ($Metal > $maxm) {
            $Metal = $maxm;
        }
        if ($Crystal > $maxc) {
            $Crystal = $maxc;
        }
        if ($Deuterium > $maxd) {
            $Deuterium = $maxd;
        }
        switch ($_GET['ress']) {
            case 'metal':
                $need = $Crystal / $trade['c'] * $trade['m'] + $Deuterium / $trade['d'] * $trade['m'];
                if ($CurrentPlanet['metal'] > $need) {
                    $CurrentPlanet['metal'] -= $need;
                } else {
                    $Message = $lang['mod_ma_noten'] . " " . $lang['Metal'] . "! ";
                    $Error = true;
                }
                break;
            case 'crystal':
                $need = $Metal / $trade['m'] * $trade['c'] + $Deuterium / $trade['d'] * $trade['c'];
                if ($CurrentPlanet['crystal'] > $need) {
                    $CurrentPlanet['crystal'] -= $need;
                } else {
                    $Message = $lang['mod_ma_noten'] . " " . $lang['Crystal'] . "! ";
                    $Error = true;
                }
                break;
            case 'deuterium':
                $need = $Metal / $trade['m'] * $trade['d'] + $Crystal / $trade['c'] * $trade['d'];
                if ($CurrentPlanet['deuterium'] > $need) {
                    $CurrentPlanet['deuterium'] -= $need;
                } else {
                    $Message = $lang['mod_ma_noten'] . " " . $lang['Deuterium'] . "! ";
                    $Error = true;
                }
                break;
        }
        if ($Error == false) {
            $CurrentPlanet['metal'] += $Metal;
            $CurrentPlanet['crystal'] += $Crystal;
            $CurrentPlanet['deuterium'] += $Deuterium;
            $QryUpdatePlanet = "UPDATE {{table}} SET ";
            $QryUpdatePlanet .= "`metal` = '" . $CurrentPlanet['metal'] . "', ";
            $QryUpdatePlanet .= "`crystal` = '" . $CurrentPlanet['crystal'] . "', ";
            $QryUpdatePlanet .= "`deuterium` = '" . $CurrentPlanet['deuterium'] . "' ";
            $QryUpdatePlanet .= "WHERE ";
            $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';";
            doquery($QryUpdatePlanet, 'planets');
            $Message = $lang['mod_ma_done'];
            $parse['title'] = $lang['mod_ma_donet'];
        } else {
            $parse['title'] = $lang['mod_ma_error'];
        }
        $parse['mod_ma_rates'] = $Message;
    } else {
        if ($_GET['action'] != 2) {
            $PageTPL = gettemplate('trader/main');
        } else {
            $PageTPL = gettemplate('trader/trade');
            switch ($_GET['resource']) {
                case 'metal':
                    $parse['storage_a'] = floor($CurrentPlanet['metal_max'] - $CurrentPlanet['metal']);
                    $parse['storage_b'] = floor($CurrentPlanet['crystal_max'] - $CurrentPlanet['crystal']);
                    $parse['storage_c'] = floor($CurrentPlanet['deuterium_max'] - $CurrentPlanet['deuterium']);
                    if ($parse['storage_a'] < 0) {
                        $parse['storage_a'] = 0;
                    }
                    if ($parse['storage_b'] < 0) {
                        $parse['storage_b'] = 0;
                    }
                    if ($parse['storage_c'] < 0) {
                        $parse['storage_c'] = 0;
                    }
                    $parse['storage_ap'] = pretty_number($parse['storage_a']);
                    $parse['storage_bp'] = pretty_number($parse['storage_b']);
                    $parse['storage_cp'] = pretty_number($parse['storage_c']);
                    $parse['ResourceA'] = $lang['Metal'];
                    $parse['ResourceB'] = $lang['Crystal'];
                    $parse['ResourceC'] = $lang['Deuterium'];
                    $parse['resa'] = 'metal';
                    $parse['resb'] = 'crystal';
                    $parse['resc'] = 'deuterium';
                    $parse['tradea'] = $trade['m'];
                    $parse['tradeb'] = $trade['c'];
                    $parse['tradec'] = $trade['d'];
                    break;
                case 'crystal':
                    $parse['storage_a'] = floor($CurrentPlanet['crystal_max'] - $CurrentPlanet['crystal']);
                    $parse['storage_b'] = floor($CurrentPlanet['metal_max'] - $CurrentPlanet['metal']);
                    $parse['storage_c'] = floor($CurrentPlanet['deuterium_max'] - $CurrentPlanet['deuterium']);
                    if ($parse['storage_a'] < 0) {
                        $parse['storage_a'] = 0;
                    }
                    if ($parse['storage_b'] < 0) {
                        $parse['storage_b'] = 0;
                    }
                    if ($parse['storage_c'] < 0) {
                        $parse['storage_c'] = 0;
                    }
                    $parse['storage_ap'] = pretty_number($parse['storage_a']);
                    $parse['storage_bp'] = pretty_number($parse['storage_b']);
                    $parse['storage_cp'] = pretty_number($parse['storage_c']);
                    $parse['ResourceA'] = $lang['Crystal'];
                    $parse['ResourceB'] = $lang['Metal'];
                    $parse['ResourceC'] = $lang['Deuterium'];
                    $parse['resa'] = 'crystal';
                    $parse['resb'] = 'metal';
                    $parse['resc'] = 'deuterium';
                    $parse['tradea'] = $trade['c'];
                    $parse['tradeb'] = $trade['m'];
                    $parse['tradec'] = $trade['d'];
                    break;
                case 'deuterium':
                    $parse['storage_a'] = floor($CurrentPlanet['deuterium_max'] - $CurrentPlanet['deuterium']);
                    $parse['storage_b'] = floor($CurrentPlanet['metal_max'] - $CurrentPlanet['metal']);
                    $parse['storage_c'] = floor($CurrentPlanet['crystal_max'] - $CurrentPlanet['crystal']);
                    if ($parse['storage_a'] < 0) {
                        $parse['storage_a'] = 0;
                    }
                    if ($parse['storage_b'] < 0) {
                        $parse['storage_b'] = 0;
                    }
                    if ($parse['storage_c'] < 0) {
                        $parse['storage_c'] = 0;
                    }
                    $parse['storage_ap'] = pretty_number($parse['storage_a']);
                    $parse['storage_bp'] = pretty_number($parse['storage_b']);
                    $parse['storage_cp'] = pretty_number($parse['storage_c']);
                    $parse['ResourceA'] = $lang['Deuterium'];
                    $parse['ResourceB'] = $lang['Metal'];
                    $parse['ResourceC'] = $lang['Crystal'];
                    $parse['resa'] = 'deuterium';
                    $parse['resb'] = 'metal';
                    $parse['resc'] = 'crystal';
                    $parse['tradec'] = $trade['d'];
                    $parse['tradeb'] = $trade['m'];
                    $parse['tradea'] = $trade['c'];
                    break;
            }
        }
    }
    $parse['planet'] = $CurrentPlanet['name'];
    $Page = parsetemplate($PageTPL, $parse);
    return $Page;
}