We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

user-stats.php 2.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?php

/* Libre.fm -- a free network service for sharing your music listening habits

   Copyright (C) 2009 Libre.fm Project

   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');
require_once('data/User.php');
require_once('data/TagCloud.php');
26
require_once('data/Statistic.php');
27 28 29 30 31 32 33 34 35 36 37

if(!isset($_GET['user']) && $logged_in == false) {
	$smarty->assign('error', 'Error!');
	$smarty->assign('details', 'User not set! You shouldn\'t be here!');
	$smarty->display('error.tpl');
	die();
}

$user = new User($_GET['user']);

if(isset($user->name)) {
38

39
#	$aUserTagCloud =  TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
40 41 42
#	if (!PEAR::isError ($aUserTagCloud)) {
#		$smarty->assign('user_tagcloud',$aUserTagCloud);
#	}
clint's avatar
clint committed
43

idflood's avatar
idflood committed
44
	$smarty->assign('stat_barwidth', 320);
45
	$aUserPlayStat =  Statistic::GeneratePlayStats('Scrobbles', 'artist', 40, $user->name, 300);
46 47 48
	if (!PEAR::isError ($aUserPlayStat)) {
		$smarty->assign('user_playstats',$aUserPlayStat);
	}
clint's avatar
clint committed
49

50
	$aUserDayStat =  Statistic::generatePlayByDays('Scrobbles', 40, $user->name, 300);
idflood's avatar
idflood committed
51 52 53
	if (!PEAR::isError ($aUserDayStat)) {
		$smarty->assign('user_daystats',$aUserDayStat);
	}
54

55
	$smarty->assign('toptracks', $user->getTopTracks(40));
clint's avatar
clint committed
56

57 58
	$smarty->assign('me', $user);
	$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
59
	$smarty->assign('isme', ($this_user->name == $user->name));
60 61 62 63 64 65

	$smarty->assign('extra_head_links', array(
			array(
				'rel' => 'meta',
				'type' => 'application/rdf+xml' ,
				'title' => 'FOAF',
66
				'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
67 68
				)
		));
clint's avatar
clint committed
69

70
	$smarty->assign('stats', true);
71
	$smarty->display('user-stats.tpl');
72 73 74 75 76 77 78
} else {
	$smarty->assign('error', 'User not found');
	$smarty->assign('details', 'Shall I call in a missing persons report?');
	$smarty->display('error.tpl');
}

?>