top-users.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* GNUkebox -- a free software server for recording your listening habits
  3. Copyright (C) 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. require_once('version.php');
  20. $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
  21. try {
  22. $res = $adodb->CacheGetAll(300, 'select users.username, user_stats.scrobble_count from user_stats left join users on user_stats.userid=users.uniqueid order by user_stats.scrobble_count desc LIMIT 1000;');
  23. } catch (Exception $e) {
  24. die($e->getMessage());
  25. }
  26. ?>
  27. <!DOCTYPE html>
  28. <html>
  29. <head>
  30. <title>GNUkebox</title>
  31. </head>
  32. <body>
  33. <h2>Top users</h2>
  34. <ol>
  35. <?php
  36. $list = [];
  37. foreach ($res as $row) {
  38. $list []= '<li><a href=http://libre.fm/user/' . $row['username'] . '>' . $row['username'] . '</a>&mdash;' . $row['scrobble_count'] . '</li>';
  39. }
  40. echo implode('', $list);
  41. ?>
  42. </ol>
  43. <p>This server is powered by <a href="https://gitorious.org/foocorp/gnu-fm">GNU FM</a> version <?php echo $version; ?></p>
  44. </body>
  45. </html>