summaryrefslogtreecommitdiffstats
path: root/lib/class/xmlrpcclient.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2010-02-05 01:29:20 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2010-02-05 01:29:20 +0000
commit24761d3863f9d3bd93ca915cb665764ed041ebe4 (patch)
tree2ff1e79e2d26c8dc6b73638f507962196f26f251 /lib/class/xmlrpcclient.class.php
parent68aca7623155d1a8365e098e1fa738582dd0d1bc (diff)
downloadampache-24761d3863f9d3bd93ca915cb665764ed041ebe4.tar.gz
ampache-24761d3863f9d3bd93ca915cb665764ed041ebe4.tar.bz2
ampache-24761d3863f9d3bd93ca915cb665764ed041ebe4.zip
Removed dead xmlrpc files, started work migrating to LastFM v2.0 api
Diffstat (limited to 'lib/class/xmlrpcclient.class.php')
-rw-r--r--lib/class/xmlrpcclient.class.php137
1 files changed, 0 insertions, 137 deletions
diff --git a/lib/class/xmlrpcclient.class.php b/lib/class/xmlrpcclient.class.php
deleted file mode 100644
index 49bf4439..00000000
--- a/lib/class/xmlrpcclient.class.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-/*
-
- Copyright (c) Ampache.org
- All rights reserved.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-/**
- * xmlRpcClient
- * This is the other half of the xmlrpcserver class, it Holds the different calls that Ampache might
- * make that are xmlrpc'ie this does not include the API responses.
- */
-
-class xmlRpcClient {
- /**
- * construtor
- * not used
- */
- private function __construct() {
-
- // Rien a faire
-
- } // constructor
-
- /**
- * ampache_handshake
- * This handshakes with ampache servers, this is used by the internal xml-rpc mojo
- */
- public static function ampache_handshake($target_url,$key) {
-
- // Generate the client
- $client = self::create_client($target_url);
-
- // 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); }
-
- // Build our key
- $timestamp = time();
- $handshake_key = hash('sha256',$timestamp . hash('sha256',$key));
-
- $encoded_key = new XML_RPC_Value($handshake_key,'string');
- $timestamp = new XML_RPC_Value($timestamp,'int');
- $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.handshake',array($encoded_key,$timestamp));
-
- // Send it off
- $response = $client->send($xmlrpc_message,10);
-
- if ($response->faultCode()) {
- $error_msg = _('Error connecting to') . " " . $client->server . " " . _("Code") . ": " . $response->faultCode() . " " . _("Reason") . ": " . $response->faultString();
- debug_event('XMLCLIENT',$error_msg,'1');
- Error::add('general',$error_msg);
- return;
- }
-
- $token = XML_RPC_Decode($response->value());
-
- debug_event('XML-RPC',$token . ' returned from ' . $client->server,'3');
-
- return $token;
-
- } // ampache_handshake
-
- /**
- * ampache_create_stream_session
- * This generates a new stream session, it takes a target_url and a token as generated by
- * a ampache_handshake action
- */
- public static function ampache_create_stream_session($target_url,$token) {
-
- $client = self::create_client($target_url);
-
- // 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); }
-
- $encoded_key = new XML_RPC_Value($token,'string');
- $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.create_stream_session',array($encoded_key));
-
- $response = $client->send($xmlrpc_message,4);
-
- if ($response->faultCode() ) {
- $error_msg = _("Error connecting to") . " " . $client->server . " " . _("Code") . ": " . $response->faultCode() . " " .
- debug_event('XMLCLIENT',$error_msg,'1');
- return false;
- }
-
- $sid = XML_RPC_Decode($response->value());
-
- debug_event('XML-RPC', $sid . ' stream session ID returned from ' . $client->server,'3');
-
- return $sid;
-
- } // ampache_create_stream_session
-
- /**
- * create_client
- * This creates the xmlrpc client object from a URL
- */
- public static function create_client($target_url) {
-
- // Figure out the host etc
- preg_match("/http:\/\/([^\/\:]+):?(\d*)\/*(.*)/", $target_url, $match);
- $server = $match['1'];
- $port = $match['2'] ? intval($match['2']) : '80';
- $path = $match['3'];
- if(Config::get('proxy_host') AND Config::get('proxy_port')) {
- $proxy_host = Config::get('proxy_host');
- $proxy_port = Config::get('proxy_port');
- $proxy_user = Config::get('proxy_user');
- $proxy_pass = Config::get('proxy_pass');
- }
-
- $full_url = "/" . ltrim($path . "/server/xmlrpc.server.php",'/');
-
- $client = new XML_RPC_Client($full_url,$server,$port,$proxy_host,$proxy_port,$proxy_user,$proxy_pass);
-
- return $client;
-
- } // create_client
-
-} // xmlRpcClient
-?>