示例#1
0
function DISPLAY_ALL_ALLIANCES()
{
   global $color, $color_header, $order, $type, $PHP_SELF, $l_team_galax, $l_team_member, $l_team_coord, $l_score, $l_name;
   global $db, $dbtables;

   echo "<h2>$l_team_galax</h2>";
   echo "<TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2>";
   echo "<TR BGCOLOR=\"$color_header\">";
   echo "<TD><B>Rank</B></TD>";
   echo "<TD><B>$l_name</B></TD>";
   echo "<TD><B>$l_score</B></TD>";
   echo "</TR>";
   $sql_query = "SELECT $dbtables[players].character_name,
                     COUNT(*) as number_of_members,
                     ROUND(SQRT(SUM(POW($dbtables[players].score,2)))) as total_score,
                     $dbtables[teams].id,
                     $dbtables[teams].team_name
                  FROM $dbtables[players]
                  LEFT JOIN $dbtables[teams] ON $dbtables[players].team = $dbtables[teams].id
                  WHERE $dbtables[players].team = $dbtables[teams].id
                  GROUP BY $dbtables[teams].team_name ORDER BY total_score DESC";
   $res = $db->Execute($sql_query) or die($db->ErrorMsg());
   $rank = 1;
   while(!$res->EOF) {
    $row = $res->fields;
   	echo "<TR BGCOLOR=\"$color\">";
	echo "<TD><B>$rank</B></TD>";
	$rank++;
   	echo "<TD>".$row[team_name]."</TD>";
   	echo "<TD>".NUMBER($row[total_score])."</TD>";
   	echo "</TR>";
    $res->MoveNext();
   }
   echo "</table><BR>";
}
示例#2
0
function display_transactions()
{
    global $db, $dbtables;
    $res5 = $db->Execute("SELECT * FROM {$dbtables['fair_tribe']} " . "WHERE clan_id = '{$_SESSION['clanid']}' " . "ORDER BY trans_id");
    echo "<P>" . "<CENTER>" . "<TABLE CLASS=color_table BORDER=1 CELLPADDING=4 CELLSPACING=0>" . "<TR CLASS=color_header>" . "<TD>Buy/Sell</TD>" . "<TD>Product</TD>" . "<TD>Quantity</TD>" . "<TD>Price</TD>" . "<TD>Total</TD>" . "<TD>Cancel</TD>" . "</TR>";
    $r = 0;
    while (!$res5->EOF) {
        $rc = $r % 2;
        $r++;
        $output = $res5->fields;
        echo "<TR CLASS=color_row{$rc}>";
        if ($output[buy_sell] == 'B') {
            echo "<TD>Buy</TD>";
        } elseif ($output[buy_sell] == 'S') {
            echo "<TD>Sell</TD>";
        } elseif ($output[buy_sell] == 'C') {
            echo "<TD>Culture</TD>";
        }
        $total = $output[price] * $output[quantity];
        if ($output[buy_sell] == 'C') {
            $total = $output[price];
        }
        echo "<TD>{$output['product']}</TD>" . "<TD>{$output['quantity']}</TD>" . "<TD>{$output['price']}</TD>" . "<TD>";
        $total = NUMBER($total);
        echo "{$total}</TD>" . "<TD>" . "<FORM ACTION=fair.php METHOD=POST><INPUT TYPE=HIDDEN NAME=transaction VALUE=\"{$output['buy_sell']}\">" . "<INPUT TYPE=HIDDEN NAME=quantity VALUE=\"{$output['quantity']}\">" . "<INPUT TYPE=HIDDEN NAME=cancel_trans_id VALUE=\"{$output['trans_id']}\">" . "<INPUT TYPE=HIDDEN NAME=cancel_product VALUE=\"{$output['product']}\">" . "<INPUT TYPE=SUBMIT VALUE=CANCEL>" . "</FORM>" . "</TD>" . "</TR>";
        $res5->MoveNext();
    }
    echo "</TABLE>" . "</CENTER>";
}
        $gm = $db->Execute("SELECT * FROM {$dbtables['game_date']} WHERE type = 'month'");
        $gy = $db->Execute("SELECT * FROM {$dbtables['game_date']} WHERE type = 'year'");
        $month = $gm->fields;
        $year = $gy->fields;
        $curdate = "{$month['count']} / {$year['count']}";
        $online = " ";
        $now = time();
        $onlinenow = $now - $row[hour];
        $onlineminutes = floor($onlinenow / 60);
        if ($onlineminutes < 10) {
            $online = "Y";
        }
        if ($i == 11) {
            echo "<TR><TD COLSPAN=9>&nbsp;</TD></TR>";
        }
        echo "<TR BGCOLOR=\"{$color}\" ALIGN=CENTER><TD>" . NUMBER($i) . "</TD><TD>{$claninfo['clanid']}</TD><TD>";
        echo "&nbsp;";
        echo "&nbsp;";
        echo "<b>{$row['chiefname']}</b></TD>";
        echo "<TD>({$battles})</TD>";
        echo "<TD>{$claninfo['clanname']}</TD><TD>{$time}</TD><TD>&nbsp;&nbsp;</TD><TD>{$claninfo['religion']}</TD><TD>{$online}</TD><TD>{$row['score']}</TD></TR>\n";
        if ($color == $color_line1) {
            $color = $color_line2;
        } else {
            $color = $color_line1;
        }
        $res->MoveNext();
    }
    echo "</TABLE>";
}
echo "<FONT SIZE=+1>Current Date is {$curdate}</FONT><P>";
示例#4
0
               "<tr><td><font size=2><b>Armour</b> ($sship[minarmour]/$sship[maxarmour])</td>" .
               "<td valign=bottom>$armour_bars</td></tr>" .
               "<tr><td><font size=2><b>Shields</b> ($sship[minshields]/$sship[maxshields])</td>" .
               "<td valign=bottom>$shields_bars</td></tr>" .
               "<tr><td><font size=2><b>Beams</b> ($sship[minbeams]/$sship[maxbeams])</td>" .
               "<td valign=bottom>$beams_bars</td></tr>" .
               "<tr><td><font size=2><b>Torpedo Launchers</b> ($sship[mintorp_launchers]/$sship[maxtorp_launchers])</td>" .
               "<td valign=bottom>$torp_launchers_bars</td></tr>" .
               "<tr><td><font size=2><b>Cloak</b> ($sship[mincloak]/$sship[maxcloak])</td>" .
			 "<td valign=bottom>$cloak_bars</td></tr>" .
			 "<tr><td><font color=white size=4><b><br>Price: </b></td>" .
			 "<td><font color=red size=4><b><br>" . NUMBER($sship[cost_credits]) . " C</b></td></tr>" .
			 "<tr><td><font color=white size=4><b><br>You have: </b></td>" .
			 "<td><font color=green size=4><b><br>" . NUMBER($playerinfo[credits]) . " C</b></td></tr>" .
			 "<tr><td><font color=white size=4><b>Current ship<br>trade-in value: </b></td>" .
			 "<td><font color=white size=4><b><br>" . NUMBER(0.8*value_ship($playerinfo[currentship])) . " C</b></td></tr>".
			 "</table><p>";
		  echo "<form action=shipyard2.php method=POST>" .
			   "<input type=hidden name=stype value=$stype>" .
			   "<input type=submit value=Purchase>" .
			   "</form><br>";
		echo "<font size=2 color=silver><b><a href=shipyard3.php>Return to shipyard</a></b></font><p>";
  }
} else {

?>

  <table width=100% border=1 cellpadding=5>
    <tr bgcolor=<? echo $color_line2 ?>><td width=10% align=center>
<?
echo "<font size=2 color=white><b>Welcome to our shipyard!<br>";
示例#5
0
echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_armourpts</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[armour_pts]) . " / " . NUMBER($armour_pts_max) . "</TD></TR>";
echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_fighters</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[ship_fighters]) . " / " . NUMBER($ship_fighters_max) . "</TD></TR>";
echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_torps</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[torps]) . " / " . NUMBER($torps_max) . "</TD></TR>";
//echo "<TR><TD>&nbsp;</TD></TR>";
echo "</TABLE><p>";
//echo "</TD><TD VALIGN=TOP>";
echo "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%\">";
$energy_max = NUM_ENERGY($shipinfo[power]);
echo "<TR BGCOLOR=\"$color_header\"><TD><B>$l_energy</B></TD><TD ALIGN=RIGHT><B>" . NUMBER($shipinfo[ship_energy]) . " / " . NUMBER($energy_max) . "</B></TD></TR>";
echo "</TABLE><P>";
echo "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%\">";
echo "<TR BGCOLOR=\"$color_header\"><TD COLSPAN=2 align=center><B>$l_devices</B></TD></TR>";
echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_beacons</TD><TD ALIGN=RIGHT>$shipinfo[dev_beacon]</TD></TR>";
echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_warpedit</TD><TD ALIGN=RIGHT>$shipinfo[dev_warpedit]</TD></TR>";
echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_genesis</TD><TD ALIGN=RIGHT>$shipinfo[dev_genesis]</TD></TR>";
echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_deflect</TD><TD ALIGN=RIGHT>".NUMBER($shipinfo[dev_minedeflector])."</TD></TR>";
echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_ewd</TD><TD ALIGN=RIGHT>$shipinfo[dev_emerwarp]</TD></TR>";
$escape_pod = ($shipinfo[dev_escapepod] == 'Y') ? $l_yes : $l_no;
$fuel_scoop = ($shipinfo[dev_fuelscoop] == 'Y') ? $l_yes : $l_no;
$lssd = ($shipinfo[dev_lssd] == 'Y') ? $l_yes : $l_no;
echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_escape_pod</TD><TD ALIGN=RIGHT>$escape_pod</TD></TR>";
echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_fuel_scoop</TD><TD ALIGN=RIGHT>$fuel_scoop</TD></TR>";
echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_lssd</TD><TD ALIGN=RIGHT>$lssd</TD></TR>";
$sectorwmd = ($shipinfo[dev_sectorwmd] == 'Y') ? $l_yes : $l_no;
if ($sectorwmd == $l_yes) {
	echo "<TR BGCOLOR=\"$color_line1\"><TD>Sector-WMD</TD><TD ALIGN=RIGHT>$sectorwmd</TD></TR>";
}
//echo "<TR><TD>&nbsp;</TD></TR>";
echo "</TABLE>";

//echo "</TD></TR>";
示例#6
0
<?


include("config.php");
include("languages/$lang");
$title = "Logout";

setcookie("username","",0);
setcookie("password","",0);

include("header.php");

connectdb();

$result = $db->Execute("SELECT * FROM $dbtables[players] WHERE email='$username'");
$playerinfo = $result->fields;

$current_score = gen_score($playerinfo[player_id]);
playerlog($playerinfo[player_id], LOG_LOGOUT, $ip);

bigtitle();
echo "$l_logout_score ".NUMBER($current_score).".<BR>";
$l_logout_text=str_replace("[name]",$username,$l_logout_text);
echo $l_logout_text;

include("footer.php");

