CC-1695 Remove Campcaster Studio and make install easier
Changed backend dir to new structure
This commit is contained in:
parent
c4b96da797
commit
e946e6a84e
82 changed files with 0 additions and 12 deletions
3833
backend/xmlrpc/XR_LocStor.php
Normal file
3833
backend/xmlrpc/XR_LocStor.php
Normal file
File diff suppressed because it is too large
Load diff
4
backend/xmlrpc/index.php
Normal file
4
backend/xmlrpc/index.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
header ("location: xrLocStor.php");
|
||||
exit;
|
||||
?>
|
99
backend/xmlrpc/put.php
Normal file
99
backend/xmlrpc/put.php
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
/**
|
||||
* Store PUT data as temporary file.
|
||||
*
|
||||
* put.php is remote callable script through HTTP PUT method.
|
||||
* Requires token returned by appropriate storageServer XMLRPC call.
|
||||
* Appropriate closing XMLRPC call should follow.
|
||||
*
|
||||
* This script accepts following HTTP GET parameter:
|
||||
* <ul>
|
||||
* <li>token : string, put token returned by appropriate
|
||||
* XMLRPC call</li>
|
||||
* </ul>
|
||||
*
|
||||
* On success, returns HTTP return code 200.
|
||||
*
|
||||
* On errors, returns HTTP return code >200
|
||||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li> 400 - Incorrect parameters passed to method</li>
|
||||
* <li> 403 - Access denied</li>
|
||||
* <li> 500 - Application error</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see XR_LocStor
|
||||
* @package Campcaster
|
||||
* @subpackage storageServer
|
||||
*/
|
||||
|
||||
define('USE_FLOCK', TRUE);
|
||||
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/../LocStor.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new LocStor();
|
||||
|
||||
function http_error($code, $err)
|
||||
{
|
||||
header("HTTP/1.1 $code");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "$err\r\n";
|
||||
flush();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['token'])) {
|
||||
$token = $_REQUEST['token'];
|
||||
} else {
|
||||
http_error(400, "Error on token parameter. ({$_REQUEST['token']})");
|
||||
}
|
||||
|
||||
$tc = BasicStor::bsCheckToken($token, 'put');
|
||||
if (PEAR::isError($tc)) {
|
||||
http_error(500, $ex->getMessage());
|
||||
}
|
||||
if (!$tc) {
|
||||
http_error(403, "put.php: Token not valid ($token).");
|
||||
}
|
||||
|
||||
header("Content-type: text/plain");
|
||||
|
||||
$destfile = $CC_CONFIG['accessDir']."/{$token}";
|
||||
|
||||
/* PUT data comes in on the input stream */
|
||||
$putdata = @fopen("php://input", "r") or
|
||||
http_error(500, "put.php: Can't read input");
|
||||
|
||||
/* Open a file for writing */
|
||||
$fp = @fopen($destfile, "ab") or
|
||||
http_error(500, "put.php: Can't write to destination file (token=$token)");
|
||||
|
||||
if ( USE_FLOCK ) {
|
||||
// lock the file
|
||||
$lockres = flock($fp,LOCK_EX+LOCK_NB);
|
||||
if ($lockres !== TRUE) {
|
||||
http_error(409, "put.php: file locked (token=$token)");
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the data 1 KB at a time and write to the file */
|
||||
while ($data = fread($putdata, 1024)){
|
||||
fwrite($fp, $data);
|
||||
}
|
||||
|
||||
if ( USE_FLOCK ) {
|
||||
// unlock the file
|
||||
flock($fp,LOCK_UN);
|
||||
}
|
||||
|
||||
/* Close the streams */
|
||||
fclose($fp);
|
||||
fclose($putdata);
|
||||
|
||||
header("HTTP/1.1 200");
|
||||
?>
|
511
backend/xmlrpc/schedulerPhpClient.php
Normal file
511
backend/xmlrpc/schedulerPhpClient.php
Normal file
|
@ -0,0 +1,511 @@
|
|||
<?php
|
||||
/* ================================================================= includes */
|
||||
include_once(dirname(__FILE__)."/../conf.php");
|
||||
require_once('DB.php');
|
||||
include_once("XML/RPC.php");
|
||||
|
||||
/* ================================================== method definition array */
|
||||
/**
|
||||
* Array with methods description
|
||||
*
|
||||
* Each element has method name as key and contains four subfields:
|
||||
* <ul>
|
||||
* <li>m</li> full method name (include optional prefix)
|
||||
* <li>p</li> array of input parameter names
|
||||
* <li>t</li> array of input parameter types
|
||||
* <li>r</li> array of result element names (not used there at present)
|
||||
* <li>e</li> array of error codes/messages (not used there at present)
|
||||
* </ul>
|
||||
*/
|
||||
$mdefs = array(
|
||||
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL, 't'=>NULL),
|
||||
"AddAudioClipToPlaylistMethod" => array(
|
||||
'm'=>'addAudioClipToPlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'audioClipId'/*string*/, 'relativeOffset'/*int*/, 'clipStart'/*int*/, 'clipEnd'/*int*/, 'clipLength'/*int*/),
|
||||
't'=>array('string', 'string', 'string', 'int', 'int', 'int', 'int'),
|
||||
'r'=>array('playlistElementId'/*string*/),
|
||||
'e'=>array(
|
||||
'301'=>'invalid argument format',
|
||||
'302'=>'missing playlist ID argument',
|
||||
'303'=>'missing audio clip ID argument',
|
||||
'304'=>'missing relative offset argument',
|
||||
'305'=>'playlist not found',
|
||||
'306'=>'playlist has not been opened for editing',
|
||||
'307'=>'audio clip does not exist',
|
||||
'308'=>'two audio clips at the same relative offset',
|
||||
'320'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"CreatePlaylistMethod" => array(
|
||||
'm'=>'createPlaylist',
|
||||
'p'=>array('sessionId'/*string*/),
|
||||
't'=>array('string'),
|
||||
'r'=>array('playlist'/*string*/),
|
||||
'e'=>array(
|
||||
'201'=>'invalid argument format',
|
||||
'202'=>'could not create playlist',
|
||||
'220'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"DeletePlaylistMethod" => array(
|
||||
'm'=>'deletePlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'901'=>'invalid argument format',
|
||||
'902'=>'missing playlist ID argument',
|
||||
'903'=>'playlist not found',
|
||||
'904'=>'playlist is locked',
|
||||
'905'=>'playlist could not be deleted',
|
||||
'920'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"DisplayAudioClipMethod" => array(
|
||||
'm'=>'displayAudioClip',
|
||||
'p'=>array('sessionId'/*string*/, 'audioClipId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array('audioClip'/*string*/),
|
||||
'e'=>array(
|
||||
'601'=>'invalid argument format',
|
||||
'602'=>'argument is not an audio clip ID',
|
||||
'603'=>'audio clip not found',
|
||||
'620'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"DisplayAudioClipsMethod" => array(
|
||||
'm'=>'displayAudioClips',
|
||||
'p'=>array('sessionId'/*string*/),
|
||||
't'=>array('string'),
|
||||
'r'=>array(array('audioClip'/*string*/)),
|
||||
'e'=>array(
|
||||
'1801'=>'invalid argument format',
|
||||
'1802'=>'XML-RPC error',
|
||||
'1820'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"DisplayPlaylistMethod" => array(
|
||||
'm'=>'displayPlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array('playlist'/*string*/),
|
||||
'e'=>array(
|
||||
'1001'=>'invalid argument format',
|
||||
'1002'=>'argument is not a playlist ID',
|
||||
'1003'=>'playlist not found',
|
||||
'1020'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"DisplayPlaylistsMethod" => array(
|
||||
'm'=>'displayPlaylists',
|
||||
'p'=>array('sessionId'/*string*/),
|
||||
't'=>array('string'),
|
||||
'r'=>array(array('playlist'/*string*/)),
|
||||
'e'=>array(
|
||||
'1701'=>'invalid argument format',
|
||||
'1702'=>'XML-RPC error',
|
||||
'1720'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"DisplayScheduleMethod" => array(
|
||||
'm'=>'displaySchedule',
|
||||
'p'=>array('sessionId'/*string*/, 'from'/*datetime*/, 'to'/*datetime*/),
|
||||
't'=>array('string', 'dateTime.iso8601', 'dateTime.iso8601'),
|
||||
'r'=>array(array('id'/*int*/, 'playlistId'/*string*/, 'start'/*datetime*/, 'end'/*datetime*/)),
|
||||
'e'=>array(
|
||||
'1101'=>'invalid argument format',
|
||||
'1102'=>"missing or invalid 'from' argument",
|
||||
'1103'=>"missing or invalid 'to' argument",
|
||||
'1120'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"GeneratePlayReportMethod" => array(
|
||||
'm'=>'generatePlayReport',
|
||||
'p'=>array('sessionId'/*string*/, 'from'/*datetime*/, 'to'/*datetime*/),
|
||||
't'=>array('string', 'dateTime.iso8601', 'dateTime.iso8601'),
|
||||
'r'=>array(array('audioClipId'/*string*/, 'timestamp'/*datetime*/)),
|
||||
'e'=>array(
|
||||
'1501'=>'invalid argument format',
|
||||
'1502'=>"missing or invalid 'from' argument",
|
||||
'1503'=>"missing or invalid 'to' argument",
|
||||
'1520'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"GetSchedulerTimeMethod" => array(
|
||||
'm'=>'getSchedulerTime',
|
||||
'p'=>array(),
|
||||
't'=>array(),
|
||||
'r'=>array('schedulerTime'/*datetime*/),
|
||||
'e'=>array(
|
||||
)
|
||||
),
|
||||
"GetVersionMethod" => array(
|
||||
'm'=>'getVersion',
|
||||
'p'=>array(),
|
||||
't'=>array(),
|
||||
'r'=>array('version'/*string*/),
|
||||
'e'=>array()
|
||||
),
|
||||
"LoginMethod" => array(
|
||||
'm'=>'login',
|
||||
'p'=>array('login'/*string*/, 'password'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array('sessionId'/*string*/),
|
||||
'e'=>array(
|
||||
'2001'=>'invalid argument format',
|
||||
'2002'=>'missing login argument',
|
||||
'2003'=>'missing password argument',
|
||||
'2004'=>'the authentication server reported an error',
|
||||
)
|
||||
),
|
||||
"LogoutMethod" => array(
|
||||
'm'=>'logout',
|
||||
'p'=>array('sessionId'/*string*/),
|
||||
't'=>array('string'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'2101'=>'invalid argument format',
|
||||
'2120'=>'missing session ID argument',
|
||||
'2104'=>'the authentication server reported an error',
|
||||
)
|
||||
),
|
||||
"OpenPlaylistForEditingMethod" => array(
|
||||
'm'=>'openPlaylistForEditing',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array('playlist'/*string*/),
|
||||
'e'=>array(
|
||||
'101'=>'invalid argument format',
|
||||
'102'=>'argument is not a playlist ID',
|
||||
'104'=>'could not open playlist for editing',
|
||||
'120'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"RemoveAudioClipFromPlaylistMethod" => array(
|
||||
'm'=>'removeAudioClipFromPlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playlistElementId'/*string*/),
|
||||
't'=>array('string', 'string', 'string'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'401'=>'invalid argument format',
|
||||
'402'=>'missing playlist ID argument',
|
||||
'403'=>'missing relative offset argument',
|
||||
'404'=>'playlist does not exist',
|
||||
'405'=>'playlist has not been opened for editing',
|
||||
'406'=>'no audio clip at the specified relative offset',
|
||||
'420'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"RemoveFromScheduleMethod" => array(
|
||||
'm'=>'removeFromSchedule',
|
||||
'p'=>array('sessionId'/*string*/, 'scheduleEntryId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'1201'=>'invalid argument format',
|
||||
'1202'=>'missing schedule entry ID argument',
|
||||
'1203'=>'schedule entry not found',
|
||||
'1220'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"RescheduleMethod" => array(
|
||||
'm'=>'reschedule',
|
||||
'p'=>array('sessionId'/*string*/, 'scheduleEntryId'/*string*/, 'playtime'/*datetime*/),
|
||||
't'=>array('string', 'string', 'dateTime.iso8601'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'1301'=>'invalid argument format',
|
||||
'1302'=>'missing schedule entry ID argument',
|
||||
'1303'=>'missing playtime argument',
|
||||
'1304'=>'schedule entry not found',
|
||||
'1305'=>'could not reschedule entry',
|
||||
'1320'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
// "ResetStorageMethod" => array(
|
||||
// 'm'=>'resetStorage',
|
||||
// 'p'=>array(),
|
||||
// 't'=>array(),
|
||||
// 'r'=>array(),
|
||||
// 'e'=>array('3001'=>'storage client reported an error'),
|
||||
// ),
|
||||
"RevertEditedPlaylistMethod" => array(
|
||||
'm'=>'revertEditedPlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'801'=>'invalid argument format',
|
||||
'802'=>'argument is not a playlist ID',
|
||||
'803'=>'playlist not found',
|
||||
'804'=>'could not revert playlist',
|
||||
'820'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"SavePlaylistMethod" => array(
|
||||
'm'=>'savePlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'701'=>'invalid argument format',
|
||||
'702'=>'argument is not a playlist ID',
|
||||
'703'=>'playlist not found',
|
||||
'705'=>'could not save playlist',
|
||||
'720'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"UpdateFadeInFadeOutMethod" => array(
|
||||
'm'=>'updateFadeInFadeOut',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playlistElementId'/*string*/, 'fadeIn'/*int*/, 'fadeOut'/*int*/),
|
||||
't'=>array('string', 'string', 'string', 'int', 'int'),
|
||||
'r'=>array(),
|
||||
'e'=>array(
|
||||
'1601'=>'invalid argument format',
|
||||
'1602'=>'missing playlist ID argument',
|
||||
'1603'=>'missing playlist element ID argument',
|
||||
'1604'=>'missing fade in argument',
|
||||
'1605'=>'missing fade out argument',
|
||||
'1606'=>'playlist does not exist',
|
||||
'1607'=>'playlist has not been opened for editing',
|
||||
'1608'=>'error executing setFadeInfo() method',
|
||||
'1620'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"UploadPlaylistMethod" => array(
|
||||
'm'=>'uploadPlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playtime'/*datetime*/),
|
||||
't'=>array('string', 'string', 'dateTime.iso8601'),
|
||||
'r'=>array('scheduleEntryId'/*string*/),
|
||||
'e'=>array(
|
||||
'1401'=>'invalid argument format',
|
||||
'1402'=>'missing playlist ID argument',
|
||||
'1403'=>'missing playtime argument',
|
||||
'1404'=>'playlist not found',
|
||||
'1405'=>'timeframe not available',
|
||||
'1406'=>'could not schedule playlist',
|
||||
'1420'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"ValidatePlaylistMethod" => array(
|
||||
'm'=>'validatePlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array('valid'/*bool*/),
|
||||
'e'=>array(
|
||||
'501'=>'invalid argument format',
|
||||
'502'=>'missing playlist ID argument',
|
||||
'503'=>'playlist does not exist',
|
||||
'504'=>'playlist has not been opened for editing',
|
||||
'520'=>'missing session ID argument',
|
||||
)
|
||||
),
|
||||
"LoginGB" => array(
|
||||
'm'=>'locstor.login',
|
||||
'p'=>array('login'/*string*/, 'pass'/*string*/),
|
||||
't'=>array('string', 'string'),
|
||||
'r'=>array('sessid'/*string*/),
|
||||
'e'=>array(
|
||||
'2001'=>'invalid argument format',
|
||||
'2002'=>'missing login argument',
|
||||
'2003'=>'missing password argument',
|
||||
'2004'=>'the authentication server reported an error',
|
||||
)
|
||||
),
|
||||
"LogoutGB" => array(
|
||||
'm'=>'locstor.logout',
|
||||
'p'=>array('sessid'/*string*/),
|
||||
't'=>array('string'),
|
||||
'r'=>array('status'/*boolean*/),
|
||||
'e'=>array(
|
||||
'2001'=>'invalid argument format',
|
||||
'2002'=>'missing login argument',
|
||||
'2003'=>'missing password argument',
|
||||
'2004'=>'the authentication server reported an error',
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
/* ======================================================== class definitions */
|
||||
|
||||
class SchedulerPhpClient {
|
||||
/**
|
||||
* Array with methods description
|
||||
* @var array
|
||||
*/
|
||||
private $mdefs = array();
|
||||
|
||||
/**
|
||||
* XMLRPC client object reference
|
||||
*/
|
||||
private $client = NULL;
|
||||
|
||||
/**
|
||||
* Verbosity flag
|
||||
*/
|
||||
private $verbose = FALSE;
|
||||
|
||||
/**
|
||||
* XMLRPC debug flag
|
||||
*/
|
||||
private $debug = 0;
|
||||
|
||||
/**
|
||||
* Constructor - please DON'T CALL IT, use factory method instead
|
||||
*
|
||||
* @param DB $dbc
|
||||
* @param array $mdefs
|
||||
* hash array with methods description
|
||||
* @param array $config
|
||||
* hash array with configuration
|
||||
* @param int $debug
|
||||
* XMLRPC debug flag
|
||||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
*/
|
||||
public function __construct($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$this->mdefs = $mdefs;
|
||||
$this->debug = $debug;
|
||||
$this->verbose = $verbose;
|
||||
$confPrefix = "scheduler";
|
||||
//$confPrefix = "storage";
|
||||
$serverPath =
|
||||
"http://{$CC_CONFIG["{$confPrefix}UrlHost"]}:{$CC_CONFIG["{$confPrefix}UrlPort"]}".
|
||||
"{$CC_CONFIG["{$confPrefix}UrlPath"]}/{$CC_CONFIG["{$confPrefix}XMLRPC"]}";
|
||||
//$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||
if ($this->verbose) {
|
||||
echo "serverPath: $serverPath\n";
|
||||
}
|
||||
$url = parse_url($serverPath);
|
||||
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory, create object instance
|
||||
*
|
||||
* In fact it doesn't create instance of SchedulerPhpClient, but
|
||||
* dynamically extend this class with set of methods based on $mdefs array
|
||||
* (using eval function) and instantiate resulting class
|
||||
* SchedulerPhpClientCore instead.
|
||||
* Each new method in this subclass accepts parameters according to $mdefs
|
||||
* array, call wrapper callMethod(methodname, parameters) and return its
|
||||
* result.
|
||||
*
|
||||
* @param array $mdefs
|
||||
* hash array with methods description
|
||||
* @param int $debug
|
||||
* XMLRPC debug flag
|
||||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
* @return SchedulerPhpClientCore
|
||||
*/
|
||||
function &factory($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$f = '';
|
||||
foreach ($mdefs as $fn => $farr) {
|
||||
$f .=
|
||||
' function '.$fn.'(){'."\n".
|
||||
' $pars = func_get_args();'."\n".
|
||||
' $r = $this->callMethod("'.$fn.'", $pars);'."\n".
|
||||
' return $r;'."\n".
|
||||
' }'."\n";
|
||||
}
|
||||
$e =
|
||||
"class SchedulerPhpClientCore extends SchedulerPhpClient{\n".
|
||||
"$f\n".
|
||||
"}\n";
|
||||
# echo $e;
|
||||
if (FALSE === eval($e)) {
|
||||
return $CC_DBC->raiseError("Eval failed");
|
||||
}
|
||||
$spc = new SchedulerPhpClientCore($mdefs, $debug, $verbose);
|
||||
return $spc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* XMLRPC methods wrapper
|
||||
* Encode XMLRPC request message, send it, receive and decode response.
|
||||
*
|
||||
* @param string $method
|
||||
* method name
|
||||
* @param array $gettedPars
|
||||
* returned by func_get_args() in called method
|
||||
* @return array
|
||||
* PHP hash with response
|
||||
*/
|
||||
function callMethod($method, $gettedPars)
|
||||
{
|
||||
$parr = array();
|
||||
$XML_RPC_val = new XML_RPC_Value;
|
||||
foreach ($this->mdefs[$method]['p'] as $i => $p) {
|
||||
$parr[$p] = new XML_RPC_Value;
|
||||
$parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]);
|
||||
}
|
||||
$XML_RPC_val->addStruct($parr);
|
||||
$fullmethod = $this->mdefs[$method]['m'];
|
||||
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
|
||||
if ($this->verbose) {
|
||||
echo "parr:\n";
|
||||
var_dump($parr);
|
||||
echo "message:\n";
|
||||
echo $msg->serialize()."\n";
|
||||
}
|
||||
$this->client->setDebug($this->debug);
|
||||
$res = $this->client->send($msg);
|
||||
if ($res->faultCode() > 0) {
|
||||
return PEAR::raiseError(
|
||||
"SchedulerPhpClient::$method:".$res->faultString()." ".
|
||||
$res->faultCode()."\n", $res->faultCode(),
|
||||
PEAR_ERROR_RETURN
|
||||
);
|
||||
}
|
||||
if ($this->verbose) {
|
||||
echo "result:\n";
|
||||
echo $res->serialize();
|
||||
}
|
||||
$val = $res->value();
|
||||
$resp = XML_RPC_decode($res->value());
|
||||
return $resp;
|
||||
}
|
||||
|
||||
} // class SchedulerPhpClient
|
||||
|
||||
/* ======================================================== class definitions */
|
||||
|
||||
/**
|
||||
* Example of use:
|
||||
*
|
||||
* /
|
||||
|
||||
|
||||
// db object handling:
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
// scheduler client instantiation:
|
||||
$spc = SchedulerPhpClient::factory($mdefs);
|
||||
#$spc = SchedulerPhpClient::factory($mdefs, 0, TRUE);
|
||||
if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; }
|
||||
|
||||
// call of chosen function by name according to key values in $mdefs array:
|
||||
// (for testing on storageServer XMLRPC I've changes confPrefix in
|
||||
// SchedulerPhpClient constructor from 'scheduler' to 'storage' value)
|
||||
#$r = $spc->LoginGB('root', 'q'); var_dump($r);
|
||||
#$r = $spc->LogoutGB(''); var_dump($r);
|
||||
|
||||
#$r = $spc->DisplayScheduleMethod($this->Base->sessid, '2005-01-01 00:00:00.000000', '2005-02-01 00:00:00.000000'); var_dump($r);
|
||||
#$r = $spc->DisplayScheduleMethod('dummySessionId2-1681692777', '2005-01-01 00:00:00.000000', '2005-02-01 00:00:00.000000'); var_dump($r);
|
||||
$r = $spc->DisplayScheduleMethod($this->Base->sessid, '20040101T00:00:00', '20050401T00:00:00'); var_dump($r);
|
||||
#$r = $spc->LoginMethod('root', 'q'); var_dump($r);
|
||||
#$r = $spc->LogoutMethod('dummySessionId3-1714636915'); var_dump($r);
|
||||
#$r = $spc->listMethods(); var_dump($r);
|
||||
#$r = $spc->GetSchedulerTimeMethod(); var_dump($r);
|
||||
================= */
|
||||
|
||||
?>
|
128
backend/xmlrpc/simpleGet.php
Normal file
128
backend/xmlrpc/simpleGet.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
/**
|
||||
* Returns stored media file identified by global unique ID.
|
||||
*
|
||||
* simpleGet.php is remote callable script through HTTP GET method.
|
||||
* Requires valid session ID with read permission for requested file.
|
||||
*
|
||||
* This script accepts following HTTP GET parameters:
|
||||
* <ul>
|
||||
* <li>sessid : string, session ID</li>
|
||||
* <li>id : string, global unique ID of requested file</li>
|
||||
* </ul>
|
||||
*
|
||||
* On success, returns HTTP return code 200 and requested file.
|
||||
*
|
||||
* On errors, returns HTTP return code >200
|
||||
* The possible error codes are:
|
||||
* <ul>
|
||||
* <li> 400 - Incorrect parameters passed to method</li>
|
||||
* <li> 403 - Access denied</li>
|
||||
* <li> 404 - File not found</li>
|
||||
* <li> 500 - Application error</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/../LocStor.php');
|
||||
require_once(dirname(__FILE__).'/../MetaData.php');
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$locStor = new LocStor();
|
||||
|
||||
function http_error($code, $err)
|
||||
{
|
||||
header("HTTP/1.1 $code");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "$err\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function encodes an filename to
|
||||
* be transferred via HTTP header.
|
||||
*
|
||||
* @param string $p_string utf8 filename
|
||||
* @return string HTTP header encoded filename
|
||||
*/
|
||||
function sg_2hexstring($p_string)
|
||||
{
|
||||
for ($x=0; $x < strlen($p_string); $x++) {
|
||||
$return .= '%' . bin2hex($p_string[$x]);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
// parameter checking:
|
||||
if (preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])) {
|
||||
$sessid = $_REQUEST['sessid'];
|
||||
} else {
|
||||
http_error(400, "Error on sessid parameter. ({$_REQUEST['sessid']})");
|
||||
}
|
||||
if (preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])) {
|
||||
$gunid = $_REQUEST['id'];
|
||||
} else {
|
||||
http_error(400, "Error on id parameter. ({$_REQUEST['id']})");
|
||||
}
|
||||
|
||||
// stored file recall:
|
||||
$ac = StoredFile::RecallByGunid($gunid);
|
||||
if (PEAR::isError($ac)) {
|
||||
switch ($ac->getCode()) {
|
||||
case GBERR_DENY:
|
||||
http_error(403, "403 ".$ac->getMessage());
|
||||
case GBERR_FILENEX:
|
||||
case GBERR_FOBJNEX:
|
||||
http_error(404, "404 File not found");
|
||||
default:
|
||||
http_error(500, "500 ".$ac->getMessage());
|
||||
}
|
||||
}
|
||||
$lid = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($lid)) {
|
||||
http_error(500, $lid->getMessage());
|
||||
}
|
||||
if (($res = BasicStor::Authorize('read', $lid, $sessid)) !== TRUE) {
|
||||
http_error(403, "403 Access denied");
|
||||
}
|
||||
$ftype = BasicStor::GetObjType($lid);
|
||||
if (PEAR::isError($ftype)) {
|
||||
http_error(500, $ftype->getMessage());
|
||||
}
|
||||
switch ($ftype) {
|
||||
case "audioclip":
|
||||
$realFname = $ac->getRealFileName();
|
||||
$mime = $ac->getMime();
|
||||
$md = new MetaData($ac->getGunId(), null);
|
||||
$fileName = $md->getMetadataValue('dc:title').'.'.$ac->getFileExtension();
|
||||
header("Content-type: $mime");
|
||||
header("Content-length: ".filesize($realFname));
|
||||
header("Content-Disposition: attachment; filename*=".sg_2hexstring($fileName).";");
|
||||
readfile($realFname);
|
||||
break;
|
||||
case "webstream":
|
||||
$url = $locStor->bsGetMetadataValue($lid, 'ls:url');
|
||||
if (empty($url)) {
|
||||
http_error(500, "Unable to get ls:url value");
|
||||
}
|
||||
$txt = "Location: $url";
|
||||
header($txt);
|
||||
// echo "$txt\n";
|
||||
break;
|
||||
case "playlist";
|
||||
// $md = $locStor->bsGetMetadata($ac->getId(), $sessid);
|
||||
$md = $locStor->getAudioClip($sessid, $gunid);
|
||||
// header("Content-type: text/xml");
|
||||
header("Content-type: application/smil");
|
||||
echo $md;
|
||||
break;
|
||||
default:
|
||||
// var_dump($ftype);
|
||||
http_error(500, "500 Unknown ftype ($ftype)");
|
||||
}
|
||||
?>
|
531
backend/xmlrpc/testRunner.sh
Executable file
531
backend/xmlrpc/testRunner.sh
Executable file
|
@ -0,0 +1,531 @@
|
|||
#!/bin/bash
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster 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 Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#DEBUG=yes
|
||||
#DEBUG_I=yes
|
||||
|
||||
if [ "x$1" != "x" ]; then
|
||||
COMM=$1
|
||||
shift
|
||||
GUNID=$1
|
||||
fi
|
||||
|
||||
METADATA="<?xml version=\"1.0\"?>
|
||||
<audioClip>
|
||||
<metadata
|
||||
xmlns=\"http://mdlf.org/campcaster/elements/1.0/\"
|
||||
xmlns:ls=\"http://mdlf.org/campcaster/elements/1.0/\"
|
||||
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
|
||||
xmlns:dcterms=\"http://purl.org/dc/terms/\"
|
||||
xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"
|
||||
>
|
||||
<dc:title>Media title testRunner</dc:title>
|
||||
<dcterms:extent>00:00:03.000000</dcterms:extent>
|
||||
</metadata>
|
||||
</audioClip>"
|
||||
METAREGEX="(<\\?xml version=\"1\\.0\"( encoding=\"UTF-8\")?\\?> )?\
|
||||
<audioClip>\
|
||||
<metadata\
|
||||
xmlns=\"http://mdlf\\.org/campcaster/elements/1\\.0/\"\
|
||||
xmlns:dc=\"http://purl\\.org/dc/elements/1\\.1/\"\
|
||||
xmlns:dcterms=\"http://purl\\.org/dc/terms/\"\
|
||||
xmlns:ls=\"http://mdlf\\.org/campcaster/elements/1\\.0/\"\
|
||||
xmlns:xml=\"http://www\\.w3\\.org/XML/1998/namespace\"\
|
||||
>\
|
||||
<dc:title>Media title testRunner</dc:title>\
|
||||
<dcterms:extent>00:00:03\\.000000</dcterms:extent>\
|
||||
<ls:mtime>[0-9]{4}(-[0-9]{2}){2}T[0-9]{2}(:[0-9]{2}){2}([-+][0-9]{1,2}:[0-9]{2})?</ls:mtime>\
|
||||
</metadata>\
|
||||
</audioClip>"
|
||||
|
||||
echo ""
|
||||
XRDIR=`dirname $0`
|
||||
XMLRPC=`cd var/install; php -q getXrUrl.php` || exit $?
|
||||
echo "# storageServer XMLRPC URL: $XMLRPC"
|
||||
|
||||
cd $XRDIR
|
||||
#XR_CLI="./xr_cli_test.py -s ${XMLRPC}"
|
||||
XR_CLI="php -q xr_cli_test.php -s ${XMLRPC}"
|
||||
|
||||
login() {
|
||||
echo -n "# login: "
|
||||
SESSID=`$XR_CLI login root q` || \
|
||||
{ ERN=$?; echo $SESSID; exit $ERN; }
|
||||
echo "sessid: $SESSID"
|
||||
}
|
||||
|
||||
test() {
|
||||
echo "# test: "
|
||||
$XR_CLI test $SESSID stringForUppercase || exit $?
|
||||
}
|
||||
|
||||
existsAudioClip() {
|
||||
echo -n "# existsAudioClip (${GUNID}): "
|
||||
$XR_CLI existsAudioClip $SESSID $GUNID || exit $?
|
||||
}
|
||||
|
||||
storeAudioClip() {
|
||||
if [ "x$1" = "x" ]; then MEDIA=../tests/ex1.mp3; else MEDIA=$1; fi
|
||||
if [ "x$2" = "x" ]; then GUNID=""; else GUNID=$2; fi
|
||||
MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done
|
||||
if [ $DEBUG_I ]; then echo "md5=$MD5"; fi
|
||||
echo -n "# storeAudioClipOpen: "
|
||||
RES=`$XR_CLI storeAudioClipOpen "$SESSID" "$GUNID" "$METADATA" "stored file.mp3" "$MD5"` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
if [ $DEBUG_I ]; then echo $URL; fi
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# curl (PUT): "
|
||||
curl -C 0 -T $MEDIA $URL || { ERN=$?; echo $RGUNID; exit $ERN; }
|
||||
echo "status: $?"
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# storeAudioClipClose: "
|
||||
RGUNID=`$XR_CLI storeAudioClipClose "$SESSID" "$TOKEN"` || \
|
||||
{ ERN=$?; echo $RGUNID; exit $ERN; }
|
||||
echo $RGUNID
|
||||
}
|
||||
|
||||
accessRawAudioData() {
|
||||
echo -n "# accessRawAudioData: "
|
||||
RES=`$XR_CLI accessRawAudioData $SESSID $GUNID` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
if [ $DEBUG_I ]; then echo $URL; fi
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# releaseRawAudioData: "
|
||||
$XR_CLI releaseRawAudioData $TOKEN || exit $?
|
||||
}
|
||||
|
||||
downloadRAD() {
|
||||
echo -n "# downloadRawAudioDataOpen: "
|
||||
RES=`$XR_CLI downloadRawAudioDataOpen $SESSID $GUNID` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
if [ $DEBUG_I ]; then echo $URL; fi
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# curl: "
|
||||
curl -Ifs $URL > /dev/null || { ERN=$?; echo $URL; exit $ERN; }
|
||||
echo "status: $?"
|
||||
echo -n "# downloadRawAudioDataClose: "
|
||||
$XR_CLI downloadRawAudioDataClose $SESSID $TOKEN || exit $?
|
||||
}
|
||||
|
||||
downloadMeta() {
|
||||
echo -n "# downloadMetadataOpen: "
|
||||
RES=`$XR_CLI downloadMetadataOpen $SESSID $GUNID` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
if [ $DEBUG_I ]; then echo $URL; fi
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# curl: "
|
||||
METAOUT=`curl -fs $URL;` || { ERN=$?; echo $RES; exit $ERN; }
|
||||
echo "OK"
|
||||
if [ $DEBUG_I ]; then echo $METAOUT; echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# metadata check:"
|
||||
METAOUT=`echo $METAOUT | sed -e 's/\\n/ /g'`
|
||||
if [[ "x$METAOUT" =~ "x$METAREGEX" ]]; then
|
||||
echo " OK"
|
||||
else
|
||||
echo " NOT MATCH ($?)"
|
||||
echo " Expected match to regex:"; echo $METAREGEX
|
||||
echo " Downloaded:"; echo ${METAOUT}
|
||||
exit 1
|
||||
fi
|
||||
echo -n "# downloadMetadataClose: "
|
||||
$XR_CLI downloadMetadataClose $SESSID $TOKEN || exit $?
|
||||
}
|
||||
|
||||
deleteAudioClip() {
|
||||
echo -n "# deleteAudioClip: "
|
||||
# disabled:
|
||||
# $XR_CLI deleteAudioClip $SESSID $GUNID || exit $?
|
||||
$XR_CLI deleteAudioClip $SESSID $GUNID 0
|
||||
}
|
||||
|
||||
updateAudioClipMetadata() {
|
||||
echo -n "#updateAudioClipMetadata: "
|
||||
$XR_CLI updateAudioClipMetadata $SESSID $GUNID "$METADATA" || exit $?
|
||||
}
|
||||
|
||||
getAudioClip() {
|
||||
echo -n "#getAudioClip: "
|
||||
$XR_CLI getAudioClip $SESSID $GUNID || exit $?
|
||||
}
|
||||
|
||||
searchMetadata() {
|
||||
echo -n "# searchMetadata: "
|
||||
RES=`$XR_CLI searchMetadata $SESSID 'title' 'testRunner'` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
echo $RES
|
||||
}
|
||||
|
||||
browseCategory() {
|
||||
echo -n "# browseCategory: "
|
||||
RES=`$XR_CLI browseCategory $SESSID 'title' 'title' 'testRunner'` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
echo $RES
|
||||
}
|
||||
|
||||
storeWebstream() {
|
||||
URL="http://localhost/x"
|
||||
echo -n "# storeWebstream: "
|
||||
RGUNID=`$XR_CLI storeWebstream "$SESSID" '' "$METADATA" "new stream" "$URL"` || \
|
||||
{ ERN=$?; echo $RGUNID; exit $ERN; }
|
||||
echo $RGUNID
|
||||
}
|
||||
|
||||
PLID="123456789abcdef8"
|
||||
|
||||
createPlaylist() {
|
||||
echo -n "# createPlaylist: "
|
||||
$XR_CLI deletePlaylist $SESSID $PLID 1
|
||||
$XR_CLI createPlaylist $SESSID $PLID "newPlaylist.xml" || exit $?
|
||||
}
|
||||
|
||||
accessPlaylist() {
|
||||
echo -n "# accessPlaylist: "
|
||||
RES=`$XR_CLI accessPlaylist $SESSID $PLID` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
if [ $DEBUG_I ]; then echo $URL; fi
|
||||
echo "# curl: "
|
||||
CURLOUT=`curl -fs $URL;` || { ERN=$?; echo $RES; exit $ERN; }
|
||||
if [ $DEBUG ]; then echo $CURLOUT; fi
|
||||
# echo $CURLOUT
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo "# status: $?"
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
echo -n "# releasePlaylist: "
|
||||
$XR_CLI releasePlaylist $TOKEN || exit $?
|
||||
}
|
||||
|
||||
editPlaylist() {
|
||||
DATE=`date '+%H:%M:%S'`
|
||||
PLAYLIST="<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
||||
<playlist id=\"123456789abcdef8\" playlength=\"01:30:00.000000\"
|
||||
title=\"My First Playlist\">
|
||||
<playlistElement id=\"0000000000000101\" relativeOffset=\"0\" >
|
||||
<audioClip id=\"0000000000010001\" playlength=\"01:00:00.000000\"
|
||||
title=\"one\"/>
|
||||
</playlistElement>
|
||||
<playlistElement id=\"0000000000000102\" relativeOffset=\"01:00:00.000000\" >
|
||||
<audioClip id=\"0000000000010002\" playlength=\"00:30:00.000000\"
|
||||
title=\"two\"/>
|
||||
</playlistElement>
|
||||
<metadata
|
||||
xmlns=\"http://www.streamonthefly.org/\"
|
||||
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
|
||||
xmlns:dcterms=\"http://purl.org/dc/terms/\"
|
||||
xmlns:xbmf=\"http://www.streamonthefly.org/xbmf\"
|
||||
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
|
||||
>
|
||||
<dc:title>My First Playlist</dc:title>
|
||||
<dc:creator>Me, myself and I</dc:creator>
|
||||
<dcterms:extent>01:30:00.000000</dcterms:extent>
|
||||
</metadata>
|
||||
</playlist>
|
||||
"
|
||||
echo -n "# editPlaylist: "
|
||||
RES=`$XR_CLI editPlaylist $SESSID $PLID` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
# deletePlaylist
|
||||
if [ $DEBUG_I ]; then echo $URL; fi
|
||||
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
|
||||
if [ $DEBUG_I ]; then echo " Playlist:"; echo $PLAYLIST; fi
|
||||
echo -n "# savePlaylist: "
|
||||
$XR_CLI savePlaylist $SESSID $TOKEN "$PLAYLIST" || exit $?
|
||||
}
|
||||
|
||||
existsPlaylist() {
|
||||
echo -n "# existsPlaylist (${PLID}): "
|
||||
EXISTS=`$XR_CLI existsPlaylist $SESSID $PLID` || \
|
||||
{ ERN=$?; echo $EXISTS; exit $ERN; }
|
||||
echo $EXISTS
|
||||
}
|
||||
|
||||
deletePlaylist() {
|
||||
if [ "$EXISTS" != "FALSE" ]; then
|
||||
echo -n "# deletePlaylist (${PLID}): "
|
||||
# disabled:
|
||||
# $XR_CLI deletePlaylist $SESSID $PLID || exit $?
|
||||
$XR_CLI deletePlaylist $SESSID $PLID 0
|
||||
echo "# status: $?"
|
||||
fi
|
||||
}
|
||||
|
||||
exportPlaylist() {
|
||||
storeAudioClip ../tests/0000000000010001 0000000000010001
|
||||
storeAudioClip ../tests/0000000000010002 0000000000010002
|
||||
echo -n "# exportPlaylistOpen (${PLID}): "
|
||||
# RES=`$XR_CLI exportPlaylistOpen $SESSID $PLID smil` || \
|
||||
RES=`$XR_CLI exportPlaylistOpen $SESSID $PLID lspl` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
echo -n "# curl: "
|
||||
curl -Ifs $URL > /dev/null || { ERN=$?; echo $URL; exit $ERN; }
|
||||
echo "status: $?"
|
||||
echo -n "# exportPlaylistClose (${TOKEN}): "
|
||||
RES=`$XR_CLI exportPlaylistClose $TOKEN` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
echo $RES
|
||||
}
|
||||
|
||||
importPlaylist() {
|
||||
echo -n "# importPlaylistOpen: "
|
||||
ARCHIVE=../tests/exportedPl_lspl.tar
|
||||
# ARCHIVE=../tests/exportedPl_smil.tar
|
||||
$XR_CLI deletePlaylist $SESSID 0000000000000001 1
|
||||
$XR_CLI deletePlaylist $SESSID 0000000000000003 1
|
||||
$XR_CLI deleteAudioClip $SESSID 0000000000010001 1
|
||||
$XR_CLI deleteAudioClip $SESSID 0000000000010002 1
|
||||
$XR_CLI deleteAudioClip $SESSID 0000000000010003 1
|
||||
CHSUM=`md5sum $ARCHIVE | cut -d ' ' -f 1 `
|
||||
RES=`$XR_CLI importPlaylistOpen $SESSID $CHSUM` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
unset URL
|
||||
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
|
||||
echo $TOKEN
|
||||
echo -n "# curl (PUT $URL): "
|
||||
curl -C 0 -T $ARCHIVE $URL || { ERN=$?; echo "curl error"; exit $ERN; }
|
||||
echo "status: $?"
|
||||
echo -n "# importPlaylistClose (${TOKEN}): "
|
||||
RES=`$XR_CLI importPlaylistClose $TOKEN` || \
|
||||
{ ERN=$?; echo $RES; exit $ERN; }
|
||||
echo $RES
|
||||
GUNID=0000000000010001; existsAudioClip;
|
||||
GUNID=0000000000010002; existsAudioClip;
|
||||
GUNID=0000000000010003; existsAudioClip;
|
||||
PLID=0000000000000001; existsPlaylist;
|
||||
PLID=0000000000000003; existsPlaylist;
|
||||
}
|
||||
|
||||
prefTest() {
|
||||
PREFKEY="testKey"
|
||||
PREFVAL="test preference value"
|
||||
echo -n "# savePref ($PREFKEY): "
|
||||
$XR_CLI savePref $SESSID "$PREFKEY" "$PREFVAL"|| exit $?
|
||||
echo -n "# loadPref ($PREFKEY): "
|
||||
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \
|
||||
{ ERN=$?; echo $VAL; exit $ERN; }
|
||||
echo "$VAL "
|
||||
if [ "x$VAL" != "x$PREFVAL" ] ; then
|
||||
echo " NOT MATCH"
|
||||
echo " Expected:"; echo $PREFVAL
|
||||
echo " Returned:"; echo $VAL
|
||||
exit 1
|
||||
else
|
||||
echo "# pref value check: OK"
|
||||
fi
|
||||
echo -n "# delPref: "
|
||||
$XR_CLI delPref $SESSID "$PREFKEY"|| exit $?
|
||||
if [ $DEBUG ]; then
|
||||
echo -n "# loadPref: "
|
||||
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || echo $?
|
||||
else
|
||||
echo $VAL
|
||||
fi
|
||||
}
|
||||
|
||||
groupPrefTest() {
|
||||
PREFKEY="Station frequency"
|
||||
PREFVAL="89.5 FM"
|
||||
GR="StationPrefs"
|
||||
echo -n "# saveGroupPref ($PREFKEY): "
|
||||
$XR_CLI saveGroupPref $SESSID "$GR" "$PREFKEY" "$PREFVAL"|| exit $?
|
||||
echo -n "# loadGroupPref ($PREFKEY): "
|
||||
VAL=`$XR_CLI loadGroupPref $SESSID "$GR" "$PREFKEY"` || \
|
||||
{ ERN=$?; echo $VAL; exit $ERN; }
|
||||
echo "$VAL "
|
||||
if [ "x$VAL" != "x$PREFVAL" ] ; then
|
||||
echo " NOT MATCH"
|
||||
echo " Expected:"; echo $PREFVAL
|
||||
echo " Returned:"; echo $VAL
|
||||
exit 1
|
||||
else
|
||||
echo "# pref value check: OK"
|
||||
fi
|
||||
echo -n "# saveGroupPref (clear it): "
|
||||
$XR_CLI saveGroupPref $SESSID "$GR" "$PREFKEY" ""|| exit $?
|
||||
}
|
||||
|
||||
logout() {
|
||||
echo -n "# logout: "
|
||||
$XR_CLI logout $SESSID || exit $?
|
||||
}
|
||||
|
||||
searchTest() {
|
||||
echo "#XMLRPC search test"
|
||||
login
|
||||
storeAudioClip
|
||||
GUNID=$RGUNID
|
||||
searchMetadata
|
||||
OK="AC(1): $GUNID | PL(0): "
|
||||
if [ "$RES" == "$OK" ]; then
|
||||
echo "match: OK"
|
||||
else
|
||||
echo "results doesn't match ($OK)"; deleteAudioClip; exit 1;
|
||||
fi
|
||||
browseCategory
|
||||
OK="RES(1): Media title testRunner"
|
||||
if [ "$RES" == "$OK" ]; then
|
||||
echo "match: OK"
|
||||
else
|
||||
echo "results doesn't match ($OK)"; deleteAudioClip; exit 1;
|
||||
fi
|
||||
deleteAudioClip
|
||||
logout
|
||||
echo "#XMLRPC: search: OK."
|
||||
echo ""
|
||||
}
|
||||
|
||||
preferenceTest(){
|
||||
echo "#XMLRPC preference test"
|
||||
login
|
||||
prefTest
|
||||
groupPrefTest
|
||||
logout
|
||||
echo "#XMLRPC: preference: OK."
|
||||
echo ""
|
||||
}
|
||||
|
||||
playlistTest(){
|
||||
echo "#XMLRPC playlists test"
|
||||
login
|
||||
existsPlaylist
|
||||
deletePlaylist
|
||||
createPlaylist
|
||||
existsPlaylist
|
||||
accessPlaylist
|
||||
editPlaylist
|
||||
accessPlaylist
|
||||
exportPlaylist
|
||||
importPlaylist
|
||||
deletePlaylist
|
||||
existsPlaylist
|
||||
logout
|
||||
echo "#XMLRPC: playlists: OK."
|
||||
echo ""
|
||||
}
|
||||
|
||||
webstreamTest(){
|
||||
echo "#XMLRPC webstream test"
|
||||
login
|
||||
storeWebstream; GUNID=$RGUNID
|
||||
# GUNID="4e58a66cf6e9f539"
|
||||
# downloadMeta
|
||||
getAudioClip
|
||||
deleteAudioClip
|
||||
logout
|
||||
echo "#XMLRPC: webstream: OK."
|
||||
echo ""
|
||||
}
|
||||
|
||||
storageTest(){
|
||||
echo "#XMLRPC: storage test"
|
||||
login
|
||||
storeAudioClip
|
||||
GUNID=$RGUNID
|
||||
existsAudioClip
|
||||
accessRawAudioData
|
||||
downloadRAD
|
||||
downloadMeta
|
||||
deleteAudioClip
|
||||
existsAudioClip
|
||||
logout
|
||||
echo "#XMLRPC: storage: OK."
|
||||
echo ""
|
||||
}
|
||||
|
||||
usage(){
|
||||
echo "Usage: $0 [<command>] [args]"
|
||||
echo -e "commands:\n test\n existsAudioClip\n accessRawAudioData"
|
||||
echo -e " storeAudioClip\n deleteAudioClip\n updateAudioClipMetadata"
|
||||
echo -e " getAudioClip\n searchMetadata\n"
|
||||
echo -e " preferences\n playlists\n storage\n"
|
||||
}
|
||||
|
||||
if [ "$COMM" = "test" ]; then
|
||||
login
|
||||
test
|
||||
logout
|
||||
elif [ "$COMM" = "existsAudioClip" ]; then
|
||||
login
|
||||
existsAudioClip
|
||||
logout
|
||||
elif [ "$COMM" = "accessRawAudioData" ]; then
|
||||
login
|
||||
accessRawAudioData
|
||||
logout
|
||||
elif [ "$COMM" = "storeAudioClip" ]; then
|
||||
login
|
||||
storeAudioClip
|
||||
logout
|
||||
elif [ "$COMM" = "deleteAudioClip" ]; then
|
||||
login
|
||||
deleteAudioClip
|
||||
logout
|
||||
elif [ "$COMM" = "updateAudioClipMetadata" ]; then
|
||||
login
|
||||
updateAudioClipMetadata
|
||||
logout
|
||||
elif [ "$COMM" = "getAudioClip" ]; then
|
||||
login
|
||||
getAudioClip
|
||||
logout
|
||||
elif [ "$COMM" = "searchMetadata" ]; then
|
||||
searchTest
|
||||
elif [ "$COMM" = "preferences" ]; then
|
||||
preferenceTest
|
||||
elif [ "$COMM" = "playlists" ]; then
|
||||
playlistTest
|
||||
elif [ "$COMM" = "webstream" ]; then
|
||||
webstreamTest
|
||||
elif [ "$COMM" = "storage" ]; then
|
||||
storageTest
|
||||
elif [ "x$COMM" = "x" ]; then
|
||||
storageTest
|
||||
playlistTest
|
||||
preferenceTest
|
||||
searchTest
|
||||
elif [ "$COMM" = "help" ]; then
|
||||
usage
|
||||
else
|
||||
echo "Unknown command"
|
||||
usage
|
||||
fi
|
7
backend/xmlrpc/urldecode
Executable file
7
backend/xmlrpc/urldecode
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/php -q
|
||||
<?
|
||||
$fp = fopen("/dev/stdin", "r");
|
||||
$data = '';
|
||||
while($part = fgets($fp, 1024)) $data .= $part;
|
||||
echo urldecode($data);
|
||||
?>
|
172
backend/xmlrpc/xrLocStor.php
Normal file
172
backend/xmlrpc/xrLocStor.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/* ====================================================== specific PHP config */
|
||||
ini_set("mbstring.internal_encoding", 'UTF-8');
|
||||
ini_set("html_errors", FALSE);
|
||||
ini_set("error_prepend_string", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<methodResponse>
|
||||
<fault>
|
||||
<value>
|
||||
<struct>
|
||||
<member>
|
||||
<name>faultCode</name>
|
||||
<value><int>804</int></value>
|
||||
</member>
|
||||
<member>
|
||||
<name>faultString</name>
|
||||
<value><string>");
|
||||
ini_set("error_append_string", "</string></value>
|
||||
</member>
|
||||
</struct>
|
||||
</value>
|
||||
</fault>
|
||||
</methodResponse>");
|
||||
header("Content-type: text/xml");
|
||||
|
||||
/* ================================================================= includes */
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once("XML/RPC/Server.php");
|
||||
require_once('XR_LocStor.php');
|
||||
|
||||
/* ============================================ setting default error handler */
|
||||
function errHndl($errno, $errmsg, $filename, $linenum, $vars)
|
||||
{
|
||||
switch ($errno) {
|
||||
case E_WARNING:
|
||||
case E_NOTICE:
|
||||
case E_USER_WARNING:
|
||||
case E_USER_NOTICE:
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
$xr = new XML_RPC_Response(0, 805,
|
||||
htmlspecialchars("ERROR:xrLocStor: $errno $errmsg ($filename:$linenum)"));
|
||||
header("Content-type: text/xml");
|
||||
echo $xr->serialize();
|
||||
exit($errno);
|
||||
}
|
||||
}
|
||||
$old_error_handler = set_error_handler("errHndl", E_ALL);
|
||||
|
||||
/* ============================================================= runable code */
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
trigger_error("DB::connect: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo(),E_USER_ERROR);
|
||||
}
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$locStor = new XR_LocStor();
|
||||
|
||||
$methods = array(
|
||||
'test' => 'Tests toupper and checks sessid, params: '.
|
||||
'teststring, sessid.',
|
||||
'getVersion' => 'Get version of Campcaster.',
|
||||
// 'authenticate' => 'Checks authentication.',
|
||||
'login' => 'Login to storage.',
|
||||
'logout' => 'Logout from storage.',
|
||||
'existsAudioClip' => 'Checks if an audio clip with the specified '.
|
||||
'id is stored in local storage.',
|
||||
'storeAudioClipOpen' => 'Open channel to store a new audio clip '.
|
||||
'or replace an existing one.',
|
||||
'storeAudioClipClose' => 'Close channel to store a new audio clip'.
|
||||
' or replace an existing one.',
|
||||
'downloadRawAudioDataOpen'=> 'Create and return downloadable URL'.
|
||||
'for audio file',
|
||||
'downloadRawAudioDataClose'=>'Discard downloadable URL for audio file',
|
||||
'downloadMetadataOpen' => 'Create and return downloadable URL'.
|
||||
'for metadata',
|
||||
'downloadMetadataClose' => 'Discard downloadable URL for metadata',
|
||||
'openPut' => 'openPut',
|
||||
'closePut' => 'closePut',
|
||||
'deleteAudioClip' => 'Delete an existing Audio clip.',
|
||||
'updateAudioClipMetadata' => 'Update the metadata of an Audio clip '.
|
||||
'stored in Local storage.',
|
||||
'searchMetadata' => 'Search through the metadata of stored '.
|
||||
'files, return all matching clip ids.',
|
||||
'browseCategory' =>'Return values of specified metadata category.',
|
||||
'accessRawAudioData' => 'Get access to raw audio data.',
|
||||
'releaseRawAudioData' => 'Release access to raw audio data.',
|
||||
'getAudioClip' => 'Return the contents of an Audio clip.',
|
||||
// 'resetStorage' => 'Reset storageServer for debugging.',
|
||||
'storeWebstream' => 'Store audio stream identified by URL',
|
||||
|
||||
'createPlaylist' => 'Create a new Playlist metafile.',
|
||||
'editPlaylist' => 'Open a Playlist metafile for editing.',
|
||||
'savePlaylist' => 'Save a Playlist metafile.',
|
||||
'revertEditedPlaylist' => 'RollBack playlist changes to the locked state.',
|
||||
'deletePlaylist' => 'Delete a Playlist metafile.',
|
||||
'accessPlaylist' => 'Open readable URL to a Playlist metafile.',
|
||||
'releasePlaylist' => 'Release readable URL from accessPlaylist.',
|
||||
'existsPlaylist' => 'Check whether a Playlist exists.',
|
||||
'playlistIsAvailable' => 'Check whether a Playlist is available '.
|
||||
'for editing.',
|
||||
'exportPlaylistOpen' => 'Create a tarfile with playlist export.',
|
||||
'exportPlaylistClose' => 'Close playlist export.',
|
||||
'importPlaylistOpen' => 'Open writable handle for playlist import.',
|
||||
'importPlaylistClose' => 'Close import-handle and import playlist.',
|
||||
|
||||
'renderPlaylistToFileOpen' => 'Render playlist to ogg file (open handle)',
|
||||
'renderPlaylistToFileCheck' => 'Render playlist to ogg file (check results)',
|
||||
'renderPlaylistToFileClose' => 'Render playlist to ogg file (close handle)',
|
||||
|
||||
'renderPlaylistToStorageOpen' => 'Render playlist to storage media clip (open handle)',
|
||||
'renderPlaylistToStorageCheck' => 'Render playlist to storage media clip (check results)',
|
||||
|
||||
'renderPlaylistToRSSOpen' => 'Render playlist to RSS file (open handle)',
|
||||
'renderPlaylistToRSSCheck' => 'Render playlist to RSS file (check results)',
|
||||
'renderPlaylistToRSSClose' => 'Render playlist to RSS file (close handle)',
|
||||
|
||||
'createBackupOpen' => 'Create backup of storage (open handle)',
|
||||
'createBackupCheck' => 'Create backup of storage (check results)',
|
||||
'createBackupClose' => 'Create backup of storage (close handle)',
|
||||
|
||||
'restoreBackupOpen' => 'Restore a backup file (open handle)',
|
||||
'restoreBackupClosePut' => 'Restore a backup file (close PUT handle)',
|
||||
'restoreBackupCheck' => 'Restore a backup file (check results)',
|
||||
'restoreBackupClose' => 'Restore a backup file (close handle)',
|
||||
|
||||
'loadPref' => 'Load user preference value.',
|
||||
'savePref' => 'Save user preference value.',
|
||||
'delPref' => 'Delete user preference record.',
|
||||
'loadGroupPref' => 'Read group preference record.',
|
||||
'saveGroupPref' => 'Delete user preference record.',
|
||||
|
||||
'getTransportInfo' => 'Common "check" method and info getter for transports',
|
||||
'turnOnOffTransports' => 'Turn transports on/off, optionaly return current state',
|
||||
'doTransportAction' => 'Pause, resume or cancel transport',
|
||||
'uploadFile2Hub' => 'Open async file transfer from local storageServer to network hub',
|
||||
'getHubInitiatedTransfers' => 'Get list of prepared transfers initiated by hub',
|
||||
'startHubInitiatedTransfer' => 'Start of download initiated by hub',
|
||||
'upload2Hub' => 'Start upload of audioclip or playlist from local storageServer to hub',
|
||||
'downloadFromHub' => 'Start download of audioclip or playlist from hub to local storageServer',
|
||||
// 'globalSearch' => 'Start search job on network hub',
|
||||
// 'getSearchResults' => 'Get results from search job on network hub',
|
||||
|
||||
'uploadOpen' => 'Open file-layer upload',
|
||||
'uploadCheck' => 'Check the checksum of uploaded file',
|
||||
'uploadClose' => 'Close file-layer upload',
|
||||
'downloadOpen' => 'Open file-layer download',
|
||||
// 'downloadCheck' => 'Check the checksum of downloaded file',
|
||||
'downloadClose' => 'Close file-layer download',
|
||||
'prepareHubInitiatedTransfer' => 'Prepare hub initiated transfer',
|
||||
'listHubInitiatedTransfers' => 'List hub initiated transfers',
|
||||
'setHubInitiatedTransfer' => 'Set state of hub initiated transfers',
|
||||
'ping' => 'Echo request',
|
||||
);
|
||||
|
||||
$defs = array();
|
||||
foreach ($methods as $method => $description) {
|
||||
$defs["locstor.$method"] = array(
|
||||
"function" => array(&$locStor, "xr_$method"),
|
||||
// NOTE: the way this signature is set up, every function must take at least one parameter!
|
||||
"signature" => array(
|
||||
array($GLOBALS['XML_RPC_Struct'], $GLOBALS['XML_RPC_Struct'])
|
||||
),
|
||||
"docstring" => $description
|
||||
);
|
||||
}
|
||||
|
||||
$s = new XML_RPC_Server($defs);
|
||||
|
||||
?>
|
368
backend/xmlrpc/xr_cli_test.php
Normal file
368
backend/xmlrpc/xr_cli_test.php
Normal file
|
@ -0,0 +1,368 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
include_once("XML/RPC.php");
|
||||
include_once("Console/Getopt.php");
|
||||
|
||||
function printUsage()
|
||||
{
|
||||
echo "Usage:\n";
|
||||
echo " -v Verbose output\n";
|
||||
echo " -s arg Server Path\n";
|
||||
echo " -o arg1:value1,arg2:value2 Function Arguments\n";
|
||||
echo " -h Help\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
$verbose = TRUE;
|
||||
$parsedCommandLine = Console_Getopt::getopt($argv, "vs:o:h");
|
||||
$options = null;
|
||||
$cmdLineOptions = $parsedCommandLine[0];
|
||||
|
||||
if (count($parsedCommandLine[1]) == 0) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$method = array_pop($parsedCommandLine[1]);
|
||||
|
||||
foreach ($cmdLineOptions as $tmpValue) {
|
||||
$optionName = $tmpValue[0];
|
||||
$optionValue = $tmpValue[1];
|
||||
switch ($optionName) {
|
||||
case "h":
|
||||
printUsage();
|
||||
exit;
|
||||
case "v":
|
||||
$verbose = TRUE;
|
||||
break;
|
||||
case "s":
|
||||
$serverPath = $optionValue;
|
||||
break;
|
||||
case "o":
|
||||
$optStr = $optionValue;
|
||||
$optArr = split(",", $optStr);
|
||||
foreach ($optArr as $opt) {
|
||||
list($k, $v) = split(':', $opt);
|
||||
$options[$k] = $v;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($serverPath)) {
|
||||
$serverPath =
|
||||
"http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}";
|
||||
}
|
||||
|
||||
$url = parse_url($serverPath);
|
||||
$client = new XML_RPC_Client($url['path'], $url['host']);
|
||||
|
||||
if ($verbose) {
|
||||
$client->debug = 1;
|
||||
echo "ServerPath: $serverPath\n";
|
||||
echo "Host: {$url['host']}, path: {$url['path']}\n";
|
||||
echo "Method: $method\n";
|
||||
echo "Parameters:\n";
|
||||
//var_dump($pars);
|
||||
}
|
||||
|
||||
$infos = array(
|
||||
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL),
|
||||
"methodHelp" => array('m'=>"system.methodHelp", 'p'=>0),
|
||||
"methodSignature" => array('m'=>"system.methodSignature", 'p'=>0),
|
||||
"test" => array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')),
|
||||
"ping" => array('m'=>"locstor.ping", 'p'=>array("par")),
|
||||
"getVersion" => array('m'=>"locstor.getVersion", 'p'=>array("str"), 'r'=>'version'),
|
||||
"authenticate" => array('m'=>"locstor.authenticate", 'p'=>array('login', 'pass'), 'r'=>'authenticate'),
|
||||
"login" => array('m'=>"locstor.login", 'p'=>array('login', 'pass'), 'r'=>'sessid'),
|
||||
"logout" => array('m'=>"locstor.logout", 'p'=>array('sessid'), 'r'=>'status'),
|
||||
"storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen",
|
||||
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'),
|
||||
'r'=>array('url', 'token')
|
||||
),
|
||||
"storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
"accessRawAudioData" => array('m'=>"locstor.accessRawAudioData",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData",
|
||||
'p'=>array('token'), 'r'=>'status'),
|
||||
"downloadRawAudioDataOpen" =>
|
||||
array('m'=>"locstor.downloadRawAudioDataOpen",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"downloadRawAudioDataClose" =>
|
||||
array('m'=>"locstor.downloadRawAudioDataClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
"downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
|
||||
"deleteAudioClip" =>
|
||||
array('m'=>"locstor.deleteAudioClip",
|
||||
'p'=>array('sessid', 'gunid', 'forced'), 'r'=>'status'),
|
||||
"existsAudioClip" => array('m'=>"locstor.existsAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'exists'),
|
||||
"getAudioClip" => array('m'=>"locstor.getAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'metadata'),
|
||||
"updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
|
||||
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
|
||||
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
|
||||
"browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
|
||||
// "resetStorage" => array('m'=>"locstor.resetStorage",
|
||||
// 'p'=>array()),
|
||||
# 'p'=>array('loadSampleData', 'invalidateSessionIds')),
|
||||
"storeWebstream" => array('m'=>"locstor.storeWebstream",
|
||||
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'),
|
||||
'r'=>array('gunid')
|
||||
),
|
||||
|
||||
"createPlaylist" => array('m'=>"locstor.createPlaylist",
|
||||
'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'),
|
||||
"editPlaylist" => array('m'=>"locstor.editPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
|
||||
"savePlaylist" => array('m'=>"locstor.savePlaylist",
|
||||
'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'),
|
||||
"revertEditedPlaylist" => array('m'=>"locstor.revertEditedPlaylist",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'plid'),
|
||||
"deletePlaylist" => array('m'=>"locstor.deletePlaylist",
|
||||
'p'=>array('sessid', 'plid', 'forced'), 'r'=>'status'),
|
||||
"accessPlaylist" => array('m'=>"locstor.accessPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
|
||||
"releasePlaylist" => array('m'=>"locstor.releasePlaylist",
|
||||
'p'=>array('token'), 'r'=>'plid'),
|
||||
"existsPlaylist" => array('m'=>"locstor.existsPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>'exists'),
|
||||
"playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')),
|
||||
|
||||
"exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen",
|
||||
'p'=>array('sessid', 'plids', 'type', 'standalone'),
|
||||
'r'=>array('url', 'token')),
|
||||
"exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"importPlaylistOpen" => array('m'=>"locstor.importPlaylistOpen",
|
||||
'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')),
|
||||
"importPlaylistClose" => array('m'=>"locstor.importPlaylistClose",
|
||||
'p'=>array('token'), 'r'=>array('gunid')),
|
||||
|
||||
"renderPlaylistToFileOpen" => array('m'=>"locstor.renderPlaylistToFileOpen",
|
||||
'p'=>array('sessid', 'plid'),
|
||||
'r'=>array('token')),
|
||||
"renderPlaylistToFileCheck" => array('m'=>"locstor.renderPlaylistToFileCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'url')),
|
||||
"renderPlaylistToFileClose" => array('m'=>"locstor.renderPlaylistToFileClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"renderPlaylistToStorageOpen" => array('m'=>"locstor.renderPlaylistToStorageOpen",
|
||||
'p'=>array('sessid', 'plid'),
|
||||
'r'=>array('token')),
|
||||
"renderPlaylistToStorageCheck" => array('m'=>"locstor.renderPlaylistToStorageCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'gunid')),
|
||||
"renderPlaylistToRSSOpen" => array('m'=>"locstor.renderPlaylistToRSSOpen",
|
||||
'p'=>array('sessid', 'plid'),
|
||||
'r'=>array('token')),
|
||||
"renderPlaylistToRSSCheck" => array('m'=>"locstor.renderPlaylistToRSSCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'url')),
|
||||
"renderPlaylistToRSSClose" => array('m'=>"locstor.renderPlaylistToRSSClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
|
||||
"loadPref" => array('m'=>"locstor.loadPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'value'),
|
||||
"savePref" => array('m'=>"locstor.savePref",
|
||||
'p'=>array('sessid', 'key', 'value'), 'r'=>'status'),
|
||||
"delPref" => array('m'=>"locstor.delPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'status'),
|
||||
"loadGroupPref" => array('m'=>"locstor.loadGroupPref",
|
||||
'p'=>array('sessid', 'group', 'key'), 'r'=>'value'),
|
||||
"saveGroupPref" => array('m'=>"locstor.saveGroupPref",
|
||||
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
|
||||
|
||||
"getTransportInfo" => array('m'=>"locstor.getTransportInfo",
|
||||
'p'=>array('trtok'),
|
||||
'r'=>array('state', 'realsize', 'expectedsize', 'realsum', 'expectedsum')),
|
||||
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
|
||||
'p'=>array('sessid', 'onOff'), 'r'=>array('state')),
|
||||
"doTransportAction" => array('m'=>"locstor.doTransportAction",
|
||||
'p'=>array('sessid', 'trtok', 'action'), 'r'=>array('state')),
|
||||
"uploadFile2Hub" => array('m'=>"locstor.uploadFile2Hub",
|
||||
'p'=>array('sessid', 'filePath'), 'r'=>array('trtok')),
|
||||
"getHubInitiatedTransfers" => array('m'=>"locstor.getHubInitiatedTransfers",
|
||||
'p'=>array('sessid'), 'r'=>array()),
|
||||
"startHubInitiatedTransfer" => array('m'=>"locstor.startHubInitiatedTransfer",
|
||||
'p'=>array('trtok'), 'r'=>array()),
|
||||
"upload2Hub" => array('m'=>"locstor.upload2Hub",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
|
||||
"downloadFromHub" => array('m'=>"locstor.downloadFromHub",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
|
||||
// "globalSearch" => array('m'=>"locstor.globalSearch",
|
||||
// 'p'=>array('sessid', 'criteria'), 'r'=>array('trtok')),
|
||||
// "getSearchResults" => array('m'=>"locstor.getSearchResults",
|
||||
// 'p'=>array('trtok')),
|
||||
|
||||
"createBackupOpen" => array('m'=>"locstor.createBackupOpen",
|
||||
'p'=>array('sessid', 'criteria'), 'r'=>array('token')),
|
||||
"createBackupCheck" => array('m'=>"locstor.createBackupCheck",
|
||||
# 'p'=>array('token'), 'r'=>array('status', 'url', 'metafile', 'faultString')),
|
||||
'p'=>array('token'), 'r'=>array('status', 'url', 'tmpfile')),
|
||||
"createBackupClose" => array('m'=>"locstor.createBackupClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"restoreBackupOpen" => array('m'=>"locstor.restoreBackupOpen",
|
||||
'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')),
|
||||
"restoreBackupClosePut" => array('m'=>"locstor.restoreBackupClosePut",
|
||||
'p'=>array('sessid', 'token'), 'r'=>array('token')),
|
||||
"restoreBackupCheck" => array('m'=>"locstor.restoreBackupCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'faultString')),
|
||||
"restoreBackupClose" => array('m'=>"locstor.restoreBackupClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
|
||||
/*
|
||||
"uploadToArchive" => array('m'=>"locstor.uploadToArchive",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'trtok'),
|
||||
"downloadFromArchive" => array('m'=>"locstor.downloadFromArchive",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'trtok'),
|
||||
*/
|
||||
|
||||
"openPut" => array('m'=>"locstor.openPut", 'p'=>array()),
|
||||
"closePut" => array('m'=>"locstor.closePut", 'p'=>array()),
|
||||
);
|
||||
|
||||
|
||||
switch ($method) {
|
||||
case "searchMetadata":
|
||||
// case "globalSearch":
|
||||
case "createBackupOpen":
|
||||
$parr = array(
|
||||
'sessid'=>$pars[0],
|
||||
'criteria'=>array(
|
||||
'filetype'=>'audioclip',
|
||||
'operator'=>'and',
|
||||
'limit'=> 0,
|
||||
'offset'=> 0,
|
||||
'conditions'=>array(
|
||||
array('cat'=>$pars[1], 'op'=>'partial', 'val'=>$pars[2])
|
||||
)
|
||||
),
|
||||
);
|
||||
break;
|
||||
case "browseCategory":
|
||||
$parr = array(
|
||||
'sessid'=>$pars[0],
|
||||
'category'=>$pars[1],
|
||||
'criteria'=>array(
|
||||
'filetype'=>'audioclip',
|
||||
'operator'=>'and',
|
||||
'limit'=> 0,
|
||||
'offset'=> 0,
|
||||
'conditions'=>array(
|
||||
array('cat'=>$pars[2], 'op'=>'partial', 'val'=>$pars[3])
|
||||
)
|
||||
),
|
||||
);
|
||||
break;
|
||||
// case "resetStorage":
|
||||
// $parr = array(
|
||||
// 'loadSampleData'=>(boolean)$pars[0],
|
||||
// 'invalidateSessionIds'=>(boolean)$pars[1],
|
||||
// );
|
||||
// break;
|
||||
default:
|
||||
$pinfo = $infos[$method]['p'];
|
||||
if (is_null($pinfo)) {
|
||||
$parr = NULL;
|
||||
} elseif(!is_array($pinfo)) {
|
||||
$parr = $pars[0];
|
||||
#echo "pinfo not null and not array.\n"; exit;
|
||||
} elseif(count($pinfo) == 0) {
|
||||
$parr = (object)array();
|
||||
} else {
|
||||
$parr = array(); $i=0;
|
||||
foreach($pinfo as $it){
|
||||
if(isset($pars[$i])) $parr[$it] = $pars[$i];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} // switch
|
||||
|
||||
$fullmethod = $infos[$method]['m'];
|
||||
if (is_array($options)) {
|
||||
$msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($options)));
|
||||
} else {
|
||||
$msg = new XML_RPC_Message($fullmethod);
|
||||
}
|
||||
//$msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($parr)));
|
||||
|
||||
if ($verbose) {
|
||||
echo "parr:\n";
|
||||
var_dump($parr);
|
||||
echo "message:\n";
|
||||
echo $msg->serialize()."\n";
|
||||
}
|
||||
|
||||
#$client->setDebug(1);
|
||||
$res = $client->send($msg);
|
||||
if ($res->faultCode() > 0) {
|
||||
echo "xr_cli_test.php: ".$res->faultString()." ".$res->faultCode()."\n";
|
||||
# echo var_export($res);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo "result:\n";
|
||||
echo $res->serialize();
|
||||
}
|
||||
|
||||
$resp = XML_RPC_decode($res->value());
|
||||
if (isset($infos[$method]['r'])) {
|
||||
$pom = $infos[$method]['r'];
|
||||
if (is_array($pom)) {
|
||||
foreach ($pom as $k => $it) {
|
||||
$pom[$k] = $resp[$it];
|
||||
}
|
||||
echo join(' ', $pom)."\n";
|
||||
} else {
|
||||
switch ($pom) {
|
||||
case "status":
|
||||
case "exists":
|
||||
echo ($resp[$pom]=='1' ? "TRUE" : "FALSE" )."\n";
|
||||
break;
|
||||
default:
|
||||
echo "{$resp[$pom]}\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch ($method) {
|
||||
case "searchMetadata":
|
||||
// case "getSearchResults":
|
||||
$acCnt = 0;
|
||||
$acGunids = array();
|
||||
$plCnt = 0;
|
||||
$plGunids = array();
|
||||
$fld = (isset($options['category']) ? $options['category'] : 'gunid' );
|
||||
foreach ($resp['results'] as $k => $v) {
|
||||
if ($v['type']=='audioclip') {
|
||||
$acCnt++;
|
||||
$acGunids[] = $v[$fld];
|
||||
}
|
||||
if ($v['type']=='playlist') {
|
||||
$plCnt++;
|
||||
$plGunids[] = $v[$fld];
|
||||
}
|
||||
}
|
||||
echo "AC({$acCnt}): ".
|
||||
join(", ", $acGunids).
|
||||
" | PL({$plCnt}): ".
|
||||
join(", ", $plGunids).
|
||||
"\n";
|
||||
break;
|
||||
case "browseCategory":
|
||||
echo "RES({$resp['cnt']}): ".
|
||||
join(", ", $resp['results']).
|
||||
"\n";
|
||||
break;
|
||||
default:
|
||||
print_r($resp);
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
373
backend/xmlrpc/xr_web_test.php
Normal file
373
backend/xmlrpc/xr_web_test.php
Normal file
|
@ -0,0 +1,373 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
include_once("XML/RPC.php");
|
||||
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* Get a persistant value. If the value is present in the $_REQUEST
|
||||
* array, the session variable will be set to this value and returned.
|
||||
* If the value is not yet set, it will be set to the default value.
|
||||
* In all other cases the value from the session variable is returned.
|
||||
*
|
||||
* @param string $p_name
|
||||
* @param mixed $p_defaultValue
|
||||
* @return mixed
|
||||
*/
|
||||
function camp_session_get($p_name, $p_defaultValue)
|
||||
{
|
||||
// Use the REQUEST variable if it is set.
|
||||
if (isset($_REQUEST[$p_name])) {
|
||||
$_SESSION[$p_name] = $_REQUEST[$p_name];
|
||||
}
|
||||
elseif (!isset($_SESSION[$p_name])) {
|
||||
$_SESSION[$p_name] = $p_defaultValue;
|
||||
}
|
||||
return $_SESSION[$p_name];
|
||||
} // fn camp_session_get
|
||||
|
||||
|
||||
/**
|
||||
* Print out an HTML OPTION element.
|
||||
*
|
||||
* @param string $p_value
|
||||
* @param string $p_selectedValue
|
||||
* @param string $p_printValue
|
||||
* @return boolean
|
||||
* Return TRUE if the option is selected, FALSE if not.
|
||||
*/
|
||||
function camp_html_select_option($p_value, $p_selectedValue, $p_printValue)
|
||||
{
|
||||
$selected = false;
|
||||
$str = '<OPTION VALUE="'.htmlspecialchars($p_value, ENT_QUOTES).'"';
|
||||
if (!strcmp($p_value, $p_selectedValue)) {
|
||||
$str .= ' SELECTED';
|
||||
$selected = true;
|
||||
}
|
||||
$str .= '>'.htmlspecialchars($p_printValue)."</OPTION>\n";
|
||||
echo $str;
|
||||
return $selected;
|
||||
} // fn camp_html_select_option
|
||||
|
||||
|
||||
$serverPath =
|
||||
"http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}";
|
||||
$serverPath = camp_session_get("storageserver_xmlrpc_path", $serverPath);
|
||||
$f_selectedMethod = camp_session_get("f_selectedMethod", "listMethods");
|
||||
$url = parse_url($serverPath);
|
||||
$client = new XML_RPC_Client($url['path'], $url['host']);
|
||||
|
||||
$methodDefs = array(
|
||||
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL),
|
||||
"methodHelp" => array('m'=>"system.methodHelp", 'p'=>0),
|
||||
"methodSignature" => array('m'=>"system.methodSignature", 'p'=>0),
|
||||
"test" => array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')),
|
||||
"getVersion" => array('m'=>"locstor.getVersion", 'p'=>array(), 'r'=>'version'),
|
||||
"authenticate" => array('m'=>"locstor.authenticate", 'p'=>array('login', 'pass'), 'r'=>'authenticate'),
|
||||
"login" => array('m'=>"locstor.login", 'p'=>array('login', 'pass'), 'r'=>'sessid'),
|
||||
"logout" => array('m'=>"locstor.logout", 'p'=>array('sessid'), 'r'=>'status'),
|
||||
"storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen",
|
||||
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'),
|
||||
'r'=>array('url', 'token')
|
||||
),
|
||||
"storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
"accessRawAudioData" => array('m'=>"locstor.accessRawAudioData",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData",
|
||||
'p'=>array('token'), 'r'=>'status'),
|
||||
"downloadRawAudioDataOpen" =>
|
||||
array('m'=>"locstor.downloadRawAudioDataOpen",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"downloadRawAudioDataClose" =>
|
||||
array('m'=>"locstor.downloadRawAudioDataClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
"downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
|
||||
"deleteAudioClip" =>
|
||||
array('m'=>"locstor.deleteAudioClip",
|
||||
'p'=>array('sessid', 'gunid', 'forced'), 'r'=>'status'),
|
||||
"existsAudioClip" => array('m'=>"locstor.existsAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'exists'),
|
||||
"getAudioClip" => array('m'=>"locstor.getAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'metadata'),
|
||||
"updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
|
||||
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
|
||||
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
|
||||
"browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
|
||||
// "resetStorage" => array('m'=>"locstor.resetStorage",
|
||||
// 'p'=>array()),
|
||||
"storeWebstream" => array('m'=>"locstor.storeWebstream",
|
||||
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'),
|
||||
'r'=>array('gunid')
|
||||
),
|
||||
|
||||
"createPlaylist" => array('m'=>"locstor.createPlaylist",
|
||||
'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'),
|
||||
"editPlaylist" => array('m'=>"locstor.editPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
|
||||
"savePlaylist" => array('m'=>"locstor.savePlaylist",
|
||||
'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'),
|
||||
"revertEditedPlaylist" => array('m'=>"locstor.revertEditedPlaylist",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'plid'),
|
||||
"deletePlaylist" => array('m'=>"locstor.deletePlaylist",
|
||||
'p'=>array('sessid', 'plid', 'forced'), 'r'=>'status'),
|
||||
"accessPlaylist" => array('m'=>"locstor.accessPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
|
||||
"releasePlaylist" => array('m'=>"locstor.releasePlaylist",
|
||||
'p'=>array('token'), 'r'=>'plid'),
|
||||
"existsPlaylist" => array('m'=>"locstor.existsPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>'exists'),
|
||||
"playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')),
|
||||
|
||||
"exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen",
|
||||
'p'=>array('sessid', 'plids', 'type', 'standalone'),
|
||||
'r'=>array('url', 'token')),
|
||||
"exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"importPlaylistOpen" => array('m'=>"locstor.importPlaylistOpen",
|
||||
'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')),
|
||||
"importPlaylistClose" => array('m'=>"locstor.importPlaylistClose",
|
||||
'p'=>array('token'), 'r'=>array('gunid')),
|
||||
|
||||
"renderPlaylistToFileOpen" => array('m'=>"locstor.renderPlaylistToFileOpen",
|
||||
'p'=>array('sessid', 'plid'),
|
||||
'r'=>array('token')),
|
||||
"renderPlaylistToFileCheck" => array('m'=>"locstor.renderPlaylistToFileCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'url')),
|
||||
"renderPlaylistToFileClose" => array('m'=>"locstor.renderPlaylistToFileClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"renderPlaylistToStorageOpen" => array('m'=>"locstor.renderPlaylistToStorageOpen",
|
||||
'p'=>array('sessid', 'plid'),
|
||||
'r'=>array('token')),
|
||||
"renderPlaylistToStorageCheck" => array('m'=>"locstor.renderPlaylistToStorageCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'gunid')),
|
||||
"renderPlaylistToRSSOpen" => array('m'=>"locstor.renderPlaylistToRSSOpen",
|
||||
'p'=>array('sessid', 'plid'),
|
||||
'r'=>array('token')),
|
||||
"renderPlaylistToRSSCheck" => array('m'=>"locstor.renderPlaylistToRSSCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'url')),
|
||||
"renderPlaylistToRSSClose" => array('m'=>"locstor.renderPlaylistToRSSClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
|
||||
"loadPref" => array('m'=>"locstor.loadPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'value'),
|
||||
"savePref" => array('m'=>"locstor.savePref",
|
||||
'p'=>array('sessid', 'key', 'value'), 'r'=>'status'),
|
||||
"delPref" => array('m'=>"locstor.delPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'status'),
|
||||
"loadGroupPref" => array('m'=>"locstor.loadGroupPref",
|
||||
'p'=>array('sessid', 'group', 'key'), 'r'=>'value'),
|
||||
"saveGroupPref" => array('m'=>"locstor.saveGroupPref",
|
||||
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
|
||||
|
||||
"getTransportInfo" => array('m'=>"locstor.getTransportInfo",
|
||||
'p'=>array('trtok'),
|
||||
'r'=>array('state', 'realsize', 'expectedsize', 'realsum', 'expectedsum')),
|
||||
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
|
||||
'p'=>array('sessid', 'onOff'), 'r'=>array('state')),
|
||||
"doTransportAction" => array('m'=>"locstor.doTransportAction",
|
||||
'p'=>array('sessid', 'trtok', 'action'), 'r'=>array('state')),
|
||||
"uploadFile2Hub" => array('m'=>"locstor.uploadFile2Hub",
|
||||
'p'=>array('sessid', 'filePath'), 'r'=>array('trtok')),
|
||||
"getHubInitiatedTransfers" => array('m'=>"locstor.getHubInitiatedTransfers",
|
||||
'p'=>array('sessid'), 'r'=>array()),
|
||||
"startHubInitiatedTransfer" => array('m'=>"locstor.startHubInitiatedTransfer",
|
||||
'p'=>array('trtok'), 'r'=>array()),
|
||||
"upload2Hub" => array('m'=>"locstor.upload2Hub",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
|
||||
"downloadFromHub" => array('m'=>"locstor.downloadFromHub",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
|
||||
// "globalSearch" => array('m'=>"locstor.globalSearch",
|
||||
// 'p'=>array('sessid', 'criteria'), 'r'=>array('trtok')),
|
||||
// "getSearchResults" => array('m'=>"locstor.getSearchResults",
|
||||
// 'p'=>array('trtok')),
|
||||
|
||||
"createBackupOpen" => array('m'=>"locstor.createBackupOpen",
|
||||
'p'=>array('sessid', 'criteria'), 'r'=>array('token')),
|
||||
"createBackupCheck" => array('m'=>"locstor.createBackupCheck",
|
||||
# 'p'=>array('token'), 'r'=>array('status', 'url', 'metafile', 'faultString')),
|
||||
'p'=>array('token'), 'r'=>array('status', 'url', 'tmpfile')),
|
||||
"createBackupClose" => array('m'=>"locstor.createBackupClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"restoreBackupOpen" => array('m'=>"locstor.restoreBackupOpen",
|
||||
'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')),
|
||||
"restoreBackupClosePut" => array('m'=>"locstor.restoreBackupClosePut",
|
||||
'p'=>array('sessid', 'token'), 'r'=>array('token')),
|
||||
"restoreBackupCheck" => array('m'=>"locstor.restoreBackupCheck",
|
||||
'p'=>array('token'), 'r'=>array('status', 'faultString')),
|
||||
"restoreBackupClose" => array('m'=>"locstor.restoreBackupClose",
|
||||
'p'=>array('token'), 'r'=>array('status')),
|
||||
"openPut" => array('m'=>"locstor.openPut", 'p'=>array()),
|
||||
"closePut" => array('m'=>"locstor.closePut", 'p'=>array()),
|
||||
);
|
||||
|
||||
if (isset($_REQUEST['go_button'])) {
|
||||
// Get the parameters
|
||||
$methodParams = $methodDefs[$f_selectedMethod]['p'];
|
||||
foreach ($methodParams as $methodParamName) {
|
||||
$inputParamName = "param_".$methodParamName;
|
||||
$xmlParameters[$methodParamName] = $_REQUEST[$inputParamName];
|
||||
$_SESSION[$inputParamName] = $_REQUEST[$inputParamName];
|
||||
}
|
||||
|
||||
// Create the XML-RPC message
|
||||
$actualMethod = $methodDefs[$f_selectedMethod]['m'];
|
||||
$msg = new XML_RPC_Message($actualMethod, array(XML_RPC_encode($xmlParameters)));
|
||||
$sentMessage = $msg->serialize();
|
||||
|
||||
// Send it
|
||||
$sendResult = $client->send($msg);
|
||||
if ($sendResult->faultCode() > 0) {
|
||||
$errorMsg = "xr_cli_test.php: ".$sendResult->faultString()." ".$sendResult->faultCode()."\n";
|
||||
} else {
|
||||
// If successful
|
||||
$xmlResponse = XML_RPC_decode($sendResult->value());
|
||||
|
||||
// Special case state handling
|
||||
switch ($f_selectedMethod) {
|
||||
case "login":
|
||||
// Remember the login session ID so we can use it to call
|
||||
// other methods.
|
||||
$loggedIn = true;
|
||||
$_SESSION['xmlrpc_session_id'] = $xmlResponse['sessid'];
|
||||
break;
|
||||
case "logout":
|
||||
unset($_SESSION['xmlrpc_session_id']);
|
||||
break;
|
||||
case "storeAudioClipOpen":
|
||||
$_SESSION['xmlrpc_token'] = $xmlResponse['token'];
|
||||
$_SESSION['xmlrpc_put_url'] = $xmlResponse['url'];
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($methodDefs[$method]['r'])) {
|
||||
$expectedResult = $methodDefs[$method]['r'];
|
||||
if (is_array($expectedResult)) {
|
||||
foreach ($expectedResult as $resultName) {
|
||||
$actualResults[$resultName] = $xmlResponse[$resultName];
|
||||
}
|
||||
echo join(' ', $actualResults)."\n";
|
||||
} else {
|
||||
switch ($expectedResult) {
|
||||
case "status":
|
||||
case "exists":
|
||||
echo ($xmlResponse[$expectedResult]=='1' ? "TRUE" : "FALSE" )."\n";
|
||||
break;
|
||||
default:
|
||||
echo "{$xmlResponse[$expectedResult]}\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch ($method) {
|
||||
case "searchMetadata":
|
||||
// case "getSearchResults":
|
||||
$acCnt = 0;
|
||||
$acGunids = array();
|
||||
$plCnt = 0;
|
||||
$plGunids = array();
|
||||
$fld = (isset($options['category']) ? $options['category'] : 'gunid' );
|
||||
foreach ($xmlResponse['results'] as $k => $v) {
|
||||
if ($v['type']=='audioclip') {
|
||||
$acCnt++;
|
||||
$acGunids[] = $v[$fld];
|
||||
}
|
||||
if ($v['type']=='playlist') {
|
||||
$plCnt++;
|
||||
$plGunids[] = $v[$fld];
|
||||
}
|
||||
}
|
||||
echo "AC({$acCnt}): ".
|
||||
join(", ", $acGunids).
|
||||
" | PL({$plCnt}): ".
|
||||
join(", ", $plGunids).
|
||||
"\n";
|
||||
break;
|
||||
case "browseCategory":
|
||||
echo "RES({$xmlResponse['cnt']}): ".
|
||||
join(", ", $xmlResponse['results']).
|
||||
"\n";
|
||||
break;
|
||||
default:
|
||||
//print_r($xmlResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<body bgcolor="#dddddd">
|
||||
<form>
|
||||
StorageServer path : <INPUT type="text" name="f_storageserver_xmlrpc_path" value="<?php echo $serverPath; ?>" size="100"><br>
|
||||
Method:
|
||||
<select name="f_selectedMethod" onchange="this.form.submit();">
|
||||
<?php
|
||||
foreach ($methodDefs as $methodName => $methodDef) {
|
||||
camp_html_select_option($methodName, $f_selectedMethod, $methodName);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br>
|
||||
Parameters:
|
||||
<?PHP
|
||||
$methodParams = $methodDefs[$f_selectedMethod]['p'];
|
||||
if (!is_array($methodParams) || count($methodParams) == 0) {
|
||||
echo "This method requires no parameters.<br>";
|
||||
} else {
|
||||
echo "<table cellpadding=3>";
|
||||
foreach ($methodParams as $methodParamName) {
|
||||
$value = "";
|
||||
if ($methodParamName == "sessid" && isset($_SESSION['xmlrpc_session_id'])) {
|
||||
$value = $_SESSION['xmlrpc_session_id'];
|
||||
} elseif ($methodParamName == "token" && isset($_SESSION['xmlrpc_token'])) {
|
||||
$value = $_SESSION['xmlrpc_token'];
|
||||
} elseif (isset($_SESSION["param_".$methodParamName])) {
|
||||
$value = $_SESSION["param_".$methodParamName];
|
||||
}
|
||||
echo "<tr>";
|
||||
echo "<td>$methodParamName</td>"; ?> <td><INPUT type="text" name="param_<?php echo $methodParamName; ?>" value="<?php echo $value; ?>"><td></tr>
|
||||
<?php
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
?>
|
||||
<br>
|
||||
<INPUT type="submit" name="go_button" value="Send Message">
|
||||
</form>
|
||||
|
||||
|
||||
<?PHP
|
||||
if ($loggedIn) {
|
||||
echo "You have logged in with session ID: ".$_SESSION['xmlrpc_session_id']."<br><br>";
|
||||
}
|
||||
if (isset($sentMessage)) {
|
||||
?>
|
||||
Sent message:<br>
|
||||
<TEXTAREA cols="60" rows="8">Method name: <?php echo $actualMethod; ?>
|
||||
<?php print_r($xmlParameters);?></TEXTAREA>
|
||||
<br>
|
||||
<?PHP
|
||||
}
|
||||
if (isset($errorMsg)) {
|
||||
?>
|
||||
Error:<br>
|
||||
<TEXTAREA cols="60" rows="8"><?php print_r($errorMsg);?></TEXTAREA>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (isset($xmlResponse)) {
|
||||
?>
|
||||
Response:<br>
|
||||
<TEXTAREA cols="60" rows="8"><?php print_r($xmlResponse);?></TEXTAREA>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue