topical media & game development
professional-sql-09-public-files-report.php / php
<?php
include '../lib/common.php';
include '../lib/db.php';
// determine useful date values
list(full_year, num_month, short_month . ' ' . query = sprintf('
SELECT
INET_NTOA(IP_ADDRESS) AS IP_ADDRESS
FROM
\%sSITE_ACCESS SA
WHERE
DATE(ACCESS_TIME) BETWEEN
"\%d-%02d-01" AND
"\%d-%02d-01" + INTERVAL 1 MONTH - INTERVAL 1 DAY
GROUP BY
SA.IP_ADDRESS
ORDER BY
COUNT(IP_ADDRESS) DESC',
DB_TBL_PREFIX,
num_month,
num_month);
query, mo_total = mysql_num_rows(i = 0; i < i++)
{
result);
row['IP_ADDRESS'];
}
mysql_free_result(query = sprintf('
SELECT
INET_NTOA(IP_ADDRESS) AS IP_ADDRESS
FROM
\%sSITE_ACCESS
WHERE
DATE(ACCESS_TIME) BETWEEN
"\%d-01-01" AND
"\%d-01-01" + INTERVAL 1 YEAR - INTERVAL 1 DAY
GROUP BY
IP_ADDRESS
ORDER BY
COUNT(IP_ADDRESS) DESC',
DB_TBL_PREFIX,
full_year);
query, yr_total = mysql_num_rows(i = 0; i < i++)
{
result);
row['IP_ADDRESS'];
}
mysql_free_result(mo_total;?></td>
<td><?php echo mo_addrs as addr . '<br/>';?></td>
<td><?php foreach (addr) echo query = sprintf('
SELECT
REQ_PAGE, COUNT(REQ_PAGE) AS TOTAL
FROM
\%sSITE_ACCESS
WHERE
DATE(ACCESS_TIME) BETWEEN
"\%d-%02d-01" AND
"\%d-%02d-01" + INTERVAL 1 MONTH - INTERVAL 1 DAY
GROUP BY
REQ_PAGE
ORDER BY
TOTAL DESC
LIMIT 5',
DB_TBL_PREFIX,
num_month,
num_month);
query, row = mysql_fetch_assoc(mo_pages_most[] = result);
// retrieve the top 5 pages accessed during the current year
full_year,
result = mysql_query(GLOBALS['DB']);
// collect the pages from the result set
while (result))
{
row['REQ_PAGE'];
}
mysql_free_result(mo_pages_most as addr . '<br/>';?></td>
<td><?php foreach (addr) echo query = sprintf('
SELECT
REQ_PAGE, COUNT(REQ_PAGE) AS TOTAL
FROM
\%sSITE_ACCESS
WHERE
DATE(ACCESS_TIME) BETWEEN
"\%d-%02d-01" AND
"\%d-%02d-01" + INTERVAL 1 MONTH - INTERVAL 1 DAY
GROUP BY
REQ_PAGE
ORDER BY
TOTAL ASC
LIMIT 5',
DB_TBL_PREFIX,
num_month,
num_month);
query, row = mysql_fetch_assoc(mo_pages_least[] = result);
full_year,
result = mysql_query(GLOBALS['DB']);
// collect the least popular pages
while (result))
{
row['REQ_PAGE'];
}
mysql_free_result(mo_pages_least as addr . '<br/>';?></td>
<td><?php foreach (addr) echo full_year; ?></strong></p>
<p><img src="img/chart.php?month" alt="monthly traffic distribution"></p>
<p><strong>Daily Traffic Distribution for <?php echo full_year; ?></strong></p>
<p><img src="img/chart.php?day" alt="daily traffic distribution"></p>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.