<script language="Javascript">
<!--
<?php
echo "\nvar font = \"{$font}\";";
echo "\n\nvar reqturns = new Array();";
for ( $i=0; $i<count($a_req_turns); $i++ )
echo "\nreqturns[{$i}] = {$a_req_turns[$i]};";
echo "\n\nvar abnames = new Array()";
echo "\nabnames[0] = \"Warfare\";";
echo "\nabnames[1] = \"Black Market\";";
echo "\nabnames[2] = \"Pimping\";";
echo "\n\nvar reqabs = new Array();";
for ( $i=0; $i<count($a_req_abs); $i++ ) {
echo "\nreqabs[{$i}] = new Array();";
$gia = explode(",", $a_req_abs[$i]);
for ( $j=0; $j<count($gia); $j++ )
echo "\nreqabs[{$i}][{$j}] = {$gia[$j]};";
}
echo "\n\nvar persnames = new Array();";
for ( $i=0; $i<count($def_p_unames); $i++ ) {
echo "\npersnames[{$i}] = new Array();";
echo "\npersnames[{$i}][0] = \"{$def_p_unames[$i]}\";";
}
for ( $j=0; $j<count($pnames); $j++ )
echo "\npersnames[".floor($j/3)."][".($j%3+1)."] = \"{$pnames[$j]}\";";
echo "\n\nvar reqpers = new Array();";
for ( $i=0; $i<count($a_req_pers); $i++ ) {
$gia = dexplode(":", ",", $a_req_pers[$i]);
echo "\nreqpers[{$i}] = new Array();";
for ( $j=0; $j<count($gia); $j++ ) {
echo "\nreqpers[{$i}][{$j}] = new Array();";
for ( $k=0; $k<count($gia[$j]); $k++ )
echo "\nreqpers[{$i}][{$j}][{$k}] = {$gia[$j][$k]};";
}
}
?>
function updatereqs() {
var gi = document.getElementById('attacktypezug').value;
if ( gi >= 0 ) {
document.getElementById('turnreqzug').value = reqturns[gi];
var gs = "Abilities: ";
var first = true;
for ( var i=0; i<reqabs[gi].length; i++ ) {
if ( reqabs[gi][i] > 0 ) {
if ( !first ) gs += ", ";
else first = false ;
gs += ""+reqabs[gi][i]+" "+abnames[i];
}
}
if ( first ) gs += "Nothing.";
document.getElementById('absreqzug').innerHTML = font+""+gs;
gs = "Personnel: ";
var first = true;
for ( var i=0; i<reqpers[gi].length; i++ ) {
if ( reqpers[gi][i].length > 1 ) { // individual personnel
for ( var j=0; j<reqpers[gi][i].length; j++ )
if ( reqpers[gi][i][j] > 0 ) {
if ( !first ) gs += ", ";
else first = false ;
gs += ""+reqpers[gi][i][j]+" "+persnames[i][j+1];
}
} else {
if ( reqpers[gi][i][0] > 0 ) {
if ( !first ) gs += ", ";
else first = false ;
gs += ""+reqpers[gi][i][0]+" "+persnames[i][0];
}
}
}
if ( first ) gs += "Nobody.";
document.getElementById('persreqzug').innerHTML = font+""+gs;
} else {
document.getElementById('turnreqzug').value = 0;
document.getElementById('absreqzug').innerHTML = font+"Abilities: Nobody.";
document.getElementById('persreqzug').innerHTML = font+"Personnel: Nobody.";
}
}
function updateattackwho(arg) {
document.getElementById('attackwhozug').value = document.getElementById('attackwhoselectzug').value;
}
-->
</script>
<?php
echo "\n<table align=center width=100% bgcolor=#{$bg} rules=none border=0 cellspacing=2>";
echo "\n<tr><td width=50% align=left>{$font}";
echo "\n<p><form action=\"{$PHP_SELF}\" method=\"post\">";
echo "\n<input type=\"hidden\" name=\"func\" value=\"attack\">";
echo "\nTarget: <input type=\"text\" name=\"attackwho\" id=\"attackwhozug\" value=\"{$auto_name}\" size=16>  ";
// get this user's attacks
$gs = outq00("SELECT attacks_out_ids FROM rusers WHERE user_id={$user_id}") . "," . outq00("SELECT attacks_in_ids FROM rusers WHERE user_id={$user_id}");
if ( $gs != "" ) {
$gia = explode(",", $gs); // get IDs
$names = array();
$dnames = array();
$somelen = 10;
for ( $k=0; $k<count($gia); $k++ ) { // get names of all users this user has attacked
if ( $gia[$k] != "" ) {
$names[$k] = outq00("SELECT name FROM rusers WHERE user_id={$gia[$k]}");
if ( strlen($names[$k]) > $somelen )
$dnames[$k] = substr($names[$k], 0, $somelen)."...";
else
$dnames[$k] = $names[$k];
} else $names[$k] = "";
}
echo "<select id=\"attackwhoselectzug\" onChange=\"javascript:updateattackwho()\">";
echo "\n<option value=\"\">-</option>";
for ( $k=0; $k<count($gia); $k++ )
if ( $names[$k] != "" )
echo "\n<option value=\"{$names[$k]}\">{$dnames[$k]}</option>";
echo "\n</select>";
}
echo "\n<br>Attack type: <select id=\"attacktypezug\" name=\"attacktype\" onChange=\"javascript:updatereqs()\">";
echo "\n<option value=\"-1\">--</option>";
for ( $k=0; $k<count($attack_types); $k++ )
echo "\n<option value=\"{$k}\">{$attack_types[$k]}</option>";
echo "\n</select>";
echo "\n<br>Leave a note: <input type=\"text\" name=\"attacknote\" value=\"\" size=16 maxlength=256>";
echo "\n<br>";
echo "\n  <input type=\"submit\" value=\"ATTACK\"></form></p>";
echo "\n</td><td width=50% align=left valign=top>{$font}";
echo "\n<p>Requirements for attack: <input type=\"text\" id=\"turnreqzug\" value=\"0\" size=5> turns";
echo "\n<div id=\"absreqzug\">Abilities: Nothing.</div>";
echo "\n<div id=\"persreqzug\">Personnel: Nobody.</div></p>";
echo "\n</td></tr></table>"; // close inner table
echo "\n</td></tr></table>"; // close COMBAT table