Longer Example
PHP Code Examples
[Download]
<?php include '../util.inc';
include 'grid.inc';

// Some odds and ends.
$dot = new point_grid(3,6, 1,5);
$colon = new point_grid(3,6, 1,2, 1,4);
$essc = new point_grid(5, 6,
	    1,0, 2,0, 3,0,
	0,1,              4,1,
	    1,2, 2,2, 3,2,
		          4,3,
	0,4,              4,4,
	    1,5, 2,5, 3,5);

$ceec = new point_grid(5, 8,
	    1,0, 2,0, 3,0,
	0,1,              4,1,
	0,2,              
	0,3,              
	0,4,              4,4,
	    1,5, 2,5, 3,5);
	

// Append the parts of an IP address.
function addip($ip)
{
	global $dot;

	$parts = explode('.', $ip);
	$ret = new grid_number(array_shift($parts));
	while(count($parts) > 0) {
		$ret->append($dot);
		$ret->append(new grid_number(array_shift($parts)));
	}

	return $ret;
}

start("The Connection");

// Client side:
echo '<p align="center">';
echo '<i>We have detect the following connection endpoints.</i>';
echo '</p><p align="center">';
$cli = new point_grid(0,0);
$cli->append($ceec);
$cli->append($colon);
$cli->append(new point_grid(1,1));
$cli->append(addip($_SERVER['REMOTE_ADDR']));
$cli->append($colon);
$cli->append(new grid_number($_SERVER['REMOTE_PORT']));

$cli->gen();
echo '</p><p align="center">';

// Server side.
$ser = new point_grid(0,0);
$ser->append($essc);
$ser->append($colon);
$ser->append(new point_grid(1,1));
$ser->append(addip($_SERVER['SERVER_ADDR']));
$ser->append($colon);
$ser->append(new grid_number($_SERVER['SERVER_PORT']));

$ser->gen();
echo "</p>";

?>
</body>
</html>