stats.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /* GNUkebox -- a free software server for recording your listening habits
  3. Copyright (C) 2009, 2016 Free Software Foundation, Inc
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. header('Content-type: text/html; charset=utf-8');
  16. require_once('database.php');
  17. require_once('utils/human-time.php');
  18. require_once('temp-utils.php');
  19. ?>
  20. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  21. "http://www.w3.org/TR/html4/strict.dtd">
  22. <html>
  23. <head>
  24. <title>Statistics</title>
  25. </head>
  26. <body>
  27. <h1><a href="/">GNUkebox</a> Statistics</h1>
  28. <p>Please note, results are cached for approximately 9 minutes.</p>
  29. <?php
  30. $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
  31. $total = $adodb->CacheGetOne(500, 'SELECT SUM(scrobble_count) as total from User_Stats');
  32. if (!$total) {
  33. die('sql error');
  34. }
  35. echo '<p>' . stripslashes($total) . ' listens.</p>';
  36. $total = $adodb->CacheGetOne(500, 'SELECT COUNT(*) as total from Track');
  37. if (!$total) {
  38. die('sql error');
  39. }
  40. echo '<p>' . stripslashes($total) . ' unique tracks.</p>';
  41. $total = $adodb->CacheGetOne(500, 'SELECT COUNT(*) as total from Users');
  42. if (!$total) {
  43. die('sql error');
  44. }
  45. echo '<p>' . stripslashes($total) . ' users.</p>';
  46. $total = $adodb->CacheGetOne(500, 'SELECT COUNT(*) as total from User_Stats');
  47. if (!$total) {
  48. die('sql error');
  49. }
  50. echo '<p>' . stripslashes($total) . ' users active.</p>';
  51. ?>
  52. </body>
  53. </html>