?>
示例#7
0
          }
          $ship_value=$upgrade_cost*(floor(mypw($upgrade_factor, $shipinfo[hull]))+floor(mypw($upgrade_factor, $shipinfo[engines]))+floor(mypw($upgrade_factor, $shipinfo[power]))+floor(mypw($upgrade_factor, $shipinfo[computer]))+floor(mypw($upgrade_factor, $shipinfo[sensors]))+floor(mypw($upgrade_factor, $shipinfo[beams]))+floor(mypw($upgrade_factor, $shipinfo[torp_launchers]))+floor(mypw($upgrade_factor, $shipinfo[shields]))+floor(mypw($upgrade_factor, $shipinfo[armour]))+floor(mypw($upgrade_factor, $shipinfo[cloak])));
          $ship_salvage_rate=rand(10,20);
          $ship_salvage=$ship_value*$ship_salvage_rate/100;
		  // Triple salvage if you were an outlaw
		  $result3 = $db->Execute ("SELECT amount FROM $dbtables[bounty] WHERE placed_by=0 AND bounty_on=$playerinfo[player_id]");
		  if (!$result3->EOF) {
		  	echo "Triple outlaw salvage bonus for $targetinfo[character_name]!<br>";
		  	$ship_salvage *=3;
		  }

          $l_att_salv=str_replace("[salv_ore]",NUMBER($salv_ore),$l_att_salv);
          $l_att_salv=str_replace("[salv_organics]",NUMBER($salv_organics),$l_att_salv);
          $l_att_salv=str_replace("[salv_goods]",NUMBER($salv_goods),$l_att_salv);
          $l_att_salv=str_replace("[ship_salvage_rate]",$ship_salvage_rate,$l_att_salv);
          $l_att_salv=str_replace("[ship_salvage]",NUMBER($ship_salvage),$l_att_salv);
          $l_att_salv=str_replace("[name]",$targetinfo[character_name],$l_att_salv);

          echo "<b>$l_att_salv</b><BR>";
          $update6 = $db->Execute ("UPDATE $dbtables[players] SET credits=credits+$ship_salvage WHERE player_id=$targetinfo[player_id]");
          $armour_lost=$targetshipinfo[armour_pts]-$targetarmour;
          $fighters_lost=$targetshipinfo[ship_fighters]-$targetfighters;
          $energy=$targetshipinfo[ship_energy];
          $update6b = $db->Execute ("UPDATE $dbtables[ships] SET ship_energy=$energy,ship_fighters=ship_fighters-$fighters_lost, armour_pts=armour_pts-$armour_lost, torps=torps-$targettorpnum,ship_ore=ship_ore+$salv_ore, ship_organics=ship_organics+$salv_organics, ship_goods=ship_goods+$salv_goods WHERE player_id=$targetinfo[player_id] AND ship_id=$targetinfo[currentship]");
        }
      }
    }
  }
}
$db->Execute("UNLOCK TABLES");
//-------------------------------------------------------------------------------------------------
示例#8
0
echo "<TD><A HREF=warpedit.php$ck>$l_warpedit</A></TD><TD>" . NUMBER($shipinfo[dev_warpedit]) . "</TD><TD>$l_manual</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line1\">";
echo "<TD><A HREF=genesis.php$ck>$l_genesis</A></TD><TD>" . NUMBER($shipinfo[dev_genesis]) . "</TD><TD>$l_manual</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line2\">";
echo "<TD>$l_deflect</TD><TD>" . NUMBER($shipinfo[dev_minedeflector]) . "</TD><TD>$l_automatic</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line1\">";
echo "<TD><A HREF=mines.php$ck&op=1>$l_mines</A></TD><TD>" . NUMBER($shipinfo[torps]) . "</TD><TD>$l_manual</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line2\">";
echo "<TD><A HREF=mines.php$ck&op=2>$l_fighters</A></TD><TD>" . NUMBER($shipinfo[ship_fighters]) . "</TD><TD>$l_manual</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line1\">";
echo "<TD><A HREF=emerwarp.php$ck>$l_ewd</A></TD><TD>" . NUMBER($shipinfo[dev_emerwarp]) . "</TD><TD>$l_manual/$l_automatic</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line2\">";
echo "<TD>$l_escape_pod</TD><TD>" . (($shipinfo[dev_escapepod] == 'Y') ? $l_yes : $l_no) . "</TD><TD>$l_automatic</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line1\">";
echo "<TD>$l_fuel_scoop</TD><TD>" . (($shipinfo[dev_fuelscoop] == 'Y') ? $l_yes : $l_no) . "</TD><TD>$l_automatic</TD>";
echo "</TR>";
echo "<TR BGCOLOR=\"$color_line2\">";
echo "<TD>$l_lssd</TD><TD>" . (($shipinfo[dev_lssd] == 'Y') ? $l_yes : $l_no) . "</TD><TD>$l_automatic</TD>";
echo "</TR>";
if ($shipinfo[tow]>0) {
	echo "<TR BGCOLOR=\"$color_line1\">";
	echo "<TD><A HREF=tractor.php$ck&cmd=rel>Release Tractor Beam</TD><TD>Active</TD><TD>$l_manual</TD>";
	echo "</TR>";
} else {
示例#9
0
    }
    else
    {
      /* if scan succeeds, show results and inform target. */
      /* scramble results by scan error factor. */

      // Get total bounty on this player, if any
      $btyamount = 0;
      $hasbounty = $db->Execute("SELECT SUM(amount) AS btytotal FROM $dbtables[bounty] WHERE bounty_on = $targetinfo[player_id]");

      if($hasbounty)
      {
         $resx = $hasbounty->fields;
         if($resx[btytotal] > 0) 
         {
            $btyamount = NUMBER($resx[btytotal]);
            $l_scan_bounty=str_replace("[amount]",$btyamount,$l_scan_bounty);
            echo $l_scan_bounty . "<BR>";
            $btyamount = 0;
            // Check for Federation bounty
            $hasfedbounty = $db->Execute("SELECT SUM(amount) AS btytotal FROM $dbtables[bounty] WHERE bounty_on = $targetinfo[player_id] AND placed_by = 0");
            if($hasfedbounty)
            {
               $resy = $hasfedbounty->fields;
               if($resy[btytotal] > 0) 
               { 
                  $btyamount = $resy[btytotal];
                  echo $l_scan_fedbounty . "<BR>";
               }
            }
         }
示例#10
0
                $trade_color = "#fff";
                $trade_result = "{$l_cost} : ";
            } elseif ($total_cost < 0) {
                $trade_color = $color_green;
                $trade_result = $trade_benefit;
            } else {
                $trade_color = $color_red;
                $trade_result = $trade_deficit;
            }
            /*
            Build table
            */
            ?>
    <div class="general-table-container">
    <?php 
            echo "<table><tbody>\n                    <tr>\n                        <td colspan=\"2\">{$l_trade_result}</td>\n                    </tr>\n                    <tr>\n                        <td colspan=\"2\">Total Trade Cost: <span class=\"table_word_yellow\">" . NUMBER(abs($total_cost)) . "</span> Credits</td>\n                    </tr>\n                    <tr>\n                        <td>{$l_traded_ore}:</td><td>" . NUMBER($trade_ore) . "</td>\n                    </tr>\n                   <tr>\n                        <td>{$l_traded_organics}: </td><td>" . NUMBER($trade_organics) . "</td>\n                    </tr>\n                    <tr>\n                        <td>{$l_traded_goods}: </td><td>" . NUMBER($trade_goods) . "</td>\n                    </tr>\n                    <tr>\n                        <td>{$l_traded_energy}: </td><td>" . NUMBER($trade_energy) . "</td>\n                    </tr>\n                    </tbody></table></div>";
            // Update ship cargo, credits and turns
            $trade_result = $db->Execute("UPDATE {$db->prefix}ships SET turns=turns-1, turns_used=turns_used+1, rating=rating+1, credits=credits-{$total_cost}, ship_ore=ship_ore+{$trade_ore}, ship_organics=ship_organics+{$trade_organics}, ship_goods=ship_goods+{$trade_goods}, ship_energy=ship_energy+{$trade_energy} WHERE ship_id={$playerinfo['ship_id']}");
            db_op_result($db, $trade_result, __LINE__, __FILE__, $db_logging);
            // Make all trades positive to change port values
            $trade_ore = round(abs($trade_ore));
            $trade_organics = round(abs($trade_organics));
            $trade_goods = round(abs($trade_goods));
            $trade_energy = round(abs($trade_energy));
            // Decrease supply and demand on port
            $trade_result2 = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-{$trade_ore}, port_organics=port_organics-{$trade_organics}, port_goods=port_goods-{$trade_goods}, port_energy=port_energy-{$trade_energy} WHERE sector_id={$sectorinfo['sector_id']}");
            db_op_result($db, $trade_result2, __LINE__, __FILE__, $db_logging);
            echo $l_trade_complete . ".<br><br>";
        }
    }
}
示例#11
0
function shiptoship($target_id)
{
	global $upgrade_cost, $upgrade_factor;
    global $attackerbeams;
    global $attackerfighters;
    global $attackershields;
    global $attackertorps;
    global $attackerarmor;
    global $attackertorpdamage;
    global $start_energy;
    global $playerinfo;
    global $l_cmb_attackershields, $l_cmb_attackertorps, $l_cmb_attackerarmor, $l_cmb_attackertorpdamage;
    global $l_cmb_startingstats, $l_cmb_statattackerbeams, $l_cmb_statattackerfighters, $l_cmb_statattackershields, $l_cmb_statattackertorps;
    global $l_cmb_statattackerarmor, $l_cmb_statattackertorpdamage, $l_cmb_isattackingyou, $l_cmb_beamexchange, $l_cmb_beamsdestroy;
    global $l_cmb_beamsdestroy2, $l_cmb_nobeamsareleft, $l_cmb_beamshavenotarget, $l_cmb_fighterdestroyedbybeams, $l_cmb_beamsdestroystillhave;
    global $l_cmb_fighterunhindered, $l_cmb_youhavenofightersleft, $l_cmb_breachedsomeshields, $l_cmb_shieldsarehitbybeams, $l_cmb_nobeamslefttoattack;
    global $l_cmb_yourshieldsbreachedby, $l_cmb_yourshieldsarehit, $l_cmb_hehasnobeamslefttoattack, $l_cmb_yourbeamsbreachedhim;
    global $l_cmb_yourbeamshavedonedamage, $l_cmb_nobeamstoattackarmor, $l_cmb_yourarmorbreachedbybeams, $l_cmb_yourarmorhitdamaged;
    global $l_cmb_torpedoexchange, $l_cmb_hehasnobeamslefttoattackyou, $l_cmb_yourtorpsdestroy, $l_cmb_yourtorpsdestroy2;
    global $l_cmb_youhavenotorpsleft, $l_cmb_hehasnofighterleft, $l_cmb_torpsdestroyyou, $l_cmb_someonedestroyedfighters, $l_cmb_hehasnotorpsleftforyou;
    global $l_cmb_youhavenofightersanymore, $l_cmb_youbreachedwithtorps, $l_cmb_hisarmorishitbytorps, $l_cmb_notorpslefttoattackarmor;
    global $l_cmb_yourarmorbreachedbytorps, $l_cmb_yourarmorhitdmgtorps, $l_cmb_hehasnotorpsforyourarmor, $l_cmb_fightersattackexchange;
    global $l_cmb_enemylostallfighters, $l_cmb_helostsomefighters, $l_cmb_youlostallfighters, $l_cmb_youalsolostsomefighters, $l_cmb_hehasnofightersleftattack;
    global $l_cmb_younofightersattackleft, $l_cmb_youbreachedarmorwithfighters, $l_cmb_youhitarmordmgfighters, $l_cmb_youhavenofighterstoarmor;
    global $l_cmb_hasbreachedarmorfighters, $l_cmb_yourarmorishitfordmgby, $l_cmb_nofightersleftheforyourarmor, $l_cmb_hehasbeendestroyed;
    global $l_cmb_escapepodlaunched, $l_cmb_yousalvaged, $l_cmb_youdidntdestroyhim, $l_cmb_shiptoshipcombatstats;
    global $db, $dbtables;

    //$db->Execute("LOCK TABLES $dbtables[players] WRITE, $dbtables[ships] WRITE, $dbtables[universe] WRITE, $dbtables[zones] READ");
    $result2 = $db->Execute ("SELECT * FROM $dbtables[ships] WHERE ship_id=$target_id");
    $targetshipinfo=$result2->fields;
    $result2 = $db->Execute ("SELECT * FROM $dbtables[players] WHERE player_id=$targetshipinfo[player_id]");
    $targetinfo=$result2->fields;

    $targetbeams = NUM_BEAMS($targetshipinfo[beams]);
    if($targetbeams>$targetshipinfo[ship_energy])
    {
        $targetbeams=$targetshipinfo[ship_energy];
    }
    $targetshipinfo[ship_energy]=$targetshipinfo[ship_energy]-$targetbeams;
    $targetshields = NUM_SHIELDS($targetshipinfo[shields]);
    if($targetshields>$targetshipinfo[ship_energy])
    {
        $targetshields=$targetshipinfo[ship_energy];
    }
    $targetshipinfo[ship_energy]=$targetshipinfo[ship_energy]-$targetshields;

    $targettorpnum = round(mypw($level_factor,$targetshipinfo[torp_launchers]))*2;
    if($targettorpnum > $targetshipinfo[torps])
    {
        $targettorpnum = $targetshipinfo[torps];
    }
    $targettorpdmg = $torp_dmg_rate*$targettorpnum;
    $targetarmor = $targetshipinfo[armour_pts];
    $targetfighters = $targetshipinfo[ship_fighters];
    $targetdestroyed = 0;
    $playerdestroyed = 0;
    echo "-->$targetshipinfo[ship_name] $l_cmb_isattackingyou<BR><BR>";
	// ***************** BEAM EXCHANGE *************************
    echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_beamexchange</font><BR>";
    if($targetfighters > 0 && $attackerbeams > 0)
    {
        if($attackerbeams > round($targetfighters / 2))
        {
            $temp = round($targetfighters/2);
            $lost = $targetfighters-$temp;
            $targetfighters = $temp;
            $attackerbeams = $attackerbeams-$lost;
            $l_cmb_beamsdestroy = str_replace("[cmb_lost]", $lost, $l_cmb_beamsdestroy);
            echo "<-- $l_cmb_beamsdestroy<BR>";
        }
        else
        {
            $targetfighters = $targetfighters-$attackerbeams;
            $l_cmb_beamsdestroy2 = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_beamsdestroy2);
            echo "--> $l_cmb_beamsdestroy2<BR>";
            $attackerbeams = 0;
        }
    }
    elseif ($targetfighters > 0 && $attackerbeams < 1)
    echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_nobeamsareleft</font><BR>";
    else
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_beamshavenotarget</font><BR>";
    if($attackerfighters > 0 && $targetbeams > 0)
    {
        if($targetbeams > round($attackerfighters / 2))
        {
            $temp=round($attackerfighters/2);
            $lost=$attackerfighters-$temp;
            $attackerfighters=$temp;
            $targetbeams=$targetbeams-$lost;
            $l_cmb_fighterdestroyedbybeams = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_fighterdestroyedbybeams);
            $l_cmb_fighterdestroyedbybeams = str_replace("[cmb_lost]", $lost, $l_cmb_fighterdestroyedbybeams);
            echo "--> $l_cmb_fighterdestroyedbybeams";
        }
        else
        {
            $attackerfighters=$attackerfighters-$targetbeams;
            $l_cmb_beamsdestroystillhave = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_beamsdestroystillhave);
            $l_cmb_beamsdestroystillhave = str_replace("[cmb_targetbeams]", $targetbeams, $l_cmb_beamsdestroystillhave);
            $l_cmb_beamsdestroystillhave = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_beamsdestroystillhave);
            echo "<-- $l_cmb_beamsdestroystillhave<BR>";
            $targetbeams=0;
        }
    }
    elseif ($attackerfighters > 0 && $targetbeams < 1)
    echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_fighterunhindered</font><BR>";
    else
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_youhavenofightersleft</font><BR>";
    if($attackerbeams > 0)
    {
        if($attackerbeams > $targetshields)
        {
            $attackerbeams=$attackerbeams-$targetshields;
            $targetshields=0;
            $l_cmb_breachedsomeshields = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_breachedsomeshields);
            echo "<-- $l_cmb_breachedsomeshields<BR>";
        }
        else
        {
            $l_cmb_shieldsarehitbybeams = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_shieldsarehitbybeams);
            $l_cmb_shieldsarehitbybeams = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_shieldsarehitbybeams);
            echo "$l_cmb_shieldsarehitbybeams<BR>";
            $targetshields=$targetshields-$attackerbeams;
            $attackerbeams=0;
        }
    }
    else
    {
        $l_cmb_nobeamslefttoattack = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_nobeamslefttoattack);
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_nobeamslefttoattack</font><BR>";
    }
    if($targetbeams > 0)
    {
        if($targetbeams > $attackershields)
        {
            $targetbeams=$targetbeams-$attackershields;
            $attackershields=0;
            $l_cmb_yourshieldsbreachedby = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourshieldsbreachedby);
            echo "--> $l_cmb_yourshieldsbreachedby<BR>";
        }
        else
        {
            $l_cmb_yourshieldsarehit = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourshieldsarehit);
            $l_cmb_yourshieldsarehit = str_replace("[cmb_targetbeams]", $targetbeams, $l_cmb_yourshieldsarehit);
            echo "<-- $l_cmb_yourshieldsarehit<BR>";
            $attackershields=$attackershields-$targetbeams;
            $targetbeams=0;
        }
    }
    else
    {
        $l_cmb_hehasnobeamslefttoattack = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnobeamslefttoattack);
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_hehasnobeamslefttoattack</font><BR>";
    }
    if($attackerbeams > 0)
    {
        if($attackerbeams > $targetarmor)
        {
            $targetarmor=0;
            $l_cmb_yourbeamsbreachedhim = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourbeamsbreachedhim);
            echo "--> $l_cmb_yourbeamsbreachedhim<BR>";
        }
        else
        {
            $targetarmor=$targetarmor-$attackerbeams;
            $l_cmb_yourbeamshavedonedamage = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_yourbeamshavedonedamage);
            $l_cmb_yourbeamshavedonedamage = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourbeamshavedonedamage);
            echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_yourbeamshavedonedamage</font><BR>";
        }
    }
    else
    {
        $l_cmb_nobeamstoattackarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_nobeamstoattackarmor);
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_nobeamstoattackarmor</font><BR>";
    }
    if($targetbeams > 0)
    {
        if($targetbeams > $attackerarmor)
        {
            $attackerarmor=0;
            $l_cmb_yourarmorbreachedbybeams = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorbreachedbybeams);
            echo "--> $l_cmb_yourarmorbreachedbybeams<BR>";
        }
        else
        {
            $attackerarmor=$attackerarmor-$targetbeams;
            $l_cmb_yourarmorhitdamaged = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorhitdamaged);
            $l_cmb_yourarmorhitdamaged = str_replace("[cmb_targetbeams]", $targetbeams, $l_cmb_yourarmorhitdamaged);
            echo "<-- $l_cmb_yourarmorhitdamaged<BR>";
        }
    }
    else
    {
        $l_cmb_hehasnobeamslefttoattackyou = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnobeamslefttoattackyou);
        echo "$l_cmb_hehasnobeamslefttoattackyou<BR>";
    }
	// ****************** TORPEDO EXCHANGE ***********************
    echo "<BR><FONT SIZE='+2' COLOR='RED'>$l_cmb_torpedoexchange</font><BR>";
    if($targetfighters > 0 && $attackertorpdamage > 0)
    {
        if($attackertorpdamage > round($targetfighters / 2))
        {
            $temp=round($targetfighters/2);
            $lost=$targetfighters-$temp;
            $targetfighters=$temp;
            $attackertorpdamage=$attackertorpdamage-$lost;
            $l_cmb_yourtorpsdestroy = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourtorpsdestroy);
            $l_cmb_yourtorpsdestroy = str_replace("[cmb_lost]", $lost, $l_cmb_yourtorpsdestroy);
            echo "--> $l_cmb_yourtorpsdestroy<BR>";
        }
        else
        {
            $targetfighters=$targetfighters-$attackertorpdamage;
            $l_cmb_yourtorpsdestroy2 = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourtorpsdestroy2);
            $l_cmb_yourtorpsdestroy2 = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_yourtorpsdestroy2);
            echo "<-- $l_cmb_yourtorpsdestroy2<BR>";
            $attackertorpdamage=0;
        }
    }
    elseif ($targetfighters > 0 && $attackertorpdamage < 1)
    {
        $l_cmb_youhavenotorpsleft = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhavenotorpsleft);
        echo "$l_cmb_youhavenotorpsleft<BR>";
    }
    else
    {
        $l_cmb_hehasnofighterleft = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnofighterleft);
        echo "$_cmb_hehasnofighterleft<BR>";
    }
    if($attackerfighters > 0 && $targettorpdmg > 0)
    {
        if($targettorpdmg > round($attackerfighters / 2))
        {
            $temp=round($attackerfighters/2);
            $lost=$attackerfighters-$temp;
            $attackerfighters=$temp;
            $targettorpdmg=$targettorpdmg-$lost;
            $l_cmb_torpsdestroyyou = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_torpsdestroyyou);
            $l_cmb_torpsdestroyyou = str_replace("[cmb_lost]", $lost, $l_cmb_torpsdestroyyou);
            echo "--> $l_cmb_torpsdestroyyou<BR>";
        }
        else
        {
            $attackerfighters=$attackerfighters-$targettorpdmg;
            $l_cmb_someonedestroyedfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_someonedestroyedfighters);
            $l_cmb_someonedestroyedfighters = str_replace("[cmb_targettorpdmg]", $targettorpdmg, $l_cmb_someonedestroyedfighters);
            echo "<-- $l_cmb_someonedestroyedfighters<BR>";
            $targettorpdmg=0;
        }
    }
    elseif ($attackerfighters > 0 && $targettorpdmg < 1)
    {
        $l_cmb_hehasnotorpsleftforyou = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnotorpsleftforyou);
        echo "$l_cmb_hehasnotorpsleftforyou<BR>";
    }
    else
    {
        $l_cmb_youhavenofightersanymore = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhavenofightersanymore);
        echo "$l_cmb_youhavenofightersanymore<BR>";
    }
    if($attackertorpdamage > 0)
    {
        if($attackertorpdamage > $targetarmor)
        {
            $targetarmor=0;
            $l_cmb_youbreachedwithtorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youbreachedwithtorps);
            echo "--> $l_cmb_youbreachedwithtorps<BR>";
        }
        else
        {
            $targetarmor=$targetarmor-$attackertorpdamage;
            $l_cmb_hisarmorishitbytorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hisarmorishitbytorps);
            $l_cmb_hisarmorishitbytorps = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_hisarmorishitbytorps);
            echo "<-- $l_cmb_hisarmorishitbytorps<BR>";
        }
    }
    else
    {
        $l_cmb_notorpslefttoattackarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_notorpslefttoattackarmor);
        echo "$l_cmb_notorpslefttoattackarmor<BR>";
    }
    if($targettorpdmg > 0)
    {
        if($targettorpdmg > $attackerarmor)
        {
            $attackerarmor=0;
            $l_cmb_yourarmorbreachedbytorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorbreachedbytorps);
            echo "<-- $l_cmb_yourarmorbreachedbytorps<BR>";
        }
        else
        {
            $attackerarmor=$attackerarmor-$targettorpdmg;
            $l_cmb_yourarmorhitdmgtorps = str_replace("[cmb_targettorpdmg]", $targettorpdmg, $l_cmb_yourarmorhitdmgtorps);
            $l_cmb_yourarmorhitdmgtorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorhitdmgtorps);
            echo "<-- $l_cmb_yourarmorhitdmgtorps<BR>";
        }
    }
    else
    {
        $l_cmb_hehasnotorpsforyourarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnotorpsforyourarmor);
        echo "$l_cmb_hehasnotorpsforyourarmor<BR>";
    }
	// *******************8 FIGHTERS EXCHANGE ******************	
    echo "<BR><FONT SIZE='+2' COLOR='RED'>$l_cmb_fightersattackexchange</FONT><BR>";
    if($attackerfighters > 0 && $targetfighters > 0)
    {
        if($attackerfighters > $targetfighters)
        {
            $l_cmb_enemylostallfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_enemylostallfighters);
            echo "--> $l_cmb_enemylostallfighters<BR>";
            $temptargfighters=0;
        }
        else
        {
            $l_cmb_helostsomefighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_helostsomefighters);
            $l_cmb_helostsomefighters = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_helostsomefighters);
            echo "$l_cmb_helostsomefighters<BR>";
            $temptargfighters=$targetfighters-$attackerfighters;
        }
        if($targetfighters > $attackerfighters)
        {
            echo "<-- $l_cmb_youlostallfighters<BR>";
            $tempplayfighters=0;
        }
        else
        {
            $l_cmb_youalsolostsomefighters = str_replace("[cmb_targetfighters]", $targetfighters, $l_cmb_youalsolostsomefighters);
            echo "<-- $l_cmb_youalsolostsomefighters<BR>";
            $tempplayfighters=$attackerfighters-$targetfighters;
        }
        $attackerfighters=$tempplayfighters;
        $targetfighters=$temptargfighters;
    }
    elseif ($attackerfighters > 0 && $targetfighters < 1)
    {
        $l_cmb_hehasnofightersleftattack = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnofightersleftattack);
        echo "$l_cmb_hehasnofightersleftattack<BR>";
    }
    else
    {
        $l_cmb_younofightersattackleft = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_younofightersattackleft);
        echo "$l_cmb_younofightersattackleft<BR>";
    }
    if($attackerfighters > 0)
    {
        if($attackerfighters > $targetarmor)
        {
            $targetarmor=0;
            $l_cmb_youbreachedarmorwithfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youbreachedarmorwithfighters);
            echo "--> $l_cmb_youbreachedarmorwithfighters<BR>";
        }
        else
        {
            $targetarmor=$targetarmor-$attackerfighters;
            $l_cmb_youhitarmordmgfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhitarmordmgfighters);
            $l_cmb_youhitarmordmgfighters = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_youhitarmordmgfighters);
            echo "<-- $l_cmb_youhitarmordmgfighters<BR>";
        }
    }
    else
    {
        $l_cmb_youhavenofighterstoarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhavenofighterstoarmor);
        echo "$l_cmb_youhavenofighterstoarmor<BR>";
    }
    if($targetfighters > 0)
    {
        if($targetfighters > $attackerarmor)
        {
            $attackerarmor=0;
            $l_cmb_hasbreachedarmorfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hasbreachedarmorfighters);
            echo "<-- $l_cmb_hasbreachedarmorfighters<BR>";
        }
        else
        {
            $attackerarmor=$attackerarmor-$targetfighters;
            $l_cmb_yourarmorishitfordmgby = str_replace("[cmb_targetfighters]", $targetfighters, $l_cmb_yourarmorishitfordmgby);
            $l_cmb_yourarmorishitfordmgby = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorishitfordmgby);
            echo "--> $l_cmb_yourarmorishitfordmgby<BR>";
        }
    }
    else
    {
        $l_cmb_nofightersleftheforyourarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_nofightersleftheforyourarmor);
        echo "$l_cmb_nofightersleftheforyourarmor<BR>";
    }
    if($targetarmor < 1)
    {
        $l_cmb_hehasbeendestroyed = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasbeendestroyed);
        echo "<BR>$l_cmb_hehasbeendestroyed<BR>";
		// news
		$headline="Ship blown up on planet!";
		$newstext="The ship ".$targetshipinfo[ship_name]." was destroyed today by ".$playerinfo[character_name]." during a planet attack. ";
        if($targetshipinfo[dev_escapepod] == "Y")
        {
            $rating=round($targetinfo[rating]/2);
            echo "$l_cmb_escapepodlaunched<BR><BR>";
            echo "<BR><BR>player_id=$targetinfo[player_id]<BR><BR>";
            $test = $db->Execute("UPDATE $dbtables[players] SET on_planet='N',rating='$rating',sector=0 WHERE player_id=$targetinfo[player_id]");
			// Immediately release any ships being towed 
    		if ($targetshipinfo[tow] > 0) {
				$db->Execute("UPDATE $dbtables[ships] SET player_id=0,on_planet='N',sector=$targetshipinfo[sector] WHERE ship_id=$targetshipinfo[tow]");
  			}
			$db->Execute("UPDATE $dbtables[ships] SET ship_destroyed ='Y', sector=0, tow=0 WHERE player_id=$targetinfo[player_id] AND ship_id=$targetinfo[currentship]");
            playerlog($targetinfo[player_id],LOG_ATTACK_LOSE, "$playerinfo[character_name]|Y");
            collect_bounty($playerinfo[player_id],$targetinfo[player_id]);
			$newstext = $newstext.$targetinfo[character_name]." survived and podded off to Sector 0.";
        }
        else
        {
            playerlog($targetinfo[player_id], LOG_ATTACK_LOSE, "$playerinfo[character_name]|N");
            db_kill_player($targetinfo[player_id],$targetinfo[currentship],$playerinfo[player_id]);
            collect_bounty($playerinfo[player_id],$targetinfo[player_id]);
			$newstext .= $targetinfo[character_name]." did not survive the attack.";
        }
		$newstext = addslashes($newstext);
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");
		
        if($attackerarmor > 0)
        {
            $rating_change=round($targetinfo[rating]*$rating_combat_factor);
            $free_ore = round($targetshipinfo[ship_ore]/2);
            $free_organics = round($targetshipinfo[ship_organics]/2);
            $free_goods = round($targetshipinfo[ship_goods]/2);
            $free_holds = NUM_HOLDS($shipinfo[hull]) - $shipinfo[ship_ore] - $shipinfo[ship_organics] - $shipinfo[ship_goods] - $shipinfo[ship_colonists];
            if($free_holds > $free_goods)
            {
                $salv_goods=$free_goods;
                $free_holds=$free_holds-$free_goods;
            }
            elseif($free_holds > 0)
            {
                $salv_goods=$free_holds;
                $free_holds=0;
            }
            else
            {
                $salv_goods=0;
            }
            if($free_holds > $free_ore)
            {
                $salv_ore=$free_ore;
                $free_holds=$free_holds-$free_ore;
            }
            elseif($free_holds > 0)
            {
                $salv_ore=$free_holds;
                $free_holds=0;
            }
            else
            {
                $salv_ore=0;
            }
            if($free_holds > $free_organics)
            {
                $salv_organics=$free_organics;
                $free_holds=$free_holds-$free_organics;
            }
            elseif($free_holds > 0)
            {
                $salv_organics=$free_holds;
                $free_holds=0;
            }
            else
            {
                $salv_organics=0;
            }
            $ship_value=$upgrade_cost*(round(mypw($upgrade_factor, $targetshipinfo[hull]))+round(mypw($upgrade_factor, $targetshipinfo[engines]))+round(mypw($upgrade_factor, $targetshipinfo[power]))+round(mypw($upgrade_factor, $targetshipinfo[computer]))+round(mypw($upgrade_factor, $targetshipinfo[sensors]))+round(mypw($upgrade_factor, $targetshipinfo[beams]))+round(mypw($upgrade_factor, $targetshipinfo[torp_launchers]))+round(mypw($upgrade_factor, $targetshipinfo[shields]))+round(mypw($upgrade_factor, $targetshipinfo[armor]))+round(mypw($upgrade_factor, $targetshipinfo[cloak])));
            $ship_salvage_rate=rand(10,20);
            $ship_salvage=$ship_value*$ship_salvage_rate/100;
			// Triple salvage if this is an outlaw
		  	$result3 = $db->Execute ("SELECT amount FROM $dbtables[bounty] WHERE placed_by=0 AND bounty_on=$targetinfo[player_id]");
		  	if (!$result3->EOF) {
		  		$ship_salvage *=3;
				echo "You destroyed a Federation fugitive! Triple hull salvage!<br>";
		  	}
            $l_cmb_yousalvaged = str_replace("[cmb_salv_ore]", NUMBER($salv_ore), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salv_organics]", NUMBER($salv_organics), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salv_goods]", NUMBER($salv_goods), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salvage_rate]", $ship_salvage_rate, $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salvage]", NUMBER($ship_salvage), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_number_rating_change]", NUMBER(abs($rating_change)), $l_cmb_yousalvaged);
            echo "$l_cmb_yousalvaged";
            $update3 = $db->Execute ("UPDATE $dbtables[players] SET credits=credits+$ship_salvage WHERE player_id=$playerinfo[player_id]");
			$update3 = $db->Execute ("UPDATE $dbtables[ships] SET ship_ore=ship_ore+$salv_ore, ship_organics=ship_organics+$salv_organics, ship_goods=ship_goods+$salv_goods WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
        }
    }
    else
    {
        $l_cmb_youdidntdestroyhim = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youdidntdestroyhim);
        echo "$l_cmb_youdidntdestroyhim<BR>";
        $target_rating_change=round($targetinfo[rating]*.1);
        $target_armor_lost=$targetshipinfo[armour_pts]-$targetarmor;
        $target_fighters_lost=$targetshipinfo[ship_fighters]-$targetfighters;
        $target_energy=$targetshipinfo[ship_energy];
        playerlog($targetinfo[player_id], LOG_ATTACKED_WIN, "$playerinfo[character_name]|$target_armor_lost|$target_fighters_lost");
        $update4 = $db->Execute ("UPDATE $dbtables[ships] SET ship_energy=$target_energy,ship_fighters=ship_fighters-$target_fighters_lost, armour_pts=armour_pts-$target_armor_lost, torps=torps-$targettorpnum WHERE player_id=$targetinfo[player_id] AND ship_id=$targetinfo[currentship]");
	}
    $db->Execute("UNLOCK TABLES");
}
示例#12
0
     echo "</ul>";
     $query->MoveNext();
 }
 $resultSDa = $db->Execute("SELECT SUM(quantity) as mines from {$db->prefix}sector_defence WHERE sector_id=? and defence_type='M';", array($sector));
 db_op_result($db, $resultSDa, __LINE__, __FILE__, $db_logging);
 $resultSDb = $db->Execute("SELECT SUM(quantity) as fighters from {$db->prefix}sector_defence WHERE sector_id=? and defence_type='F';", array($sector));
 db_op_result($db, $resultSDb, __LINE__, __FILE__, $db_logging);
 $defM = $resultSDa->fields;
 $defF = $resultSDb->fields;
 echo "</td></tr>";
 echo "<tr><td class=\"long-rang-scan-titles-cell\"><span class=\"long-rang-scan-titles\">Mines</span></td>";
 $has_mines = NUMBER($defM['mines']);
 echo "<td>" . $has_mines;
 echo "</td></tr>";
 echo "<tr><td class=\"long-rang-scan-titles-cell\"><span class=\"long-rang-scan-titles\">Fighters</span></td>";
 $has_fighters = NUMBER($defF['fighters']);
 echo "<td>" . $has_fighters;
 echo "</td></tr>";
 if ($playerinfo['dev_lssd'] == 'Y') {
     echo "<tr><td class=\"long-rang-scan-titles-cell\"><span class=\"long-rang-scan-titles\">Last ship seen in this sector</span></td>";
     echo "<td>";
     $resx = $db->Execute("SELECT * FROM {$db->prefix}movement_log WHERE ship_id <> ? AND sector_id = ? ORDER BY time DESC LIMIT 1;", array($playerinfo['ship_id'], $sector));
     db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
     if (!$resx) {
         echo "None";
     } else {
         $myrow = $resx->fields;
         echo "<span class=\"table_word_red\">" . get_player($db, $myrow['ship_id']) . "</span>";
     }
     echo "</td></tr>";
 } else {
示例#13
0
<table BORDER=1 CELLPADDING=0 CELLSPACING=0 BGCOLOR="#005000" align="center"> 
<tr><td>
<table BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR="#005000" align="center" class=dis> 
<tr><td nowrap align='left'>&nbsp;<img height=12 width=12 alt="<? echo $l_ore ?>" src="images/ore.gif">&nbsp;<? echo $l_ore ?>&nbsp;</td></tr> 
 <tr><td nowrap align='right'><span class=mnu>&nbsp;<? echo NUMBER($shipinfo[ship_ore]); ?>&nbsp;</span></td></tr>
<tr><td nowrap align='left'>&nbsp;<img height=12 width=12 alt="<? echo $l_organics ?>" src="images/organics.gif">&nbsp;<? echo $l_organics ?>&nbsp;</td></tr> 
 <tr><td nowrap align='right'><span class=mnu>&nbsp;<? echo NUMBER($shipinfo[ship_organics]); ?>&nbsp;</span></td></tr>
<tr><td nowrap align='left'>&nbsp;<img height=12 width=12 alt="<? echo $l_goods ?>" src="images/goods.gif">&nbsp;<? echo $l_goods ?>&nbsp;</td></tr> 
 <tr><td nowrap align='right'><span class=mnu>&nbsp;<? echo NUMBER($shipinfo[ship_goods]); ?>&nbsp;</span></td></tr>
<tr><td nowrap align='left'>&nbsp;<img height=12 width=12 alt="<? echo $l_energy ?>" src="images/energy.gif">&nbsp;<? echo $l_energy ?>&nbsp;</td></tr> 
 <tr><td nowrap align='right'><span class=mnu>&nbsp;<? echo NUMBER($shipinfo[ship_energy]); ?>&nbsp;</span></td></tr>
<tr><td nowrap align='left'>&nbsp;<img height=12 width=12 alt="<? echo $l_colonists ?>" src="images/colonists.gif">&nbsp;<? echo $l_colonists ?>&nbsp;</td></tr> 
 <tr><td nowrap align='right'><span class=mnu>&nbsp;<? echo NUMBER($shipinfo[ship_colonists]); ?>&nbsp;</span></td></tr>
<tr><td nowrap align='left'>&nbsp;<img height=12 width=12 alt="<? echo $l_credits ?>" src="images/credits.gif">&nbsp;<? echo $l_credits ?>&nbsp;</td></tr> 
 <tr><td nowrap align='right'><span class=mnu>&nbsp;<? echo NUMBER($playerinfo[credits]); ?>&nbsp;</span></td></tr>
</table>
</td></tr>
</table>

<br>

<table border="0" cellpadding="0" cellspacing="0" align="center"><tr valign="top">
<td><img src="images/lcorner.gif" width="8" height="11" border="0" alt=""></td>
<td nowrap bgcolor="<? echo $color_line2; ?>"><font face="verdana" size="1" color="#ffffff"><b>
<? echo $l_traderoutes ?>
</b></font></td>
<td><img src="images/rcorner.gif" width="8" height="11" border="0" alt=""></td>
</tr></table>

<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 BGCOLOR="#005000" align="center">
示例#14
0
			$curship = $res->fields;
			// Federation Sector Check - only newbies can use
			if ($playerinfo[sector]==0 && $playerinfo[score] > $fed_dock_max) {
				echo "This Spacedock is reserved for new traders. Please try another special port spacedock.<br>";
			} else {
				$canDock = true;
				// Check to see if we are at a special port
				if ($sectorinfo[port_type] == "special") {
					// Check that they have some money in their IGB account
					$res2 = $db->Execute("SELECT balance FROM $dbtables[ibank_accounts] WHERE player_id=$playerinfo[player_id] ");
					$row = $res2->fields;
					if ($row[balance] <1000) {
						echo "The Spacedock owners require you to have at least 1000 credits in your IGB account before they will allow you to dock.<br><br>";
						$canDock=false;
					} else if ($row[balance] < 10000) {
						echo "The Spacedock owners grudgingly let you moor the ship but with only ".NUMBER($row[balance])." credits in your IGB account you better be careful not to loose you ship for non-payment of mooring fees!<br>";
					}
				}
				if ($canDock) {
					echo "You detatch the tractor beam connection from your ship to the $shipinfo[ship_name] and it settles safely into the space dock.<br><br>";
					// Belt and braces
					$db->Execute("UPDATE $dbtables[ships] SET sector=$playerinfo[sector] WHERE ship_id=$shipinfo[tow]");
					$db->Execute("UPDATE $dbtables[ships] SET tow = 0 WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
				}
			}
		} else {
			echo "You cannot do that!<br><br>";
		}
	} else {
		echo "You are not towing any ship!<br><br>";
	}
示例#15
0
function planet_production_change()
{
  global $db;
  global $res;
  global $playerinfo;
  global $dbtables;
  global $username;
  global $sort;
  global $query;
  global $color_header, $color, $color_line1, $color_line2;
  global $l_pr_teamlink, $l_pr_clicktosort;
  global $l_sector, $l_name, $l_unnamed, $l_ore, $l_organics, $l_goods, $l_energy, $l_colonists, $l_credits, $l_fighters, $l_torps, $l_base, $l_selling, $l_pr_totals, $l_yes, $l_no;


  $query = "SELECT * FROM $dbtables[planets] WHERE owner=$playerinfo[player_id] AND base='Y'";

  echo "Planetary report <B><A HREF=planet-report.php?PRepType=0>menu</A></B><BR>" .
       "<BR>" .
       "<B><A HREF=planet-report.php?PRepType=1>Planet Status</A></B><BR>";
  echo "<br><B><A HREF=planet-report.php?PRepType=3>Set Planet Commodity Sale Prices</A></B><BR>";
  if ($playerinfo[team]>0)
  {
    echo "<BR>" .
         "<B><A HREF=alliance-planets.php>$l_pr_teamlink</A></B><BR> " . 
         "<BR>";
  }

  if(!empty($sort))
  {
    $query .= " ORDER BY";
    if($sort == "name")
    {
      $query .= " $sort ASC";
    }
    elseif($sort == "organics" || $sort == "ore" || $sort == "goods" || $sort == "energy" || $sort == "fighters")
    {
      $query .= " prod_$sort DESC, sector_id ASC";
    }
    elseif($sort == "colonists" || $sort == "credits")
    {
      $query .= " $sort DESC, sector_id ASC";
    }
    elseif($sort == "torp")
    {
      $query .= " prod_torp DESC, sector_id ASC";
    }
    elseif($sort == "piq")
    {
      $query .= " tech_level DESC, sector_id ASC";
    }
    else
    {
      $query .= " sector_id ASC";
    }

  }
  else
  {
     $query .= " ORDER BY sector_id ASC";
  }

  $res = $db->Execute($query);

  $i = 0;
  if($res)
  {
    while(!$res->EOF)
    {
      $planet[$i] = $res->fields;
      $i++;
      $res->MoveNext();
    }
  }

  $num_planets = $i;
  if($num_planets < 1)
  {
    echo "<BR>$l_pr_noplanet";
  }
  else
  {
    echo "<FORM ACTION=planet-report-CE.php METHOD=POST>";

// ------ next block of echo's creates the header of the table
    echo "$l_pr_clicktosort<BR><BR>";
    echo "<TABLE WIDTH=\"100%\" BORDER=1 CELLSPACING=0 CELLPADDING=0>";
    echo "<TR BGCOLOR=\"$color_header\" VALIGN=BOTTOM>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=sector_id>Sector</A><BR>";
    echo "<A HREF=planet-report.php?PRepType=2&sort=name>Planet</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=ore>$l_ore</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=organics>Orgs</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=goods>$l_goods</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=energy>NRG</A></FONT></TD>";
    echo "</TR>";
    $total_colonists = 0;
    $total_credits = 0;
    $total_corp = 0;
    
    $temp_var = 0;

    $color = $color_line1;

    for($i=0; $i<$num_planets; $i++)
    {
      if(empty($planet[$i][name]))
      {
        $planet[$i][name] = $l_unnamed;
      }
      echo "<TR BGCOLOR=\"$color\">";
      echo "<TD ALIGN=CENTER><A HREF=rsmove.php?engage=1&destination=". $planet[$i][sector_id] . ">". $planet[$i][sector_id] ."</A><BR>". $planet[$i][name] . "</TD>";
      echo "<TD ALIGN=CENTER>" . "<input size=2 type=text name=\"prod_ore["      . $planet[$i]["planet_id"] . "]\" value=\"" . $planet[$i]["prod_ore"]      . "\">" . "</TD>";
      echo "<TD ALIGN=CENTER>" . "<input size=2 type=text name=\"prod_organics[" . $planet[$i]["planet_id"] . "]\" value=\"" . $planet[$i]["prod_organics"] . "\">" . "</TD>";
      echo "<TD ALIGN=CENTER>" . "<input size=2 type=text name=\"prod_goods["    . $planet[$i]["planet_id"] . "]\" value=\"" . $planet[$i]["prod_goods"]    . "\">" . "</TD>";
      echo "<TD ALIGN=CENTER>" . "<input size=2 type=text name=\"prod_energy["   . $planet[$i]["planet_id"] . "]\" value=\"" . $planet[$i]["prod_energy"]   . "\">" . "</TD>";
      echo "</TR>";

      if($color == $color_line1)
      {
        $color = $color_line2;
      }
      else
      {
        $color = $color_line1;
      }
    }
    echo "</TABLE><br>";
    echo "<TABLE WIDTH=\"100%\" BORDER=1 CELLSPACING=0 CELLPADDING=0>";
    echo "<TR BGCOLOR=\"$color_header\" VALIGN=BOTTOM>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=sector_id>Sector</A></FONT><br>";
    echo "<A HREF=planet-report.php?PRepType=2&sort=name>$l_name</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=colonists>Pops</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=credits>Creds</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=fighters>$l_fighters</A></FONT></TD>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=torp>Torps</A></FONT></TD>";
    echo "</TR>";
    $color = $color_line1;

    for($i=0; $i<$num_planets; $i++)
    {
      $total_colonists += $planet[$i][colonists];
      $total_credits += $planet[$i][credits];
      if(empty($planet[$i][name]))
      {
        $planet[$i][name] = $l_unnamed;
      }
      echo "<TR BGCOLOR=\"$color\">";
      echo "<TD ALIGN=CENTER><A HREF=rsmove.php?engage=1&destination=". $planet[$i][sector_id] . ">". $planet[$i][sector_id] ."</A><br>";
      echo $planet[$i][name] . "</TD>";
      echo "<TD ALIGN=CENTER>"  . NUMBER($planet[$i][colonists])              . "</TD>";
      echo "<TD ALIGN=CENTER>"  . NUMBER($planet[$i][credits])        . "</TD>";
      echo "<TD ALIGN=CENTER>" . "<input size=2 type=text name=\"prod_fighters[" . $planet[$i]["planet_id"] . "]\" value=\"" . $planet[$i]["prod_fighters"] . "\">" . "</TD>";
      echo "<TD ALIGN=CENTER>" . "<input size=2 type=text name=\"prod_torp["     . $planet[$i]["planet_id"] . "]\" value=\"" . $planet[$i]["prod_torp"]     . "\">" . "</TD>";
      echo "</TR>";
      if($color == $color_line1)
      {
        $color = $color_line2;
      }
      else
      {
        $color = $color_line1;
      }
    }
    echo "<TR BGCOLOR=$color>";
    echo "<TD ALIGN=CENTER>$l_pr_totals</TD>";
    echo "<TD ALIGN=CENTER>" . NUMBER($total_colonists) . "</TD>";
    echo "<TD ALIGN=CENTER>" . NUMBER($total_credits)   . "</TD>";
    echo "<TD>" . "" . "</TD>";
    echo "<TD>" . "" . "</TD>";
    echo "</TR>";
    echo "</TABLE><br>";
	
    echo "<TABLE WIDTH=\"100%\" BORDER=1 CELLSPACING=0 CELLPADDING=2>";
    echo "<TR BGCOLOR=\"$color_header\" VALIGN=BOTTOM>";
    echo "<TD ALIGN=CENTER><A HREF=planet-report.php?PRepType=2&sort=sector_id>Sector</A></FONT><br>";
    echo "<A HREF=planet-report.php?PRepType=2&sort=name>$l_name</A></FONT></TD>";
    if($playerinfo[team] > 0)
      echo "<TD ALIGN=CENTER>Alliance<br>Planet?</TD>";
    echo "<TD ALIGN=CENTER>$l_selling?</TD>";
	echo "<TD ALIGN=CENTER>Planet IQ</TD>";
    echo "</TR>";
    $color = $color_line1;

    for($i=0; $i<$num_planets; $i++)
    {
      if(empty($planet[$i][name]))
      {
        $planet[$i][name] = $l_unnamed;
      }
      echo "<TR BGCOLOR=\"$color\">";
      echo "<TD ALIGN=CENTER><A HREF=rsmove.php?engage=1&destination=". $planet[$i][sector_id] . ">". $planet[$i][sector_id] ."</A><br>";
      echo $planet[$i][name] . "</TD>";

      if($playerinfo[team] > 0)
        echo "<TD ALIGN=CENTER>" . corp_planet_checkboxes($planet, $i) . "</TD>";
      echo "<TD ALIGN=CENTER>" . selling_checkboxes($planet, $i)     . "</TD>";
	  echo "<TD ALIGN=CENTER>" . NUMBER($planet[$i][tech_level])   . "</TD>";
      echo "</TR>";
      if($color == $color_line1)
      {
        $color = $color_line2;
      }
      else
      {
        $color = $color_line1;
      }
    }
    echo "</TABLE>";
	
	
    echo "<BR>";
    echo "<INPUT TYPE=HIDDEN NAME=player_id VALUE=$playerinfo[player_id]>";
    echo "<INPUT TYPE=HIDDEN NAME=team_id   VALUE=$playerinfo[team]>";
    echo "<INPUT TYPE=SUBMIT VALUE=Submit>  <INPUT TYPE=RESET VALUE=Reset>";
    echo "</FORM>";
  }
}
示例#16
0
echo "<td><a href='warpedit.php'>Warp Editors</A></td><td><span class=\"table_word_white\">" . NUMBER($playerinfo['dev_warpedit']) . "</span></td><td><span class=\"table_word_orange\">Manual</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><a href='genesis.php'>Genesis Torpedoes</A></td><td><span class=\"table_word_white\">" . NUMBER($playerinfo['dev_genesis']) . "</span></td><td><span class=\"table_word_orange\">Manual</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><span class=\"table_word_gold\">Mine Deflectors</span></td><td><span class=\"table_word_white\">" . NUMBER($playerinfo['dev_minedeflector']) . "</span></td><td><span class=\"table_word_yellow\">Automatic</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><a href='mines.php?op=1'>Space Mines</A></td><td><span class=\"table_word_white\">" . NUMBER($playerinfo['torps']) . "</span></td><td><span class=\"table_word_orange\">Manual</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><a href='mines.php?op=2'>Space Fighters</A></td><td><span class=\"table_word_white\">" . NUMBER($playerinfo['ship_fighters']) . "</span></td><td><span class=\"table_word_orange\">Manual</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><a href='emerwarp.php'>Emergency Warp Device</A></td><td><span class=\"table_word_white\">" . NUMBER($playerinfo['dev_emerwarp']) . "</span></td><td><span class=\"table_word_orange\">Manual</span> / <span class=\"table_word_yellow\">Automatic</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><span class=\"table_word_gold\">Escape Pod</span></td><td><span class=\"table_word_white\">" . ($playerinfo['dev_escapepod'] == 'Y' ? $l_yes : $l_no) . "</span></td><td><span class=\"table_word_yellow\">Automatic</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><span class=\"table_word_gold\">Fuel Scoop</span></td><td><span class=\"table_word_white\">" . ($playerinfo['dev_fuelscoop'] == 'Y' ? $l_yes : $l_no) . "</span></td><td><span class=\"table_word_yellow\">Automatic</span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><span class=\"table_word_gold\">Warp Analyser</span></td><td><span class=\"table_word_white\">" . ($playerinfo['dev_lssd'] == 'Y' ? $l_yes : $l_no) . "</span></td><td><span class=\"table_word_yellow\">Automatic</span></td>";
echo "</tr>";
echo "</tbody></table>";
?>
</div>
<?php 
TEXT_GOTOMAIN();
示例#17
0
 }
 $roll = mt_rand(1, 100);
 if ($roll > $success) {
     // If scan fails - inform both player and target.
     echo $l_planet_noscan;
     playerlog($db, $targetinfo['ship_id'], LOG_SHIP_SCAN_FAIL, $playerinfo['character_name']);
 } else {
     // If scan succeeds, show results and inform target. Scramble results by scan error factor.
     // Get total bounty on this player, if any
     $btyamount = 0;
     $hasbounty = $db->Execute("SELECT SUM(amount) AS btytotal FROM {$db->prefix}bounty WHERE bounty_on = ?", array($targetinfo['ship_id']));
     db_op_result($db, $hasbounty, __LINE__, __FILE__, $db_logging);
     if ($hasbounty) {
         $resx = $hasbounty->fields;
         if ($resx['btytotal'] > 0) {
             $btyamount = NUMBER($resx['btytotal']);
             $l_scan_bounty = str_replace("[amount]", $btyamount, $l_scan_bounty);
             echo $l_scan_bounty . "<br>";
             $btyamount = 0;
             // Check for Federation bounty
             $hasfedbounty = $db->Execute("SELECT SUM(amount) AS btytotal FROM {$db->prefix}bounty WHERE bounty_on = ? AND placed_by = 0", array($targetinfo['ship_id']));
             db_op_result($db, $hasfedbounty, __LINE__, __FILE__, $db_logging);
             if ($hasfedbounty) {
                 $resy = $hasfedbounty->fields;
                 if ($resy['btytotal'] > 0) {
                     $btyamount = $resy['btytotal'];
                     echo $l_scan_fedbounty . "<br>";
                 }
             }
         }
     }
示例#18
0
    while (!$pirate_day->EOF) {
        if ($i == $targetnum) {
            echo "loooool";
            $targetinfo = $pirate_day->fields;
            break;
        }
        $i++;
        $pirate_day->MoveNext();
    }
    if ($affliction == 1) {
        /*pirates launch raid on your bank!*/
        echo "Pirates raided planet " . $targetinfo['planet_id'] . "!!<br/>.";
        $pirates_steal = rand(1, 20) / 100;
        $resx = $db->Execute("UPDATE {$db->prefix}planets SET credits = ROUND(credits-credits*{$pirates_steal}) WHERE planet_id = {$targetinfo['planet_id']}");
        db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
        $stolen_credits = NUMBER($targetinfo['credits'] * $pirates_steal);
        ##New Log ##
        $manage_log->player_log($targetinfo['owner'], 29, $targetinfo['name'], $targetinfo['sector_id'], $stolen_credits, 'notrack', "<font color='#E9AB17'>Medium Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
    }
}
echo "<br/>";
##################################################################################################################
echo "<strong>ZOMBIE APOCALYPSE</strong><br><br>";
$doomsday = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE colonists > {$doomsday_value}");
db_op_result($db, $doomsday, __LINE__, __FILE__, $db_logging);
$chance = 9;
$reccount = $doomsday->RecordCount();
if ($reccount > 200) {
    $chance = 7;
    // increase chance it will happen if we have lots of planets meeting the criteria
}
示例#19
0
    echo "    <TD align=center><INPUT TYPE=TEXT NAME=armour_number SIZE=6 MAXLENGTH=10 VALUE=$armour_free>";
  }
  else
  {
    echo "0</TD><TD align=center>Full";
  }
  echo "</TD>\n";
  echo "  </TR>\n";
  echo "  <TR BGCOLOR=\"$color_line2\">\n";
  echo "    <TD>$l_colonists</TD>\n";
  echo "    <TD align=center>" . NUMBER($colonist_price) . "</TD>\n";
  echo "    <TD align=center>" . NUMBER($shipinfo[ship_colonists]) . " / ". NUMBER($colonist_max). "</TD>\n";
  echo "    <TD align=center>";
  if($shipinfo[ship_colonists] != $colonist_max)
  {
	echo NUMBER($colonist_free) . "</TD>\n";
    echo "    <TD align=center><INPUT TYPE=TEXT NAME=colonist_number SIZE=6 MAXLENGTH=10 VALUE=0>";
  }
  else
  {
    echo "0</TD><TD align=center>Full";
  }
  echo "</TD>\n";
  echo "  </TR>\n";
  echo " </TABLE><BR>\n";
  echo " <TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=0>\n";
  echo "  <TR>\n";
  echo "    <TD><INPUT TYPE=SUBMIT VALUE=$l_buy ></TD>\n";
  echo "  </TR>\n";
  echo " </TABLE>\n";
  echo "</FORM>\n";
