diff --git a/docs/CHANGELOG b/docs/CHANGELOG index d876b3a0..d529f30a 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.4-Alpha4 + - Fixed XML-RPC, now uses handshake method properly - Fixed bug where stream would start even with no songs - Upgraded to Prototype 1.6 - Added playlists and playlist_songs methods to API diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index d0388477..6c93e549 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1274,40 +1274,57 @@ class Catalog { else { $client = new xmlrpc_client("/$path/server/xmlrpc.server.php", $server, 80); } - - /* encode the variables we need to send over */ - $encoded_key = new xmlrpcval($this->key,"string"); - $encoded_path = new xmlrpcval(Config::get('web_path'),"string"); - - $xmlrpc_message = new xmlrpcmsg('xmlrpcserver.get_catalogs', array($encoded_key,$encoded_path)); - + // 6 that's right, the secret level because if you do have debug on most likely you're // going to just crash your browser... sorry folks if (Config::get('debug') AND Config::get('debug_level') == '6') { $client->setDebug(1); } - - $response = $client->send($xmlrpc_message,30); - $value = $response->value(); - if ( !$response->faultCode() ) { - $data = php_xmlrpc_decode($value); + // Before we do anything else we need to do a handshake with the remote server + $timestamp = time(); + $handshake_key = md5($timestamp . $this->key); + + $encoded_key = new xmlrpcval($handshake_key,"string"); + $timestamp = new xmlrpcval($timestamp,"int"); + $xmlrpc_message = new xmlrpcmsg('xmlrpcserver.handshake',array($encoded_key,$timestamp)); + + // Send it off + $response = $client->send($xmlrpc_message,10); + if ($response->faultCode()) { + $error_msg = _("Error connecting to") . " " . $server . " " . _("Code") . ": " . $response->faultCode() . " " . _("Reason") . ": " . $response->faultString(); + debug_event('XMLCLIENT',$error_msg,'1'); + echo "
$error_msg
"; + return; + } - // Print out the catalogs we are going to sync - foreach ($data as $vars) { - $catalog_name = $vars['name']; - $count = $vars['count']; - print("Reading Remote Catalog: $catalog_name ($count Songs) [$this->path]$error_msg
"; return; - } + } + + + $data = php_xmlrpc_decode($response->value()); + + // Print out the catalogs we are going to sync + foreach ($data as $vars) { + $catalog_name = $vars['name']; + $count = $vars['count']; + print("Reading Remote Catalog: $catalog_name ($count Songs) [$this->path]" . _('Completed updating remote catalog(s)') . ".
\n---SENDING---\n" . htmlentities($op) . "\n---END---\n"; - // let the client see this now in case http times out... + debug_event('XMLRPC',"\n---SENDING---\n" . htmlentities($op) . "\n---END---\n",'1','xmlrpc'); flush(); } @@ -1458,11 +1457,8 @@ $cp1252_to_xmlent = $encoding_hdr = ''; } - if($this->debug > 1) - { - print "
\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n"; - // let the client see this now in case http times out... - flush(); + if($this->debug > 1) { + debug_event('XMLRPC',"\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n",'1','xmlrpc'); } if(!$keepalive || !$this->xmlrpc_curl_handle) @@ -2338,18 +2334,17 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha $data = substr($data, $bd); - if($this->debug && count($GLOBALS['_xh']['headers'])) - { - print '
'; - foreach($GLOBALS['_xh']['headers'] as $header => $value) - { - print htmlentities("HEADER: $header: $value\n"); + // If we're debuging and we've got some headers + if($this->debug && count($GLOBALS['_xh']['headers'])) { + $debug_string = ''; + + foreach($GLOBALS['_xh']['headers'] as $header => $value) { + $debug_string .= "HEADER: $header: $value\n"; } - foreach($GLOBALS['_xh']['cookies'] as $header => $value) - { - print htmlentities("COOKIE: $header={$value['value']}\n"); + foreach($GLOBALS['_xh']['cookies'] as $header => $value) { + $debug_string .= "COOKIE: $header={$value['value']}\n"; } - print "\n"; + debug_event('XMLRPC',"\n---SENDING---\n" . htmlentities($debug_string) . "\n---END---\n",'1','xmlrpc'); } // if CURL was used for the call, http headers have been processed, @@ -2381,13 +2376,13 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha { $data = $degzdata; if($this->debug) - print "
---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---"; + debug_event('XMLRPC',"\n---RESPONSE---\n" . $data . "\n---END---\n",'1','xmlrpc'); } elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { $data = $degzdata; if($this->debug) - print "
---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---"; + debug_event('XMLRPC',"\n---RESPONSE---\n" . $data . "\n---END---\n",'1','xmlrpc'); } else { @@ -2425,7 +2420,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha if($this->debug) { //by maHo, replaced htmlspecialchars with htmlentities - print "
---GOT---\n" . htmlentities($data) . "\n---END---\n"; + debug_event('XMLRPC',"\n---GOT---\n" . $data . "\n---END---\n",'1','xmlrpc'); } if($data == '') diff --git a/templates/show_get_albumart.inc.php b/templates/show_get_albumart.inc.php index bf831436..a9cf2f37 100644 --- a/templates/show_get_albumart.inc.php +++ b/templates/show_get_albumart.inc.php @@ -21,7 +21,6 @@ */ ?> -