summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/class/access.class.php13
-rw-r--r--lib/class/api.class.php1
-rw-r--r--lib/class/artist.class.php1
-rw-r--r--lib/class/update.class.php8
-rw-r--r--lib/class/xmldata.class.php63
-rw-r--r--server/xml.server.php13
6 files changed, 93 insertions, 6 deletions
diff --git a/lib/class/access.class.php b/lib/class/access.class.php
index 379ee626..f0b4fbbe 100644
--- a/lib/class/access.class.php
+++ b/lib/class/access.class.php
@@ -325,6 +325,19 @@ class Access {
// Switch on the type they pass
switch ($type) {
case 'api':
+ $key = Dba::escape($key);
+ $time = time();
+ $sql = "SELECT * FROM `session_api` WHERE `id`='$key' AND `expire` > '$time'";
+ $db_results = Dba::query($sql);
+
+ if (Dba::num_rows($db_results)) {
+ $time = $time + 3600;
+ $sql = "UPDATE `session_api` WHERE `id`='$key' SET `expire`='$time'";
+ $db_results($db_results);
+ return true;
+ }
+
+ return false;
break;
case 'stream':
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index fb0fd2f9..861b9b8d 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -36,7 +36,6 @@ class Api {
} // constructor
-
/**
* handshake
* This is the function that handles the verifying a new handshake
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index b857c7b7..7116d979 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -207,6 +207,7 @@ class Artist {
/* Combine prefix and name, trim then add ... if needed */
$name = truncate_with_ellipsis(trim($this->prefix . " " . $this->name));
$this->f_name = $name;
+ $this->f_full_name = trim($this->prefix . " " . $this->name);
// If this is a fake object, we're done here
if ($this->_fake) { return true; }
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index c51886c8..eda00d70 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -238,10 +238,9 @@ class Update {
'- Change wording on Localplay preferences.<br />';
$version[] = array('version' => '340010','description'=>$update_string);
- $update_string = '- Adjusted Tables to new democratic play methods.<br />' .
- '- Added api session table, will eventually recombine.<br />';
+ $update_string = '- Added api session table, will eventually recombine with others.<br />';
- //$version[] = array('version' => '340011','description'=>$update_string);
+ $version[] = array('version' => '340011','description'=>$update_string);
return $version;
@@ -1005,7 +1004,8 @@ class Update {
") ENGINE = MYISAM";
$db_results = Dba::query($sql);
-
+
+ self::set_version('db_version','340011');
} // 340011
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index 2fea98db..de71fbc8 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -46,11 +46,72 @@ class xmlData {
*/
public static function error($string) {
- $string = "<root>\n\t<error><![CDATA[$string]]></error>\n</root>";
+ $string = self::_header() . "\t<error><![CDATA[$string]]></error>" . self::_footer();
return $string;
} // error
+ /**
+ * artists
+ * This takes an array of artists and then returns a pretty xml document with the information
+ * we want
+ */
+ public static function artists($artists) {
+
+ foreach ($artists as $artist_id) {
+ $artist = new Artist($artist_id);
+ $artist->format();
+
+ $string .= "<artist id="$artist->id">\n" .
+ "\t<name>$artist->f_full_name</name>\n";
+ "</artist>\n";
+ } // end foreach artists
+
+ $final = self::_header() . $string . self::_footer();
+ return $final;
+
+ } // artists
+
+ /**
+ * _header
+ * this returns a standard header, there are a few types
+ * so we allow them to pass a type if they want to
+ */
+ private static function _header($type='') {
+
+ switch ($type) {
+ case 'xspf':
+
+ break;
+ case 'itunes':
+
+ break;
+ default:
+ $header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<root>\n";
+ break;
+ } // end switch
+
+ return $header;
+
+ } // _header
+
+ /**
+ * _footer
+ * this returns the footer for this document, these are pretty boring
+ */
+ private static function _footer($type='') {
+
+ switch ($type) {
+ default:
+ $footer = "\n</root>\n";
+ break;
+ } // end switch on type
+
+
+ return $footer;
+
+ } // _footer
+
} // xmlData
?>
diff --git a/server/xml.server.php b/server/xml.server.php
index 79082f43..a8e86f57 100644
--- a/server/xml.server.php
+++ b/server/xml.server.php
@@ -50,6 +50,19 @@ switch ($_REQUEST['action']) {
}
break;
+ case 'artists':
+
+ Browse::reset_filters();
+ Browse::set_type('artist');
+ Browse::set_sort('name','ASC');
+
+ if ($_REQUEST['filter']) {
+ Browse::set_filter('alpha_match',$_REQUEST['filter']);
+ }
+ $artists = Browse::get_objects();
+ // echo out the resulting xml document
+ echo xmlData::artists($artists);
+ break;
default:
// Rien a faire
break;