1 #include <infodrom.style>
3 <page func="Infodrom Oldenburg" title="Statistics">
10 if (isset($_GET["site"]) && isset($_GET["details"]))
12 elseif (isset($_GET["referer"]))
24 '<table class="font height border" width="100%" cellspacing="0">
25 <tr bgcolor="#<colh>"><th width="10%">Count</th><th width="90%">URLs</th></tr>';
26 $tabfoot[] = '</table>';
27 $tabrow[] = '<tr bgcolor="#%s"><td width="10%%" align="center">%d</td><td width="90%%"><a href="<get-var WML_SRC_BASENAME>.php?site=%d&details=1&url=%d">http://%s%s</a></td></tr>';
32 '<table class="font height border" width="100%" cellspacing="0">
33 <tr bgcolor="#<colh>"><th width="10%">Count</th><th width="90%">Referer</th></tr>';
34 $tabfoot[] = '</table>';
35 $tabrow[] = '<tr bgcolor="#%s"><td width="10%%" align="center">%d</td><td width="90%%"><a href="<get-var WML_SRC_BASENAME>.php?site=%d&details=1&origin=%d" title="%s">%s</a></td></tr>';
40 '<table class="font height border" width="100%" cellspacing="0">
41 <tr bgcolor="#<colh>"><th width="16%">Date</th><th width="54%">Referer</th><th width="30%">URL</th></tr>';
42 $tabfoot[] = '</table>';
43 $tabrow[] = '<tr bgcolor="#%s"><td width="16%%">%s</td><td width="54%%"><a href="%s" title="%s">%s</a></td><td width="30%%"><a href="%s">%s</a></td></tr>';
46 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
47 or die("Unable to connect to SQL server");
50 $query = "SELECT id,name FROM ref_site ";
51 if (isset($_GET["site"]))
52 $query .= sprintf("WHERE id = %d ", $_GET["site"]);
53 $query .= "ORDER BY name";
54 $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
56 for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
57 $site = pg_fetch_array ($sth, $nr);
58 if (isset($_GET["details"]) && $_GET["details"] == 1)
59 printf ('<h3 class="bar">%s</h3>', $site["name"]);
60 elseif (isset($_GET["referer"]) && !isset($_GET["site"]))
61 printf ('<h3 class="bar"><a href="<get-var WML_SRC_BASENAME>.php?referer=1&site=%d">%s</a></h3>',
62 $site["id"], $site["name"]);
63 elseif (isset($_GET["site"]))
64 printf ('<h3 class="bar"><a href="<get-var WML_SRC_BASENAME>.php?site=%d&details=1">%s</a></h3>',
65 $site["id"], $site["name"]);
67 printf ('<h3 class="bar"><a href="<get-var WML_SRC_BASENAME>.php?site=%d">%s</a></h3>',
68 $site["id"], $site["name"]);
72 if ($mode == OVERVIEW)
74 "SELECT count(*) AS count,ref_log.url,ref_url.path
76 WHERE ref_log.url = ref_url.id
78 GROUP BY ref_log.url,path
79 ORDER BY count DESC,path", $site["id"]);
80 elseif ($mode == REFERER)
82 "SELECT count(*) AS count,ref_origin.url,ref_origin.title,origin
83 FROM ref_origin,ref_url,ref_log
84 WHERE ref_log.url = ref_url.id
85 AND ref_log.origin = ref_origin.id
87 GROUP BY ref_origin.url,title,origin
88 ORDER BY count DESC,title", $site["id"]);
91 "SELECT occurrence,ref_origin.url,title,path,ref_log.url AS urlid
92 FROM ref_origin,ref_url,ref_log
93 WHERE ref_log.url = ref_url.id
94 AND ref_log.origin = ref_origin.id
95 AND ref_url.site = %d", $site["id"]);
97 if (isset($_GET[origin]))
98 $query .= sprintf(" AND origin = %d", $_GET[origin]);
99 if (isset($_GET[url]))
100 $query .= sprintf(" AND ref_log.url = %d", $_GET[url]);
101 $query .= " ORDER BY occurrence DESC";
104 if (!isset($_GET["site"]))
105 $query .= " LIMIT 10";
107 $sth2 = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
108 for ($i=0; $i < pg_NumRows ($sth2); $i++) {
109 $row = pg_fetch_array ($sth2, $i);
110 if (strlen($row["title"])) {
111 $title = substr($row["title"], 0, $refcut[$mode]);
113 $title = htmlentities(substr($row["url"], 0, $refcut[$mode]));
116 $color = $color == "<cold>"?"<coln>" : "<cold>";
117 if ($mode == OVERVIEW)
118 printf ($tabrow[$mode], $color, $row["count"], $site["id"], $row["url"],
119 $site["name"], htmlentities($row["path"]));
120 elseif ($mode == REFERER)
121 printf ($tabrow[$mode], $color, $row["count"], $site["id"], $row["origin"],
122 htmlentities($row["url"]), $title);
124 $date = substr($row["occurrence"], 0, 16);
125 if (isset($_GET["url"]))
126 $url = sprintf("http://%s%s", $site["name"], $row["path"]);
128 $url = sprintf("<get-var WML_SRC_BASENAME>.php?site=%d&details=1&url=%d", $site["id"], $row["urlid"]);
129 printf ($tabrow[$mode], $color, $date, $row["url"], htmlentities($row["url"]), $title, $url, $row["path"]);
132 echo $tabfoot[$mode];
136 <div style="padding-top: 1em"></div>