track.php 1.92 KB
Newer Older
jurgbohn's avatar
jurgbohn committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?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/>.

*/

clint's avatar
clint committed
22 23 24 25 26
require_once('database.php');
require_once('templating.php');
require_once('data/sanitize.php');
require_once('data/Server.php');
require_once('data/TagCloud.php');
jurgbohn's avatar
jurgbohn committed
27

jurgbohn's avatar
jurgbohn committed
28
$track = new Track(urldecode($_GET['track']), urldecode($_GET['artist']));
29
$smarty->assign("track", $track);
jurgbohn's avatar
jurgbohn committed
30

31 32
$album = new Album($track->album_name, $track->artist_name);
$smarty->assign("album", $album);
clint's avatar
clint committed
33

34 35
$artist = new Artist($track->artist_name);
$smarty->assign("artist", $artist);
jurgbohn's avatar
jurgbohn committed
36

clint's avatar
clint committed
37
// no idea how this would be track-relevant
38
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
clint's avatar
clint committed
39 40 41 42
if (!PEAR::isError ($aTagCloud)) {
        $smarty->assign('tagcloud', $aTagCloud);
}

43
$res = $mdb2->query("SELECT * FROM Track WHERE lower(artist) = " . $mdb2->quote(mb_strtolower($track->artist_name, "UTF-8"),"text") . " AND lower(name) = " . $mdb2->quote(mb_strtolower($track->name, "UTF-8"),"text"));
clint's avatar
clint committed
44

clint's avatar
clint committed
45
$aOtheralbums = array();
46
$i = 0;
clint's avatar
clint committed
47

48 49
while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
	$trow = sanitize($row);
jurgbohn's avatar
jurgbohn committed
50
	if ($trow["album"]) {
51
		$aOtherAlbums[$i++] = new Album($trow["album"], $trow["artist"]);
52
	}
53
}
clint's avatar
clint committed
54

55
$smarty->assign("albums", $aOtherAlbums);
clint's avatar
clint committed
56

jurgbohn's avatar
jurgbohn committed
57
$smarty->display("track.tpl");
jurgbohn's avatar
jurgbohn committed
58
?>