<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>PiAnoS Windows Server</title>
	</head>
	<body>
		<h1>PiAnoS Windows Server</h1>
		<p><a href="index.html">Back to the home page</a></p>
		<h2>Database Diagnostics</h2>
		<p>This page is a simple tool that tests the interaction between PostgreSQL and PHP.</p>
		<div><h3>Connection test</h3><?php
$conn = pg_connect('host=localhost port=54333 dbname=postgres user=postgres');
if ($conn)
	echo '<p style="color:green">Connection is OK !</p>';
else
	echo '<p style="color:red">Connection failed !</p>';
?></div>
		<div><h3>Databases list</h3><?php
if (!$conn)
{
	echo '<p style="color:red">Previous test failed, cannot continue</p>';
}
else
{
	$res = pg_query($conn, "SELECT * FROM pg_database;");
	while ($row = pg_fetch_assoc($res))
	{
		echo '<h4>'.htmlentities($row['datname']).'</h4>';
		echo '<ul>';
		foreach ($row as $key => $value)
			echo '<li><span style="display:inline-block;width:10em;font-weight:bold">'.htmlentities($key).'</span><span>'.htmlentities($value).'</span></li>';
		echo '</ul>';
	}
}
?></div>
	</body>
</html>
