summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-20 08:32:15 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-20 08:32:15 +0000
commit8c99cc87702cd47f62e6356be98dc874b051abe9 (patch)
treeb7139544ebe83cba68ce405691f3223055cf4316 /lib
parent5869da3fe58876644364941fa7216caee09adbf5 (diff)
downloadampache-8c99cc87702cd47f62e6356be98dc874b051abe9.tar.gz
ampache-8c99cc87702cd47f62e6356be98dc874b051abe9.tar.bz2
ampache-8c99cc87702cd47f62e6356be98dc874b051abe9.zip
added genres as a new xml method, and improved logging
Diffstat (limited to 'lib')
-rw-r--r--lib/class/api.class.php6
-rw-r--r--lib/class/xmldata.class.php33
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index 29bc0bff..1ebc86e8 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -58,6 +58,9 @@ class Api {
$user_id = Dba::escape($user_id);
$timestamp = intval($timestamp);
$ip = ip2int($ip);
+
+ // Log this attempt
+ debug_event('API','Login Attempt, IP:' . int2ip($ip) . ' Time:' . $timestamp . ' User:' . $user_id . ' Auth:' . $passphrase,'1');
// Run the query and return the passphrases as we'll have to mangle them
// to figure out if they match what we've got
@@ -72,11 +75,14 @@ class Api {
if ($md5pass === $passphrase) {
// Create the Session, in this class for now needs to be moved
$token = self::create_session($row['level'],$ip,$user_id);
+ debug_event('API','Login Success, passphrase matched','1');
return $token;
} // match
} // end while
+ debug_event('API','Login Failed, unable to match passphrase','1');
+
} // handhsake
/**
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index 655a65f3..ba1bec3f 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -133,6 +133,39 @@ class xmlData {
} // albums
/**
+ * genres
+ * This takes an array of genre ids and returns a nice little pretty xml doc
+ */
+ public static function genres($genres) {
+
+ if (count($genres) > self::$limit) {
+ $genres = array_slice($genres,0,self::$limit);
+ }
+
+ // Foreach the ids
+ foreach ($genres as $genre_id) {
+ $genre = new Genre($genre_id);
+ $genre->format();
+ $song_count = $genre->get_song_count();
+ $album_count = $genre->get_album_count();
+ $artist_count = $genre->get_artist_count();
+
+ $string .= "<genre id=\"$genre->id\">\n" .
+ "\t<name><![CDATA[$genre->name]]></name>\n" .
+ "\t<songs>$song_count</songs>\n" .
+ "\t<albums>$album_count</albums>\n" .
+ "\t<artists>$artist_count</artists>\n" .
+ "</genre>\n";
+
+ } // end foreach
+
+ $final = self::_header() . $string . self::_footer();
+
+ return $final;
+
+ } // genres
+
+ /**
* _header
* this returns a standard header, there are a few types
* so we allow them to pass a type if they want to