user-recent-tracks.php 2.65 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
	$smarty->assign('pageheading', 'Error!');
32 33 34 35 36
	$smarty->assign('details', 'User not set! You shouldn\'t be here!');
	$smarty->display('error.tpl');
	die();
}

37
try {
38 39 40 41 42
	if(strstr($_GET['user'], '@')) {
		$user = new RemoteUser($_GET['user']);
	} else {
		$user = new User($_GET['user']);
	}
43 44 45 46 47 48 49
} catch (Exception $e) {
	$smarty->assign('pageheading', 'User not found');
	$smarty->assign('details', 'Shall I call in a missing persons report?');
	$smarty->display('error.tpl');
	die();
}

tobyink's avatar
tobyink committed
50
$scrobbleCount = (int)$_GET['count'];
51
if ($scobbleCount >= 1200) {
52
	$scrobbleCount = 1200;
53
} else if (!$scrobbleCount) {
tobyink's avatar
tobyink committed
54
	$scrobbleCount = 100;
55
}
56

57 58
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
59
	$aUserScrobbles = $user->getScrobbles($scrobbleCount);
60
	$smarty->assign('scrobbles', $aUserScrobbles);
61
} catch (Exception $e) {}
62

63 64 65
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('pagetitle', $user->name . '\'s recent tracks');
66

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

82 83
$submenu = user_menu($user, 'Recent Tracks');
$smarty->assign('submenu', $submenu);
84

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