Exemplo n.º 1
0
                        echo "<a href=index.php?page=galaxy&no_header=1&session={$session}&mode=1&p1=" . $moon['g'] . "&p2=" . $moon['s'] . "&p3=" . $moon['p'] . "&pdd=" . $moon['planet_id'] . "&zp=" . $moon['owner_id'] . " >Ракетная атака</a><br />";
                    }
                    echo "<a href=index.php?page=flotten1&session=" . $_GET['session'] . "&galaxy=" . $moon['g'] . "&system=" . $moon['s'] . "&planet=" . $moon['p'] . "&planettype=3&target_mission=3 >Транспорт</a><br />";
                    echo "<a href=index.php?page=flotten1&session=" . $_GET['session'] . "&galaxy=" . $moon['g'] . "&system=" . $moon['s'] . "&planet=" . $moon['p'] . "&planettype=3&target_mission=1 >Атака</a><br />";
                    echo "<a href=index.php?page=flotten1&session=" . $_GET['session'] . "&galaxy=" . $moon['g'] . "&system=" . $moon['s'] . "&planet=" . $moon['p'] . "&planettype=3&target_mission=5 >Удерживать</a><br />";
                    echo "<a href=index.php?page=flotten1&session=" . $_GET['session'] . "&galaxy=" . $moon['g'] . "&system=" . $moon['s'] . "&planet=" . $moon['p'] . "&planettype=3&target_mission=9 >Уничтожить</a><br />";
                }
                if ($GlobalUser['admin'] >= 2) {
                    echo "<a href=index.php?page=admin&session={$session}&mode=Planets&cp=" . $moon['planet_id'] . ">Управление планетой</a><br />";
                }
                echo "</th></tr></table></tr></table>', STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -110 );\" style=\"cursor: pointer;\" \n";
                echo " href='#' onclick='doit(6, " . $moon['g'] . ", " . $moon['s'] . ", " . $moon['p'] . ", 3, " . $GlobalUser['maxspy'] . ")' \n";
                echo ">\n";
                echo "<img width=\"22\" height=\"22\" alt=\"Луна (размер: " . $moon['diameter'] . ")\" src=\"" . GetPlanetSmallImage(UserSkin(), $moon) . "\"/></a>\n";
            } else {
                echo "<div style=\"border: 2pt solid #FF0000;\"><img src=\"" . GetPlanetSmallImage(UserSkin(), $moon) . "\" alt=\"Луна (размер: " . $moon['diameter'] . ")\" height=\"22\" width=\"22\" onmouseover=\"return overlib('<font color=white><b>Покинута</b></font>', WIDTH, 75);\" onmouseout=\"return nd();\"/></div>\n";
            }
        }
        echo "</th>\n";
        // поле обломков (не показывать ПО <= 300 единиц)
        echo "<th width=\"30\">";
        $debris = LoadPlanet($coord_g, $coord_s, $p, 2);
        if ($debris) {
            $harvesters = ceil(($debris['m'] + $debris['k']) / $UnitParam[209][3]);
            if ($debris['m'] + $debris['k'] > 300) {
                ?>
    <a style="cursor:pointer"
       onmouseover="return overlib('<table width=240 ><tr><td class=c colspan=2 ></td></tr><tr><th width=80 ><img src=<?php 
                echo UserSkin();
                ?>
planeten/debris.jpg height=75 width=75 alt=T /></th><th><table><tr><td class=c colspan=2>Ресурсы:</td></tr><tr><th>металл:</th><th><?php 
Exemplo n.º 2
0
function Admin_Users()
{
    global $session;
    global $db_prefix;
    global $GlobalUser;
    global $FleetMissionList;
    $now = time();
    $resmap = array(106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 199);
    $unitab = LoadUniverse();
    $speed = $unitab['speed'];
    // Обработка POST-запроса.
    if (method() === "POST" && $GlobalUser['admin'] >= 2) {
        if (key_exists('player_id', $_GET)) {
            $player_id = intval($_GET['player_id']);
        } else {
            $player_id = 0;
        }
        if (key_exists('action', $_GET) && $player_id) {
            $action = $_GET['action'];
        } else {
            $action = "";
        }
        if ($action === "update") {
            $query = "UPDATE " . $db_prefix . "users SET ";
            foreach ($resmap as $i => $gid) {
                $query .= "r{$gid} = " . intval($_POST["r{$gid}"]) . ", ";
            }
            if ($_POST['deaktjava'] === "on") {
                $query .= "disable = 1, disable_until = " . ($now + 7 * 24 * 60 * 60) . ", ";
            } else {
                $query .= "disable = 0, ";
            }
            if ($_POST['vacation'] === "on") {
                $query .= "vacation = 1, vacation_until = " . ($now + 2 * 24 * 60 * 60 / $speed) . ", ";
            } else {
                $query .= "vacation = 0, ";
            }
            if ($_POST['banned'] !== "on") {
                $query .= "banned = 0, ";
            }
            if ($_POST['noattack'] !== "on") {
                $query .= "noattack = 0, ";
            }
            $query .= "pemail = '" . $_POST['pemail'] . "', ";
            $query .= "email = '" . $_POST['email'] . "', ";
            $query .= "admin = '" . $_POST['admin'] . "', ";
            $query .= "validated = " . ($_POST['validated'] === "on" ? 1 : 0) . ", ";
            $query .= "sniff = " . ($_POST['sniff'] === "on" ? 1 : 0) . ", ";
            $query .= "debug = " . ($_POST['debug'] === "on" ? 1 : 0) . ", ";
            $query .= "dm = '" . intval($_POST['dm']) . "', ";
            $query .= "dmfree = '" . intval($_POST['dmfree']) . "', ";
            $query .= "sortby = '" . intval($_POST['settings_sort']) . "', ";
            $query .= "sortorder = '" . intval($_POST['settings_order']) . "', ";
            $query .= "skin = '" . $_POST['dpath'] . "', ";
            $query .= "useskin = " . ($_POST['design'] === "on" ? 1 : 0) . ", ";
            $query .= "deact_ip = " . ($_POST['deact_ip'] === "on" ? 1 : 0) . ", ";
            $query .= "maxspy = '" . intval($_POST['spio_anz']) . "', ";
            $query .= "maxfleetmsg = '" . intval($_POST['settings_fleetactions']) . "' ";
            $query .= " WHERE player_id={$player_id};";
            dbquery($query);
            $qname = array('CommanderOff', 'AdmiralOff', 'EngineerOff', 'GeologeOff', 'TechnocrateOff');
            foreach ($qname as $i => $qcmd) {
                $days = intval($_POST[$qcmd]);
                if ($days > 0) {
                    RecruitOfficer($player_id, $qcmd, $days * 24 * 60 * 60);
                }
            }
        }
        if ($action === "create_planet") {
            $g = $_POST['g'];
            if ($g === "") {
                $g = 1;
            }
            $s = $_POST['s'];
            if ($s === "") {
                $s = 1;
            }
            $p = $_POST['p'];
            if ($p === "") {
                $p = 1;
            }
            if (!HasPlanet($g, $s, $p)) {
                $planet_id = CreatePlanet($g, $s, $p, $_GET['player_id']);
                $query = "UPDATE " . $db_prefix . "planets SET mprod = 0, kprod = 0, dprod = 0 WHERE planet_id = " . $planet_id;
                dbquery($query);
            }
        }
    }
    // Обработка GET-запроса.
    if (method() === "GET" && $GlobalUser['admin'] >= 2) {
        if (key_exists('player_id', $_GET)) {
            $player_id = intval($_GET['player_id']);
        } else {
            $player_id = 0;
        }
        if (key_exists('action', $_GET) && $player_id) {
            $action = $_GET['action'];
        } else {
            $action = "";
        }
        $now = time();
        if ($action === "recalc_stats") {
            RecalcStats($player_id);
            RecalcRanks();
        }
        if ($action === "reactivate") {
            ReactivateUser($player_id);
        }
        if ($action === "bot_start") {
            StartBot($player_id);
        }
        if ($action === "bot_stop") {
            StopBot($player_id);
        }
    }
    if (key_exists("player_id", $_GET)) {
        // Информация об игроке
        InvalidateUserCache();
        $user = LoadUser(intval($_GET['player_id']));
        ?>

    <?php 
        echo AdminPanel();
        ?>

    <table>
    <form action="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Users&action=update&player_id=<?php 
        echo $user['player_id'];
        ?>
" method="POST" >
    <tr><td class=c><?php 
        echo AdminUserName($user);
        ?>
</td><td class=c>Настройки</td><td class=c>Исследования</td></tr>

        <th valign=top><table>
            <tr><th>ID</th><th><?php 
        echo $user['player_id'];
        ?>
</th></tr>
            <tr><th>Дата регистрации</th><th><?php 
        echo date("Y-m-d H:i:s", $user['regdate']);
        ?>
</th></tr>
            <tr><th>Альянс</th><th>
<?php 
        if ($user['ally_id']) {
            $ally = LoadAlly($user['ally_id']);
            echo "[" . $ally['tag'] . "] " . $ally['name'];
        }
        ?>
</th></tr>
            <tr><th>Дата вступления</th><th>
<?php 
        if ($user['ally_id']) {
            echo date("Y-m-d H:i:s", $user['joindate']);
        }
        ?>
</th></tr>
            <tr><th>Постоянный адрес</th><th><input type="text" name="pemail" maxlength="100" size="20" value="<?php 
        echo $user['pemail'];
        ?>
" /></th></tr>
            <tr><th>Временный адрес</th><th><input type="text" name="email" maxlength="100" size="20" value="<?php 
        echo $user['email'];
        ?>
" /></th></tr>
            <tr><th>Удалить игрока</th><th><input type="checkbox" name="deaktjava"  <?php 
        echo IsChecked($user, "disable");
        ?>
/>
      <?php 
        if ($user['disable']) {
            echo date("Y-m-d H:i:s", $user['disable_until']);
        }
        ?>
</th></tr>
            <tr><th>Режим отпуска</th><th><input type="checkbox" name="vacation"  <?php 
        echo IsChecked($user, "vacation");
        ?>
/>
      <?php 
        if ($user['vacation']) {
            echo date("Y-m-d H:i:s", $user['vacation_until']);
        }
        ?>
</th></tr>
            <tr><th>Заблокирован</th><th><input type="checkbox" name="banned"  <?php 
        echo IsChecked($user, "banned");
        ?>
/>
      <?php 
        if ($user['banned']) {
            echo date("Y-m-d H:i:s", $user['banned_until']);
        }
        ?>
</th></tr>
            <tr><th>Бан атак</th><th><input type="checkbox" name="noattack"  <?php 
        echo IsChecked($user, "noattack");
        ?>
/>
      <?php 
        if ($user['noattack']) {
            echo date("Y-m-d H:i:s", $user['noattack_until']);
        }
        ?>
</th></tr>
            <tr><th>Последний вход</th><th><?php 
        echo date("Y-m-d H:i:s", $user['lastlogin']);
        ?>
</th></tr>
            <tr><th>Активность</th><th>
<?php 
        $now = time();
        echo date("Y-m-d H:i:s", $user['lastclick']);
        if ($now - $user['lastclick'] < 60 * 60) {
            echo " (" . floor(($now - $user['lastclick']) / 60) . " min)";
        }
        ?>
</th></tr>
            <tr><th>IP адрес</th><th><a href="http://nic.ru/whois/?query=<?php 
        echo $user['ip_addr'];
        ?>
" target=_blank><?php 
        echo $user['ip_addr'];
        ?>
</a></th></tr>
            <tr><th>Активирован</th><th><input type="checkbox" name="validated" <?php 
        echo IsChecked($user, "validated");
        ?>
 /> <a href="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Users&action=reactivate&player_id=<?php 
        echo $user['player_id'];
        ?>
">выслать пароль</a></th></tr>
            <tr><th>Главная планета</th><th>
<?php 
        $planet = GetPlanet($user['hplanetid']);
        echo "[" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "] <a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $planet['planet_id'] . "\">" . $planet['name'] . "</a>";
        ?>
</th></tr>
            <tr><th>Текущая планета</th><th>
<?php 
        $planet = GetPlanet($user['aktplanet']);
        echo "[" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "] <a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $planet['planet_id'] . "\">" . $planet['name'] . "</a>";
        ?>
</th></tr>
            <tr><th>Права</th><th>
   <select name="admin">
     <option value="0" <?php 
        echo IsSelected($user, "admin", 0);
        ?>
>Пользователь</option>
     <option value="1" <?php 
        echo IsSelected($user, "admin", 1);
        ?>
>Оператор</option>
     <option value="2" <?php 
        echo IsSelected($user, "admin", 2);
        ?>
>Администратор</option>
   </select>
</th></tr>
            <tr><th>Включить слежение</th><th><input type="checkbox" name="sniff" <?php 
        echo IsChecked($user, "sniff");
        ?>
 /></th></tr>
            <tr><th>Отладочная информация</th><th><input type="checkbox" name="debug" <?php 
        echo IsChecked($user, "debug");
        ?>
 /></th></tr>

<?php 
        if (IsBot($user['player_id'])) {
            ?>
            <tr><th colspan=2><a href="index.php?page=admin&session=<?php 
            echo $session;
            ?>
&mode=Users&action=bot_stop&player_id=<?php 
            echo $user['player_id'];
            ?>
" >[Остановить бота]</a></th></tr>
<?php 
        } else {
            ?>
            <tr><th colspan=2><a href="index.php?page=admin&session=<?php 
            echo $session;
            ?>
&mode=Users&action=bot_start&player_id=<?php 
            echo $user['player_id'];
            ?>
" >[Запустить бота]</a></th></tr>
<?php 
        }
        ?>
        </table></th>

        <th valign=top><table>
            <tr><th>Сортировка планет</th><th>
   <select name="settings_sort">
    <option value="0" <?php 
        echo IsSelected($user, "sortby", 0);
        ?>
 >порядку колонизации</option>
    <option value="1" <?php 
        echo IsSelected($user, "sortby", 1);
        ?>
 >координатам</option>
    <option value="2" <?php 
        echo IsSelected($user, "sortby", 2);
        ?>
 >алфавиту</option>
   </select>
</th></tr>
            <tr><th>Порядок сортировки</th><th>
   <select name="settings_order">
     <option value="0" <?php 
        echo IsSelected($user, "sortorder", 0);
        ?>
>по возрастанию</option>
     <option value="1" <?php 
        echo IsSelected($user, "sortorder", 1);
        ?>
>по убыванию</option>
   </select>
</th></tr>
            <tr><th>Скин</th><th><input type=text name="dpath" maxlength="80" size="40" value="<?php 
        echo $user['skin'];
        ?>
" /></th></tr>
            <tr><th>Использовать скин</th><th><input type="checkbox" name="design" <?php 
        echo IsChecked($user, "useskin");
        ?>
 /></th></tr>
            <tr><th>Декативировать проверку IP</th><th><input type="checkbox" name="deact_ip" <?php 
        echo IsChecked($user, "deact_ip");
        ?>
 /></th></tr>
            <tr><th>Количество зондов</th><th><input type="text" name="spio_anz" maxlength="2" size="2" value="<?php 
        echo $user['maxspy'];
        ?>
" /></th></tr>
            <tr><th>Количество сообщений флота</th><th><input type="text" name="settings_fleetactions" maxlength="2" size="2" value="<?php 
        echo $user['maxfleetmsg'];
        ?>
" /></th></tr>

            <tr><th colspan=2>&nbsp</th></tr>
            <tr><td class=c colspan=2>Статистика</td></tr>
            <tr><th>Очки (старые)</th><th><?php 
        echo nicenum($user['oldscore1'] / 1000);
        ?>
 / <?php 
        echo nicenum($user['oldplace1']);
        ?>
</th></tr>
            <tr><th>Флот (старые)</th><th><?php 
        echo nicenum($user['oldscore2']);
        ?>
 / <?php 
        echo nicenum($user['oldplace2']);
        ?>
</th></tr>
            <tr><th>Исследования (старые)</th><th><?php 
        echo nicenum($user['oldscore3']);
        ?>
 / <?php 
        echo nicenum($user['oldplace3']);
        ?>
</th></tr>
            <tr><th>Очки</th><th><?php 
        echo nicenum($user['score1'] / 1000);
        ?>
 / <?php 
        echo nicenum($user['place1']);
        ?>
</th></tr>
            <tr><th>Флот</th><th><?php 
        echo nicenum($user['score2']);
        ?>
 / <?php 
        echo nicenum($user['place2']);
        ?>
</th></tr>
            <tr><th>Исследования</th><th><?php 
        echo nicenum($user['score3']);
        ?>
 / <?php 
        echo nicenum($user['place3']);
        ?>
</th></tr>
            <tr><th>Дата старой статистики</th><th><?php 
        echo date("Y-m-d H:i:s", $user['scoredate']);
        ?>
</th></tr>
            <tr><th colspan=2><a href="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Users&action=recalc_stats&player_id=<?php 
        echo $user['player_id'];
        ?>
" >[Пересчитать статистику]</a></th></tr>

            <tr><th colspan=2>&nbsp</th></tr>
            <tr><td class=c colspan=2>Офицеры</td></tr>
            <tr><th colspan=2><table><tr>
<?php 
        $oname = array('Командир ОГейма', 'Адмирал', 'Инженер', 'Геолог', 'Технократ');
        $odesc = array('', '<font size=1 color=skyblue>&amp;nbsp;Макс. кол-во флотов +2</font>', '<font size=1 color=skyblue>Сокращает вдвое потери в обороне+10% больше энергии</font>', '<font size=1 color=skyblue>+10% доход от шахты</font>', '<font size=1 color=skyblue>+2 уровень шпионажа, 25% меньше времени на исследования</font>');
        $qname = array('CommanderOff', 'AdmiralOff', 'EngineerOff', 'GeologeOff', 'TechnocrateOff');
        $imgname = array('commander', 'admiral', 'ingenieur', 'geologe', 'technokrat');
        $now = time();
        foreach ($qname as $i => $qcmd) {
            $end = GetOfficerLeft($user['player_id'], $qname[$i]);
            $img = "";
            if ($end <= $now) {
                $img = "_un";
                $days = "";
            } else {
                $d = ($end - $now) / (60 * 60 * 24);
                if ($d > 0) {
                    $days = "&lt;font color=lime&gt;Активен&lt;/font&gt; ещё " . ceil($d) . " д.";
                }
            }
            echo "    <td align='center' width='35' class='header'>\n";
            echo "\t<img border='0' src='img/" . $imgname[$i] . "_ikon" . $img . ".gif' width='32' height='32' alt='" . $oname[$i] . "'\n";
            echo "\tonmouseover=\"return overlib('<center><font size=1 color=white><b>" . $days . "<br>" . $oname[$i] . "</font><br>" . $odesc[$i] . "<br></b></center>', LEFT, WIDTH, 150);\" onmouseout='return nd();'>\n";
            echo "    </td> <td><input type=\"text\" name=\"" . $qname[$i] . "\" size=\"3\" /></td>\n\n";
        }
        ?>
        </tr></table></th></tr>

            <tr><th colspan=2><i>Чтобы продлить офицера укажите необходимое количество дней в полях ввода</i></th></tr>

        </table></th>

        <th valign=top><table>
<?php 
        foreach ($resmap as $i => $gid) {
            echo "<tr><th>" . loca("NAME_{$gid}") . "</th><th><input type=\"text\" size=3 name=\"r{$gid}\" value=\"" . $user["r{$gid}"] . "\" /></th></tr>\n";
        }
        ?>
        <tr><th>Найденная Тёмная Материя</th><th><input type="text" size=5 name="dmfree" value="<?php 
        echo $user['dmfree'];
        ?>
" /></th></tr>
        <tr><th>Покупная Тёмная Материя</th><th><input type="text" size=5 name="dm" value="<?php 
        echo $user['dm'];
        ?>
" /></th></tr>
        </table></th>
    <tr><th colspan=3><input type="submit" value="Сохранить" /></th></tr>
    </form>
    </table>

    <br>
    <table> 
    <form action="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Users&action=create_planet&player_id=<?php 
        echo $user['player_id'];
        ?>
" method="POST" >
    <tr><td class=c colspan=20>Список планет</td></tr>
    <tr>
<?php 
        $query = "SELECT * FROM " . $db_prefix . "planets WHERE owner_id = '" . intval($_GET['player_id']) . "' ORDER BY g ASC, s ASC, p ASC, type DESC";
        $result = dbquery($query);
        $rows = dbrows($result);
        $counter = 0;
        while ($rows--) {
            $p = dbarray($result);
            ?>
    <td> <img src="<?php 
            echo GetPlanetSmallImage("../evolution/", $p);
            ?>
" width="32px" height="32px"></td>
    <td> <a href="index.php?page=admin&session=<?php 
            echo $session;
            ?>
&mode=Planets&cp=<?php 
            echo $p['planet_id'];
            ?>
"> <?php 
            echo $p['name'];
            ?>
 </a>
            [<a href="index.php?page=galaxy&session=<?php 
            echo $session;
            ?>
&galaxy=<?php 
            echo $p['g'];
            ?>
&system=<?php 
            echo $p['s'];
            ?>
"><?php 
            echo $p['g'];
            ?>
:<?php 
            echo $p['s'];
            ?>
:<?php 
            echo $p['p'];
            ?>
</a>] </td>
<?php 
            $counter++;
            if ($counter > 9) {
                $counter = 0;
                echo "</tr>\n<tr>\n";
            }
        }
        ?>
    </tr>
    <tr><td colspan=20> Координаты: <input name="g" size=2> <input name="s" size=2> <input name="p" size=2> <input type="submit" value="Создать планету"></td></tr>
    </form>
    </table>

    <br>
    <table>

<?php 
        if ($_GET['action'] === 'fleetlogs') {
            echo "<tr><td class=c colspan=12>Логи полётов</td></tr>\n";
            if ($_GET['from'] == 1) {
                $result = FleetlogsFromPlayer($user['player_id'], $FleetMissionList[$_GET['mission']]);
            } else {
                $result = FleetlogsToPlayer($user['player_id'], $FleetMissionList[$_GET['mission']]);
            }
            $anz = $rows = dbrows($result);
            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> </tr>\n";
            $bxx = 1;
            while ($rows--) {
                $fleet_obj = dbarray($result);
                $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='" . ($fleet_obj['end'] - $now) . "' star='" . $fleet_obj['start'] . "'> </th>";
                echo "<tr><th {$style} >" . date("d.m.Y H:i:s", $fleet_obj['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", $fleet_obj['start']);
                ?>
 <br> <?php 
                echo date("H:i:s", $fleet_obj['start']);
                ?>
</th>
        <th <?php 
                echo $style;
                ?>
 ><?php 
                echo date("d.m.Y", $fleet_obj['end']);
                ?>
 <br> <?php 
                echo date("H:i:s", $fleet_obj['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 
                echo "[" . $fleet_obj['origin_g'] . ":" . $fleet_obj['origin_s'] . ":" . $fleet_obj['origin_p'] . "]";
                $u = LoadUser($fleet_obj['owner_id']);
                echo " <br>" . AdminUserName($u);
                ?>
        </th>
        <th <?php 
                echo $style;
                ?>
 >
<?php 
                echo "[" . $fleet_obj['target_g'] . ":" . $fleet_obj['target_s'] . ":" . $fleet_obj['target_p'] . "]";
                $u = LoadUser($fleet_obj['target_id']);
                echo " <br>" . AdminUserName($u);
                ?>
        </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['pm'] + $fleet_obj['pk'] + $fleet_obj['pd'];
                if ($total > 0) {
                    echo "М: " . nicenum($fleet_obj['pm']) . "<br>";
                    echo "К: " . nicenum($fleet_obj['pk']) . "<br>";
                    echo "Д: " . nicenum($fleet_obj['pd']);
                } else {
                    echo "-";
                }
                ?>
        </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 
                if ($fleet_obj['union_id']) {
                    echo $fleet_obj['union_id'];
                } else {
                    echo "-";
                }
                ?>
        </th>

        </tr>
<?php 
                $bxx++;
            }
            echo "<script language=javascript>anz={$anz};t();</script>\n";
        } else {
            ?>

    <tr><td class=c colspan=3>Логи полётов</td></tr>
    <tr><td>Задание</td><td>от <?php 
            echo $user['oname'];
            ?>
</td><td>на <?php 
            echo $user['oname'];
            ?>
</td></tr>
    <tr><td>Все</td><td><?php 
            echo LinkFleetsFrom($user, 0);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 0);
            ?>
</td></tr>
    <tr><td>Атака</td><td><?php 
            echo LinkFleetsFrom($user, 1);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 1);
            ?>
</td></tr>
    <tr><td>Совместная атака</td><td><?php 
            echo LinkFleetsFrom($user, 2);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 2);
            ?>
</td></tr>
    <tr><td>Транспорт</td><td><?php 
            echo LinkFleetsFrom($user, 3);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 3);
            ?>
</td></tr>
    <tr><td>Оставить</td><td><?php 
            echo LinkFleetsFrom($user, 4);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 4);
            ?>
</td></tr>
    <tr><td>Держаться</td><td><?php 
            echo LinkFleetsFrom($user, 5);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 5);
            ?>
</td></tr>
    <tr><td>Шпионаж</td><td><?php 
            echo LinkFleetsFrom($user, 6);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 6);
            ?>
</td></tr>
    <tr><td>Колонизировать</td><td><?php 
            echo LinkFleetsFrom($user, 7);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 7);
            ?>
</td></tr>
    <tr><td>Переработать</td><td><?php 
            echo LinkFleetsFrom($user, 8);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 8);
            ?>
</td></tr>
    <tr><td>Уничтожить</td><td><?php 
            echo LinkFleetsFrom($user, 9);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 9);
            ?>
</td></tr>
    <tr><td>Экспедиция</td><td><?php 
            echo LinkFleetsFrom($user, 15);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 15);
            ?>
</td></tr>
    <tr><td>Ракетная атака</td><td><?php 
            echo LinkFleetsFrom($user, 20);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 20);
            ?>
</td></tr>
    <tr><td>Атака (САБ)</td><td><?php 
            echo LinkFleetsFrom($user, 21);
            ?>
</td><td><?php 
            echo LinkFleetsTo($user, 21);
            ?>
</td></tr>
    </table>

<?php 
        }
        ?>

<?php 
    } else {
        $query = "SELECT * FROM " . $db_prefix . "users ORDER BY regdate DESC LIMIT 25";
        $result = dbquery($query);
        AdminPanel();
        echo "    </th> \n";
        echo "   </tr> \n";
        echo "</table> \n";
        echo "Новые пользователи:<br>\n";
        echo "<table>\n";
        echo "<tr><td class=c>Дата регистрации</td><td class=c>Главная планета</td><td class=c>Имя игрока</td></tr>\n";
        $rows = dbrows($result);
        while ($rows--) {
            $user = dbarray($result);
            $hplanet = GetPlanet($user['hplanetid']);
            echo "<tr><th>" . date("Y-m-d H:i:s", $user['regdate']) . "</th>";
            echo "<th>[" . $hplanet['g'] . ":" . $hplanet['s'] . ":" . $hplanet['p'] . "] <a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $hplanet['planet_id'] . "\">" . $hplanet['name'] . "</a></th>";
            echo "<th>" . AdminUserName($user) . "</th></tr>\n";
        }
        echo "</table>\n";
        ?>

    <br>
    <table>
<?php 
        $when = time() - 24 * 60 * 60;
        $query = "SELECT * FROM " . $db_prefix . "users WHERE lastclick >= {$when} ORDER BY oname ASC";
        $result = dbquery($query);
        $rows = dbrows($result);
        ?>
    <tr><td class=c>Активные за последние 24 часа (<?php 
        echo $rows;
        ?>
)</td></tr>
    <tr><td>
<?php 
        $first = true;
        while ($rows--) {
            $user = dbarray($result);
            if ($first) {
                $first = false;
            } else {
                echo ", ";
            }
            echo AdminUserName($user);
        }
        ?>
    </td></tr>
    </table>

<?php 
    }
    // Поиск пользователей
}
Exemplo n.º 3
0
function PlayerDetails($player_id)
{
    global $galaxy, $stats, $ally;
    if (!key_exists($player_id, $stats)) {
        return;
    }
    $planets = array();
    $moons = array();
    echo "<br><br><font size=+2>" . $stats[$player_id]['name'] . ":</font>";
    echo "<table cellpadding=0 cellspacing=0><tr>";
    echo "<td class=b style=\"vertical-align:top\">";
    echo va(loca("GALATOOL_POINTS"), nicenum($stats[$player_id]['points'] / 1000)) . "<br>";
    echo va(loca("GALATOOL_FLEET"), nicenum($stats[$player_id]['fpoints'])) . "<br>";
    echo va(loca("GALATOOL_RESEARCH"), nicenum($stats[$player_id]['rpoints'])) . "<br>";
    if ($stats[$player_id]['ally_id']) {
        echo va(loca("GALATOOL_ALLY"), $ally[$stats[$player_id]['ally_id']]['name']) . "<br>";
    }
    echo "</td>";
    foreach ($galaxy as $planet_id => $planet) {
        if ($planet['owner_id'] == $player_id && $planet['type'] < 10000) {
            $num = 1000000 * $planet['g'] + 1000 * $planet['s'] + 15 * $planet['p'];
            if ($planet['type'] == 0) {
                $moons[$num] = array();
                $moons[$num]['name'] = $planet['name'];
                $moons[$num]['type'] = 0;
                $moons[$num]['present'] = 1;
            } else {
                $planets[$planet_id] = array();
                $planets[$planet_id]['name'] = $planet['name'];
                $planets[$planet_id]['num'] = $num;
                $planets[$planet_id]['g'] = $planet['g'];
                $planets[$planet_id]['s'] = $planet['s'];
                $planets[$planet_id]['p'] = $planet['p'];
                $planets[$planet_id]['planet_id'] = $planet_id;
                $planets[$planet_id]['type'] = 1;
            }
        }
    }
    $planets = sksort($planets, 'num', true);
    echo "<td class=b><b>" . loca("GALATOOL_PLANETS") . "</b>:";
    echo "<table>";
    foreach ($planets as $id => $planet) {
        echo "<tr><td align=center><img src=\"" . GetPlanetSmallImage(hostname() . "/evolution/", $planet) . "\" height=30px><br>\n";
        echo $planet['name'];
        echo " [" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "]</td></tr>";
    }
    echo "</table></td>";
    echo "<td class=b><b>" . loca("GALATOOL_MOONS") . "</b>:";
    echo "<table>";
    if (key_exists($planet['num'], $moons)) {
        foreach ($planets as $id => $planet) {
            if ($moons[$planet['num']]['present'] == 1) {
                echo "<tr><td align=center><img src=\"" . GetPlanetSmallImage(hostname() . "/evolution/", $moons[$planet['num']]) . "\" height=30px><br>\n";
                echo $moons[$planet['num']]['name'] . "</td></tr>";
            } else {
                echo "<tr><td height=\"45px\"></td></tr>";
            }
        }
    }
    echo "</table></td>";
    echo "</tr></table>";
}
function Admin_Planets()
{
    global $loca_lang, $Languages;
    global $session;
    global $db_prefix;
    global $GlobalUser;
    $SearchResult = "";
    $buildmap = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 41, 42, 43, 44);
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $defmap = array(401, 402, 403, 404, 405, 406, 407, 408, 502, 503);
    // Обработка POST-запроса.
    if (method() === "POST" && $GlobalUser['admin'] >= 2) {
        $cp = intval($_GET['cp']);
        $action = $_GET['action'];
        $now = time();
        //print_r ( $_POST);
        if ($action === "update") {
            $param = array('b1', 'b2', 'b3', 'b4', 'b12', 'b14', 'b15', 'b21', 'b22', 'b23', 'b24', 'b31', 'b33', 'b34', 'b41', 'b42', 'b43', 'b44', 'd401', 'd402', 'd403', 'd404', 'd405', 'd406', 'd407', 'd408', 'd502', 'd503', 'f202', 'f203', 'f204', 'f205', 'f206', 'f207', 'f208', 'f209', 'f210', 'f211', 'f212', 'f213', 'f214', 'f215', 'm', 'k', 'd', 'g', 's', 'p', 'diameter', 'type', 'temp', 'mprod', 'kprod', 'dprod', 'sprod', 'fprod', 'ssprod');
            $moon_param = array('g', 's', 'p');
            $query = "UPDATE " . $db_prefix . "planets SET lastpeek={$now}, ";
            foreach ($param as $i => $p) {
                if (strpos($p, "prod")) {
                    $query .= ", {$p}='" . $_POST[$p] . "'";
                } else {
                    if ($i == 0) {
                        $query .= "{$p}=" . intval($_POST[$p]);
                    } else {
                        $query .= ", {$p}=" . intval($_POST[$p]);
                    }
                }
            }
            $query .= " WHERE planet_id={$cp};";
            if (key_exists("delete_planet", $_POST)) {
                $planet = GetPlanet($cp);
                $user = LoadUser($planet['owner_id']);
                if ($user['hplanetid'] != $cp) {
                    DestroyPlanet($cp);
                    $_GET['cp'] = $user['hplanetid'];
                    // перенаправить на главную планету.
                }
            } else {
                // Обновить данные планеты
                $moon_id = PlanetHasMoon($cp);
                // Переместить луну за планетой.
                if ($moon_id) {
                    $mquery = "UPDATE " . $db_prefix . "planets SET lastpeek={$now}, ";
                    foreach ($moon_param as $i => $p) {
                        if ($i == 0) {
                            $mquery .= "{$p}=" . intval($_POST[$p]);
                        } else {
                            $mquery .= ", {$p}=" . intval($_POST[$p]);
                        }
                    }
                    $mquery .= " WHERE planet_id={$moon_id};";
                    dbquery($mquery);
                }
                dbquery($query);
                RecalcFields($cp);
            }
        } else {
            if ($action === "search") {
                $searchtype = $_POST['type'];
                if ($_POST['searchtext'] === "") {
                    $SearchResult .= "Укажите строку для поиска<br>\n";
                    $searchtype = "none";
                }
                if ($searchtype === "playername") {
                    $query = "SELECT player_id FROM " . $db_prefix . "users WHERE oname LIKE '" . $_POST['searchtext'] . "%'";
                    $query = "SELECT * FROM " . $db_prefix . "planets WHERE owner_id = ANY ({$query});";
                } else {
                    if ($searchtype === "planetname") {
                        $query = "SELECT * FROM " . $db_prefix . "planets WHERE name LIKE '" . $_POST['searchtext'] . "%';";
                    } else {
                        if ($searchtype === "allytag") {
                            $query = "SELECT ally_id FROM " . $db_prefix . "ally WHERE tag LIKE '" . $_POST['searchtext'] . "%'";
                            $query = "SELECT player_id FROM " . $db_prefix . "users WHERE ally_id <> 0 AND ally_id = ANY ({$query})";
                            $query = "SELECT * FROM " . $db_prefix . "planets WHERE owner_id = ANY ({$query});";
                        }
                    }
                }
                if ($query) {
                    $result = dbquery($query);
                }
                $SearchResult .= "<table>\n";
                $rows = dbrows($result);
                if ($rows > 0) {
                    while ($rows--) {
                        $planet = dbarray($result);
                        $user = LoadUser($planet['owner_id']);
                        $SearchResult .= "<tr><th>" . date("Y-m-d H:i:s", $planet['date']) . "</th><th>" . AdminPlanetCoord($planet) . "</th>";
                        $SearchResult .= "<th><a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $planet['planet_id'] . "\">" . $planet['name'] . "</a></th>";
                        $SearchResult .= "<th><a href=\"index.php?page=admin&session={$session}&mode=Users&player_id=" . $user['player_id'] . "\">" . $user['oname'] . "</a></th></tr>\n";
                    }
                } else {
                    $SearchResult .= "Ничего не найдено<br>\n";
                }
                $SearchResult .= "</table>\n";
            }
        }
    }
    // Обработка GET-запроса.
    if (method() === "GET" && $GlobalUser['admin'] >= 2) {
        if (key_exists('cp', $_GET)) {
            $cp = intval($_GET['cp']);
        } else {
            $cp = 0;
        }
        if (key_exists('action', $_GET) && $cp) {
            $action = $_GET['action'];
        } else {
            $action = "";
        }
        $now = time();
        if ($action === "create_moon") {
            $planet = GetPlanet($cp);
            if ($planet['type'] > 0 && $planet['type'] < 10000) {
                if (PlanetHasMoon($cp) == 0) {
                    CreatePlanet($planet['g'], $planet['s'], $planet['p'], $planet['owner_id'], 0, 1, 20);
                }
            }
        } else {
            if ($action === "create_debris") {
                $planet = GetPlanet($cp);
                if ($planet['type'] > 0 && $planet['type'] < 10000) {
                    if (HasDebris($planet['g'], $planet['s'], $planet['p']) == 0) {
                        CreateDebris($planet['g'], $planet['s'], $planet['p'], $planet['owner_id']);
                    }
                }
            } else {
                if ($action === "cooldown_gates") {
                    $planet = GetPlanet($cp);
                    if ($planet['type'] == 0) {
                        $query = "UPDATE " . $db_prefix . "planets SET gate_until=0 WHERE planet_id=" . $planet['planet_id'];
                        dbquery($query);
                    }
                } else {
                    if ($action === "warmup_gates") {
                        $planet = GetPlanet($cp);
                        if ($planet['type'] == 0) {
                            $query = "UPDATE " . $db_prefix . "planets SET gate_until=" . ($now + 59 * 60 + 59) . " WHERE planet_id=" . $planet['planet_id'];
                            dbquery($query);
                        }
                    } else {
                        if ($action === "recalc_fields") {
                            RecalcFields($cp);
                        } else {
                            if ($action === "random_diam") {
                                $planet = GetPlanet($cp);
                                if (GetPlanetType($planet) == 1) {
                                    $p = $planet['p'];
                                    if ($p <= 3) {
                                        $diam = mt_rand(50, 120) * 72;
                                    } else {
                                        if ($p >= 4 && $p <= 6) {
                                            $diam = mt_rand(50, 150) * 120;
                                        } else {
                                            if ($p >= 7 && $p <= 9) {
                                                $diam = mt_rand(50, 120) * 120;
                                            } else {
                                                if ($p >= 10 && $p <= 12) {
                                                    $diam = mt_rand(50, 120) * 96;
                                                } else {
                                                    if ($p >= 13 && $p <= 15) {
                                                        $diam = mt_rand(50, 150) * 96;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    $query = "UPDATE " . $db_prefix . "planets SET diameter={$diam} WHERE planet_id=" . $planet['planet_id'];
                                    dbquery($query);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (key_exists("cp", $_GET)) {
        // Информация о планете.
        $planet = GetPlanet(intval($_GET['cp']));
        $user = LoadUser($planet['owner_id']);
        $moon_id = PlanetHasMoon($planet['planet_id']);
        $debris_id = HasDebris($planet['g'], $planet['s'], $planet['p']);
        $now = time();
        // Парсер шпионских докладов.
        ?>
<script>

function php_str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;
    var j = 0;
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || '' : r[0]), ++j in f){};
        }
    }
    return sa ? s : s[0];
}

function spio ()
{
    global $GlobalUni;

    //
    // Перечислить все технологии для всех языков, а также ресурсы
    //

    var TechNames = {
<?php 
        foreach ($Languages as $lang => $langname) {
            loca_add("common", $lang);
            loca_add("technames", $lang);
        }
        $old_lang = $loca_lang;
        foreach ($Languages as $lang => $langname) {
            $loca_lang = $lang;
            foreach ($buildmap as $i => $gid) {
                echo "\"" . loca("NAME_{$gid}") . "\": {$gid}, ";
            }
            foreach ($fleetmap as $i => $gid) {
                echo "\"" . loca("NAME_{$gid}") . "\": {$gid}, ";
            }
            foreach ($defmap as $i => $gid) {
                echo "\"" . loca("NAME_{$gid}") . "\": {$gid}, ";
            }
        }
        ?>
    };
    var ResNames = {
<?php 
        foreach ($Languages as $lang => $langname) {
            $loca_lang = $lang;
            echo "\"" . loca("METAL") . "\": 'm', ";
            echo "\"" . loca("CRYSTAL") . "\": 'k', ";
            echo "\"" . loca("DEUTERIUM") . "\": 'd', ";
        }
        $loca_lang = $old_lang;
        ?>
    };

    var text = document.getElementById ("spiotext" ).value;
    text = php_str_replace (".", "", text);
    text = php_str_replace (":", "", text);

    for ( var name in TechNames ) {
        var id = TechNames[name];
        pos = text.indexOf ( name );
        if ( pos > 0 ) {
            obj = text.substr ( pos );
            found = obj.match ("("+name+"[\\s]+)([0-9]{1,})");
            document.getElementById ( "obj" + id ) . value = parseInt(found[2]);
        }
    }

    for ( var name in ResNames ) {
        var id = ResNames[name];
        pos = text.indexOf ( name );
        if ( pos > 0 ) {
            obj = text.substr ( pos );
            found = obj.match ("("+name+"[\\s]+)([0-9]{1,})");
            document.getElementById ( "obj" + id ) . value = parseInt(found[2]);
        }
    }

}

function reset ()
{
    var ids = [
<?php 
        foreach ($buildmap as $i => $gid) {
            echo "{$gid}, ";
        }
        foreach ($fleetmap as $i => $gid) {
            echo "{$gid}, ";
        }
        foreach ($defmap as $i => $gid) {
            echo "{$gid}, ";
        }
        ?>
    ];

    for ( var i in ids ) {
        document.getElementById ( "obj" + ids[i] ) . value = 0;
    }
}
</script>

<?php 
        AdminPanel();
        echo "<table>\n";
        echo "<form action=\"index.php?page=admin&session={$session}&mode=Planets&action=update&cp=" . $planet['planet_id'] . "\" method=\"POST\" >\n";
        echo "<tr><td class=c colspan=2>Планета \"" . $planet['name'] . "\" (<a href=\"index.php?page=admin&session={$session}&mode=Users&player_id=" . $user['player_id'] . "\">" . $user['oname'] . "</a>)</td>\n";
        echo "       <td class=c >Постройки</td> <td class=c >Флот</td> <td class=c >Оборона</td> </tr>\n";
        echo "<tr><th><img src=\"" . GetPlanetImage(UserSkin(), $planet) . "\"> <br>Тип: " . $planet['type'];
        $pp = PlanetPrice($planet);
        echo "<br>Стоимость : " . nicenum($pp['points'] / 1000);
        echo "<br>Постройки : " . nicenum(($pp['points'] - ($pp['fleet_pts'] + $pp['defense_pts'])) / 1000);
        echo "<br>Флот : " . nicenum($pp['fleet_pts'] / 1000);
        echo "<br>Оборона : " . nicenum($pp['defense_pts'] / 1000);
        if ($planet['type'] == 10000) {
            echo "<br>М: " . nicenum($planet['m']) . "<br>К: " . nicenum($planet['k']) . "<br>";
        }
        echo "</th><th>";
        if ($planet['type'] > 0 && $planet['type'] < 10000) {
            if ($moon_id) {
                $moon = GetPlanet($moon_id);
                echo "<a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $moon['planet_id'] . "\"><img src=\"" . GetPlanetSmallImage(UserSkin(), $moon) . "\"><br>\n";
                echo $moon['name'] . "</a>";
            } else {
                echo "<a href=\"index.php?page=admin&session={$session}&mode=Planets&action=create_moon&cp=" . $planet['planet_id'] . "\" >Создать луну</a>\n";
            }
            echo "<br/><br/>\n";
            if ($debris_id) {
                $debris = GetPlanet($debris_id);
                echo "<a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $debris['planet_id'] . "\"><img src=\"" . UserSkin() . "planeten/debris.jpg\"><br>\n";
                echo $debris['name'] . "</a>";
                echo "<br>М: " . nicenum($debris['m']) . "<br>К: " . nicenum($debris['k']) . "<br>";
            } else {
                echo "<a href=\"index.php?page=admin&session={$session}&mode=Planets&action=create_debris&cp=" . $planet['planet_id'] . "\" >Создать поле обломков</a>\n";
            }
        } else {
            $parent = LoadPlanet($planet['g'], $planet['s'], $planet['p'], 1);
            echo "<a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $parent['planet_id'] . "\"><img src=\"" . GetPlanetSmallImage(UserSkin(), $parent) . "\"><br>\n";
            echo $parent['name'] . "</a>";
        }
        ?>
        <br><br><textarea rows=10 cols=10 id="spiotext"></textarea>
        <a href="#" onclick="javascript:spio();">Разобрать данные доклада</a> <br>
        <a href="#" onclick="javascript:reset();">Сбросить</a>
<?php 
        echo "</th>";
        echo "<th valign=top><table>\n";
        foreach ($buildmap as $i => $gid) {
            echo "<tr><th>" . loca("NAME_{$gid}");
            if ($gid == 43 && $planet['type'] == 0) {
                // управление воротами.
                if ($now >= $planet["gate_until"]) {
                    // ворота готовы
                    echo " <a href=\"index.php?page=admin&session={$session}&mode=Planets&action=warmup_gates&cp=" . $planet['planet_id'] . "\" >нагреть</a>";
                } else {
                    // ворота НЕ готовы
                    $delta = $planet["gate_until"] - $now;
                    echo " " . date('i\\m s\\s', $delta) . " <a href=\"index.php?page=admin&session={$session}&mode=Planets&action=cooldown_gates&cp=" . $planet['planet_id'] . "\">остудить</a>";
                }
            }
            echo "</th><th><nobr><input id=\"obj{$gid}\" type=\"text\" size=3 name=\"b{$gid}\" value=\"" . $planet["b{$gid}"] . "\" />";
            // управление шахтами и выработкой энергии.
            if ($gid == 1 && $planet['type'] != 0) {
                echo "<select name='mprod'>\n";
                for ($prc = 0; $prc <= 1; $prc += 0.1) {
                    echo "<option value='{$prc}' ";
                    if ($planet["mprod"] == $prc . "") {
                        echo " selected";
                    }
                    echo ">" . $prc * 100 . "</option>\n";
                }
                echo "</select>\n";
            }
            if ($gid == 2 && $planet['type'] != 0) {
                echo "<select name='kprod'>\n";
                for ($prc = 0; $prc <= 1; $prc += 0.1) {
                    echo "<option value='{$prc}' ";
                    if ($planet["kprod"] == $prc . "") {
                        echo " selected";
                    }
                    echo ">" . $prc * 100 . "</option>\n";
                }
                echo "</select>\n";
            }
            if ($gid == 3 && $planet['type'] != 0) {
                echo "<select name='dprod'>\n";
                for ($prc = 0; $prc <= 1; $prc += 0.1) {
                    echo "<option value='{$prc}' ";
                    if ($planet["dprod"] == $prc . "") {
                        echo " selected";
                    }
                    echo ">" . $prc * 100 . "</option>\n";
                }
                echo "</select>\n";
            }
            if ($gid == 4 && $planet['type'] != 0) {
                echo "<select name='sprod'>\n";
                for ($prc = 0; $prc <= 1; $prc += 0.1) {
                    echo "<option value='{$prc}' ";
                    if ($planet["sprod"] == $prc . "") {
                        echo " selected";
                    }
                    echo ">" . $prc * 100 . "</option>\n";
                }
                echo "</select>\n";
            }
            if ($gid == 12 && $planet['type'] != 0) {
                echo "<select name='fprod'>\n";
                for ($prc = 0; $prc <= 1; $prc += 0.1) {
                    echo "<option value='{$prc}' ";
                    if ($planet["fprod"] == $prc . "") {
                        echo " selected";
                    }
                    echo ">" . $prc * 100 . "</option>\n";
                }
                echo "</select>\n";
            }
            echo "</nobr></th></tr>\n";
        }
        echo "</table></th>\n";
        echo "<th valign=top><table>\n";
        foreach ($fleetmap as $i => $gid) {
            echo "<tr><th>" . loca("NAME_{$gid}") . "</th><th><nobr><input id=\"obj{$gid}\" type=\"text\" size=6 name=\"f{$gid}\" value=\"" . $planet["f{$gid}"] . "\" />";
            if ($gid == 212 && $planet['type'] != 0) {
                echo "<select name='ssprod'>\n";
                for ($prc = 0; $prc <= 1; $prc += 0.1) {
                    echo "<option value='{$prc}' ";
                    if ($planet["ssprod"] == $prc . "") {
                        echo " selected";
                    }
                    echo ">" . $prc * 100 . "</option>\n";
                }
                echo "</select>\n";
            }
            echo "</nobr></th></tr>\n";
        }
        echo "</table></th>\n";
        echo "<th valign=top><table>\n";
        foreach ($defmap as $i => $gid) {
            echo "<tr><th>" . loca("NAME_{$gid}") . "</th><th><input id=\"obj{$gid}\" type=\"text\" size=6 name=\"d{$gid}\" value=\"" . $planet["d{$gid}"] . "\" /></th></tr>\n";
        }
        echo "</table></th>\n";
        echo "</tr>\n";
        echo "<tr><th>Дата создания</th><th>" . date("Y-m-d H:i:s", $planet['date']) . "</th> <td colspan=10 class=c>Очередь построек</td></tr>";
        echo "<tr><th>Дата удаления</th><th>" . date("Y-m-d H:i:s", $planet['remove']) . "</th> <th colspan=3 rowspan=12 valign=top style='text-align: left;'> ";
        $query = "SELECT * FROM " . $db_prefix . "buildqueue WHERE planet_id = " . $planet['planet_id'] . " ORDER BY list_id ASC";
        $result = dbquery($query);
        $anz = dbrows($result);
        echo "<table>";
        $bxx = 1;
        $duration = 0;
        while ($row = dbarray($result)) {
            echo "<tr><td> <table><tr><th><div id='bxx" . $bxx . "' title='" . ($row['end'] - $row['start'] - ($now - ($row['start'] + $duration))) . "' star='" . $duration . "'></th>";
            echo "<tr><th>" . date("d.m.Y H:i:s", $row['end'] + $duration) . "</th></tr></table></td>";
            echo "<td><img width='32px' src='" . UserSkin() . "gebaeude/" . $row['tech_id'] . ".gif'></td>";
            echo "<td><b>" . loca("NAME_" . $row['tech_id']) . "</b><br>уровень " . $row['level'] . "</td></tr>";
            $bxx++;
            $duration += $row['end'] - $row['start'];
        }
        echo "</table>";
        echo "<script language=javascript>anz={$anz};t();</script>\n";
        ?>

<?php 
        echo "</th> </tr>";
        echo "<tr><th>Последняя активность</th><th>" . date("Y-m-d H:i:s", $planet['lastakt']) . "</th>  \n";
        echo "<input type=\"hidden\" name=\"type\" value=\"" . $planet['type'] . "\" >\n";
        echo "</th> </tr>\n";
        echo "<tr><th>Последнее обновление</th><th>" . date("Y-m-d H:i:s", $planet['lastpeek']) . "</th></tr>\n";
        echo "<tr><th>Диаметр <br><a href=\"index.php?page=admin&session={$session}&mode=Planets&action=random_diam&cp=" . $planet['planet_id'] . "\" >новый диаметр</a>  </th><th><input size=5 type=\"text\" name=\"diameter\" value=\"" . $planet['diameter'] . "\" /> км (" . $planet['fields'] . " из " . $planet['maxfields'] . " полей) ";
        echo "<a href=\"index.php?page=admin&session={$session}&mode=Planets&action=recalc_fields&cp=" . $planet['planet_id'] . "\" >пересчитать поля</a> ";
        echo "</th></tr>\n";
        echo "<tr><th>Температура</th><th>от <input size=5 type=\"text\" name=\"temp\" value=\"" . $planet['temp'] . "\" />°C до " . ($planet['temp'] + 40) . "°C</th></tr>\n";
        echo "<tr><th>Координаты</th><th>[<input type=\"text\" name=\"g\" value=\"" . $planet['g'] . "\" size=1 />:<input type=\"text\" name=\"s\" value=\"" . $planet['s'] . "\" size=2 />:<input type=\"text\" name=\"p\" value=\"" . $planet['p'] . "\" size=1 />]</th></tr>\n";
        echo "<tr><td class=c colspan=2>Ресурсы</td></tr>\n";
        echo "<tr><th>Металл</th><th><input id=\"objm\" type=\"text\" name=\"m\" value=\"" . ceil($planet['m']) . "\" /></th></tr>\n";
        echo "<tr><th>Кристалл</th><th><input id=\"objk\" type=\"text\" name=\"k\" value=\"" . ceil($planet['k']) . "\" /></th></tr>\n";
        echo "<tr><th>Дейтерий</th><th><input id=\"objd\" type=\"text\" name=\"d\" value=\"" . ceil($planet['d']) . "\" /></th></tr>\n";
        echo "<tr><th>Энергия</th><th>" . $planet['e'] . " / " . $planet['emax'] . "</th></tr>\n";
        echo "<tr><th>Коэффициент производства</th><th>" . $planet['factor'] . "</th></tr>\n";
        echo "<tr><th colspan=8><input type=\"submit\" value=\"Сохранить\" />  <input type=\"submit\" name=\"delete_planet\" value=\"Удалить\" /> </th></tr>\n";
        echo "</form>\n";
        echo "</table>\n";
    } else {
        $query = "SELECT * FROM " . $db_prefix . "planets ORDER BY date DESC LIMIT 25";
        $result = dbquery($query);
        AdminPanel();
        echo "    </th> \n";
        echo "   </tr> \n";
        echo "</table> \n";
        echo "Новые планеты:<br>\n";
        echo "<table>\n";
        echo "<tr><td class=c>Дата создания</td><td class=c>Координаты</td><td class=c>Планета</td><td class=c>Игрок</td></tr>\n";
        $rows = dbrows($result);
        while ($rows--) {
            $planet = dbarray($result);
            $user = LoadUser($planet['owner_id']);
            echo "<tr><th>" . date("Y-m-d H:i:s", $planet['date']) . "</th><th>" . AdminPlanetCoord($planet) . "</th>";
            echo "<th><a href=\"index.php?page=admin&session={$session}&mode=Planets&cp=" . $planet['planet_id'] . "\">" . $planet['name'] . "</a></th>";
            echo "<th>" . AdminUserName($user) . "</th></tr>\n";
        }
        echo "</table>\n";
        ?>
       </th> 
       </tr> 
    </table>
    Искать:<br>
 <form action="index.php?page=admin&session=<?php 
        echo $session;
        ?>
&mode=Planets&action=search" method="post">
 <table>
  <tr>
   <th>
    <select name="type">
     <option value="playername">Имя игрока</option>
     <option value="planetname" >Имя планеты</option>
     <option value="allytag" >Аббревиатура альянса</option>
    </select>
    &nbsp;&nbsp;
    <input type="text" name="searchtext" value=""/>
    &nbsp;&nbsp;
    <input type="submit" value="Искать" />
   </th>
  </tr>
 </table>
 </form>
<?php 
        if ($SearchResult !== "") {
            ?>
       </th> 
       </tr> 
    </table>
    Результаты поиска:<br>
    <?php 
            echo $SearchResult;
        }
    }
}
Exemplo n.º 5
0
        $msgs = loca("OVERVIEW_MSGS");
    } else {
        $msgs = "";
    }
    echo "<tr><th colspan=\"4\"><a href=\"index.php?page=messages&dsp=1&session={$session}\">  " . va(loca("OVERVIEW_NEWMSG"), $num, $msgs) . "   </th></tr>\n";
}
// Время сервера и список событий.
echo "<tr><th>    " . loca("OVERVIEW_TIME") . "   </th> <th colspan=3>" . date("D M j G:i:s", $now) . "</th></tr>\n";
echo "<tr><td colspan='4' class='c'>  " . loca("OVERVIEW_EVENTS") . "   </td> </tr>\n\n";
EventList();
// Показать, если у планеты есть луна.
$moonid = PlanetHasMoon($aktplanet['planet_id']);
if ($moonid) {
    $moonobj = GetPlanet($moonid);
    echo "<th>    " . $moonobj['name'] . "     <br>\n";
    echo "<a href=\"index.php?page=overview&session={$session}&cp=" . $moonid . "\"><img src=\"" . GetPlanetSmallImage(UserSkin(), $moonobj) . "\" width=\"50\" alt=\"" . loca("MOON") . "\" height=\"50\" ></a>\n";
    echo "</th>\n";
} else {
    echo "<th>\n</th>\n";
}
// Показать картинку планеты.
echo "<th colspan=\"2\">\n<img src=\"" . GetPlanetImage(UserSkin(), $aktplanet) . "\" width=\"200\" height=\"200\">\n";
$result = GetBuildQueue($aktplanet['planet_id']);
$cnt = dbrows($result);
if ($cnt > 0) {
    $queue = dbarray($result);
    $left = $queue['end'] - time();
    echo "<br><center>" . loca("NAME_" . $queue['tech_id']) . " ";
    if ($queue['destroy']) {
        $queue['level']++;
        echo "Снести";
Exemplo n.º 6
0
function PlanetsDropList($page)
{
    global $GlobalUser;
    $sess = $GlobalUser['session'];
    $aktplanet = GetPlanet($GlobalUser['aktplanet']);
    $result = EnumPlanets($GlobalUser['player_id']);
    echo "<td class='header' style='width:5;' >\n";
    echo "<table class='header'>\n";
    echo "<tr class='header'>\n";
    echo "<td class='header'><img src='" . GetPlanetSmallImage(UserSkin(), $aktplanet) . "' width='50' height='50'></td>\n";
    echo "<td class='header'>\n";
    echo "<table class='header'>\n";
    echo "<select size='1' onchange='haha(this)'>\n";
    $plist = array();
    $num = dbrows($result);
    for ($n = 0; $n < $num; $n++) {
        $plist[] = dbarray($result);
    }
    if (key_exists('gid', $_GET)) {
        $gid = "&gid=" . $_GET['gid'];
    }
    if (key_exists('tid', $_GET)) {
        $tid = "&tid=" . $_GET['tid'];
    }
    if (key_exists('mode', $_GET)) {
        $mode = "&mode=" . $_GET['mode'];
    }
    for ($n = 0; $n < $num; $n++) {
        $planet = $plist[$n];
        if ($planet['type'] == 0) {
            continue;
        }
        $cp = $planet['planet_id'];
        $sel = "";
        if ($cp == $GlobalUser['aktplanet']) {
            $sel = "selected";
        }
        $g = $planet['g'];
        $s = $planet['s'];
        $p = $planet['p'];
        $name = $planet['name'];
        echo "    <option value='index.php?page=" . $page . "&session={$sess}&cp={$cp}{$gid}{$tid}{$mode}' {$sel}>{$name}  <a href='index.php?page=galaxy&galaxy={$g}&system={$s}&position={$p}&session={$sess}&cp={$cp}{$gid}{$tid}{$mode}' >[{$g}:{$s}:{$p}]</a></option>\n";
        $moon = DropListHasMoon($plist, $planet);
        if ($moon) {
            $planet = $moon;
            $cp = $planet['planet_id'];
            $sel = "";
            if ($cp == $GlobalUser['aktplanet']) {
                $sel = "selected";
            }
            $g = $planet['g'];
            $s = $planet['s'];
            $p = $planet['p'];
            $name = $planet['name'];
            echo "    <option value='index.php?page=" . $page . "&session={$sess}&cp={$cp}{$gid}{$tid}{$mode}' {$sel}>{$name}  <a href='index.php?page=galaxy&galaxy={$g}&system={$s}&position={$p}&session={$sess}&cp={$cp}{$gid}{$tid}{$mode}' >[{$g}:{$s}:{$p}]</a></option>\n";
        }
    }
    echo "</select></table></td></tr></table></td>\n\n";
}