diff options
author | dipsol <dipsol@ampache> | 2008-12-11 15:21:07 +0000 |
---|---|---|
committer | dipsol <dipsol@ampache> | 2008-12-11 15:21:07 +0000 |
commit | e415574302f507405c85daf96e050e07ce54d5cc (patch) | |
tree | cca1097a9497a4da505766b8fba23784b326b878 /lib/class/xmlrpcserver.class.php | |
parent | efa0fda4ff3133e15c79489e49258247182e3c50 (diff) | |
download | ampache-e415574302f507405c85daf96e050e07ce54d5cc.tar.gz ampache-e415574302f507405c85daf96e050e07ce54d5cc.tar.bz2 ampache-e415574302f507405c85daf96e050e07ce54d5cc.zip |
When updating an remote catalog it will try to grab the images from the remote machine to the local database.
Diffstat (limited to 'lib/class/xmlrpcserver.class.php')
-rw-r--r-- | lib/class/xmlrpcserver.class.php | 83 |
1 files changed, 60 insertions, 23 deletions
diff --git a/lib/class/xmlrpcserver.class.php b/lib/class/xmlrpcserver.class.php index a5687c21..1d66dfd2 100644 --- a/lib/class/xmlrpcserver.class.php +++ b/lib/class/xmlrpcserver.class.php @@ -68,6 +68,8 @@ class xmlRpcServer { return new XML_RPC_Response($encoded_array); } // get_catalogs + + /** * get_songs * This is a basic function to return all of the song data in a serialized format. It takes a start and end point @@ -80,15 +82,15 @@ class xmlRpcServer { set_time_limit(0); - // Pull out the key - $variable = $xmlrpc_object->getParam(0); - $key = $variable->scalarval(); - - // Check it and make sure we're super green - if (!vauth::session_exists('xml-rpc',$key)) { - debug_event('XMLSERVER','Error ' . $_SERVER['REMOTE_ADDR'] . ' with key ' . $key . ' does not match any ACLs','1'); - return new XML_RPC_Response(0,'503','Key/IP Mis-match Access Denied'); - } + // Pull out the key + $variable = $xmlrpc_object->getParam(0); + $key = $variable->scalarval(); + + // Check it and make sure we're super green + if (!vauth::session_exists('xml-rpc',$key)) { + debug_event('XMLSERVER','Error ' . $_SERVER['REMOTE_ADDR'] . ' with key ' . $key . ' does not match any ACLs','1'); + return new XML_RPC_Response(0,'503','Key/IP Mis-match Access Denied'); + } // Now pull out the start and end $start = intval($xmlrpc_object->params['1']->me['int']); @@ -126,20 +128,60 @@ class xmlRpcServer { } // get_songs /** + * get_album_images + * Returns the images information of the albums + */ + public static function get_album_images($xmlrpc_object) { + // We're going to be here a while + set_time_limit(0); + + // Pull out the key + $variable = $xmlrpc_object->getParam(0); + $key = $variable->scalarval(); + + // Check it and make sure we're super green + if (!vauth::session_exists('xml-rpc',$key)) { + debug_event('XMLSERVER','Error ' . $_SERVER['REMOTE_ADDR'] . ' with key ' . $key . ' does not match any ACLs','1'); + return new XML_RPC_Response(0,'503','Key/IP Mis-match Access Denied'); + } + + // Get Albums first + $sql = "SELECT `album`.`id` FROM `album` "; + $db_results = Dba::query($sql); + + while ($row = Dba::fetch_assoc($db_results)) { + // Load the current album + $album = new Album($row['id']); + $art = $album->get_db_art(); + + // Only return album ids with art + if (count($art) != 0) { + $output = serialize($album); + $results[] = $output; + } + } + + $encoded_array = XML_RPC_encode($results); + debug_event('XMLSERVER','Encoded ' . count($results) . 'albums with art','5'); + + return new XML_RPC_Response($encoded_array); + } + + /** * create_stream_session * This creates a new stream session and returns the SID in question, this requires a TOKEN as generated by the handshake */ public static function create_stream_session($xmlrpc_object) { - // Pull out the key - $variable = $xmlrpc_object->getParam(0); - $key = $variable->scalarval(); + // Pull out the key + $variable = $xmlrpc_object->getParam(0); + $key = $variable->scalarval(); - // Check it and make sure we're super green - if (!vauth::session_exists('xml-rpc',$key)) { - debug_event('XMLSERVER','Error ' . $_SERVER['REMOTE_ADDR'] . ' with key ' . $key . ' does not match any ACLs','1'); - return new XML_RPC_Response(0,'503','Key/IP Mis-match Access Denied'); - } + // Check it and make sure we're super green + if (!vauth::session_exists('xml-rpc',$key)) { + debug_event('XMLSERVER','Error ' . $_SERVER['REMOTE_ADDR'] . ' with key ' . $key . ' does not match any ACLs','1'); + return new XML_RPC_Response(0,'503','Key/IP Mis-match Access Denied'); + } if (!Stream::insert_session($key,'-1')) { debug_event('XMLSERVER','Failed to create stream session','1'); @@ -155,12 +197,7 @@ class xmlRpcServer { * used in all further communication */ public static function handshake($xmlrpc_object) { - /* - ob_start(); - print_r ($xmlrpc_object); - $got = ob_get_clean(); - debug_event('XMLSERVER','handshake: ' . $got,'1'); - */ + debug_event('XMLSERVER','handshake: ' . print_r ($xmlrpc_object, true),'5'); // Pull out the params $encoded_key = $xmlrpc_object->params['0']->me['string']; |