diff --git a/livesupport/src/modules/htmlUI/var/templates/playlist/import.tpl b/livesupport/src/modules/htmlUI/var/templates/playlist/import.tpl
new file mode 100755
index 000000000..692993a11
--- /dev/null
+++ b/livesupport/src/modules/htmlUI/var/templates/playlist/import.tpl
@@ -0,0 +1,6 @@
+
+
##Import Playlist##
+ {*UIBROWSER->fileForm id=$editItem.id folderId=$editItem.folderId assign="dynform"*}
+ {include file="sub/dynForm_plain.tpl}
+ {assign var="_uploadform" value=null}
+
diff --git a/livesupport/src/modules/htmlUI/var/ui_search.class.php b/livesupport/src/modules/htmlUI/var/ui_search.class.php
index 5f4970923..f12c69758 100644
--- a/livesupport/src/modules/htmlUI/var/ui_search.class.php
+++ b/livesupport/src/modules/htmlUI/var/ui_search.class.php
@@ -136,12 +136,12 @@ class uiSearch
$this->criteria['conditions'] = NULL;
$this->criteria['offset'] = NULL;
- $this->criteria['operator'] = UI_SIMPLESEARCH_FILETYPE;
- $this->criteria['filetype'] = UI_SIMPLESEARCH_OPERATOR;
+ $this->criteria['operator'] = UI_SIMPLESEARCH_OPERATOR;
+ $this->criteria['filetype'] = UI_SIMPLESEARCH_FILETYPE;
$this->criteria['limit'] = UI_SIMPLESEARCH_LIMIT;
$this->criteria['counter'] = UI_SIMPLESEARCH_ROWS;
$this->criteria['form']['operator'] = 'OR'; ## $criteria['form'] is used for retransfer to form ##
- $this->criteria['form']['filetype'] = 'File';
+ $this->criteria['form']['filetype'] = UI_SIMPLESEARCH_FILETYPE;
$this->criteria['form']['limit'] = UI_SIMPLESEARCH_LIMIT;
for ($n = 1; $n<=UI_SIMPLESEARCH_ROWS; $n++) {
diff --git a/livesupport/src/modules/storageServer/bin/backup.sh b/livesupport/src/modules/storageServer/bin/backup.sh
new file mode 100644
index 000000000..f5cd2613f
--- /dev/null
+++ b/livesupport/src/modules/storageServer/bin/backup.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# param $1: workdir what we would like to tar
+# param $2: output file: the .tar file
+# param $3: statusfile
+date +\=\=\>%Y%m%d\ %H:%M:%S
+echo "backup2.sh: create tarball $1 to $2<=="
+echo -n "working" > $3;
+touch $2 || { echo -n "fail" > $3; exit 1; }
+#sleep 120
+cd $1
+tar cf $2 * || { echo -n "fail" > $3; exit 1; }
+
+echo -n "success" > $3
\ No newline at end of file
diff --git a/livesupport/src/modules/storageServer/var/Backup.php b/livesupport/src/modules/storageServer/var/Backup.php
new file mode 100755
index 000000000..35a7707f8
--- /dev/null
+++ b/livesupport/src/modules/storageServer/var/Backup.php
@@ -0,0 +1,407 @@
+gb =& $gb;
+ $this->token = null;
+ $this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
+ }
+
+ /**
+ * Open a backup
+ * Create a backup file (tarball)
+ *
+ * @param sessid : string - session id
+ * @param criteria : struct - see search criteria
+ * @return hasharray with field:
+ * token string: backup token
+ */
+ function openBackup($sessid,$criteria='') {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n");
+ }
+ $this->sessid = $sessid;
+ $this->criteria = $criteria;
+
+ # get ids (and real filenames) which files match with criteria
+ $this->setIDs($this->gb->localSearch($this->criteria,$this->sessid));
+ #echo 'this->ids:'; print_r($this->ids); echo '';
+
+ # get real filenames
+ if (is_array($this->ids)) {
+ $this->setFileNames();
+ #echo 'this->filenames:'; print_r($this->filenames); echo '';
+
+ $this->setEnviroment(true);
+
+ # write a status file
+ file_put_contents($this->statusFile, 'working');
+
+ # save the metafile to tmpdir
+ $hostname = trim(`hostname`);
+ $ctime = time();
+ file_put_contents("{$this->tmpDirMeta}/storage.xml",
+ "\n".
+ "\n"
+ );
+
+ # copy all file to tmpdir
+ $this->copyAllFiles();
+
+ # do everything
+ $this->doIt();
+
+ return array('token'=>$this->token);
+ } else return false;
+ }
+
+ /**
+ * check the status of backup
+ *
+ * @param token : token
+ * @return hasharray with field:
+ * status : string - susccess | working | fault
+ * token : stirng - backup token
+ * url : string - access url
+ */
+ function checkBackup($token) {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
+ }
+ $this->token = $token;
+ $this->setEnviroment();
+ $status = file_get_contents($this->statusFile);
+ switch ($status) {
+ case 'success':
+ $r['url'] = $this->gb->getUrlPart()."access/$token.".BACKUP_EXT;
+ case 'working':
+ case 'fault':
+ $r['status'] = $status;
+ $r['token'] = $token;
+ break;
+ }
+ return $r;
+ }
+
+ /**
+ * Close a backup
+ *
+ * @param token : token
+ * @return status : boolean
+ */
+ function closeBackup($token) {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." closeBackup - token:$token\n");
+ }
+ # post procedures
+ $this->token = $token;
+ $this->setEnviroment();
+ $this->gb->bsRelease($token,ACCESS_TYPE);
+ Backup::rRmDir($this->tmpDir);
+ unlink($this->statusFile);
+ unlink($this->tmpFile);
+ if (is_file($this->tmpName)) unlink($this->tmpName);
+ return !is_file($this->tmpFile);
+ }
+
+ /**
+ * list of unclosed backups
+ *
+ * @param stat : status (optional)
+ * if this parameter is not set, then return with all unclosed backups
+ * @return array of hasharray with field:
+ * status : string - susccess | working | fault
+ * token : stirng - backup token
+ * url : string - access url
+ */
+ function listBackups($stat='') {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." listBackups - stat:$stat\n");
+ }
+ # open temporary dir
+ $tokens = $this->gb->getTokensByType(ACCESS_TYPE);
+ # echo 'tokens:'; print_r($tokens); echo '';
+ foreach ($tokens as $token) {
+ $st = $this->checkBackup($token);
+ if ($stat=='' || $st['status']==$stat) {
+ $r[] = $st;
+ }
+ }
+ return $r;
+ }
+
+ /**
+ * set the ids from searchResult
+ *
+ * @param searchResult : array of gunids
+ */
+ function setIDs($searchResult) {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." setIDs\n");
+ }
+ if (is_array($searchResult['results'])) {
+ $this->ids = $searchResult['results'];
+ } else {
+ $this->addLogItem("-E- ".date("Ymd-H:i:s")." setIDs - the parameter is not array!\n");
+ return PEAR::raiseError('The IDs variable isn\'t array.');
+ }
+ }
+
+ /**
+ * set the filenames from ids
+ *
+ */
+ function setFilenames () {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
+ }
+ if (is_array($this->ids)) {
+ foreach ($this->ids as $gunid) {
+ # get a stored file object of this gunid
+ $sf = $r = StoredFile::recallByGunid($this->gb, $gunid);
+ if(PEAR::isError($r)) return $r;
+ $lid = $this->gb->_idFromGunid($gunid);
+ if(($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE){
+ $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
+ return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
+ }
+ # if the file is a playlist then it have only meta file
+ if (strtolower($sf->md->format)!='playlist') {
+ $this->filenames[] = array(
+ 'filename' => $sf->_getRealRADFname(), # get real filename of raw media data
+ 'format' => $sf->md->format
+ );
+ }
+ $this->filenames[] = array(
+ 'filename' => $sf->_getRealMDFname(), # get real filename of metadata file
+ 'format' => $sf->md->format
+ );
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->_getRealMDFname()."\n");
+ }
+ }
+ return $this->filenames;
+ } else {
+ $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
+ return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
+ }
+ }
+
+ /**
+ * Create the trackball - call the shell script
+ *
+ */
+ function doIt() {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n");
+ }
+ $command = dirname(__FILE__)."/../bin/backup.sh".
+ " {$this->tmpDir}".
+ " {$this->tmpFile}".
+ " {$this->statusFile}".
+ " >> {$this->logFile} &";
+ $res = system("$command");
+ sleep(2);
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt - command:$command\n");
+ }
+ }
+
+ /**
+ * Copy the real files into the tmp dirs to tar they.
+ *
+ */
+ function copyAllFiles() {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." copyAllFiles\n");
+ }
+ //echo 'this->filenames:'; print_r($this->filenames); echo '';
+ foreach ($this->filenames as $v) {
+ # get the filename from full path
+ $fn = substr($v['filename'],strrpos($v['filename'],'/'));
+ switch (strtolower($v['format'])) {
+ case 'playlist':
+ # if playlist then copy to the playlist dir
+ copy($v['filename'],$this->tmpDirPlaylist.$fn);
+ break;
+ case 'audioclip':
+ # if audioclip then copy to the audioclip dir
+ copy($v['filename'],$this->tmpDirClip.$fn);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Figure out the enviroment to the backup
+ *
+ */
+ function setEnviroment($createDir=false) {
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment - createDirs:$createDirs\n");
+ }
+ # create a temporary directories
+ if (is_null($this->token) && $createDir) {
+ $this->tmpName = tempnam($this->gb->bufferDir, ACCESS_TYPE.'_');
+ $this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
+ $this->tmpDir = $this->tmpName.'.dir';
+ $this->tmpDirPlaylist = $this->tmpDir. '/playlist';
+ $this->tmpDirClip = $this->tmpDir. '/audioClip';
+ $this->tmpDirMeta = $this->tmpDir. '/meta-inf';
+ touch($this->tmpFile);
+ mkdir($this->tmpDir);
+ mkdir($this->tmpDirPlaylist);
+ mkdir($this->tmpDirClip);
+ mkdir($this->tmpDirMeta);
+ $this->genToken();
+ } else {
+ $symlink = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT;
+ if (is_link($symlink) && is_file(readlink($symlink))) {
+ $this->tmpName = str_replace('.tar','',readlink($symlink));
+ $this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
+ $this->tmpDir = $this->tmpName.'.dir';
+ $this->tmpDirPlaylist = $this->tmpDir. '/playlist';
+ $this->tmpDirClip = $this->tmpDir. '/audioClip';
+ $this->tmpDirMeta = $this->tmpDir. '/meta-inf';
+ } else {
+ $this->addLogItem("-E- ".date("Ymd-H:i:s")." setEnviroment - Corrupt symbolic link.\n");
+ return false;
+ }
+ }
+ $this->statusFile = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT.'.status';
+ if ($this->loglevel=='debug') {
+ $this->addLogItem("this->tmpName: $this->tmpName\n");
+ $this->addLogItem("this->tmpFile: $this->tmpFile\n");
+ $this->addLogItem("this->tmpDir: $this->tmpDir\n");
+ $this->addLogItem("this->tmpDirPlaylist: $this->tmpDirPlaylist\n");
+ $this->addLogItem("this->tmpDirClip: $this->tmpDirClip\n");
+ $this->addLogItem("this->tmpDirMeta: $this->tmpDirMeta\n");
+ $this->addLogItem("this->token: $this->token\n");
+ $this->addLogItem("this->statusFile: $this->statusFile\n");
+ }
+ }
+
+ /**
+ * generate a new token.
+ *
+ */
+ function genToken() {
+ $acc = $this->gb->bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
+ if($this->gb->dbc->isError($acc)){ return $acc; }
+ $this->token = $acc['token'];
+ }
+
+ /**
+ * Add a line to the logfile.
+ *
+ * @param item : string - the new row of log file
+ */
+ function addLogItem($item) {
+ $f = fopen ($this->logFile,'a');
+ fwrite($f,$item);
+ fclose($f);
+ //echo file_get_contents($this->logFile)."
\n\n";
+ }
+
+ /**
+ * Delete a directory recursive
+ *
+ * @param dirname : string - path of dir.
+ */
+ function rRmDir($dirname) {
+ if(is_dir($dirname))
+ $dir_handle = opendir($dirname);
+ while($file = readdir($dir_handle)) {
+ if($file!="." && $file!="..") {
+ if(!is_dir($dirname."/".$file))
+ unlink ($dirname."/".$file);
+ else
+ Backup::rRmDir($dirname."/".$file);
+ }
+ }
+ closedir($dir_handle);
+ rmdir($dirname);
+ return true;
+ }
+}
+?>
+
diff --git a/livesupport/src/modules/storageServer/var/BasicStor.php b/livesupport/src/modules/storageServer/var/BasicStor.php
index 91630107e..80d6da763 100644
--- a/livesupport/src/modules/storageServer/var/BasicStor.php
+++ b/livesupport/src/modules/storageServer/var/BasicStor.php
@@ -625,6 +625,23 @@ class BasicStor extends Alib{
$owner = $row;
}
+ /**
+ * Get tokens by type
+ *
+ * @param type: string - access|put|render etc.
+ * @return array - array of tokens
+ */
+ function getTokensByType($type)
+ {
+ $res = $this->dbc->query(
+ "SELECT TO_HEX(token) AS token FROM {$this->accessTable} WHERE type=?",
+ array($type));
+ while ($row = $res->fetchRow()) {
+ $r[] = $row['token'];
+ }
+ return $r;
+ }
+
/* -------------------------------------------- metadata methods4metadata */
/**
diff --git a/livesupport/src/modules/storageServer/var/GreenBox.php b/livesupport/src/modules/storageServer/var/GreenBox.php
index 4c63b4997..78bba7409 100644
--- a/livesupport/src/modules/storageServer/var/GreenBox.php
+++ b/livesupport/src/modules/storageServer/var/GreenBox.php
@@ -825,6 +825,21 @@ class GreenBox extends BasicStor{
return array('status'=>$r['status'], 'tmpfile'=>$r['tmpfile']);
}
+ /**
+ * Render playlist to ogg file (list results)
+ *
+ * @param status : string - success | working | fault
+ * if this parameter is not set, then return with all unclosed
+ * @return array of hasharray:
+ * status : string - susccess | working | fault
+ * tmpfile : string - filepath to result temporary file
+ */
+ function renderPlaylistToFileList($status='')
+ {
+ require_once "Renderer.php";
+ return Renderer::rnRender2FileList($this, $status);
+ }
+
/**
* Render playlist to ogg file (close handle)
*
@@ -911,6 +926,23 @@ class GreenBox extends BasicStor{
);
}
+ /**
+ * Render playlist to RSS file (list results)
+ *
+ * @param status : string - success | working | fault
+ * @return array of hasharray:
+ * status : string - susccess | working | fault
+ * tmpfile : string - filepath to result temporary file
+ */
+ function renderPlaylistToRSSList($status='')
+ {
+ $dummytokens = array ('123456789abcdeff');
+ foreach ($dummytokens as $token) {
+ $r[] = renderPlaylistToRSSCheck($token);
+ }
+ return $r
+ }
+
/**
* Render playlist to RSS file (close handle)
*
@@ -935,84 +967,66 @@ class GreenBox extends BasicStor{
/**
* Create backup of storage (open handle)
*
- * @param sessid : string - session id
+ * @param sessid : string - session id
* @param criteria : struct - see search criteria
* @return hasharray:
- * token : string - backup token
+ * token : string - backup token
*/
function createBackupOpen($sessid, $criteria='')
{
- $token = '123456789abcdeff';
- $tmpn = tempnam($this->bufferDir, 'backup_');
- $tmpf = "$tmpn.tar";
- $tmpd = "$tmpn.dir"; mkdir($tmpd);
- $tmpdp = "$tmpd/playlist"; mkdir($tmpdp);
- $tmpdc = "$tmpd/audioClip"; mkdir($tmpdc);
- $tmpdm = "$tmpd/meta-inf"; mkdir($tmpdm);
- $ctime = time();
- // $hostname = $_SERVER['SERVER_NAME'];
- $hostname = trim(`hostname`);
- file_put_contents("$tmpdm/storage.xml",
- "\n".
- "\n"
- );
- $res = `cd $tmpd; tar cf $tmpf * --remove-files`;
- $fakeFile = "{$this->accessDir}/$token.tar";
- rename($tmpf, $fakeFile);
- //copy($tmpf, $fakeFile);
- rmdir($tmpdp); rmdir($tmpdc); rmdir($tmpdm);
- rmdir($tmpd); unlink($tmpn);
- return array('token'=>$token);
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->openBackup($sessid,$criteria);
}
/**
* Create backup of storage (check results)
*
* @param token : string - backup token
- * @return hasharray:
+ * @return hasharray with field:
* status : string - susccess | working | fault
- * tmpfile : string - filepath to result temporary file
- * metafile : string - archive metafile in XML format
- * faultString : string - error message (use only if status==fault)
+ * token : stirng - backup token
+ * url : string - access url
*/
function createBackupCheck($token)
{
- $fakeFile = "{$this->accessDir}/$token.tar";
- if($token != '123456789abcdeff' || !file_exists($fakeFile)){
- return PEAR::raiseError(
- "LocStor::createBackupCheck: invalid token ($token)"
- );
- }
- $status = 'success';
- return array(
- 'status'=> $status,
- 'tmpfile' => $fakeFile,
- 'metafile' => '',
- 'faultString' => ($status==fault ? 'backup process fault' : ''),
- );
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->checkBackup($token);
+ }
+
+ /**
+ * Create backup of storage (list results)
+ *
+ * @param stat : status (optional)
+ * if this parameter is not set, then return with all unclosed backups
+ * @return array of hasharray with field:
+ * status : string - susccess | working | fault
+ * token : stirng - backup token
+ * url : string - access url
+ */
+ function createBackupList($sessid,$stat='')
+ {
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->listBackups($stat);
}
/**
* Create backup of storage (close handle)
*
- * @param token : string - backup token
- * @return status : boolean
+ * @param token : string - backup token
+ * @return status : boolean
*/
function createBackupClose($token)
{
- if($token != '123456789abcdeff'){
- return PEAR::raiseError(
- "LocStor::createBackupClose: invalid token"
- );
- }
- $fakeFile = "{$this->accessDir}/$token.tar";
- unlink($fakeFile);
- return TRUE;
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->closeBackup($token);
}
/* ============================================== methods for preferences */
diff --git a/livesupport/src/modules/storageServer/var/LocStor.php b/livesupport/src/modules/storageServer/var/LocStor.php
index 374c18ffc..972bc9059 100644
--- a/livesupport/src/modules/storageServer/var/LocStor.php
+++ b/livesupport/src/modules/storageServer/var/LocStor.php
@@ -824,7 +824,7 @@ class LocStor extends BasicStor{
/**
* Render playlist to ogg file (close handle)
*
- * @param token : string - render token
+ * @param token : string - render token
* @return status : boolean
*/
function renderPlaylistToFileClose($token)
@@ -839,9 +839,9 @@ class LocStor extends BasicStor{
/**
* Render playlist to storage media clip (open handle)
*
- * @param sessid : string - session id
- * @param plid : string - playlist gunid
- * @return token : string - render token
+ * @param sessid : string - session id
+ * @param plid : string - playlist gunid
+ * @return token : string - render token
*/
function renderPlaylistToStorageOpen($sessid, $plid)
{
@@ -859,7 +859,7 @@ class LocStor extends BasicStor{
* @param token : string - render token
* @return hasharray:
* status : string - success | working | fault
- * gunid : string - gunid of result file
+ * gunid : string - gunid of result file
*/
function renderPlaylistToStorageCheck($token)
{
@@ -873,9 +873,9 @@ class LocStor extends BasicStor{
/**
* Render playlist to RSS file (open handle)
*
- * @param sessid : string - session id
- * @param plid : string - playlist gunid
- * @return token : string - render token
+ * @param sessid : string - session id
+ * @param plid : string - playlist gunid
+ * @return token : string - render token
*/
function renderPlaylistToRSSOpen($sessid, $plid)
{
@@ -888,10 +888,10 @@ class LocStor extends BasicStor{
/**
* Render playlist to RSS file (check results)
*
- * @param token : string - render token
- * @return hasharray:
+ * @param token : string - render token
+ * @return hasharray :
* status : string - success | working | fault
- * url : string - readable url
+ * url : string - readable url
*/
function renderPlaylistToRSSCheck($token)
{
@@ -911,7 +911,7 @@ class LocStor extends BasicStor{
/**
* Render playlist to RSS file (close handle)
*
- * @param token : string - render token
+ * @param token : string - render token
* @return status : boolean
*/
function renderPlaylistToRSSClose($token)
@@ -932,84 +932,66 @@ class LocStor extends BasicStor{
/**
* Create backup of storage (open handle)
*
- * @param sessid : string - session id
+ * @param sessid : string - session id
* @param criteria : struct - see search criteria
- * @return token : string - backup token
+ * @return hasharray:
+ * token : string - backup token
*/
- function createBackupOpen($sessid, $criteria)
+ function createBackupOpen($sessid, $criteria='')
{
- $token = '123456789abcdeff';
- $tmpn = tempnam($this->bufferDir, 'backup_');
- $tmpf = "$tmpn.tar";
- $tmpd = "$tmpn.dir"; mkdir($tmpd);
- $tmpdp = "$tmpd/playlist"; mkdir($tmpdp);
- $tmpdc = "$tmpd/audioClip"; mkdir($tmpdc);
- $tmpdm = "$tmpd/meta-inf"; mkdir($tmpdm);
- $ctime = time();
- // $hostname = $_SERVER['SERVER_NAME'];
- $hostname = trim(`hostname`);
- file_put_contents("$tmpdm/storage.xml",
- "\n".
- "\n"
- );
- $res = `cd $tmpd; tar cf $tmpf * --remove-files`;
- $fakeFile = "{$this->accessDir}/$token.tar";
- rename($tmpf, $fakeFile);
- //copy($tmpf, $fakeFile);
- rmdir($tmpdp); rmdir($tmpdc); rmdir($tmpdm);
- rmdir($tmpd); unlink($tmpn);
- return array('token'=>$token);
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->openBackup($sessid,$criteria);
}
/**
* Create backup of storage (check results)
*
* @param token : string - backup token
- * @return hasharray:
- * status : string - success | working | fault
- * url : string - readable url
- * metafile : string - archive metafile in XML format
- * faultString : string - error message (use only if status==fault)
+ * @return hasharray with field:
+ * status : string - susccess | working | fault
+ * token : stirng - backup token
+ * url : string - access url
*/
function createBackupCheck($token)
{
- $fakeFile = "{$this->accessDir}/$token.tar";
- if($token != '123456789abcdeff' || !file_exists($fakeFile)){
- return PEAR::raiseError(
- "LocStor::createBackupCheck: invalid token ($token)"
- );
- }
- $fakeFUrl = $this->getUrlPart()."access/$token.tar";
- $status = 'success';
- return array(
- 'status'=> $status,
- 'url' => $fakeFUrl,
- 'metafile' => '',
- 'faultString' => ($status==fault ? 'backup process fault' : ''),
- );
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->checkBackup($token);
+ }
+
+ /**
+ * Create backup of storage (list results)
+ *
+ * @param stat : status (optional)
+ * if this parameter is not set, then return with all unclosed backups
+ * @return array of hasharray with field:
+ * status : string - susccess | working | fault
+ * token : stirng - backup token
+ * url : string - access url
+ */
+ function createBackupList($sessid,$stat='')
+ {
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->listBackups($stat);
}
/**
* Create backup of storage (close handle)
*
- * @param token : string - backup token
- * @return status : boolean
+ * @param token : string - backup token
+ * @return status : boolean
*/
function createBackupClose($token)
{
- if($token != '123456789abcdeff'){
- return PEAR::raiseError(
- "LocStor::createBackupClose: invalid token"
- );
- }
- $fakeFile = "{$this->accessDir}/$token.tar";
- unlink($fakeFile);
- return TRUE;
+ require_once "Backup.php";
+ $bu = $r = new Backup($this);
+ if (PEAR::isError($r)) return $r;
+ return $bu->closeBackup($token);
}
/*===================================================== auxiliary methods */
diff --git a/livesupport/src/modules/storageServer/var/Renderer.php b/livesupport/src/modules/storageServer/var/Renderer.php
index 3106ccd6b..bc7847c50 100644
--- a/livesupport/src/modules/storageServer/var/Renderer.php
+++ b/livesupport/src/modules/storageServer/var/Renderer.php
@@ -41,6 +41,7 @@ require_once "LsPlaylist.php";
* @version $Revision: 1949 $
* @see LocStor
*/
+
class Renderer
{
@@ -115,6 +116,28 @@ class Renderer
return array('status'=>$status, 'url'=>$url, 'tmpfile'=>$tmpfile);
}
+ /**
+ * Render playlist to ogg file (list results)
+ *
+ * @param gb: greenbox object reference
+ * @param stat : status (optional)
+ * if this parameter is not set, then return with all unclosed backups
+ * @return array of hasharray:
+ * status : string - success | working | fault
+ * url : string - readable url
+ */
+ function rnRender2FileList(&$gb,$stat='') {
+ # open temporary dir
+ $tokens = $gb->getTokensByType('render');
+ foreach ($tokens as $token) {
+ $st = Renderer::rnRender2FileCheck($gb, $token);
+ if ($stat=='' || $st['status']==$stat) {
+ $r[] = $st;
+ }
+ }
+ return $r;
+ }
+
/**
* Render playlist to ogg file (close handle)
*
diff --git a/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
index 5ba21af9c..abc65c810 100644
--- a/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
+++ b/livesupport/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
@@ -1837,6 +1837,56 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode($res));
}
+ /**
+ * Create backup of storage (list results)
+ *
+ * The XML-RPC name of this method is "locstor.createBackupList".
+ *
+ * The input parameters are an XML-RPC struct with the following
+ * fields:
+ *
+ * - stat : string - backup status
+ *
+ *
+ * On success, returns a XML-RPC array of struct with following fields:
+ *
+ * - status : string - success | working | fault
+ * - url : string - readable url
+ * - metafile : string - archive metafile in XML format
+ * - faultString : string - error message
+ * (use only if status==fault)
+ *
+ *
+ * On errors, returns an XML-RPC error response.
+ * The possible error codes and error message are:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_createBackupCheck:
+ * <message from lower layer>
+ *
+ *
+ * @param input XMLRPC struct
+ * @return XMLRPC struct
+ * @see LocStor::createBackupCheck
+ */
+ // 854 - backup process fault
+ function xr_createBackupList($stat='')
+ {
+ $res = $this->createBackupList($stat);
+
+ if(PEAR::isError($res)){
+ $ec0 = intval($res->getCode());
+ $ec = ($ec0 == GBERR_BGERR ? 800+$ec0 : 805 );
+ return new XML_RPC_Response(0, $ec,
+ "xr_createBackupCheck: ".$res->getMessage().
+ " ".$res->getUserInfo()
+ );
+ }
+ return new XML_RPC_Response(XML_RPC_encode($res));
+ }
+
/**
* Create backup of storage (close handle)
*