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

Commit 8831ef79 authored by clint's avatar clint

whitespace

parent fb8315ad
......@@ -25,12 +25,12 @@ require_once('xml.php');
class UserXML {
public static function getInfo($username) {
$user = new User($username);
if (PEAR::isError($user)) {
return(XML::error('failed', '7', 'Invalid resource specified'));
}
$xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
$user_node = $xml->addChild('user', null);
$user_node->addChild('name', $user->name);
......@@ -41,15 +41,15 @@ class UserXML {
$user_node->addChild('profile_created', strftime('%c', $user->created));
if (isset($user->modified))
$user_node->addChild('profile_updated', strftime('%c', $user->modified));
return($xml);
}
public static function getTopTracks($username, $time) {
global $mdb2;
$timestamp;
if (!isset($time))
if (!isset($time))
$time = 'overall';
//TODO: Do better, this is too ugly :\
if (strcmp($time, 'overall') == 0) {
......@@ -65,24 +65,24 @@ class UserXML {
} else {
return(XML::error('error', '13', 'Invalid method signature supplied'));
}
$res = $mdb2->query('SELECT Track.*, Artist.mbid AS artmbid, COUNT(*) AS freq
FROM Track, Scrobbles,Artist
$res = $mdb2->query('SELECT Track.*, Artist.mbid AS artmbid, COUNT(*) AS freq
FROM Track, Scrobbles,Artist
WHERE Scrobbles.username = ' . $mdb2->quote($username, 'text') . '
AND Scrobbles.track = Track.name AND Scrobbles.time > ' . $timestamp . ' AND Track.artist = Artist.name
AND Scrobbles.track = Track.name AND Scrobbles.time > ' . $timestamp . ' AND Track.artist = Artist.name
GROUP BY Track.name ORDER BY freq DESC LIMIT 20');
if (PEAR::isError($res) || !$res->numRows()) {
return(XML::error('failed', '7', 'Invalid resource specified'));
}
}
$xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
$root = $xml->addChild('toptracks', null);
$root->addAttribute('user', $username);
$root->addAttribute('type', $time);
$i = 1;
while(($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
$track = $root->addChild('track', null);
$track->addAttribute('rank', $i);
$track->addChild('name', repamp($row['name']));
......@@ -94,39 +94,39 @@ class UserXML {
}
return($xml);
}
public static function getRecentTracks($user, $limit) {
global $mdb2;
if (!isset($limit)) {
$limit = 10;
}
$res = $mdb2->query('SELECT Track . * , COUNT( * ) AS freq
FROM Track, Scrobbles
WHERE Scrobbles.username = ' . $mdb2->quote($user, 'text') . '
AND Scrobbles.track = Track.name
GROUP BY Track.name
LIMIT 10');
if (PEAR::isError($res) || !$res->numRows()) {
if (PEAR::isError($res) || !$res->numRows()) {
return(XML::error('error', '7', 'Invalid resource specified'));
}
$xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
$root = $xml->addChild('recenttracks', null);
$root->addAttribute('user', $user);
while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
$track = $root->addChild('track', null);
$artist = $track->addChild('artist', repamp($row['artist']));
$artist->addAttribute('mbid', $row['artmbid']);
$track->addChild('name', repamp($row['name']));
}
return($xml);
}
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment