user-recent-tracks.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2009 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. require_once('database.php');
  16. require_once('templating.php');
  17. require_once('user-menu.php');
  18. require_once('data/User.php');
  19. require_once('data/RemoteUser.php');
  20. require_once('data/TagCloud.php');
  21. require_once('data/Server.php');
  22. if (!isset($_GET['user']) && $logged_in == false) {
  23. displayError("Error", "User not set. You shouldn't be here.");
  24. }
  25. try {
  26. if(strstr($_GET['user'], '@')) {
  27. $user = new RemoteUser($_GET['user']);
  28. } else {
  29. $user = new User($_GET['user']);
  30. }
  31. } catch (Exception $e) {
  32. displayError("User not found", "User not found, shall I call in a missing persons report?");
  33. }
  34. $scrobbleCount = (int)$_GET['count'];
  35. if ($scobbleCount >= 1200) {
  36. $scrobbleCount = 1200;
  37. } else if (!$scrobbleCount) {
  38. $scrobbleCount = 100;
  39. }
  40. $smarty->assign('geo', Server::getLocationDetails($user->location_uri));
  41. try {
  42. $aUserScrobbles = $user->getScrobbles($scrobbleCount);
  43. $smarty->assign('scrobbles', $aUserScrobbles);
  44. } catch (Exception $e) {}
  45. $smarty->assign('isme', ($this_user->name == $user->name));
  46. $smarty->assign('me', $user);
  47. $smarty->assign('pagetitle', $user->name . '\'s recent tracks');
  48. $smarty->assign('extra_head_links', array(
  49. array(
  50. 'rel' => 'alternate',
  51. 'type' => 'application/rss+xml',
  52. 'title' => 'RSS 1.0 Feed (Recent plays)',
  53. 'href' => $base_url . '/rdf.php?fmt=rss&page=' . rawurlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
  54. ),
  55. array(
  56. 'rel' => 'meta',
  57. 'type' => 'application/rdf+xml',
  58. 'title' => 'FOAF',
  59. 'href' => $base_url . '/rdf.php?fmt=xml&page=' . rawurlencode(str_replace($base_url, '', $user->getURL()))
  60. )
  61. ));
  62. $submenu = user_menu($user, 'Recent Tracks');
  63. $smarty->assign('submenu', $submenu);
  64. $smarty->display('user-recent-tracks.tpl');