git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

user-recent-tracks.php 2.49 KB
Newer Older
1 2
<?php

3
/* GNU FM -- a free network service for sharing your music listening habits
4

5
   Copyright (C) 2009 Free Software Foundation, Inc
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

require_once('database.php');
require_once('templating.php');
Mike Sheldon's avatar
Mike Sheldon committed
24
require_once('user-menu.php');
25
require_once('data/User.php');
26
require_once('data/RemoteUser.php');
27 28 29
require_once('data/TagCloud.php');
require_once('data/Server.php');

30
if (!isset($_GET['user']) && $logged_in == false) {
31
	displayError("Error", "User not set. You shouldn't be here.");
32 33
}

34
try {
35 36 37 38 39
	if(strstr($_GET['user'], '@')) {
		$user = new RemoteUser($_GET['user']);
	} else {
		$user = new User($_GET['user']);
	}
40
} catch (Exception $e) {
Jonas Haraldsson's avatar
Jonas Haraldsson committed
41
	displayError("User not found", "User not found, shall I call in a missing persons report?");
42 43
}

44
$scrobbleCount = (int)$_GET['count'];
45
if ($scobbleCount >= 1200) {
46
	$scrobbleCount = 1200;
47
} else if (!$scrobbleCount) {
48
	$scrobbleCount = 100;
49
}
50

51 52
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
53
	$aUserScrobbles = $user->getScrobbles($scrobbleCount);
54
	$smarty->assign('scrobbles', $aUserScrobbles);
55
} catch (Exception $e) {}
56

57 58 59
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('pagetitle', $user->name . '\'s recent tracks');
60

61 62
$smarty->assign('extra_head_links', array(
		array(
63 64
			'rel'   => 'alternate',
			'type'  => 'application/rss+xml',
65
			'title' => 'RSS 1.0 Feed (Recent plays)',
66
			'href'  => $base_url . '/rdf.php?fmt=rss&page=' . rawurlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
67 68
			),
		array(
69 70
			'rel'   => 'meta',
			'type'  => 'application/rdf+xml',
71
			'title' => 'FOAF',
72
			'href'  => $base_url . '/rdf.php?fmt=xml&page=' . rawurlencode(str_replace($base_url, '', $user->getURL()))
73 74
			)
	));
clint's avatar
clint committed
75

76 77
$submenu = user_menu($user, 'Recent Tracks');
$smarty->assign('submenu', $submenu);
78

79
$smarty->display('user-recent-tracks.tpl');