if (empty($SecTarget)) {
    $SecTarget = 'Beta';
}
if (!isset($Game_Scrn_Type)) {
    $Game_Scrn_Type = 1;
}
postHead('');
AuthUser("{$Pl_Value['USERNAME']}", "{$Pl_Value['PASSWORD']}");
if ($CFU_Time >= $TIMEAUTH + $TIME_OUT_TIME || $TIMEAUTH <= $CFU_Time - $TIME_OUT_TIME) {
    echo "連線逾時!<br>請重新登入!";
    exit;
}
mt_srand((double) microtime() * 1000000);
include 'includes/sfo.class.php';
include 'includes/obattle.ext.php';
$Pl = new oBattle();
$Pl->SetUser($Pl_Value['USERNAME']);
$Pl->FetchPlayer(true, true);
if ($CFU_Time - $Pl->Player['btltime'] < $Btl_Intv) {
    echo "距離上次攻擊或移動的時間太短了!<br>請在 " . ($Btl_Intv - ($CFU_Time - $Pl->Player['btltime'])) . " 秒後再進行攻擊!";
    exit;
}
if ($Pl->Player['msuit']) {
    $Pl->ProcessAllWeapon();
    $Pl_Repaired = RepairPlayer($Pl->Player, $Pl->Eq['D'], $Pl->Eq['E']);
    $Pl->Player['hp'] = $Pl_Repaired['hp'];
    $Pl->Player['en'] = $Pl_Repaired['en'];
    $Pl->Player['sp'] = $Pl_Repaired['sp'];
    $Pl->Player['status'] = $Pl_Repaired['status'];
    $t_now = $Pl->Player['time1'] = $Pl_Repaired['time1'];
    if ($Pl->Player['status']) {
             $i++;
         }
         $d_sql_where .= " ) AND `ga`.`username` = `ge`.`username`";
     } else {
         $d_sql_where = ' 0 ';
     }
     $sql = "SELECT COUNT(*) AS `num` FROM `" . $GLOBALS['DBPrefix'] . "phpeb_user_game_info` `ga`,`" . $GLOBALS['DBPrefix'] . "phpeb_user_general_info` `ge` WHERE !`status` AND `coordinates` = '{$Pl->Player[coordinates]}' AND " . $d_sql_where;
     $query = mysql_query($sql) or die(mysql_error() . '<br>' . $sql . '<hr>');
     $d = mysql_fetch_array($query);
     if ($d['num'] > 0) {
         echo "請先攻擊守衛!";
         postFooter();
         exit;
     }
     // Create Fort Information - Start
     $Op = new oBattle();
     $AtkFortFlag = 1;
     $Op->Player = array("username" => '<AttackFort>', "name" => '<AttackFort>', "bounty" => 0, "color" => "{$Area_Org['color']}", "msuit" => '<AttackFort>', "typech" => "nat", "hypermode" => 0, "coordinates" => $Pl->Player['coordinates'], "fame" => "0", "time2" => "0", "gamename" => '防禦要塞', "hp" => $Area["User"]["hp"], "hpmax" => $Area["User"]["hpmax"], "en" => "100000", "enmax" => "100000", "attacking" => $Area_Pi, "defending" => $Area_Pi, "reacting" => 1, "targeting" => $Area_Pi, "level" => $Area_Pi, "ms_custom" => "", "expr" => "0", "wepa" => $Area["User"]["wepa"] . "<!>25000", "wepb" => "0<!>0", "wepc" => "0<!>0", "eqwep" => "0<!>0", "p_equip" => "0<!>0", "spec" => "", "show_log_num" => 0, "rank" => "100000", "rights" => "1", "organization" => "{$Area_Org['id']}", "status" => "0", "tactics" => "DefCounterA\nTripleStrike\nMindStrike\nFirstStrike\nSenseStrike");
     // Create Fort Information - Done
 }
 if ($Op->Player['status']) {
     echo "對手修理中..";
     postFooter();
     exit;
 }
 if (substr($Op->Player['coordinates'], 0, 2) != substr($Pl->Player['coordinates'], 0, 2)) {
     echo "看不見對手..<br>對方位置: " . $Op->Player['coordinates'] . " 自己位置: " . $Pl->Player['coordinates'];
     postFooter();
     exit;
 }
 $Op_Org = $Area['User']['occupied'] != $Op->Player['organization'] ? ReturnOrg($Op->Player['organization']) : $Area_Org;