Major changes in transport layer - generalized for metadata and search jobs.
This commit is contained in:
parent
d086760277
commit
4b07803e0c
|
@ -20,7 +20,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: tomas $
|
# Author : $Author: tomas $
|
||||||
# Version : $Revision: 1.3 $
|
# Version : $Revision: 1.4 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/Attic/Makefile,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/Attic/Makefile,v $
|
||||||
#
|
#
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
@ -62,13 +62,15 @@ USR_LIB_DIR = ${USR_DIR}/lib
|
||||||
|
|
||||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||||
|
|
||||||
HTTP_GROUP = apache
|
GET_GNAME = install/getGname.php
|
||||||
#HTTP_GROUP = nobody
|
WWW_ROOT := $(shell cd var/install; php -q getWwwRoot.php)
|
||||||
|
HTTP_GROUP := $(shell curl -s ${WWW_ROOT}/${GET_GNAME})
|
||||||
|
|
||||||
PHP_DIR = ${BASE_DIR}/var
|
PHP_DIR = ${BASE_DIR}/var
|
||||||
INSTALL_DIR = ${PHP_DIR}/install
|
INSTALL_DIR = ${PHP_DIR}/install
|
||||||
STOR_DIR = ${PHP_DIR}/stor
|
STOR_DIR = ${PHP_DIR}/stor
|
||||||
ACCESS_DIR = ${PHP_DIR}/access
|
ACCESS_DIR = ${PHP_DIR}/access
|
||||||
|
TRANS_DIR = ${PHP_DIR}/trans
|
||||||
BUFF_DIR = ${STOR_DIR}/buffer
|
BUFF_DIR = ${STOR_DIR}/buffer
|
||||||
TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh
|
TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh
|
||||||
|
|
||||||
|
@ -95,18 +97,23 @@ TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh
|
||||||
db_init db_clean transtest
|
db_init db_clean transtest
|
||||||
|
|
||||||
all: dir_setup db_init
|
all: dir_setup db_init
|
||||||
|
$(MAKE) -C ../archiveServer all
|
||||||
|
|
||||||
dir_setup: ${DOXYGEN_DIR} ${STOR_DIR} ${ACCESS_DIR}
|
dir_setup: ${DOXYGEN_DIR} ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR}
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
${DOXYGEN} ${DOXYGEN_CONFIG}
|
${DOXYGEN} ${DOXYGEN_CONFIG}
|
||||||
|
|
||||||
clean: db_clean
|
clean: db_clean
|
||||||
|
${RMDIR} ${STOR_DIR}
|
||||||
|
${RMDIR} ${ACCESS_DIR}
|
||||||
|
${RMDIR} ${TRANS_DIR}
|
||||||
|
|
||||||
docclean:
|
docclean:
|
||||||
${RMDIR} ${DOXYGEN_DIR}/html
|
${RMDIR} ${DOXYGEN_DIR}/html
|
||||||
|
|
||||||
depclean: clean
|
depclean: clean
|
||||||
|
$(MAKE) -C ../archiveServer clean
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} *
|
${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} *
|
||||||
|
@ -115,6 +122,7 @@ distclean: clean docclean
|
||||||
|
|
||||||
check: all ${TEST_RUNNER}
|
check: all ${TEST_RUNNER}
|
||||||
${TEST_RUNNER}
|
${TEST_RUNNER}
|
||||||
|
$(MAKE) transtest
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Specific targets
|
# Specific targets
|
||||||
|
@ -124,6 +132,9 @@ transtest:
|
||||||
cd var/tests; php -q transTest.php
|
cd var/tests; php -q transTest.php
|
||||||
|
|
||||||
db_init:
|
db_init:
|
||||||
|
@echo "Settings:"
|
||||||
|
@echo "Http daemon group: ${HTTP_GROUP}"
|
||||||
|
@echo "WWW root: ${WWW_ROOT}"
|
||||||
cd var/install; php -q install.php
|
cd var/install; php -q install.php
|
||||||
|
|
||||||
db_clean:
|
db_clean:
|
||||||
|
@ -136,7 +147,7 @@ ${DOXYGEN_DIR}:
|
||||||
${MKDIR} ${DOXYGEN_DIR}
|
${MKDIR} ${DOXYGEN_DIR}
|
||||||
|
|
||||||
${STOR_DIR}:
|
${STOR_DIR}:
|
||||||
@echo "Http daemon group have set in Makefile: ${HTTP_GROUP}"
|
@echo "Http daemon group: ${HTTP_GROUP}"
|
||||||
@echo "You should be in this group for easy testing"
|
@echo "You should be in this group for easy testing"
|
||||||
${MKDIR} ${STOR_DIR}
|
${MKDIR} ${STOR_DIR}
|
||||||
chown .${HTTP_GROUP} ${STOR_DIR}
|
chown .${HTTP_GROUP} ${STOR_DIR}
|
||||||
|
@ -147,6 +158,11 @@ ${ACCESS_DIR}:
|
||||||
chown .${HTTP_GROUP} ${ACCESS_DIR}
|
chown .${HTTP_GROUP} ${ACCESS_DIR}
|
||||||
chmod g+ws ${ACCESS_DIR}
|
chmod g+ws ${ACCESS_DIR}
|
||||||
|
|
||||||
|
${TRANS_DIR}:
|
||||||
|
${MKDIR} ${TRANS_DIR}
|
||||||
|
chown .${HTTP_GROUP} ${TRANS_DIR}
|
||||||
|
chmod g+ws ${TRANS_DIR}
|
||||||
|
|
||||||
${BUFF_DIR}:
|
${BUFF_DIR}:
|
||||||
${MKDIR} ${BUFF_DIR}
|
${MKDIR} ${BUFF_DIR}
|
||||||
chmod g+w ${BUFF_DIR}
|
chmod g+w ${BUFF_DIR}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -40,6 +40,7 @@ define('GBERR_NOTIMPL', 50);
|
||||||
|
|
||||||
require_once "../../../alib/var/alib.php";
|
require_once "../../../alib/var/alib.php";
|
||||||
require_once "StoredFile.php";
|
require_once "StoredFile.php";
|
||||||
|
require_once "Transport.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GreenBox class
|
* GreenBox class
|
||||||
|
@ -47,7 +48,7 @@ require_once "StoredFile.php";
|
||||||
* LiveSupport file storage module
|
* LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class GreenBox extends Alib{
|
class GreenBox extends Alib{
|
||||||
|
@ -55,6 +56,7 @@ class GreenBox extends Alib{
|
||||||
var $mdataTable;
|
var $mdataTable;
|
||||||
var $accessTable;
|
var $accessTable;
|
||||||
var $storageDir;
|
var $storageDir;
|
||||||
|
var $bufferDir;
|
||||||
var $accessDir;
|
var $accessDir;
|
||||||
var $rootId;
|
var $rootId;
|
||||||
var $storId;
|
var $storId;
|
||||||
|
@ -69,10 +71,13 @@ class GreenBox extends Alib{
|
||||||
function GreenBox(&$dbc, $config)
|
function GreenBox(&$dbc, $config)
|
||||||
{
|
{
|
||||||
parent::Alib(&$dbc, $config);
|
parent::Alib(&$dbc, $config);
|
||||||
|
$this->config = $config;
|
||||||
$this->filesTable = $config['tblNamePrefix'].'files';
|
$this->filesTable = $config['tblNamePrefix'].'files';
|
||||||
$this->mdataTable = $config['tblNamePrefix'].'mdata';
|
$this->mdataTable = $config['tblNamePrefix'].'mdata';
|
||||||
$this->accessTable= $config['tblNamePrefix'].'access';
|
$this->accessTable= $config['tblNamePrefix'].'access';
|
||||||
$this->storageDir = $config['storageDir'];
|
$this->storageDir = $config['storageDir'];
|
||||||
|
$this->bufferDir = $config['bufferDir'];
|
||||||
|
$this->transDir = $config['transDir'];
|
||||||
$this->accessDir = $config['accessDir'];
|
$this->accessDir = $config['accessDir'];
|
||||||
$this->dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
$this->dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
$this->rootId = $this->getRootNode();
|
$this->rootId = $this->getRootNode();
|
||||||
|
@ -112,14 +117,14 @@ class GreenBox extends Alib{
|
||||||
* @exception PEAR::error
|
* @exception PEAR::error
|
||||||
*/
|
*/
|
||||||
function putFile($parid, $fileName,
|
function putFile($parid, $fileName,
|
||||||
$mediaFileLP, $mdataFileLP, $sessid='')
|
$mediaFileLP, $mdataFileLP, $sessid='', $gunid=NULL)
|
||||||
{
|
{
|
||||||
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
||||||
return $res;
|
return $res;
|
||||||
$name = "$fileName";
|
$name = "$fileName";
|
||||||
$id = $this->addObj($name , 'File', $parid);
|
$id = $this->addObj($name , 'File', $parid);
|
||||||
$ac =& StoredFile::insert(
|
$ac =& StoredFile::insert(
|
||||||
&$this, $id, $name, $mediaFileLP, $mdataFileLP
|
&$this, $id, $name, $mediaFileLP, $mdataFileLP, $gunid
|
||||||
);
|
);
|
||||||
if(PEAR::isError($ac)) return $ac;
|
if(PEAR::isError($ac)) return $ac;
|
||||||
return $id;
|
return $id;
|
||||||
|
@ -447,12 +452,6 @@ class GreenBox extends Alib{
|
||||||
GROUP BY md.gunid
|
GROUP BY md.gunid
|
||||||
");
|
");
|
||||||
if(!is_array($res)) $res = array();
|
if(!is_array($res)) $res = array();
|
||||||
/*
|
|
||||||
if(!(count($res)>0))
|
|
||||||
return PEAR::raiseError(
|
|
||||||
'GreenBox::localSearch: no items found', GBERR_NONE
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,30 +461,70 @@ class GreenBox extends Alib{
|
||||||
* Upload file to remote repository
|
* Upload file to remote repository
|
||||||
*
|
*
|
||||||
* @param id int, virt.file's local id
|
* @param id int, virt.file's local id
|
||||||
|
* @param gunid string, global id
|
||||||
* @param sessid string, session id
|
* @param sessid string, session id
|
||||||
* @return string - transfer id or PEAR::error
|
* @return string - transfer id or PEAR::error
|
||||||
*/
|
*/
|
||||||
function uploadFile($id, $sessid='')
|
function uploadFile($id, $gunid, $sessid='')
|
||||||
{
|
{
|
||||||
return PEAR::raiseError(
|
$res = $this->prepareForTransport($id, $gunid, $sessid);
|
||||||
'GreenBox::uploadFile: not implemented', GBERR_NOTIMPL
|
if(PEAR::isError($res)) return $res;
|
||||||
);
|
list($mediaFile, $mdataFile, $gunid) = $res;
|
||||||
|
$tr =& new Transport(&$this->dbc, $this->config);
|
||||||
|
$res = $tr->uploadOpen($mediaFile, 'media', $sessid, $gunid);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
$res2 = $tr->uploadOpen($mdataFile, 'metadata', $sessid, $gunid);
|
||||||
|
if(PEAR::isError($res2)) return $res2;
|
||||||
|
$res3 = $tr->getTransportStatus($res);
|
||||||
|
$res4 = $tr->getTransportStatus($res2);
|
||||||
|
# return $res;
|
||||||
|
return array($res, $res2, $res3, $res4);
|
||||||
|
# return PEAR::raiseError(
|
||||||
|
# 'GreenBox::uploadFile: not implemented', GBERR_NOTIMPL
|
||||||
|
# );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download file from remote repository
|
* Download file from remote repository
|
||||||
*
|
*
|
||||||
* @param id int, virt.file's local id
|
* @param gunid int, global unique id
|
||||||
* @param parid int, destination folder local id
|
|
||||||
* @param sessid string, session id
|
* @param sessid string, session id
|
||||||
* @return string - transfer id or PEAR::error
|
* @return string - transfer id or PEAR::error
|
||||||
*/
|
*/
|
||||||
function downloadFile($id, $parid, $sessid='')
|
function downloadFile($gunid, $sessid='')
|
||||||
{
|
{
|
||||||
return PEAR::raiseError(
|
$tr =& new Transport(&$this->dbc, $this->config);
|
||||||
'GreenBox::downloadFile: not implemented', GBERR_NOTIMPL
|
// get home dir if needed
|
||||||
|
$res = $tr->downloadOpen($sessid, 'media', $gunid,
|
||||||
|
$this->getSessUserId($sessid)
|
||||||
);
|
);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
$res2 = $tr->downloadOpen($sessid, 'metadata', $gunid,
|
||||||
|
$this->getSessUserId($sessid)
|
||||||
|
);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
$res3 = $tr->getTransportStatus($res);
|
||||||
|
$res4 = $tr->getTransportStatus($res2);
|
||||||
|
# return $res;
|
||||||
|
return array($res, $res2, $res3, $res4);
|
||||||
|
# return PEAR::raiseError(
|
||||||
|
# 'GreenBox::downloadFile: not implemented', GBERR_NOTIMPL
|
||||||
|
# );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for handling interupted transports via cron
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function cronJob()
|
||||||
|
{
|
||||||
|
$tr =& new Transport(&$this->dbc, $this->config);
|
||||||
|
$ru = $tr->uploadCron();
|
||||||
|
$rd = $tr->downloadCron(&$this);
|
||||||
|
return array($ru, $rd);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get status of asynchronous transfer
|
* Get status of asynchronous transfer
|
||||||
|
@ -502,6 +541,82 @@ class GreenBox extends Alib{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare symlink to media file and create metadata file for transport
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param gunid
|
||||||
|
* @param sessid
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function prepareForTransport($id, $gunid, $sessid='')
|
||||||
|
{
|
||||||
|
if(!$gunid) $gunid = $this->_gunidFromId($id);
|
||||||
|
else $id = $this->_idFromGunid($gunid);
|
||||||
|
$ac =& StoredFile::recall(&$this, '', $gunid);
|
||||||
|
if(PEAR::isError($ac)) return $ac;
|
||||||
|
$mediaTarget = $ac->_getRealRADFname();
|
||||||
|
$mediaFile = "$gunid";
|
||||||
|
$mdataFile = "$gunid.xml";
|
||||||
|
@symlink($mediaTarget, $this->transDir."/$mediaFile");
|
||||||
|
$mdata = $this->getMdata($id, $sessid);
|
||||||
|
if(PEAR::isError($mdata)) return $mdata;
|
||||||
|
if(!($fh = fopen($this->transDir."/$mdataFile", 'w'))) $res=FALSE;
|
||||||
|
else{
|
||||||
|
$res = fwrite($fh, $mdata);
|
||||||
|
fclose($fh);
|
||||||
|
}
|
||||||
|
if($res === FALSE) return PEAR::raiseError(
|
||||||
|
"GreenBox::prepareForTransport:".
|
||||||
|
" can't write metadata tmp file ($mdataFile)"
|
||||||
|
);
|
||||||
|
return array($mediaFile, $mdataFile, $gunid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert transported file and metadata into storage.<br>
|
||||||
|
* TODO: cals methods from LocStor - it's not good
|
||||||
|
*
|
||||||
|
* @param sessid string - session id
|
||||||
|
* @param file string - local path to filr
|
||||||
|
* @param type string - media|metadata|search
|
||||||
|
* @param gunid string - global unique id
|
||||||
|
*/
|
||||||
|
function processTransported($sessid, $file, $type, $gunid='X')
|
||||||
|
{
|
||||||
|
switch($type){
|
||||||
|
case 'media':
|
||||||
|
if(!file_exists($file)) break;
|
||||||
|
$res = $this->storeAudioClip($sessid, $gunid,
|
||||||
|
$file, '');
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
@unlink($file);
|
||||||
|
break;
|
||||||
|
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':
|
||||||
|
//$this->localSearch($criteria);
|
||||||
|
return PEAR::raiseError("processTranferred: search not implemented");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return PEAR::raiseError("processTranferred: unknown type ($type)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search in central metadata database
|
* Search in central metadata database
|
||||||
*
|
*
|
||||||
|
@ -514,6 +629,15 @@ class GreenBox extends Alib{
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'GreenBox::globalSearch: not implemented', GBERR_NOTIMPL
|
'GreenBox::globalSearch: not implemented', GBERR_NOTIMPL
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
|
$srchid = md5($sessid.mtime());
|
||||||
|
$fh = fopen($this->transDir."/$srchid", "w");
|
||||||
|
fwrite($fh, serialize($searchData));
|
||||||
|
fclose($fh);
|
||||||
|
$res = $tr->uploadOpen($srchid, 'search', $sessid, $gunid);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
return $res;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -561,7 +685,6 @@ class GreenBox extends Alib{
|
||||||
*/
|
*/
|
||||||
function getObjIdFromRelPath($id, $relPath='.')
|
function getObjIdFromRelPath($id, $relPath='.')
|
||||||
{
|
{
|
||||||
# $a = $this->getDir($id, 'id, name, type, param as target', 'name');
|
|
||||||
$a = split('/', $relPath);
|
$a = split('/', $relPath);
|
||||||
if($this->getObjType($id)!=='Folder') $nid = $this->getparent($id);
|
if($this->getObjType($id)!=='Folder') $nid = $this->getparent($id);
|
||||||
else $nid = $id;
|
else $nid = $id;
|
||||||
|
@ -577,9 +700,7 @@ class GreenBox extends Alib{
|
||||||
default:
|
default:
|
||||||
$nid = $this->getObjId($item, $nid);
|
$nid = $this->getObjId($item, $nid);
|
||||||
}
|
}
|
||||||
# $a[$i] = array('o'=>$item, 'n'=>($nid==null ? 'NULL' : $nid));
|
|
||||||
}
|
}
|
||||||
# return $a;
|
|
||||||
return $nid;
|
return $nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +851,27 @@ class GreenBox extends Alib{
|
||||||
$perm = $perm && $res;
|
$perm = $perm && $res;
|
||||||
}
|
}
|
||||||
if($perm) return TRUE;
|
if($perm) return TRUE;
|
||||||
return PEAR::raiseError("GreenBox::$method: access denied", GBERR_DENY);
|
$adesc = "[".join(',',$acts)."]";
|
||||||
|
return PEAR::raiseError("GreenBox::$adesc: access denied", GBERR_DENY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create fake session for downloaded files
|
||||||
|
*
|
||||||
|
* @param userid user id
|
||||||
|
* @return string sessid
|
||||||
|
*/
|
||||||
|
function _fakeSession($userid)
|
||||||
|
{
|
||||||
|
$sessid = $this->_createSessid();
|
||||||
|
if(PEAR::isError($sessid)) return $sessid;
|
||||||
|
$login = $this->getSubjName($userid);
|
||||||
|
$r = $this->dbc->query("INSERT INTO {$this->sessTable}
|
||||||
|
(sessid, userid, login, ts)
|
||||||
|
VALUES
|
||||||
|
('$sessid', '$userid', '$login', now())");
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
|
return $sessid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -746,6 +887,20 @@ class GreenBox extends Alib{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get global id from local id
|
||||||
|
*
|
||||||
|
* @param id int local id
|
||||||
|
* @return string global id
|
||||||
|
*/
|
||||||
|
function _gunidFromId($id)
|
||||||
|
{
|
||||||
|
if(!is_numeric($id)) return NULL;
|
||||||
|
return $this->dbc->getOne(
|
||||||
|
"SELECT gunid FROM {$this->filesTable} WHERE id='$id'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* =============================================== test and debug methods */
|
/* =============================================== test and debug methods */
|
||||||
/**
|
/**
|
||||||
* dump
|
* dump
|
||||||
|
@ -922,9 +1077,9 @@ class GreenBox extends Alib{
|
||||||
)");
|
)");
|
||||||
$this->dbc->query("CREATE INDEX {$this->accessTable}_acc_idx
|
$this->dbc->query("CREATE INDEX {$this->accessTable}_acc_idx
|
||||||
ON {$this->accessTable} (tmpLink, sessid)");
|
ON {$this->accessTable} (tmpLink, sessid)");
|
||||||
if(!file_exists("{$this->storageDir}/buffer")){
|
if(!file_exists($this->bufferDir)){
|
||||||
mkdir("{$this->storageDir}/buffer", 02775);
|
mkdir($this->bufferDir, 02775);
|
||||||
chmod("{$this->storageDir}/buffer", 02775);
|
chmod($this->bufferDir, 02775); // may be obsolete
|
||||||
}
|
}
|
||||||
$this->initData();
|
$this->initData();
|
||||||
}
|
}
|
||||||
|
@ -960,7 +1115,6 @@ class GreenBox extends Alib{
|
||||||
{
|
{
|
||||||
$dd = dir("{$this->storageDir}/$entry");
|
$dd = dir("{$this->storageDir}/$entry");
|
||||||
while (false !== ($ee = $dd->read())){
|
while (false !== ($ee = $dd->read())){
|
||||||
//if(substr($ee, -4)=='.mp3' || substr($ee, -4)=='.xml')
|
|
||||||
if(substr($ee, 0, 1)!=='.')
|
if(substr($ee, 0, 1)!=='.')
|
||||||
unlink("{$this->storageDir}/$entry/$ee");
|
unlink("{$this->storageDir}/$entry/$ee");
|
||||||
}
|
}
|
||||||
|
@ -969,12 +1123,12 @@ class GreenBox extends Alib{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(is_object($d)) $d->close();
|
if(is_object($d)) $d->close();
|
||||||
if(file_exists("{$this->storageDir}/buffer")){
|
if(file_exists($this->bufferDir)){
|
||||||
$d = dir("{$this->storageDir}/buffer");
|
$d = dir($this->bufferDir);
|
||||||
while (false !== ($entry = $d->read())) if(substr($entry,0,1)!='.')
|
while (false !== ($entry = $d->read())) if(substr($entry,0,1)!='.')
|
||||||
{ unlink("{$this->storageDir}/buffer/$entry"); }
|
{ unlink("{$this->bufferDir}/$entry"); }
|
||||||
$d->close();
|
$d->close();
|
||||||
rmdir("{$this->storageDir}/buffer");
|
rmdir($this->bufferDir);
|
||||||
}
|
}
|
||||||
parent::uninstall();
|
parent::uninstall();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/MetaData.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/MetaData.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -372,11 +372,16 @@ class MetaData{
|
||||||
AND subjns='_G' AND subject='{$this->gunid}'
|
AND subjns='_G' AND subject='{$this->gunid}'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($row)) return $row;
|
if(PEAR::isError($row)) return $row;
|
||||||
if(is_null($row)) return PEAR::raiseError(
|
if(is_null($row)){
|
||||||
"MetaData::genXMLDoc: not exists ({$this->gunid})"
|
// return PEAR::raiseError(
|
||||||
);
|
// "MetaData::genXMLDoc: not exists ({$this->gunid})"
|
||||||
$rr = $this->genXMLNode(&$domd, &$domd, $row);
|
// );
|
||||||
if(PEAR::isError($rr)) return $rr;
|
$nxn =& $domd->create_element('metadata');
|
||||||
|
$domd->append_child(&$nxn);
|
||||||
|
}else{
|
||||||
|
$rr = $this->genXMLNode(&$domd, &$domd, $row);
|
||||||
|
if(PEAR::isError($rr)) return $rr;
|
||||||
|
}
|
||||||
return preg_replace("|</([^>]*)>|", "</\\1>\n", $domd->dump_mem())."\n";
|
return preg_replace("|</([^>]*)>|", "</\\1>\n", $domd->dump_mem())."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,10 +408,11 @@ class MetaData{
|
||||||
");
|
");
|
||||||
if(!is_null($uri) && $uri !== ''){
|
if(!is_null($uri) && $uri !== ''){
|
||||||
$root =& $domd->document_element();
|
$root =& $domd->document_element();
|
||||||
$root->add_namespace($uri, $row['predns']);
|
# if($row['predns'] !== ''){
|
||||||
if($row['predns'] !== ''){
|
if($row['predns'] === '') $row['predns']='d';
|
||||||
|
$root->add_namespace($uri, $row['predns']);
|
||||||
$nxn->set_namespace($uri, $row['predns']);
|
$nxn->set_namespace($uri, $row['predns']);
|
||||||
}
|
# }
|
||||||
}
|
}
|
||||||
if($row['object'] != 'NULL'){
|
if($row['object'] != 'NULL'){
|
||||||
$tn =& $domd->create_text_node($row['object']);
|
$tn =& $domd->create_text_node($row['object']);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/RawMediaData.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/RawMediaData.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -62,16 +62,22 @@ class RawMediaData{
|
||||||
function insert($mediaFileLP)
|
function insert($mediaFileLP)
|
||||||
{
|
{
|
||||||
if($this->exists) return FALSE;
|
if($this->exists) return FALSE;
|
||||||
|
// for files downloaded from archive:
|
||||||
|
if($mediaFileLP == $this->fname){
|
||||||
|
$this->exists = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
umask(0002);
|
umask(0002);
|
||||||
if(@copy($mediaFileLP, $this->fname)){
|
if(@copy($mediaFileLP, $this->fname)){
|
||||||
// @chmod($this->fname, 0775);
|
// @chmod($this->fname, 0775);
|
||||||
$this->exists = TRUE;
|
$this->exists = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}else{
|
}else{
|
||||||
@unlink($this->fname);
|
// @unlink($this->fname);
|
||||||
$this->exists = FALSE;
|
$this->exists = FALSE;
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"RawMediaData::insert: file save failed", GBERR_FILEIO
|
"RawMediaData::insert: file save failed".
|
||||||
|
" ($mediaFileLP, {$this->fname})",GBERR_FILEIO
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -230,7 +230,7 @@ class StoredFile{
|
||||||
{
|
{
|
||||||
$this->dbc->query("BEGIN");
|
$this->dbc->query("BEGIN");
|
||||||
$res = $this->dbc->query("UPDATE {$this->filesTable}
|
$res = $this->dbc->query("UPDATE {$this->filesTable}
|
||||||
SET currentlyaccessing=currentlyaccessing+1
|
SET currentlyAccessing=currentlyAccessing+1
|
||||||
WHERE gunid='{$this->gunid}'");
|
WHERE gunid='{$this->gunid}'");
|
||||||
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; }
|
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; }
|
||||||
$accLinkName = $this->_getAccessFname($sessid, $this->_getExt());
|
$accLinkName = $this->_getAccessFname($sessid, $this->_getExt());
|
||||||
|
@ -261,11 +261,11 @@ class StoredFile{
|
||||||
{
|
{
|
||||||
$this->dbc->query("BEGIN");
|
$this->dbc->query("BEGIN");
|
||||||
$res = $this->dbc->query("UPDATE {$this->filesTable}
|
$res = $this->dbc->query("UPDATE {$this->filesTable}
|
||||||
SET currentlyaccessing=currentlyaccessing-1
|
SET currentlyAccessing=currentlyAccessing-1
|
||||||
WHERE gunid='{$this->gunid}' AND currentlyaccessing>0"
|
WHERE gunid='{$this->gunid}' AND currentlyAccessing>0"
|
||||||
);
|
);
|
||||||
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; }
|
if(PEAR::isError($res)){ $this->dbc->query("ROLLBACK"); return $res; }
|
||||||
$ca = $this->dbc->getOne("SELECT currentlyaccessing
|
$ca = $this->dbc->getOne("SELECT currentlyAccessing
|
||||||
FROM {$this->filesTable}
|
FROM {$this->filesTable}
|
||||||
WHERE gunid='{$this->gunid}'"
|
WHERE gunid='{$this->gunid}'"
|
||||||
);
|
);
|
||||||
|
@ -481,6 +481,7 @@ class StoredFile{
|
||||||
function _getResDir()
|
function _getResDir()
|
||||||
{
|
{
|
||||||
$resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3);
|
$resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3);
|
||||||
|
// see Transport::_getResDir too for resDir name create code
|
||||||
if(!file_exists($resDir)){ mkdir($resDir, 02775); chmod($resDir, 02775); }
|
if(!file_exists($resDir)){ mkdir($resDir, 02775); chmod($resDir, 02775); }
|
||||||
return $resDir;
|
return $resDir;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,18 +23,11 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Transport.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Transport.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
include("xmlrpc/xmlrpc.inc");
|
include_once "xmlrpc/xmlrpc.inc";
|
||||||
|
|
||||||
$config['archiveUrlPath'] = '/livesupport/modules/archiveServer/var';
|
|
||||||
$config['archiveXMLRPC'] = 'xmlrpc/xrArchive.php';
|
|
||||||
$config['archiveUrlHost'] = 'localhost';
|
|
||||||
$config['archiveUrlPort'] = 80;
|
|
||||||
$config['archiveAccountLogin'] = 'root';
|
|
||||||
$config['archiveAccountPass'] = 'q';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for handling file tranport between StorageServer and ArchiveServer<br>
|
* Class for handling file tranport between StorageServer and ArchiveServer<br>
|
||||||
|
@ -54,269 +47,26 @@ class Transport{
|
||||||
*/
|
*/
|
||||||
function Transport(&$dbc, $config)
|
function Transport(&$dbc, $config)
|
||||||
{
|
{
|
||||||
$this->dbc =& $dbc;
|
$this->dbc =& $dbc;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->transTable = $config['tblNamePrefix'].'trans';
|
$this->transTable = $config['tblNamePrefix'].'trans';
|
||||||
}
|
$this->transDir = $config['transDir'];
|
||||||
|
|
||||||
/**
|
|
||||||
* Start of download<br>
|
|
||||||
* - create transport record<br>
|
|
||||||
* - call archive.downloadOpen<br>
|
|
||||||
*
|
|
||||||
* @param gunid
|
|
||||||
*/
|
|
||||||
function downloadFile($gunid)
|
|
||||||
{
|
|
||||||
$res = $this->xmlrpcCall(
|
|
||||||
'archive.login',
|
|
||||||
array(
|
|
||||||
'login'=>$this->config['archiveAccountLogin'],
|
|
||||||
'pass'=>$this->config['archiveAccountPass']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
$sessid = $res;
|
|
||||||
// call archive.downloadOpen
|
|
||||||
$res = $this->xmlrpcCall(
|
|
||||||
'archive.downloadOpen', array('sessid'=>$sessid, 'gunid'=>$gunid)
|
|
||||||
);
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
$file = $res;
|
|
||||||
// insert transport record to db
|
|
||||||
$id = $this->dbc->nextId("{$this->transTable}_id_seq");
|
|
||||||
$res = $this->dbc->query("
|
|
||||||
INSERT INTO {$this->transTable}
|
|
||||||
(id, direction, state, gunid, type, sessid, md5h, url, fname)
|
|
||||||
VALUES (
|
|
||||||
$id, 'down', 'pending', '$gunid', 'file', '$sessid',
|
|
||||||
'{$file['md5h']}', '{$file['url']}', '{$file['fname']}'
|
|
||||||
)
|
|
||||||
");
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
#?? $this->downloadCron();
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cron method for download.<br>
|
|
||||||
* Should be called periodically.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function downloadCron()
|
|
||||||
{
|
|
||||||
// fetch all pending downloads
|
|
||||||
$rows = $this->dbc->getAll("
|
|
||||||
SELECT id, url, md5h, fname
|
|
||||||
FROM {$this->transTable}
|
|
||||||
WHERE direction='down' AND state='pending'
|
|
||||||
");
|
|
||||||
// for all pending downloads:
|
|
||||||
foreach($rows as $i=>$row){
|
|
||||||
// wget the file
|
|
||||||
$res = system(
|
|
||||||
"wget -q -c --timeout={$this->timeout}".
|
|
||||||
" --waitretry={$this->waitretry}".
|
|
||||||
" -t {$this->retries} {$row['url']}",
|
|
||||||
$status
|
|
||||||
);
|
|
||||||
// check consistency
|
|
||||||
$md5h = $this->_md5sum($row['fname']);
|
|
||||||
if($status == 0){
|
|
||||||
if($md5h == $row['md5h']){
|
|
||||||
// mark download as finished
|
|
||||||
$this->dbc->query("
|
|
||||||
UPDATE {$this->transTable}
|
|
||||||
SET state='finished'
|
|
||||||
WHERE id='{$row['id']}'
|
|
||||||
");
|
|
||||||
}else{
|
|
||||||
@unlink($fname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fetch all finished downloads
|
|
||||||
$rows = $this->dbc->getAll("
|
|
||||||
SELECT id, url, md5h, sessid
|
|
||||||
FROM {$this->transTable}
|
|
||||||
WHERE direction='down' AND state='finished'
|
|
||||||
");
|
|
||||||
// for all finished downloads:
|
|
||||||
foreach($rows as $i=>$row){
|
|
||||||
$res = $this->xmlrpcCall(
|
|
||||||
'archive.downloadClose',
|
|
||||||
array('sessid'=>$row['sessid'], 'url'=>$row['url'])
|
|
||||||
);
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
// close download in db TODO: or delete record?
|
|
||||||
$this->dbc->query("
|
|
||||||
UPDATE {$this->transTable}
|
|
||||||
SET state='closed'
|
|
||||||
WHERE id='{$row['id']}'
|
|
||||||
");
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start of upload
|
|
||||||
*
|
|
||||||
* @param fname
|
|
||||||
* @param gunid
|
|
||||||
*/
|
|
||||||
function uploadFile($fname, $gunid)
|
|
||||||
{
|
|
||||||
$res = $this->xmlrpcCall(
|
|
||||||
'archive.login',
|
|
||||||
array(
|
|
||||||
'login'=>$this->config['archiveAccountLogin'],
|
|
||||||
'pass'=>$this->config['archiveAccountPass']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
$sessid = $res;
|
|
||||||
$file = $this->xmlrpcCall(
|
|
||||||
'archive.uploadOpen', array('sessid'=>$sessid, 'gunid'=>$gunid)
|
|
||||||
);
|
|
||||||
if(PEAR::isError($file)) return $file;
|
|
||||||
$md5h = $this->_md5sum($fname);
|
|
||||||
$id = $this->dbc->nextId("{$this->transTable}_id_seq");
|
|
||||||
$res = $this->dbc->query("
|
|
||||||
INSERT INTO {$this->transTable}
|
|
||||||
(id, direction, state, gunid, type, sessid, md5h, url, fname)
|
|
||||||
VALUES (
|
|
||||||
$id, 'up', 'pending', '$gunid', 'file', '$sessid',
|
|
||||||
'$md5h', '{$file['url']}', '$fname'
|
|
||||||
)
|
|
||||||
");
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
#?? $this->uploadCron();
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cron method for upload.<br>
|
|
||||||
* Should be called periodically.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function uploadCron()
|
|
||||||
{
|
|
||||||
// fetch all pending uploads
|
|
||||||
$rows = $this->dbc->getAll("
|
|
||||||
SELECT id, sessid, gunid, fname, url, md5h
|
|
||||||
FROM {$this->transTable}
|
|
||||||
WHERE direction='up' AND state='pending'
|
|
||||||
");
|
|
||||||
// for all pending uploads:
|
|
||||||
foreach($rows as $i=>$row){
|
|
||||||
$file = $this->uploadCheck($row['sessid'], $row['url']);
|
|
||||||
if(PEAR::isError($file)) return $file;
|
|
||||||
// test filesize
|
|
||||||
if(intval($file['size']) < filesize($row['fname'])){
|
|
||||||
// not finished - upload next part
|
|
||||||
$res = system(
|
|
||||||
"curl -s -C {$file['size']} --max-time 600".
|
|
||||||
" --speed-time 20 --speed-limit 500".
|
|
||||||
" --connect-timeout 20".
|
|
||||||
" -T {$row['fname']} {$row['url']}",
|
|
||||||
$status
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
// hmmm - we are finished? strage, but we'll try to continue
|
|
||||||
$status = 0;
|
|
||||||
}
|
|
||||||
if($status == 0){
|
|
||||||
$file = $this->uploadCheck($row['sessid'], $row['url']);
|
|
||||||
if(PEAR::isError($file)) return $file;
|
|
||||||
// test checksum
|
|
||||||
if($file['md5h'] == $row['md5h']){
|
|
||||||
// finished
|
|
||||||
$res = $this->dbc->query("
|
|
||||||
UPDATE {$this->transTable} SET state='finished'
|
|
||||||
WHERE id='{$row['id']}'
|
|
||||||
");
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
}else{
|
|
||||||
if(intval($file['size']) >= filesize($row['fname'])){
|
|
||||||
// wrong md5 at finish - we probably have to start again
|
|
||||||
// $this->xmlrpcCall('archive.uploadReset', array());
|
|
||||||
return PEAR::raiseError(
|
|
||||||
"Transport::uploadCron: file uploaded with bad md5"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fetch all finished uploads
|
|
||||||
$rows = $this->dbc->getAll("
|
|
||||||
SELECT id, sessid, gunid, fname, url, md5h
|
|
||||||
FROM {$this->transTable}
|
|
||||||
WHERE direction='up' AND state='finished'
|
|
||||||
");
|
|
||||||
// for all finished uploads:
|
|
||||||
foreach($rows as $i=>$row){
|
|
||||||
$res = $this->xmlrpcCall(
|
|
||||||
'archive.uploadClose',
|
|
||||||
array('sessid'=>$row['sessid'], 'url'=>$row['url'])
|
|
||||||
);
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
// close upload in db TODO: or delete record?
|
|
||||||
$this->dbc->query("
|
|
||||||
UPDATE {$this->transTable} SET state='closed'
|
|
||||||
WHERE id='{$row['id']}'
|
|
||||||
");
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check state of uploaded file
|
|
||||||
*
|
|
||||||
* @param sessid
|
|
||||||
* @param url
|
|
||||||
* @return hash: md5h, size, url
|
|
||||||
*/
|
|
||||||
function uploadCheck($sessid, $url)
|
|
||||||
{
|
|
||||||
$file = $this->xmlrpcCall(
|
|
||||||
'archive.uploadCheck',
|
|
||||||
array('sessid'=>$sessid, 'url'=>$url)
|
|
||||||
);
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abort pending upload
|
|
||||||
*
|
|
||||||
* @param id local tranport id
|
|
||||||
*/
|
|
||||||
function uploadAbort($id)
|
|
||||||
{
|
|
||||||
$row = $this->dbc->getRow("
|
|
||||||
SELECT id, sessid, gunid, fname, url
|
|
||||||
FROM {$this->transTable}
|
|
||||||
WHERE id='$id'
|
|
||||||
");
|
|
||||||
if(PEAR::isError($row)) return $row;
|
|
||||||
$res = $this->xmlrpcCall('archive.uploadAbort',
|
|
||||||
array('sessid'=>$row['sessid'], 'url'=>$row['url'])
|
|
||||||
);
|
|
||||||
if(PEAR::isError($res)) return $res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return state of transport job
|
* Return state of transport job
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getTransportStatus($id)
|
function getTransportStatus($trid)
|
||||||
{
|
{
|
||||||
$row = $this->dbc->getRow(
|
$row = $this->dbc->getRow(
|
||||||
"SELECT state FROM {$this->transTable} WHERE id='$id'"
|
"SELECT state FROM {$this->transTable} WHERE trid='$trid'"
|
||||||
);
|
);
|
||||||
if(PEAR::isError($res)) return $res;
|
if(PEAR::isError($res)) return $res;
|
||||||
return $row['state'];
|
return $row['state'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================================= search methods */
|
||||||
/**
|
/**
|
||||||
* Start search in archive
|
* Start search in archive
|
||||||
*/
|
*/
|
||||||
|
@ -337,17 +87,327 @@ class Transport{
|
||||||
// not implemented yet
|
// not implemented yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================= general file transport methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function uploadOpen($file, $type, $sessid='', $gunid='X')
|
||||||
|
{
|
||||||
|
$trid = $this->_createTrId();
|
||||||
|
$md5h = $this->_md5sum($this->transDir."/$file");
|
||||||
|
$id = $this->dbc->nextId("{$this->transTable}_id_seq");
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
INSERT INTO {$this->transTable}
|
||||||
|
(id, trid, direction, state, type,
|
||||||
|
md5h, url, fname, gunid
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
($id, '$trid', 'up', 'init', '$type',
|
||||||
|
'$md5h', '', '$file', '$gunid'
|
||||||
|
)
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
#?? $this->uploadCron();
|
||||||
|
return $trid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function uploadCron()
|
||||||
|
{
|
||||||
|
// fetch all opened uploads
|
||||||
|
$rows = $this->dbc->getAll("
|
||||||
|
SELECT * FROM {$this->transTable}
|
||||||
|
WHERE direction='up' AND state<>'closed'
|
||||||
|
");
|
||||||
|
if(count($rows)==0) return TRUE;
|
||||||
|
$asessid = $this->loginToArchive();
|
||||||
|
chdir($this->config['transDir']);
|
||||||
|
// for all opened uploads:
|
||||||
|
foreach($rows as $i=>$row){
|
||||||
|
switch($row['state']){
|
||||||
|
case"init": // ------ new uploads
|
||||||
|
$finf = $this->xmlrpcCall( 'archive.uploadOpen',
|
||||||
|
array('sessid'=>$asessid, 'trid'=>$row['trid'],
|
||||||
|
'type'=>$row['type']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if(PEAR::isError($finf)) return $finf;
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
UPDATE {$this->transTable}
|
||||||
|
SET state='pending', url='{$finf['url']}'
|
||||||
|
WHERE id='{$row['id']}'
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
$row['url'] = $finf['url'];
|
||||||
|
#break;
|
||||||
|
case"pending": // ------ pending uploads
|
||||||
|
$finf = $this->uploadCheck($asessid, $row['url']);
|
||||||
|
if(PEAR::isError($finf)) return $finf;
|
||||||
|
// test filesize
|
||||||
|
if(intval($finf['size']) < filesize($row['fname'])){
|
||||||
|
// not finished - upload next part
|
||||||
|
$res = system(
|
||||||
|
"curl -s -C {$finf['size']} --max-time 600".
|
||||||
|
" --speed-time 20 --speed-limit 500".
|
||||||
|
" --connect-timeout 20".
|
||||||
|
" -T {$row['fname']} {$row['url']}",
|
||||||
|
$status
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
// hmmm - we are finished? OK - continue
|
||||||
|
$status = 0;
|
||||||
|
}
|
||||||
|
if($status == 0 || $status == 18){
|
||||||
|
$finf = $this->uploadCheck($asessid, $row['url']);
|
||||||
|
if(PEAR::isError($finf)) return $finf;
|
||||||
|
// test checksum
|
||||||
|
if($finf['md5h'] == $row['md5h']){
|
||||||
|
// finished
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
UPDATE {$this->transTable} SET state='finished'
|
||||||
|
WHERE id='{$row['id']}'
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
}else{
|
||||||
|
if(intval($finf['size']) >= filesize($row['fname']))
|
||||||
|
{
|
||||||
|
// wrong md5 at finish - TODO: start again
|
||||||
|
// $this->xmlrpcCall('archive.uploadReset', array());
|
||||||
|
return PEAR::raiseError("Transport::uploadCron:".
|
||||||
|
" file uploaded with bad md5"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#break;
|
||||||
|
case"finished": // ------ finished uploads
|
||||||
|
$res = $this->xmlrpcCall(
|
||||||
|
'archive.uploadClose',
|
||||||
|
array('sessid'=>$asessid,
|
||||||
|
'url'=>$row['url'], 'type'=>$row['type'],
|
||||||
|
'gunid'=>$row['gunid'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
@unlink($this->transDir."/".$row['fname']);
|
||||||
|
// close upload in db TODO: or delete record?
|
||||||
|
$this->dbc->query("
|
||||||
|
UPDATE {$this->transTable} SET state='closed'
|
||||||
|
WHERE id='{$row['id']}'
|
||||||
|
");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo "Transport::uploadCron: unknown state".
|
||||||
|
" '{$row['state']}' (id={$row['id']})\n";
|
||||||
|
} // switch state
|
||||||
|
} // foreach opened
|
||||||
|
$this->logoutFromArchive($asessid);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check state of uploaded file
|
||||||
|
*
|
||||||
|
* @param sessid
|
||||||
|
* @param url
|
||||||
|
* @return hash: md5h, size, url
|
||||||
|
*/
|
||||||
|
function uploadCheck($sessid, $url)
|
||||||
|
{
|
||||||
|
$finf = $this->xmlrpcCall(
|
||||||
|
'archive.uploadCheck',
|
||||||
|
array('sessid'=>$sessid, 'url'=>$url)
|
||||||
|
);
|
||||||
|
return $finf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function downloadOpen($sessid, $type, $gunid, $uid)
|
||||||
|
{
|
||||||
|
// insert transport record to db
|
||||||
|
$trid = $this->_createTrId();
|
||||||
|
$id = $this->dbc->nextId("{$this->transTable}_id_seq");
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
INSERT INTO {$this->transTable}
|
||||||
|
(id, trid, direction, state, type,
|
||||||
|
gunid, sessid, uid
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
($id, '$trid', 'down', 'init', '$type',
|
||||||
|
'$gunid', '$sessid', $uid
|
||||||
|
)
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
#?? $this->downloadCron();
|
||||||
|
return $trid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function downloadCron(&$gb)
|
||||||
|
{
|
||||||
|
// fetch all opened downloads
|
||||||
|
$rows = $this->dbc->getAll("
|
||||||
|
SELECT * FROM {$this->transTable}
|
||||||
|
WHERE direction='down' AND state<>'closed'
|
||||||
|
");
|
||||||
|
if(count($rows)==0) return TRUE;
|
||||||
|
$asessid = $this->loginToArchive();
|
||||||
|
chdir($this->config['transDir']);
|
||||||
|
// for all opened downloads:
|
||||||
|
foreach($rows as $i=>$row){
|
||||||
|
switch($row['state']){
|
||||||
|
case"init": // ------ new downloads
|
||||||
|
// call archive.downloadOpen
|
||||||
|
$finf = $this->xmlrpcCall(
|
||||||
|
'archive.downloadOpen',
|
||||||
|
array('sessid'=>$asessid, 'type'=>$row['type'],
|
||||||
|
'par'=>$row['gunid']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if(PEAR::isError($finf)) return $finf;
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
UPDATE {$this->transTable}
|
||||||
|
SET state='pending', url='{$finf['url']}',
|
||||||
|
md5h='{$finf['md5h']}', fname='{$finf['fname']}'
|
||||||
|
WHERE id='{$row['id']}'
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
$row = array_merge($row, $finf);
|
||||||
|
#break;
|
||||||
|
case"pending": // ------ pending downloads
|
||||||
|
// wget the file
|
||||||
|
$res = system(
|
||||||
|
"wget -q -c --timeout={$this->timeout}".
|
||||||
|
" --waitretry={$this->waitretry}".
|
||||||
|
" -t {$this->retries} {$row['url']}",
|
||||||
|
$status
|
||||||
|
);
|
||||||
|
// check consistency
|
||||||
|
$md5h = $this->_md5sum($row['fname']);
|
||||||
|
if($status == 0){
|
||||||
|
if($md5h == $row['md5h']){
|
||||||
|
// mark download as finished
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
UPDATE {$this->transTable}
|
||||||
|
SET state='finished'
|
||||||
|
WHERE id='{$row['id']}'
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
}else{
|
||||||
|
@unlink($row['fname']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#break;
|
||||||
|
case"finished": // ------ finished downloads
|
||||||
|
// call archive that downloads have been finished OK
|
||||||
|
$res = $this->xmlrpcCall(
|
||||||
|
'archive.downloadClose',
|
||||||
|
array('sessid'=>$asessid, 'url'=>$row['url'])
|
||||||
|
);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
// process file in fake session
|
||||||
|
$lsessid = $gb->_fakeSession($row['uid']);
|
||||||
|
if(PEAR::isError($lsessid)) return $lsessid;
|
||||||
|
$res = $gb->processTransported(
|
||||||
|
$lsessid, $row['fname'], $row['type'], $row['gunid']
|
||||||
|
);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
$res = $gb->logout($lsessid);
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
|
||||||
|
// close download in db TODO: or delete record?
|
||||||
|
$res = $this->dbc->query("
|
||||||
|
UPDATE {$this->transTable}
|
||||||
|
SET state='closed'
|
||||||
|
WHERE id='{$row['id']}'
|
||||||
|
");
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo "Transport::downloadCron: unknown state".
|
||||||
|
" '{$row['state']}' (id={$row['id']})\n";
|
||||||
|
} // switch state
|
||||||
|
} // foreach opened
|
||||||
|
$this->logoutFromArchive($asessid);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================== authentication methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login to archive server
|
||||||
|
*
|
||||||
|
* @return string sessid or error
|
||||||
|
*/
|
||||||
|
function loginToArchive()
|
||||||
|
{
|
||||||
|
$res = $this->xmlrpcCall(
|
||||||
|
'archive.login',
|
||||||
|
array(
|
||||||
|
'login'=>$this->config['archiveAccountLogin'],
|
||||||
|
'pass'=>$this->config['archiveAccountPass']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout from archive server
|
||||||
|
*
|
||||||
|
* @param sessid session id
|
||||||
|
* @return string Bye or error
|
||||||
|
*/
|
||||||
|
function logoutFromArchive($sessid)
|
||||||
|
{
|
||||||
|
$res = $this->xmlrpcCall(
|
||||||
|
'archive.logout',
|
||||||
|
array(
|
||||||
|
'sessid'=>$sessid,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==================================================== auxiliary methods */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function _createTrId()
|
||||||
|
{
|
||||||
|
return md5(microtime().$_SERVER['SERVER_ADDR'].rand().
|
||||||
|
"org.mdlf.livesupport");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function _getResDir($gunid)
|
||||||
|
{
|
||||||
|
$resDir = $this->config['storageDir']."/".substr($gunid, 0, 3);
|
||||||
|
if(!file_exists($resDir)){ mkdir($resDir, 02775); chmod($resDir, 02775); }
|
||||||
|
return $resDir;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XMLRPC call to archive
|
* XMLRPC call to archive
|
||||||
*/
|
*/
|
||||||
function xmlrpcCall($method, $pars=array())
|
function xmlrpcCall($method, $pars=array())
|
||||||
{
|
{
|
||||||
|
$xrp = xmlrpc_encoder($pars);
|
||||||
$c = new xmlrpc_client(
|
$c = new xmlrpc_client(
|
||||||
"{$this->config['archiveUrlPath']}/".
|
"{$this->config['archiveUrlPath']}/".
|
||||||
"{$this->config['archiveXMLRPC']}",
|
"{$this->config['archiveXMLRPC']}",
|
||||||
$this->config['archiveUrlHost'], $this->config['archiveUrlPort']
|
$this->config['archiveUrlHost'], $this->config['archiveUrlPort']
|
||||||
);
|
);
|
||||||
$f=new xmlrpcmsg($method, array(xmlrpc_encoder($pars)));
|
$f=new xmlrpcmsg($method, array($xrp));
|
||||||
$r = $c->send($f);
|
$r = $c->send($f);
|
||||||
if ($r->faultCode()>0) {
|
if ($r->faultCode()>0) {
|
||||||
return PEAR::raiseError($r->faultString(), $r->faultCode());
|
return PEAR::raiseError($r->faultString(), $r->faultCode());
|
||||||
|
@ -367,6 +427,7 @@ class Transport{
|
||||||
return $arr[0];
|
return $arr[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ====================================================== install methods */
|
||||||
/**
|
/**
|
||||||
* Install method<br>
|
* Install method<br>
|
||||||
* state: pending, finished, closed
|
* state: pending, finished, closed
|
||||||
|
@ -375,19 +436,24 @@ class Transport{
|
||||||
{
|
{
|
||||||
$this->dbc->query("CREATE TABLE {$this->transTable} (
|
$this->dbc->query("CREATE TABLE {$this->transTable} (
|
||||||
id int not null,
|
id int not null,
|
||||||
gunid char(32) not null,
|
trid char(32) not null,
|
||||||
md5h char(32) not null,
|
|
||||||
sessid char(32) not null,
|
|
||||||
url varchar(255) not null,
|
|
||||||
fname varchar(255) not null,
|
|
||||||
type varchar(128) not null, -- file | searchJob
|
|
||||||
direction varchar(128) not null, -- down | up
|
direction varchar(128) not null, -- down | up
|
||||||
state varchar(128) not null,
|
state varchar(128) not null,
|
||||||
|
type varchar(128) not null, -- file | searchJob
|
||||||
|
md5h char(32),
|
||||||
|
url varchar(255),
|
||||||
|
fname varchar(255),
|
||||||
|
gunid char(32),
|
||||||
|
sessid char(32),
|
||||||
|
uid int,
|
||||||
|
parid int,
|
||||||
ts timestamp
|
ts timestamp
|
||||||
)");
|
)");
|
||||||
$this->dbc->createSequence("{$this->transTable}_id_seq");
|
$this->dbc->createSequence("{$this->transTable}_id_seq");
|
||||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_id_idx
|
$this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_id_idx
|
||||||
ON {$this->transTable} (id)");
|
ON {$this->transTable} (id)");
|
||||||
|
$this->dbc->query("CREATE INDEX {$this->transTable}_trid_idx
|
||||||
|
ON {$this->transTable} (trid)");
|
||||||
$this->dbc->query("CREATE INDEX {$this->transTable}_gunid_idx
|
$this->dbc->query("CREATE INDEX {$this->transTable}_gunid_idx
|
||||||
ON {$this->transTable} (gunid)");
|
ON {$this->transTable} (gunid)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -58,6 +58,21 @@ $config = array(
|
||||||
'editPrivs', 'write', 'read', 'classes', 'subjects'
|
'editPrivs', 'write', 'read', 'classes', 'subjects'
|
||||||
),
|
),
|
||||||
'storageDir' => dirname(getcwd()).'/stor',
|
'storageDir' => dirname(getcwd()).'/stor',
|
||||||
|
'bufferDir' => dirname(getcwd()).'/stor/buffer',
|
||||||
|
'transDir' => dirname(getcwd()).'/trans',
|
||||||
'accessDir' => dirname(getcwd()).'/access',
|
'accessDir' => dirname(getcwd()).'/access',
|
||||||
|
|
||||||
|
'storageUrlPath' => '/livesupport/modules/storageServer/var',
|
||||||
|
'storageXMLRPC' => 'xmlrpc/xrLocStor.php',
|
||||||
|
'storageUrlHost' => 'localhost',
|
||||||
|
'storageUrlPort' => 80,
|
||||||
|
|
||||||
|
'archiveUrlPath' => '/livesupport/modules/archiveServer/var',
|
||||||
|
'archiveXMLRPC' => 'xmlrpc/xrArchive.php',
|
||||||
|
'archiveUrlHost' => 'localhost',
|
||||||
|
'archiveUrlPort' => 80,
|
||||||
|
'archiveAccountLogin' => 'root',
|
||||||
|
'archiveAccountPass' => 'q',
|
||||||
|
|
||||||
);
|
);
|
||||||
?>
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/php -q
|
||||||
|
<?php
|
||||||
|
require_once "../conf.php";
|
||||||
|
require_once "DB.php";
|
||||||
|
require_once '../LocStor.php';
|
||||||
|
|
||||||
|
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
|
$dbc = DB::connect($config['dsn'], TRUE);
|
||||||
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$gb = &new LocStor(&$dbc, $config);
|
||||||
|
|
||||||
|
$res = $gb->cronJob();
|
||||||
|
|
||||||
|
var_dump($res);
|
||||||
|
?>
|
|
@ -77,7 +77,7 @@ $tpldata['showMenu']=true;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html><head>
|
<html><head>
|
||||||
<title>Browser</title>
|
<title>Storage - browser</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<link rel="stylesheet" type="text/css" href="default.css">
|
<link rel="stylesheet" type="text/css" href="default.css">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
|
@ -42,8 +42,8 @@ switch($_REQUEST['act']){
|
||||||
// --- files ---
|
// --- files ---
|
||||||
case"upload":
|
case"upload":
|
||||||
$tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.livesupport");
|
$tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.livesupport");
|
||||||
$ntmp = "{$gb->storageDir}/buffer/$tmpgunid";
|
$ntmp = "{$gb->bufferDir}/$tmpgunid";
|
||||||
# $ntmp = tempnam(""{$gb->storageDir}/buffer", 'gbTmp_');
|
# $ntmp = tempnam(""{$gb->bufferDir}", 'gbTmp_');
|
||||||
$mdtmp = "";
|
$mdtmp = "";
|
||||||
move_uploaded_file($_FILES['mediafile']['tmp_name'], $ntmp); chmod($ntmp, 0664);
|
move_uploaded_file($_FILES['mediafile']['tmp_name'], $ntmp); chmod($ntmp, 0664);
|
||||||
if($_FILES['mdatafile']['tmp_name']){
|
if($_FILES['mdatafile']['tmp_name']){
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?
|
||||||
|
header("Content-type: text/plain");
|
||||||
|
$gid = posix_getgid();
|
||||||
|
$egid = posix_getegid();
|
||||||
|
$info = posix_getgrgid($egid);
|
||||||
|
echo $info['name'];
|
||||||
|
?>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?
|
||||||
|
header("Content-type: text/plain");
|
||||||
|
require "../conf.php";
|
||||||
|
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||||
|
"{$config['storageUrlPath']}";
|
||||||
|
?>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?
|
||||||
|
header("Content-type: text/plain");
|
||||||
|
require "../conf.php";
|
||||||
|
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||||
|
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
||||||
|
?>
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/install/install.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/install/install.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -53,10 +53,6 @@ if(PEAR::isError($dbc)){
|
||||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
$gb = &new GreenBox(&$dbc, $config);
|
$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 "Storage: Install ...\n";
|
echo "Storage: Install ...\n";
|
||||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
$gb->uninstall();
|
$gb->uninstall();
|
||||||
|
|
|
@ -1,30 +1,37 @@
|
||||||
<?php
|
<?
|
||||||
require_once "../conf.php";
|
header("Content-type: text/plain");
|
||||||
require_once "DB.php";
|
echo "\nTransport test\n\n";
|
||||||
require_once "../Transport.php";
|
|
||||||
|
|
||||||
|
require_once '../conf.php';
|
||||||
|
require_once 'DB.php';
|
||||||
|
require_once '../LocStor.php';
|
||||||
|
|
||||||
|
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
$dbc = DB::connect($config['dsn'], TRUE);
|
$dbc = DB::connect($config['dsn'], TRUE);
|
||||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
$gb = &new LocStor(&$dbc, $config);
|
||||||
|
|
||||||
$tr =& new Transport(&$dbc, $config);
|
$gunid = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
|
||||||
|
$mediaFile = '../tests/ex1.mp3';
|
||||||
|
$mdataFile = '../tests/mdata1.xml';
|
||||||
|
|
||||||
$gunid = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
echo"login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||||
|
|
||||||
#$r = $tr->install(); var_dump($r);
|
echo"Store:\n";
|
||||||
#$r = $tr->uninstall(); var_dump($r);
|
$r = $gb->storeAudioClip($sessid, $gunid, $mediaFile, $mdataFile); var_dump($r);
|
||||||
#$r = $tr->getTransportStatus(); var_dump($r);
|
|
||||||
|
echo"Upload:\n"; $r = $gb->uploadFile('', $gunid, $sessid); var_dump($r);
|
||||||
|
|
||||||
echo "uploadFile:\n";
|
echo"Cron:\n"; $r = $gb->cronJob(); var_dump($r);
|
||||||
$r = $tr->uploadFile('ex2.wav', $gunid); var_dump($r);
|
|
||||||
echo "uploadCron:\n";
|
|
||||||
$r = $tr->uploadCron(); var_dump($r);
|
|
||||||
|
|
||||||
echo "downloadFile:\n";
|
echo"Delete:\n"; $r = $gb->deleteAudioClip($sessid, $gunid); var_dump($r);
|
||||||
$r = $tr->downloadFile($gunid); var_dump($r);
|
|
||||||
echo "downloadCron:\n";
|
|
||||||
$r = $tr->downloadCron(); var_dump($r);
|
|
||||||
|
|
||||||
#$r = $tr->uploadAbort(1); var_dump($r);
|
echo"Download:\n"; $r = $gb->downloadFile($gunid, $sessid); var_dump($r);
|
||||||
|
|
||||||
|
echo"Cron:\n"; $r = $gb->cronJob(); var_dump($r);
|
||||||
|
|
||||||
|
echo"logout: ".($r = $gb->logout($sessid))."\n";
|
||||||
|
|
||||||
|
echo"\n";
|
||||||
?>
|
?>
|
|
@ -23,7 +23,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: tomas $
|
# Author : $Author: tomas $
|
||||||
# Version : $Revision: 1.2 $
|
# Version : $Revision: 1.3 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ COMM=$1
|
||||||
shift
|
shift
|
||||||
GUNID=$1
|
GUNID=$1
|
||||||
|
|
||||||
XMLRPC=http://localhost:80/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php
|
#XMLRPC=http://localhost:80/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php
|
||||||
|
XMLRPC=`cd var/install; php -q getXrUrl.php`
|
||||||
echo "XMLRPC server URL (check it in troubles):"
|
echo "XMLRPC server URL (check it in troubles):"
|
||||||
echo $XMLRPC
|
echo $XMLRPC
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue