Example #1
0
function SpyArrive($queue, $fleet_obj, $fleet, $origin, $target)
{
    global $UnitParam;
    $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);
    $buildmap = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 41, 42, 43, 44);
    $resmap = array(106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 199);
    $now = $queue['end'];
    $origin_user = LoadUser($origin['owner_id']);
    $target_user = LoadUser($target['owner_id']);
    $origin_ships = $target_ships = $origin_cost = 0;
    foreach ($fleetmap as $i => $gid) {
        $origin_ships += $fleet_obj["ship{$gid}"];
        $origin_cost += $fleet_obj["ship{$gid}"] * $UnitParam[$gid][0];
        $target_ships += $target["f{$gid}"];
    }
    $origin_prem = PremiumStatus($origin_user);
    $target_prem = PremiumStatus($target_user);
    $origin_tech = $origin_user['r106'];
    if ($origin_prem['technocrat']) {
        $origin_tech += 2;
    }
    $target_tech = $target_user['r106'];
    if ($target_prem['technocrat']) {
        $target_tech += 2;
    }
    loca_add("technames", $origin_user['lang']);
    /*
        $diff = abs ( $target_tech - $origin_tech );
        if ( $target_tech > $origin_tech ) {
            $level = $fleet_obj['ship210'] - pow ( $diff, 2 );
            $counter_max = min (100, floor((($target_ships / 4) * $origin_ships) * pow ( 2, $diff )));
        }
        else {
            $level = $fleet_obj['ship210'] + pow ( $diff, 2 );
            $counter_max = min (100, floor((($target_ships / 4) * $origin_ships) / pow ( 2, $diff )));
        }
        $counter = mt_rand ( 0, $counter_max );
    */
    $level = $origin_tech - $target_tech;
    $level = $level * abs($level) - 1 + $origin_ships;
    $cost = $origin_cost / 1000 / 400;
    $c = sqrt(pow(2, $origin_ships - ($level + 1))) * ($cost * sqrt($target_ships) * 5);
    if ($c > 2) {
        $c = 2;
    }
    $c = rand(0, $c * 100) / 100;
    if ($c < 0) {
        $c = 0;
    }
    if ($c > 1) {
        $c = 1;
    }
    $counter = $c * 100;
    $subj = "\n<span class=\"espionagereport\">\n" . "Разведданные с " . $target['name'] . "\n" . "<a onclick=\"showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . ");\" href=\"#\">[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a>\n";
    $report = "";
    // Шапка
    $report .= "<table width=400><tr><td class=c colspan=4>Сырьё на " . $target['name'] . " <a href=# onclick=showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "); >[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a> (Игрок \\'" . $target_user['oname'] . "\\')<br /> на " . date("m-d H:i:s", $now) . "</td></tr>\n";
    $report .= "</div></font></TD></TR><tr><td>металла:</td><td>" . nicenum($target['m']) . "</td>\n";
    $report .= "<td>кристалла:</td><td>" . nicenum($target['k']) . "</td></tr>\n";
    $report .= "<tr><td>дейтерия:</td><td>" . nicenum($target['d']) . "</td>\n";
    $report .= "<td>энергии:</td><td>" . nicenum($target['emax']) . "</td></tr>\n";
    $report .= "</table>\n";
    // Активность
    $report .= "<table width=400><tr><td class=c colspan=4>     </td></tr>\n";
    $report .= "<TR><TD colspan=4><div onmouseover=\\'return overlib(\"&lt;font color=white&gt;Активность означает, что сканируемый игрок был активен на своей планете, либо на него был произведён вылет флота другого игрока.&lt;/font&gt;\", STICKY, MOUSEOFF, DELAY, 750, CENTER, WIDTH, 100, OFFSETX, -130, OFFSETY, -10);\\' onmouseout=\\'return nd();\\'></TD></TR></table>\n";
    // Флот на удержании
    $result = GetHoldingFleets($target['planet_id']);
    $holding_fleet = array();
    while ($fobj = dbarray($result)) {
        foreach ($fleetmap as $i => $gid) {
            $holding_fleet[$gid] += $fobj["ship{$gid}"];
        }
    }
    // Флот
    if ($level > 0) {
        $report .= "<table width=400><tr><td class=c colspan=4>Флоты     </td></tr>\n";
        $count = 0;
        foreach ($fleetmap as $i => $gid) {
            $amount = $target["f{$gid}"] + $holding_fleet[$gid];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    // Оборона
    if ($level > 1) {
        $report .= "<table width=400><tr><td class=c colspan=4>Оборона     </td></tr>\n";
        $count = 0;
        foreach ($defmap as $i => $gid) {
            $amount = $target["d{$gid}"];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    // Постройки
    if ($level > 3) {
        $report .= "<table width=400><tr><td class=c colspan=4>Постройки     </td></tr>\n";
        $count = 0;
        foreach ($buildmap as $i => $gid) {
            $amount = $target["b{$gid}"];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    // Исследования
    if ($level > 5) {
        $report .= "<table width=400><tr><td class=c colspan=4>Исследования     </td></tr>\n";
        $count = 0;
        foreach ($resmap as $i => $gid) {
            $amount = $target_user["r{$gid}"];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    $report .= "<center> Шанс на защиту от шпионажа:" . floor($counter) . "%</center>\n";
    $report .= "<center><a href=\\'#\\' onclick=\\'showFleetMenu(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "," . GetPlanetType($target) . ",1);\\'>Атака</a></center>\n";
    SendMessage($fleet_obj['owner_id'], "Командование флотом", $subj, $report, 1, $queue['end']);
    // Отправить сообщение чужому игроку о шпионаже.
    $text = "\nЧужой флот с планеты " . $origin['name'] . "\n" . "<a onclick=\"showGalaxy(" . $origin['g'] . "," . $origin['s'] . "," . $origin['p'] . ");\" href=\"#\">[" . $origin['g'] . ":" . $origin['s'] . ":" . $origin['p'] . "]</a>\n" . "был обнаружен вблизи от планеты " . $target['name'] . "\n" . "<a onclick=\"showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . ");\" href=\"#\">[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a>\n" . ". Шанс на защиту от шпионажа: {$counter} %\n" . "</td>\n";
    SendMessage($target['owner_id'], "Наблюдение", "Шпионаж", $text, 5, $queue['end']);
    // Обновить активность на чужой планете.
    UpdatePlanetActivity($fleet_obj['target_planet'], $queue['end']);
    // Вернуть флот.
    if (mt_rand(0, 100) < $counter) {
        StartBattle($fleet_obj['fleet_id'], $fleet_obj['target_planet'], $queue['end']);
    } else {
        DispatchFleet($fleet, $origin, $target, 106, $fleet_obj['flight_time'], $fleet_obj['m'], $fleet_obj['k'], $fleet_obj['d'], $fleet_obj['fuel'] / 2, $queue['end']);
    }
}
        $union_count++;
    }
}
if ($union_count > 0) {
    echo "<input type=\"hidden\" name=\"union2\" value=\"0\" >";
    $now = time();
    foreach ($unions as $i => $union) {
        $fleet_obj = LoadFleet($union['fleet_id']);
        if ($fleet_obj['union_id'] != $union['union_id']) {
            continue;
        }
        $queue = GetFleetQueue($union['fleet_id']);
        $target = GetPlanet($fleet_obj['target_planet']);
        echo "  <tr height=\"20\">";
        echo "<th><div id='bxx" . ($i + 1) . "' title='" . max($queue['end'] - $now, 0) . "'star='" . $queue['end'] . "'></div></th>";
        echo "<th><a href=\"javascript:setTarget(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "," . GetPlanetType($target) . "); setUnion(" . $union['union_id'] . "); shortInfo()\">";
        echo $union['name'] . " [" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a></th></tr>\n";
    }
    echo "<script language=javascript>anz=" . $union_count . ";t();</script>\n\n";
} else {
    echo " <tr height=\"20\"><th colspan=\"2\">-</th></tr>\n";
}
?>

<tr height="20">
 <th colspan="2">
  <input type="submit" value="Дальше" />
 </th>
</tr>

</form>
Example #3
0
function ShowImperiumPage($CurrentUser)
{
    global $lang, $resource, $reslist, $dpath;
    $lang['imperium_vision'] = 'Visi&oacute;n general del Imperio';
    $lang['name'] = 'Planeta';
    $lang['coordinates'] = 'Coordenadas';
    $lang['fields'] = 'Campos';
    $lang['resources'] = 'Recursos';
    $lang['buildings'] = 'Edificios';
    $lang['investigation'] = 'Investigaciones';
    $lang['ships'] = 'Flotas';
    $lang['defense'] = 'Defensas';
    $parse = $lang;
    if (isset($_GET['planet_type'])) {
        if ($_GET['planet_type'] == 1) {
            $planettype = " AND `planet_type` = '1'";
            $parse['select1'] = ' selected';
        } elseif ($_GET['planet_type'] == 3) {
            $planettype = "AND `planet_type` = '3'";
            $parse['select3'] = ' selected';
        } else {
            $planettype = '';
            $parse['select0'] = ' selected';
        }
    } else {
        $planettype = '';
        $parse['select0'] = ' selected';
    }
    $planetsrow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentUser['id'] . "'{$planettype};", 'planets');
    $planet = array();
    while ($p = mysql_fetch_array($planetsrow)) {
        PlanetResourceUpdate($CurrentUser, $p, time());
        $planet['sum'] = sumar_array($planet['sum'], $p);
        $planet[] = $p;
    }
    uksort($planet, 'planet_empire_sort');
    $parse['mount'] = count($planet) + 3;
    // primera tabla, con las imagenes y coordenadas
    $row = gettemplate('empire/imperium_row');
    $row2 = gettemplate('empire/imperium_row2');
    foreach ($planet as $ID => $p) {
        if ($ID !== 'sum') {
            UpdatePlanetBatimentQueueList($p, $CurrentUser);
            $AllPlanets = '';
            if ($p['b_building'] != 0) {
                $BuildQueue = $p['b_building_id'];
                $QueueArray = explode(";", $BuildQueue);
                $CurrentBuild = explode(",", $QueueArray[0]);
                $BuildElement = $CurrentBuild[0];
                $BuildLevel = $CurrentBuild[1];
                $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                $AllPlanets .= $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                $AllPlanets .= "<br/><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
            } else {
                CheckPlanetUsedFields($p);
                $AllPlanets .= "<a href='game.php?page=buildings'>Libre</a>";
            }
            // {file_images}
            $parse['build'] .= '<th width="75">' . $AllPlanets . '</th>';
            $data['text'] = '<a href="game.php?page=overview&cp=' . $p['id'] . '&re=0"><img src="' . $dpath . 'planeten/' . $p['image'] . '.jpg" border="0" height="75" width="75"></a><br/>';
            $parse['file_images'] .= parsetemplate($row, $data);
            // {file_names}
            $data['text'] = '<a href="game.php?page=overview&cp=' . $p['id'] . '&re=0">' . $p['name'] . ' </a>';
            if ($p['planet_type'] == 3) {
                $data['text'] = '<a href="game.php?page=overview&cp=' . $p['id'] . '&re=0">' . $p['name'] . ' (Luna)</a>';
            }
            $parse['file_names'] .= parsetemplate($row2, $data);
            // {file_type}
            $data['text'] = GetPlanetType($p);
            $parse['file_type'] .= parsetemplate($row2, $data);
            // {file_coordinates}
            $data['text'] = "[<a href=\"game.php?page=galaxy&mode=3&galaxy={$p['galaxy']}&system={$p['system']}\">{$p['galaxy']}:{$p['system']}:{$p['planet']}</a>]";
            $parse['file_coordinates'] .= parsetemplate($row2, $data);
            // {file_fields}
            $data['text'] = $p['field_current'] . '/' . CalculateMaxPlanetFields($p) . '<br/>' . GetPercentBar($p['field_current'], CalculateMaxPlanetFields($p));
            $parse['file_fields'] .= parsetemplate($row2, $data);
            // {file_metal}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['metal']) . '</a><br/>' . GetPercentBar($p['metal'], $p['metal_max'] * MAX_OVERFLOW);
            $parse['file_metal'] .= parsetemplate($row2, $data);
            // {file_crystal}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['crystal']) . '</a><br/>' . GetPercentBar($p['crystal'], $p['crystal_max'] * MAX_OVERFLOW);
            $parse['file_crystal'] .= parsetemplate($row2, $data);
            // {file_deuterium}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['deuterium']) . '</a><br/>' . GetPercentBar($p['deuterium'], $p['deuterium_max'] * MAX_OVERFLOW);
            $parse['file_deuterium'] .= parsetemplate($row2, $data);
            // {file_hidrogeno}
            $data['text'] = '<a href="game.php?page=resources&cp=' . $p['id'] . '&re=0&planettype=' . $p['planet_type'] . '">' . pretty_number($p['tritium']) . '</a><br/>' . GetPercentBar($p['tritium'], $p['tritium_max'] * MAX_OVERFLOW);
            $parse['file_tritium'] .= parsetemplate($row2, $data);
            // {file_energy}
            $data['text'] = pretty_number($p['energy_max'] - $p['energy_used']) . ' / ' . pretty_number($p['energy_max']) . '<br/>' . GetPercentBar($p['energy_max'], $p['energy_max'] - $p['energy_used']);
            $parse['file_energy'] .= parsetemplate($row2, $data);
            $Queue = ShowBuildingsPage::ShowBuildingQueue($p, $CurrentUser);
            foreach ($resource as $i => $res) {
                if (in_array($i, $reslist['build'])) {
                    if ($Queue['buildingarray'][$i] > $p[$resource[$i]]) {
                        $p[$resource[$i]] = $p[$resource[$i]] . " <span style='color:lime;'>+" . ($Queue['buildingarray'][$i] - $p[$resource[$i]]) . "</span>";
                    }
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">" . pretty_number($p[$resource[$i]]) . "</a>";
                    if (IsElementBuyable($CurrentUser, $p, $i, true, false) and IsTechnologieAccessible($CurrentUser, $p, $i) and $p["field_current"] < CalculateMaxPlanetFields($p)) {
                        $data['text'] .= " <a href=\"game.php?page=buildings&cmd=insert&cp={$p['id']}&re=0&building=" . $i . "\"><font color=lime>+</font></a>";
                    }
                } elseif (in_array($i, $reslist['tech'])) {
                    $data['text'] = $CurrentUser[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&mode=research&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">{$CurrentUser[$resource[$i]]}</a>";
                    if (IsElementBuyable($CurrentUser, $p, $i, true, false) and IsTechnologieAccessible($CurrentUser, $p, $i) and $CurrentUser["b_tech_planet"] == 0) {
                        $data['text'] .= " <a href=\"game.php?page=buildings&mode=research&cmd=search&cp={$p['id']}&re=0&tech=" . $i . "\"><font color=lime>+</font></a>";
                    }
                } elseif (in_array($i, $reslist['fleet'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&mode=fleet&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">" . pretty_number($p[$resource[$i]]) . "</a>";
                } elseif (in_array($i, $reslist['defense'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : "<a href=\"game.php?page=buildings&mode=defense&cp={$p['id']}&re=0&planettype={$p['planet_type']}\">" . pretty_number($p[$resource[$i]]) . "</a>";
                }
                $r[$i] .= parsetemplate($row2, $data);
            }
        } else {
            $parse['build'] .= '<th width="75">-</th>';
            $data['text'] = '<span style="font-size:48px;font-weight:normal;">&Sigma;</span><br/>';
            $parse['file_images'] .= parsetemplate($row, $data);
            // {file_names}
            $data['text'] = '-';
            $parse['file_names'] .= parsetemplate($row2, $data);
            // {file_type}
            $data['text'] = "-";
            $parse['file_type'] .= parsetemplate($row2, $data);
            // {file_coordinates}
            $data['text'] = "-";
            $parse['file_coordinates'] .= parsetemplate($row2, $data);
            // {file_fields}
            $data['text'] = $p['field_current'] . '/' . CalculateMaxPlanetFields($p) . '<br/>' . GetPercentBar($p['field_current'], CalculateMaxPlanetFields($p));
            $parse['file_fields'] .= parsetemplate($row2, $data);
            // {file_metal}
            $data['text'] = pretty_number($p['metal']) . '<br/>' . GetPercentBar($p['metal'], $p['metal_max'] * MAX_OVERFLOW);
            $parse['file_metal'] .= parsetemplate($row2, $data);
            // {file_crystal}
            $data['text'] = pretty_number($p['crystal']) . '<br/>' . GetPercentBar($p['crystal'], $p['crystal_max'] * MAX_OVERFLOW);
            $parse['file_crystal'] .= parsetemplate($row2, $data);
            // {file_deuterium}
            $data['text'] = pretty_number($p['deuterium']) . '<br/>' . GetPercentBar($p['deuterium'], $p['deuterium_max'] * MAX_OVERFLOW);
            $parse['file_deuterium'] .= parsetemplate($row2, $data);
            // {file_hidrogeno}
            $data['text'] = pretty_number($p['tritium']) . '<br/>' . GetPercentBar($p['tritium'], $p['tritium_max'] * MAX_OVERFLOW);
            $parse['file_tritium'] .= parsetemplate($row2, $data);
            // {file_energy}
            $data['text'] = pretty_number($p['energy_max'] - $p['energy_used']) . ' / ' . pretty_number($p['energy_max']) . '<br/>' . GetPercentBar($p['energy_max'], $p['energy_max'] - $p['energy_used']);
            $parse['file_energy'] .= parsetemplate($row2, $data);
            foreach ($resource as $i => $res) {
                if (in_array($i, $reslist['build'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : pretty_number($p[$resource[$i]]);
                } elseif (in_array($i, $reslist['tech'])) {
                    $data['text'] = $CurrentUser[$resource[$i]] == 0 ? '' : $CurrentUser[$resource[$i]];
                } elseif (in_array($i, $reslist['fleet'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : pretty_number($p[$resource[$i]]);
                } elseif (in_array($i, $reslist['defense'])) {
                    $data['text'] = $p[$resource[$i]] == 0 ? '' : pretty_number($p[$resource[$i]]);
                }
                $r[$i] .= parsetemplate($row2, $data);
            }
        }
    }
    // {building_row}
    foreach ($reslist['build'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['building_row'] .= '<tr><th width="15"><span style="float:center;width: 16px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    // {technology_row}
    foreach ($reslist['tech'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['technology_row'] .= '<tr><th width="15"><span style="float:center;width: 16px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    // {fleet_row}
    foreach ($reslist['fleet'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['fleet_row'] .= '<tr><th width="15"><span style="float:center;width: 16px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    // {defense_row}
    foreach ($reslist['defense'] as $a => $i) {
        $data['text'] = $lang['tech'][$i];
        $parse['defense_row'] .= '<tr><th width="15"><span style="float:center;width: 15px;"><a title="' . $lang['tech'][$i] . '"><img style="border: 1px solid rgb(46, 52, 54);vertical-align: bottom;padding: 0px;width: 15px;height: 15px;" src="' . $dpath . 'gebaeude/' . $i . '.gif"></a></span></th>' . parsetemplate($row2, $data) . $r[$i] . "</tr>";
    }
    $page .= parsetemplate(gettemplate('empire/imperium_table'), $parse);
    display($page, false);
}
function PlanetTo($planet, $mission)
{
    $res = "";
    if (GetPlanetType($planet) == 1) {
        $res .= "планету";
    }
    if ($planet['type'] == 10002 || $planet['type'] == 20000) {
        $res = " <a href=\"javascript:showGalaxy(" . $planet['g'] . "," . $planet['s'] . "," . $planet['p'] . ")\" {$mission}>[" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "]</a>";
    } else {
        $res .= " " . $planet['name'] . " <a href=\"javascript:showGalaxy(" . $planet['g'] . "," . $planet['s'] . "," . $planet['p'] . ")\" {$mission}>[" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "]</a>";
    }
    return $res;
}
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;
        }
    }
}
Example #6
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user, $resource;
    include_once $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . intval($CurrentPlanet['id_owner']) . "' AND `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND  `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type`='3'", 'planets', true);
    if (empty($lunarow)) {
        unset($lunarow);
    }
    CheckPlanetUsedFields($lunarow);
    $parse = $lang;
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    $parse['planet_type_lang'] = GetPlanetType($CurrentPlanet, 1);
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . intval($CurrentUser['current_planet']) . "' LIMIT 1;", "planets");
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
            } elseif (intval($_POST['kolonieloeschen']) == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_owner = '" . intval($user['id']) . "' AND fleet_start_galaxy='" . intval($CurrentPlanet['galaxy']) . "' AND fleet_start_system='" . intval($CurrentPlanet['system']) . "' AND fleet_start_planet='" . intval($CurrentPlanet['planet']) . "'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $harabeyeri = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_target_owner = '" . intval($user['id']) . "' AND fleet_end_galaxy='" . intval($CurrentPlanet['galaxy']) . "' AND fleet_end_system='" . intval($CurrentPlanet['system']) . "' AND fleet_end_planet='" . intval($CurrentPlanet['planet']) . "'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $gezoay = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                if ($kendifilo > 0) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($digerfilo > 0 && $mess < 1 && $gezoay != 2) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                        doquery("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "' WHERE `id` = '" . intval($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                        doquery("UPDATE {{table}} SET `current_planet` = `id_planet` WHERE `id` = '" . intval($CurrentUser['id']) . "' LIMIT 1", "users");
                        doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type` = 3;", 'planets');
                        $WorwHole = CreateWormHole($WormHolePercent, $CurrentPlanet['galaxy'], $CurrentPlanet['system'], $CurrentPlanet['planet']);
                        if ($WorwHole == true) {
                            $Qrydestructionlune = "DELETE FROM {{table}} ";
                            $Qrydestructionlune .= "WHERE ";
                            $Qrydestructionlune .= "`galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND ";
                            $Qrydestructionlune .= "`system` = '" . $CurrentPlanet['system'] . "' AND ";
                            $Qrydestructionlune .= "`planet` = '" . $CurrentPlanet['planet'] . "';";
                            doquery($Qrydestructionlune, 'galaxy');
                        }
                        message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                    } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                        message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                    } else {
                        message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                    }
                }
            }
            return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
            break;
        default:
            if ($CurrentUser['new_message'] != 0) {
                $Have_new_message .= "<tr>";
                if ($CurrentUser['new_message'] == 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>" . $lang['ov_have_new_message'] . "</a></th>";
                } elseif ($CurrentUser['new_message'] > 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>";
                    $Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
                    $Have_new_message .= "</a></th>";
                }
                $Have_new_message .= "</tr>";
            }
            $OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets');
            $Record = 0;
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                /////// // ### LUCKY , CODES ARE BELOW
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                //////
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
            }
            mysql_free_result($OwnFleets);
            //iss ye katilan filo////////////////////////////////////
            // ### LUCKY , CODES ARE BELOW
            $dostfilo = doquery("SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = '" . intval($hedefgalaksi) . "' AND `fleet_end_system` = '" . intval($hedefsistem) . "' AND `fleet_end_planet` = '" . intval($hedefgezegen) . "' AND `fleet_group` = '" . intval($filogrubu) . "';", 'fleets');
            $Record1 = 0;
            while ($FleetRow = mysql_fetch_array($dostfilo)) {
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $EndTime = $FleetRow['fleet_end_time'];
                ///////
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                ///////
                if ($FleetRow['fleet_mission'] == 2 && $FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    $Record1++;
                    //		if (($FleetRow['fleet_mission'] == 2) ){
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record1);
                    }
                    //	}
                }
                ///""
                if ($FleetRow['fleet_mission'] == 1 && $FleetRow['fleet_owner'] != $CurrentUser['id'] && $filogrubu > 0) {
                    $Record++;
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                    }
                }
            }
            mysql_free_result($dostfilo);
            //
            //////////////////////////////////////////////////
            $OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        $id = $FleetRow['fleet_id'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            mysql_free_result($OtherFleets);
            $planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='" . intval($CurrentUser['id']) . "' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $AllPlanets = "<tr>";
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".jpg\" height=\"50\" width=\"50\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Colone <= 1) {
                        $Colone++;
                    } else {
                        $AllPlanets .= "</tr><tr>";
                        $Colone = 1;
                    }
                }
            }
            mysql_free_result($planets_query);
            $AllPlanets .= "</tr>";
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . intval($CurrentPlanet['galaxy']) . "' AND `system` = '" . intval($CurrentPlanet['system']) . "' AND `planet` = '" . intval($CurrentPlanet['planet']) . "' AND `planet_type` = '3'", 'planets', true);
                    $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/" . $moon['image'] . ".jpg\" height=\"50\" width=\"50\"></a>";
                    $parse['moon'] = $moon['name'] . " (" . $lang['fcm_moon'] . ")";
                } else {
                    $parse['moon_img'] = "";
                    $parse['moon'] = "";
                }
            } else {
                $parse['moon_img'] = "";
                $parse['moon'] = "";
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            $StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($CurrentUser['id']) . "';", 'statpoints', true);
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            if ($CurrentPlanet['b_building'] != 0) {
                include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("buildings");
                    $Build .= "<table>";
                    $Build .= "    <tr>";
                    $Build .= "        <td colspan=\"2\" style=font-weight:bold; >" . $lang['tech'][$CurrBuild[0]] . "</td>";
                    $Build .= "    </tr>";
                    $Build .= "    <tr>";
                    $Build .= "        <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"></td>";
                    $Build .= "        <td>" . $lang['pr_subiendo'] . " <span style=\"color:#FF8C00;\">Nivel&nbsp;" . $CurrBuild[1] . "</span><br />";
                    $Build .= "            " . $lang['pr_duracion'] . ":<div id=\"blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                    $Build .= "        </td>";
                    $Build .= "    </tr>";
                    $Build .= "</Table>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n    pp = \"" . $RestTime . "\";\n";
                    $Build .= "\n    pk = \"" . 1 . "\";\n";
                    $Build .= "\n    pm = \"cancel\";\n";
                    $Build .= "\n    pl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n    t();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            $PlanetaQueInv = doquery("SELECT id, name, b_tech, b_tech_id FROM `{{table}}` WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `b_tech` != '0';", 'planets', true);
            if ($PlanetaQueInv['b_tech'] != 0) {
                include $xgp_root . 'includes/functions/InsertTechListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $NvlActual = $CurrentUser[$resource[$PlanetaQueInv['b_tech_id']]] + 1;
                $RestTime = $PlanetaQueInv['b_tech'] - time();
                $PlanetID = $PlanetaQueInv['id'];
                $NomPlaneta = "";
                if ($PlanetaQueInv['name'] != $CurrentPlanet['name']) {
                    $NomPlaneta = " de " . $PlanetaQueInv['name'];
                }
                $Tech = InsertTechListScript("buildings", $NomPlaneta);
                $Tech .= "<table>";
                $Tech .= "    <tr>";
                $Tech .= "        <td colspan=\"2\" style=font-weight:bold; >" . $lang['tech'][$PlanetaQueInv['b_tech_id']] . "</td>";
                $Tech .= "    </tr>";
                $Tech .= "    <tr>";
                $Tech .= "        <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $PlanetaQueInv['b_tech_id'] . ".gif\" width=\"40\" height=\"40\"></td>";
                $Tech .= "        <td>" . $lang['pr_investigando'] . " <span style=\"color:#FF8C00;\">Nivel&nbsp;" . $NvlActual . "</span><br />";
                $Tech .= "            " . $lang['pr_duracion'] . ":<div id=\"tec_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Tech .= "        </td>";
                $Tech .= "    </tr>";
                $Tech .= "</Table>";
                $Tech .= "\n<script language=\"JavaScript\">";
                $Tech .= "\n    tec_pp = \"" . $RestTime . "\";\n";
                $Tech .= "\n    tec_pk = \"" . 1 . "\";\n";
                $Tech .= "\n    tec_pm = \"cancel\";\n";
                $Tech .= "\n    tec_pl = \"" . $PlanetaQueInv['b_tech_id'] . "\";\n";
                $Tech .= "\n    tec_t();\n";
                $Tech .= "\n</script>\n";
                $parse['tech_en_proceso'] .= $Tech;
            } else {
                $parse['tech_en_proceso'] = $lang['ov_free'];
            }
            if ($CurrentPlanet['b_hangar'] != 0) {
                include $xgp_root . 'includes/functions/InsertHangarListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $BuildQueue = explode(";", $CurrentPlanet['b_hangar_id']);
                $CurrBuild = explode(",", $BuildQueue[0]);
                $RealTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $CurrBuild[0]);
                $QueueTime = $RealTime * $CurrBuild[1];
                $RestTime = $QueueTime - $CurrentPlanet['b_hangar'];
                $PlanetID = $CurrentPlanet['id'];
                $Hangar = InsertHangarListScript("overview");
                $Hangar .= "<table>";
                $Hangar .= "    <tr>";
                $Hangar .= "        <td colspan=\"2\" style=font-weight:bold; >" . $lang['tech'][$CurrBuild[0]] . "</td>";
                $Hangar .= "    </tr>";
                $Hangar .= "    <tr>";
                $Hangar .= "        <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"><br />";
                $Hangar .= "        </td>";
                $Hangar .= "        <td>" . $lang['pr_tiempo_prod'] . "<br />";
                $Hangar .= "            <div id=\"han_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Hangar .= "        </td>";
                $Hangar .= "    </tr>";
                $Hangar .= "</Table>";
                $Hangar .= "\n<script language=\"JavaScript\">";
                $Hangar .= "\n    han_pp = \"" . $RestTime . "\";\n";
                $Hangar .= "\n    han_pk = \"" . 1 . "\";\n";
                $Hangar .= "\n    han_pm = \"cancel\";\n";
                $Hangar .= "\n    han_pl = \"" . $PlanetID . "\";\n";
                $Hangar .= "\n    han_t();\n";
                $Hangar .= "\n</script>\n";
                $parse['hangar_en_proceso'] .= $Hangar;
            } else {
                $parse['hangar_en_proceso'] = $lang['ov_free'];
            }
            $parse['overview_produccion'] = parsetemplate(gettemplate('overview/overview_production'), $parse);
            $parse['fleet_list'] = $flotten;
            $parse['Have_new_message'] = $Have_new_message;
            $parse['planet_image'] = $CurrentPlanet['image'];
            $parse['anothers_planets'] = $AllPlanets;
            $parse["dpath"] = $dpath;
            if ($game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } elseif ($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            $parse['date_time'] = date("D M j H:i:s", time());
            return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
            break;
    }
}
Example #7
0
 public function GalaxyRowPlanet($GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType, $HavePhalanx, $CurrentGalaxy, $CurrentSystem, $GalaxyRowWormHole)
 {
     global $dpath, $user, $CurrentMIP, $CurrentSystem, $game_config, $lang;
     $Result = "<th colspan=2>";
     if ($GalaxyRow && $GalaxyRowPlanet["destruyed"] == 0 && $GalaxyRow["id_planet"] != 0) {
         $Result = "<th width=30>";
         if ($HavePhalanx != 0) {
             if ($GalaxyRowUser['id'] != $user['id']) {
                 if ($GalaxyRowPlanet["galaxy"] == $CurrentGalaxy) {
                     $PhRange = $this->GetPhalanxRange($HavePhalanx);
                     $SystemLimitMin = $CurrentSystem - $PhRange;
                     if ($SystemLimitMin < 1) {
                         $SystemLimitMin = 1;
                     }
                     $SystemLimitMax = $CurrentSystem + $PhRange;
                     if ($System <= $SystemLimitMax) {
                         if ($System >= $SystemLimitMin) {
                             $PhalanxTypeLink = "<a href=# onclick=fenster(&#039;game.php?page=phalanx&galaxy=" . $Galaxy . "&amp;system=" . $System . "&amp;planet=" . $Planet . "&amp;planettype=" . $PlanetType . "&#039;) >" . $lang['gl_phalanx'] . "</a><br />";
                         } else {
                             $PhalanxTypeLink = "";
                         }
                     } else {
                         $PhalanxTypeLink = "";
                     }
                 } else {
                     $PhalanxTypeLink = "";
                 }
             } else {
                 $PhalanxTypeLink = "";
             }
         } else {
             $PhalanxTypeLink = "";
         }
         if ($CurrentMIP != 0) {
             if ($GalaxyRowUser['id'] != $user['id']) {
                 if ($GalaxyRowPlanet["galaxy"] == $CurrentGalaxy) {
                     $MiRange = $this->GetMissileRange();
                     $SystemLimitMin = $CurrentSystem - $MiRange;
                     if ($SystemLimitMin < 1) {
                         $SystemLimitMin = 1;
                     }
                     $SystemLimitMax = $CurrentSystem + $MiRange;
                     if ($System <= $SystemLimitMax) {
                         if ($System >= $SystemLimitMin) {
                             $MissileBtn = true;
                         } else {
                             $MissileBtn = false;
                         }
                     } else {
                         $MissileBtn = false;
                     }
                 } else {
                     $MissileBtn = false;
                 }
             } else {
                 $MissileBtn = false;
             }
         } else {
             $MissileBtn = false;
         }
         if ($GalaxyRowUser['id'] != $user['id']) {
             $MissionType6Link = "<a href=# onclick=&#039javascript:doit(6, " . $Galaxy . ", " . $System . ", " . $Planet . ", " . $PlanetType . ", " . $user["spio_anz"] . ");&#039 >" . $lang['type_mission'][6] . "</a><br /><br />";
         } elseif ($GalaxyRowUser['id'] == $user['id']) {
             $MissionType6Link = "";
         }
         if ($GalaxyRowUser['id'] != $user['id']) {
             $MissionType1Link = "<a href=game.php?page=fleet&galaxy=" . $Galaxy . "&amp;system=" . $System . "&amp;planet=" . $Planet . "&amp;planettype=" . $PlanetType . "&amp;target_mission=1>" . $lang['type_mission'][1] . "</a><br />";
         } elseif ($GalaxyRowUser['id'] == $user['id']) {
             $MissionType1Link = "";
         }
         if ($GalaxyRowUser['id'] == $user['id']) {
             $MissionType5Link = "<a href=game.php?page=fleet&galaxy=" . $Galaxy . "&system=" . $System . "&planet=" . $Planet . "&planettype=" . $PlanetType . "&target_mission=5>" . $lang['type_mission'][5] . "</a><br />";
         } elseif ($GalaxyRowUser['id'] == $user['id']) {
             $MissionType5Link = "";
         }
         if ($GalaxyRowUser['id'] == $user['id']) {
             $MissionType4Link = "<a href=game.php?page=fleet&galaxy=" . $Galaxy . "&system=" . $System . "&planet=" . $Planet . "&planettype=" . $PlanetType . "&target_mission=4>" . $lang['type_mission'][4] . "</a><br />";
         } elseif ($GalaxyRowUser['id'] != $user['id']) {
             $MissionType4Link = "";
         }
         if ($user["settings_mis"] == "1" and $MissileBtn == true && $GalaxyRowUser['id']) {
             $MissionType10Link = "<a href=game.php?page=galaxy&mode=2&galaxy=" . $Galaxy . "&system=" . $System . "&planet=" . $Planet . "&current=" . $user['current_planet'] . " >" . $lang['gl_missile_attack'] . "</a><br />";
         } elseif ($GalaxyRowUser['id'] != $user['id']) {
             $MissionType10Link = "";
         }
         $MissionType3Link = "<a href=game.php?page=fleet&galaxy=" . $Galaxy . "&system=" . $System . "&planet=" . $Planet . "&planettype=" . $PlanetType . "&target_mission=3>" . $lang['type_mission'][3] . "</a><br />";
         $Result .= "<a style=\"cursor: pointer;\"";
         $Result .= " onmouseover='return overlib(\"";
         $Result .= "<table width=240>";
         $Result .= "<tr>";
         $Result .= "<td class=c colspan=2>";
         $Result .= $lang['gl_planet'] . " " . $GalaxyRowPlanet["name"] . " [" . $Galaxy . ":" . $System . ":" . $Planet . "]";
         $Result .= "</td>";
         $Result .= "</tr><tr>";
         $Result .= "<th width=80 rowspan=3>";
         $Result .= "<img src=" . $dpath . "planeten/small/s_" . $GalaxyRowPlanet["image"] . ".jpg height=75 width=75 />";
         $Result .= "</th><th>Diámetro: " . pretty_number($GalaxyRowPlanet['diameter']) . " km</th></tr>";
         $Result .= "<tr><th>Tipo: " . GetPlanetType($GalaxyRowPlanet, 1) . "</th></tr><tr>";
         $Result .= "<th align=left>";
         $Result .= $MissionType6Link;
         $Result .= $PhalanxTypeLink;
         $Result .= $MissionType1Link;
         $Result .= $MissionType5Link;
         $Result .= $MissionType4Link;
         $Result .= $MissionType3Link;
         $Result .= $MissionType10Link;
         $Result .= "</th>";
         $Result .= "</tr>";
         $Result .= "</table>\"";
         $Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'";
         $Result .= " onmouseout='return nd();'>";
         $Result .= "<img src=" . $dpath . "planeten/small/s_" . $GalaxyRowPlanet["image"] . ".jpg height=30 width=30>";
         $Result .= "</a>";
         $Result .= "</th>";
     } elseif ($GalaxyRowWormHole) {
         $Result = "<th width=30>";
         if ($GalaxyRowWormHole['start_galaxy'] == $Galaxy and $GalaxyRowWormHole['start_system'] == $System and $GalaxyRowWormHole['start_planet'] == $Planet) {
             $Orientation = 'end';
         } else {
             $Orientation = 'start';
         }
         if ($GalaxyRowWormHole['state'] == 1) {
             $Result .= "<a style=\"cursor: pointer;\"";
             $Result .= " onmouseover='return overlib(\"";
             $Result .= "<table width=300>";
             $Result .= "<tr>";
             $Result .= "<td class=c colspan=2 >";
             $Result .= "Agujero de gusano [" . $Galaxy . ":" . $System . ":" . $Planet . "] -&gt; <a href=game.php?page=galaxy&mode=3&galaxy=" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . "&system=" . $GalaxyRowWormHole[$Orientation . '_system'] . "&amp;unid=" . UNID . " >[" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . ":" . $GalaxyRowWormHole[$Orientation . '_system'] . ":" . $GalaxyRowWormHole[$Orientation . '_planet'] . "]</a>";
             $Result .= "</td>";
             $Result .= "</tr>";
             $Result .= "<tr>";
             $Result .= "<th width=120 rowspan=2 >";
             $Result .= "<img src=styles/images/wormhole.jpg height=75 width=120 />";
             $Result .= "</th>";
             $Result .= "<th align=left>";
             $Result .= "<span style=color:lime; >Estable</span><br><span style=color:grey; >Desvanecimiento: " . pretty_time($GalaxyRowWormHole['time'] - time()) . "</span>";
             $Result .= "</th>";
             $Result .= "</tr>";
             $Result .= "<tr>";
             $Result .= "<th align=left>";
             $Result .= "<a href=game.php?page=fleet&wormhole_galaxy=" . $Galaxy . "&wormhole_system=" . $System . "&wormhole_planet=" . $Planet . "&planettype=1&wormhole=on>Atravesar</a>";
             $Result .= "</th>";
             $Result .= "</tr>";
             $Result .= "</table>\"";
             $Result .= ", STICKY, MOUSEOFF, DELAY, 150, CENTER, OFFSETX, -40, OFFSETY, -40 );'";
             $Result .= " onmouseout='return nd();'>";
             $Result .= "<img src=styles/images/wormhole_thumb.jpg height=32 width=55/>";
             $Result .= "</a>";
         } elseif ($GalaxyRowWormHole['state'] == 2) {
             $Result .= "<a style=\"cursor: pointer;\"";
             $Result .= " onmouseover='return overlib(\"";
             $Result .= "<table width=300>";
             $Result .= "<tr>";
             $Result .= "<td class=c colspan=2 >";
             $Result .= "Agujero de gusano [" . $Galaxy . ":" . $System . ":" . $Planet . "] -&gt; <a href=game.php?page=galaxy&mode=3&galaxy=" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . "&system=" . $GalaxyRowWormHole[$Orientation . '_system'] . "&amp;unid=" . UNID . " >[" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . ":" . $GalaxyRowWormHole[$Orientation . '_system'] . ":" . $GalaxyRowWormHole[$Orientation . '_planet'] . "]</a>";
             $Result .= "</td>";
             $Result .= "</tr>";
             $Result .= "<tr>";
             $Result .= "<th width=120 rowspan=2 >";
             $Result .= "<img src=styles/images/wormhole.jpg height=75 width=120 />";
             $Result .= "</th>";
             $Result .= "<th align=left>";
             $Result .= "<span style=color:lime; >Singularidad natural</span>";
             $Result .= "</th>";
             $Result .= "</tr>";
             $Result .= "<tr>";
             $Result .= "<th align=left>";
             $Result .= "<a href=game.php?page=fleet&wormhole_galaxy=" . $Galaxy . "&wormhole_system=" . $System . "&wormhole_planet=" . $Planet . "&planettype=1&wormhole=on>Atravesar</a>";
             $Result .= "</th>";
             $Result .= "</tr>";
             $Result .= "</table>\"";
             $Result .= ", STICKY, MOUSEOFF, DELAY, 150, CENTER, OFFSETX, -40, OFFSETY, -40 );'";
             $Result .= " onmouseout='return nd();'>";
             $Result .= "<img src=styles/images/wormhole_thumb.jpg height=32 width=55/>";
             $Result .= "</a>";
         } elseif ($GalaxyRowWormHole['state'] == 0) {
             $Result .= "<a style=\"cursor: pointer;\"";
             $Result .= " onmouseover='return overlib(\"";
             $Result .= "<table width=300>";
             $Result .= "<tr>";
             $Result .= "<td class=c colspan=2 >";
             $Result .= "Agujero de gusano [" . $Galaxy . ":" . $System . ":" . $Planet . "] -&gt; <a href=game.php?page=galaxy&mode=3&galaxy=" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . "&system=" . $GalaxyRowWormHole[$Orientation . '_system'] . "&amp;unid=" . UNID . " >[" . $GalaxyRowWormHole[$Orientation . '_galaxy'] . ":" . $GalaxyRowWormHole[$Orientation . '_system'] . ":" . $GalaxyRowWormHole[$Orientation . '_planet'] . "]</a>";
             $Result .= "</td>";
             $Result .= "</tr>";
             $Result .= "<tr>";
             $Result .= "<th width=120 rowspan=2 >";
             $Result .= "<img src=styles/images/wormhole.jpg height=75 width=120 />";
             $Result .= "</th>";
             $Result .= "<th align=left>";
             $Result .= "<span style=color:red; >Inestable</span>";
             $Result .= "</th>";
             $Result .= "</tr>";
             $Result .= "<tr>";
             $Result .= "<th align=left>";
             $Result .= "<span style=color:grey; >Atravesar</span>";
             $Result .= "</th>";
             $Result .= "</tr>";
             $Result .= "</table>\"";
             $Result .= ", STICKY, MOUSEOFF, DELAY, 150, CENTER, OFFSETX, -40, OFFSETY, -40 );'";
             $Result .= " onmouseout='return nd();'>";
             $Result .= "<img src=styles/images/wormhole_thumb.jpg height=32 width=55/>";
             $Result .= "</a>";
         }
         $Result .= "</th>";
     }
     return $Result;
 }