<?php
	include_once(dirname(__FILE__).'/../lib/functions.inc.php');
	include_once(dirname(__FILE__).'/../lib/config.inc.php');
	include_once(dirname(__FILE__).'/../lib/UrlShortener.class.php');

	$urlShortener = new UrlShortener();
	
	$linkData = $urlShortener->getStatsLinkData(1);

	echo "<" . "?xml version=\"1.0\"?".">\n";
?>
<!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>
	<title>URL Shortener - Admin</title>
	<link rel="stylesheet" href="reset.css" type="text/css" />
	<link rel="stylesheet" href="style.1.css" type="text/css" />
	<script src="../website/jquery-1.4.3.min.js" type="text/javascript"></script>
	<script src="../website/jquery.cookie.js" type="text/javascript"></script>
</head>
<body>
<div id="header" class="pagearea">
	<div class="contentblock">
		&nbsp;
	</div>
</div>
<div id="navigation" class="pagearea">
	<div class="contentblock">
		<div style="padding:20px;">
			Navigation:
			<a href="index.php" class="navlink">Overview</a>
			<a href="all-ids.php" class="navlink">All IDs</a>
			<a href="custom-ids.php" class="navlink hl">Custom IDs</a>
			<a href="normal-ids.php" class="navlink">Normal IDs</a>
		</div>
	</div>
</div>
<div id="main" class="pagearea">
	<div class="contentblock">
		<div style="padding:20px;">
<?php
	if (count($linkData) > 0) {
?>
			<div class="captioned">All links:</div>
			<table summary="all links">
				<tr>
					<th>Short ID</th>
					<th>Long link</th>
					<th>Last clicked at</th>
					<th>Number of visits</th>
				</tr>
<?php
		for ($i = 0; $i < count($linkData); $i++) {
			$oneLink = $linkData[$i];
?>
				<tr>
					<td><a href="<?= (SERVICE_BASE_URL . $oneLink['id']) ?>"><?= $oneLink['id'] ?></a></td>
					<td><?= $oneLink['url'] ?></td>
					<td><?= $oneLink['date'] ?></td>
					<td><?= $oneLink['visited'] ?></td>
				</tr>
<?php
		}
?>				
			</table>
<?php
	}
?>
		</div>
	</div>
</div>
</body>
</html>