示例#20
0
 Start table
 */
 ?>
 <div class="general-table-container">
 <?php 
 echo "<table><tbody>";
 echo "<tr>";
 echo "<td><a href=defence_report.php?sort=sector>Sector</a></td>";
 echo "<td><a href=defence_report.php?sort=quantity>Quantity</a></td>";
 echo "<td><a href=defence_report.php?sort=type>Type</a></td>";
 echo "<td><a href=defence_report.php?sort=mode>Mode</a></td>";
 echo "</tr>";
 for ($i = 0; $i < $num_sectors; $i++) {
     echo "<tr>";
     echo "<td><a href=rsmove.php?engage=1&destination=" . $sector[$i]['sector_id'] . ">" . $sector[$i]['sector_id'] . "</a></td>";
     echo "<td>" . NUMBER($sector[$i]['quantity']) . "</td>";
     $defence_type = $sector[$i]['defence_type'] == 'F' ? $l_fighters : $l_mines;
     echo "<td> {$defence_type} </td>";
     $mode = $sector[$i]['defence_type'] == 'F' ? $sector[$i]['fm_setting'] : $l_n_a;
     if ($mode == 'attack') {
         $mode = $l_md_attack;
     } else {
         $mode = $l_md_toll;
     }
     echo "<td> " . $mode . " </td>";
     echo "</tr>";
 }
 echo "</tbody></table>";
 ?>
 </div>
 <?php 
					}
				}
				break;
              default:
                 $interface_string = $calledfrom . '?sector='.$sector.'&destination='.$destination.'&engage='.$engage;
                 $db->Execute("UPDATE $dbtables[players] SET cleared_defences = '$interface_string' WHERE player_id = $playerinfo[player_id]");
                 $fighterstoll = $total_sector_fighters * $fighter_price * 0.6;
                 bigtitle();
				 $ok=0;
				 echo "<!-- DEBUG2: OK=$ok-->";
                 echo "<FORM ACTION=$calledfrom METHOD=POST>";
                 $l_chf_therearetotalfightersindest = str_replace("[chf_total_sector_fighters]", NUMBER($total_sector_fighters), $l_chf_therearetotalfightersindest);
                 echo "$l_chf_therearetotalfightersindest<br>";
                 if($defences[0]['fm_setting'] == "toll")
                 {
                    $l_chf_creditsdemanded = str_replace("[chf_number_fighterstoll]", NUMBER($fighterstoll), $l_chf_creditsdemanded);
                    echo "$l_chf_creditsdemanded<BR>";
                 }
                 echo "$l_chf_youcanretreat";
                 if($defences[0]['fm_setting'] == "toll")
                 {
                    echo "$l_chf_inputpay";
                 }
                 echo "$l_chf_inputfight";
				 if ($shipinfo[dev_sectorwmd] == 'Y' && $shipinfo[dev_genesis] > 0) {
				 	echo "<INPUT TYPE=RADIO NAME=response CHECKED VALUE=sectorwmd><B>Use Sector-WMD</B> - Smart Bomb the Sector Fighters with a Genesis Torpedo.<BR></INPUT>";
				 }
                 echo "$l_chf_inputcloak<BR>";
                 echo "<INPUT TYPE=SUBMIT VALUE=$l_chf_go><BR><BR>";
                 echo "<input type=hidden name=sector value=$sector>";
                 echo "<input type=hidden name=engage value=1>";
