diff options
| author | czaks <marcin@6irc.net> | 2014-01-31 23:38:29 +0100 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2014-01-31 23:38:29 +0100 |
| commit | c29f1a3db70b8be01ec60a2028d156d236e27c02 (patch) | |
| tree | b497fd768dc63d090d077d918d28f1b7e6786bda | |
| parent | 87677f7ed4d33ae1dd2ac219f06e284e1d10f8ad (diff) | |
add a basic stats CLI util
| -rwxr-xr-x | tools/stats.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/stats.php b/tools/stats.php new file mode 100755 index 00000000..438d9c8f --- /dev/null +++ b/tools/stats.php @@ -0,0 +1,30 @@ +<?php +require dirname(__FILE__) . '/inc/cli.php'; + +if(!is_writable($config['file_script'])) { + get_httpd_privileges(); +} + +$variants = [["hour", 3600], ["day", 3600*24], ["3 days", 3600*24*3], + ["week", 3600*24*7], ["month", 3600*24*7*30]]; + +printf(" || "); +foreach ($variants as list($term, $time)) { + printf("%8s | ", $term); +} +print("\n"); +print(str_repeat('=', 13+11*count($variants))); +print("\n"); + + +$q = query("SELECT uri FROM ``boards``"); +while ($f = $q->fetch()) { + printf("%10s || ", $f['uri']); + foreach ($variants as list($term, $time)) { + $qq = query(sprintf("SELECT COUNT(*) as count FROM ``posts_%s`` WHERE time > %d", $f['uri'], time()-$time); + $c = $qq->fetch()['count']; + + printf("%8d | ", $c); + } + print("\n"); +} |
