urlshortener/admin/index.php

96 lines
2.7 KiB
PHP

<?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();
$countByType = $urlShortener->getStatsCountByType();
$lastTenActive = $urlShortener->getStatsListActiveLinks(10);
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 hl">Overview</a>
<a href="all-ids.php" class="navlink">All IDs</a>
<a href="custom-ids.php" class="navlink">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 ($countByType != NULL) {
?>
<div class="captioned">Number of links:</div>
<table summary="number of links">
<tr>
<td class="right">Number of links with <b>normal</b> short id:</td>
<td><b><?= $countByType[0]['cnt'] ?></b></td>
</tr>
<tr>
<td class="right">Number of links with <b>custom</b> short id:</td>
<td><b><?= $countByType[1]['cnt'] ?></b></td>
</tr>
<tr>
<td class="right"><b>Total</b> number of links:</td>
<td><b><?= ($countByType[0]['cnt'] + $countByType[1]['cnt']) ?></b></td>
</tr>
</table>
<?php
}
if (count($lastTenActive) > 0) {
?>
<div class="captioned">Last 10 active links:</div>
<table summary="last ten active links">
<tr>
<th>#</th>
<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($lastTenActive); $i++) {
$oneLink = $lastTenActive[$i];
?>
<tr>
<td><?= $i ?></td>
<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>