Major changes in transport layer and xmlrpc interface.
Transport prepared for search jobs.
This commit is contained in:
parent
a07710d09e
commit
d086760277
|
@ -20,7 +20,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: tomas $
|
||||
# Version : $Revision: 1.1 $
|
||||
# Version : $Revision: 1.2 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/Attic/Makefile,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -62,13 +62,15 @@ USR_LIB_DIR = ${USR_DIR}/lib
|
|||
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
||||
HTTP_GROUP = apache
|
||||
#HTTP_GROUP = nobody
|
||||
GET_GNAME = install/getGname.php
|
||||
WWW_ROOT := $(shell cd ../storageServer/var/install; php -q getWwwRoot.php)
|
||||
HTTP_GROUP := $(shell curl -s ${WWW_ROOT}/${GET_GNAME})
|
||||
|
||||
PHP_DIR = ${BASE_DIR}/var
|
||||
INSTALL_DIR = ${PHP_DIR}/install
|
||||
STOR_DIR = ${PHP_DIR}/stor
|
||||
ACCESS_DIR = ${PHP_DIR}/access
|
||||
TRANS_DIR = ${PHP_DIR}/trans
|
||||
BUFF_DIR = ${STOR_DIR}/buffer
|
||||
TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh
|
||||
|
||||
|
@ -95,12 +97,15 @@ TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh
|
|||
|
||||
all: dir_setup db_init
|
||||
|
||||
dir_setup: ${DOXYGEN_DIR} ${STOR_DIR} ${ACCESS_DIR}
|
||||
dir_setup: ${DOXYGEN_DIR} ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR}
|
||||
|
||||
doc:
|
||||
${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||
|
||||
clean: db_clean
|
||||
${RMDIR} ${STOR_DIR}
|
||||
${RMDIR} ${ACCESS_DIR}
|
||||
${RMDIR} ${TRANS_DIR}
|
||||
|
||||
docclean:
|
||||
${RMDIR} ${DOXYGEN_DIR}/html
|
||||
|
@ -141,6 +146,11 @@ ${ACCESS_DIR}:
|
|||
chown .${HTTP_GROUP} ${ACCESS_DIR}
|
||||
chmod g+ws ${ACCESS_DIR}
|
||||
|
||||
${TRANS_DIR}:
|
||||
${MKDIR} ${TRANS_DIR}
|
||||
chown .${HTTP_GROUP} ${TRANS_DIR}
|
||||
chmod g+ws ${TRANS_DIR}
|
||||
|
||||
${BUFF_DIR}:
|
||||
${MKDIR} ${BUFF_DIR}
|
||||
chmod g+w ${BUFF_DIR}
|
||||
|
|
|
@ -8,7 +8,7 @@ Install steps for file uploading (do it with appropriate changes):
|
|||
2) move put.cgi there from var subdir
|
||||
3) add to apache2 config (i.g. commonapache2.conf):
|
||||
|
||||
<Location /livesupport/modules/archiveServer/var/access>
|
||||
<Location /livesupport/modules/archiveServer/var/trans>
|
||||
Script PUT /cgi-bin-put/put.cgi
|
||||
</Location>
|
||||
ScriptAlias /cgi-bin-put/ "/usr/local/apache2/cgi-bin-put/"
|
||||
|
|
|
@ -23,130 +23,195 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/Archive.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
require_once "../../../storageServer/var/LocStor.php";
|
||||
|
||||
$config['archiveUrlPath'] = '/livesupport/modules/archiveServer/var';
|
||||
$config['archiveXMLRPC'] = 'xmlrpc/xrArchive.php';
|
||||
$config['archiveUrlHost'] = 'localhost';
|
||||
$config['archiveUrlPort'] = 80;
|
||||
$config['archiveAccountLogin'] = 'root';
|
||||
$config['archiveAccountPass'] = 'q';
|
||||
|
||||
/**
|
||||
* Extension to StorageServer to act as ArchiveServer
|
||||
*/
|
||||
class Archive extends LocStor{
|
||||
|
||||
/**
|
||||
* Open download
|
||||
* Constructor
|
||||
*/
|
||||
function downloadOpen($sessid, $gunid)
|
||||
function Archive(&$dbc, $config)
|
||||
{
|
||||
// access
|
||||
$lnk = $this->accessRawAudioData($sessid, $gunid);
|
||||
if(PEAR::isError($lnk)) return $lnk;
|
||||
// return tmpurl, fname, md5h
|
||||
$url = $this->_lnk2url($lnk);
|
||||
$md5h = $this->_md5sum($lnk);
|
||||
return array('url'=>$url, 'md5h'=>$md5h, 'fname'=>basename($lnk));
|
||||
parent::LocStor(&$dbc, $config);
|
||||
$this->transDir = $config['transDir'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ======================================================= upload methods */
|
||||
|
||||
/**
|
||||
* Close download
|
||||
* Open file upload
|
||||
*
|
||||
* @param sessid string - session id
|
||||
* @param trid string - transport id
|
||||
* @param type string - media|metadata|search
|
||||
* @return array(url string) or error
|
||||
*/
|
||||
function downloadClose($sessid, $url)
|
||||
function uploadOpen($sessid, $trid, $type)
|
||||
{
|
||||
// release
|
||||
$lnk = $this->_url2lnk($url);
|
||||
$res = $this->releaseRawAudioData($sessid, $lnk);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open upload
|
||||
*/
|
||||
function uploadOpen($sessid, $gunid)
|
||||
{
|
||||
$fname = "{$this->storageDir}/buffer/$gunid";
|
||||
if(!$fp = fopen($fname, 'w')) return PEAR::raiseError(
|
||||
$file = "{$this->transDir}/$trid";
|
||||
if(!$fp = fopen($file, 'w')) return PEAR::raiseError(
|
||||
"Archive::uploadOpen: unable to create blank file"
|
||||
);
|
||||
fclose($fp);
|
||||
$res = $this->storeAudioClip($sessid, $gunid, $fname, '');
|
||||
if(PEAR::isError($res)) return $res;
|
||||
$lnk = $this->accessRawAudioData($sessid, $gunid);
|
||||
if(PEAR::isError($lnk)) return $lnk;
|
||||
$url = $this->_lnk2url($lnk);
|
||||
$host = $this->config['archiveUrlHost'];
|
||||
$port = $this->config['archiveUrlPort'];
|
||||
$path = $this->config['archiveUrlPath'];
|
||||
$url = "http://$host:$port$path/trans/".basename($file);
|
||||
return array('url'=>$url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Abort upload
|
||||
*/
|
||||
function uploadAbort($sessid, $url)
|
||||
{
|
||||
$lnk = $this->_url2lnk($url);
|
||||
$res = $this->releaseRawAudioData($sessid, $lnk);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check upload
|
||||
* Check uploaded file
|
||||
*
|
||||
* @param sessid string - session id
|
||||
* @param url string
|
||||
* @return array(md5h string, size int, url string)
|
||||
*/
|
||||
function uploadCheck($sessid, $url)
|
||||
{
|
||||
$lnk = $this->_url2lnk($url);
|
||||
$md5h = $this->_md5sum($lnk);
|
||||
$size = filesize($lnk);
|
||||
$file = "{$this->transDir}/".basename($url);
|
||||
$md5h = $this->_md5sum($file);
|
||||
$size = filesize($file);
|
||||
return array('md5h'=>$md5h, 'size'=>$size, 'url'=>$url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close upload
|
||||
* Close file upload
|
||||
*
|
||||
* @param sessid string - session id
|
||||
* @param url string
|
||||
* @param type string - media|metadata|search
|
||||
* @param gunid string - global unique id
|
||||
* @return boolean or error
|
||||
*/
|
||||
function uploadClose($sessid, $url, $type='file')
|
||||
function uploadClose($sessid, $url, $type, $gunid)
|
||||
{
|
||||
$file = "{$this->transDir}/".basename($url);
|
||||
$res = $this->processUploaded($sessid, $file, $type, $gunid);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process uploaded file - insert to the storage
|
||||
*
|
||||
* @param sessid string - session id
|
||||
* @param file string - absolute local pathname
|
||||
* @param type string - media|metadata|search
|
||||
* @param gunid string - global unique id
|
||||
* @return boolean or error
|
||||
*/
|
||||
function processUploaded($sessid, $file, $type, $gunid='X')
|
||||
{
|
||||
switch($type){
|
||||
default: // case"file":
|
||||
// release
|
||||
$lnk = $this->_url2lnk($url);
|
||||
$res = $this->releaseRawAudioData($sessid, $lnk);
|
||||
return $res;
|
||||
case 'media':
|
||||
if(!file_exists($file)) break;
|
||||
$res = $this->storeAudioClip($sessid, $gunid,
|
||||
$file, '');
|
||||
if(PEAR::isError($res)) return $res;
|
||||
@unlink($file);
|
||||
break;
|
||||
case"search":
|
||||
// localSearch
|
||||
// return results
|
||||
case 'metadata':
|
||||
case 'mdata':
|
||||
if(!file_exists($file)) break;
|
||||
$res = $this->updateAudioClipMetadata($sessid, $gunid,
|
||||
$file);
|
||||
if(PEAR::isError($res)){
|
||||
// catch valid exception
|
||||
if($res->getCode() == GBERR_FOBJNEX){
|
||||
$res2 = $this->storeAudioClip($sessid, $gunid,
|
||||
'', $file);
|
||||
if(PEAR::isError($res2)) return $res2;
|
||||
}else return $res;
|
||||
}
|
||||
@unlink($file);
|
||||
break;
|
||||
case 'search':
|
||||
return PEAR::raiseError("Archive::processUploaded: search not implemented");
|
||||
/*
|
||||
rename($file, $file."_");
|
||||
$criteria = unserialize(file_get_contents($file_));
|
||||
$res = $this->searchMetadata($sessid, $criteria);
|
||||
$fh = fopen($file, "w");
|
||||
fwrite($fh, serialize($res));
|
||||
fclose($fh);
|
||||
@unlink($file."_");
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
return PEAR::raiseError("Archive::processUploaded: unknown type ($type)");
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ===================================================== download methods */
|
||||
/**
|
||||
* Translate local symlink to URL
|
||||
* Open file download
|
||||
*
|
||||
* @param sessid string - session id
|
||||
* @param type string media|metadata|search
|
||||
* @param par string - depends on type
|
||||
*/
|
||||
function _lnk2url($lnk)
|
||||
function downloadOpen($sessid, $type, $par)
|
||||
{
|
||||
return "http://{$this->config['archiveUrlHost']}:{$this->config['archiveUrlPort']}".
|
||||
"{$this->config['archiveUrlPath']}/access/".basename($lnk);
|
||||
switch($type){
|
||||
case 'media':
|
||||
case 'metadata':
|
||||
$gunid = $par;
|
||||
$res = $this->prepareForTransport('', $gunid, $sessid);
|
||||
if(PEAR::isError($res)) return $res;
|
||||
list($mediaFile, $mdataFile, $gunid) = $res;
|
||||
default:
|
||||
}
|
||||
switch($type){
|
||||
case 'media':
|
||||
$fname = $mediaFile;
|
||||
break;
|
||||
case 'metadata':
|
||||
$fname = $mdataFile;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
$file = "{$this->transDir}/$fname";
|
||||
$host = $this->config['archiveUrlHost'];
|
||||
$port = $this->config['archiveUrlPort'];
|
||||
$path = $this->config['archiveUrlPath'];
|
||||
$url = "http://$host:$port$path/trans/$fname";
|
||||
$md5h = $this->_md5sum($file);
|
||||
return array('url'=>$url, 'md5h'=>$md5h, 'fname'=>$fname);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Traslate URL to local symlink
|
||||
* Close file download
|
||||
*
|
||||
* @param sessid string - session id
|
||||
* @param url string
|
||||
* @return boolean
|
||||
*/
|
||||
function _url2lnk($url)
|
||||
function downloadClose($sessid, $url)
|
||||
{
|
||||
return $this->accessDir."/".basename($url);
|
||||
$file = "{$this->transDir}/".basename($url);
|
||||
@unlink($file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ==================================================== auxiliary methods */
|
||||
|
||||
/**
|
||||
* Returns md5 hash of external file
|
||||
*
|
||||
* @param fpath string - local path to file
|
||||
* @return string
|
||||
*/
|
||||
function _md5sum($fpath)
|
||||
{
|
||||
$md5h = `md5sum $fpath`;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/conf.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -38,7 +38,7 @@ $config = array(
|
|||
),
|
||||
'tblNamePrefix' => 'as_',
|
||||
'authCookieName'=> 'assid',
|
||||
'RootNode' => 'RootNode',
|
||||
'RootNode' => 'RootNode',
|
||||
'tmpRootPass' => 'q',
|
||||
'objtypes' => array(
|
||||
'RootNode' => array('Folder'),
|
||||
|
@ -58,6 +58,20 @@ $config = array(
|
|||
'editPrivs', 'write', 'read', 'classes', 'subjects'
|
||||
),
|
||||
'storageDir' => dirname(getcwd()).'/stor',
|
||||
'bufferDir' => dirname(getcwd()).'/stor/buffer',
|
||||
'transDir' => dirname(getcwd()).'/trans',
|
||||
'accessDir' => dirname(getcwd()).'/access',
|
||||
|
||||
// on central archive side storage=archive
|
||||
'storageUrlPath' => '/livesupport/modules/archiveServer/var',
|
||||
'storageXMLRPC' => 'xmlrpc/xrArchive.php',
|
||||
'storageUrlHost' => 'localhost',
|
||||
'storageUrlPort' => 80,
|
||||
// only for returning right URLs:
|
||||
'archiveUrlPath' => '/livesupport/modules/archiveServer/var',
|
||||
'archiveXMLRPC' => 'xmlrpc/xrArchive.php',
|
||||
'archiveUrlHost' => 'localhost',
|
||||
'archiveUrlPort' => 80,
|
||||
|
||||
);
|
||||
?>
|
|
@ -77,7 +77,7 @@ $tpldata['showMenu']=true;
|
|||
|
||||
?>
|
||||
<html><head>
|
||||
<title>Browser</title>
|
||||
<title>Archive - browser</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="default.css">
|
||||
<style type="text/css">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// $Id: gbHtmlLogin.php,v 1.1 2004/09/21 00:43:21 tomas Exp $
|
||||
// $Id: gbHtmlLogin.php,v 1.2 2004/09/29 01:37:40 tomas Exp $
|
||||
require_once"gbHtml_h.php";
|
||||
|
||||
// prefill data structure for template
|
||||
|
@ -24,7 +24,7 @@ unset($_SESSION['lastPost']);
|
|||
// template follows:
|
||||
?>
|
||||
<html><head>
|
||||
<title>Storage - login</title>
|
||||
<title>Archive - login</title>
|
||||
<link rel="stylesheet" type="text/css" href="default.css">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
|
@ -51,7 +51,7 @@ unset($_SESSION['lastPost']);
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<h1>Storage - login</h1>
|
||||
<h1>Archive - login</h1>
|
||||
|
||||
<form action="gbHttp.php" method="post" id="loginform">
|
||||
<table>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// $Id: gbHtmlPerms.php,v 1.1 2004/09/21 00:43:22 tomas Exp $
|
||||
// $Id: gbHtmlPerms.php,v 1.2 2004/09/29 01:37:40 tomas Exp $
|
||||
require_once"gbHtml_h.php";
|
||||
require_once"gbHtmlTestAuth.php";
|
||||
|
||||
|
@ -29,7 +29,7 @@ $tpldata['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
|||
// template follows:
|
||||
?>
|
||||
<html><head>
|
||||
<title>Storage - permission editor</title>
|
||||
<title>Archive - permission editor</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="default.css">
|
||||
<style type="text/css">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// $Id: gbHtmlSubj.php,v 1.1 2004/09/21 00:43:24 tomas Exp $
|
||||
// $Id: gbHtmlSubj.php,v 1.2 2004/09/29 01:37:40 tomas Exp $
|
||||
require_once"gbHtml_h.php";
|
||||
require_once"gbHtmlTestAuth.php";
|
||||
|
||||
|
@ -43,7 +43,7 @@ $d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
|||
// template follows:
|
||||
?>
|
||||
<html><head>
|
||||
<title>Storage - user and roles editor</title>
|
||||
<title>Archive - user and roles editor</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="default.css">
|
||||
<style type="text/css">
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/install/install.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -53,10 +53,6 @@ if(PEAR::isError($dbc)){
|
|||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = &new GreenBox(&$dbc, $config);
|
||||
|
||||
echo "\nIMPORTANT settings:\n";
|
||||
echo " Makefile: HTTP_GROUP - group of running http daemon\n";
|
||||
echo " var/xmlrpc/testRunner.sh: XMLRPC - URL of XMLRPC server\n\n";
|
||||
|
||||
echo "Archive: Install ...\n";
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$gb->uninstall();
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# A simple log file, must be writable by the user that this program runs as.
|
||||
# Should not be within the document tree.
|
||||
$putlog = "/tmp/put1.log";
|
||||
|
||||
#&log($ENV{'HTTP_CONTENT_RANGE'});
|
||||
|
||||
# Check we are using PUT method
|
||||
if ($ENV{'REQUEST_METHOD'} ne "PUT") { &reply(500, "Request method is not PUT"); }
|
||||
|
||||
# Check we got a destination filename
|
||||
$filename = $ENV{'PATH_TRANSLATED'};
|
||||
if (!$filename) { &reply(500, "No PATH_TRANSLATED"); }
|
||||
|
||||
# Check we got some content
|
||||
$clength = $ENV{'CONTENT_LENGTH'};
|
||||
if (!$clength) { &reply(500, "Content-Length missing or zero ($clength)"); }
|
||||
|
||||
# Read the content itself and write it out
|
||||
# Note: doesn't check the location of the file, whether it already
|
||||
# exists, whether it is a special file, directory or link. Does not
|
||||
# set the access permissions. Does not handle subdirectories that
|
||||
# need creating.
|
||||
$toread = $clength;
|
||||
#$content = "";
|
||||
$packlen = 2048;
|
||||
open(OUT, ">> $filename") || &reply(500, "Cannot write to $filename");
|
||||
while ($toread > 0)
|
||||
{
|
||||
# $nread = read(STDIN, $data, $clength);
|
||||
$nread = read(STDIN, $data, $packlen);
|
||||
&reply(500, "Error reading content") if !defined($nread);
|
||||
$toread -= $nread;
|
||||
# $content = $data;
|
||||
print OUT $data;
|
||||
}
|
||||
|
||||
close(OUT);
|
||||
|
||||
# Everything seemed to work, reply with 204 (or 200). Should reply with 201
|
||||
# if content was created, not updated.
|
||||
&reply(204);
|
||||
|
||||
exit(0);
|
||||
|
||||
#
|
||||
# Send back reply to client for a given status.
|
||||
#
|
||||
|
||||
sub reply
|
||||
{
|
||||
local($status, $message) = @_;
|
||||
local($remuser, $remhost, $logline) = ();
|
||||
|
||||
print "Status: $status\n";
|
||||
print "Content-Type: text/html\n\n";
|
||||
|
||||
if ($status == 200) {
|
||||
print "<HEAD><TITLE>OK</TITLE></HEAD><H1>Content Accepted</H1>\n";
|
||||
} elsif ($status == 500) {
|
||||
print "<HEAD><TITLE>Error</TITLE></HEAD><H1>Error Publishing File</H1>\n";
|
||||
print "An error occurred publishing this file ($message).\n";
|
||||
}
|
||||
# Note: status 204 and 201 gives have content part
|
||||
|
||||
# Create a simple log
|
||||
$remuser = $ENV{'REMOTE_USER'} || "-";
|
||||
$remhost = $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'} || "-";
|
||||
|
||||
$logline = "$remhost $remuser $filename status $status";
|
||||
$logline .= " ($message)" if ($status == 500);
|
||||
&log($logline);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
sub log
|
||||
{
|
||||
local($msg) = @_;
|
||||
open (LOG, ">> $putlog") || return;
|
||||
print LOG "$msg\n";
|
||||
close(LOG);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,450 +0,0 @@
|
|||
<?php
|
||||
// by Edd Dumbill (C) 1999-2002
|
||||
// <edd@usefulinc.com>
|
||||
// $Id: xmlrpcs.inc,v 1.1 2004/09/21 00:43:34 tomas Exp $
|
||||
|
||||
// Copyright (c) 1999,2000,2002 Edd Dumbill.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// * Neither the name of the "XML-RPC for PHP" nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// XML RPC Server class
|
||||
// requires: xmlrpc.inc
|
||||
|
||||
// listMethods: either a string, or nothing
|
||||
$_xmlrpcs_listMethods_sig=array(array($xmlrpcArray, $xmlrpcString), array($xmlrpcArray));
|
||||
$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
|
||||
function _xmlrpcs_listMethods($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
$v=new xmlrpcval();
|
||||
$dmap=$server->dmap;
|
||||
$outAr=array();
|
||||
for(reset($dmap); list($key, $val)=each($dmap); )
|
||||
{
|
||||
$outAr[]=new xmlrpcval($key, 'string');
|
||||
}
|
||||
$dmap=$_xmlrpcs_dmap;
|
||||
for(reset($dmap); list($key, $val)=each($dmap); )
|
||||
{
|
||||
$outAr[]=new xmlrpcval($key, 'string');
|
||||
}
|
||||
$v->addArray($outAr);
|
||||
return new xmlrpcresp($v);
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString));
|
||||
$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
|
||||
function _xmlrpcs_methodSignature($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName=$m->getParam(0);
|
||||
$methName=$methName->scalarval();
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dmap=$server->dmap; $sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName]))
|
||||
{
|
||||
if ($dmap[$methName]['signature'])
|
||||
{
|
||||
$sigs=array();
|
||||
$thesigs=$dmap[$methName]['signature'];
|
||||
for($i=0; $i<sizeof($thesigs); $i++)
|
||||
{
|
||||
$cursig=array();
|
||||
$inSig=$thesigs[$i];
|
||||
for($j=0; $j<sizeof($inSig); $j++)
|
||||
{
|
||||
$cursig[]=new xmlrpcval($inSig[$j], 'string');
|
||||
}
|
||||
$sigs[]=new xmlrpcval($cursig, 'array');
|
||||
}
|
||||
$r=new xmlrpcresp(new xmlrpcval($sigs, 'array'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(new xmlrpcval('undef', 'string'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(0,$xmlrpcerr['introspect_unknown'], $xmlrpcstr['introspect_unknown']);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodHelp_sig=array(array($xmlrpcString, $xmlrpcString));
|
||||
$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
|
||||
function _xmlrpcs_methodHelp($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName=$m->getParam(0);
|
||||
$methName=$methName->scalarval();
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap=$_xmlrpcs_dmap; $sysCall=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dmap=$server->dmap; $sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName]))
|
||||
{
|
||||
if ($dmap[$methName]['docstring'])
|
||||
{
|
||||
$r=new xmlrpcresp(new xmlrpcval($dmap[$methName]["docstring"]), 'string');
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(new xmlrpcval('', 'string'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=new xmlrpcresp(0, $xmlrpcerr['introspect_unknown'], $xmlrpcstr['introspect_unknown']);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_multicall_sig = array(array($xmlrpcArray, $xmlrpcArray));
|
||||
$_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details';
|
||||
|
||||
function _xmlrpcs_multicall_error($err)
|
||||
{
|
||||
if (is_string($err))
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr;
|
||||
$str = $xmlrpcstr["multicall_${err}"];
|
||||
$code = $xmlrpcerr["multicall_${err}"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = $err->faultCode();
|
||||
$str = $err->faultString();
|
||||
}
|
||||
$struct['faultCode'] = new xmlrpcval($code, 'int');
|
||||
$struct['faultString'] = new xmlrpcval($str, 'string');
|
||||
return new xmlrpcval($struct, 'struct');
|
||||
}
|
||||
|
||||
function _xmlrpcs_multicall_do_call($server, $call)
|
||||
{
|
||||
if ($call->kindOf() != 'struct')
|
||||
return _xmlrpcs_multicall_error('notstruct');
|
||||
$methName = $call->structmem('methodName');
|
||||
if (!$methName)
|
||||
return _xmlrpcs_multicall_error('nomethod');
|
||||
if ($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string')
|
||||
return _xmlrpcs_multicall_error('notstring');
|
||||
if ($methName->scalarval() == 'system.multicall')
|
||||
return _xmlrpcs_multicall_error('recursion');
|
||||
|
||||
$params = $call->structmem('params');
|
||||
if (!$params)
|
||||
return _xmlrpcs_multicall_error('noparams');
|
||||
if ($params->kindOf() != 'array')
|
||||
return _xmlrpcs_multicall_error('notarray');
|
||||
$numParams = $params->arraysize();
|
||||
|
||||
$msg = new xmlrpcmsg($methName->scalarval());
|
||||
for ($i = 0; $i < $numParams; $i++)
|
||||
$msg->addParam($params->arraymem($i));
|
||||
|
||||
$result = $server->execute($msg);
|
||||
|
||||
if ($result->faultCode() != 0)
|
||||
return _xmlrpcs_multicall_error($result); // Method returned fault.
|
||||
|
||||
return new xmlrpcval(array($result->value()), "array");
|
||||
}
|
||||
|
||||
function _xmlrpcs_multicall($server, $m)
|
||||
{
|
||||
$calls = $m->getParam(0);
|
||||
$numCalls = $calls->arraysize();
|
||||
$result = array();
|
||||
|
||||
for ($i = 0; $i < $numCalls; $i++)
|
||||
{
|
||||
$call = $calls->arraymem($i);
|
||||
$result[$i] = _xmlrpcs_multicall_do_call($server, $call);
|
||||
}
|
||||
|
||||
return new xmlrpcresp(new xmlrpcval($result, 'array'));
|
||||
}
|
||||
|
||||
$_xmlrpcs_dmap=array(
|
||||
'system.listMethods' => array(
|
||||
'function' => '_xmlrpcs_listMethods',
|
||||
'signature' => $_xmlrpcs_listMethods_sig,
|
||||
'docstring' => $_xmlrpcs_listMethods_doc),
|
||||
'system.methodHelp' => array(
|
||||
'function' => '_xmlrpcs_methodHelp',
|
||||
'signature' => $_xmlrpcs_methodHelp_sig,
|
||||
'docstring' => $_xmlrpcs_methodHelp_doc),
|
||||
'system.methodSignature' => array(
|
||||
'function' => '_xmlrpcs_methodSignature',
|
||||
'signature' => $_xmlrpcs_methodSignature_sig,
|
||||
'docstring' => $_xmlrpcs_methodSignature_doc),
|
||||
'system.multicall' => array(
|
||||
'function' => '_xmlrpcs_multicall',
|
||||
'signature' => $_xmlrpcs_multicall_sig,
|
||||
'docstring' => $_xmlrpcs_multicall_doc
|
||||
)
|
||||
);
|
||||
|
||||
$_xmlrpc_debuginfo='';
|
||||
function xmlrpc_debugmsg($m)
|
||||
{
|
||||
global $_xmlrpc_debuginfo;
|
||||
$_xmlrpc_debuginfo=$_xmlrpc_debuginfo . $m . "\n";
|
||||
}
|
||||
|
||||
class xmlrpc_server
|
||||
{
|
||||
var $dmap=array();
|
||||
|
||||
function xmlrpc_server($dispMap='', $serviceNow=1)
|
||||
{
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
// dispMap is a dispatch array of methods
|
||||
// mapped to function names and signatures
|
||||
// if a method
|
||||
// doesn't appear in the map then an unknown
|
||||
// method error is generated
|
||||
/* milosch - changed to make passing dispMap optional.
|
||||
* instead, you can use the class add_to_map() function
|
||||
* to add functions manually (borrowed from SOAPX4)
|
||||
*/
|
||||
if($dispMap)
|
||||
{
|
||||
$this->dmap = $dispMap;
|
||||
if($serviceNow)
|
||||
{
|
||||
$this->service();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function serializeDebug()
|
||||
{
|
||||
global $_xmlrpc_debuginfo;
|
||||
if ($_xmlrpc_debuginfo!='')
|
||||
{
|
||||
return "<!-- DEBUG INFO:\n\n" . $_xmlrpc_debuginfo . "\n-->\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function service()
|
||||
{
|
||||
global $xmlrpc_defencoding;
|
||||
|
||||
$r=$this->parseRequest();
|
||||
$payload='<?xml version="1.0" encoding="' . $xmlrpc_defencoding . '"?>' . "\n"
|
||||
. $this->serializeDebug()
|
||||
. $r->serialize();
|
||||
Header("Content-type: text/xml\r\nContent-length: " .
|
||||
strlen($payload));
|
||||
print $payload;
|
||||
}
|
||||
|
||||
/*
|
||||
add a method to the dispatch map
|
||||
*/
|
||||
function add_to_map($methodname,$function,$sig,$doc)
|
||||
{
|
||||
$this->dmap[$methodname] = array(
|
||||
'function' => $function,
|
||||
'signature' => $sig,
|
||||
'docstring' => $doc
|
||||
);
|
||||
}
|
||||
|
||||
function verifySignature($in, $sig)
|
||||
{
|
||||
for($i=0; $i<sizeof($sig); $i++)
|
||||
{
|
||||
// check each possible signature in turn
|
||||
$cursig=$sig[$i];
|
||||
if (sizeof($cursig)==$in->getNumParams()+1)
|
||||
{
|
||||
$itsOK=1;
|
||||
for($n=0; $n<$in->getNumParams(); $n++)
|
||||
{
|
||||
$p=$in->getParam($n);
|
||||
// print "<!-- $p -->\n";
|
||||
if ($p->kindOf() == 'scalar')
|
||||
{
|
||||
$pt=$p->scalartyp();
|
||||
}
|
||||
else
|
||||
{
|
||||
$pt=$p->kindOf();
|
||||
}
|
||||
// $n+1 as first type of sig is return type
|
||||
if ($pt != $cursig[$n+1])
|
||||
{
|
||||
$itsOK=0;
|
||||
$pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($itsOK)
|
||||
{
|
||||
return array(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
|
||||
}
|
||||
|
||||
function parseRequest($data='')
|
||||
{
|
||||
global $_xh,$HTTP_RAW_POST_DATA;
|
||||
global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding,
|
||||
$_xmlrpcs_dmap;
|
||||
|
||||
if ($data=="")
|
||||
{
|
||||
$data=$HTTP_RAW_POST_DATA;
|
||||
}
|
||||
$parser = xml_parser_create($xmlrpc_defencoding);
|
||||
|
||||
$_xh[$parser]=array();
|
||||
$_xh[$parser]['st']='';
|
||||
$_xh[$parser]['cm']=0;
|
||||
$_xh[$parser]['isf']=0;
|
||||
$_xh[$parser]['params']=array();
|
||||
$_xh[$parser]['method']='';
|
||||
|
||||
// decompose incoming XML into request structure
|
||||
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
|
||||
xml_set_character_data_handler($parser, 'xmlrpc_cd');
|
||||
xml_set_default_handler($parser, 'xmlrpc_dh');
|
||||
if (!xml_parse($parser, $data, 1))
|
||||
{
|
||||
// return XML error as a faultCode
|
||||
$r=new xmlrpcresp(0,
|
||||
$xmlrpcerrxml+xml_get_error_code($parser),
|
||||
sprintf("XML error: %s at line %d",
|
||||
xml_error_string(xml_get_error_code($parser)),
|
||||
xml_get_current_line_number($parser)));
|
||||
xml_parser_free($parser);
|
||||
}
|
||||
else
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
$m=new xmlrpcmsg($_xh[$parser]['method']);
|
||||
// now add parameters in
|
||||
$plist="";
|
||||
for($i=0; $i<sizeof($_xh[$parser]['params']); $i++)
|
||||
{
|
||||
//print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
|
||||
$plist.="$i - " . $_xh[$parser]['params'][$i]. " \n";
|
||||
eval('$m->addParam(' . $_xh[$parser]['params'][$i]. ");");
|
||||
}
|
||||
// uncomment this to really see what the server's getting!
|
||||
// xmlrpc_debugmsg($plist);
|
||||
|
||||
$r = $this->execute($m);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function execute ($m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
// now to deal with the method
|
||||
$methName = $m->method();
|
||||
$sysCall = ereg("^system\.", $methName);
|
||||
$dmap = $sysCall ? $_xmlrpcs_dmap : $this->dmap;
|
||||
|
||||
if (!isset($dmap[$methName]['function']))
|
||||
{
|
||||
// No such method
|
||||
return new xmlrpcresp(0,
|
||||
$xmlrpcerr['unknown_method'],
|
||||
$xmlrpcstr['unknown_method']);
|
||||
}
|
||||
|
||||
// Check signature.
|
||||
if (isset($dmap[$methName]['signature']))
|
||||
{
|
||||
$sig = $dmap[$methName]['signature'];
|
||||
list ($ok, $errstr) = $this->verifySignature($m, $sig);
|
||||
if (!$ok)
|
||||
{
|
||||
// Didn't match.
|
||||
return new xmlrpcresp(0,
|
||||
$xmlrpcerr['incorrect_params'],
|
||||
$xmlrpcstr['incorrect_params'] . ": ${errstr}");
|
||||
}
|
||||
}
|
||||
|
||||
$func = $dmap[$methName]['function'];
|
||||
|
||||
if ($sysCall)
|
||||
{
|
||||
return call_user_func($func, $this, $m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return call_user_func($func, $m);
|
||||
}
|
||||
}
|
||||
|
||||
function echoInput()
|
||||
{
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
|
||||
// a debugging routine: just echos back the input
|
||||
// packet as a string value
|
||||
|
||||
$r=new xmlrpcresp;
|
||||
$r->xv=new xmlrpcval( "'Aha said I: '" . $HTTP_RAW_POST_DATA, 'string');
|
||||
print $r->serialize();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -23,12 +23,12 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/xmlrpc/xrArchive.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
include_once "xmlrpc.inc";
|
||||
include_once "xmlrpcs.inc";
|
||||
include_once "../../../storageServer/var/xmlrpc/xmlrpc.inc";
|
||||
include_once "../../../storageServer/var/xmlrpc/xmlrpcs.inc";
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once "../Archive.php";
|
||||
|
@ -41,82 +41,83 @@ $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
|||
* XMLRPC layer for Archive module
|
||||
*/
|
||||
class XR_Archive extends Archive{
|
||||
|
||||
/**
|
||||
* Simple ping method - return strtouppered string
|
||||
* Call LocStor::authenticate
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_ping($input)
|
||||
function xr_authenticate($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
return new xmlrpcresp(new xmlrpcval(strtoupper($r['par']), "string"));
|
||||
$res = $this->authenticate($r['login'], $r['pass']);
|
||||
return new xmlrpcresp(new xmlrpcval($res, "boolean"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open download
|
||||
* Call LocStor::existsAudioClip
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_downloadOpen($input)
|
||||
function xr_existsAudioClip($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->downloadOpen($r['sessid'], $r['gunid']);
|
||||
#$this->debugLog(join(', ', $r));
|
||||
$res = $this->existsAudioClip($r['sessid'], $r['gunid']);
|
||||
#$this->debugLog($res);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadOpen: ".$res->getMessage().
|
||||
"xr_existsAudioClip: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
return new xmlrpcresp(new xmlrpcval($res, "boolean"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Close download
|
||||
* Call LocStor::deleteAudioClip
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_downloadClose($input)
|
||||
function xr_deleteAudioClip($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->downloadClose($r['sessid'], $r['url']);
|
||||
if(PEAR::isError($res))
|
||||
$res = $this->deleteAudioClip($r['sessid'], $r['gunid']);
|
||||
if(!PEAR::isError($res))
|
||||
return new xmlrpcresp(new xmlrpcval($res, "boolean"));
|
||||
else
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadOpen: ".$res->getMessage().
|
||||
"xr_deleteAudioClip: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
}
|
||||
|
||||
/* ======================================================= upload methods */
|
||||
|
||||
/**
|
||||
* Open upload
|
||||
* Open general file upload
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_uploadOpen($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->uploadOpen($r['sessid'], $r['gunid']);
|
||||
$res = $this->uploadOpen($r['sessid'], $r['trid'], $r['type']);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadOpen: ".$res->getMessage().
|
||||
"xr_uploadOpen: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort upload
|
||||
*/
|
||||
function xr_uploadAbort($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->uploadAbort($r['sessid'], $r['url']);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadOpen: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check upload
|
||||
* Check general file upload
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_uploadCheck($input)
|
||||
{
|
||||
|
@ -125,20 +126,42 @@ class XR_Archive extends Archive{
|
|||
$res = $this->uploadCheck($r['sessid'], $r['url']);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadOpen: ".$res->getMessage().
|
||||
"xr_uploadCheck: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close upload
|
||||
* Close general file upload
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_uploadClose($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->uploadClose($r['sessid'], $r['url']);
|
||||
$res = $this->uploadClose($r['sessid'], $r['url'], $r['type'], $r['gunid']);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_uploadClose: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
}
|
||||
|
||||
/* ===================================================== download methods */
|
||||
/**
|
||||
* Open general file download
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_downloadOpen($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->downloadOpen($r['sessid'], $r['type'], $r['par']);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadOpen: ".$res->getMessage().
|
||||
|
@ -148,6 +171,25 @@ class XR_Archive extends Archive{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close general file download
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_downloadClose($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
$res = $this->downloadClose($r['sessid'], $r['url']);
|
||||
if(PEAR::isError($res))
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_downloadClose: ".$res->getMessage().
|
||||
" ".$res->getUserInfo()
|
||||
);
|
||||
return new xmlrpcresp(xmlrpc_encoder($res));
|
||||
}
|
||||
|
||||
/* =============================================== authentication methods */
|
||||
/**
|
||||
* Call Archive::login
|
||||
*
|
||||
|
@ -183,6 +225,20 @@ class XR_Archive extends Archive{
|
|||
);
|
||||
}
|
||||
|
||||
/* ==================================================== auxiliary methods */
|
||||
|
||||
/**
|
||||
* Simple ping method - return strtouppered string
|
||||
*
|
||||
* @param input XMLRPC struct
|
||||
*/
|
||||
function xr_ping($input)
|
||||
{
|
||||
list($ok, $r) = $this->_xr_getPars($input);
|
||||
if(!$ok) return $r;
|
||||
return new xmlrpcresp(new xmlrpcval(strtoupper($r['par']), "string"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert PHP variables to XMLRPC objects
|
||||
*
|
||||
|
@ -232,12 +288,12 @@ $methods = array(
|
|||
'login' => 'Login to storage.',
|
||||
'logout' => 'Logout from storage.',
|
||||
'ping' =>'Echo request',
|
||||
'downloadOpen' =>'Open download channel',
|
||||
'downloadClose' =>'Close download channel',
|
||||
'uploadOpen' =>'Open upload channel',
|
||||
'uploadAbort' =>'Close upload channel',
|
||||
'uploadCheck' =>'Check size and checksum of uploaded file',
|
||||
'uploadClose' =>'Close upload channel'
|
||||
|
||||
'uploadOpen' =>'Open file upload',
|
||||
'uploadCheck' =>'Check size and md5 uploaded file',
|
||||
'uploadClose' =>'Close file upload',
|
||||
'downloadOpen' =>'Open file download',
|
||||
'downloadClose' =>'Close file download',
|
||||
);
|
||||
|
||||
$defs = array();
|
||||
|
|
Loading…
Reference in New Issue