<page func="Infodrom Oldenburg" title="Statistics">
<?
- $tabhead =
-'<table class="font border" width="100%">
+ define(OVERVIEW,0);
+ define(DETAILS,1);
+
+ if (isset($_GET["site"]) && isset($_GET["details"]))
+ $mode = DETAILS;
+ else
+ $mode = OVERVIEW;
+
+ $tablehead = array();
+ $tablerow = array();
+ $tablefoot = array();
+ $refcut = array();
+
+ # overview
+ $tabhead[] =
+'<table class="font height border" width="100%">
<tr bgcolor="#<colh>"><th width="10%">Count</th><th width="90%">Referer</th></tr>';
- $tabfoot = '</table>';
- $tabrow = '<tr bgcolor="#%s"><td width="10%%" align="center">%d</td><td width="90%%"><a href="%s" title="%s">%s</a></td></tr>';
+ $tabfoot[] = '</table>';
+ $tabrow[] = '<tr bgcolor="#%s"><td width="10%%" align="center">%d</td><td width="90%%"><a href="%s" title="%s">%s</a></td></tr>';
+ $refcut[] = 80;
+
+ # details
+ $tabhead[] =
+'<table class="font height border" width="100%">
+<tr bgcolor="#<colh>"><th width="15%">Date</th><th width="55%">Referer</th><th width="30%">URL</th></tr>';
+ $tabfoot[] = '</table>';
+ $tabrow[] = '<tr bgcolor="#%s"><td width="15%%">%s</td><td width="55%%"><a href="%s" title="%s">%s</a></td><td width="30%%"><a href="%s">%s</a></td></tr>';
+ $refcut[] = 55;
$dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
or die("Unable to connect to SQL server");
for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
$site = pg_fetch_array ($sth, $nr);
- printf ('<h3 class="bar"><a href="<get-var WML_SRC_BASENAME>.php?site=%d">%s</a></h3>', $site["id"], $site["name"]);
+ if (isset($_GET["details"]) && $_GET["details"] == 1)
+ printf ('<h3 class="bar">%s</h3>', $site["name"]);
+ else {
+ if (isset($_GET["site"]))
+ printf ('<h3 class="bar"><a href="<get-var WML_SRC_BASENAME>.php?site=%d&details=1">%s</a></h3>',
+ $site["id"], $site["name"]);
+ else
+ printf ('<h3 class="bar"><a href="<get-var WML_SRC_BASENAME>.php?site=%d">%s</a></h3>',
+ $site["id"], $site["name"]);
+ }
$color = "<cold>";
- echo $tabhead;
- $query = sprintf (
+ echo $tabhead[$mode];
+ if ($mode == OVERVIEW)
+ $query = sprintf (
"SELECT count(*) AS count,ref_origin.url,ref_origin.title
FROM ref_origin,ref_url,ref_log
WHERE ref_log.url = ref_url.id
AND ref_url.site = %d
GROUP BY ref_origin.url,ref_origin.title
ORDER BY count DESC", $site["id"]);
+ else
+ $query = sprintf (
+"SELECT occurrence,ref_origin.url,title,path
+ FROM ref_origin,ref_url,ref_log
+ WHERE ref_log.url = ref_url.id
+ AND ref_log.origin = ref_origin.id
+ AND ref_url.site = 1
+ ORDER BY occurrence DESC", $site["id"]);
if (!isset($_GET["site"]))
$query .= " LIMIT 10";
for ($i=0; $i < pg_NumRows ($sth2); $i++) {
$row = pg_fetch_array ($sth2, $i);
if (strlen($row["title"])) {
- $title = substr($row["title"], 0, 80);
+ $title = substr($row["title"], 0, $refcut[$mode]);
} else {
- $title = htmlentities(substr($row["url"], 0, 80));
+ $title = htmlentities(substr($row["url"], 0, $refcut[$mode]));
}
$color = $color == "<cold>"?"<coln>" : "<cold>";
- printf ($tabrow, $color, $row["count"], $row["url"], htmlentities($row["url"]), $title);
+ if ($mode == OVERVIEW)
+ printf ($tabrow[$mode], $color, $row["count"], $row["url"], htmlentities($row["url"]), $title);
+ else {
+ $date = substr($row["occurrence"], 0, 16);
+ printf ($tabrow[$mode], $color, $date, $row["url"], htmlentities($row["url"]), $title, $row["path"], $row["path"]);
+ }
}
- echo $tabfoot;
+ echo $tabfoot[$mode];
}
?>