function display_logbook($log)
{
    global $game, $BUILDING_NAME;
    $game->out('
<br>
<table align="center" border="0" cellpadding="2" cellspacing="2" class="style_outer">
  <tr>
    <td>
      <table align="center" border="0" cellpadding="2" cellspacing="2" class="style_inner">
        <tr>
          <td width="450">
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="450">
                  <table border=0 cellpadding=0 cellspacing=0>
                    <tr>
                      <td width="330" align="left"><b><u>' . $log['log_title'] . '</u></b></td>
                      <td width="120" align="right"><b>' . date('d.m.y H:i:s', $log['log_date']) . '</b></td>
                    </tr>
                  </table>
                  <br>
                  ' . constant($game->sprache("TEXT136")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data']['planet_id'])) . '"><b>' . $log['log_data']['planet_name'] . '</a></b> ' . constant($game->sprache("TEXT137")) . '
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
    ');
}
     $game->out(constant($game->sprache("TEXT7")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['start'])) . '"><b>' . $move['start_planet_name'] . '</b></a><br>');
 } else {
     $game->out(constant($game->sprache("TEXT8")) . ' ' . (isset($move['owner_name']) ? '<a href="' . parse_link('a=stats&a2=viewplayer&id=' . $move['user_id']) . '"><b>' . $move['owner_name'] . '</b></a>' : '<b>' . constant($game->sprache("TEXT9")) . '</b>') . '<br>');
     if (!empty($move['start'])) {
         if (empty($move['start_owner_id'])) {
             $start_owner_str = ' <i>' . constant($game->sprache("TEXT10")) . '</i>';
         } elseif ($move['start_owner_id'] != $game->player['user_id']) {
             $start_owner_str = ' ' . constant($game->sprache("TEXT11")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $move['start_owner_id']) . '"><b>' . $move['start_owner_name'] . '</b></a>';
         } else {
             $start_owner_str = '';
         }
         $game->out(constant($game->sprache("TEXT12")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['start'])) . '"><b>' . $move['start_planet_name'] . '</b></a>' . $start_owner_str . '<br>');
     } else {
         $game->out(constant($game->sprache("TEXT12")) . ' <i>' . constant($game->sprache("TEXT13")) . '</i><br>');
     }
     $game->out(constant($game->sprache("TEXT14")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['dest'])) . '"><b>' . $move['dest_planet_name'] . '</b></a><br>');
 }
 $commands = array(11 => constant($game->sprache("TEXT15")), 12 => constant($game->sprache("TEXT16")), 13 => constant($game->sprache("TEXT16")), 14 => constant($game->sprache("TEXT17")), 21 => constant($game->sprache("TEXT15")), 22 => constant($game->sprache("TEXT18")), 23 => constant($game->sprache("TEXT19")), 24 => constant($game->sprache("TEXT20")), 25 => constant($game->sprache("TEXT20")), 26 => constant($game->sprache("TEXT36")), 31 => constant($game->sprache("TEXT17")), 32 => constant($game->sprache("TEXT21")), 33 => constant($game->sprache("TEXT22")), 34 => constant($game->sprache("TEXT23")), 35 => constant($game->sprache("TEXT23")), 36 => constant($game->sprache("TEXT23")), 37 => constant($game->sprache("TEXT23")), 38 => constant($game->sprache("TEXT23")), 39 => constant($game->sprache("TEXT23")), 40 => constant($game->sprache("TEXT24")), 41 => constant($game->sprache("TEXT24")), 42 => constant($game->sprache("TEXT24")), 43 => constant($game->sprache("TEXT25")), 44 => constant($game->sprache("TEXT26")), 45 => constant($game->sprache("TEXT20")), 46 => constant($game->sprache("TEXT35")), 51 => constant($game->sprache("TEXT24")), 53 => constant($game->sprache("TEXT25")), 54 => constant($game->sprache("TEXT26")), 55 => constant($game->sprache("TEXT20")));
 if (in_array($move['action_code'], $visible_actions) || $travelled >= $visibility + (100 - $visibility) / 4) {
     $game->out('<br>' . constant($game->sprache("TEXT27")) . ' <b>' . $sensor1['n_ships'] . '</b>');
 }
 if (in_array($move['action_code'], $visible_actions) || $travelled >= $visibility + 2 * ((100 - $visibility) / 4)) {
     $game->out('<br>' . constant($game->sprache("TEXT28")) . ' <b>' . $commands[$move['action_code']] . '</b>');
 }
 if (in_array($move['action_code'], $visible_actions) || $travelled >= $visibility + 3 * ((100 - $visibility) / 4)) {
     $game->out('<br>' . constant($game->sprache("TEXT29")));
     for ($t = 0; $t < 14; $t++) {
         if (isset($sensor1['torso'][$t]) && $sensor1['torso'][$t] > 0) {
             if (!isset($SHIP_TORSO[$game->player['user_race']][$t][0])) {
                 if ($SHIP_TORSO[9][6][0]) {
                     $game->out('<br><b>' . $sensor1['torso'][$t] . 'x</b> ' . constant($game->sprache("TEXT30")) . ' ' . 7 . ')');
Example #3
0
function Trade_Ress()
{
    global $game, $db, $ACTUAL_TICK;
    /*
    [22:07:05] <TotesTAP> [02:46] <rmA> 1 : 4 : 3
    [22:07:05] <TotesTAP> [02:46] <rmA> Met : Min : Lat
    [22:07:08] <TotesTAP> [02:47] <rmA> bei 6h 50% steuern
    [22:07:08] <TotesTAP> [02:47] <rmA> bei 12h 35% steuern
    [22:07:08] <TotesTAP> [02:48] <rmA> bei 36h 15% steuern
    */
    $game->out('<center><span class="sub_caption">' . constant($game->sprache("TEXT144")) . ' ' . HelpPopup('trade_ress') . ' :</span></center><br>');
    if (isset($_POST['bezahlungsart'])) {
        $_POST['bezahlungsart'] = (int) $_POST['bezahlungsart'];
    }
    /*
    if(isset($_POST['plani_ziel'])) $_POST['plani_ziel']=(int)$_POST['plani_ziel'];
    if(isset($_POST['plani'])) $_POST['plani']=(int)$_POST['plani'];
    */
    /*
    if(isset($_POST['Art']))
    if($_POST['Art']!="Metall" && $_POST['Art']!="Latinum" && $_POST['Art']!="Mineral")
    {
    	message(NOTICE, constant($game->sprache("TEXT145")));
    }
    */
    /*
    $daten=$db->queryrow('SELECT * FROM FHB_Handels_Lager WHERE id=1');
    
    // 27/02/08 - AC: Check DB query 
    if($daten == null)
    {
    	$daten['ress_1'] = 0;
    	$daten['ress_2'] = 0;
    	$daten['ress_3'] = 0;
    }
    */
    /* 04/03/08 - AC: If step is not specified, it si frist step */
    if (!isset($_REQUEST['step'])) {
        $_REQUEST['step'] = '1';
    }
    if (isset($_REQUEST['handel']) && $_REQUEST['handel'] == 'trade_ress' && isset($_POST['plani']) && $_REQUEST['step'] == '2') {
        /* 01/03/08 - AC: Check this value */
        if (!isset($_POST['plani_ziel'])) {
            $_POST['plani_ziel'] = 0;
        }
        $plani_id_a = $db->queryrow('SELECT planet_id,planet_name FROM `planets` WHERE planet_id=' . decode_planet_id($_POST['plani_ziel']) . ' AND planet_owner=' . $game->player['user_id'] . '');
        $plani_id_r = $db->queryrow('SELECT planet_id,planet_name FROM `planets` WHERE planet_id=' . decode_planet_id($_POST['plani']) . ' AND planet_owner=' . $game->player['user_id'] . '');
        if ($plani_id_a['planet_id'] != decode_planet_id($_POST['plani_ziel']) || $plani_id_r['planet_id'] != decode_planet_id($_POST['plani'])) {
            $game->out(constant($game->sprache("TEXT146")));
        } else {
            $kosten['Metall'] = 0;
            $kosten['Mineral'] = 0;
            $kosten['Latinum'] = 0;
            if ($_POST['transport'] != 1 && $_POST['transport'] != 2 && $_POST['transport'] != 3) {
                $game->out('Cheat');
                exit;
            }
            if ($_POST['transport'] == 1) {
                $transportsatz = 0.5;
                $tickzeit = 20 * 6;
            }
            if ($_POST['transport'] == 2) {
                $transportsatz = 0.35;
                $tickzeit = 20 * 12;
            }
            if ($_POST['transport'] == 3) {
                $transportsatz = 0.15;
                $tickzeit = 20 * 36;
            }
            $daten = $db->queryrow('SELECT * FROM FHB_Handels_Lager WHERE id=1');
            /* 27/02/08 - AC: Check DB query */
            if ($daten == null) {
                $daten['ress_1'] = 0;
                $daten['ress_2'] = 0;
                $daten['ress_3'] = 0;
            }
            // DC --- Vediamo di compattare un poco il codice
            $db->lock('FHB_Handels_Lager', 'scheduler_resourcetrade');
            $plani_inhalt = $db->queryrow('SELECT resource_1,resource_2,resource_3 FROM `planets` WHERE planet_id=' . decode_planet_id($_POST['plani']) . ' AND planet_owner=' . $game->player['user_id'] . '');
            if ($_POST['risorsa_da'] == "Metall" && $_POST['risorsa_a'] == "Mineral") {
                $kosten['Mineral'] = (int) ($_POST['Qty'] * Ress_price(10, 9));
                if ($_POST['Qty'] <= $plani_inhalt['resource_1']) {
                    $steuern = (int) ($kosten['Mineral'] * $transportsatz);
                    if ($daten['ress_2'] >= $kosten['Mineral'] - $steuern) {
                        // dem user Ressourcen abziehen:
                        if ($db->query('UPDATE planets SET resource_1=resource_1-' . $_POST['Qty'] . ' WHERE planet_id=' . decode_planet_id($_POST['plani']) . '') == true) {
                            // dem NPC Ressourcen abziehen:
                            if ($db->query('UPDATE FHB_Handels_Lager SET ress_2=ress_2-' . $kosten['Mineral'] . '+' . $steuern . ',ress_1=ress_1+' . $_POST['Qty'] . ' WHERE id=1') == true) {
                                // Buyers goods in the Trade Register Scheduler:
                                if ($db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . decode_planet_id($_POST['plani_ziel']) . '",0,' . ($kosten['Mineral'] - $steuern) . ',0,"' . ($ACTUAL_TICK + $tickzeit) . '")') == true) {
                                    $game->out('<table><tr><td>' . constant($game->sprache("TEXT147")) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT148")) . $plani_id_a['planet_name'] . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT149")) . $steuern . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT150")) . ($kosten['Mineral'] - $steuern) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT151")) . $_POST['Qty'] . '</td></tr>
									<tr><td><form name="ritorno" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress') . '" method="post">
									<input type="submit" value="' . constant($game->sprache("TEXT152")) . '"  name="submit" class="Button_nosize"></form></td></tr></table>');
                                } else {
                                    message(DATABASE_ERROR, 'Internal database error');
                                }
                            } else {
                                message(DATABASE_ERROR, 'Internal database error');
                            }
                        } else {
                            message(DATABASE_ERROR, 'Internal database error');
                        }
                    } else {
                        message(NOTICE, constant($game->sprache("TEXT153")));
                    }
                } else {
                    message(NOTICE, constant($game->sprache("TEXT158")));
                }
            } else {
                if ($_POST['risorsa_da'] == "Metall" && $_POST['risorsa_a'] == "Latinum") {
                    $kosten['Latinum'] = (int) ($_POST['Qty'] * Ress_price(11, 9));
                    if ($_POST['Qty'] <= $plani_inhalt['resource_1']) {
                        $steuern = (int) ($kosten['Latinum'] * $transportsatz);
                        if ($daten['ress_3'] >= $kosten['Latinum'] - $steuern) {
                            // dem user Ressourcen abziehen:
                            if ($db->query('UPDATE planets SET resource_1=resource_1-' . $_POST['Qty'] . ' WHERE planet_id=' . decode_planet_id($_POST['plani']) . '') == true) {
                                // dem NPC Ressourcen abziehen:
                                if ($db->query('UPDATE FHB_Handels_Lager SET ress_3=ress_3-' . $kosten['Latinum'] . '+' . $steuern . ',ress_1=ress_1+' . $_POST['Qty'] . ' WHERE id=1') == true) {
                                    // Buyers goods in the Trade Register Scheduler:
                                    if ($db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . decode_planet_id($_POST['plani_ziel']) . '",0,0,' . ($kosten['Latinum'] - $steuern) . ',"' . ($ACTUAL_TICK + $tickzeit) . '")') == true) {
                                        $game->out('<table><tr><td>' . constant($game->sprache("TEXT147")) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT148")) . $plani_id_a['planet_name'] . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT149")) . $steuern . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT156")) . ($kosten['Latinum'] - $steuern) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT151")) . $_POST['Qty'] . '</td></tr>
									<tr><td><form name="ritorno" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress') . '" method="post">
									<input type="submit" value="' . constant($game->sprache("TEXT152")) . '"  name="submit" class="Button_nosize"></form></td></tr></table>');
                                    } else {
                                        message(DATABASE_ERROR, 'Internal database error');
                                    }
                                } else {
                                    message(DATABASE_ERROR, 'Internal database error');
                                }
                            } else {
                                message(DATABASE_ERROR, 'Internal database error');
                            }
                        } else {
                            message(NOTICE, constant($game->sprache("TEXT153")));
                        }
                    } else {
                        message(NOTICE, constant($game->sprache("TEXT158")));
                    }
                } else {
                    if ($_POST['risorsa_da'] == "Mineral" && $_POST['risorsa_a'] == "Metall") {
                        $kosten['Metall'] = (int) ($_POST['Qty'] * Ress_price(9, 10));
                        if ($_POST['Qty'] <= $plani_inhalt['resource_2']) {
                            $steuern = (int) ($kosten['Metall'] * $transportsatz);
                            if ($daten['ress_1'] >= $kosten['Metall'] - $steuern) {
                                // dem user Ressourcen abziehen:
                                if ($db->query('UPDATE planets SET resource_2=resource_2-' . $_POST['Qty'] . ' WHERE planet_id=' . decode_planet_id($_POST['plani']) . '') == true) {
                                    // dem NPC Ressourcen abziehen:
                                    if ($db->query('UPDATE FHB_Handels_Lager SET ress_1=ress_1-' . $kosten['Metall'] . '+' . $steuern . ',ress_2=ress_2+' . $_POST['Qty'] . ' WHERE id=1') == true) {
                                        // Buyers goods in the Trade Register Scheduler:
                                        if ($db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . decode_planet_id($_POST['plani_ziel']) . '",' . ($kosten['Metall'] - $steuern) . ',0,0,"' . ($ACTUAL_TICK + $tickzeit) . '")') == true) {
                                            $game->out('<table><tr><td>' . constant($game->sprache("TEXT147")) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT148")) . $plani_id_a['planet_name'] . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT149")) . $steuern . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT154")) . ($kosten['Metall'] - $steuern) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT155")) . $_POST['Qty'] . '</td></tr>
									<tr><td><form name="ritorno" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress') . '" method="post">
									<input type="submit" value="' . constant($game->sprache("TEXT152")) . '"  name="submit" class="Button_nosize"></form></td></tr></table>');
                                        } else {
                                            message(DATABASE_ERROR, 'Internal database error');
                                        }
                                    } else {
                                        message(DATABASE_ERROR, 'Internal database error');
                                    }
                                } else {
                                    message(DATABASE_ERROR, 'Internal database error');
                                }
                            } else {
                                message(NOTICE, constant($game->sprache("TEXT153")));
                            }
                        } else {
                            message(NOTICE, constant($game->sprache("TEXT158")));
                        }
                    } else {
                        if ($_POST['risorsa_da'] == "Mineral" && $_POST['risorsa_a'] == "Latinum") {
                            $kosten['Latinum'] = (int) ($_POST['Qty'] * Ress_price(11, 10));
                            if ($_POST['Qty'] <= $plani_inhalt['resource_2']) {
                                $steuern = (int) ($kosten['Latinum'] * $transportsatz);
                                if ($daten['ress_3'] >= $kosten['Latinum'] - $steuern) {
                                    // dem user Ressourcen abziehen:
                                    if ($db->query('UPDATE planets SET resource_2=resource_2-' . $_POST['Qty'] . ' WHERE planet_id=' . decode_planet_id($_POST['plani']) . '') == true) {
                                        // dem NPC Ressourcen abziehen:
                                        if ($db->query('UPDATE FHB_Handels_Lager SET ress_3=ress_3-' . $kosten['Latinum'] . '+' . $steuern . ',ress_2=ress_2+' . $_POST['Qty'] . ' WHERE id=1') == true) {
                                            // Buyers goods in the Trade Register Scheduler:
                                            if ($db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . decode_planet_id($_POST['plani_ziel']) . '",0,0,' . ($kosten['Latinum'] - $steuern) . ',"' . ($ACTUAL_TICK + $tickzeit) . '")') == true) {
                                                $game->out('<table><tr><td>' . constant($game->sprache("TEXT147")) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT148")) . $plani_id_a['planet_name'] . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT149")) . $steuern . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT156")) . ($kosten['Latinum'] - $steuern) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT155")) . $_POST['Qty'] . '</td></tr>
									<tr><td><form name="ritorno" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress') . '" method="post">
									<input type="submit" value="' . constant($game->sprache("TEXT152")) . '"  name="submit" class="Button_nosize"></form></td></tr></table>');
                                            } else {
                                                message(DATABASE_ERROR, 'Internal database error');
                                            }
                                        } else {
                                            message(DATABASE_ERROR, 'Internal database error');
                                        }
                                    } else {
                                        message(DATABASE_ERROR, 'Internal database error');
                                    }
                                } else {
                                    message(NOTICE, constant($game->sprache("TEXT153")));
                                }
                            } else {
                                message(NOTICE, constant($game->sprache("TEXT158")));
                            }
                        } else {
                            if ($_POST['risorsa_da'] == "Latinum" && $_POST['risorsa_a'] == "Metall") {
                                $kosten['Metall'] = (int) ($_POST['Qty'] * Ress_price(9, 11));
                                if ($_POST['Qty'] <= $plani_inhalt['resource_3']) {
                                    $steuern = (int) ($kosten['Metall'] * $transportsatz);
                                    if ($daten['ress_1'] >= $kosten['Metall'] - $steuern) {
                                        // dem user Ressourcen abziehen:
                                        if ($db->query('UPDATE planets SET resource_3=resource_3-' . $_POST['Qty'] . ' WHERE planet_id=' . decode_planet_id($_POST['plani']) . '') == true) {
                                            // dem NPC Ressourcen abziehen:
                                            if ($db->query('UPDATE FHB_Handels_Lager SET ress_1=ress_1-' . $kosten['Metall'] . '+' . $steuern . ',ress_3=ress_3+' . $_POST['Qty'] . ' WHERE id=1') == true) {
                                                // Buyers goods in the Trade Register Scheduler:
                                                if ($db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . decode_planet_id($_POST['plani_ziel']) . '",' . ($kosten['Metall'] - $steuern) . ',0,0,"' . ($ACTUAL_TICK + $tickzeit) . '")') == true) {
                                                    $game->out('<table><tr><td>' . constant($game->sprache("TEXT147")) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT148")) . $plani_id_a['planet_name'] . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT149")) . $steuern . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT154")) . ($kosten['Metall'] - $steuern) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT157")) . $_POST['Qty'] . '</td></tr>
									<tr><td><form name="ritorno" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress') . '" method="post">
									<input type="submit" value="' . constant($game->sprache("TEXT152")) . '"  name="submit" class="Button_nosize"></form></td></tr></table>');
                                                } else {
                                                    message(DATABASE_ERROR, 'Internal database error');
                                                }
                                            } else {
                                                message(DATABASE_ERROR, 'Internal database error');
                                            }
                                        } else {
                                            message(DATABASE_ERROR, 'Internal database error');
                                        }
                                    } else {
                                        message(NOTICE, constant($game->sprache("TEXT153")));
                                    }
                                } else {
                                    message(NOTICE, constant($game->sprache("TEXT158")));
                                }
                            } else {
                                if ($_POST['risorsa_da'] == "Latinum" && $_POST['risorsa_a'] == "Mineral") {
                                    $kosten['Mineral'] = (int) ($_POST['Qty'] * Ress_price(10, 11));
                                    if ($_POST['Qty'] <= $plani_inhalt['resource_3']) {
                                        $steuern = (int) ($kosten['Mineral'] * $transportsatz);
                                        if ($daten['ress_2'] >= $kosten['Mineral'] - $steuern) {
                                            // dem user Ressourcen abziehen:
                                            if ($db->query('UPDATE planets SET resource_3=resource_3-' . $_POST['Qty'] . ' WHERE planet_id=' . decode_planet_id($_POST['plani']) . '') == true) {
                                                // dem NPC Ressourcen abziehen:
                                                if ($db->query('UPDATE FHB_Handels_Lager SET ress_2=ress_2-' . $kosten['Mineral'] . '+' . $steuern . ',ress_3=ress_3+' . $_POST['Qty'] . ' WHERE id=1') == true) {
                                                    // Buyers goods in the Trade Register Scheduler:
                                                    if ($db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . decode_planet_id($_POST['plani_ziel']) . '",0,' . ($kosten['Mineral'] - $steuern) . ',0,"' . ($ACTUAL_TICK + $tickzeit) . '")') == true) {
                                                        $game->out('<table><tr><td>' . constant($game->sprache("TEXT147")) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT148")) . $plani_id_a['planet_name'] . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT149")) . $steuern . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT150")) . ($kosten['Mineral'] - $steuern) . '</td></tr>
									<tr><td>' . constant($game->sprache("TEXT157")) . $_POST['Qty'] . '</td></tr>
									<tr><td><form name="ritorno" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress') . '" method="post">
									<input type="submit" value="' . constant($game->sprache("TEXT152")) . '"  name="submit" class="Button_nosize"></form></td></tr></table>');
                                                    } else {
                                                        message(DATABASE_ERROR, 'Internal database error');
                                                    }
                                                } else {
                                                    message(DATABASE_ERROR, 'Internal database error');
                                                }
                                            } else {
                                                message(DATABASE_ERROR, 'Internal database error');
                                            }
                                        } else {
                                            message(NOTICE, constant($game->sprache("TEXT153")));
                                        }
                                    } else {
                                        message(NOTICE, constant($game->sprache("TEXT158")));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $db->unlock('FHB_Handels_Lager', 'scheduler_resourcetrade');
        }
    } else {
        $ressavail = $db->queryrow('SELECT * FROM FHB_Handels_Lager WHERE id=1');
        if ($ressavail == null) {
            $ressavail['ress_1'] = 0;
            $ressavail['ress_2'] = 0;
            $ressavail['ress_3'] = 0;
        }
        $game->out('
	<script type="text/javascript">
	    function check_exchange(){
	    	if(document.ScambioRisorse.risorsa_da.value ==
	    	   document.ScambioRisorse.risorsa_a.value)
	    	   {
	    	   		alert("' . constant($game->sprache("TEXT278")) . '");
	    	   		
	    			document.ScambioRisorse.risorsa_da.value = "Metall";
	    			document.ScambioRisorse.risorsa_a.value  = "Mineral";
	    	
	    			document.ScambioRisorse.Qty.value    = 0;
	    			document.ScambioRisorse.Result.value = 0;
	    	   }
	    }
	    function display_rateo()
	    {
	    	var res_from, res_to,value_from, value_to, rateo;
	    	
	    	res_from = document.ScambioRisorse.risorsa_da.value;
	    	res_to   = document.ScambioRisorse.risorsa_a.value;
	    	
	    	if(res_from == "Metall") value_from = 4;
	    	if(res_from == "Mineral") value_from = 5;
	    	if(res_from == "Latinum") value_from = 2.8;
	    	
	    	if(res_to == "Metall") value_to = 4;
	    	if(res_to == "Mineral") value_to = 5;
	    	if(res_to == "Latinum") value_to = 2.8;

			rateo = Math.round((1 / value_from * value_to) * 100) / 100;
			
			document.ScambioRisorse.Rateo.value = rateo;	    		    	
	    }
	    function display_avail()
	    {
	    	if(document.ScambioRisorse.risorsa_a.value == "Metall")
	    	{
	    		document.ScambioRisorse.Avail.value = document.ScambioRisorse.Ress_Avail_1.value;
	    	}
	    	if(document.ScambioRisorse.risorsa_a.value == "Mineral")
	    	{
	    		document.ScambioRisorse.Avail.value = document.ScambioRisorse.Ress_Avail_2.value;
	    	}
	    	if(document.ScambioRisorse.risorsa_a.value == "Latinum")
	    	{
	    		document.ScambioRisorse.Avail.value = document.ScambioRisorse.Ress_Avail_3.value;
	    	}
	    }
	    
		function recompute(){
			var res_from, res_to, quantity = 0, exchanged = 0, tax;
			var tax_rate = new Array(0, 0.50, 0.65, 0.85);

			// Exchange rates: Metall; Minerals; Latinum => 4 ; 5 ; 2.8
			
			res_from = document.ScambioRisorse.risorsa_da.value;
			res_to   = document.ScambioRisorse.risorsa_a.value;
			quantity = document.ScambioRisorse.Qty.value;
			tax      = document.ScambioRisorse.transport.value;
			
			if(res_from == "Metall")
			{
				if(res_to == "Mineral")
				{
					exchanged = Math.round((quantity / 4 * 5) * tax_rate[tax]);
				}
				
				if(res_to == "Latinum")
				{
					exchanged = Math.round((quantity / 4 * 2.8) * tax_rate[tax]);				
				}
			}
			
			if(res_from == "Mineral")
			{
				if(res_to == "Metall")
				{
					exchanged = Math.round((quantity / 5 * 4) * tax_rate[tax]);
				}
				
				if(res_to == "Latinum")
				{
					exchanged = Math.round((quantity / 5 * 2.8) * tax_rate[tax]);				
				}			
			}
			
			if(res_from == "Latinum")
			{
				if(res_to == "Metall")
				{
					exchanged = Math.round((quantity / 2.8 * 4) * tax_rate[tax]);
				}
				
				if(res_to == "Mineral")
				{
					exchanged = Math.round((quantity / 2.8 * 5) * tax_rate[tax]);
				}			
			}
			
			display_avail();			
			
			document.ScambioRisorse.Result.value = exchanged;
			
			if(exchanged > document.ScambioRisorse.Avail.value)
				document.ScambioRisorse.submit.disabled = true;
			else
				document.ScambioRisorse.submit.disabled = false;

		}
	</script>
	');
        $game->out('<form name="ScambioRisorse" action="' . parse_link('a=trade&view=' . $_REQUEST['view'] . '&handel=trade_ress&step=2') . '" method="post">');
        $game->out('<input type="hidden" name="Ress_Avail_1" value="' . $ressavail['ress_1'] . '">
			    <input type="hidden" name="Ress_Avail_2" value="' . $ressavail['ress_2'] . '">
			    <input type="hidden" name="Ress_Avail_3" value="' . $ressavail['ress_3'] . '">
	');
        $game->out('<table align=center>
				<tr>
				<td>' . constant($game->sprache("TEXT159")) . '</td>
				<td>: <select size="1" name="risorsa_da" onchange="display_rateo(); document.ScambioRisorse.Result.value = 0; document.ScambioRisorse.Qty.value = 0;">
					<option value="Metall" selected>' . constant($game->sprache("TEXT123")) . '</option>
					<option value="Mineral">' . constant($game->sprache("TEXT165")) . '</option>
					<option value="Latinum">' . constant($game->sprache("TEXT167")) . '</option>
					</select>
					==> <input name="Rateo" type="number" value="1.25" size="3" class="Field_nosize" readonly> ==>
					<select size="1" name="risorsa_a" onchange="display_rateo(); document.ScambioRisorse.Result.value = 0; document.ScambioRisorse.Qty.value = 0; display_avail();">
					<option value="Metall">' . constant($game->sprache("TEXT123")) . '</option>
					<option value="Mineral" selected>' . constant($game->sprache("TEXT165")) . '</option>
					<option value="Latinum">' . constant($game->sprache("TEXT167")) . '</option>
					</select>				
				</td>
				</tr>
	');
        $game->out('<tr>
				<td>' . constant($game->sprache("TEXT276")) . '</td>
				<td>: <input name="Qty" type="number" value="0" class="Field_nosize" onchange="check_exchange(); recompute();"></td>
				</tr>
	');
        $game->out('<tr>
				<td>' . constant($game->sprache("TEXT173")) . '</td>
				<td>: <select size="1" name="transport" onchange="recompute();">
					<option value="1">' . constant($game->sprache("TEXT174")) . '</option>
					<option value="2">' . constant($game->sprache("TEXT175")) . '</option>
					<option value="3">' . constant($game->sprache("TEXT176")) . '</option>
					</select>
				</td>
				</tr>
	');
        $game->out('<tr>
				<td>' . constant($game->sprache("TEXT277")) . '</td>
				<td>: <input name="Result" type="number" value="0" class="Field_nosize" disabled> ' . constant($game->sprache("TEXT245")) . ' <input name="Avail" type="number" value="' . $ressavail['ress_2'] . '" class="Field_nosize" disabled><td>
				</tr>
	');
        $sql = 'SELECT planet_id,planet_name,building_11 FROM `planets` WHERE planet_owner=' . $game->player['user_id'] . ' ORDER BY planet_name ASC';
        if (($planis = $db->query($sql)) == false) {
            $game->out(constant($game->sprache("TEXT178")));
        } else {
            $game->out('<tr><td width="150">' . constant($game->sprache("TEXT179")) . '</td><td>: <select size="1" name="plani">');
            while ($planeten = $db->fetchrow($planis)) {
                if ($planeten['building_11'] > 0) {
                    if ($game->planet['planet_id'] == $planeten['planet_id']) {
                        $game->out('<option value="' . encode_planet_id($planeten['planet_id']) . '" selected="selected">' . $planeten['planet_name'] . '</option>');
                    } else {
                        $game->out('<option value="' . encode_planet_id($planeten['planet_id']) . '">' . $planeten['planet_name'] . '</option>');
                    }
                }
            }
            $game->out('</select></td></tr>');
        }
        if (($planis = $db->query($sql)) == false) {
            $game->out(constant($game->sprache("TEXT178")));
        } else {
            $game->out('<tr><td width="150">' . constant($game->sprache("TEXT180")) . '</td><td>: <select size="1" name="plani_ziel">');
            while ($planeten = $db->fetchrow($planis)) {
                if ($planeten['building_11'] > 0) {
                    if ($game->planet['planet_id'] == $planeten['planet_id']) {
                        $game->out('<option value="' . encode_planet_id($planeten['planet_id']) . '" selected="selected">' . $planeten['planet_name'] . '</option>');
                    } else {
                        $game->out('<option value="' . encode_planet_id($planeten['planet_id']) . '">' . $planeten['planet_name'] . '</option>');
                    }
                }
            }
            $game->out('</select></td></tr>');
        }
        $game->out('<tr><td colspan="3" align="center"><input type="submit" value="' . constant($game->sprache("TEXT185")) . '"  name="submit" class="Button_nosize" disabled></td></tr>');
        $game->out('</table></form>');
    }
}
Example #4
0
</script>

<table class="style_outer" align="center" border="0" cellpadding="2" cellspacing="2" width="450"><tr><td>
<table class="style_inner" align="center" border="0" cellpadding="2" cellspacing="2" width="450">
  <form name="send_form" method="post" action="' . parse_link('a=ship_send') . '">
  <input type="hidden" name="dest" value="' . encode_planet_id($dest) . '">
        ');
        $fleet_option_html = '';
        for ($i = 0; $i < $n_fleets; ++$i) {
            $fleet_option_html .= '<option>' . $fleets[$i]['fleet_name'] . ' (' . $fleets[$i]['n_ships'] . ')</option>';
            $game->out('<input type="hidden" name="fleets[]" value="' . $fleets[$i]['fleet_id'] . '">');
        }
        $game->out('
  <tr>
    <td>
      ' . constant($game->sprache("TEXT28")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($start)) . '"><b>' . $start_planet['planet_name'] . '</b></a> (' . $game->get_sector_name($start_planet['sector_id']) . ':' . $game->get_system_cname($start_planet['system_x'], $start_planet['system_y']) . ':' . ($start_planet['planet_distance_id'] + 1) . ')' . ($start_planet['user_id'] != $game->player['user_id'] ? ' ' . constant($game->sprache("TEXT26")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $start_planet['user_id']) . '"><b>' . $start_planet['user_name'] . '</b></a>' : '') . '<br>
        ');
        if ($free_planet) {
            $game->out(constant($game->sprache("TEXT29")) . ' <i>' . constant($game->sprache("TEXT51")) . '</i> (' . $game->get_sector_name($dest_planet['sector_id']) . ':' . $game->get_system_cname($dest_planet['system_x'], $dest_planet['system_y']) . ':' . ($dest_planet['planet_distance_id'] + 1) . ')<br><br>');
        } else {
            $game->out(constant($game->sprache("TEXT29")) . $dest_str . '<br><br>');
        }
        $game->out('
      ' . constant($game->sprache("TEXT30")) . ' <select style="width: 200px;">' . $fleet_option_html . '</select><br><br>
      ' . constant($game->sprache("TEXT52")) . ' <b>' . $max_speed_str . '</b><br>
      ' . constant($game->sprache("TEXT53")) . ' ' . $min_stardate . '</b><br><br>
      ' . constant($game->sprache("TEXT31")) . ' <input class="field" style="width: 45px;" type="text" name="higher_arrival_stardate" value="' . $min_stardate_split[0] . '" maxlength="5" onBlur="return update_times();">&nbsp;.&nbsp;<input class="field" style="width: 15px;" type="text" name="lower_arrival_stardate" value="' . $min_stardate_split[1] . '" maxlength="1" onBlur="return update_times();">&nbsp;&nbsp;<input class="button" style="width: 20px;" type="button" value="+" onClick="return increment_arrival();"">&nbsp;<input class="button" style="width: 20px;" type="button" value="-" onClick="return decrement_arrival();"><br><br>
      ' . constant($game->sprache("TEXT54")) . ' <input class="field" style="width: 25px;" type="text" name="arrival_days" value="" disabled="disabled">&nbsp;<i>' . constant($game->sprache("TEXT55")) . '</i>&nbsp;&nbsp;<input class="field" style="width: 25px;" name="arrival_hours" value="" disabled="disabled">&nbsp;<i>' . constant($game->sprache("TEXT56")) . '</i>&nbsp;&nbsp;<input class="field" style="width: 25px;" name="arrival_minutes" value="" disabled="disabled">&nbsp;<i>' . constant($game->sprache("TEXT57")) . ' +</i>&nbsp;<i id="timer2" title="time1_' . $NEXT_TICK . '_type1_4">&nbsp;</i><br><br>

      <table width="440" align="center" border="0" cellpadding="0" cellspacing="0"><tr><td width="220">
        ');
function display_logbook($log)
{
    global $game, $BUILDING_NAME;
    $game->out('
<br>
<table align="center" border="0" cellpadding="2" cellspacing="2" class="style_outer">
  <tr>
    <td>
      <table align="center" border="0" cellpadding="2" cellspacing="2" class="style_inner">
        <tr>
          <td width="450">
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="450">
                  <table border=0 cellpadding=0 cellspacing=0>
                    <tr>
                      <td width="330" align="left"><b><u>' . $log['log_title'] . '</u></b></td>
                      <td width="120" align="right"><b>' . date('d.m.y H:i:s', $log['log_date']) . '</b></td>
                    </tr>
                  </table>
                  <br><br>');
    switch ($log['log_data'][4]) {
        case 0:
            $game->out('
                  ' . constant($game->sprache("TEXT168")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a>!<br><br>
                  ' . constant($game->sprache("TEXT169")) . '<i><b><a href="' . parse_link('a=ships&view=ship_details&id=' . $log['log_data'][2]) . '">' . $log['log_data'][3] . '</a></b></i>' . constant($game->sprache("TEXT170")) . ' 
                  ');
            break;
        case 1:
            $game->out('
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>');
            $game->out('<td width="65" valign="top">' . constant($game->sprache("TEXT33")) . '&nbsp;</td> <td width="385"><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>');
            $game->out(constant($game->sprache("TEXT158")) . ' ' . $log['log_data'][5]['user_mood']);
            $game->out('<br><br>');
            if (isset($log['log_data'][5]['toptenlist'][0])) {
                $game->out(constant($game->sprache("TEXT159")) . '<br><br>');
                foreach ($log['log_data'][5]['toptenlist'] as $other_user) {
                    $game->out('<b>' . $other_user['user_name'] . '</b> ' . constant($game->sprache("TEXT160")) . ' ' . $other_user['mood_value'] . '.<br>');
                }
            }
            $game->out('<br><br>');
            if (isset($log['log_data'][6]['research_1'])) {
                $game->out('Modifica Ambientale <b>aggiornabile</b>');
                if (isset($log['log_data'][6]['time_1'])) {
                    $game->out(', coda di lavoro disponibile tra: ' . $log['log_data'][6]['time_1']);
                }
                $game->out('<br>');
            }
            if (isset($log['log_data'][6]['research_2'])) {
                $game->out('Ricerche Mediche <b>aggiornabili</b>');
                if (isset($log['log_data'][6]['time_2'])) {
                    $game->out(', coda di lavoro disponibile tra: ' . $log['log_data'][6]['time_2']);
                }
                $game->out('<br>');
            }
            if (isset($log['log_data'][6]['research_3'])) {
                $game->out('Strutture Difensive <b>aggiornabili</b>');
                if (isset($log['log_data'][6]['time_3'])) {
                    $game->out(', coda di lavoro disponibile tra: ' . $log['log_data'][6]['time_3']);
                }
                $game->out('<br>');
            }
            if (isset($log['log_data'][6]['research_4'])) {
                $game->out('Automazione <b>aggiornabile</b>');
                if (isset($log['log_data'][6]['time_4'])) {
                    $game->out(', coda di lavoro disponibile tra: ' . $log['log_data'][6]['time_4']);
                }
                $game->out('<br>');
            }
            if (isset($log['log_data'][6]['research_5'])) {
                $game->out('Estrazione Risorse <b>aggiornabile</b>');
                if (isset($log['log_data'][6]['time_5'])) {
                    $game->out(', coda di lavoro disponibile tra: ' . $log['log_data'][6]['time_5']);
                }
                $game->out('<br>');
            }
            $game->out('</td></tr></table>');
            break;
        case 2:
            // log_data[5] = return code
            // log_data[6] = mood modifier
            switch ($log['log_data'][5]) {
                case -2:
                    $game->out(constant($game->sprache("TEXT166")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT157")));
                    break;
                case 0:
                    $game->out('
                    ' . constant($game->sprache("TEXT165")) . ' ' . $log['log_data'][6] . '.
                    ');
                    break;
            }
            break;
        case 3:
            // log_data[5] = return code
            // log_data[6] = mood modifier
            // log_data[7] = text, type of research undergoing
            // log_data[8] = text, research time to finish on planet
            $game->out(constant($game->sprache("TEXT33")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>');
            switch ($log['log_data'][5]) {
                case -6:
                    $game->out(constant($game->sprache("TEXT202")));
                    break;
                case -5:
                    $game->out(constant($game->sprache("TEXT178")));
                    break;
                case -4:
                    $game->out(constant($game->sprache("TEXT176")) . $log['log_data'][7] . '.<br><br>');
                    $game->out(constant($game->sprache("TEXT172")));
                    break;
                case -3:
                    $game->out(constant($game->sprache("TEXT176")) . $log['log_data'][7] . '.<br><br>');
                    $game->out(constant($game->sprache("TEXT173")));
                    break;
                case -2:
                    $game->out(constant($game->sprache("TEXT176")) . $log['log_data'][7] . '.<br><br>');
                    $game->out(constant($game->sprache("TEXT174")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT176")) . $log['log_data'][7] . '.<br><br>');
                    $game->out(constant($game->sprache("TEXT175")));
                    break;
                case 0:
                    $game->out(constant($game->sprache("TEXT176")) . $log['log_data'][7] . '.<br><br>');
                    $game->out(constant($game->sprache("TEXT171")) . $log['log_data'][6] . '.<br><br>
                    ' . constant($game->sprache("TEXT177")) . $log['log_data'][8] . '.');
                    break;
            }
            if (isset($log['log_data'][9][0])) {
                $game->out('<br><br>' . constant($game->sprache("TEXT201")) . '<br><table border=0 cellpadding=0 cellspacing=0>');
                foreach ($log['log_data'][9] as $text_string) {
                    $game->out($text_string);
                }
                $game->out('</table>');
            }
            break;
        case 4:
            $game->out(constant($game->sprache("TEXT33")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>');
            switch ($log['log_data'][5]) {
                case -2:
                    $game->out(constant($game->sprache("TEXT178")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT180")));
                    break;
                case 0:
                    $game->out(constant($game->sprache("TEXT179")) . $log['log_data'][6] . '.');
                    break;
            }
            if (isset($log['log_data'][7][0])) {
                $game->out('<br><br>' . constant($game->sprache("TEXT201")) . '<br><table border=0 cellpadding=0 cellspacing=0>');
                foreach ($log['log_data'][7] as $text_string) {
                    $game->out($text_string);
                }
                $game->out('</table>');
            }
            break;
        case 5:
            $game->out(constant($game->sprache("TEXT33")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>');
            switch ($log['log_data'][5]) {
                case -5:
                    $game->out(constant($game->sprache("TEXT219")));
                    break;
                case -4:
                    $game->out(constant($game->sprache("TEXT200")));
                    break;
                case -3:
                    $game->out(constant($game->sprache("TEXT189")));
                    break;
                case -2:
                    $game->out(constant($game->sprache("TEXT190")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT191")));
                    break;
                case 0:
                    $game->out(constant($game->sprache("TEXT192")));
                    break;
            }
            break;
        case 10:
            switch ($log['log_data'][5]) {
                case -7:
                    $game->out(constant($game->sprache("TEXT178")));
                    break;
                case -6:
                    $game->out(constant($game->sprache("TEXT210")));
                    break;
                case -5:
                    $game->out(constant($game->sprache("TEXT175")));
                    break;
                case -4:
                    $game->out(constant($game->sprache("TEXT193")));
                    break;
                case -3:
                    $game->out(constant($game->sprache("TEXT194")));
                    break;
                case -2:
                    $game->out(constant($game->sprache("TEXT195")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT199")));
                    break;
                case 0:
                    $game->out(constant($game->sprache("TEXT196")));
                    break;
                case 1:
                    $game->out(constant($game->sprache("TEXT196")));
                    break;
            }
            break;
        case 100:
            $game->out(constant($game->sprache("TEXT181")));
            break;
        case 101:
            // Settlers sends Troops
            $game->out('
                  ' . constant($game->sprache("TEXT168")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a>!<br><br>
                  ' . constant($game->sprache("TEXT182")));
            switch ($log['log_data'][5]) {
                case 0:
                    $game->out('<br><br>' . constant($game->sprache("TEXT211")));
                    break;
                case 1:
                    $game->out('<br><br>' . constant($game->sprache("TEXT212")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][6])) . '"><b>' . $log['log_data'][7] . '</b>.</a>');
                    break;
            }
            $game->out('<ul>');
            if (isset($log['log_data'][8]['ress_4']) && !empty($log['log_data'][8]['ress_4'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_worker_small.gif"> ' . $log['log_data'][8]['ress_4'] . '</li>');
            }
            if (isset($log['log_data'][8]['unit_1']) && !empty($log['log_data'][8]['unit_1'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_unit1_small.gif"> ' . $log['log_data'][8]['unit_1'] . '</li>');
            }
            if (isset($log['log_data'][8]['unit_2']) && !empty($log['log_data'][8]['unit_2'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_unit2_small.gif"> ' . $log['log_data'][8]['unit_2'] . '</li>');
            }
            if (isset($log['log_data'][8]['unit_5']) && !empty($log['log_data'][8]['unit_5'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_unit5_small.gif"> ' . $log['log_data'][8]['unit_5'] . '</li>');
            }
            if (isset($log['log_data'][8]['unit_6']) && !empty($log['log_data'][8]['unit_6'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_unit6_small.gif"> ' . $log['log_data'][8]['unit_6'] . '</li>');
            }
            $game->out('</ul>');
            break;
        case 102:
            // Settlers sends Resources
            $game->out('
                  ' . constant($game->sprache("TEXT168")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a>!<br><br>
                  ' . constant($game->sprache("TEXT183")));
            switch ($log['log_data'][5]) {
                case 0:
                    $game->out('<br><br>' . constant($game->sprache("TEXT213")) . '<br><br>');
                    break;
                case 1:
                    $game->out('<br><br>' . constant($game->sprache("TEXT214")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][6])) . '"><b>' . $log['log_data'][7] . '</b>.</a><br><br>');
                    break;
            }
            $game->out('<ul>');
            if (isset($log['log_data'][8]['ress_1']) && !empty($log['log_data'][8]['ress_1'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_metal_small.gif"> ' . number_format($log['log_data'][8]['ress_1'], 0, ',', '.') . '</li>');
            }
            if (isset($log['log_data'][8]['ress_2']) && !empty($log['log_data'][8]['ress_2'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_mineral_small.gif"> ' . number_format($log['log_data'][8]['ress_2'], 0, ',', '.') . '</li>');
            }
            if (isset($log['log_data'][8]['ress_3']) && !empty($log['log_data'][8]['ress_3'])) {
                $game->out('<li><img src="' . $game->GFX_PATH . 'menu_latinum_small.gif"> ' . number_format($log['log_data'][8]['ress_3'], 0, ',', '.') . '</li>');
            }
            $game->out('</ul>');
            break;
        case 103:
            // Automatic distress call for Borg attack
            $game->out('
                  ' . constant($game->sprache("TEXT184")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>
                  ' . constant($game->sprache("TEXT185")));
            break;
        case 104:
            // Distress call for Borg attack
            $game->out('
                  ' . constant($game->sprache("TEXT186")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>
                  ' . constant($game->sprache("TEXT187")));
            break;
        case 105:
            // Player conquer Settlers colony
            $game->out('
                  ' . constant($game->sprache("TEXT184")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>
                  ' . constant($game->sprache("TEXT188")) . $log['log_data'][6] . '.');
            break;
        case 106:
            // Player mission ambushed by Hirogen Hunters
            $game->out(constant($game->sprache("TEXT209")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>');
            switch ($log['log_data'][5]) {
                case -2:
                    $game->out(constant($game->sprache("TEXT208")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT207")));
                    break;
                case 0:
                    $game->out(constant($game->sprache("TEXT197")));
                    break;
                case 1:
                    $game->out(constant($game->sprache("TEXT198")));
                    break;
            }
            break;
        case 107:
            // Hirogeni Hunters reporting in
            $game->out(constant($game->sprache("TEXT209")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($log['log_data'][0])) . '"><b>' . $log['log_data'][1] . '</b></a><br><br>');
            switch ($log['log_data'][5]) {
                case -2:
                    $game->out(constant($game->sprache("TEXT203")));
                    break;
                case -1:
                    $game->out(constant($game->sprache("TEXT204")));
                    break;
                case 0:
                    $game->out(constant($game->sprache("TEXT205")));
                    break;
                case 1:
                    $game->out(constant($game->sprache("TEXT206")));
                    break;
            }
            break;
    }
    $game->out('</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
    ');
}
 <td>
   <table class="style_inner" width="400" align="center" border="0" cellpadding="4" cellspacing="2">
     <form name="load_form" method="post" action="' . parse_link('a=ship_fleets_loadingp&to=' . $fleet_id . ($return_to ? '&return_to=' . urlencode($return_to) : '')) . '" onSubmit="return document.load_form.submit_button.disabled = true;">
     <input type="hidden" name="to_submit" value="1">
     <tr>
       <td align="center">
         <table width="400" border="0" cellpadding="0" cellspacing="0">
           <tr>
             <td width="200" align="left"><b>' . $fleet['fleet_name'] . '</b></td>
             <td width="200" align="right">' . ($fleet['n_ships'] == 1 ? '<b>1</b> ' . constant($game->sprache("TEXT8")) : '<b>' . $fleet['n_ships'] . '</b> ' . constant($game->sprache("TEXT9"))) . '</td>
           </tr>
         </table><br>
         <table border="0" cellpadding="0" cellspacing="0">
           <tr>
             <td width="140">' . constant($game->sprache("TEXT33")) . '</td>
             <td width="260"><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($fleet['planet_id'])) . '"><b>' . $fleet['planet_name'] . '</b></a>' . ($fleet['owner_id'] != $game->player['user_id'] ? ' von <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $fleet['owner_id']) . '"><b>' . $fleet['owner_name'] . '</b></a>' : '') . '</td>
           </tr>
 ');
 if ($own_planet) {
     $game->out('
           <tr><td height="5"></td></tr>
           <tr>
             <td rowspan="5" width="140" valign="top">' . constant($game->sprache("TEXT34")) . '</td>
             <td width="260"><i>' . constant($game->sprache("TEXT16")) . '</i>: <b>' . ($fleet['max_presources'] - $fleet['presource_1']) . '</b></td>
           </tr>
           <tr><td><i>' . constant($game->sprache("TEXT17")) . '</i>: <b>' . ($fleet['max_presources'] - $fleet['presource_2']) . '</b></td></tr>
           <tr><td><i>' . constant($game->sprache("TEXT18")) . '</i>: <b>' . ($fleet['max_presources'] - $fleet['presource_3']) . '</b></td></tr>
           <tr><td><i>' . constant($game->sprache("TEXT19")) . '</i>: <b>' . ($fleet['max_pworker'] - $fleet['presource_4']) . '</b></td></tr>
           <tr><td><i>' . constant($game->sprache("TEXT35")) . '</i>: <b>' . ($fleet['max_punits'] - $fleet['punit_1'] * 2 - $fleet['punit_2'] * 3 - $fleet['punit_3'] * 4 - $fleet['punit_4'] * 4 - $fleet['unit_5'] * 4 - $fleet['unit_6'] * 4) . '</b></td></tr>
     ');
 }
function display_logbook($log)
{
    global $game, $db, $SHIP_TORSO, $RACE_DATA;
    $ldata = array('action_code' => $log['log_data'][0], 'user_id' => $log['log_data'][1], 'start' => $log['log_data'][2], 'start_planet_name' => $log['log_data'][3], 'start_owner_id' => $log['log_data'][4], 'dest' => $log['log_data'][5], 'dest_planet_name' => $log['log_data'][6], 'dest_owner_id' => $log['log_data'][7]);
    $sql = 'SELECT p.sector_id, s.system_x, s.system_y, p.planet_distance_id FROM planets p INNER JOIN starsystems s ON p.system_id = s.system_id WHERE p.planet_id = ' . $ldata['start'];
    if (($s_coord = $db->queryrow($sql)) === false) {
        message(DATABASE_ERROR, 'Could not query starsystem data');
    }
    $sql = 'SELECT p.sector_id, s.system_x, s.system_y, p.planet_distance_id FROM planets p INNER JOIN starsystems s ON p.system_id = s.system_id WHERE p.planet_id = ' . $ldata['dest'];
    if (($d_coord = $db->queryrow($sql)) === false) {
        message(DATABASE_ERROR, 'Could not query starsystem data');
    }
    $des_owner = $ldata['dest_owner_id'];
    $game->out('
<br>
<table width="450" align="center" border="0" cellpadding="2" cellspacing="2" class="style_outer"><tr><td>
<table width="450" align="center" border="0" cellpadding="2" cellspacing="2" class="style_inner">
  <tr><td>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="330"><b><u>' . $log['log_title'] . '</u></b></td>
        <td width="120"><b><b>' . date('d.m.y H:i:s', $log['log_date']) . '</b></td>
      </tr>
    </table>
    <br>
    ');
    $inter_planet = false;
    if ($ldata['dest'] == 0) {
        if (empty($ldata['start_owner_id'])) {
            $start_owner_str = ' ' . constant($game->sprache("TEXT29"));
        } elseif ($ldata['start_owner_id'] != $game->player['user_id']) {
            $start_owner = $game->uc_get($ldata['start_owner_id']);
            if (!$start_owner) {
                $start_owner_str = ' ' . constant($game->sprache("TEXT29"));
            } else {
                $start_owner_str = ' ' . constant($game->sprache("TEXT30")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['start_owner_id']) . '"><b>' . $start_owner . '</b></a>';
            }
        } else {
            $start_owner_str = '';
        }
        $game->out(constant($game->sprache("TEXT31")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($ldata['start'])) . '"><b>' . $ldata['start_planet_name'] . '</b></a>' . ' (' . $game->get_sector_name($s_coord['sector_id']) . ':' . $game->get_system_cname($s_coord['system_x'], $s_coord['system_y']) . ':' . ($s_coord['planet_distance_id'] + 1) . ') ' . $start_owner_str . '<br><br>');
        $inter_planet = true;
    } else {
        if (empty($ldata['start_owner_id'])) {
            $start_owner_str = ' ' . constant($game->sprache("TEXT29"));
        } elseif ($ldata['start_owner_id'] != $game->player['user_id']) {
            $start_owner = $game->uc_get($ldata['start_owner_id']);
            if (!$start_owner) {
                $start_owner_str = ' ' . constant($game->sprache("TEXT29"));
            } else {
                $start_owner_str = ' ' . constant($game->sprache("TEXT30")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['start_owner_id']) . '"><b>' . $start_owner . '</b></a>';
            }
        } else {
            $start_owner_str = '';
        }
        if (empty($ldata['dest_owner_id'])) {
            $dest_owner_str = ' ' . constant($game->sprache("TEXT29"));
        } elseif ($ldata['dest_owner_id'] != $game->player['user_id']) {
            $dest_owner = $game->uc_get($ldata['dest_owner_id']);
            if (!$dest_owner) {
                $dest_owner_str = ' ' . constant($game->sprache("TEXT29"));
            } else {
                $dest_owner_str = ' ' . constant($game->sprache("TEXT30")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['dest_owner_id']) . '"><b>' . $dest_owner . '</b></a>';
            }
        } else {
            $dest_owner_str = '';
        }
        $game->out('
	' . constant($game->sprache("TEXT32")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($ldata['start'])) . '"><b>' . $ldata['start_planet_name'] . '</b></a>' . ' (' . $game->get_sector_name($s_coord['sector_id']) . ':' . $game->get_system_cname($s_coord['system_x'], $s_coord['system_y']) . ':' . ($s_coord['planet_distance_id'] + 1) . ') ' . $start_owner_str . '<br>
	' . constant($game->sprache("TEXT33")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($ldata['dest'])) . '"><b>' . $ldata['dest_planet_name'] . '</b></a>' . ' (' . $game->get_sector_name($d_coord['sector_id']) . ':' . $game->get_system_cname($d_coord['system_x'], $d_coord['system_y']) . ':' . ($d_coord['planet_distance_id'] + 1) . ') ' . $dest_owner_str . '<br>
	<br>
		');
    }
    $str = '';
    switch ($ldata['action_code']) {
        case 11:
            // nothing to report
            break;
        case 12:
            $fleets =& $log['log_data'][8];
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">' . constant($game->sprache("TEXT35")) . '</td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT36")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT37")) . '</b></td>
      </tr>
            ');
            for ($i = 0; $i < count($fleets); ++$i) {
                $game->out('
      <tr>
        <td>' . $fleets[$i][1] . '</td>
        <td>' . $fleets[$i][2] . '</td>
      </tr>
                ');
            }
            $game->out('</table><br>');
            break;
        case 13:
            $fleets =& $log['log_data'][8];
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">' . constant($game->sprache("TEXT38")) . '</td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT36")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT37")) . '</b></td>
      </tr>
            ');
            for ($i = 0; $i < count($fleets); ++$i) {
                $game->out('
      <tr>
        <td>' . $fleets[$i][1] . '</td>
        <td>' . $fleets[$i][2] . '</td>
      </tr>
                ');
            }
            $game->out('</table><br>');
            break;
        case 21:
            // nothing to report
            break;
        case 22:
            if ($ldata['user_id'] == $game->player['user_id']) {
                $spy_report =& $log['log_data'][9];
                $n_spyed = count($spy_report[1]) + count($spy_report[2]) + count($spy_report[3]) + count($spy_report[4]) + count($spy_report[5]);
                $dest_race = $log['log_data'][10];
            }
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            if ($ldata['user_id'] == $game->player['user_id']) {
                if ($spy_report[0]) {
                    $game->out(constant($game->sprache("TEXT39")));
                } else {
                    $game->out(constant($game->sprache("TEXT40")));
                }
            } else {
                $game->out(constant($game->sprache("TEXT41")));
            }
            $game->out('
        </td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250">' . constant($game->sprache("TEXT42")) . '</td>
        <td width="200">' . $log['log_data'][8] . '</td>
      </tr>
    </table>
    <br>
            ');
            if ($n_spyed == 0) {
                $game->out(constant($game->sprache("TEXT43")));
                break;
            }
            $wares_names = get_wares_by_id($dest_race);
            if (count($spy_report[1]) > 0) {
                $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250"><b>' . constant($game->sprache("TEXT44")) . '</b></td>
        <td width="200"><b>' . constant($game->sprache("TEXT45")) . '</b></td>
      </tr>
                ');
                foreach ($spy_report[1] as $resource_id => $resorce_amount) {
                    $game->out('
      <tr>
        <td>' . $wares_names[$resource_id] . '</td>
        <td>' . $resorce_amount . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br>');
            }
            if (count($spy_report[2]) > 0) {
                $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250"><b>' . constant($game->sprache("TEXT46")) . '</b></td>
        <td width="200"><b>' . constant($game->sprache("TEXT45")) . '</b></td>
      </tr>
                ');
                foreach ($spy_report[2] as $unit_id => $unit_amount) {
                    $game->out('
      <tr>
        <td>' . $wares_names[$unit_id + 4] . '</td>
        <td>' . $unit_amount . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br>');
            }
            if (count($spy_report[3]) > 0) {
                $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250"><b>' . constant($game->sprache("TEXT47")) . '</b></td>
        <td width="200"><b>' . constant($game->sprache("TEXT48")) . '</b></td>
      </tr>
                ');
                global $BUILDING_NAME;
                foreach ($spy_report[3] as $building_id => $building_level) {
                    $game->out('
      <tr>
        <td>' . $BUILDING_NAME[$dest_race][$building_id] . '</td>
        <td>' . $building_level . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br>');
            }
            if (count($spy_report[4]) > 0) {
                $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250"><b>' . constant($game->sprache("TEXT49")) . '</b></td>
        <td width="200"><b>' . constant($game->sprache("TEXT48")) . '</b></td>
      </tr>
                ');
                global $TECH_NAME;
                foreach ($spy_report[4] as $tech_id => $tech_level) {
                    $game->out('
      <tr>
        <td>' . $TECH_NAME[$dest_race][$tech_id] . '</td>
        <td>' . $tech_level . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br>');
            }
            if (count($spy_report[5]) > 0) {
                $sql = 'SELECT name
                        FROM ship_ccategory
                        WHERE race = ' . $dest_race . '
                        ORDER BY id ASC
                        LIMIT 10';
                if (($ship_comps = $db->queryrowset($sql)) === false) {
                    message(DATABASE_ERROR, 'Could not query ship component category data');
                }
                $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250"><b>' . constant($game->sprache("TEXT50")) . '</b></td>
        <td width="200"><b>' . constant($game->sprache("TEXT48")) . '</b></td>
      </tr>
                ');
                foreach ($spy_report[5] as $scomp_id => $scomp_level) {
                    $game->out('
      <tr>
        <td>' . $ship_comps[$scomp_id]['name'] . '</td>
        <td>' . $scomp_level . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br>');
            }
            break;
        case 23:
            $ships =& $log['log_data'][8];
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            if ($inter_planet) {
                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT52")));
            } else {
                if ($ldata['user_id'] == $game->player['user_id']) {
                    $game->out(constant($game->sprache("TEXT53")));
                } else {
                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT52")));
                }
            }
            $game->out('
        </td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT54")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT55")) . '</b></td>
      </tr>
            ');
            for ($i = 0; $i < count($ships); ++$i) {
                $game->out('
      <tr>
        <td>' . $ships[$i][0] . ' (<i>' . $SHIP_TORSO[$ships[$i][2]][$ships[$i][1]][29] . '</i>, <i>' . $RACE_DATA[$ships[$i][2]][0] . '</i>)</td>
        <td>' . $ships[$i][3] . '</td>
      </tr>
                ');
            }
            $game->out('</table><br>');
            break;
        case 24:
        case 25:
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            switch ($log['log_data'][8]) {
                case -1:
                    $game->out(constant($game->sprache("TEXT56")));
                    break;
                case -2:
                    $game->out(constant($game->sprache("TEXT57")));
                    break;
                case -3:
                    $game->out(constant($game->sprache("TEXT152")));
                    break;
                case -4:
                    $game->out(constant($game->sprache("TEXT153")));
                    break;
                case 1:
                    $game->out(constant($game->sprache("TEXT58")));
                    break;
                case 2:
                    $game->out(constant($game->sprache("TEXT154")));
                    break;
                default:
                    $game->out('Illegal status code - report this as a bug');
                    break;
            }
            $game->out('
        </td>
      </tr>
    </table>
            ');
            if ($log['log_data'][8] == 1) {
                $game->out('
    <br>
    <b>' . constant($game->sprache("TEXT54")) . ':</b><br>
    ' . $log['log_data'][9] . '</a> (<i>' . $SHIP_TORSO[$log['log_data'][10]][SHIP_TYPE_COLO][29] . '</i>, <i>' . $RACE_DATA[$log['log_data'][10]][0] . '</i>)
    <br>
                ');
            }
            break;
        case 26:
            switch ($log['log_data'][11]) {
                case 0:
                    $text_1 = constant($game->sprache("TEXT149"));
                    $color1 = 'red';
                    break;
                case 1:
                    $text_1 = constant($game->sprache("TEXT150"));
                    $color1 = 'grey';
                    break;
                case 2:
                    $text_1 = constant($game->sprache("TEXT151"));
                    $color1 = 'green';
                    break;
            }
            switch ($log['log_data'][12]) {
                case 0:
                    $text_2 = constant($game->sprache("TEXT149"));
                    $color2 = 'red';
                    break;
                case 1:
                    $text_2 = constant($game->sprache("TEXT150"));
                    $color2 = 'grey';
                    break;
                case 2:
                    $text_2 = constant($game->sprache("TEXT151"));
                    $color2 = 'green';
                    break;
            }
            switch ($log['log_data'][13]) {
                case 0:
                    $text_3 = constant($game->sprache("TEXT149"));
                    $color3 = 'red';
                    break;
                case 1:
                    $text_3 = constant($game->sprache("TEXT150"));
                    $color3 = 'grey';
                    break;
                case 2:
                    $text_3 = constant($game->sprache("TEXT151"));
                    $color3 = 'green';
                    break;
            }
            $game->out($log['log_data'][8] . '<br><br>' . $log['log_data'][9] . '<br><br>
				<table border=0 cellpadding=0 cellspacing=0>
				<tr>
					<td align=left width=200>' . constant($game->sprache("TEXT146")) . '</td>
					<td align=left><font color=' . $color1 . '>' . $text_1 . '</font></td>
				</tr>
				<tr>
					<td align=left width=200>' . constant($game->sprache("TEXT147")) . '</td>
					<td align=left><font color=' . $color2 . '>' . $text_2 . '</font></td>
				</tr>
				<tr>
					<td align=left width=200>' . constant($game->sprache("TEXT148")) . '</td>
					<td align=left><font color=' . $color3 . '>' . $text_3 . '</font></td>
				</tr>
				</table>');
            break;
        case 27:
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            $t_a_data = $log['log_data'][8];
            switch ($t_a_data['mission_type']) {
                case 0:
                    switch ($t_a_data['mission_result']) {
                        case -1:
                            $game->out(constant($game->sprache("TEXT155")));
                            break;
                        case -2:
                            $game->out(constant($game->sprache("TEXT157")));
                            break;
                        case 1:
                            $game->out(constant($game->sprache("TEXT156")));
                            break;
                        default:
                            $game->out('Illegal status code - report this as a bug');
                            break;
                    }
                    break;
                case 1:
                    $game->out(constant($game->sprache("TEXT158")) . ' ' . $t_a_data['user_mood']['value']);
                    if (isset($t_a_data['user_mood']['alliance']) || isset($t_a_data['user_mood']['race'])) {
                        if (!empty($t_a_data['user_mood']['alliance'])) {
                            $game->out('<br>.... ' . constant($game->sprache("TEXT163")) . ' ' . $t_a_data['user_mood']['alliance'] . '.');
                        }
                        if (!empty($t_a_data['user_mood']['race'])) {
                            $game->out('<br>.... ' . constant($game->sprache("TEXT164")) . ' ' . $t_a_data['user_mood']['race'] . '.');
                        }
                    }
                    $game->out('<br><br>');
                    if (isset($t_a_data['toptenlist'][0])) {
                        $game->out(constant($game->sprache("TEXT159")) . '<br><br>');
                        foreach ($t_a_data['toptenlist'] as $other_user) {
                            $game->out('<b>' . $other_user['user_name'] . '</b> ' . constant($game->sprache("TEXT160")) . ' ' . $other_user['mood_value'] . '.<br>');
                        }
                    }
                    break;
            }
            $game->out('
        </td>
      </tr>
    </table>
            ');
            break;
        case 31:
            $ships =& $log['log_data'][8];
            $wares =& $log['log_data'][9];
            $planet_overloaded = $log['log_data'][10];
            $push = $log['log_data'][11];
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            if (!$push) {
                if ($ldata['user_id'] == $game->player['user_id']) {
                    $game->out(constant($game->sprache("TEXT59")) . ($planet_overloaded ? ' ' . constant($game->sprache("TEXT60")) : ''));
                } else {
                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT61")) . ($planet_overloaded ? ' ' . constant($game->sprache("TEXT62")) : ''));
                }
                $game->out('
        </td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT54")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT55")) . '</b></td>
      </tr>
            ');
                for ($i = 0; $i < count($ships); ++$i) {
                    $game->out('
      <tr>
        <td>' . $ships[$i][0] . ' (<i>' . $SHIP_TORSO[$ships[$i][2]][$ships[$i][1]][29] . '</i>, <i>' . $RACE_DATA[$ships[$i][2]][0] . '</i>)</td>
        <td>' . $ships[$i][3] . '</td>
      </tr>
                ');
                }
                $game->out('
	</table>
	<br>
	<table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT63")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT64")) . '</b></td>
      </tr>
		   ');
                $wares_names = get_wares_by_id();
                for ($i = 0; $i < count($wares_names); ++$i) {
                    if ($wares[$i] > 0) {
                        $game->out('
	  <tr>
		<td>' . $wares_names[$i] . '</td>
		<td>' . $wares[$i] . '</td>
	  </tr>
				   ');
                    }
                }
                $game->out('</table><br>');
            } else {
                if ($ldata['user_id'] == $game->player['user_id']) {
                    $game->out(constant($game->sprache("TEXT65")));
                } else {
                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT66")));
                }
                $game->out('
            </td>
          </tr>
        </table>
        <br> ');
            }
            break;
        case 32:
            message(GENERAL, 'Fake fleets should not report a log entry', 'Entered $action == 32 case');
            break;
        case 33:
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">' . constant($game->sprache("TEXT67")) . '</td>
      </tr>
    </table>
    <br>
    <b>' . constant($game->sprache("TEXT54")) . ':</b><br>
    <a href="' . parse_link('a=ship_fleets_ops&ship_details=' . $log['log_data'][8]) . '">' . $log['log_data'][9] . '</a> (<i>' . $SHIP_TORSO[$log['log_data'][11]][$log['log_data'][10]][29] . '</i>, <i>' . $RACE_DATA[$log['log_data'][11]][0] . '</i>)
    <br>
            ');
            break;
        case 34:
            $ships =& $log['log_data'][8];
            $unloaded_wares =& $log['log_data'][9];
            $loaded_wares =& $log['log_data'][10];
            $planet_overloaded = $log['log_data'][11];
            // Shows communication of the action
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            if ($ldata['user_id'] == $game->player['user_id']) {
                $game->out(constant($game->sprache("TEXT59")) . ($planet_overloaded ? ' ' . constant($game->sprache("TEXT60")) : ''));
            } else {
                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT61")) . ($planet_overloaded ? ' ' . constant($game->sprache("TEXT62")) : ''));
            }
            // Shows number and type of ships involved
            $game->out('
        </td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT54")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT55")) . '</b></td>
      </tr>
            ');
            for ($i = 0; $i < count($ships); ++$i) {
                $game->out('
      <tr>
        <td>' . $ships[$i][0] . ' (<i>' . $SHIP_TORSO[$ships[$i][2]][$ships[$i][1]][29] . '</i>, <i>' . $RACE_DATA[$ships[$i][2]][0] . '</i>)</td>
        <td>' . $ships[$i][3] . '</td>
      </tr>
                ');
            }
            // Shows unloaded goods
            $game->out('
	</table>
	<br>
	<table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT63")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT64")) . '</b></td>
      </tr>
		   ');
            $wares_names = get_wares_by_id();
            for ($i = 0; $i < count($wares_names); ++$i) {
                if ($unloaded_wares[$i] > 0) {
                    $game->out('
	  <tr>
		<td>' . $wares_names[$i] . '</td>
		<td>' . $unloaded_wares[$i] . '</td>
	  </tr>
				   ');
                }
            }
            // Shows loaded goods
            $game->out('
	</table>
	<br>
	<table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT63")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT64a")) . '</b></td>
      </tr>
		   ');
            $wares_names = get_wares_by_id();
            for ($i = 0; $i < count($wares_names); ++$i) {
                if ($loaded_wares[$i] > 0) {
                    $game->out('
	  <tr>
		<td>' . $wares_names[$i] . '</td>
		<td>' . $loaded_wares[$i] . '</td>
	  </tr>
				   ');
                }
            }
            $game->out('</table><br>');
            break;
        case 40:
        case 41:
        case 42:
        case 46:
        case 51:
        case 54:
        case 99:
        case 55:
            $text =& $log['log_data'][10];
            $a_fleets =& $log['log_data'][12];
            $d_fleets =& $log['log_data'][13];
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            if ($ldata['action_code'] == 99) {
                if ($log['log_data'][9]) {
                    $game->out(constant($game->sprache("TEXT68")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT69")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $log['log_data'][4]) . '"><b>' . $game->uc_get($log['log_data'][4]) . '</b></a> ' . constant($game->sprache("TEXT70")));
                } else {
                    $game->out(constant($game->sprache("TEXT68")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT69")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $log['log_data'][4]) . '"><b>' . $game->uc_get($log['log_data'][4]) . '</b></a> ' . constant($game->sprache("TEXT71")));
                }
            }
            if (isset($log['log_data'][16]) && $ldata['action_code'] != 99) {
                if ($log['log_data'][9]) {
                    $game->out(constant($game->sprache("TEXT72")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT73")));
                } else {
                    $game->out(constant($game->sprache("TEXT72")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT74")));
                }
            } else {
                switch ($ldata['action_code']) {
                    case 40:
                        if ($log['log_data'][8] == CWIN_ATTACKER) {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT75")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT76")));
                            } else {
                                $game->out(constant($game->sprache("TEXT75")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT77")));
                            }
                        } else {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT78")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $log['log_data'][15]) . '"><b>' . $game->uc_get($log['log_data'][15]) . '</b></a> ' . constant($game->sprache("TEXT79")));
                            } else {
                                $game->out(constant($game->sprache("TEXT78")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $log['log_data'][15]) . '"><b>' . $game->uc_get($log['log_data'][15]) . '</b></a> ' . constant($game->sprache("TEXT80")));
                            }
                        }
                        break;
                    case 41:
                        if ($log['log_data'][8] == CWIN_ATTACKER) {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT81")));
                            } else {
                                $game->out(constant($game->sprache("TEXT82")));
                            }
                        } else {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a>, ' . constant($game->sprache("TEXT83")));
                            } else {
                                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT84")));
                            }
                        }
                        break;
                    case 42:
                        if ($log['log_data'][8] == CWIN_ATTACKER) {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT85")));
                            } else {
                                $game->out(constant($game->sprache("TEXT82")));
                            }
                        } else {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a>, ' . constant($game->sprache("TEXT83")));
                            } else {
                                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT86")));
                            }
                        }
                        break;
                    case 46:
                        if ($log['log_data'][8] == CWIN_ATTACKER && !$log['log_data'][9]) {
                            $game->out('lose all');
                        } elseif ($log['log_data'][8] == CWIN_DEFENDER && $log['log_data'][9]) {
                            $game->out(constant($game->sprache("TEXT87")));
                        }
                        switch ($log['log_data'][17]) {
                            // Colony ship not found
                            case -2:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out('win fight, no colo ship');
                                } else {
                                    $game->out(constant($game->sprache("TEXT88")));
                                }
                                break;
                                // Attacker has lost ground battle
                            // Attacker has lost ground battle
                            case -1:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out('win fight, lose infantery');
                                } else {
                                    $game->out(constant($game->sprache("TEXT89")));
                                }
                                break;
                                // Colonization was successful
                            // Colonization was successful
                            case 1:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out('win all');
                                } else {
                                    $game->out(constant($game->sprache("TEXT90")));
                                }
                                break;
                        }
                        break;
                    case 51:
                        if ($log['log_data'][8] == CWIN_ATTACKER) {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT91")));
                            } else {
                                $game->out(constant($game->sprache("TEXT92")));
                            }
                        } else {
                            if ($log['log_data'][9]) {
                                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a>, ' . constant($game->sprache("TEXT83")));
                            } else {
                                $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT93")));
                            }
                        }
                        break;
                    case 54:
                        if ($log['log_data'][8] == CWIN_ATTACKER && !$log['log_data'][9]) {
                            $game->out(constant($game->sprache("TEXT92")));
                        } elseif ($log['log_data'][8] == CWIN_DEFENDER && $log['log_data'][9]) {
                            $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a>, ' . constant($game->sprache("TEXT83")));
                        }
                        switch ($log['log_data'][17]) {
                            // No planetary weapons were available
                            case -3:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT94")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT93")));
                                }
                                break;
                            case -2:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT95")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT96")));
                                }
                                break;
                            case -1:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT97")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT93")));
                                }
                                break;
                            case 1:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT98")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT99")));
                                }
                                break;
                            case 2:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT100")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT101")));
                                }
                                break;
                        }
                        break;
                    case 55:
                        if ($log['log_data'][8] == CWIN_ATTACKER && !$log['log_data'][9]) {
                            $game->out(constant($game->sprache("TEXT92")));
                        } elseif ($log['log_data'][8] == CWIN_DEFENDER && $log['log_data'][9]) {
                            $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a>, ' . constant($game->sprache("TEXT83")));
                        }
                        switch ($log['log_data'][17]) {
                            // Colony ship not found
                            case -2:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT102")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT93")));
                                }
                                break;
                                // Attacker has lost ground battle
                            // Attacker has lost ground battle
                            case -1:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT103")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT104")));
                                }
                                break;
                                // Colonization was successful
                            // Colonization was successful
                            case 1:
                                if ($log['log_data'][8] == CWIN_ATTACKER) {
                                    $game->out(constant($game->sprache("TEXT105")));
                                } else {
                                    $game->out(constant($game->sprache("TEXT51")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $ldata['user_id']) . '"><b>' . $game->uc_get($ldata['user_id']) . '</b></a> ' . constant($game->sprache("TEXT106")));
                                }
                                break;
                        }
                        break;
                }
            }
            $game->out('
        </td>
      </tr>
    </table> <br><br>');
            if (count($a_fleets) <= 0) {
                $game->out(constant($game->sprache("TEXT107")));
            } else {
                $game->out('
    <b>' . constant($game->sprache("TEXT108")) . '</b><br>
    <table border="0" cellpadding="1" cellspacing="1">
      <tr>
        <td width="100"><b>' . constant($game->sprache("TEXT109")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT110")) . '</b></td>
        <td width="50"><b>' . constant($game->sprache("TEXT37")) . '</b></td>
      </tr>
                ');
                for ($i = 0; $i < count($a_fleets); $i++) {
                    $game->out('
      <tr>
        <td>' . $a_fleets[$i]['fleet_name'] . '</td>
        <td>' . $a_fleets[$i]['owner_name'] . '</td>
        <td>' . $a_fleets[$i]['n_ships'] . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br><br>');
            }
            if (count($d_fleets) <= 0) {
                $game->out(constant($game->sprache("TEXT111")));
            } else {
                $game->out('
    <b>' . constant($game->sprache("TEXT112")) . '</b><br>
    <table border="0" cellpadding="1" cellspacing="1">
      <tr>
        <td width="100"><b>' . constant($game->sprache("TEXT109")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT110")) . '</b></td>
        <td width="50"><b>' . constant($game->sprache("TEXT37")) . '</b></td>
      </tr>
                ');
                for ($i = 0; $i < count($d_fleets); ++$i) {
                    $game->out('
      <tr>
        <td>' . $d_fleets[$i]['fleet_name'] . '</td>
        <td>' . $d_fleets[$i]['owner_name'] . '</td>
        <td>' . $d_fleets[$i]['n_ships'] . '</td>
      </tr>
                    ');
                }
                $game->out('</table><br><br>');
            }
            $game->out('
<br><table border="0" cellpadding="0" cellspacing="0"><tr><td>' . $text . '</td></tr></table>');
            switch ($ldata['action_code']) {
                case 44:
                case 54:
                    global $BUILDING_NAME, $NUM_BUILDING;
                    if (!isset($log['log_data'][18])) {
                        $game->out(constant($game->sprache("TEXT113")));
                    } elseif (array_sum($log['log_data'][18]) == 0) {
                        $game->out(constant($game->sprache("TEXT113")));
                    } else {
                        //Beginning troops bombs
                        $game->out('<table border="0" cellpadding="2" cellspacing="2">
       <tr><td width="200"><b>' . constant($game->sprache("TEXT46")) . '</b></td>
        <td width="150"><b>' . constant($game->sprache("TEXT114")) . '</b></td></tr>');
                        global $UNIT_NAME;
                        $game->out('<tr><td width="200">' . constant($game->sprache("TEXT115")) . '</td><td width="150">' . $log['log_data'][18][0] . '</td></tr>');
                        $truppen_bomben = 0;
                        for ($i = 13; $i < 19; ++$i) {
                            if ($log['log_data'][18][$i] > 0) {
                                $game->out('<tr><td width="200">' . $UNIT_NAME[$game->player['user_race']][$truppen_bomben] . '</td>
        <td width="150">' . $log['log_data'][18][$i] . '</td></tr>');
                            }
                            $truppen_bomben++;
                        }
                        //End troops bombs
                        $game->out('
    <tr><td><br></td><td></td></tr>
      <tr>
        <td width="200"><b>' . constant($game->sprache("TEXT116")) . '</b></td>
        <td width="150"><b>' . constant($game->sprache("TEXT48")) . '</b></td>
      </tr>
                         ');
                        // $NUM_BUILDING = the largest index
                        for ($i = 1; $i <= $NUM_BUILDING; ++$i) {
                            if ($log['log_data'][18][$i] > 0) {
                                $game->out('
      <tr>
        <td>' . $BUILDING_NAME[$log['log_data'][19]][$i - 1] . '</td>
        <td>-' . $log['log_data'][18][$i] . '</td>
      </tr>
                                 ');
                            }
                        }
                        $game->out('</table><br>');
                    }
                    if ($log['log_data'][20][0] > 0) {
                        $game->out('
							    <table border="0" cellpadding="2" cellspacing="2">
							      <tr>
							        <td width="200"><b>' . constant($game->sprache("TEXT117")) . '</b></td>
							        <td width="150"><b>' . constant($game->sprache("TEXT55")) . '</b></td>
							      </tr>
                         ');
                        global $UNIT_NAME;
                        for ($i = 0; $i < 4; $i++) {
                            if ($log['log_data'][20][$i] > 0) {
                                $game->out('
									      <tr>
									        <td>' . $UNIT_NAME[6][$i] . '</td>
									        <td>-' . $log['log_data'][20][$i] . '</td>
									      </tr>
                                 ');
                            }
                        }
                        $game->out('</table><br>');
                    }
                    break;
                case 45:
                case 46:
                case 55:
                    if (isset($log['log_data'][18])) {
                        if (array_sum($log['log_data'][18]) == 0) {
                            $game->out(constant($game->sprache("TEXT118")));
                        } else {
                            $game->out('
    <table border="0" cellpadding="2" cellspacing="2">
      <tr>
        <td width="215"><b>' . constant($game->sprache("TEXT46")) . '</b></td>
        <td width="150"><b>' . constant($game->sprache("TEXT119")) . '</b></td>
      </tr>
                            ');
                            global $UNIT_NAME;
                            for ($i = 0; $i < 4; ++$i) {
                                $game->out('
      <tr>
        <td>' . $UNIT_NAME[$game->player['user_race']][$i] . '</td>
        <td>' . $log['log_data'][18][$i] . '</td>
      </tr>
                                ');
                            }
                            if (isset($log['log_data'][18][4])) {
                                $game->out('
      <tr>
        <td><i>' . constant($game->sprache("TEXT115")) . '</i></td>
        <td>' . $log['log_data'][18][4] . '</td>
      </tr>
                                ');
                            }
                            $game->out('</table><br>');
                        }
                    }
                    if (isset($log['log_data'][19])) {
                        if (array_sum($log['log_data'][19]) == 0) {
                            $game->out(constant($game->sprache("TEXT118a")));
                        } else {
                            $game->out('
    <table border="0" cellpadding="2" cellspacing="2">
      <tr>
        <td width="215"><b>' . constant($game->sprache("TEXT46")) . '</b></td>
        <td width="150"><b>' . constant($game->sprache("TEXT119")) . '</b></td>
      </tr>
                            ');
                            global $UNIT_NAME;
                            for ($i = 0; $i < 4; ++$i) {
                                $game->out('
      <tr>
        <td>' . $UNIT_NAME[$log['log_data'][20]][$i] . '</td>
        <td>' . $log['log_data'][19][$i] . '</td>
      </tr>
                                ');
                            }
                            if (isset($log['log_data'][19][4])) {
                                $game->out('
      <tr>
        <td><i>' . constant($game->sprache("TEXT115")) . '</i></td>
        <td>' . $log['log_data'][19][4] . '</td>
      </tr>
                                ');
                            }
                            $game->out('</table><br>');
                        }
                    }
                    break;
            }
            break;
        case 100:
            // AY-Fleet Report
            $game->out('
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="65" valign="top"><b>' . constant($game->sprache("TEXT34")) . '&nbsp;</b></td>
        <td width="385">
            ');
            $game->out(constant($game->sprache("TEXT215")) . '<a href="' . parse_link('a=ship_fleets_display&pfleet_details=' . $log['log_data'][8]) . '"> <b>' . $log['log_data'][9] . '</b></a> ' . constant($game->sprache("TEXT216")) . '<a href="' . parse_link('a=stats&a2=viewplayer&id=' . $log['log_data'][1]) . '">  <b>' . $log['log_data'][12] . '</b> </a> ' . constant($game->sprache("TEXT217")) . '<b>' . $log['log_data'][6] . '</b>. ' . constant($game->sprache("TEXT218")));
            $game->out('
        </td>
      </tr>
    </table>
    <br>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350"><b>' . constant($game->sprache("TEXT54")) . '</b></td>
        <td width="100"><b>' . constant($game->sprache("TEXT55")) . '</b></td>
      </tr>
            ');
            foreach ($log['log_data'][11] as $ship_report) {
                $game->out('
      <tr>
        <td>' . $ship_report['name'] . ' (<i>' . $SHIP_TORSO[$ship_report['race']][$ship_report['ship_torso']][29] . '</i>, <i>' . $RACE_DATA[$ship_report['race']][0] . '</i>)</td>
        <td>' . $ship_report['n_ships'] . '</td>
      </tr>
                ');
            }
            $game->out('</table><br>');
            break;
        default:
            message(GENERAL, 'Unknown action code in logbook_tactical.php', '$ldata[\'action_data\'] = ' . $ldata['action_code']);
            break;
    }
    $game->out('</td></tr>
</table>
</td>
</tr>
</table>
<br>
    ');
}
            <b>' . $RACE_DATA[$ship['race']][0] . '</b><br><br>

            <b>' . $ship['ship_name'] . '</b><br>

            <b>' . $ship['ship_ncc'] . '</b><br>

            <b>' . date('d/m/y H:i:s', $ship['construction_time']) . '</b><br><br>

            <b>' . (!empty($ship['last_refit_time']) ? date('d/m/y H:i:s', $ship['last_refit_time']) : constant($game->sprache("TEXT58"))) . '</b><br>

            <b>(' . $ship['hitpoints'] . '</b> / <b>' . $ship['value_5'] . ')</b> + <b><span style="color: yellow">' . $buff_value_5 . '</span></b><br>

            <b>' . $ship['value_4'] . ' + <span style="color: yellow">' . $buff_value_4 . '</span></b><br><br>

            <b>' . (intval($ship['awayteam']) == 0 ? ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($ship['awayteamplanet_id'])) . '"><b>' . $ship['mission_planet_name'] . '</b></a> ' : intval($ship['awayteam'])) . '</b><br><br>

            <b><span style="color: yellow">' . $ship['experience'] . '</span></b> <img src="' . $game->GFX_PATH . 'rank_' . $rank_nr . '.jpg" width="47" height="12"><br><br>

            <b>(' . ($ship['value_1'] + $buff_value_1) . ' + <span style="color: yellow">' . round(($ship['value_1'] + $buff_value_1) * $ship_rank_bonus[$rank_nr - 1], 0) . '</span>)</b> x<b><span style="color: yellow">' . $rof . '</span></b><br>

            <b>(' . ($ship['value_2'] + $buff_value_2) . ' + <span style="color: yellow">' . round(($ship['value_2'] + $buff_value_2) * $ship_rank_bonus[$rank_nr - 1], 0) . '</span>)</b> x<b><span style="color: yellow">' . $rof2 . '</span></b><br>

            <b>' . ($ship['value_3'] + $buff_value_3) . ' + <span style="color: yellow">' . round(($ship['value_3'] + $buff_value_3) * $ship_rank_bonus[$rank_nr - 1], 0) . '</span></b><br>

            <b>' . $ship['torp'] . ' / ' . $ship['max_torp'] . '</b><br><br>

            <b>' . ($ship['value_6'] + $buff_value_6) . ' + <span style="color: yellow">' . round(($ship['value_6'] + $buff_value_6) * $ship_rank_bonus[$rank_nr - 1], 0) . '</span></b><br>

            <b>' . $ship['value_7'] . ' + <span style="color: yellow">' . round($ship['value_7'] * $ship_rank_bonus[$rank_nr - 1], 0) . '</span></b><br>
             VALUES (' . $game->player['user_id'] . ', 0, 0, ' . $planet_id . ', ' . $planet_id . ', 0, 0, 0, ' . $ACTUAL_TICK . ', ' . ($ACTUAL_TICK + 1) . ', ' . $n_ships . ', 24, "' . serialize(array($ship_id, $is_terraform, $is_settler)) . '")';
     if (!$db->query($sql)) {
         message(DATABASE_ERROR, 'Could not insert new movement data');
     }
     $new_move_id = $db->insert_id();
     if (empty($new_move_id)) {
         message(GENERAL, 'Could not obtain new move id', '$new_move_id = empty');
     }
     $sql = 'UPDATE ship_fleets
             SET planet_id = 0,
                 move_id = ' . $new_move_id . '
             WHERE fleet_id IN (' . implode(',', $fleet_ids) . ')';
     if (!$db->query($sql)) {
         message(DATABASE_ERROR, 'Could not update fleets location data');
     }
     redirect('a=tactical_cartography&planet_id=' . encode_planet_id($planet_id));
     break;
 case 'colo_setup':
     if ($game->SITTING_MODE) {
         message(NOTICE, constant($game->sprache("TEXT52")));
     }
     if ($atkptc_present) {
         message(NOTICE, constant($game->sprache("TEXT53")));
     }
     if (!$free_planet) {
         message(NOTICE, constant($game->sprache("TEXT54")));
     }
     if (!$planetary_dest) {
         message(NOTICE, constant($game->sprache("TEXT55")));
     }
     if (!$in_colo) {
Example #10
0
    for ($i = 0; $i < $rows; $i++) {
        $game->out('<tr>');
        // Name
        $game->out('<td width="20%"><a href="' . parse_link('a=settlers&detail=' . encode_planet_id($sett_diplo[$i]['planet_id'])) . '">' . $sett_diplo[$i]['planet_name'] . '</a></td>');
        // Position
        $game->out('<td width="20%"><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($sett_diplo[$i]['planet_id'])) . '">' . $game->get_sector_name($sett_diplo[$i]['sector_id']) . ':' . $game->get_system_cname($sett_diplo[$i]['system_x'], $sett_diplo[$i]['system_y']) . ':' . ($sett_diplo[$i]['planet_distance_id'] + 1) . '</a></td>');
        // Class
        $game->out('<td width="10%">' . strtoupper($sett_diplo[$i]['planet_type']) . '</td>');
        // Mood
        $game->out('<td width="20%"><span style="color: ' . ($game->player['user_id'] == $sett_diplo[$i]['best_mood_user'] || $sett_diplo[$i]['mood'] > $sett_diplo[$i]['best_mood'] ? 'green' : 'red') . '">' . $sett_diplo[$i]['mood'] . '</span></td>');
        // Linked planet
        if ($sett_diplo[$i]['best_mood_user'] == $game->player['user_id']) {
            $game->out('<td><table width="100%" border="0" cellpadding="0" cellspacing="1"><tr>');
            is_null($sett_diplo[$i]['best_mood_planet']) ? $_linked_planet = constant($game->sprache("TEXT15")) : ($_linked_planet = $sett_diplo[$i]['target_planet_name']);
            is_null($sett_diplo[$i]['best_mood_planet']) ? $txt_button = constant($game->sprache("TEXT16")) : ($txt_button = constant($game->sprache("TEXT17")));
            $game->out('<td width="70%" align="left">' . $_linked_planet . '</td><td width="30%" align="right"><input class="Button_nosize" onclick="document.controller.data1.value=\'' . encode_planet_id($sett_diplo[$i]['planet_id']) . '\'; document.controller.data2.value=\'' . $txt_button . '\'" type="submit" name="switch_button" value="' . $txt_button . '"></td>');
            $game->out('</tr></table>');
        } else {
            $game->out('<td align="left">------------</td>');
        }
        $game->out('</tr>');
    }
    $game->out('
  </table></td></tr></form></table>
    ');
} elseif ($sub_action == constant($game->sprache("TEXT30"))) {
    // New Settlers Colony Detail panel
    $watch_on_planet = false;
    // Step 1: Loading planet
    $sql = 'SELECT planet_name
            FROM planets 
         $sql = 'SELECT timestamp FROM starsystems_details sd INNER JOIN planets p USING ( system_id )
                 WHERE p.planet_id = ' . $fleet['dest'] . ' AND sd.user_id = ' . $game->player['user_id'];
         if (($_temp = $db->queryrow($sql)) == true && !empty($_temp['timestamp'])) {
             $system_known = true;
         }
     }
     if ($system_known) {
         $dest_name = addslashes($fleet['dest_planet_name']);
         $dest_owner = !empty($fleet['dest_owner_id']) ? constant($game->sprache("TEXT72")) . ' <b>' . $fleet['dest_owner_name'] . '</b>' : constant($game->sprache("TEXT73"));
         $dest_class = strtoupper($fleet['dest_planet_type']);
     } else {
         $dest_name = '&#171;' . constant($game->sprache("TEXT56")) . '&#187;';
         $dest_owner = constant($game->sprache("TEXT72")) . ' <b>&#171;' . constant($game->sprache("TEXT56")) . '&#187;</b>';
         $dest_class = '&#171;' . constant($game->sprache("TEXT77")) . '&#187;';
     }
     $dest_planet_str = overlib($game->get_sector_name($fleet['dest_sector_id']) . ':' . $game->get_system_cname($fleet['dest_system_x'], $fleet['dest_system_y']) . ':' . ($fleet['dest_distance_id'] + 1), '<b>' . $dest_name . '</b><br>' . $dest_owner . '<br>' . constant($game->sprache("TEXT74")) . ' <b>' . $dest_class . '</b>', parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($fleet['dest'])));
     $ticks_left = $fleet['move_finish'] - $ACTUAL_TICK;
     if ($ticks_left < 0) {
         $ticks_left = 0;
     }
     $location_str = $start_planet_str . ' -> ' . $dest_planet_str . ' (' . ($i < 10 ? '<b id="timer' . $i . '" title="time1_' . ($ticks_left * TICK_DURATION * 60 + $NEXT_TICK) . '_type2_2">&nbsp;</b>' : '<b>' . format_time($ticks_left * TICK_DURATION) . '</b>') . ')';
     ++$i;
 } else {
     $sql = 'UPDATE ship_fleets
             SET planet_id = ' . $game->player['user_capital'] . ',
                 move_id = 0
             WHERE fleet_id = ' . $fleet['fleet_id'];
     if (!$db->query($sql)) {
         message(DATABASE_ERROR, 'Could not update fleets location data');
     }
     $INVALID_FLEET_POSITION = true;
    $attacked_user = array($move['dest_user_id'], $move['dest_user_name'], $move['dest_alliance_id'], $move['dest_alliance_tag']);
    // With 51 also a free fleet could be attacked
    if ($move['action_code'] == 51) {
        $action_data = (array) unserialize($move['action_data']);
        if (!empty($action_data[0])) {
            $user_id = (int) $action_data[0];
            $sql = 'SELECT u.user_id, u.user_name,
                           a.alliance_id, a.alliance_tag
                    FROM (user u)
                    LEFT JOIN (alliance a) ON a.alliance_id = u.user_alliance
                    WHERE u.user_id = ' . $user_id;
            if (($user = $db->queryrow($sql)) === false) {
                message(DATABASE_ERROR, 'Could not query user/alliance data');
            }
            if (!empty($user['user_id'])) {
                $attacked_user = array($user_id, $user['user_name'], $user['alliance_id'], $user['alliance_tag']);
            }
        }
    }
    $game->out('
    <tr>
      <td><a href="' . parse_link('a=stats&a2=viewplayer&id=' . $move['start_user_id']) . '">' . $move['start_user_name'] . '</a></td>
      <td><a href="' . parse_link('a=stats&a2=viewplayer&id=' . $attacked_user[0]) . '">' . $attacked_user[1] . '</a>' . (!empty($attacked_user[2]) ? ' [<a href="' . parse_link('a=stats&a2=viewalliance&id=' . $attacked_user[2]) . '">' . $attacked_user[3] . '</a>]' : '') . '</td>
      <td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['dest'])) . '">' . $move['dest_planet_name'] . '</a></td>
      <td>' . $move['n_ships'] . '</td>
      <td>' . $commands[$move['action_code']] . '</td>
      <td>' . format_time(($move['move_finish'] - $ACTUAL_TICK) * TICK_DURATION) . '</td>
    </tr>
    ');
}
$game->out('</table></td></tr></table><br></td></tr></table>');
Example #13
0
function Show_Settlers()
{
    global $db;
    global $game;
    global $config;
    // Men BASIC
    Show_Main();
    if (($user = $db->queryrow('SELECT * FROM user WHERE user_id="' . INDEPENDENT_USERID . '" LIMIT 1')) === false) {
        $game->out('<span class="sub_caption">' . constant($game->sprache("TEXT33")) . ' (id=' . $_REQUEST['id'] . '<br>' . constant($game->sprache("TEXT34")) . '</span>');
    } else {
        $game->out('
<table border=0 cellpadding=2 cellspacing=2 wisth="450" class="style_outer" align="center">
  <tr>
    <td>
      <center><span class="caption">' . $user['user_name'] . '</span></center>
    </td>
  </tr>
  <tr>
    <td>
      <table border=0 cellpadding=1 cellspacing=1 width=450 class ="style_inner">
        <tr>');
        //avatar:
        if (!empty($user['user_avatar'])) {
            $info = getimagesize_remote($user['user_avatar']);
            if ($info[0] > 0 && $info[1] > 0 && $info[0] <= 150 && $info[1] <= 250) {
                $game->out('<td width=' . $info[0] . '><img src="' . $user['user_avatar'] . '"></td><td width=25></td><td width=425-' . $info[0] . ' valign=top>');
            } else {
                if ($info[0] > 0 && $info[1] > 0) {
                    $width = 150;
                    $height = 150;
                    if ($info[0] > $info[1]) {
                        $height = 150 * ($info[1] / $info[0]);
                    } else {
                        $width = 150 * ($info[0] / $info[1]);
                    }
                    $game->out('<td width=' . $width . '><img src="' . $user['user_avatar'] . '" width="' . $width . '" height="' . $height . '"></td><td width=25></td><td width=425-' . $width . ' valign=top>');
                } else {
                    $game->out('<td width=200></td><td width=250 valign=top>');
                }
            }
        } else {
            $game->out('<td width=200></td><td width=250 valign=top>');
        }
        $rasse = $RACE_DATA[$user['user_race']][0];
        $planets = $db->queryrow('SELECT count(planet_id) AS num FROM planets WHERE planet_owner="' . $user['user_id'] . '"');
        $game->out('
            <table border=0 cellpadding=2 cellspacing=2 class="style_inner">
              <tr>
                <td width=70><span class="text_large">' . constant($game->sprache("TEXT19")) . '</b></span></td>
                <td width=150><span class="text_large">' . $planets['num'] . '</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
');
        $_link_image = '<a href="usermap.php?user='******'user_name'] . '&size=6&map" target=_blank><img src="usermap.php?user='******'user_name'] . '&size=1" border=0></a>';
        $game->out('
<br>

<table border=0 cellpadding=2 cellspacing=2 width="450" class="style_outer">
  <tr>
    <td><span class="sub_caption">' . constant($game->sprache("TEXT52")) . '</span></td>
  </tr>
  <tr>
    <td>
      <table border=0 cellpadding=2 cellspacing=2 width="450" class="style_inner">
        <tr>
          <td align="center">' . $_link_image . '</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
');
        $game->out('
<table border=0 cellpadding=2 cellspacing=2 width="450" class="style_outer">
  <tr>
    <td><span class="sub_caption">' . constant($game->sprache("TEXT53")) . '</span></td>
  </tr>');
        $game->out('
  <tr>
    <td align="center">
      <b>' . constant($game->sprache("TEXT99")) . '</b>
    </td>
  </tr>
  <tr>
    <td>
      <table border=0 cellpadding=2 cellspacing=2 width="450" class="style_inner">
        <tr>
          <td width=80><b>' . constant($game->sprache("TEXT69")) . '</td>
          <td width=200><b>' . constant($game->sprache("TEXT18")) . '</td>
          <td width=60><b>' . constant($game->sprache("TEXT102")) . '</td>
          <td width=50><b>' . constant($game->sprache("TEXT55")) . '</td>
        </tr>
');
        $sql_pl = 'SELECT pl.planet_id, pl.planet_name, pl.best_mood, pl.best_mood_user, pl.sector_id, pl.planet_distance_id, pl.planet_type, sys.system_x, sys.system_y
                   FROM (planets pl)
                   INNER JOIN (starsystems sys) USING (system_id)
                   INNER JOIN (starsystems_details sd) ON pl.system_id = sd.system_id AND sd.user_id = ' . $game->player['user_id'] . '
                   WHERE pl.planet_owner = "' . INDEPENDENT_USERID . '" AND
                         pl.planet_type IN ("a","b","c","d","m","o","p") 
                   GROUP BY pl.planet_id
                   ORDER BY pl.sector_id, pl.system_id, pl.planet_name';
        $planetquery = $db->query($sql_pl);
        $numero_righe = $db->num_rows($planetquery);
        if ($numero_righe == 0) {
            $game->out('<tr><td> --- </td><td> --- </td><td> --- </td><td> --- </td></tr>');
        } else {
            $sett_diplo = $db->fetchrowset($planetquery);
            foreach ($sett_diplo as $planet) {
                $game->out('<tr><td>' . $game->get_sector_name($planet['sector_id']) . ':' . $game->get_system_cname($planet['system_x'], $planet['system_y']) . ':' . ($planet['planet_distance_id'] + 1) . '</td><td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '">');
                if ($planet['planet_name'] == "") {
                    $planet['planet_name'] = "(<i>" . constant($game->sprache("TEXT40")) . "</i>)";
                }
                $game->out($planet['planet_name'] . '</a></td>');
                // Insane number of SELECT
                $sql = 'SELECT SUM(mood_modifier) as mood FROM settlers_relations WHERE planet_id = ' . $planet['planet_id'] . ' AND user_id = ' . $game->player['user_id'];
                $u_m = $db->queryrow($sql);
                if (isset($u_m['mood']) && !empty($u_m['mood'])) {
                    $user_mood = $u_m['mood'];
                    $game->out('<td><span style="color: ' . ($game->player['user_id'] == $planet['best_mood_user'] || $user_mood > $planet['best_mood'] ? 'green' : 'red') . '">' . $user_mood . '</span></td>');
                } else {
                    $game->out('<td>---</td>');
                }
                $game->out('<td>' . strtoupper($planet['planet_type']) . '</td></tr>');
            }
        }
        $game->out('
      </table>
    </td>
  </tr>
  <tr>
    <td align="center">
      <b>' . constant($game->sprache("TEXT100")) . '</b>
    </td>
  </tr>
  <tr>
    <td>
      <table border=0 cellpadding=2 cellspacing=2 width="450" class="style_inner">
        <tr>
          <td width=80><b>' . constant($game->sprache("TEXT69")) . '</td>
          <td width=200><b>' . constant($game->sprache("TEXT18")) . '</td>
          <td width=60><b>' . constant($game->sprache("TEXT102")) . '</td>
          <td width=50><b>' . constant($game->sprache("TEXT55")) . '</td>
        </tr>');
        $sql_pl = 'SELECT pl.planet_id, pl.planet_name, pl.best_mood, pl.best_mood_user, pl.sector_id, pl.planet_distance_id, pl.planet_type, sys.system_x, sys.system_y
                   FROM (planets pl)
                   INNER JOIN (starsystems sys) USING (system_id)
                   INNER JOIN (starsystems_details sd) ON pl.system_id = sd.system_id AND sd.user_id = ' . $game->player['user_id'] . '
                   WHERE pl.planet_owner = "' . INDEPENDENT_USERID . '" AND
                         pl.planet_type IN ("h","n","k","l","e","f","g") 
                   GROUP BY pl.planet_id
                   ORDER BY pl.sector_id, pl.system_id, pl.planet_name';
        $planetquery = $db->query($sql_pl);
        $numero_righe = $db->num_rows($planetquery);
        if ($numero_righe == 0) {
            $game->out('<tr><td> --- </td><td> --- </td><td> --- </td><td> --- </td></tr>');
        } else {
            $sett_diplo = $db->fetchrowset($planetquery);
            foreach ($sett_diplo as $planet) {
                $game->out('<tr><td>' . $game->get_sector_name($planet['sector_id']) . ':' . $game->get_system_cname($planet['system_x'], $planet['system_y']) . ':' . ($planet['planet_distance_id'] + 1) . '</td><td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '">');
                if ($planet['planet_name'] == "") {
                    $planet['planet_name'] = "(<i>" . constant($game->sprache("TEXT40")) . "</i>)";
                }
                $game->out($planet['planet_name'] . '</a></td>');
                // Insane number of SELECT
                $sql = 'SELECT SUM(mood_modifier) as mood FROM settlers_relations WHERE planet_id = ' . $planet['planet_id'] . ' AND user_id = ' . $game->player['user_id'];
                $u_m = $db->queryrow($sql);
                if (isset($u_m['mood']) && !empty($u_m['mood'])) {
                    $user_mood = $u_m['mood'];
                    $game->out('<td><span style="color: ' . ($game->player['user_id'] == $planet['best_mood_user'] || $user_mood > $planet['best_mood'] ? 'green' : 'red') . '">' . $user_mood . '</span></td>');
                } else {
                    $game->out('<td>---</td>');
                }
                $game->out('<td>' . strtoupper($planet['planet_type']) . '</td></tr>');
            }
        }
        $game->out('
      </table>
    </td>
  </tr>
  <tr>
    <td align="center">
      <b>' . constant($game->sprache("TEXT101")) . '</b>
    </td>
  </tr>
  <tr>
    <td>
      <table border=0 cellpadding=2 cellspacing=2 width="450" class="style_inner">
        <tr>
          <td width=80><b>' . constant($game->sprache("TEXT69")) . '</td>
          <td width=200><b>' . constant($game->sprache("TEXT18")) . '</td>
          <td width=50><b>' . constant($game->sprache("TEXT102")) . '</td>
          <td width=50><b>' . constant($game->sprache("TEXT55")) . '</td>
        </tr>');
        $sql_pl = 'SELECT pl.planet_id, pl.planet_name, pl.best_mood, pl.best_mood_user, pl.sector_id, pl.planet_distance_id, pl.planet_type, sys.system_x, sys.system_y
                   FROM (planets pl)
                   INNER JOIN (starsystems sys) USING (system_id)
                   INNER JOIN (starsystems_details sd) ON pl.system_id = sd.system_id AND sd.user_id = ' . $game->player['user_id'] . '
                   WHERE pl.planet_owner = "' . INDEPENDENT_USERID . '" AND
                         pl.planet_type IN ("i","j","s","t","x","y") 
                   GROUP BY pl.planet_id
                   ORDER BY pl.sector_id, pl.system_id, pl.planet_name';
        $planetquery = $db->query($sql_pl);
        $numero_righe = $db->num_rows($planetquery);
        if ($numero_righe == 0) {
            $game->out('<tr><td> --- </td><td> --- </td><td> --- </td><td> --- </td></tr>');
        } else {
            $sett_diplo = $db->fetchrowset($planetquery);
            foreach ($sett_diplo as $planet) {
                $game->out('<tr><td>' . $game->get_sector_name($planet['sector_id']) . ':' . $game->get_system_cname($planet['system_x'], $planet['system_y']) . ':' . ($planet['planet_distance_id'] + 1) . '</td><td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '">');
                if ($planet['planet_name'] == "") {
                    $planet['planet_name'] = "(<i>" . constant($game->sprache("TEXT40")) . "</i>)";
                }
                $game->out($planet['planet_name'] . '</a></td>');
                // Insane number of SELECT
                $sql = 'SELECT SUM(mood_modifier) as mood FROM settlers_relations WHERE planet_id = ' . $planet['planet_id'] . ' AND user_id = ' . $game->player['user_id'];
                $u_m = $db->queryrow($sql);
                if (isset($u_m['mood']) && !empty($u_m['mood'])) {
                    $user_mood = $u_m['mood'];
                    $game->out('<td><span style="color: ' . ($game->player['user_id'] == $planet['best_mood_user'] || $user_mood > $planet['best_mood'] ? 'green' : 'red') . '">' . $user_mood . '</span></td>');
                } else {
                    $game->out('<td>---</td>');
                }
                $game->out('<td>' . strtoupper($planet['planet_type']) . '</td></tr>');
            }
        }
        $game->out('
      </table>
    </td>
  </tr>
</table>');
    }
}
Example #14
0
    function display()
    {
        global $db, $NEXT_TICK, $BUILDING_NAME, $RACE_DATA, $UNIT_NAME, $TECH_NAME, $SHIP_NAME, $MAX_POINTS;
        /* 01/02/08 - AC: Initialize this ALSO if user is not STGC_DEVELOPER... */
        $banner = '';
        if ($this->player['user_auth_level'] != STGC_DEVELOPER) {
            $banner = '<center><img border="0" src="' . FIXED_GFX_PATH . '../stgcbanner2.jpg" valign="top"></center>';
        }
        echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>' . GetTabbyAction($_GET['a']) . ' - Star Trek: Frontline Combat 2</title>
  <meta name="Content-Language" content="' . $this->player['language'] . '">
  <meta name="description" content="ST: Frontline Combat is a free browser based multiplayer game, take the role of different races and peoples of the universe and rewrite history.">
  <meta name="keywords" content="star trek, startrek, galaxy, conquest, universe, game, gratis, kostenlos, spiel, multiplayer, strategy, strategie, onlinegame, bbg, free, browser, based, galaxie, universum, klingon, klingonen, federation, f&ouml;deration">

  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="pragma" content="no-cache">
  <meta name="author" content="Florian Brede & Philipp Schmidt">
  <meta name="publisher" content="Florian Brede & Philipp Schmidt">
  <meta name="copyright" content="Paramount Pic., Brede, Schmidt">
  <meta name="page-topic" content="Star Trek Online Game">
  <meta name="date" content="2008-11-27">
  <meta name="page-type" content="game">
  <meta name="robots" content="index,nofollow">
  <meta name="revisit-after" content="10">
        ';
        if ($this->auto_refresh > 0) {
            echo '<meta http-equiv="refresh" content="' . $this->auto_refresh . '; URL=index.php?a=' . $this->current_module . '">';
        }
        // Check presence of localized javascript
        if (file_exists('stgc2_' . $this->player['language'] . '.js')) {
            $stgcjs = 'stgc2_' . $this->player['language'] . '.js';
        } else {
            $stgcjs = 'stgc2_ENG.js';
        }
        echo '
  <script type="text/javascript" language="JavaScript" src="' . $this->player['user_jspath'] . $stgcjs . '"></script>
  <script type="text/javascript" language="JavaScript" src="' . $this->player['user_jspath'] . 'overlib.js"></script>
  <script type="text/javascript" language="JavaScript" src="' . $this->player['user_jspath'] . 'popup.js"></script>

       ' . NL . NL;
        if (!strpos($this->game_html, 'function mOver(')) {
            echo '
  <script type="text/javascript" language="JavaScript">
  <!--
  function mOver(Item) {
      Item.style.backgroundColor="#33355E";
      Item.style.cursor="hand";
      Item.style.cursor="pointer";
  }

  function mOut(Item) {
      Item.style.backgroundColor="#121536";
  }
  //-->
  </script>

            ';
        }
        if ($this->player['user_hidenotepad'] == 0) {
            $notepad_html = '
<table align="center" border="0" cellpadding="2" cellspacing="2" width="' . ($this->player['notepad_width'] != 0 ? '' . ($this->player['notepad_width'] + 35) . 'px' : '335px') . '" class="border_grey">
  <tr>
    <td>
      <table border="0" cellpadding="0" cellspacing="0" width="' . ($this->player['notepad_width'] != 0 ? '' . ($this->player['notepad_width'] + 30) . 'px' : '330px') . '">
        <tr>
                 <td align="center" width="' . ($this->player['notepad_width'] != 0 ? '' . ($this->player['notepad_width'] + 30) . 'px' : '330px') . '">
            <form method="post" action="submit_notepad.php" target="_blank">

            <table width="' . ($this->player['notepad_width'] != 0 ? '' . $this->player['notepad_width'] . 'px' : '300px') . '" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="50%" align="left">' . constant($this->sprache("NOTEPAD")) . '</td>
                <td width="50%" align="right"><a href="index.php?hide_notepad=1"><b>' . constant($this->sprache("NOTEHIDE")) . '</b></a></td>
              </tr>
              <tr height="5"><td></td>
              <tr>
                <td width="100%" colspan="2">
                  <textarea name="user_notepad" class="textfield" style="width: ' . ($this->player['notepad_width'] != 0 ? '' . $this->player['notepad_width'] . 'px' : '300px') . ';" rows="' . ($this->player['notepad_cols'] != 0 ? '' . $this->player['notepad_cols'] . '' : '13') . '">' . $this->player['user_notepad'] . '</textarea>
                </td>
              </tr>
              <tr height="10"><td></td></tr>
            </table>
            <input type="submit" name="Update" class="button_nosize" width=45 value="' . constant($this->sprache("NOTESAVE")) . '">

            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
';
        } else {
            $notepad_html = '
<table align="center" border="0" cellpadding="2" cellspacing="2" width="305" background="' . $this->GFX_PATH . 'template_bg3.jpg" class="border_grey">
  <tr>
    <td>
      <table border="0" cellpadding="0" cellspacing="0" width="300">
        <tr>
          <td align="center">
            <a href="index.php?show_notepad=1"><b>' . constant($this->sprache("NOTESHOW")) . '</b></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
            ';
        }
        $planets_option_html = '';
        for ($i = 0; $i < count($this->player['planets']); ++$i) {
            $planets_option_html .= '<option value="' . $this->player['planets'][$i]['planet_id'] . '"' . ($this->player['planets'][$i]['planet_id'] == $this->planet['planet_id'] ? ' selected="selected"' : '') . '>' . ($this->player['planets'][$i]['planet_id'] == $this->planet['planet_id'] ? '->' : '') . ' ' . $this->player['planets'][$i]['planet_name'] . '</option>' . NL;
        }
        $anzahl_truppen = $db->queryrow('SELECT unit_1, unit_2, unit_3, unit_4, unit_5, unit_6 FROM `FHB_Handels_Lager` LIMIT 1');
        // Retrieve alliance information only if an alliance exists
        if ($this->player['user_alliance'] != 0) {
            $alliance_hp = $db->queryrow('SELECT alliance_homepage AS hp FROM alliance WHERE alliance_id=' . $this->player['user_alliance']);
            // 21/02/08 - AC: Check if alliance homepage is empty
            if ($alliance_hp['hp'] == '') {
                $alliance_hp_var = '<a href="' . parse_link('a=alliance_board') . '">' . constant($this->sprache("ALLYFORUM")) . '</a><br>';
            } else {
                if (stripos($alliance_hp['hp'], "http://") == false) {
                    $alliance_hp['hp'] = 'http://' . $alliance_hp['hp'];
                }
                $alliance_hp_var = '<a href="' . $alliance_hp['hp'] . '" target="_blank">' . constant($this->sprache("ALLYFORUM")) . '</a><br>';
            }
        } else {
            // 27/08/12 - AC: These variables must be initialized for some skins.
            $alliance_hp_var = '';
            $alliance_hp['hp'] = '';
        }
        // 01/02/08 - AC: Check if data is valid!
        if ($anzahl_truppen == null) {
            $anzahl_truppen['unit_1'] = '0';
            $anzahl_truppen['unit_2'] = '0';
            $anzahl_truppen['unit_3'] = '0';
            $anzahl_truppen['unit_4'] = '0';
            $anzahl_truppen['unit_5'] = '0';
            $anzahl_truppen['unit_6'] = '0';
        }
        $truppen_hz = 'Truppen zum Verkauf:<br>
<li>Lv1: ' . $anzahl_truppen['unit_1'] . '</li><li>Lv2: ' . $anzahl_truppen['unit_2'] . '</li><li>Lv3: ' . $anzahl_truppen['unit_3'] . '</li><li>Lv4: ' . $anzahl_truppen['unit_4'] . '</li><li>Lv5: ' . $anzahl_truppen['unit_5'] . '</li><li>Lv6: ' . $anzahl_truppen['unit_6'] . '</li>';
        if ($this->player['skin_farbe'] == null) {
            $this->player['skin_farbe'] = "#283359";
        }
        /* 17/03/08 - AC: Add Trade Center link highlighting if auctions are presents */
        global $ACTUAL_TICK;
        $highlight_trade = false;
        $num_auctions = $db->queryrow('SELECT count(*) AS anzahl FROM ship_trade WHERE scheduler_processed=0 AND start_time<=' . $ACTUAL_TICK . ' AND end_time>=' . $ACTUAL_TICK . '');
        if ($num_auctions['anzahl'] > 0 && $this->player['user_points'] >= MIN_POINTS_AUCTIONS) {
            $highlight_trade = true;
        }
        $template_vars = array('GFX_PATH' => $this->GFX_PATH, 'Lv1_Handel' => $anzahl_truppen['unit_1'], 'Lv2_Handel' => $anzahl_truppen['unit_2'], 'Lv3_Handel' => $anzahl_truppen['unit_3'], 'Lv4_Handel' => $anzahl_truppen['unit_4'], 'Lv5_Handel' => $anzahl_truppen['unit_5'], 'Lv6_Handel' => $anzahl_truppen['unit_6'], 'U_LOGOUT' => parse_link('stgc_logout=1'), 'B_STATS' => constant($this->sprache("STATS")), 'B_FAQ' => constant($this->sprache("FAQ")), 'B_IMPRINT' => constant($this->sprache("IMPRINT")), 'B_DONATIONS' => constant($this->sprache("DONATIONS")), 'B_COMMAND' => constant($this->sprache("BCOMMAND")), 'T_COLONY' => constant($this->sprache("TCOLONY")), 'T_COMMAND' => constant($this->sprache("TCOMMAND")), 'T_DATABASE' => constant($this->sprache("TDATABASE")), 'T_GENERAL' => constant($this->sprache("TGENERAL")), 'T_NEXTTICK' => constant($this->sprache("TNEXTTICK")), 'T_SITTING' => constant($this->sprache("TSITTING")), 'B_OVERVIEW' => constant($this->sprache("BOVERVIEW")), 'T_HELLO' => constant($this->sprache("THELLO")), 'T_ALLIANCE' => constant($this->sprache("TALLIANCE")), 'T_POINTS' => constant($this->sprache("TPOINTS")), 'T_RANK' => constant($this->sprache("TRANK")), 'T_CLASS' => constant($this->sprache("TCLASS")), 'T_POSITION' => constant($this->sprache("TPOSITION")), 'T_PL_POINTS' => constant($this->sprache("TPL_POINTS")), 'T_TROOPSXSEC' => constant($this->sprache("TTROOPSXSEC")), 'T_AVOIDREBEL' => constant($this->sprache("TAVOIDREBEL")), 'T_TROOPS' => constant($this->sprache("TTROOPS")), 'T_FLEETS' => constant($this->sprache("TFLEETS")), 'STARDATE' => $this->config['stardate'], 'skin_farbe' => $this->player['skin_farbe'], 'U_HEADQUARTER' => parse_link('a=headquarter'), 'L_HEADQUARTER' => $BUILDING_NAME[$this->player['user_race']][0], 'U_BUILDINGS' => parse_link('a=building'), 'L_BUILDINGS' => constant($this->sprache("BUILDINGS")), 'U_RESEARCH' => parse_link('a=researchlabs'), 'L_RESEARCH' => $BUILDING_NAME[$this->player['user_race']][8], 'U_SPACEDOCK' => parse_link('a=spacedock'), 'L_SPACEDOCK' => $BUILDING_NAME[$this->player['user_race']][6], 'U_SHIPYARD' => parse_link('a=shipyard'), 'L_SHIPYARD' => $BUILDING_NAME[$this->player['user_race']][7], 'U_SHIPTEMPLATE' => parse_link('a=ship_template'), 'L_SHIPTEMPLATE' => constant($this->sprache("SHIPTEMPLATES")), 'U_ACADEMY' => parse_link('a=academy'), 'L_ACADEMY' => $BUILDING_NAME[$this->player['user_race']][5], 'U_MINES' => parse_link('a=mines'), 'L_MINES' => constant($this->sprache("MINES")), 'U_TRADE' => parse_link('a=trade'), 'L_TRADE' => $highlight_trade ? '<span style="color: #FFFF00; font-weight: bold;">' . $BUILDING_NAME[$this->player['user_race']][10] . '</span>' : '' . $BUILDING_NAME[$this->player['user_race']][10] . '', 'U_PLANETLIST' => parse_link('a=planetlist'), 'L_PLANETLIST' => constant($this->sprache("PLANETS")), 'U_FLEETS' => parse_link('a=ship_fleets_display'), 'L_FLEETS' => constant($this->sprache("FLEETS")), 'U_TACTICAL' => parse_link('a=tactical_cartography'), 'L_TACTICAL' => constant($this->sprache("TACTIC")), 'U_SENSORS' => parse_link('a=tactical_sensors'), 'L_SENSORS' => constant($this->sprache("SENSORS")), 'U_SHIPMOVES' => parse_link('a=tactical_moves'), 'L_SHIPMOVES' => constant($this->sprache("SHIPMOVES")), 'U_BUYTROOPS' => parse_link('a=trade&view=trade_buy_truppen'), 'L_BUYTROOPS' => constant($this->sprache("BUYTROOPS")), 'U_ALLYTACTIC' => parse_link('a=alliance_attack'), 'L_ALLYTACTIC' => constant($this->sprache("ALLYTACTIC")), 'U_ALLYTAXES' => parse_link('a=alliance_taxes'), 'L_ALLYTAXES' => constant($this->sprache("ALLYTAXES")), 'U_DIPLOMACY' => parse_link('a=user_diplomacy'), 'L_DIPLOMACY' => constant($this->sprache("DIPLOMACY")), 'U_ALLIANCE' => parse_link('a=alliance_main'), 'L_ALLIANCE' => constant($this->sprache("ALLIANCE")), 'HP_Alliance' => $alliance_hp['hp'], 'HP_Alliance_z' => $alliance_hp_var, 'U_DATABASE' => parse_link('a=database'), 'L_DATABASE' => constant($this->sprache("GENERAL")), 'U_LOGBOOK' => parse_link('a=logbook'), 'L_LOGBOOK' => $this->player['unread_log_entries'] > 0 ? '<span style="color: #FFFF00; font-weight: bold;">' . constant($this->sprache("LOGBOOK")) . '</span>' : '' . constant($this->sprache("LOGBOOK")) . '', 'U_MESSAGES' => parse_link('a=messages'), 'L_MESSAGES' => $this->player['unread_messages'] > 0 ? '<span style="color: #FFFF00; font-weight: bold;">' . constant($this->sprache("MESSAGES")) . '</span>' : '' . constant($this->sprache("MESSAGES")) . '', 'U_PORTAL' => parse_link('a=portal'), 'L_PORTAL' => constant($this->sprache("PORTAL")), 'U_STATS' => parse_link('a=stats'), 'L_STATS' => constant($this->sprache("RANKINGS")), 'U_SETTINGS' => parse_link('a=settings'), 'L_SETTINGS' => constant($this->sprache("SETTINGS")), 'U_HELP' => parse_link('a=help'), 'L_HELP' => constant($this->sprache("HELP")), 'HZ_Truppen' => $truppen_hz, 'U_SUPPORT' => '', 'L_SUPPORT' => '', 'U_SUPPORTCENTER' => '', 'L_SUPPORTCENTER' => '', 'U_ADMINPANEL' => $this->player['user_auth_level'] == STGC_SUPPORTER ? parse_link('a=modcenter') : parse_link('a=tools/index'), 'L_ADMINPANEL' => $this->player['user_auth_level'] == STGC_SUPPORTER ? 'Modcenter' : 'Admin Panel', 'U_PLANETSWITCH' => parse_link('a=' . $this->current_module), 'PLANET_SWITCH_HTML' => $planets_option_html, 'NEXT_TICK_HTML' => '<b id="timer1" title="time1_' . $NEXT_TICK . '_type1_4">&nbsp;</b>', 'USER_NAME' => $this->player['user_name'], 'USER_RACE' => $this->player['user_race'], 'USER_POINTS' => $this->player['user_points'], 'USER_RANKPOS' => $this->player['user_rank_points'], 'USER_RANK' => 0, 'USER_PLANETS' => $this->player['user_planets'], 'USER_HONOR' => $this->player['user_honor'], 'USER_RANKPOS_PLANETS' => $this->player['user_rank_planets'], 'USER_RANKPOS_HONOR' => $this->player['user_rank_honor'], 'ALLIANCE_NAME' => $this->player['alliance_name'], 'ALLIANCE_TAG' => $this->player['alliance_tag'], 'ACTIVE_PLANET_NAME' => $this->planet['planet_name'], 'ACTIVE_PLANET_ALTNAME' => $this->planet['planet_altname'], 'ACTIVE_PLANET_TYPE' => strtoupper($this->planet['planet_type']), 'ACTIVE_PLANET_POINTS' => $this->planet['planet_points'], 'ACTIVE_PLANET_POSITION' => '', 'ACTIVE_PLANET_ID' => encode_planet_id($this->planet['planet_id']), 'ACTIVE_PLANET_MAXRES' => $this->planet['max_resources'] >= 100000 ? round($this->planet['max_resources'] / 1000) . 'k' : round($this->planet['max_resources'], 0), 'ACTIVE_PLANET_MAXWORKER' => $this->planet['max_worker'] >= 100000 ? round($this->planet['max_worker'] / 1000) . 'k' : round($this->planet['max_worker'], 0), 'ACTIVE_PLANET_METAL' => $this->planet['resource_1'] >= 100000 ? round($this->planet['resource_1'] / 1000) . 'k' : round($this->planet['resource_1'], 0), 'ACTIVE_PLANET_MINERALS' => $this->planet['resource_2'] >= 100000 ? round($this->planet['resource_2'] / 1000) . 'k' : round($this->planet['resource_2'], 0), 'ACTIVE_PLANET_LATINUM' => $this->planet['resource_3'] >= 100000 ? round($this->planet['resource_3'] / 1000) . 'k' : round($this->planet['resource_3'], 0), 'ACTIVE_PLANET_WORKER' => round($this->planet['resource_4'], 0) . ' (+' . round($this->planet['add_4'], 1) . ')', 'ACTIVE_PLANET_MAXTROOPS' => $this->planet['max_units'], 'ACTIVE_PLANET_MAXUNITS' => $this->planet['max_units'], 'ACTIVE_PLANET_UNIT1' => $this->planet['unit_1'], 'ACTIVE_PLANET_UNIT2' => $this->planet['unit_2'], 'ACTIVE_PLANET_UNIT3' => $this->planet['unit_3'], 'ACTIVE_PLANET_UNIT4' => $this->planet['unit_4'], 'ACTIVE_PLANET_UNIT5' => $this->planet['unit_5'], 'ACTIVE_PLANET_UNIT6' => $this->planet['unit_6'], 'ACTIVE_PLANET_UNITS' => $this->planet['unit_1'] * 2 + $this->planet['unit_2'] * 3 + $this->planet['unit_3'] * 4 + $this->planet['unit_4'] * 4 + $this->planet['unit_5'] * 4 + $this->planet['unit_6'] * 4, 'ACTIVE_PLANET_STRENGTH' => $this->planet['unit_1'] * 2 + $this->planet['unit_2'] * 3 + $this->planet['unit_3'] * 4 + $this->planet['unit_4'] * 4, 'ACTIVE_PLANET_TROOPS' => $this->planet['unit_1'] * 2 + $this->planet['unit_2'] * 3 + $this->planet['unit_3'] * 4 + $this->planet['unit_4'] * 4, 'ACTIVE_PLANET_STRENGTH_REQUIRED' => $this->planet['min_troops_required'], 'ACTIVE_PLANET_TROOPS_REQUIRED' => $this->planet['min_troops_required'], 'ACTIVE_PLANET_ORBITALDEFENSE' => $this->planet['building_10'], 'ACTIVE_PLANET_ATTACKED' => $this->planet['planet_next_attack'] > 0 ? '<a href="index.php?a=tactical_sensors"><img src="' . $this->GFX_PATH . 'menu_attack_small.gif" border=0></a>' : '', 'ACTIVE_PLANET_GFX' => FIXED_GFX_PATH . 'planet_type_' . $this->planet['planet_type'] . '.png', 'ACTIVE_PLANET_MAXPOINTS' => $this->player['user_capital'] == $this->planet['planet_id'] ? $MAX_POINTS[1] : $MAX_POINTS[0], 'GAME_HTML' => &$this->game_html, 'NOTEPAD_HTML' => &$notepad_html, 'B_REGISTRATION' => constant($this->sprache("BREGISTRATION")), 'T_WELCOME' => constant($this->sprache("TWELCOME")), 'T_STARDATE' => constant($this->sprache("TSTARDATE")), 'T_RESOURCES' => constant($this->sprache("TRESOURCES")), 'T_TACTIC' => constant($this->sprache("TACTIC")), 'T_SECURITY' => constant($this->sprache("TSECURITY")), 'T_REQUIRED' => constant($this->sprache("TREQUIRED")), 'T_DEFENSE' => constant($this->sprache("TDEFENSE")), 'T_LEVEL1' => constant($this->sprache("TLEVEL1")), 'T_LEVEL2' => constant($this->sprache("TLEVEL2")), 'T_LEVEL3' => constant($this->sprache("TLEVEL3")), 'T_COMMANDERS' => constant($this->sprache("TCOMMANDERS")), 'T_TECHNICIANS' => constant($this->sprache("TTECHNICIANS")), 'T_PHYSICIANS' => constant($this->sprache("TPHYSICIANS")), 'T_WORKERS' => constant($this->sprache("TWORKERS")), 'T_CAP_ADMIRAL' => constant($this->sprache("TCAP_ADMIRAL")), 'T_CAP_ALLIANCE' => constant($this->sprache("TCAP_ALLIANCE")), 'T_CAP_RANK' => constant($this->sprache("TCAP_RANK")), 'L_SHIPS' => constant($this->sprache("SHIPS")), 'U_SHIPS' => parse_link('a=ships'), 'L_SETTLERS' => constant($this->sprache("INDEPENDENT_COLONIES")), 'U_SETTLERS' => parse_link('a=settlers'), 'GAME_URL' => JSCRIPT_PATH);
        $template_vars['ACTIVE_PLANET_FLEETS'] = '<form action="' . parse_link('a=ship_fleets_display') . '" name="fleetselect" type="GET">
	<input type="hidden" name="a" value="ship_fleets_display">
	<select name="pfleet_details" size="4" style="width: 100px;" onChange="document.fleetselect.submit()">';
        $fleetquery = $db->query('SELECT fleet_id, fleet_name, n_ships FROM ship_fleets WHERE planet_id = ' . $this->planet['planet_id'] . ' AND user_id=' . $this->player['user_id']);
        $select_size = $db->num_rows($fleetquery) + 1;
        if ($select_size == 1) {
            $template_vars['ACTIVE_PLANET_FLEETS'] .= '<option></option>';
        }
        while (($fleet = $db->fetchrow($fleetquery)) == true) {
            $template_vars['ACTIVE_PLANET_FLEETS'] .= '<option value="' . $fleet['fleet_id'] . '">' . $fleet['fleet_name'] . ' (' . $fleet['n_ships'] . ')</option>';
        }
        $template_vars['ACTIVE_PLANET_FLEETS'] .= '</select></form>';
        if (!$this->SITTING_MODE) {
            $sql = 'SELECT tick_id FROM config';
            $tickqry = $db->query($sql);
            $sql = 'SELECT user_id,user_name FROM user WHERE user_active=1 AND user_auth_level<>' . STGC_BOT . ' AND (user_sitting_id1=' . $this->player['user_id'] . ' OR user_sitting_id2=' . $this->player['user_id'] . ' OR user_sitting_id3=' . $this->player['user_id'] . ' OR user_sitting_id4=' . $this->player['user_id'] . ' OR user_sitting_id5=' . $this->player['user_id'] . ')AND num_sitting>=0 AND (user_vacation_start <= ' . $this->config['tick_id'] . ' OR user_vacation_end >= ' . $this->config['tick_id'] . ') ORDER by user_name ASC';
            $susr = $db->query($sql);
            $template_vars['USER_SITTING'] = '<form action="' . parse_link('a=settings') . '" name="sittingselect" type="GET">
		<input type="hidden" name="a" value="settings">
		<input type="hidden" name="view" value="sitting">
		<select name="login_sitting" size="4" style="width: 100px;" onChange="document.sittingselect.submit()">';
            $select_size = $db->num_rows($susr) + 1;
            if ($select_size == 1) {
                $template_vars['USER_SITTING'] .= '<option></option>';
            }
            while ($sittinguser = $db->fetchrow($susr)) {
                $template_vars['USER_SITTING'] .= '<option value="' . $sittinguser['user_id'] . '">' . $sittinguser['user_name'] . '</option>';
            }
            $template_vars['USER_SITTING'] .= '</select></form>';
            //$template_vars['USER_SITTING']='<i>Wegen Lags deaktiviert</i><br>Bitte unter Einstellungen zugreifen.';
        } else {
            $template_vars['USER_SITTING'] = '<a href=' . parse_link('a=settings&view=sitting&login_sitting=-1') . '><i>' . constant($this->sprache("LOGOUT")) . '</i></a>';
        }
        $system = $db->queryrow('SELECT system_x, system_y FROM starsystems WHERE system_id = ' . $this->planet['system_id']);
        $template_vars['ACTIVE_PLANET_POSITION'] = $this->get_sector_name($this->planet['sector_id']) . ':' . $this->get_system_cname($system['system_x'], $system['system_y']) . ':' . ($this->planet['planet_distance_id'] + 1);
        $rank_honor = array(0, 200, 500, 1000, 1750, 2500, 3500, 5000, 7000, 10000);
        $rank_nr = 1;
        if ($this->player['user_honor'] >= $rank_honor[9]) {
            $rank_nr = 10;
        } elseif ($this->player['user_honor'] >= $rank_honor[8]) {
            $rank_nr = 9;
        } elseif ($this->player['user_honor'] >= $rank_honor[7]) {
            $rank_nr = 8;
        } elseif ($this->player['user_honor'] >= $rank_honor[6]) {
            $rank_nr = 7;
        } elseif ($this->player['user_honor'] >= $rank_honor[5]) {
            $rank_nr = 6;
        } elseif ($this->player['user_honor'] >= $rank_honor[4]) {
            $rank_nr = 5;
        } elseif ($this->player['user_honor'] >= $rank_honor[3]) {
            $rank_nr = 4;
        } elseif ($this->player['user_honor'] >= $rank_honor[2]) {
            $rank_nr = 3;
        } elseif ($this->player['user_honor'] >= $rank_honor[1]) {
            $rank_nr = 2;
        } elseif ($this->player['user_honor'] >= $rank_honor[0]) {
            $rank_nr = 1;
        }
        $template_vars['USER_RANK'] = '<img src="' . $this->GFX_PATH . 'rank_' . $rank_nr . '.jpg" border=0>';
        if ($this->player['user_auth_level'] != STGC_DEVELOPER && $this->player['user_auth_level'] != STGC_SUPPORTER) {
            $template_vars['U_SUPPORTCENTER'] = $template_vars['L_SUPPORTCENTER'] = '';
        }
        if ($this->player['user_auth_level'] != STGC_DEVELOPER && $this->player['user_auth_level'] != STGC_SUPPORTER) {
            $template_vars['U_ADMINPANEL'] = $template_vars['L_ADMINPANEL'] = '';
        }
        foreach ($template_vars as $name => $content) {
            $this->template_html = str_replace('{' . $name . '}', $content, $this->template_html);
        }
        echo $this->template_html;
        global $start_time;
        $total_time = time() + microtime() - $start_time;
        echo '<center>';
        echo '<div style="font-family: verdana; font-size: 11px;">' . round($total_time, 4) . ' secs&nbsp;&nbsp;-&nbsp;&nbsp;' . $db->i_query . ' queries<br></div>';
        // The following line is a copyright mark and must not be altered, removed or hidden in any way:
        echo '<div style="font-family: verdana; font-size: 10px;">based on stgc.de</div>';
        echo '

<!-- PHP Exec Time:    ' . ($total_time - $db->t_query) . ' secs -->
<!-- MySQL Query Time: ' . $db->t_query . ' secs -->
<br><br><br><br><br><br><br><br><br><br><br><br><br>

</body>

</html>
        ';
        //stgc_log('performance', $_SERVER['QUERY_STRING'].'|'.($total_time - $db->t_query).'|'.$db->t_query);
    }
Example #15
0
 function create_system_map($system_id = 0)
 {
     global $db, $game, $ACTUAL_TICK, $PLANETS_DATA;
     $sql = 'SELECT system_id,
                    system_starcolor_red,
                    system_starcolor_green,
                    system_starcolor_blue,
                    system_starsize
             FROM starsystems
             WHERE system_id = "' . $system_id . '"';
     if (($system = $db->queryrow($sql)) === false) {
         message(DATABASE_ERROR, 'Could not query starsystem data');
     }
     if (empty($system['system_id'])) {
         message(GENERAL, 'Could not find system ' . $system_id);
     }
     // DC ---- Fog of war is coming!!!
     $sql = 'SELECT p.planet_id, p.planet_name, p.planet_type, p.planet_distance_px, p.planet_covered_distance, p.planet_current_x, p.planet_current_y, p.planet_points,
                    u.user_id, u.user_name, u.user_attack_protection, u.user_points,
                    a.alliance_id, a.alliance_tag, a.alliance_name
             FROM (planets p)
             LEFT JOIN (user u) ON u.user_id = p.planet_owner
             LEFT JOIN (alliance a) ON a.alliance_id = u.user_alliance
             WHERE p.system_id = ' . $system_id . ' ORDER BY p.planet_id';
     if (!($q_planets = $db->query($sql))) {
         message(DATABASE_ERROR, 'Could not query planets data');
     }
     // DC ----
     $system_is_known = false;
     $sql = 'SELECT COUNT(*) AS system_is_known FROM starsystems_details WHERE system_id = ' . $system_id . ' AND user_id = ' . $game->player['user_id'];
     if (!($q_details = $db->queryrow($sql))) {
         message(DATABASE_ERROR, 'Could not query planet details data');
     }
     if (isset($q_details['system_is_known']) && $q_details['system_is_known'] > 0 || $game->player['user_auth_level'] == STGC_DEVELOPER) {
         $system_is_known = true;
     }
     // ----
     $n_planets = $db->num_rows($q_planets);
     $im = imagecreate($this->system_map_size, $this->system_map_size);
     imagecolorallocate($im, 0, 0, 0);
     $this->draw_stars($im, $this->system_map_size, 800);
     $center_coord = $this->system_map_size / 2;
     $star_color = imagecolorallocate($im, $system['system_starcolor_red'], $system['system_starcolor_green'], $system['system_starcolor_blue']);
     $star_size = $system['system_starsize'];
     imagefilledellipse($im, $center_coord, $center_coord, $star_size, $star_size, $star_color);
     $orbit_color = imagecolorallocate($im, 50, 50, 50);
     $cl_own_planet = imagecolorallocate($im, 0, 255, 0);
     // green
     $cl_active_planet = imagecolorallocate($im, 255, 255, 0);
     // yellow
     $cl_alliance_planet = imagecolorallocate($im, 0, 0, 255);
     // blue
     $cl_settlers_planet = imagecolorallocate($im, 204, 102, 0);
     // orange
     $cl_attack_protection = imagecolorallocate($im, 180, 180, 180);
     // gray
     $cl_alliance_war = imagecolorallocate($im, 255, 0, 0);
     // red
     $cl_alliance_bnd_pbnd = imagecolorallocate($im, 137, 202, 239);
     // lightblue
     $map_html = '<map name="system_map">' . NL;
     $used_distances = array();
     $planet_images = array();
     for ($i = 1; $i <= $star_size + 10; ++$i) {
         $used_distances[$i] = true;
     }
     $rect_coords = array(array(3, 5, 1, 3), array(7, 5, 5, 3), array(3, 1, 1, -1), array(7, 1, 5, -1));
     $rows_planets = $db->fetchrowset($q_planets);
     foreach ($rows_planets as $planet) {
         $radius = $planet['planet_distance_px'];
         imageellipse($im, $center_coord, $center_coord, $radius * 2, $radius * 2, $orbit_color);
         if ($planet['planet_current_x'] == 0) {
             $coords = $this->calculate_planet_position($radius, $planet['planet_covered_distance']);
             $planet_x = $coords[0];
             $planet_y = $coords[1];
             $sql = 'UPDATE planets
                     SET planet_current_x = ' . $planet_x . ',
                         planet_current_y = ' . $planet_y . '
                     WHERE planet_id = ' . $planet['planet_id'];
             if (!$db->query($sql)) {
                 message(DATABASE_ERROR, 'Could not update planet position data');
             }
         } else {
             $planet_x = $planet['planet_current_x'];
             $planet_y = $planet['planet_current_y'];
         }
         $current_type = $planet['planet_type'];
         $planet_width = $PLANETS_DATA[$current_type][8];
         if (empty($planet_colors[$current_type])) {
             $planet_colors[$current_type] = imagecolorallocate($im, $PLANETS_DATA[$current_type][9][0], $PLANETS_DATA[$current_type][9][1], $PLANETS_DATA[$current_type][9][2]);
         }
         if ($planet['user_id'] == $game->player['user_id'] || $planet['alliance_id'] == $game->player['user_alliance'] || $system_is_known) {
             imagefilledellipse($im, $planet_x, $planet_y, $PLANETS_DATA[$current_type][8], $PLANETS_DATA[$current_type][8], $planet_colors[$current_type]);
         } else {
             $fake_colors = imagecolorallocate($im, 255, 255, 255);
             imagefilledellipse($im, $planet_x, $planet_y, 5, 5, $fake_colors);
         }
         // DC ---- Fog of War: here we go!
         if ($planet['user_id'] == $game->player['user_id'] || $planet['alliance_id'] == $game->player['user_alliance'] || $system_is_known) {
             $map_html .= '<area href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '" shape="circle" coords="' . (int) $planet_x . ', ' . (int) $planet_y . ', ' . $PLANETS_DATA[$current_type][8] . '"';
             $map_html .= ' onmouseover="return overlib(\'<font color=gray><b>' . $this->str_name . '</b> ' . str_replace("'", "\\'", $planet['planet_name']) . '</font><br><font color=gray><b>' . $this->str_class . '</b> ' . strtoupper($planet['planet_type']) . '</font>';
             if (empty($planet['user_id'])) {
                 $map_html .= '<br><i>' . $this->str_uninhabited . '</i>';
             } else {
                 $map_html .= '<br><b>' . $this->str_owner . '</b> ' . $planet['user_name'];
                 $map_html .= (!empty($planet['alliance_name']) ? '<br><font color=gray><b>' . $this->str_alliance . '</b> ' . str_replace("'", "\\'", $planet['alliance_name']) . ' [' . $planet['alliance_tag'] . ']</font>' : '') . '<br><b>' . $this->str_points . '</b> ' . $planet['planet_points'] . ' (' . $planet['user_points'] . ' ges.)';
             }
             // DC Try to give more information, just for fun
             $sql = 'SELECT sf.fleet_name, sf.n_ships, sf.fleet_id FROM ship_fleets sf 
                     INNER JOIN planets pl ON pl.planet_id = sf.planet_id 
                     WHERE pl.planet_id = ' . $planet['planet_id'] . ' AND sf.user_id = ' . $game->player['user_id'];
             if ($fleet_details = $db->queryrowset($sql)) {
                 foreach ($fleet_details as $f_i) {
                     $map_html .= '<br>' . $this->str_fleet_player . ' <b>' . htmlentities($f_i['fleet_name']) . '</b>, ' . $f_i['n_ships'] . ' ' . $this->str_ships;
                 }
             }
             // DC More info! Let's push mysql
             $sql = 'SELECT survey_1, survey_2, survey_3 FROM planet_details
                     WHERE log_code = 100 AND planet_id = ' . $planet['planet_id'] . '
                     AND user_id = ' . $game->player['user_id'];
             if ($survey_details = $db->queryrow($sql)) {
                 $map_html .= '<br>' . $this->str_res;
                 switch ($survey_details['survey_1']) {
                     case 0:
                         $map_html .= '<font color=red>' . $this->str_met . '</font> ';
                         break;
                     case 1:
                         $map_html .= '<font color=gray>' . $this->str_met . '</font> ';
                         break;
                     case 2:
                         $map_html .= '<font color=green>' . $this->str_met . '</font> ';
                         break;
                 }
                 switch ($survey_details['survey_2']) {
                     case 0:
                         $map_html .= '<font color=red>' . $this->str_mins . '</font> ';
                         break;
                     case 1:
                         $map_html .= '<font color=gray>' . $this->str_mins . '</font> ';
                         break;
                     case 2:
                         $map_html .= '<font color=green>' . $this->str_mins . '</font> ';
                         break;
                 }
                 switch ($survey_details['survey_3']) {
                     case 0:
                         $map_html .= '<font color=red>' . $this->str_dilh . '</font>';
                         break;
                     case 1:
                         $map_html .= '<font color=gray>' . $this->str_dilh . '</font>';
                         break;
                     case 2:
                         $map_html .= '<font color=green>' . $this->str_dilh . '</font>';
                         break;
                 }
             }
             // ----
             $map_html .= '\', CAPTION, \'' . $this->str_details . '\', WIDTH, 300, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">';
         } else {
             $map_html .= '<area href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '" shape="circle" coords="' . (int) $planet_x . ', ' . (int) $planet_y . ', ' . $PLANETS_DATA[$current_type][8] . '"';
             $map_html .= ' onmouseover="return overlib(\'<b><i>&#171;Nessuna Informazione&#187;</i></b>\', CAPTION, \'' . $this->str_details . '\', WIDTH, 300, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">';
         }
         $rect_colors = array();
         if ($planet['user_id'] == $game->player['user_id'] || $planet['alliance_id'] == $game->player['user_alliance'] || $system_is_known) {
             if ($planet['planet_id'] == $game->planet['planet_id']) {
                 $rect_colors[] = $cl_active_planet;
             }
             if ($planet['user_attack_protection'] > $ACTUAL_TICK) {
                 $rect_colors[] = $cl_attack_protection;
             }
             $rotz = 0;
             $rotz = $planet['alliance_id'];
             if (empty($rotz)) {
                 $rotz = 0;
             }
             $sql = 'SELECT ad_id, alliance1_id, alliance2_id, type, status
                     FROM alliance_diplomacy
                     WHERE (alliance1_id = ' . $rotz . ' OR
                            alliance2_id = ' . $rotz . ') AND (alliance1_id = ' . $game->player['user_alliance'] . ' OR
                            alliance2_id = ' . $game->player['user_alliance'] . ') AND ((status = 0) OR (type=1 AND status=2))';
             if (($alliance_1 = $db->queryrow($sql)) === false) {
                 message(DATABASE_ERROR, 'Could not query alliance data');
             }
             if (!empty($alliance_1['ad_id'])) {
                 $sql = 'SELECT alliance_id
                         FROM alliance
                         WHERE alliance_id != ' . $game->player['user_alliance'] . ' AND
                              (alliance_id = ' . $alliance_1['alliance1_id'] . ' OR
                               alliance_id = ' . $alliance_1['alliance2_id'] . ')';
                 if (($alliance_2 = $db->queryrow($sql)) === false) {
                     message(DATABASE_ERROR, 'Could not query alliance data');
                 }
             }
             if ($planet['user_id'] == $game->player['user_id']) {
                 $rect_colors[] = $cl_own_planet;
             } elseif ($planet['user_id'] == INDEPENDENT_USERID) {
                 $rect_colors[] = $cl_settlers_planet;
             } elseif ($planet['alliance_id'] == $game->player['user_alliance']) {
                 $rect_colors[] = $cl_alliance_planet;
             } elseif ($planet['alliance_id'] == $alliance_2['alliance_id'] && $alliance_1['type'] == 1) {
                 $rect_colors[] = $cl_alliance_war;
             } elseif ($planet['alliance_id'] == $alliance_2['alliance_id'] && $alliance_1['type'] == 3) {
                 $rect_colors[] = $cl_alliance_bnd_pbnd;
             }
         }
         if (!empty($rect_colors)) {
             for ($i = 0; $i < count($rect_colors); ++$i) {
                 imagefilledrectangle($im, $planet_x - $planet_width - $rect_coords[$i][0], $planet_y - $rect_coords[$i][1], $planet_x - $planet_width - $rect_coords[$i][2], $planet_y - $rect_coords[$i][3], $rect_colors[$i]);
             }
         }
     }
     imagepng($im, 'maps/images/cache/' . md5($game->player['user_id']) . '.png');
     imagedestroy($im);
     $map_html .= '</map>';
     return $map_html;
 }
            $start_owner_str = '';
        }
        if (empty($move['dest_owner_id'])) {
            $dest_owner_str = ' <i>' . constant($game->sprache("TEXT9")) . '</i>';
        } elseif ($move['dest_owner_id'] != $game->player['user_id']) {
            $dest_owner_str = ' ' . constant($game->sprache("TEXT10")) . ' <a href="' . parse_link('a=stats&a2=viewplayer&id=' . $move['dest_owner_id']) . '"><b>' . $move['dest_owner_name'] . '</b></a>';
        } else {
            $dest_owner_str = '';
        }
        $system_is_known = false;
        if (isset($move['timestamp']) && !empty($move['timestamp'])) {
            $system_is_known = true;
        }
        $know_dest_str = ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['dest'])) . '"><b>' . $move['dest_planet_name'] . '</b></a>' . $dest_owner_str;
        $unknow_dest_str = ' <b><i>&#171;' . constant($game->sprache("TEXT28")) . '&#187;</i></b>';
        $game->out(constant($game->sprache("TEXT12")) . ' <a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['start'])) . '"><b>' . $move['start_planet_name'] . '</b></a>' . $start_owner_str . '<br>
		   ' . constant($game->sprache("TEXT13")) . ($system_is_known ? $know_dest_str : $unknow_dest_str) . '<br>
		');
    }
    $game->out('
	      <br>
	      <select name="fleets[]" style="width: 200px;">
	');
    for ($j = 0; $j < $n_fleets; ++$j) {
        $game->out('<option value="' . $fleets_by_move[$move_id][$j][0] . '">' . $fleets_by_move[$move_id][$j][1] . ' (' . $fleets_by_move[$move_id][$j][2] . ')</option>');
    }
    $ticks_left = $move['move_finish'] - $ACTUAL_TICK;
    if ($ticks_left < 0) {
        $ticks_left = 0;
    }
    $game->out('
Example #17
0
function Ships_List($focus = 0, $search_name = "")
{
    global $db, $game, $UNIT_NAME, $NEXT_TICK, $ACTUAL_TICK;
    /* AC: Get search name */
    $search_name = htmlspecialchars($_REQUEST['search']);
    /* AC: Check query focus */
    if (isset($_REQUEST['start'])) {
        $focus = $_REQUEST['start'];
    }
    /* AC: Check chosen ordering method */
    if (!isset($_REQUEST['order']) || empty($_REQUEST['order'])) {
        $_REQUEST['order'] = 1;
    }
    /* Filter ship's type */
    if (isset($_GET['filter']) && $_GET['filter'] == 1) {
        $game->option_store('stype_0', (int) (1 - $game->option_retr('stype_0', 1)));
    }
    if (isset($_GET['filter']) && $_GET['filter'] == 2) {
        $game->option_store('stype_1', (int) (1 - $game->option_retr('stype_1', 1)));
    }
    if (isset($_GET['filter']) && $_GET['filter'] == 3) {
        $game->option_store('stype_2', (int) (1 - $game->option_retr('stype_2', 1)));
    }
    if (isset($_GET['filter']) && $_GET['filter'] == 4) {
        $game->option_store('stype_3', (int) (1 - $game->option_retr('stype_3', 1)));
    }
    $_POST['stype_0'] = $game->option_retr('stype_0', 1);
    $_POST['stype_1'] = $game->option_retr('stype_1', 1);
    $_POST['stype_2'] = $game->option_retr('stype_2', 1);
    $_POST['stype_3'] = $game->option_retr('stype_3', 1);
    if ($_POST['stype_0']) {
        $sels[] = 0;
    }
    if ($_POST['stype_1']) {
        $sels[] = 1;
    }
    if ($_POST['stype_2']) {
        $sels[] = 2;
    }
    if ($_POST['stype_3']) {
        $sels[] = 3;
    }
    if (empty($sels)) {
        $sels[] = 4;
    }
    /* */
    $queryfocus = $focus;
    /* AC: Query user ships ordered by shiptorso */
    $ordermethod = 'st.ship_torso DESC,s.ship_name, fl.fleet_name, pl.planet_name, s.ship_scrap,s.ship_repair,st.name ASC';
    /* AC: Query user ships ordered by name */
    if ($_REQUEST['order'] == 2) {
        $ordermethod = 's.ship_name ASC,s.ship_scrap,s.ship_repair,st.name ASC';
    } else {
        if ($_REQUEST['order'] == 3) {
            $ordermethod = 'pl.planet_name, fl.fleet_name ASC,s.ship_scrap,s.ship_repair,st.name ASC';
        } else {
            if ($_REQUEST['order'] == 4) {
                $ordermethod = 's.hitpoints DESC,s.ship_scrap,s.ship_repair,st.name ASC';
            } else {
                if ($_REQUEST['order'] == 5) {
                    $ordermethod = 's.awayteam ASC,s.ship_scrap,s.ship_repair,st.name ASC';
                } else {
                    if ($_REQUEST['order'] == -1) {
                        $ordermethod = 'st.ship_torso ASC,s.ship_name, fl.fleet_name, pl.planet_name, s.ship_scrap,s.ship_repair,st.name ASC';
                    } else {
                        if ($_REQUEST['order'] == -2) {
                            $ordermethod = 's.ship_name DESC,s.ship_scrap,s.ship_repair,st.name ASC';
                        } else {
                            if ($_REQUEST['order'] == -3) {
                                $ordermethod = 'pl.planet_name, fl.fleet_name DESC,s.ship_scrap,s.ship_repair,st.name ASC';
                            } else {
                                if ($_REQUEST['order'] == -4) {
                                    $ordermethod = 's.hitpoints ASC,s.ship_scrap,s.ship_repair,st.name ASC';
                                } else {
                                    if ($_REQUEST['order'] == -5) {
                                        $ordermethod = 's.awayteam DESC,s.ship_scrap,s.ship_repair,st.name ASC';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $shipsxpage = 20;
    /* Vary number of displayable ships per page according max number of ships owned */
    $sql = 'SELECT COUNT(ship_id) AS n_ships
			FROM (ships s)
			INNER JOIN (ship_templates st) ON st.id = s.template_id
			WHERE user_id = ' . $game->player['user_id'] . ' AND st.ship_class IN (' . implode(',', $sels) . ')';
    $n_ships = $db->queryrow($sql);
    if ($n_ships['n_ships'] > 500) {
        $shipsxpage = 100;
    }
    $sql = 'SELECT s.ship_id, s.hitpoints, s.ship_repair, s.ship_scrap, s.ship_untouchable, s.awayteam, s.awayteamplanet_id,
			s.unit_1,s.unit_2,s.unit_3,s.unit_4, s.ship_name, s.ship_ncc, s.fleet_id,
			s.construction_time, st.max_unit_1,st.max_unit_2,st.max_unit_3,st.max_unit_4,
			st.name AS template_name, st.value_5 AS max_hitpoints, fl.fleet_name,
			fl.planet_id AS fleet_target, pl.planet_name, pl2.planet_name AS mission_planet
			FROM (ships s)
			INNER JOIN (ship_templates st) ON st.id = s.template_id
			LEFT JOIN (ship_fleets fl) ON fl.fleet_id = s.fleet_id
			LEFT JOIN (planets pl) ON pl.planet_id = ABS(s.fleet_id)
                        LEFT JOIN (planets pl2) ON pl2.planet_id = s.awayteamplanet_id
			WHERE s.user_id = ' . $game->player['user_id'] . '
			AND st.ship_class IN (' . implode(',', $sels) . ') ORDER BY ' . $ordermethod . ' LIMIT ' . $queryfocus . ',' . $shipsxpage;
    $shipquery = $db->query($sql);
    $game->out(constant($game->sprache("TEXT1")) . '<br><br>');
    /* AC: Searching ship */
    $game->out('<br><table border=0 cellpadding=1 cellspacing=1  class="style_outer" width=300><tr><td>
		<table border=0 cellpadding=2 cellspacing=2  class="style_inner" width=300>
		<tr>
			<td align="center" valign="middle">
				<form method="post" action="' . parse_link('a=ships&view=ships_list&order=' . $_REQUEST['order']) . '">
				<input type="text" name="search" size="16" class="field" value="' . htmlspecialchars($_REQUEST['search']) . '">
			</td>
			<td align="center" valign="middle">
				<input type="submit" name="exec_search" class="button" width=100 value="' . constant($game->sprache("TEXT2")) . '">
				</form>
			</td>
		</tr>
		</table>
	</td></tr>
	</table>');
    /* AC: If we have to search ships */
    if ($search_name != "" && $focus == 0) {
        $game->out('<br><table border=0 cellpadding=1 cellspacing=1  class="style_outer" width=300><tr><td>
		<table border=0 cellpadding=2 cellspacing=2 class="style_inner" width=300>
			<tr>
				<td width=150>
					<b>' . constant($game->sprache("TEXT3")) . '</b>
				</td>
				<td>
					<b>' . constant($game->sprache("TEXT5")) . '</b>
				</td>
			</tr>');
        $search_ships = $db->query('SELECT ship_name, ship_id, st.name AS template_name
					FROM (ships s) INNER JOIN (ship_templates st) ON st.id = s.template_id
					WHERE ship_name LIKE "%' . $_REQUEST['search'] . '%" AND user_id = ' . $game->player['user_id'] . ' ORDER by ship_name ASC');
        while (($ship = $db->fetchrow($search_ships)) != false) {
            $game->out('
				<tr>
					<td width=150>
						<a href="' . parse_link('a=ships&view=ship_details&id=' . $ship['ship_id']) . '">' . $ship['ship_name'] . '</a>
					</td>
					<td>
						' . $ship['template_name'] . '
					</td>
				</tr>
			');
        }
        $game->out('</table></td></tr></table>');
    }
    $game->out('<br><br><span class="sub_caption">' . constant($game->sprache("TEXT4")) . ' ' . HelpPopup('ships') . ' :</span><br>');
    /**
     * AC: Create main table
     */
    switch ($_REQUEST['order']) {
        case 1:
        case -1:
            $header1 = '<a href="' . parse_link('a=ships&view=ships_list&order=' . $_REQUEST['order'] * -1 . '&search=' . $search_name) . '"><b><u>' . constant($game->sprache("TEXT5")) . '</u></b></a>';
            $header2 = '<a href="' . parse_link('a=ships&view=ships_list&order=2&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT6")) . '</b></a>';
            $header3 = '<a href="' . parse_link('a=ships&view=ships_list&order=3&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT7")) . '</b></a>';
            $header4 = '<a href="' . parse_link('a=ships&view=ships_list&order=4&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT8")) . '</b></a>';
            $header5 = '<a href="' . parse_link('a=ships&view=ships_list&order=5&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT11")) . '</b></a>';
            break;
        case 2:
        case -2:
            $header1 = '<a href="' . parse_link('a=ships&view=ships_list&order=1&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT5")) . '</b></a>';
            $header2 = '<a href="' . parse_link('a=ships&view=ships_list&order=' . $_REQUEST['order'] * -1 . '&search=' . $search_name) . '"><b><u>' . constant($game->sprache("TEXT6")) . '</u></b></a>';
            $header3 = '<a href="' . parse_link('a=ships&view=ships_list&order=3&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT7")) . '</b></a>';
            $header4 = '<a href="' . parse_link('a=ships&view=ships_list&order=4&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT8")) . '</b></a>';
            $header5 = '<a href="' . parse_link('a=ships&view=ships_list&order=5&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT11")) . '</b></a>';
            break;
        case 3:
        case -3:
            $header1 = '<a href="' . parse_link('a=ships&view=ships_list&order=1&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT5")) . '</b></a>';
            $header2 = '<a href="' . parse_link('a=ships&view=ships_list&order=2&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT6")) . '</b></a>';
            $header3 = '<a href="' . parse_link('a=ships&view=ships_list&order=' . $_REQUEST['order'] * -1 . '&search=' . $search_name) . '"><b><u>' . constant($game->sprache("TEXT7")) . '</u></b></a>';
            $header4 = '<a href="' . parse_link('a=ships&view=ships_list&order=4&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT8")) . '</b></a>';
            $header5 = '<a href="' . parse_link('a=ships&view=ships_list&order=5&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT11")) . '</b></a>';
            break;
        case 4:
        case -4:
            $header1 = '<a href="' . parse_link('a=ships&view=ships_list&order=1&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT5")) . '</b></a>';
            $header2 = '<a href="' . parse_link('a=ships&view=ships_list&order=2&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT6")) . '</b></a>';
            $header3 = '<a href="' . parse_link('a=ships&view=ships_list&order=3&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT7")) . '</b></a>';
            $header4 = '<a href="' . parse_link('a=ships&view=ships_list&order=' . $_REQUEST['order'] * -1 . '&search=' . $search_name) . '"><b><u>' . constant($game->sprache("TEXT8")) . '</u></b></a>';
            $header5 = '<a href="' . parse_link('a=ships&view=ships_list&order=5&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT11")) . '</b></a>';
            break;
        case 5:
        case -5:
            $header1 = '<a href="' . parse_link('a=ships&view=ships_list&order=1&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT5")) . '</b></a>';
            $header2 = '<a href="' . parse_link('a=ships&view=ships_list&order=2&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT6")) . '</b></a>';
            $header3 = '<a href="' . parse_link('a=ships&view=ships_list&order=3&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT7")) . '</b></a>';
            $header4 = '<a href="' . parse_link('a=ships&view=ships_list&order=4&search=' . $search_name) . '"><b>' . constant($game->sprache("TEXT8")) . '</b></a>';
            $header5 = '<a href="' . parse_link('a=ships&view=ships_list&order=' . $_REQUEST['order'] * -1 . '&search=' . $search_name) . '"><b><u>' . constant($game->sprache("TEXT11")) . '</u></b></a>';
            break;
    }
    $game->out('<br><table border=0 cellpadding=2 cellspacing=2 class="style_outer"><tr><td>
	<table border=0 cellpadding=2 cellspacing=2 class="style_inner">
		<tr>
		<td><b>#</b></td>
		<td width=160>' . $header1 . '</td>
		<td width=200>' . $header2 . '</td>
		<td width=100>' . $header3 . '</td>
		<td width=100 align="center">' . $header4 . '</td>
		<td width=75 align="center"><b>' . constant($game->sprache("TEXT9")) . '</b></td>
		<td width=75 align="center"><b>' . constant($game->sprache("TEXT10")) . '</b></td>
		<td width=150 align="center">' . $header5 . '</td></tr>');
    $name_title = constant($game->sprache("TEXT13"));
    $position_title = constant($game->sprache("TEXT14"));
    $condition_title = constant($game->sprache("TEXT15"));
    $status_title = constant($game->sprache("TEXT16"));
    $crew_title = constant($game->sprache("TEXT17"));
    $n = $queryfocus + 1;
    while (($ship = $db->fetchrow($shipquery)) != false) {
        /* Check ship Naval Construction Code */
        $name_desc = constant($game->sprache("TEXT19")) . ' ' . ($ship['ship_ncc'] != '' ? $ship['ship_ncc'] : '<i>' . constant($game->sprache("TEXT20")) . '</i>');
        /* Check ship current position */
        $position = '';
        $position_desc = '';
        if ($ship['fleet_id'] > 0) {
            $position = $ship['fleet_name'];
            /* Check il fleet is moving */
            if ($ship['fleet_target'] != 0) {
                $planet = $db->queryrow('SELECT planet_name FROM planets WHERE planet_id = ' . $ship['fleet_target']);
                $position_desc = constant($game->sprache("TEXT21")) . ' ' . $planet['planet_name'];
                $pos_link = parse_link('a=ship_fleets_display&pfleet_details=' . $ship['fleet_id']);
            } else {
                $position_desc = constant($game->sprache("TEXT22"));
                $pos_link = parse_link('a=ship_fleets_display&mfleet_details=' . $ship['fleet_id']);
            }
            /* Check ship current status */
            $status = '<font color=#80ff80>O</font>';
            $status_desc = constant($game->sprache("TEXT23"));
        } else {
            $position = $ship['planet_name'];
            $position_desc = constant($game->sprache("TEXT24"));
            /* Check ship current status */
            $status = '<font color=#ffff80>S</font>';
            $status_desc = constant($game->sprache("TEXT25"));
            $pos_link = 'javascript:void(0);';
        }
        /* Check ship conditions */
        $per_damage = round($ship['hitpoints'] / $ship['max_hitpoints'] * 100, 0);
        if ($per_damage > 75) {
            $condition = $ship['hitpoints'] . ' / ' . $ship['max_hitpoints'];
        } else {
            if ($per_damage > 50) {
                $condition = '<a href="javascript:void(0);" onmouseover="return overlib(\'' . constant($game->sprache("TEXT26")) . '\', CAPTION, \'' . $condition_title . '\', WIDTH, 250, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();"><font color=#ffff80>' . $ship['hitpoints'] . '</font></a> / ' . $ship['max_hitpoints'];
            } else {
                $condition = '<a href="javascript:void(0);" onmouseover="return overlib(\'' . constant($game->sprache("TEXT27")) . '\', CAPTION, \'' . $condition_title . '\', WIDTH, 250, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();"><font color=#ff8080>' . $ship['hitpoints'] . '</font></a> / ' . $ship['max_hitpoints'];
            }
        }
        /* Check ship status */
        if ($ship['ship_repair'] > 0) {
            $status = '<font color=#ff8080>R</font>';
            $status_desc = constant($game->sprache("TEXT28")) . '<br>' . TimeDetailShort($NEXT_TICK + 3 * 60 * ($ship['ship_repair'] - $ACTUAL_TICK)) . '.';
        }
        if ($ship['ship_scrap'] > 0) {
            $status = '<font color=#ff8080>D</font>';
            $status_desc = constant($game->sprache("TEXT29")) . '<br>' . TimeDetailShort($NEXT_TICK + 3 * 60 * ($ship['ship_scrap'] - $ACTUAL_TICK)) . '.';
        }
        if ($ship['ship_untouchable'] > 0 && $ship['ship_repair'] <= 0 && $ship['ship_scrap'] <= 0) {
            $status = 'U';
            $status_desc = constant($game->sprache("TEXT30"));
        }
        /* Check ship crew aboard */
        $crew = '';
        $crew_desc = constant($game->sprache("TEXT31"));
        if ($ship['unit_1'] + $ship['unit_2'] + $ship['unit_3'] + $ship['unit_4'] > 0) {
            $ncrew = 100 / ($ship['max_unit_1'] + $ship['max_unit_2'] + $ship['max_unit_3'] + $ship['max_unit_4']) * ($ship['unit_1'] + $ship['unit_2'] + $ship['unit_3'] + $ship['unit_4']);
            $ncrew = round($ncrew, 0);
            // Critical condition
            if ($ncrew > 0 && $ncrew <= 25) {
                $crew = '<font color=#ff8080>' . $ncrew . '%';
            } else {
                if ($ncrew > 25 && $ncrew <= 50) {
                    $crew = '<font color=#ffff80>' . $ncrew . '%';
                } else {
                    if ($ncrew > 50 && $ncrew <= 75) {
                        $crew = '<font color=#80ff80>' . $ncrew . '%';
                    } else {
                        if ($ncrew >= 75) {
                            $crew = $ncrew . '%';
                        }
                    }
                }
            }
            $crew_desc = '<img src=' . $game->GFX_PATH . 'menu_unit1_small.gif>&nbsp;' . $ship['unit_1'] . '&nbsp;&nbsp;' . addslashes($UNIT_NAME[$game->player['user_race']][0]) . '<br>';
            $crew_desc .= '<img src=' . $game->GFX_PATH . 'menu_unit2_small.gif>&nbsp;' . $ship['unit_2'] . '&nbsp;&nbsp;' . addslashes($UNIT_NAME[$game->player['user_race']][1]) . '<br>';
            $crew_desc .= '<img src=' . $game->GFX_PATH . 'menu_unit3_small.gif>&nbsp;' . $ship['unit_3'] . '&nbsp;&nbsp;' . addslashes($UNIT_NAME[$game->player['user_race']][2]) . '<br>';
            $crew_desc .= '<img src=' . $game->GFX_PATH . 'menu_unit4_small.gif>&nbsp;' . $ship['unit_4'] . '&nbsp;&nbsp;' . addslashes($UNIT_NAME[$game->player['user_race']][3]);
        }
        $game->out('
			<tr>
			<td>' . $n . '</td>
			<td>' . $ship['template_name'] . '</td>
			<td>
				<a href="' . parse_link('a=ships&view=ship_details&id=' . $ship['ship_id'] . '') . '" onmouseover="return overlib(\'' . $name_desc . '\', CAPTION, \'' . $name_title . '\', WIDTH, 300, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . ($ship['ship_name'] != '' ? $ship['ship_name'] : '<i>' . constant($game->sprache("TEXT67")) . '</i>') . '</a>
			</td>
			<td>
				<a href="' . $pos_link . '" onmouseover="return overlib(\'' . $position_desc . '\', CAPTION, \'' . $position_title . '\', WIDTH, 300, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $position . '</a>
			</td>
			<td align="center">' . $condition . '</td>
			<td align="center">
				<a href="javascript:void(0);" onmouseover="return overlib(\'' . $status_desc . '\', CAPTION, \'' . $status_title . '\', WIDTH, 200, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $status . '</a>
			</td>
			<td align="center">
				<a href="javascript:void(0);" onmouseover="return overlib(\'' . $crew_desc . '\', CAPTION, \'' . $crew_title . '\', WIDTH, 200, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $crew . '</a>
			</td>
			<td align="center">' . ($ship['awayteam'] == 0 ? constant($game->sprache("TEXT76")) . '<a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($ship['awayteamplanet_id'])) . '">' . $ship['mission_planet'] . '</a>' : intval($ship['awayteam'])) . '</td>
			</tr>');
        $n++;
    }
    $game->out('</table></td></tr></table>');
    /* AC: Pages browsing */
    $sql = 'SELECT COUNT(ship_id) AS n_ships
			FROM (ships s)
			INNER JOIN (ship_templates st) ON st.id = s.template_id
			WHERE user_id = ' . $game->player['user_id'] . ' AND st.ship_class IN (' . implode(',', $sels) . ')';
    $n_ships = $db->queryrow($sql);
    $max_pages = ceil($n_ships['n_ships'] / $shipsxpage);
    $game->out('<br><table border=0 cellpadding=1 cellspacing=1 class="style_outer" width=400><tr><td>
		<table border=0 cellpadding=2 cellspacing=2 class="style_inner" width=400><tr>
		<td width=50 align=middle>
			' . ($queryfocus > 0 ? '<a href="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=0') . '"><span class="text_large">[1]</a>' : '[1]') . '
		</td>
		<td width=150 align=middle>
			' . ($queryfocus > 0 ? '<a href="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . ($queryfocus - $shipsxpage)) . '"><span class="text_large">' . constant($game->sprache("TEXT32")) . '</a>' : '') . '
		</td>
		<td width=150 align=middle>
			' . ($queryfocus < $n_ships['n_ships'] - $shipsxpage ? '<a href="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . ($queryfocus + $shipsxpage)) . '"><span class="text_large">' . constant($game->sprache("TEXT33")) . '</a>' : '') . '
		</td>
		<td width=50 align=middle>
			' . ($queryfocus < $n_ships['n_ships'] - $shipsxpage ? '<a href="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . ($n_ships['n_ships'] - $shipsxpage)) . '"><span class="text_large">[' . $max_pages . ']</a>' : '[' . $max_pages . ']') . '
		</td>
		</tr></table></td></tr></table>');
    /* Show up ship's filter */
    $game->out('<br>
		<table border=0 cellpadding=1 cellspacing=1 class="style_outer" width=300><tr><td>
		<table border=0 cellpadding=1 cellspacing=1 class="style_inner" width=300>
		<tr>
		<td>
			<fieldset><legend>' . constant($game->sprache("TEXT68")) . '</legend>
			<table><tr>
			<td>
			<form name="stype0form" method="post" action="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . $queryfocus . '&filter=1') . '">
			<input type="checkbox" name="stype_0" value="1"' . ($_POST['stype_0'] == 1 ? ' checked="checked"' : '') . '  onChange="document.stype0form.submit()">' . constant($game->sprache("TEXT69")) . '
			</form>
			</td>
			<td>
			<form name="stype1form" method="post" action="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . $queryfocus . '&filter=2') . '">
			<input type="checkbox" name="stype_1" value="1"' . ($_POST['stype_1'] == 1 ? ' checked="checked"' : '') . '  onChange="document.stype1form.submit()">' . constant($game->sprache("TEXT70")) . '
			</form>
			</td>
			<td>
			<form name="stype2form" method="post" action="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . $queryfocus . '&filter=3') . '">
			<input type="checkbox" name="stype_2" value="1"' . ($_POST['stype_2'] == 1 ? ' checked="checked"' : '') . '  onChange="document.stype2form.submit()">' . constant($game->sprache("TEXT71")) . '
			</form>
			</td>
			<td>
			<form name="stype3form" method="post" action="' . parse_link('a=ships&order=' . $_REQUEST['order'] . '&start=' . $queryfocus . '&filter=4') . '">
			<input type="checkbox" name="stype_3" value="1"' . ($_POST['stype_3'] == 1 ? ' checked="checked"' : '') . '  onChange="document.stype3form.submit()">' . constant($game->sprache("TEXT72")) . '
			</form>
			</td></tr></table>
			</fieldset>
		</td>
		</tr></table></td></tr></table>');
}
          <td width="20">&nbsp;</td>
          <td width="360">' . $legend_html . $map_html . constant($game->sprache("TEXT91")) . '</font></td>
          <td width="20">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
    ');
    display_cartography_jump();
} else {
    if (empty($tc_views_map[$game->player['last_tcartography_view']])) {
        $sql = 'UPDATE user
                SET last_tcartography_view = 0,
                    last_tcartography_id = 0
                WHERE user_id = ' . $game->player['user_id'];
        if (!$db->query($sql)) {
            message(DATABASE_ERROR, 'Could not update user last tcartography data');
        }
        redirect('a=tactical_cartography&galaxy');
    }
    // workaround
    if ($game->player['last_tcartography_view'] == 3) {
        $game->player['last_tcartography_id'] = encode_system_id((int) $game->player['last_tcartography_id']);
    }
    if ($game->player['last_tcartography_view'] == 4) {
        $game->player['last_tcartography_id'] = encode_planet_id((int) $game->player['last_tcartography_id']);
    }
    redirect('a=tactical_cartography&' . sprintf($tc_views_map[$game->player['last_tcartography_view']], $game->player['last_tcartography_id']));
}
Example #19
0
    $unita1 = $unita1 + round($planet['unit_1'], 0);
    $unita2 = $unita2 + round($planet['unit_2'], 0);
    $unita3 = $unita3 + round($planet['unit_3'], 0);
    $unita4 = $unita4 + round($planet['unit_4'], 0);
    $unita5 = $unita5 + round($planet['unit_5'], 0);
    $unita6 = $unita6 + round($planet['unit_6'], 0);
    // Show the coordinates and the exchange symbol:
    if ($game->planet['planet_id'] == $planet['planet_id']) {
        $game->out('
			<tr><td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '"><span class="highlight">' . $planet['planet_name'] . '</span></a></td><td></td>
			<td>' . $game->get_sector_name($planet['sector_id']) . ':' . $game->get_system_cname($planet['system_x'], $planet['system_y']) . ':' . ($planet['planet_distance_id'] + 1) . '</td>
			<td></td>
			<td>' . $stat_out . '&nbsp;&nbsp;');
    } else {
        $game->out('
			<tr height=20><td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($planet['planet_id'])) . '">' . $planet['planet_name'] . '</a></td><td>[<a href="' . parse_link('a=headquarter&switch_active_planet=' . $planet['planet_id']) . '" title="' . constant($game->sprache("TEXT37")) . '">' . constant($game->sprache("TEXT38")) . '</a>]</td>
			<td>' . $game->get_sector_name($planet['sector_id']) . ':' . $game->get_system_cname($planet['system_x'], $planet['system_y']) . ':' . ($planet['planet_distance_id'] + 1) . '</td>
			<td><a href="javascript:void(0);" onmouseover="return overlib(\'' . $distance_str . '\', CAPTION, \'@ Warp 6.0\', WIDTH, 250, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $distance . '</a></td>
			<td>' . $stat_out . '&nbsp;&nbsp;');
    }
    // Output status of construction from above, etc. as well as the display of impending attack (it's set in the scheduler):
    $attack = $planet['planet_next_attack'];
    if ($game->option_retr('redalert_options') == 2) {
        $attack = 0;
    }
    if ($game->option_retr('redalert_options') == 1 && $attack - date() > 3600 * 24 * 7) {
        $attack = 0;
    }
    $game->out('</td><td>' . ($attack > 0 ? '<font color=red><b>' . constant($game->sprache("TEXT39")) . ' </b>' . date('d.m.y H:i', $attack) . '</font></b><br>' : '') . $status . '</td><td>' . $planet['planet_points'] . '</td><td>' . strtoupper($planet['planet_type']) . '</td></tr>');
}
// End of the planets table
    <td width="90"><b>' . constant($game->sprache("TEXT48")) . '</b></td>
  </tr>');
    $sql = 'SELECT sr.planet_id, p.planet_name, p.best_mood, p.best_mood_user,
                   p.sector_id, ss.system_x, ss.system_y, p.planet_distance_id,
                   p.planet_type, MAX(timestamp) AS last_time, SUM(mood_modifier) AS mood
            FROM settlers_relations sr
            INNER JOIN planets p on sr.planet_id = p.planet_id
            INNER JOIN starsystems ss on p.system_id = ss.system_id
            WHERE sr.user_id = ' . $game->player['user_id'] . '
            GROUP BY planet_id';
    $q_p_setdiplo = $db->query($sql);
    $rows = $db->num_rows($q_p_setdiplo);
    $sett_diplo = $db->fetchrowset($q_p_setdiplo);
    for ($i = 0; $i < $rows; $i++) {
        $game->out('<tr>');
        // Name
        $game->out('<td width="140"><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($sett_diplo[$i]['planet_id'])) . '">' . $sett_diplo[$i]['planet_name'] . '</a></td>');
        // Position
        $game->out('<td width="80">' . $game->get_sector_name($sett_diplo[$i]['sector_id']) . ':' . $game->get_system_cname($sett_diplo[$i]['system_x'], $sett_diplo[$i]['system_y']) . ':' . ($sett_diplo[$i]['planet_distance_id'] + 1) . '</td>');
        // Class
        $game->out('<td width="40">' . strtoupper($sett_diplo[$i]['planet_type']) . '</td>');
        // Mood
        $game->out('<td width="60"><span style="color: ' . ($game->player['user_id'] == $sett_diplo[$i]['best_mood_user'] || $sett_diplo[$i]['mood'] > $sett_diplo[$i]['best_mood'] ? 'green' : 'red') . '">' . $sett_diplo[$i]['mood'] . '</span></td>');
        // Last Mission Time
        $game->out('<td width="100">' . date("d.m.y H:i", $sett_diplo[$i]['last_time']) . '</td>');
        $game->out('</tr>');
    }
    $game->out('
  </table></td></tr></table>
    ');
}