diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-10 20:21:09 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-10 20:21:09 +0000 |
commit | bdddcc8892aacf3baeafb0b2f25db43f86df7655 (patch) | |
tree | a3622df3b6ed9870b6fa5d41c2fa22f598548f41 | |
parent | a025743d762bb5dfe1edcf4131d3e8764fe45283 (diff) | |
download | ampache-bdddcc8892aacf3baeafb0b2f25db43f86df7655.tar.gz ampache-bdddcc8892aacf3baeafb0b2f25db43f86df7655.tar.bz2 ampache-bdddcc8892aacf3baeafb0b2f25db43f86df7655.zip |
new staggered xmlrpc mojo
-rw-r--r-- | lib/xmlrpc.php | 20 | ||||
-rw-r--r-- | play/index.php | 4 | ||||
-rw-r--r-- | server.php | 12 |
3 files changed, 24 insertions, 12 deletions
diff --git a/lib/xmlrpc.php b/lib/xmlrpc.php index a9d71bc7..194a9808 100644 --- a/lib/xmlrpc.php +++ b/lib/xmlrpc.php @@ -30,18 +30,20 @@ */ /** - * remote_server_query + * remote_catalog_query * this is the initial contact and response to a xmlrpc request from another ampache server * this returns a list of catalog names * @package XMLRPC * @catagory Server */ -function remote_server_query($m) { +function remote_catalog_query($m) { $result = array(); // we only want to send the local entries - $sql = "SELECT name,COUNT(song.id) FROM catalog LEFT JOIN song ON catalog.id = song.catalog WHERE catalog_type='local' GROUP BY catalog.id"; + $sql = "SELECT name,COUNT(song.id) FROM catalog " . + "LEFT JOIN song ON catalog.id = song.catalog " . + "WHERE catalog_type='local' GROUP BY catalog.id"; $db_result = mysql_query($sql, dbh()); while ( $i = mysql_fetch_row($db_result) ) { @@ -65,9 +67,13 @@ function remote_server_query($m) { * @catagory Server * @todo Add catalog level access control * @todo fix for the smallint(1) change of song.status + * @todo serialize the information rather than cheat with the :: */ -function remote_song_query() { +function remote_song_query($params) { + $start = $params->params['0']->me['int']; + $step = $params->params['1']->me['int']; + // Get me a list of all local catalogs $sql = "SELECT catalog.id FROM catalog WHERE catalog_type='local'"; $db_results = mysql_query($sql, dbh()); @@ -75,7 +81,7 @@ function remote_song_query() { $results = array(); $sql = "SELECT song.id FROM song WHERE song.status='enabled' AND ("; - + // Get the catalogs and build the query! while ($r = mysql_fetch_object($db_results)) { $sql .= " song.catalog='$r->id' OR"; @@ -83,8 +89,8 @@ function remote_song_query() { $sql = rtrim($sql,"OR"); - $sql .= ")"; - + $sql .= ") LIMIT $start,$step"; + $db_results = mysql_query($sql, dbh()); // Recurse through the songs and build a results diff --git a/play/index.php b/play/index.php index 76b3e467..a72231c3 100644 --- a/play/index.php +++ b/play/index.php @@ -54,9 +54,9 @@ if (conf('require_session') && !conf('xml_rpc')) { /* If we are in demo mode.. die here */ if (conf('demo_mode') || !$user->has_access('25')) { if (conf('debug')) { - log_event($user->usrename,' access_denied ', "Streaming Access Denied, " . conf('demo_mode') . "is the value of demo_mode. Current user level is $user->access"); + log_event($user->username,' access_denied ', "Streaming Access Denied, " . conf('demo_mode') . "is the value of demo_mode. Current user level is $user->access"); } -// access_denied(); + access_denied(); } /* @@ -20,18 +20,24 @@ $no_session = true; require_once('modules/init.php'); require_once(conf('prefix') . "/modules/xmlrpc/xmlrpcs.inc"); +require_once(conf('prefix') . "/modules/xmlrpc/xmlrpc.inc"); /* Setup the vars we are going to need */ $access = new Access(); // ** check that the remote server has access to this catalog if ($access->check('75',$_SERVER['REMOTE_ADDR'])) { - $s = new xmlrpc_server( array( "remote_server_query" => array("function" => "remote_server_query"), - "remote_song_query" => array("function" => "remote_song_query") ) ); + + /* Setup Possible Actions */ + $methods['remote_catalog_query'] = array('function' => 'remote_catalog_query'); + $methods['remote_song_query'] = array('function' => 'remote_song_query'); + $methods['remote_session_auth'] = array('function' => 'remote_session_auth'); + + $s = new xmlrpc_server($methods); } else { // Access Denied... Sucka!! - $s = new xmlrpc_server( array( "remote_server_query" => array("function" => "remote_server_denied"))); + $s = new xmlrpc_server( array( "remote_catalog_query" => array("function" => "remote_server_denied"))); } ?> |