Location: PHPKode > scripts > Mine Checker > mine-checker/example_en.php
<?php
require('minechecker.php');
session_start();

$minechecker = new minechecker();

if (isset($_GET['new'])) {session_unset('area');}

if (!isset($_SESSION['area']))
{
	$minechecker->newarea(10, 5, 5);
	$_SESSION['area'] = $minechecker->area;
}
else
{
	$minechecker->loadarea($_SESSION['area']);

	if (isset($_GET['x']) && isset($_GET['y']))
	{
			if (isset($_GET['flag'])) $minechecker->flagarea($_GET['x'], $_GET['y']);
			else $minechecker->openarea($_GET['x'], $_GET['y']);
			$_SESSION['area'] = $minechecker->area;
			if ($minechecker->status) {session_unset('area');}
	}

	if (isset($_GET['check'])) {$minechecker->wincheck();}
}
?>
<style type="text/css">
a {font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color:#00F;}
a:hover {color:#00FF00;}
.info {font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; border: 1px solid #000;}
.area {border-collapse:collapse;}
.opened {width:25px; height:25px; border:1px solid #000; background-color:#FFF; text-align:center;}
.closed {width:25px; height:25px; border:1px solid #000; background-color:#999; text-align:center;}
.flaged {width:25px; height:25px; border:1px solid #000; background-color:#F00; text-align:center;}
.mined {width:25px; height:25px; border:1px solid #000; background-color:#000; text-align:center;}
.light {background-color:#FC3; text-align:center;}
</style>
<script language="javascript">
var $clicked = <?=$minechecker->status;?>;

function light($ref, $color)
{
	if ($color) $ref.className = 'light';
	else $ref.className = 'closed';
}
function openarea($x, $y)
{
	if (!$clicked)
	{
		$clicked = -1;
		document.location.href = 'example_en.php?x=' + $x + '&y=' + $y;
		return false;
	}
	return false;
}
function flagarea($x, $y)
{
	if (!$clicked)
	{
		$clicked = -1;
		document.location.href = 'example_en.php?flag=-1&x=' + $x + '&y=' + $y;
		return false;
	}
	return false;
}
function noright()
{
	return false;
}
</script>
<a href="example_en.php?new">New Game</a> <a href="example_en.php?check">Win Check<br></a>
<br>
<?=($minechecker->status == 1) ? '<font color="#FF0000">You Win</font><br><br>' : '';?>
<?=($minechecker->status == -1) ? '<font color="#FF0000">You Loose</font><br><br>' : '';?>
<table class="area">
<?php for ($i = 1; $i <= $minechecker->height; $i++) { ?>
<tr>
<?php for ($j = 1; $j <= $minechecker->width; $j++) { ?>
<td class="closed"><?=$minechecker->area[$i][$j];?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
<br>
<table class="area">
<?php for ($i = 1; $i <= $minechecker->height; $i++) { ?>
<tr>
<?php for ($j = 1; $j <= $minechecker->width; $j++) { ?>
<?php if ($minechecker->area[$i][$j] < 0) { ?>
<td class="<?=(abs($minechecker->area[$i][$j] % 10) == 9) ? 'mined' : 'opened';?>" oncontextmenu="return noright();"><?=abs($minechecker->area[$i][$j] % 10);?></td>
<?php } elseif ($minechecker->area[$i][$j] >= 10) { ?>
<td class="flaged" oncontextmenu="return flagarea(<?=$j;?>, <?=$i;?>);"></td>
<?php } else { ?>
<td class="closed" onMouseOver="light(this, -1);" onMouseOut="light(this, 0);" onClick="return openarea(<?=$j;?>, <?=$i;?>);" oncontextmenu="return flagarea(<?=$j;?>, <?=$i;?>);"></td>
<?php } ?>
<?php } ?>
</tr>
<?php } ?>
</table>
<br>
<table class="info">
<tr><td>0:</td><td>Closed</td><td>Box with no bombs around.</td></tr>
<tr><td>1 to 8:</td><td>Closed</td><td>Number of bombs around the box.</td></tr>
<tr><td>9:</td><td>Closed</td><td>Mine box</td></tr>
<tr><td colspan="3" style="border-top:1px solid #000;">&nbsp;</td></tr>
<tr><td>-10:</td><td>Opened</td><td>Box with no bombs around.</td></tr>
<tr><td>-1 to -8:</td><td>Opened</td><td>Number of bombs around the box.</td></tr>
<tr><td>-9:</td><td>Opened</td><td>Mine box</td></tr>
<tr><td colspan="3" style="border-top:1px solid #000;">&nbsp;</td></tr>
<tr><td>100:</td><td>Flaged</td><td>Box with no bombs around.</td></tr>
<tr><td>10 to 80:</td><td>Flaged</td><td>Number of bombs around the box.</td></tr>
<tr><td>90:</td><td>Flaged</td><td>Mine box</td></tr>
<tr><td colspan="3" style="border-top:1px solid #000;">&nbsp;</td></tr>
<tr><td colspan="2">Left Click:</td><td>Open box</td></tr>
<tr><td colspan="2">Right Click:</td><td>Flag / UnFlag box</td></tr>
</table>
Return current item: Mine Checker