示例#22
0
			  case "sectorwmd":
				 {
				 	if ($shipinfo[dev_sectorwmd] == 'Y' && $shipinfo[dev_genesis] > 0) {
						$db->Execute("UPDATE $dbtables[players] SET cleared_defences = ' ' WHERE player_id = $playerinfo[player_id]");
						$ok = 1;
						$db->Execute("UPDATE $dbtables[ships] SET dev_genesis=dev_genesis-1 WHERE player_id = $playerinfo[player_id] AND ship_id = $playerinfo[currentship]");
						// Destroy fighters
						$fighterslost = $total_sector_fighters;
						$l_sf_sendlog = str_replace("[player]", $playerinfo[character_name], $l_sf_sendlog);
						$l_sf_sendlog = str_replace("[lost]", NUMBER($fighterslost), $l_sf_sendlog);
						$l_sf_sendlog = str_replace("[sector]", $sector, $l_sf_sendlog);
						echo "<h1>Sector WMD Attack</h1>";
						echo "You obliterate ".NUMBER($fighterslost)." sector defense fighters!<br>";
						destroy_fighters($sector,$fighterslost);
						message_defence_owner($sector,$l_sf_sendlog);
						playerlog($playerinfo[player_id], LOG_DEFS_DESTROYED_F, NUMBER($fighterslost)."|$sector");
					} else {
						$ok = 0;
					}
				}
				break;
              default:
                 $interface_string = $calledfrom . '?sector='.$sector.'&destination='.$destination.'&engage='.$engage;
                 $db->Execute("UPDATE $dbtables[players] SET cleared_defences = '$interface_string' WHERE player_id = $playerinfo[player_id]");
                 //$fighterstoll = $total_sector_fighters * $fighter_price * 0.6;
                 //bigtitle();
				 $ok=0;
				 //echo "<!-- DEBUG2: OK=$ok-->";
                 echo "<FORM ACTION=$calledfrom METHOD=POST>";
                 //$l_chf_therearetotalfightersindest = str_replace("[chf_total_sector_fighters]", NUMBER($total_sector_fighters), $l_chf_therearetotalfightersindest);
                 echo "$l_chf_therearetotalfightersindest<br>";
