Index: trunk/tools/counter/display/dbconfig.php |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +// Use something nicer ;) |
| 5 | +define('STATS_DB', 'counter'); |
| 6 | +define('STATS_DB_HOST', 'localhost'); |
| 7 | +define('STATS_DB_USER', 'root'); |
| 8 | +define('STATS_DB_PASS', ''); |
| 9 | + |
| 10 | +define('STATS_DB_DEBUG', true); |
| 11 | + |
| 12 | +?> |
\ No newline at end of file |
Property changes on: trunk/tools/counter/display/dbconfig.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 13 | + native |
Index: trunk/tools/counter/display/index.php |
— | — | @@ -0,0 +1,66 @@ |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<title>Group counter -- experimental</title> |
| 5 | +<meta name="robots" content="noindex,nofollow"> |
| 6 | +</head> |
| 7 | +<body> |
| 8 | +<h1>Group counter -- experimental</h1> |
| 9 | +<?php |
| 10 | +ini_set('display_errors', 0); |
| 11 | + |
| 12 | +require './dbconfig.php'; |
| 13 | + |
| 14 | +if (STATS_DB_DEBUG) { |
| 15 | + ini_set('display_errors', 1); |
| 16 | + error_reporting(E_ALL); |
| 17 | +} |
| 18 | + |
| 19 | +function debugError($message) { |
| 20 | + if (STATS_DB_DEBUG) { |
| 21 | + $error = mysql_error(); |
| 22 | + if ($error) { |
| 23 | + $message .= ' - ' . $error; |
| 24 | + } |
| 25 | + print "<p>" . htmlspecialchars($message) . "</p>"; |
| 26 | + } |
| 27 | + return false; |
| 28 | +} |
| 29 | + |
| 30 | +function doit() { |
| 31 | + $conn = mysql_connect(STATS_DB_HOST, STATS_DB_USER, STATS_DB_PASS); |
| 32 | + if ($conn === false) { |
| 33 | + return debugError('Failed to connect.'); |
| 34 | + } |
| 35 | + $ok = mysql_select_db(STATS_DB); |
| 36 | + if (!$ok) { |
| 37 | + return debugError('Failed to select database.'); |
| 38 | + } |
| 39 | + |
| 40 | + $res = mysql_query('SELECT hc_site, hc_page, COUNT(*) AS hc_count FROM hit_counter GROUP BY hc_site, hc_page ORDER BY hc_site, hc_page'); |
| 41 | + if ($res === false) { |
| 42 | + return debugError('Query failed.'); |
| 43 | + } |
| 44 | + print "<table border=\"1\">\n"; |
| 45 | + print "<tr><th>Hits to date</th><th>Site</th><th>Page</th></tr>\n"; |
| 46 | + while ($row = mysql_fetch_object($res)) { |
| 47 | + $url = 'http://' . $row->hc_site . '/wiki/' . |
| 48 | + urlencode(str_replace(' ', '_', $row->hc_page)); |
| 49 | + |
| 50 | + $encCount = htmlspecialchars(number_format($row->hc_count)); |
| 51 | + $encSite = htmlspecialchars($row->hc_site); |
| 52 | + $encPage = htmlspecialchars($row->hc_page); |
| 53 | + $encUrl = htmlspecialchars($url); |
| 54 | + |
| 55 | + print "<tr><td>$encCount</td><td>$encSite</td><td><a href=\"$encUrl\">$encPage</a></td></tr>\n"; |
| 56 | + } |
| 57 | + print "</table>\n"; |
| 58 | + return true; |
| 59 | +} |
| 60 | + |
| 61 | +if (!doit()) { |
| 62 | + print "<p>Error retrieving stats from database.</p>\n"; |
| 63 | +} |
| 64 | + |
| 65 | +?> |
| 66 | +</body> |
| 67 | +</html> |
\ No newline at end of file |
Property changes on: trunk/tools/counter/display/index.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 68 | + native |