drawt
<?php
// read the necessary board data from board.txt
$Board = rtrim(file_get_contents($BoardURL));
$BoardLines = explode("\n", $Board); // split the file into lines
//echo count($BoardLines);
foreach ($BoardLines as $OneLine) {
$Fields = explode("|", $OneLine); // split the line into individual fields
if (($Fields[0] < 30) && ($Fields[1] < 30)) {
$ThisTime = strtotime($Fields[4]); // the time this cell was established
// check if the square is mature or not
//use date("Z") to account for timezone different to UTC
if ($ThisTime + $TimeBetweenCaptures < time(U)-date("Z")) {
// mature
$CellTeam[$Fields[0]][$Fields[1]] = $Fields[3]."Old";
} else {
// immature
$CellTeam[$Fields[0]][$Fields[1]] = $Fields[3]."New";
}
//CellTeam is used to determine color
//CellValue is the flag value
$CellValue[$Fields[0]][$Fields[1]] = $Fields[8];
//Use CellOffset to validate banked move
$CellOffset[$Fields[0]][$Fields[1]] = substr($Fields[6],-3,3).substr($Fields[7],-3,3);
}
}
$MoveList = explode($MoveDelimiter, $MoveData);
for ($j=0; $j<count($MoveList)-1; $j++) {
$MovePieces = explode("|", $MoveList[$j]);
$Square = FindSquare($MovePieces[0], $MovePieces[3], $MovePieces[7]);
$LatLon = explode("x",$Square);
$CellPlayer[$LatLon[0] % 30][$LatLon[1] % 30] = substr($MovePieces[0],0,1); // first initial
//CellPlayer indicates the player who banked this move
$MoveOffset = $MovePieces[4].$MovePieces[8];
// Get GameBoard offset either from CellOffset or from default
if ($CellOffset[$LatLon[0] % 30][$LatLon[1] % 30]) {
$ThisCellOffset = $CellOffset[$LatLon[0] % 30][$LatLon[1] % 30];
} else {
$ThisCellOffset = $DefaultOffsets;
}
if ($MoveOffset != $ThisCellOffset) {
$CellPlayer[$LatLon[0] % 30][$LatLon[1] % 30] .= "X";
}
}
//Now draw the actual board
?>
<table>
<tr><td>
<STYLE type=text/css>
<!--
.mys { FONT-SIZE: 8pt }
.mys TD { FONT-SIZE: 8pt }
.mys TH { FONT-SIZE: 8pt }
.lg2 {position: absolute; top: 15; left: 20; z-index: 2}
.cp2 {position: absolute; top: 520; left: 5; font-family: Arial; font-size: 10px; z-index: 2}
.bd2 {position: absolute; top: 20; left: 20; z-index: 1}
.mw2 {position: absolute; font-family: Arial; font-size: 11px; z-index: 3}
.cl2 {position: absolute; top: 610; left: 20; font-family: Arial; z-index: 3}
-->
</STYLE>
<table><tr><td>
<DIV id=board class=bd>
<FONT FACE=arial>
<TABLE class=mys cellSpacing=1 cellPadding=0 align=center bgColor=black border=0 frame=void>
<TBODY>
<TR align=middle>
<TD width=18 height=14 bgcolor=black></TD>
<TD width=18 bgColor=lightgrey>29</TD>
<TD width=18 bgColor=lightgrey>28</TD>
<TD width=18 bgColor=lightgrey>27</TD>
<TD width=18 bgColor=lightgrey>26</TD>
<TD width=18 bgColor=lightgrey>25</TD>
<TD width=18 bgColor=lightgrey>24</TD>
<TD width=18 bgColor=lightgrey>23</TD>
<TD width=18 bgColor=lightgrey>22</TD>
<TD width=18 bgColor=lightgrey>21</TD>
<TD width=18 bgColor=lightgrey>20</TD>
<TD width=18 bgColor=lightgrey>19</TD>
<TD width=18 bgColor=lightgrey>18</TD>
<TD width=18 bgColor=lightgrey>17</TD>
<TD width=18 bgColor=lightgrey>16</TD>
<TD width=18 bgColor=lightgrey>15</TD>
<TD width=18 bgColor=lightgrey>14</TD>
<TD width=18 bgColor=lightgrey>13</TD>
<TD width=18 bgColor=lightgrey>12</TD>
<TD width=18 bgColor=lightgrey>11</TD>
<TD width=18 bgColor=lightgrey>10</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>9</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>8</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>7</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>6</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>5</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>4</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>3</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>2</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>1</TD>
<TD width=18 bgColor=lightgrey><font color=lightgrey>0</font>0</TD>
<TD width=18 bgcolor=black></TD>
</TR>
<?php
for ($i=29; $i>=0; $i--) {
echo "<TR align=middle>\n";
echo " <TD height=14 bgColor=lightgrey>$i</TD>\n";
for ($j=29; $j>=0; $j--) {
echo " <TD bgcolor=".$CellColor[$CellTeam[$i][$j]].">";
if ($CellValue[$i][$j]>0 || $CellPlayer[$i][$j]) {
echo ($CellValue[$i][$j]>0 ? $CellValue[$i][$j] : "").$CellPlayer[$i][$j];
} else {
echo " ";
}
echo "</TD>";
// may as well count squares while we're here
$Score[substr($CellTeam[$i][$j],0,1)]++;
}
echo " <TD bgColor=lightgrey>$i</TD>\n";
echo "</TR>\n";
}
?>
<TR align=middle>
<TD height=14 bgcolor=black></TD>
<TD bgColor=lightgrey>29</TD>
<TD bgColor=lightgrey>28</TD>
<TD bgColor=lightgrey>27</TD>
<TD bgColor=lightgrey>26</TD>
<TD bgColor=lightgrey>25</TD>
<TD bgColor=lightgrey>24</TD>
<TD bgColor=lightgrey>23</TD>
<TD bgColor=lightgrey>22</TD>
<TD bgColor=lightgrey>21</TD>
<TD bgColor=lightgrey>20</TD>
<TD bgColor=lightgrey>19</TD>
<TD bgColor=lightgrey>18</TD>
<TD bgColor=lightgrey>17</TD>
<TD bgColor=lightgrey>16</TD>
<TD bgColor=lightgrey>15</TD>
<TD bgColor=lightgrey>14</TD>
<TD bgColor=lightgrey>13</TD>
<TD bgColor=lightgrey>12</TD>
<TD bgColor=lightgrey>11</TD>
<TD bgColor=lightgrey>10</TD>
<TD bgColor=lightgrey>9</TD>
<TD bgColor=lightgrey>8</TD>
<TD bgColor=lightgrey>7</TD>
<TD bgColor=lightgrey>6</TD>
<TD bgColor=lightgrey>5</TD>
<TD bgColor=lightgrey>4</TD>
<TD bgColor=lightgrey>3</TD>
<TD bgColor=lightgrey>2</TD>
<TD bgColor=lightgrey>1</TD>
<TD bgColor=lightgrey>0</TD>
<TD bgColor=black></TD>
</TR>
</TBODY>
</TABLE>
</FONT>
</td></tr>
<P>
<tr><td>
<P>
<TABLE class=mys cellSpacing=1 cellPadding=0 align=center bgColor=black border=0 frame=void>
<TBODY>
<TR align=middle>
<TD height=14 bgcolor=white><font face=arial> Newly captured </font></TD>
<TD width=18 height=14 bgcolor=#FF0099>E</TD>
<TD width=18 height=14 bgcolor=#33CC00>N</TD>
<TD width=18 height=14 bgcolor=#FFFF00>S</TD>
<TD width=18 height=14 bgcolor=#6699FF>W</TD>
</TR><TR align=middle>
<TD height=14 bgcolor=white><font face=arial> Older captures </font></TD>
<TD width=18 height=14 bgcolor=#FF99CC>E</TD>
<TD width=18 height=14 bgcolor=#99FF00>N</TD>
<TD width=18 height=14 bgcolor=#FFFF99>S</TD>
<TD width=18 height=14 bgcolor=#99CCFF>W</TD>
</TR>
<TR>
<TD height=14 bgcolor=white><font face=arial> Score </font></TD>
<?php
echo "<TD bgcolor=white align=center>".$Score["E"]."</TD>\n";
echo "<TD bgcolor=white align=center>".$Score["N"]."</TD>\n";
echo "<TD bgcolor=white align=center>".$Score["S"]."</TD>\n";
echo "<TD bgcolor=white align=center>".$Score["W"]."</TD>\n";
?>
</TR>
</TBODY>
</TABLE>
</DIV>
</td></tr></table>
</td><td><p>
<a href="movedb.php?T=<?php echo $DefTeam;?>&P=<?php echo $DefPlayer;?>">Refresh</a><br>
<p> <p>
<a href="javascript: document.MWForm.scoreboard.click();">MW Scoreboard</a><br>
<p> <p>
<a href="javascript: document.MWForm.db_search.click();">MW Recent Moves</a><br>
<p> <p>
<a href="currentevents.php?G=<?php echo $GameDataFields[0]; ?>">Current Events</a><br>
<p> <p>
<div align="left">
<table border="0" cellpadding="4" cellspacing="4" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1" bgcolor="#6699cc">
<tr>
<td>
<p align="left"><font color="#FFFFFF" face="Verdana" size="2">
An "X" after a player's initial indicates the move is stale (i.e. fractional coords don't match game board)
<br>For example, because a neutral that was visited has since been captured.
</font></td>
</tr>
</table>
</div>
</td></tr></table>