示例#23
0
else
{
  echo "$l_pr_clicktosort<BR><BR>";
  echo "<TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2>";
  echo "<TR BGCOLOR=\"$color_header\">";
  echo "<TD><B><A HREF=defence-report.php?sort=sector>$l_sector</A></B></TD>";
  echo "<TD><B><A HREF=defence-report.php?sort=quantity>$l_qty</A></B></TD>";
  echo "<TD><B><A HREF=defence-report.php?sort=type>$l_sdf_type</A></B></TD>";
  echo "<TD><B><A HREF=defence-report.php?sort=mode>$l_sdf_mode</A></B></TD>";
  echo "</TR>";
  $color = $color_line1;
  for($i=0; $i<$num_sectors; $i++) {

    echo "<TR BGCOLOR=\"$color\">";
    echo "<TD><A HREF=rsmove.php?engage=1&destination=". $sector[$i][sector_id] . ">". $sector[$i][sector_id] ."</A></TD>";
    echo "<TD>" . NUMBER($sector[$i]['quantity']) . "</TD>";
    $defence_type = $sector[$i]['defence_type'] == 'F' ? $l_fighters : $l_mines;
    echo "<TD> $defence_type </TD>";
    $mode = $sector[$i]['defence_type'] == 'F' ? $sector[$i]['fm_setting'] : $l_n_a;
    //if($mode == 'attack')
    //  $mode = $l_md_attack;
    //else
    //  $mode = $l_md_toll;
    echo "<TD> $mode </TD>";
    echo "</TR>";

    if($color == $color_line1)
    {
      $color = $color_line2;
    }
    else
示例#24
0
					echo "<font size=2 color=silver><b><a href=spacedock.php?kk=".date("U").">Return to spacedock</a></b></font><p>";
			  }
			} else if ($cmd == "build" || $cmd=="confirm") {
				// Build a specific ship
				$res = $db->Execute("SELECT * FROM $dbtables[ship_types] WHERE buyable = 'N' AND tech_level<=$planetinfo[tech_level] AND type_id='$id'");
				if ($res->RowCount() >0) {
					$ship = $res->fields;
					// Check to see if this planet can build this ship
					// Display the ships that can be built
					echo "<h2>Ship Type: $ship[name]</h2>";
					echo "<table border=1><tr><td>&nbsp;</td><td>Required</td><td>On Planet</td></tr>";
					echo "<tr><td>Ore: </td><td>".NUMBER($ship[cost_ore])."</td><td>".NUMBER($planetinfo[ore])."</td></tr>";
					echo "<tr><td>Goods: </td><td>".NUMBER($ship[cost_goods])."</td><td>".NUMBER($planetinfo[goods])."</td></tr>";
					echo "<tr><td>Energy: </td><td>".NUMBER($ship[cost_energy])."</td><td>".NUMBER($planetinfo[energy])."</td></tr>";
					echo "<tr><td>Organics: </td><td>".NUMBER($ship[cost_organics])."</td><td>".NUMBER($planetinfo[organics])."</td></tr>";
					echo "<tr><td>Credits: </td><td>".NUMBER($ship[cost_credits])."</td><td>".NUMBER($planetinfo[credits])."</td></tr>";
					echo "</table>";
					// First check
					$build = true;
					if ($planetinfo[ore] < $ship[cost_ore]) {
						echo "You do not have enough ore on the planet!<br>";
						$build = false;
					}
					if ($planetinfo[goods] < $ship[cost_goods]) {
						echo "You do not have enough goods on the planet!<br>";
						$build = false;
					}
					if ($planetinfo[energy] < $ship[cost_energy]) {
						echo "You do not have enough energy on the planet!<br>";
						$build = false;
					}
示例#25
0
function IGB_consolidate3()
{
  global $playerinfo;
  global $db, $dbtables;
  global $dplanet_id, $minimum, $maximum, $IGB_tconsolidate, $ibank_paymentfee;
  global $l_igb_notenturns, $l_igb_back, $l_igb_logout, $l_igb_transfersuccessful;
  global $l_igb_currentpl, $l_igb_in, $l_igb_turncost, $l_igb_unnamed;

  $res = $db->Execute("SELECT name, credits, owner, sector_id FROM $dbtables[planets] WHERE planet_id=$dplanet_id");
  if(!$res || $res->EOF)
      IGB_error($l_igb_errunknownplanet, "IGB.php?kk=".date("U")."&command=transfer");
  $dest = $res->fields;

  if(empty($dest[name]))
    $dest[name]=$l_igb_unnamed;

  if($dest[owner] != $playerinfo[player_id])
    IGB_error($l_igb_errnotyourplanet, "IGB.php?kk=".date("U")."&command=transfer");

  $minimum = StripNonNum($minimum);
  $maximum = StripNonNum($maximum);

  $query = "SELECT SUM(credits) as total, COUNT(*) as count from $dbtables[planets] WHERE owner=$playerinfo[player_id] AND credits != 0";

  if($minimum != 0)
    $query .= " AND credits >= $minimum";

  if($maximum != 0)
    $query .= " AND credits <= $maximum";

  $query .= " AND planet_id != $dplanet_id";

  $res = $db->Execute($query);
  $amount = $res->fields;

  $fee = $ibank_paymentfee * $amount[total];

  $tcost = ceil($amount[count] / $IGB_tconsolidate);
  $transfer = $amount[total] - $fee;

  $cplanet = $transfer + $dest[credits];

  if($tcost > $playerinfo[turns])
    IGB_error($l_igb_notenturns, "IGB.php?kk=".date("U")."&command=transfer");

  echo "<tr><td colspan=2 align=center valign=top><font size=2 face=\"courier new\" color=#00FF00>$l_igb_transfersuccessful<br>---------------------------------</td></tr>" .
       "<tr valign=top>" .
       "<td><font size=2 face=\"courier new\" color=#00FF00>$l_igb_currentpl $dest[name] $l_igb_in $dest[sector_id] :<br><br>" .
       "$l_igb_turncost :</td>" .
       "<td align=right><font size=2 face=\"courier new\" color=#00FF00>" . NUMBER($cplanet) . " C<br><br>" .
       NUMBER($tcost) . "</td>" .
       "<tr valign=bottom>" .
       "<td><font size=2 face=\"courier new\" color=#00FF00><a href=IGB.php?kk=".date("U")."&command=login>$l_igb_back</a></td><td align=right><font size=2 face=\"courier new\" color=#00FF00>&nbsp;<br><a href=\"main.php?kk=".date("U")."\">$l_igb_logout</a></td>" .
       "</tr>";

  $query = "UPDATE $dbtables[planets] SET credits=0 WHERE owner=$playerinfo[player_id] AND credits != 0";

  if($minimum != 0)
    $query .= " AND credits >= $minimum";

  if($maximum != 0)
    $query .= " AND credits <= $maximum";

  $query .= " AND planet_id != $dplanet_id";

  $res = $db->Execute($query);
  $res = $db->Execute("UPDATE $dbtables[planets] SET credits=credits + $transfer WHERE planet_id=$dplanet_id");
  $res = $db->Execute("UPDATE $dbtables[players] SET turns=turns - $tcost WHERE player_id = $playerinfo[player_id]");
  $res = $db->Execute("INSERT INTO $dbtables[ibank_statement] SET player_id=$playerinfo[player_id], amount=$transfer, trans_type=5"); // Type 5 = consolidate

}
示例#26
0
     echo "<td>{$sc_beams}</td></tr>";
 } else {
     echo "<td>???</td></tr>";
 }
 echo "<tr><td>Torpedo launchers:</td>";
 $roll = mt_rand(1, 100);
 if ($roll < $success) {
     $sc_torp_launchers = NUMBER(round($ownerinfo['torp_launchers'] * $sc_error / 100));
     echo "<td>{$sc_torp_launchers}</td></tr>";
 } else {
     echo "<td>???</td></tr>";
 }
 echo "<tr><td>Shields:</td>";
 $roll = mt_rand(1, 100);
 if ($roll < $success) {
     $sc_shields = NUMBER(round($ownerinfo['shields'] * $sc_error / 100));
     echo "<td>{$sc_shields}</td></tr>";
 } else {
     echo "<td>???</td></tr>";
 }
 echo "</tbody></table></div>";
 $res = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE on_planet = 'Y' and planet_id = {$planet_id}");
 db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
 while (!$res->EOF) {
     $row = $res->fields;
     $success = SCAN_SUCCESS($playerinfo['sensors'], $row['cloak']);
     if ($success < 5) {
         $success = 5;
     }
     if ($success > 95) {
         $success = 95;
示例#27
0
	if ( $difftime > $IGB_crate) {
		//echo "Delinquent loan: $account[player_id] owes ".NUMBER($account[loan])."<br>";
		$res2 = $db->Execute("SELECT * from $dbtables[players] WHERE player_id=$account[player_id]");
		$playerinfo = $res2->fields;
		$logentry = "";
		$newsentry = "";
		// Pay off from account
		//echo "Try to pay off from IGB account. $playerinfo[character_name] had ".NUMBER($account[balance])."<br>";
		$account[loan] -= $account[balance];
		$account[balance] = 0;
		//echo "Loan is now $account[loan]<br>";
		if ($account[loan] > 0) {
			if ($playerDeath == true) {
				$logentry = $logentry."The IGB collected on its loan as you died before you could pay it off. It was ".NUMBER($account[loan])." credits.";
			} else {
				$logentry = "A massive ship appears in your sector with the letters IGB written on the side. As a blue laser beam sweeps the cabin you hear a booming voice say: 'The IGB is collecting on our loan to you which stood at ".NUMBER($account[loan])." credits.";
			}
			// Try to pay off by liquidating planets
			//echo "Try to pay off by liquidating planets<br>";
			$num_planets = 0;
			$calc_planet_goods = "organics*$organics_price+ore*$ore_price+goods*$goods_price+energy*$energy_price";
			$calc_planet_colonists = "colonists*$colonist_price";
			$calc_planet_defence = "fighters*$fighter_price+IF($dbtables[planets].base='Y', $base_credits+torps*$torpedo_price, 0)";
			$calc_planet_credits = "credits";
			$sql = "SELECT planet_id, name, sector_id,$calc_planet_goods+$calc_planet_colonists+$calc_planet_defence+$calc_planet_credits AS score FROM $dbtables[planets] WHERE owner=$account[player_id] ORDER BY score ASC";
			//echo $sql."<br>";
			$res3 = $db->Execute($sql);
			$planetlist = "";
			while (!$res3->EOF && $account[loan] > 0) {
			 	$row = $res3->fields;
				$account[loan] -= $row[score];
示例#28
0
function table_pop_info($tribeinfo)
{
    global $db, $dbtables;
    echo "<P>";
    echo "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=4 WIDTH=\"100%\">";
    echo "<TR>";
    echo "<TD colspan=8><FONT CLASS=rsrc_title>Population</FONT></TD>";
    echo "</TR>";
    echo "<TR>";
    $totalpop = NUMBER($tribeinfo['activepop'] + $tribeinfo['warpop'] + $tribeinfo['inactivepop'], 0);
    echo "<TD><FONT CLASS=rsrc_name>Total</FONT></TD>";
    echo "<TD align=right><FONT CLASS=stat_resource>{$totalpop}</TD>";
    if ($tribeinfo['activepop'] > 0) {
        $activepop = NUMBER($tribeinfo['activepop'], 0);
        $unassigned = NUMBER($tribeinfo['curam'], 0);
        echo "<TD><FONT CLASS=rsrc_name>Actives</FONT></TD>";
        echo "<TD align=right><FONT CLASS=stat_resource>{$activepop} ({$unassigned})</TD>";
    }
    if ($tribeinfo['inactivepop'] > 0) {
        $inactivepop = NUMBER($tribeinfo['inactivepop'], 0);
        echo "<TD><FONT CLASS=rsrc_name>Inactives</FONT></TD>";
        echo "<TD align=right><FONT CLASS=stat_resource>{$inactivepop}</TD>";
    }
    if ($tribeinfo['warpop'] > 0) {
        $gar = $db->Execute("SELECT count(*) as garrisons FROM {$dbtables['garrisons']} " . "WHERE tribeid = '{$_SESSION['current_unit']}'");
        $garinfo = $gar->fields;
        $warpop = NUMBER($tribeinfo['warpop']);
        echo "<TD><FONT CLASS=rsrc_name>Warriors</FONT></TD>";
        echo "<TD align=right><FONT CLASS=stat_resource>{$warpop} ({$garinfo['garrisons']})</TD>";
    }
    echo "</TR>";
    if ($tribeinfo['slavepop'] > 0 || $tribeinfo['specialpop'] > 0) {
        echo "<TR>";
        $record_pad = 8;
        if ($tribeinfo['slavepop'] > 0) {
            $record_pad = $record_pad - 2;
            echo "<TD><FONT CLASS=rsrc_name>Slaves</FONT></TD>";
            echo "<TD align=right><FONT CLASS=stat_resource>{$tribeinfo['slavepop']}</TD>";
        }
        if ($tribeinfo['specialpop'] > 0) {
            $record_pad = $record_pad - 2;
            echo "<TD><FONT CLASS=rsrc_name>Special</FONT></TD>";
            echo "<TD align=right><FONT CLASS=stat_resource>{$tribeinfo['specialpop']}</TD>";
        }
        echo "<TD colspan={$record_pad}>&nbsp;</TD>";
        echo "</TR>";
    }
    echo "</TABLE>";
}
示例#29
0
 echo "    <td>" . NUMBER($armor_price) . "</td>\n";
 echo "    <td>" . NUMBER($playerinfo['armor_pts']) . " / " . NUMBER($armor_max) . "</td>\n";
 echo "    <td>";
 if ($playerinfo['armor_pts'] != $armor_max) {
     echo "<a href='#' onClick=\"MakeMax('armor_number', {$armor_free});countTotal();return false;\" {$onblur}>" . NUMBER($armor_free) . "</a></td>\n";
     echo "    <td><input type=TEXT NAME=armor_number SIZE=6 MAXLENGTH=10 value=0 {$onblur}>";
 } else {
     echo "0<td><input type=text readonly NAME=armor_number MAXLENGTH=10 value={$l_full} tabindex='0' {$onblur}>";
 }
 echo "</td>\n";
 echo "    <td>{$l_colonists}</td>\n";
 echo "    <td>" . NUMBER($colonist_price) . "</td>\n";
 echo "    <td>" . NUMBER($playerinfo['ship_colonists']) . " / " . NUMBER($colonist_max) . "</td>\n";
 echo "    <td>";
 if ($playerinfo['ship_colonists'] != $colonist_max) {
     echo "<a href='#' onClick=\"MakeMax('colonist_number', {$colonist_free});countTotal();return false;\" {$onblur}>" . NUMBER($colonist_free) . "</a></td>\n";
     echo "    <td><input type=TEXT NAME=colonist_number SIZE=6 MAXLENGTH=10 value=0 {$onblur}>";
 } else {
     echo "0<td><input type=text readonly NAME=colonist_number MAXLENGTH=10 value={$l_full} tabindex='0' {$onblur}>";
 }
 echo "    </td>\n";
 echo "  </tr>\n";
 echo " </tbody></table>";
 ?>
 </div><div class="port-table-container">
 <?php 
 echo " <table><tbody>\n";
 echo "  <tr style=\"background-color: transparent;\">\n";
 echo "    <td><input type=submit value={$l_buy} {$onclick}></td>\n";
 echo "    <td style=\"text-align:right\">{$l_totalcost}: <input type=TEXT style=\"text-align:right\" class=\"purchase-total-cost\"NAME=total_cost SIZE=22 value=0 {$onfocus} {$onblur} {$onchange} {$onclick}></td>\n";
 echo "  </tr>\n";
示例#30
0
 public static function attack_target_ship($victim_id, $attacker_id)
 {
     global $db_prefix;
     global $ewd_maxhullsize;
     global $sector_max;
     global $bounty_ratio;
     global $bounty_minturns;
     global $bounty_maxvalue;
     global $level_factor;
     global $torp_dmg_rate;
     global $rating_combat_factor;
     global $upgrade_cost;
     global $upgrade_factor;
     $sql_manager = new manage_table();
     $player_manager = new manage_player();
     $manage_log = new manage_log();
     ###############################################################################################
     ###																							###
     ###   LAUNCHING ATTACK LAUNCHING ATTACK LAUNCHING ATTACK LAUNCHING ATTACK LAUNCHING ATTACK  ###
     ###																							###
     ###############################################################################################
     $tables_to_lock_array = array('xenobe', 'sector_defence', 'ships', 'universe', 'bounty', 'planets', 'news', 'movement_log', 'logs', 'ibank_accounts', 'languages', 'zones', 'player_logs', 'security_logs');
     if ($sql_manager->lock_table($tables_to_lock_array)) {
         $victim_id = $this->stripnum($victim_id);
         $attacker_id = $this->stripnum($attacker_id);
         /* Get Player Data */
         $target_data = $sql_manager->playerinfo($victim_id, "");
         $attacker_data = $sql_manager->playerinfo($attacker_id, "");
         $playerscore = $player_manager->generate_score($attacker_id);
         $targetscore = $player_manager->generate_score($victim_id);
         $playerscore = $playerscore * $playerscore;
         $targetscore = $targetscore * $targetscore;
         $zone_information = $sql_manager->zone_information($target_data['sector'], 'allow_attack');
         # stage 1 - check both are in the same sector
         if ($target_data['sector'] != $attacker_data['sector'] || $target_data['on_planet'] == "Y") {
             echo "Target not in the sector, or the target is on a planet. You sir have failed.<br/>";
             # Security Log #
             $manage_log->security_log($attacker_data['ship_id'], 23, $attacker_data['ship_id'], $target_data['ship_id']);
         } else {
             if ($attacker_data['turns'] < 1) {
                 echo "You have no turns to attack with. You sir have failed.<br/>";
                 $manage_log->security_log($attacker_data['ship_id'], 24, $attacker_data['ship_id'], $target_data['ship_id'], $attacker_data['turns']);
             } else {
                 if ($attacker_data['team'] == $target_data['team'] and $target_data['team'] > 0) {
                     echo "Oi, trying to attack your friends, shame on you... SHAME ON YOU!<br/>";
                     $manage_log->security_log($attacker_data['ship_id'], 25, $attacker_data['ship_id'], $target_data['ship_id']);
                 } else {
                     if ($zone_information['allow_attack'] == "N") {
                         echo "This zone doesnt allow attacking. You sir have failed.<br/>";
                         $manage_log->security_log($attacker_data['ship_id'], 26, $attacker_data['ship_id'], $target_data['ship_id']);
                     } else {
                         if (isset($_SESSION['in_combat']) && $_SESSION['in_combat'] === true) {
                             echo "Whoooops, your allready attacking this ship! Refresh much? Admin has been notified.<br/>";
                             ## LOG THIS MULTI ATTACK ##
                             $manage_log->security_log($attacker_data['ship_id'], 27, $attacker_data['ship_id'], $target_data['ship_id']);
                         } else {
                             $manage_log->security_log($attacker_data['ship_id'], 28, $attacker_data['ship_id'], $target_data['ship_id']);
                             /* WE CAN ATTACK ... NO GOING BACK NOW JIM!!!*/
                             if (preg_match("/(\\@xenobe)\$/", $target_data['email']) === 0) {
                                 /*xenobe. we dont want to be blocking the scheduler again*/
                             } else {
                                 $_SESSION['in_combat'] = (bool) true;
                             }
                             // Set In Combat Flag
                             $success = (10 - $target_data['cloak'] + $attacker_data['sensors']) * 5;
                             if ($success < 5) {
                                 $success = 5;
                             }
                             if ($success > 95) {
                                 $success = 95;
                             }
                             $flee = (10 - $target_data['engines'] + $attacker_data['engines']) * 5;
                             if ($target_data['beams'] == $attacker_data['beams'] and $target_data['power'] == $attacker_data['power']) {
                                 /*Black holes open when 2 equally matched beams are fired directly at each other with the same power amplilification*/
                                 $roll3 = mt_rand(1, 10000);
                                 /* chance of Accidently creating a black hole!*/
                                 /*to not ruin the game, there is a 0.04% chance of a black hole appearing. and then the 2 ships have to be matched in size*/
                             } else {
                                 $roll3 = 1;
                             }
                             $roll = mt_rand(1, 100);
                             $roll2 = mt_rand(1, 100);
                             if ($flee < $roll2) {
                                 echo "Oh no they out manouvered you! UPGRADE THOSE ENGINES! <br/>";
                                 $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                 $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                 $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used']);
                                 $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                 $manage_log->player_log($target_data['ship_id'], 4, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                             } elseif ($roll > $success) {
                                 // If scanning failed, inform the target
                                 echo "Oops you where unable to lock target on the enemy ship, UPGRADE THOSE SENSORS!!!!?!<br/>";
                                 $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                 $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                 $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used']);
                                 $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                 $manage_log->player_log($target_data['ship_id'], 9, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                             } else {
                                 $shipavg = $this->ship_average_tech($target_data, "ship");
                                 if ($shipavg > $ewd_maxhullsize) {
                                     $chance = ($shipavg - $ewd_maxhullsize) * 10;
                                 } else {
                                     $chance = 0;
                                 }
                                 $random_value = mt_rand(1, 100);
                                 if ($roll3 > 9996) {
                                     $manage_log->security_log($attacker_data['ship_id'], 29, $attacker_data['ship_id'], $target_data['ship_id']);
                                     /*A black hole was accidently created*/
                                     echo "Uuuuuuuuuuuhhhhhhhh oooooohhhhhhh shsssshshshshhhhhhiiiiiii............bbbbbblllllllaaaaaccccccckkkkkkkkk kk kk kk kk kk  h    h      h     o<br/>";
                                     $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                     $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                     $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used']);
                                     $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                     # both ships suffer damage if they have EWD, otherwise both ships destroyed #
                                     if ($target_data['dev_emerwarp'] > 0) {
                                         $dest_sector = mt_rand(1, $sector_max - 1);
                                         $target_data['dev_emerwarp'] = $target_data['dev_emerwarp'] - 1;
                                         $updated_stats = array('sector' => $dest_sector, 'dev_emerwarp' => $target_data['dev_emerwarp'], 'cleared_defences' => ' ');
                                         $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                         $manage_log->player_log($target_data['ship_id'], 25, '', '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                     } else {
                                         #  SHIP DESTROYED  #
                                         /*Escape pods are useless....*/
                                         $sql_manager->reset_ship($target_data['ship_id']);
                                         $sql_manager->kill_ship($target_data['ship_id']);
                                         $sql_manager->update_player_ship_deaths($target_data['ship_id']);
                                         $manage_log->player_log($target_data['ship_id'], 24, '', '', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                     }
                                     if ($attacker_data['dev_emerwarp'] > 0) {
                                         $dest_sector = mt_rand(1, $sector_max - 1);
                                         $rating_change = round($attacker_data['rating'] * 0.1);
                                         $attacker_data['dev_emerwarp'] = $attacker_data['dev_emerwarp'] - 1;
                                         $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                         $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                         $updated_stats = array('sector' => $dest_sector, 'dev_emerwarp' => $attacker_data['dev_emerwarp'], 'cleared_defences' => ' ', 'turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used'], 'rating' => $rating_change);
                                         $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                         $manage_log->player_log($attacker_data['ship_id'], 25, '', '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                     } else {
                                         #  SHIP DESTROYED  #
                                         /*Escape pods are useless....*/
                                         $sql_manager->reset_ship($attacker_data['ship_id']);
                                         $sql_manager->kill_ship($attacker_data['ship_id']);
                                         $sql_manager->update_player_ship_deaths($attacker_data['ship_id']);
                                         $manage_log->player_log($attacker_data['ship_id'], 24, '', '', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                     }
                                 } else {
                                     if ($target_data['dev_emerwarp'] > 0 && $random_value > $chance) {
                                         /*They did it, they hit the EWD just in time*/
                                         echo "they hit the EWD.... we missed them ... now to take your anger out on your weapons officer.....<br/>";
                                         $rating_change = round($attacker_data['rating'] * 0.1);
                                         $dest_sector = mt_rand(1, $sector_max - 1);
                                         $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                         $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                         $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used'], 'rating' => $rating_change);
                                         $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                         /*Move the ship that hit the EWD*/
                                         $target_data['dev_emerwarp'] = $target_data['dev_emerwarp'] - 1;
                                         $updated_stats = array('sector' => $dest_sector, 'dev_emerwarp' => $target_data['dev_emerwarp'], 'cleared_defences' => ' ');
                                         $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                         $manage_log->player_log($target_data['ship_id'], 6, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                     } else {
                                         /*Go forth and attack*/
                                         if (($targetscore / $playerscore < $bounty_ratio || $target_data['turns_used'] < $bounty_minturns) && preg_match("/(\\@xenobe)\$/", $target_data['email']) === 0) {
                                             $btyamount = 0;
                                             $hasbounty = $sql_manager->get_bounty($target_data['ship_id'], 0);
                                             if ($hasbounty['btytotal'] > 0) {
                                                 $btyamount = $hasbounty['btytotal'];
                                             }
                                             if ($btyamount <= 0) {
                                                 $bounty = round($playerscore * $bounty_maxvalue);
                                                 $sql_manager->create_bounty($attacker_data['ship_id'], 0, $bounty);
                                                 # LOG BOUNTY ON PLAYER #
                                                 echo "The Federation does not approve of you attacking a smaller ship. Your now barred from all shipyards until you pay your fine.<br/>";
                                                 $manage_log->player_log($attacker_data['ship_id'], 26, $target_data['ship_id'], $bounty, '', '', "<font color='#E9AB17'>Medium Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                             }
                                         }
                                         if ($target_data['dev_emerwarp'] > 0) {
                                             $manage_log->player_log($target_data['ship_id'], 7, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                         }
                                         ##############################
                                         ##############################
                                         ##							##
                                         ## SETTING UP ATTACK DATA	##
                                         ##							##
                                         ##############################
                                         ##############################
                                         $targetenergy = $target_data['ship_energy'];
                                         $playerenergy = $attacker_data['ship_energy'];
                                         // I added these two so we can have a value for debugging and reporting totals
                                         // If we use the variables in calcs below, change the display of stats too
                                         $targetbeams = $this->number_beams($target_data['beams']);
                                         if ($targetbeams > $target_data['ship_energy']) {
                                             $targetbeams = $target_data['ship_energy'];
                                         }
                                         $target_data['ship_energy'] = $target_data['ship_energy'] - $targetbeams;
                                         // Why dont we set targetinfo[ship_energy] to a variable instead?
                                         $playerbeams = $this->number_beams($attacker_data['beams']);
                                         if ($playerbeams > $attacker_data['ship_energy']) {
                                             $playerbeams = $attacker_data['ship_energy'];
                                         }
                                         $attacker_data['ship_energy'] = $attacker_data['ship_energy'] - $playerbeams;
                                         $playershields = $this->number_shields($attacker_data['shields']);
                                         if ($playershields > $attacker_data['ship_energy']) {
                                             $playershields = $attacker_data['ship_energy'];
                                         }
                                         $attacker_data['ship_energy'] = $attacker_data['ship_energy'] - $playershields;
                                         $targetshields = $this->number_shields($target_data['shields']);
                                         if ($targetshields > $target_data['ship_energy']) {
                                             $targetshields = $target_data['ship_energy'];
                                         }
                                         $target_data['ship_energy'] = $target_data['ship_energy'] - $targetshields;
                                         $playertorpnum = round(pow($level_factor, $attacker_data['torp_launchers'])) * 10;
                                         if ($playertorpnum > $attacker_data['torps']) {
                                             $playertorpnum = $attacker_data['torps'];
                                         }
                                         $targettorpnum = round(pow($level_factor, $target_data['torp_launchers'])) * 10;
                                         if ($targettorpnum > $target_data['torps']) {
                                             $targettorpnum = $target_data['torps'];
                                         }
                                         $playertorpdmg = $torp_dmg_rate * $playertorpnum;
                                         $targettorpdmg = $torp_dmg_rate * $targettorpnum;
                                         $playerarmor = $attacker_data['armor_pts'];
                                         $targetarmor = $target_data['armor_pts'];
                                         $playerfighters = $attacker_data['ship_fighters'];
                                         $targetfighters = $target_data['ship_fighters'];
                                         $targetdestroyed = 0;
                                         $playerdestroyed = 0;
                                         echo "You are currently attacking " . $target_data['character_name'] . " aboard " . $target_data['ship_name'] . ":<br/>";
                                         $bcs_info = null;
                                         $bcs_info[] = array("Beams (lvl)", $playerbeams . " <span class=\"table_word_faded\">(" . $attacker_data['beams'] . ")</span>", $targetbeams . " <span class=\"table_word_faded\">(" . $target_data['beams'] . ")</span>");
                                         $bcs_info[] = array("Shields (lvl)", $playershields . " <span class=\"table_word_faded\">(" . $attacker_data['shields'] . ")</span>", $targetshields . " <span class=\"table_word_faded\">(" . $target_data['shields'] . ")</span>");
                                         $bcs_info[] = array("Energy (Start)", $attacker_data['ship_energy'] . " <span class=\"table_word_faded\">(" . $playerenergy . ")</span>", $target_data['ship_energy'] . " <span class=\"table_word_faded\">(" . $targetenergy . ")</span>");
                                         $bcs_info[] = array("Torps (lvl)", $playertorpnum . " <span class=\"table_word_faded\">(" . $attacker_data['torp_launchers'] . ")</span>", $targettorpnum . " <span class=\"table_word_faded\">(" . $target_data['torp_launchers'] . ")</span>");
                                         $bcs_info[] = array("TorpDmg", $playertorpdmg, $targettorpdmg);
                                         $bcs_info[] = array("Fighters", $playerfighters, $targetfighters);
                                         $bcs_info[] = array("Armor (lvl)", $playerarmor . " <span class=\"table_word_faded\">(" . $attacker_data['armor'] . ")</span>", $targetarmor . " <span class=\"table_word_faded\">(" . $target_data['beams'] . ")</span>");
                                         $bcs_info[] = array("Escape Pod", $attacker_data['dev_escapepod'], $target_data['dev_escapepod']);
                                         /*
                                         Build table
                                         */
                                         ?>
 <div class="general-table-container">
 <?php 
                                         echo "<table><tbody>";
                                         echo "<tr>";
                                         echo "<td>Stats</td>";
                                         echo "<td>You [<span class=\"table_word_blue\">" . $attacker_data['character_name'] . "</span>]</td>";
                                         echo "<td>Target [<span class=\"table_word_orange\">" . $target_data['character_name'] . "</span>]</td>";
                                         echo "</tr>";
                                         for ($bcs_index = 0; $bcs_index < count($bcs_info); $bcs_index++) {
                                             echo "  <tr>";
                                             echo "    <td>" . $bcs_info[$bcs_index][0] . "</td>";
                                             echo "    <td>" . $bcs_info[$bcs_index][1] . "</td>";
                                             echo "    <td>" . $bcs_info[$bcs_index][2] . "</td>";
                                             echo "  </tr>";
                                         }
                                         echo "</tbody></table>";
                                         echo "<table><tbody>";
                                         echo "<tr>";
                                         echo "<td colspan=\"2\">Target Locked</td>";
                                         echo "</tr>";
                                         echo "<tr><td class=\"ship-attack-title\">Firing Beams</td>";
                                         echo "<td>";
                                         $bcs_stats_info = false;
                                         if ($targetfighters > 0 && $playerbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerbeams > round($targetfighters / 2)) {
                                                 $temp = round($targetfighters / 2);
                                                 $lost = $targetfighters - $temp;
                                                 //Maybe we should report on how many beams fired , etc for comparision/bugtracking
                                                 echo $target_data['character_name'] . " lost " . $lost . " fighters<br/>";
                                                 $targetfighters = $temp;
                                                 $playerbeams = $playerbeams - $lost;
                                             } else {
                                                 $targetfighters = $targetfighters - $playerbeams;
                                                 echo $target_data['character_name'] . " lost " . $playerbeams . " fighters<br/>";
                                                 $playerbeams = 0;
                                             }
                                         }
                                         if ($playerfighters > 0 && $targetbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetbeams > round($playerfighters / 2)) {
                                                 $temp = round($playerfighters / 2);
                                                 $lost = $playerfighters - $temp;
                                                 echo "You lost " . $lost . " fighters<br>";
                                                 $playerfighters = $temp;
                                                 $targetbeams = $targetbeams - $lost;
                                             } else {
                                                 $playerfighters = $playerfighters - $targetbeams;
                                                 echo "You lost " . $targetbeams . " fighters<br>";
                                                 $targetbeams = 0;
                                             }
                                         }
                                         if ($playerbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerbeams > $targetshields) {
                                                 $playerbeams = $playerbeams - $targetshields;
                                                 $targetshields = 0;
                                                 echo $target_data['character_name'] . "'s shields are down!<br>";
                                             } else {
                                                 echo $target_data['character_name'] . "'s shields are hit for " . $playerbeams . " damage.<br>";
                                                 $targetshields = $targetshields - $playerbeams;
                                                 $playerbeams = 0;
                                             }
                                         }
                                         if ($targetbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetbeams > $playershields) {
                                                 $targetbeams = $targetbeams - $playershields;
                                                 $playershields = 0;
                                                 echo "Your shields are down!<br/>";
                                             } else {
                                                 echo "Your shields are hit for " . $targetbeams . " damage.<br/>";
                                                 $playershields = $playershields - $targetbeams;
                                                 $targetbeams = 0;
                                             }
                                         }
                                         if ($playerbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerbeams > $targetarmor) {
                                                 $targetarmor = 0;
                                                 echo $target_data['character_name'] . "'s armor breached!<br/>";
                                             } else {
                                                 $targetarmor = $targetarmor - $playerbeams;
                                                 echo $target_data['character_name'] . "'s armor is hit for " . $playerbeams . " damage.<br/>";
                                             }
                                         }
                                         if ($targetbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetbeams > $playerarmor) {
                                                 $playerarmor = 0;
                                                 echo "Your armor has been breached!" . "<br/>";
                                             } else {
                                                 $playerarmor = $playerarmor - $targetbeams;
                                                 echo "Your armor is hit for {$targetbeams} damage.<br>";
                                             }
                                         }
                                         if ($bcs_stats_info == false) {
                                             echo "No information available.<br>";
                                         }
                                         echo "  </td></tr>";
                                         echo "<tr><td class=\"ship-attack-title\">Launching Torpedos</td>";
                                         echo "<td>";
                                         $bcs_stats_info = false;
                                         if ($targetfighters > 0 && $playertorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($playertorpdmg > round($targetfighters / 2)) {
                                                 $temp = round($targetfighters / 2);
                                                 $lost = $targetfighters - $temp;
                                                 echo $target_data['character_name'] . " lost " . $lost . " fighters<br/>";
                                                 $targetfighters = $temp;
                                                 $playertorpdmg = $playertorpdmg - $lost;
                                             } else {
                                                 $targetfighters = $targetfighters - $playertorpdmg;
                                                 echo $target_data['character_name'] . " lost " . $playertorpdmg . " fighters<br/>";
                                                 $playertorpdmg = 0;
                                             }
                                         }
                                         if ($playerfighters > 0 && $targettorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($targettorpdmg > round($playerfighters / 2)) {
                                                 $temp = round($playerfighters / 2);
                                                 $lost = $playerfighters - $temp;
                                                 echo "You lost " . $lost . " fighters<br/>";
                                                 echo "{$temp} - {$playerfighters} - {$targettorpdmg}";
                                                 $playerfighters = $temp;
                                                 $targettorpdmg = $targettorpdmg - $lost;
                                             } else {
                                                 $playerfighters = $playerfighters - $targettorpdmg;
                                                 echo "You lost " . $targettorpdmg . " fighters<br/>";
                                                 $targettorpdmg = 0;
                                             }
                                         }
                                         if ($playertorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($playertorpdmg > $targetarmor) {
                                                 $targetarmor = 0;
                                                 echo $target_data['character_name'] . "'s armor breached!<br/>";
                                             } else {
                                                 $targetarmor = $targetarmor - $playertorpdmg;
                                                 echo $target_data['character_name'] . "'s armor is hit for " . $playertorpdmg . " damage.<br/>";
                                             }
                                         }
                                         if ($targettorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($targettorpdmg > $playerarmor) {
                                                 $playerarmor = 0;
                                                 echo "Your armor has been breached!" . "<br/>";
                                             } else {
                                                 $playerarmor = $playerarmor - $targettorpdmg;
                                                 echo "Your armor is hit for " . $targettorpdmg . " damage.<br/>";
                                             }
                                         }
                                         if ($bcs_stats_info == false) {
                                             echo "No information available.<br>";
                                         }
                                         echo "</tr></td>";
                                         echo "<tr><td class=\"ship-attack-title\">Fighter have been launched</td>";
                                         echo "<td>";
                                         $bcs_stats_info = false;
                                         if ($playerfighters > 0 && $targetfighters > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerfighters > $targetfighters) {
                                                 echo $target_data['character_name'] . " Lost all their fighters<br/>";
                                                 $temptargfighters = 0;
                                             } else {
                                                 echo $target_data['character_name'] . " lost " . $playerfighters . " fighters.<br/>";
                                                 $temptargfighters = $targetfighters - $playerfighters;
                                             }
                                             if ($targetfighters > $playerfighters) {
                                                 echo "You lost all fighters.<br/>";
                                                 $tempplayfighters = 0;
                                             } else {
                                                 echo "You lost " . $targetfighters . " fighters.<br/>";
                                                 $tempplayfighters = $playerfighters - $targetfighters;
                                             }
                                             $playerfighters = $tempplayfighters;
                                             $targetfighters = $temptargfighters;
                                         }
                                         if ($playerfighters > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerfighters > $targetarmor) {
                                                 $targetarmor = 0;
                                                 echo $target_data['character_name'] . "'s armor breached!<br/>";
                                             } else {
                                                 $targetarmor = $targetarmor - $playerfighters;
                                                 echo $target_data['character_name'] . "'s armor is hit for " . $playerfighters . " damage.<br/>";
                                             }
                                         }
                                         if ($targetfighters > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetfighters > $playerarmor) {
                                                 $playerarmor = 0;
                                                 echo "Your armor has been breached!" . "<br/>";
                                             } else {
                                                 $playerarmor = $playerarmor - $targetfighters;
                                                 echo "Your armor is hit for " . $targetfighters . " damage.<br/>";
                                             }
                                         }
                                         if ($bcs_stats_info == false) {
                                             echo "No information available.<br>";
                                         }
                                         echo " </td></tr></tbody></table>";
                                         echo "<table><tbody><tr><td>Results</td></tr><tr><td>";
                                         if ($targetarmor < 1) {
                                             ######################################
                                             ### 							   ###
                                             ##									##
                                             ##			ENEMY DESTROYED			##
                                             ##									##
                                             ###								   ###
                                             ######################################
                                             echo $target_data['character_name'] . "'s ship has been destroyed.<br/>";
                                             if ($target_data['dev_escapepod'] == "Y") {
                                                 #LOG ATTACK LOOSE ESCAPE
                                                 $rating = round($target_data['rating'] / 2);
                                                 echo "Escape pod was launch detected! <span class=\"table_word_blue\">You destroyed their ship but they got away in their Escape Pod</span><br/>";
                                                 $sql_manager->reset_ship($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_kills($attacker_data['ship_id']);
                                                 $sql_manager->collect_bounty($attacker_data['ship_id'], $target_data['ship_id']);
                                                 /*Reload credits just in case user collected a bounty*/
                                                 $current_credits = $sql_manager->check_credits($attacker_data['ship_id']);
                                                 $attacker_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($target_data['ship_id'], 10, $attacker_data['ship_id'], 'Y', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             } else {
                                                 # LOG ATTACK #
                                                 $sql_manager->reset_ship($target_data['ship_id']);
                                                 $sql_manager->kill_ship($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_kills($attacker_data['ship_id']);
                                                 $sql_manager->collect_bounty($attacker_data['ship_id'], $target_data['ship_id']);
                                                 $current_credits = $sql_manager->check_credits($attacker_data['ship_id']);
                                                 $attacker_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($target_data['ship_id'], 10, $attacker_data['ship_id'], 'N', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             }
                                             if ($playerarmor > 0) {
                                                 ######################################
                                                 ### 							   ###
                                                 ##									##
                                                 ##			YOU SURVIVED			##
                                                 ##									##
                                                 ###								   ###
                                                 ######################################
                                                 $rating_change = round($target_data['rating'] * $rating_combat_factor);
                                                 // Updating to always get a positive rating increase for xenobe and the credits they are carrying
                                                 $salv_credits = 0;
                                                 // Double Death Attack Bug Fix - Returns 0 for real players, 1 for Xenobe players
                                                 if (preg_match("/(\\@xenobe)\$/", $target_data['email']) !== 0) {
                                                     $sql_manager->disable_xenobe($target_data['email']);
                                                     if ($rating_change > 0) {
                                                         $rating_change = 0 - $rating_change;
                                                         $manage_log->player_log($target_data['ship_id'], 10, $attacker_data['ship_id'], 'N', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                                         $salv_credits = $target_data['credits'];
                                                         # BUG FIX copy the credits before killing ship*/
                                                         $sql_manager->reset_ship($target_data['ship_id']);
                                                         $sql_manager->kill_ship($target_data['ship_id']);
                                                         $sql_manager->collect_bounty($attacker_data['ship_id'], $target_data['ship_id']);
                                                         $current_credits = $sql_manager->check_credits($attacker_data['ship_id']);
                                                         $attacker_data['credits'] = $current_credits['credits'];
                                                     } else {
                                                         $salv_credits = $target_data['credits'];
                                                     }
                                                 }
                                                 $salvage_percentage = mt_rand(1, 10);
                                                 $free_ore = round($target_data['ship_ore'] / $salvage_percentage);
                                                 $free_organics = round($target_data['ship_organics'] / $salvage_percentage);
                                                 $free_goods = round($target_data['ship_goods'] / $salvage_percentage);
                                                 $free_holds = $this->number_holds($attacker_data['hull']) - $attacker_data['ship_ore'] - $attacker_data['ship_organics'] - $attacker_data['ship_goods'] - $attacker_data['ship_colonists'];
                                                 if ($free_holds > $free_goods) {
                                                     $salv_goods = $free_goods;
                                                     $free_holds = $free_holds - $free_goods;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_goods = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_goods = 0;
                                                 }
                                                 if ($free_holds > $free_ore) {
                                                     $salv_ore = $free_ore;
                                                     $free_holds = $free_holds - $free_ore;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_ore = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_ore = 0;
                                                 }
                                                 if ($free_holds > $free_organics) {
                                                     $salv_organics = $free_organics;
                                                     $free_holds = $free_holds - $free_organics;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_organics = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_organics = 0;
                                                 }
                                                 $ship_value = $upgrade_cost * (round(pow($upgrade_factor, $target_data['hull'])) + round(pow($upgrade_factor, $target_data['engines'])) + round(pow($upgrade_factor, $target_data['power'])) + round(pow($upgrade_factor, $target_data['computer'])) + round(pow($upgrade_factor, $target_data['sensors'])) + round(pow($upgrade_factor, $target_data['beams'])) + round(pow($upgrade_factor, $target_data['torp_launchers'])) + round(pow($upgrade_factor, $target_data['shields'])) + round(pow($upgrade_factor, $target_data['armor'])) + round(pow($upgrade_factor, $target_data['cloak'])));
                                                 $ship_salvage_rate = mt_rand(10, 20);
                                                 $ship_salvage = $ship_value * $ship_salvage_rate / 100 + $salv_credits;
                                                 // Added credits for xenobe - 0 if normal player
                                                 echo "You salvaged <span class=\"table_word_green\">" . $salv_ore . "</span> units of ore,<span class=\"table_word_green\"> " . $salv_organics . "</span> units of organics, <span class=\"table_word_green\">" . $salv_goods . "</span> units of goods, and salvaged <span class=\"table_word_yellow\">" . $ship_salvage_rate . "</span>% of the ship for <span class=\"table_word_yellow\">" . $ship_salvage . "</span> credits.<br/>Your rating changed by " . NUMBER(abs($rating_change)) . " points.<br/>";
                                                 $armor_lost = $attacker_data['armor_pts'] - $playerarmor;
                                                 $fighters_lost = $attacker_data['ship_fighters'] - $playerfighters;
                                                 $attacker_data['ship_ore'] = $attacker_data['ship_ore'] + $salv_ore;
                                                 $attacker_data['ship_organics'] = $attacker_data['ship_organics'] + $salv_organics;
                                                 $attacker_data['ship_goods'] = $attacker_data['ship_goods'] + $salv_goods;
                                                 $attacker_data['credits'] = $attacker_data['credits'] + $ship_salvage;
                                                 $attacker_data['ship_energy'] = $attacker_data['ship_energy'];
                                                 $attacker_data['ship_fighters'] = $attacker_data['ship_fighters'] - $fighters_lost;
                                                 $attacker_data['armor_pts'] = $attacker_data['armor_pts'] - $armor_lost;
                                                 $attacker_data['torps'] = $attacker_data['torps'] - $playertorpnum;
                                                 $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                                 $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                                 $attacker_data['rating'] = $attacker_data['rating'] - $rating_change;
                                                 $updated_stats = array('rating' => $attacker_data['rating'], 'turns_used' => $attacker_data['turns_used'], 'turns' => $attacker_data['turns'], 'torps' => $attacker_data['torps'], 'armor_pts' => $attacker_data['armor_pts'], 'ship_fighters' => $attacker_data['ship_fighters'], 'ship_energy' => $attacker_data['ship_energy'], 'ship_ore' => $attacker_data['ship_ore'], 'ship_organics' => $attacker_data['ship_organics'], 'ship_goods' => $attacker_data['ship_goods'], 'credits' => $attacker_data['credits']);
                                                 $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                                 echo "You lost <span class=\"table_word_red\">" . $armor_lost . "</span> Armour, <span class=\"table_word_red\">" . $fighters_lost . "</span> Fighters, and used <span class=\"table_word_red\">" . $playertorpnum . "</span> Torpedoes.<br/>";
                                             }
                                         } else {
                                             ######################################
                                             ### 							   ###
                                             ##									##
                                             ##			ENEMY SURVIVED			##
                                             ##									##
                                             ###								   ###
                                             ######################################
                                             echo "You did not destory " . $target_data['character_name'] . "'s ship.<br>";
                                             $rating_change = round($target_data['rating'] * 0.1);
                                             $armor_lost = $target_data['armor_pts'] - $targetarmor;
                                             $fighters_lost = $target_data['ship_fighters'] - $targetfighters;
                                             $energy = $target_data['ship_energy'];
                                             $manage_log->player_log($target_data['ship_id'], 27, $attacker_data['ship_id'], $armor_lost, $fighters_lost, '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             $target_data['ship_energy'] = $target_data['ship_energy'];
                                             $target_data['ship_fighters'] = $target_data['ship_fighters'] - $fighters_lost;
                                             $target_data['armor_pts'] = $target_data['armor_pts'] - $armor_lost;
                                             $target_data['torps'] = $target_data['torps'] - $targettorpnum;
                                             $updated_stats = array('ship_energy' => $target_data['ship_energy'], 'ship_fighters' => $target_data['ship_fighters'], 'armor_pts' => $target_data['armor_pts'], 'torps' => $target_data['torps']);
                                             $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                             $armor_lost = $attacker_data['armor_pts'] - $playerarmor;
                                             $fighters_lost = $attacker_data['ship_fighters'] - $playerfighters;
                                             $energy = $attacker_data['ship_energy'];
                                             $attacker_data['ship_energy'] = $energy;
                                             $attacker_data['ship_fighters'] = $attacker_data['ship_fighters'] - $fighters_lost;
                                             $attacker_data['armor_pts'] = $attacker_data['armor_pts'] - $armor_lost;
                                             $attacker_data['torps'] = $attacker_data['torps'] - $playertorpnum;
                                             $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                             $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                             $attacker_data['rating'] = $attacker_data['rating'];
                                             $updated_stats = array('ship_energy' => $attacker_data['ship_energy'], 'ship_fighters' => $attacker_data['ship_fighters'], 'armor_pts' => $attacker_data['armor_pts'], 'torps' => $attacker_data['torps'], 'turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used'], 'rating' => $attacker_data['rating']);
                                             $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                             echo "You lost <span class=\"table_word_red\">" . $armor_lost . "</span> armour, <span class=\"table_word_red\">" . $fighters_lost . "</span> Fighters, and used <span class=\"table_word_red\">" . $playertorpnum . "</span> Torpedoes.<br/>";
                                         }
                                         if ($playerarmor < 1) {
                                             ######################################
                                             ### 							   ###
                                             ##									##
                                             ##			YOU LOST... WHAT!		##
                                             ##									##
                                             ###								   ###
                                             ######################################
                                             echo "Your ship has been destroyed!<br/>";
                                             if ($attacker_data['dev_escapepod'] == "Y") {
                                                 echo "Luckily you have an escape pod!<br/>";
                                                 $sql_manager->reset_ship($attacker_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($attacker_data['ship_id']);
                                                 ## LOG EVENT ##
                                                 $sql_manager->collect_bounty($target_data['ship_id'], $attacker_data['ship_id']);
                                                 $current_credits = $sql_manager->check_credits($target_data['ship_id']);
                                                 $target_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($attacker_data['ship_id'], 28, $target_data['ship_id'], 'Y', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             } else {
                                                 echo "You didnt have an escape Pod, sadly your ice cold corpse can be seen floating in space....<br/>";
                                                 $sql_manager->reset_ship($attacker_data['ship_id']);
                                                 $sql_manager->kill_ship($attacker_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($attacker_data['ship_id']);
                                                 $sql_manager->collect_bounty($target_data['ship_id'], $attacker_data['ship_id']);
                                                 $current_credits = $sql_manager->check_credits($target_data['ship_id']);
                                                 $target_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($attacker_data['ship_id'], 28, $target_data['ship_id'], 'N', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             }
                                             if ($targetarmor > 0) {
                                                 $salvage_percentage = mt_rand(1, 10);
                                                 $free_ore = round($attacker_data['ship_ore'] / $salvage_percentage);
                                                 $free_organics = round($attacker_data['ship_organics'] / $salvage_percentage);
                                                 $free_goods = round($attacker_data['ship_goods'] / $salvage_percentage);
                                                 $free_holds = $this->number_holds($target_data['hull']) - $target_data['ship_ore'] - $target_data['ship_organics'] - $target_data['ship_goods'] - $target_data['ship_colonists'];
                                                 if ($free_holds > $free_goods) {
                                                     $salv_goods = $free_goods;
                                                     $free_holds = $free_holds - $free_goods;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_goods = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_goods = 0;
                                                 }
                                                 if ($free_holds > $free_ore) {
                                                     $salv_ore = $free_ore;
                                                     $free_holds = $free_holds - $free_ore;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_ore = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_ore = 0;
                                                 }
                                                 if ($free_holds > $free_organics) {
                                                     $salv_organics = $free_organics;
                                                     $free_holds = $free_holds - $free_organics;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_organics = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_organics = 0;
                                                 }
                                                 $ship_value = $upgrade_cost * (round(pow($upgrade_factor, $attacker_data['hull'])) + round(pow($upgrade_factor, $attacker_data['engines'])) + round(pow($upgrade_factor, $attacker_data['power'])) + round(pow($upgrade_factor, $attacker_data['computer'])) + round(pow($upgrade_factor, $attacker_data['sensors'])) + round(pow($upgrade_factor, $attacker_data['beams'])) + round(pow($upgrade_factor, $attacker_data['torp_launchers'])) + round(pow($upgrade_factor, $attacker_data['shields'])) + round(pow($upgrade_factor, $attacker_data['armor'])) + round(pow($upgrade_factor, $attacker_data['cloak'])));
                                                 $ship_salvage_rate = mt_rand(10, 20);
                                                 $ship_salvage = $ship_value * $ship_salvage_rate / 100 + $salv_credits;
                                                 // Added credits for xenobe - 0 if normal player
                                                 echo $target_data['character_name'] . " salvaged <span class=\"table_word_green\">" . $salv_ore . "</span> units of ore, <span class=\"table_word_green\">" . $salv_organics . "</span> units of organics, <span class=\"table_word_green\">" . $salv_goods . "</span> units of goods, and salvaged <span class=\"table_word_yellow\">" . $ship_salvage_rate . "</span>% of the ship for <span class=\"table_word_yellow\">" . $ship_salvage . "</span> credits<br/>";
                                                 $target_data['credits'] = $target_data['credits'] + $ship_salvage;
                                                 $target_data['ship_ore'] = $target_data['ship_ore'] + $salv_ore;
                                                 $target_data['ship_organics'] = $target_data['ship_organics'] + $salv_organics;
                                                 $target_data['ship_goods'] = $target_data['ship_goods'] + $salv_goods;
                                                 $target_data['armor_pts'] = $target_data['armor_pts'] - $targetarmor;
                                                 $target_data['ship_fighters'] = $target_data['ship_fighters'] - $targetfighters;
                                                 $target_data['ship_energy'] = $target_data['ship_energy'];
                                                 $target_data['torps'] = $target_data['torps'] - $targettorpnum;
                                                 echo "<P>ACTIVATING</P>";
                                                 $updated_stats = array('credits' => $target_data['credits'], 'ship_ore' => $target_data['ship_ore'], 'ship_organics' => $target_data['ship_organics'], 'ship_goods' => $target_data['ship_goods'], 'armor_pts' => $target_data['armor_pts'], 'ship_fighters' => $target_data['ship_fighters'], 'ship_energy' => $target_data['ship_energy'], 'torps' => $target_data['torps']);
                                                 $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                             }
                                         }
                                         echo "</td></td></tbody></table></div>";
                                         ## END OF ATTACK ##
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         /*Error*/
     }
     /*Now unlock the tables*/
     $sql_manager = new manage_table();
     if ($sql_manager->unlock_table()) {
         /*Now we have finished, unlock the tables.*/
     } else {
         /*Somthing went wrong*/
     }
     $_SESSION['in_combat'] = (bool) false;
 }