예제 #1
0
function DestroyMoon($moon_id, $when, $fleet_id)
{
    global $db_prefix;
    $moon = GetPlanet($moon_id);
    $planet = LoadPlanet($moon['g'], $moon['s'], $moon['p'], 1);
    if ($moon == NULL || $planet == NULL) {
        return;
    }
    // Развернуть флоты летящие на луну
    $query = "SELECT * FROM " . $db_prefix . "fleet WHERE target_planet = {$moon_id} AND mission < 100 AND fleet_id <> {$fleet_id};";
    $result = dbquery($query);
    $rows = dbrows($result);
    while ($rows--) {
        $fleet_obj = dbarray($result);
        RecallFleet($fleet_obj['fleet_id'], $when);
    }
    // Перенаправить возвращающиеся и улетающие флоты на планету.
    $query = "UPDATE " . $db_prefix . "fleet SET start_planet = " . $planet['planet_id'] . " WHERE start_planet = {$moon_id};";
    dbquery($query);
    // Всё остальное уничтожается безвозвратно
    DestroyPlanet($moon_id);
    // Сделать текущей планетой - планету под уничтоженной луной
    SelectPlanet($planet['owner_id'], $planet['planet_id']);
}
예제 #2
0
function RemoveUser($player_id, $when)
{
    global $db_prefix;
    // Аккаунты администратора и space нельзя удалить.
    if ($player_id == 1 || $player_id == 99999) {
        return;
    }
    // Развернуть все флоты, летящие на игрока.
    $result = EnumFleetQueue($player_id);
    $rows = dbrows($result);
    while ($rows--) {
        $queue = dbarray($result);
        $fleet_obj = LoadFleet($queue['sub_id']);
        if ($fleet_obj['owner_id'] != $player_id && $fleet_obj['mission'] < 100) {
            RecallFleet($fleet_obj['fleet_id'], $when);
        }
    }
    // Удалить все флоты игрока
    $query = "DELETE FROM " . $db_prefix . "fleet WHERE owner_id = {$player_id}";
    dbquery($query);
    // Удалить все задания из очереди
    $query = "DELETE FROM " . $db_prefix . "queue WHERE owner_id = {$player_id}";
    dbquery($query);
    // Удалить все планеты, кроме ПО, которые переходят во владения space.
    $query = "DELETE FROM " . $db_prefix . "planets WHERE owner_id = {$player_id} AND type <> 10000";
    dbquery($query);
    $query = "UPDATE " . $db_prefix . "planets SET owner_id = 99999 WHERE owner_id = {$player_id} AND type = 10000";
    dbquery($query);
    // Удалить игрока.
    $query = "DELETE FROM " . $db_prefix . "users WHERE player_id = {$player_id}";
    dbquery($query);
    // Уменьшить количество пользователей.
    $query = "UPDATE " . $db_prefix . "uni SET usercount = usercount - 1;";
    dbquery($query);
    // Удалить заявки в альянс
    $apply_id = GetUserApplication($player_id);
    if ($apply_id) {
        RemoveApplication($apply_id);
    }
    // Удалить из списка друзей
    $query = "DELETE FROM " . $db_prefix . "buddy WHERE request_from = {$player_id} OR request_to = {$player_id}";
    dbquery($query);
    RecalcRanks();
}
예제 #3
0
            $num -= 100;
        } else {
            $desc = "<a title=\"Уход на задание\">(У)</a>";
        }
    }
    echo "      <a title=\"\">" . loca("FLEET_ORDER_{$num}") . "</a>\n{$desc}\n";
}
$union_id = 0;
$uni = LoadUniverse();
// Обработка POST-запросов
if (method() === "POST") {
    if (key_exists('order_return', $_POST)) {
        $fleet_id = intval($_POST['order_return']);
        $fleet_obj = LoadFleet($fleet_id);
        if ($fleet_obj['owner_id'] == $GlobalUser['player_id'] && ($fleet_obj['mission'] < 100 || $fleet_obj['mission'] > 200)) {
            RecallFleet($fleet_id);
        }
    }
    if (key_exists('union_name', $_POST) && $uni['acs'] > 0) {
        $fleet_id = intval($_POST['flotten']);
        $union_id = CreateUnion($fleet_id, "KV" . $fleet_id);
        RenameUnion($union_id, $_POST['union_name']);
        // переименовать
    }
    if (key_exists('user_name', $_POST) && $uni['acs'] > 0) {
        $fleet_id = intval($_POST['flotten']);
        $union_id = CreateUnion($fleet_id, "KV" . $fleet_id);
        $FleetError = AddUnionMember($union_id, $_POST['user_name']);
        // добавить игрока
    }
}
예제 #4
0
function Admin_Fleetlogs()
{
    global $session;
    global $db_prefix;
    global $GlobalUser;
    $now = time();
    // Обработка POST-запросов.
    $player_id = 0;
    if (method() === "POST" && $GlobalUser['admin'] >= 2) {
        if (key_exists("order_2min", $_POST)) {
            // -2 минуты до оконачания задания
            $id = intval($_POST['order_2min']);
            $queue = LoadQueue($id);
            $fleet_obj = LoadFleet($queue['sub_id']);
            if ($fleet_obj['union_id']) {
                UpdateUnionTime($fleet_obj['union_id'], $now + 2 * 60, 0, true);
            } else {
                $query = "UPDATE " . $db_prefix . "queue SET end=" . ($now + 2 * 60) . " WHERE task_id={$id}";
                dbquery($query);
            }
        }
        if (key_exists("order_end", $_POST)) {
            // Завершить задание
            $id = intval($_POST['order_end']);
            $queue = LoadQueue($id);
            $fleet_obj = LoadFleet($queue['sub_id']);
            if ($fleet_obj['union_id']) {
                UpdateUnionTime($fleet_obj['union_id'], $now, 0, true);
            } else {
                $query = "UPDATE " . $db_prefix . "queue SET end={$now} WHERE task_id={$id}";
                dbquery($query);
            }
        }
        if (key_exists("order_return", $_POST)) {
            // Развернуть флот
            $queue = LoadQueue(intval($_POST['order_return']));
            RecallFleet($queue['sub_id']);
        }
    }
    $query = "SELECT * FROM " . $db_prefix . "queue WHERE type='Fleet' ORDER BY end ASC";
    $result = dbquery($query);
    $anz = $rows = dbrows($result);
    $bxx = 1;
    AdminPanel();
    echo "<table>\n";
    echo "<tr><td class=c>N</td> <td class=c>Таймер</td> <td class=c>Задание</td> <td class=c>Отправлен</td> <td class=c>Прибывает</td><td class=c>Время полёта</td> <td class=c>Старт</td> <td class=c>Цель</td> <td class=c>Флот</td> <td class=c>Груз</td> <td class=c>Топливо</td> <td class=c>САБ</td> <td class=c colspan=3>Приказ</td> </tr>\n";
    while ($rows--) {
        $queue = dbarray($result);
        $fleet_obj = LoadFleet($queue['sub_id']);
        $fleet_price = FleetPrice($fleet_obj);
        $points = $fleet_price['points'];
        $fpoints = $fleet_price['fpoints'];
        $style = "";
        if ($points >= 100000000) {
            if ($fleet_obj['mission'] <= 2) {
                $style = " style=\"background-color: FireBrick;\" ";
            } else {
                $style = " style=\"background-color: DarkGreen;\" ";
            }
        }
        ?>

        <tr <?php 
        echo $style;
        ?>
 >

        <th <?php 
        echo $style;
        ?>
 > <?php 
        echo $bxx;
        ?>
 </th>

        <th <?php 
        echo $style;
        ?>
 >
<?php 
        echo "<table><tr {$style} ><th {$style} ><div id='bxx" . $bxx . "' title='" . ($queue['end'] - $now) . "' star='" . $queue['start'] . "'> </th>";
        echo "<tr><th {$style} >" . date("d.m.Y H:i:s", $queue['end']) . "</th></tr></table>";
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        echo FleetlogsMissionText($fleet_obj['mission']);
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 ><?php 
        echo date("d.m.Y", $queue['start']);
        ?>
 <br> <?php 
        echo date("H:i:s", $queue['start']);
        ?>
</th>
        <th <?php 
        echo $style;
        ?>
 ><?php 
        echo date("d.m.Y", $queue['end']);
        ?>
 <br> <?php 
        echo date("H:i:s", $queue['end']);
        ?>
</th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        echo "<nobr>" . BuildDurationFormat($fleet_obj['flight_time']) . "</nobr><br>";
        echo "<nobr>" . $fleet_obj['flight_time'] . " сек.</nobr>";
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        $planet = GetPlanet($fleet_obj['start_planet']);
        $user = LoadUser($planet['owner_id']);
        echo AdminPlanetName($planet) . " " . AdminPlanetCoord($planet) . " <br>";
        echo AdminUserName($user);
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        $planet = GetPlanet($fleet_obj['target_planet']);
        $user = LoadUser($planet['owner_id']);
        echo AdminPlanetName($planet) . " " . AdminPlanetCoord($planet) . " <br>";
        echo AdminUserName($user);
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
        foreach ($fleetmap as $i => $gid) {
            $amount = $fleet_obj["ship" . $gid];
            if ($amount > 0) {
                echo loca("NAME_{$gid}") . ":" . nicenum($amount) . " ";
            }
        }
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        $total = $fleet_obj['m'] + $fleet_obj['k'] + $fleet_obj['d'];
        if ($total > 0) {
            echo "М: " . nicenum($fleet_obj['m']) . "<br>";
            echo "К: " . nicenum($fleet_obj['k']) . "<br>";
            echo "Д: " . nicenum($fleet_obj['d']);
        } else {
            echo "-";
        }
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
        <?php 
        echo nicenum($fleet_obj['fuel']);
        ?>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
<?php 
        if ($fleet_obj['union_id']) {
            echo $fleet_obj['union_id'];
        } else {
            echo "-";
        }
        ?>
        </th>

        <th <?php 
        echo $style;
        ?>
 >
         <form action="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Fleetlogs" method="POST">
    <input type="hidden" name="order_2min" value="<?php 
        echo $queue['task_id'];
        ?>
" />
        <input type="submit" value="2m" />
     </form>
        </th>
        <th <?php 
        echo $style;
        ?>
 >
         <form action="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Fleetlogs" method="POST">
    <input type="hidden" name="order_end" value="<?php 
        echo $queue['task_id'];
        ?>
" />
        <input type="submit" value="F" />
     </form>
        </th><th <?php 
        echo $style;
        ?>
 >
         <form action="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Fleetlogs" method="POST">
    <input type="hidden" name="order_return" value="<?php 
        echo $queue['task_id'];
        ?>
" />
        <input type="submit" value="R" />
     </form>
        </th>
        </tr>

<?php 
        $bxx++;
    }
    echo "<script language=javascript>anz={$anz};t();</script>\n";
    echo "</table>\n";
}
예제 #5
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']));
예제 #6
0
function Queue_CleanPlanets_End($queue)
{
    global $db_prefix;
    $when = $queue['end'];
    $query = "SELECT * FROM " . $db_prefix . "planets WHERE remove <= {$when} AND remove <> 0";
    $result = dbquery($query);
    $rows = dbrows($result);
    $count = 0;
    while ($rows--) {
        $planet = dbarray($result);
        $planet_id = $planet['planet_id'];
        // Развернуть флоты, летящие на удаляемую планету.
        $query = "SELECT * FROM " . $db_prefix . "fleet WHERE target_planet = {$planet_id} AND mission < 100;";
        $fleet_result = dbquery($query);
        $fleets = dbrows($fleet_result);
        while ($fleets--) {
            $fleet_obj = dbarray($fleet_result);
            RecallFleet($fleet_obj['fleet_id'], $when);
        }
        DestroyPlanet($planet_id);
        $count++;
    }
    Debug("Чистка уничтоженных планет ({$count})");
    RemoveQueue($queue['task_id']);
    AddCleanPlanetsEvent();
}
예제 #7
0
/**
 * DestroyPlanet.php
 *
 * @version 1.0
 * @copyright 2010 By MadnessRed for XNova Redesigned
 */
function DestroyPlanet($id, $CurrentUser = false, $CurrentPlanet = false, $moon_dest = false)
{
    //Do we have the current planet?
    if (!$CurrentPlanet) {
        $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . idstring($id) . "' LIMIT 1 ;", "planets", true);
    }
    //Do we have the current user?
    if (!$CurrentUser) {
        $CurrentUser = doquery("SELECT * FROM {{table}} WHERE `id` = '" . idstring($CurrentPlanet['id_owner']) . "' LIMIT 1 ;", "users", true);
    }
    //Destroy the planet
    if ($CurrentPlanet['planet_type'] == 1) {
        //Destroy the planet
        $destruyed = time() + 60 * 60 * 24;
        $QryUpdatePlanet = "UPDATE {{table}} SET ";
        $QryUpdatePlanet .= "`destruyed` = '" . $destruyed . "', ";
        $QryUpdatePlanet .= "`id_owner` = '0' ";
        $QryUpdatePlanet .= "WHERE ";
        $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "' AND `id_owner` = '" . $CurrentUser['id'] . "'  LIMIT 1;";
        doquery($QryUpdatePlanet, 'planets');
        //Delete the moon
        $QryUpdateMoon = "SELECT `id` FROM {{table}} WHERE ";
        $QryUpdateMoon .= "`galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND ";
        $QryUpdateMoon .= "`system` = '" . $CurrentPlanet['system'] . "' AND ";
        $QryUpdateMoon .= "`planet` = '" . $CurrentPlanet['planet'] . "' AND ";
        $QryUpdateMoon .= "`planet_type` = '3' LIMIT 1 ;";
        $moon = doquery($QryUpdateMoon, 'planets');
        if ($moon['id'] > 0) {
            DestroyPlanet($moon['id'], $CurrentUser);
        }
        //Delete the moon
    } else {
        $QryUpdatePlanet = "DELETE FROM {{table}} WHERE ";
        $QryUpdatePlanet .= "`id` = '" . $CurrentUser['current_planet'] . "' AND ";
        $QryUpdatePlanet .= "`id_owner` = '" . $CurrentUser['id'] . "'  LIMIT 1;";
        doquery($QryUpdatePlanet, 'planets');
        //If this is a destroy fleet, get the orbitted planet
        if ($moon_dest) {
            $QryUpdateMoon = "SELECT `id` FROM {{table}} WHERE ";
            $QryUpdateMoon .= "`galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND ";
            $QryUpdateMoon .= "`system` = '" . $CurrentPlanet['system'] . "' AND ";
            $QryUpdateMoon .= "`planet` = '" . $CurrentPlanet['planet'] . "' AND ";
            $QryUpdateMoon .= "`planet_type` = '1' LIMIT 1 ;";
            $planet = doquery($QryUpdateMoon, 'planets');
        }
    }
    //Set the user to his homeworld
    $QryUpdateUser = "******";
    $QryUpdateUser .= "`current_planet` = `id_planet`, ";
    $QryUpdateUser .= "`menus_update` = '" . time() . "' ";
    $QryUpdateUser .= "WHERE ";
    $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "' LIMIT 1";
    doquery($QryUpdateUser, "users");
    //Deal with any fleets
    //Recall and fleets going to this planet
    $incoming = doquery("SELECT `fleet_id` FROM {{table}} WHERE `target_id` = " . $CurrentPlanet['id'] . " AND `fleet_mess` = '0' ;", 'fleets');
    while ($row = FetchArray($incoming)) {
        RecallFleet($row['fleet_id']);
    }
    //Get all fleets returning to this planet
    if ($moon_dest) {
        //Divert returning fleets to the planet
        $incoming = doquery("UPDATE {{table}} SET `target_id` = " . $planet['id'] . " WHERE `target_id` = " . $CurrentPlanet['id'] . " AND `fleet_mess` = '1' ;", 'fleets');
    } else {
        //This planet was not destroyed that way, jsut remove any ships going to it.
        doquery("DELETE FROM {{table}} WHERE `target_id` = " . $CurrentPlanet['id'] . " AND `fleet_mess` = '1' ;", 'fleets', false, true);
    }
}