Renamed LiveSupport to Campcaster. Got rid of copyright notice in files, we will just have one that covers all files at the root of the package. Converted comments to Phpdocumentor format. Added @author, @version, @package, and @subpackage doc tags. Reformatted code to Campware PHP coding conventions.
This commit is contained in:
parent
56d250f21e
commit
f4c68079d4
46 changed files with 3805 additions and 3252 deletions
|
@ -1,103 +1,108 @@
|
||||||
<?
|
<?
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccessRecur class
|
* AccessRecur class
|
||||||
*
|
*
|
||||||
* Hadles recursive accessPlaylist/releasePlaylist.
|
* Handles recursive accessPlaylist/releasePlaylist.
|
||||||
* Should be "required_once" from LocStor.php only.
|
* Should be 'required_once' from LocStor.php only.
|
||||||
*
|
*
|
||||||
* It's not documeted yet - excuse me, please - not enough time :(
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
*/
|
*/
|
||||||
class AccessRecur{
|
class AccessRecur {
|
||||||
function AccessRecur(&$ls, $sessid){
|
|
||||||
|
function AccessRecur(&$ls, $sessid)
|
||||||
|
{
|
||||||
$this->ls =& $ls;
|
$this->ls =& $ls;
|
||||||
$this->dbc =& $ls->dbc;
|
$this->dbc =& $ls->dbc;
|
||||||
$this->sessid = $sessid;
|
$this->sessid = $sessid;
|
||||||
}
|
}
|
||||||
function accessPlaylist(&$ls, $sessid, $plid, $parent='0'){
|
|
||||||
|
|
||||||
|
function accessPlaylist(&$ls, $sessid, $plid, $parent='0')
|
||||||
|
{
|
||||||
$ppa =& new AccessRecur($ls, $sessid);
|
$ppa =& new AccessRecur($ls, $sessid);
|
||||||
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
|
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$plRes = $r;
|
$plRes = $r;
|
||||||
$r = StoredFile::recallByGunid($ppa->ls, $plid);
|
$r = StoredFile::recallByGunid($ppa->ls, $plid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$ac = $r;
|
$ac = $r;
|
||||||
$r = $ac->md->genPhpArray();
|
$r = $ac->md->genPhpArray();
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$pla = $r;
|
$pla = $r;
|
||||||
$r = $ppa->processPlaylist($pla, $plRes['token']);
|
$r = $ppa->processPlaylist($pla, $plRes['token']);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$plRes['content'] = $r;
|
$plRes['content'] = $r;
|
||||||
return $plRes;
|
return $plRes;
|
||||||
}
|
}
|
||||||
function releasePlaylist(&$ls, $sessid, $token){
|
|
||||||
|
|
||||||
|
function releasePlaylist(&$ls, $sessid, $token)
|
||||||
|
{
|
||||||
$ppa =& new AccessRecur($ls, $sessid);
|
$ppa =& new AccessRecur($ls, $sessid);
|
||||||
$r = $ppa->dbc->getAll("
|
$r = $ppa->dbc->getAll("
|
||||||
SELECT to_hex(token)as token2, to_hex(gunid)as gunid
|
SELECT to_hex(token)as token2, to_hex(gunid)as gunid
|
||||||
FROM {$ppa->ls->accessTable}
|
FROM {$ppa->ls->accessTable}
|
||||||
WHERE parent=x'{$token}'::bigint
|
WHERE parent=x'{$token}'::bigint
|
||||||
");
|
");
|
||||||
if($ppa->dbc->isError($r)){ return $r; }
|
if ($ppa->dbc->isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$arr = $r;
|
$arr = $r;
|
||||||
foreach($arr as $i=>$item){
|
foreach ($arr as $i => $item) {
|
||||||
extract($item); // token2, gunid
|
extract($item); // token2, gunid
|
||||||
$r = $ppa->ls->_getType($gunid);
|
$r = $ppa->ls->_getType($gunid);
|
||||||
if($ppa->dbc->isError($r)){ return $r; }
|
if ($ppa->dbc->isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$ftype = $r;
|
$ftype = $r;
|
||||||
# echo "$ftype/$token2\n";
|
# echo "$ftype/$token2\n";
|
||||||
switch(strtolower($ftype)){
|
switch (strtolower($ftype)) {
|
||||||
case"audioclip":
|
case"audioclip":
|
||||||
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
|
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
|
||||||
if($ppa->dbc->isError($r)){ return $r; }
|
if ($ppa->dbc->isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
# var_dump($r);
|
# var_dump($r);
|
||||||
break;
|
break;
|
||||||
case"playlist":
|
case"playlist":
|
||||||
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
|
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
|
||||||
if($ppa->dbc->isError($r)){ return $r; }
|
if ($ppa->dbc->isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
# var_dump($r);
|
# var_dump($r);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
|
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
|
||||||
if($ppa->dbc->isError($r)){ return $r; }
|
if ($ppa->dbc->isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
function processPlaylist($pla, $parent){
|
|
||||||
|
|
||||||
|
function processPlaylist($pla, $parent)
|
||||||
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
foreach($pla['children'] as $ple){
|
foreach ($pla['children'] as $ple) {
|
||||||
switch($ple['elementname']){
|
switch ($ple['elementname']) {
|
||||||
case"playlistElement":
|
case"playlistElement":
|
||||||
$r = $this->processPlEl($ple, $parent);
|
$r = $this->processPlEl($ple, $parent);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
// $res = array_merge($res, $r);
|
// $res = array_merge($res, $r);
|
||||||
$res[] = $r;
|
$res[] = $r;
|
||||||
break;
|
break;
|
||||||
|
@ -106,28 +111,41 @@ class AccessRecur{
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
function processAc($gunid, $parent){
|
|
||||||
|
|
||||||
|
function processAc($gunid, $parent)
|
||||||
|
{
|
||||||
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
|
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
function processPlEl($ple, $parent='0'){
|
|
||||||
foreach($ple['children'] as $ac){
|
|
||||||
switch($ac['elementname']){
|
function processPlEl($ple, $parent='0')
|
||||||
|
{
|
||||||
|
foreach ($ple['children'] as $ac) {
|
||||||
|
switch ($ac['elementname']) {
|
||||||
case"audioClip":
|
case"audioClip":
|
||||||
$r = $this->processAc($ac['attrs']['id'], $parent);
|
$r = $this->processAc($ac['attrs']['id'], $parent);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $r;
|
return $r;
|
||||||
break;
|
break;
|
||||||
case"playlist":
|
case"playlist":
|
||||||
// if(empty($ac['children'])){
|
// if(empty($ac['children'])){
|
||||||
$r = $this->accessPlaylist($this->ls, $this->sessid,
|
$r = $this->accessPlaylist($this->ls, $this->sessid,
|
||||||
$ac['attrs']['id'], $parent);
|
$ac['attrs']['id'], $parent);
|
||||||
if(PEAR::isError($r)){
|
if (PEAR::isError($r)) {
|
||||||
if($r->getCode() != GBERR_NOTF) return $r;
|
if ($r->getCode() != GBERR_NOTF) {
|
||||||
else{
|
return $r;
|
||||||
|
} else {
|
||||||
$r = $this->processPlaylist($ac, $parent);
|
$r = $this->processPlaylist($ac, $parent);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = array(
|
$r = array(
|
||||||
'content' => $r,
|
'content' => $r,
|
||||||
'url' => NULL,
|
'url' => NULL,
|
||||||
|
@ -160,5 +178,6 @@ class AccessRecur{
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
?>
|
} // class AccessRecur
|
||||||
|
?>
|
|
@ -2,7 +2,13 @@
|
||||||
define('BACKUP_EXT', 'tar');
|
define('BACKUP_EXT', 'tar');
|
||||||
define('ACCESS_TYPE', 'backup');
|
define('ACCESS_TYPE', 'backup');
|
||||||
|
|
||||||
class Backup
|
/**
|
||||||
|
* @author $Author: $
|
||||||
|
* @version $Revision: $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
*/
|
||||||
|
class Backup
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* string - name of logfile
|
* string - name of logfile
|
||||||
|
@ -34,7 +40,7 @@ class Backup
|
||||||
* array - array of affected filenames
|
* array - array of affected filenames
|
||||||
*/
|
*/
|
||||||
var $filenames = array();
|
var $filenames = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string - base tmp name
|
* string - base tmp name
|
||||||
*/
|
*/
|
||||||
|
@ -46,25 +52,25 @@ class Backup
|
||||||
/**
|
/**
|
||||||
* string - name of temporary directory
|
* string - name of temporary directory
|
||||||
*/
|
*/
|
||||||
var $tmpDir;
|
var $tmpDir;
|
||||||
/**
|
/**
|
||||||
* string - name of temporary playlist directory
|
* string - name of temporary playlist directory
|
||||||
*/
|
*/
|
||||||
var $tmpDirPlaylist;
|
var $tmpDirPlaylist;
|
||||||
/**
|
/**
|
||||||
* string - name of temporary audioclip directory
|
* string - name of temporary audioclip directory
|
||||||
*/
|
*/
|
||||||
var $tmpDirClip;
|
var $tmpDirClip;
|
||||||
/**
|
/**
|
||||||
* string - name of temporary metafile directory
|
* string - name of temporary metafile directory
|
||||||
*/
|
*/
|
||||||
var $tmpDirMeta;
|
var $tmpDirMeta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string - loglevel
|
* string - loglevel
|
||||||
*/
|
*/
|
||||||
var $loglevel = 'warn'; # 'debug';
|
var $loglevel = 'warn'; # 'debug';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* greenbox object reference
|
* greenbox object reference
|
||||||
*/
|
*/
|
||||||
|
@ -82,14 +88,15 @@ class Backup
|
||||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a backup
|
* Open a backup
|
||||||
* Create a backup file (tarball)
|
* Create a backup file (tarball)
|
||||||
*
|
*
|
||||||
* @param sessid : string - session id
|
* @param sessid : string - session id
|
||||||
* @param criteria : struct - see search criteria
|
* @param criteria : struct - see search criteria
|
||||||
* @return hasharray with field:
|
* @return hasharray with field:
|
||||||
* token string: backup token
|
* token string: backup token
|
||||||
*/
|
*/
|
||||||
function openBackup($sessid,$criteria='')
|
function openBackup($sessid,$criteria='')
|
||||||
|
@ -99,23 +106,25 @@ class Backup
|
||||||
}
|
}
|
||||||
$this->sessid = $sessid;
|
$this->sessid = $sessid;
|
||||||
$this->criteria = $criteria;
|
$this->criteria = $criteria;
|
||||||
|
|
||||||
# get ids (and real filenames) which files match with criteria
|
# get ids (and real filenames) which files match with criteria
|
||||||
$srch = $r = $this->gb->localSearch($this->criteria,$this->sessid);
|
$srch = $r = $this->gb->localSearch($this->criteria,$this->sessid);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$this->setIDs($srch);
|
$this->setIDs($srch);
|
||||||
#echo '<XMP>this->ids:'; print_r($this->ids); echo '</XMP>';
|
#echo '<XMP>this->ids:'; print_r($this->ids); echo '</XMP>';
|
||||||
|
|
||||||
# get real filenames
|
# get real filenames
|
||||||
if (is_array($this->ids)) {
|
if (is_array($this->ids)) {
|
||||||
$this->setFilenames();
|
$this->setFilenames();
|
||||||
#echo '<XMP>this->filenames:'; print_r($this->filenames); echo '</XMP>';
|
#echo '<XMP>this->filenames:'; print_r($this->filenames); echo '</XMP>';
|
||||||
|
|
||||||
$this->setEnviroment(true);
|
$this->setEnviroment(true);
|
||||||
|
|
||||||
# write a status file
|
# write a status file
|
||||||
file_put_contents($this->statusFile, 'working');
|
file_put_contents($this->statusFile, 'working');
|
||||||
|
|
||||||
# save the metafile to tmpdir
|
# save the metafile to tmpdir
|
||||||
$hostname = trim(`hostname`);
|
$hostname = trim(`hostname`);
|
||||||
$ctime = time();
|
$ctime = time();
|
||||||
|
@ -129,22 +138,25 @@ class Backup
|
||||||
" hostname=\"$hostname\"\n".
|
" hostname=\"$hostname\"\n".
|
||||||
"/><!-- $ctime_f -->\n"
|
"/><!-- $ctime_f -->\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
# copy all file to tmpdir
|
# copy all file to tmpdir
|
||||||
$this->copyAllFiles();
|
$this->copyAllFiles();
|
||||||
|
|
||||||
# do everything
|
# do everything
|
||||||
$this->doIt();
|
$this->doIt();
|
||||||
|
|
||||||
return array('token'=>$this->token);
|
return array('token'=>$this->token);
|
||||||
} else return false;
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check the status of backup
|
* Check the status of backup.
|
||||||
*
|
*
|
||||||
* @param token : token
|
* @param unknown $token
|
||||||
* @return hasharray with field:
|
* @return array
|
||||||
* status : string - susccess | working | fault
|
* status : string - susccess | working | fault
|
||||||
* faultString: string - description of fault
|
* faultString: string - description of fault
|
||||||
* token : stirng - backup token
|
* token : stirng - backup token
|
||||||
|
@ -160,7 +172,7 @@ class Backup
|
||||||
$this->setEnviroment();
|
$this->setEnviroment();
|
||||||
$status = file_get_contents($this->statusFile);
|
$status = file_get_contents($this->statusFile);
|
||||||
if (strpos($status,'fault')!==false) {
|
if (strpos($status,'fault')!==false) {
|
||||||
list($status,$faultString) = explode('|',$status);
|
list($status,$faultString) = explode('|',$status);
|
||||||
}
|
}
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 'success':
|
case 'success':
|
||||||
|
@ -175,12 +187,13 @@ class Backup
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close a backup
|
* Close a backup
|
||||||
*
|
*
|
||||||
* @param token : token
|
* @param unknown $token
|
||||||
* @return status : boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function closeBackup($token)
|
function closeBackup($token)
|
||||||
{
|
{
|
||||||
|
@ -194,16 +207,19 @@ class Backup
|
||||||
Backup::rRmDir($this->tmpDir);
|
Backup::rRmDir($this->tmpDir);
|
||||||
unlink($this->statusFile);
|
unlink($this->statusFile);
|
||||||
unlink($this->tmpFile);
|
unlink($this->tmpFile);
|
||||||
if (is_file($this->tmpName)) unlink($this->tmpName);
|
if (is_file($this->tmpName)) {
|
||||||
|
unlink($this->tmpName);
|
||||||
|
}
|
||||||
return !is_file($this->tmpFile);
|
return !is_file($this->tmpFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list of unclosed backups
|
* list of unclosed backups
|
||||||
*
|
*
|
||||||
* @param stat : status (optional)
|
* @param string $stat (optional)
|
||||||
* if this parameter is not set, then return with all unclosed backups
|
* if this parameter is not set, then return with all unclosed backups
|
||||||
* @return array of hasharray with field:
|
* @return array of hasharray with field:
|
||||||
* status : string - susccess | working | fault
|
* status : string - susccess | working | fault
|
||||||
* token : stirng - backup token
|
* token : stirng - backup token
|
||||||
* url : string - access url
|
* url : string - access url
|
||||||
|
@ -224,11 +240,12 @@ class Backup
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the ids from searchResult
|
* Aet the ids from searchResult
|
||||||
*
|
*
|
||||||
* @param searchResult : array of gunids
|
* @param array $searchResult : array of gunids
|
||||||
*/
|
*/
|
||||||
function setIDs($searchResult)
|
function setIDs($searchResult)
|
||||||
{
|
{
|
||||||
|
@ -242,12 +259,13 @@ class Backup
|
||||||
return PEAR::raiseError('The IDs variable isn\'t array.');
|
return PEAR::raiseError('The IDs variable isn\'t array.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the filenames from ids
|
* Set the filenames from ids.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function setFilenames ()
|
function setFilenames()
|
||||||
{
|
{
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
||||||
|
@ -257,9 +275,11 @@ class Backup
|
||||||
$gunid = $item['gunid'];
|
$gunid = $item['gunid'];
|
||||||
# get a stored file object of this gunid
|
# get a stored file object of this gunid
|
||||||
$sf = $r = StoredFile::recallByGunid($this->gb, $gunid);
|
$sf = $r = StoredFile::recallByGunid($this->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$lid = $this->gb->_idFromGunid($gunid);
|
$lid = $this->gb->_idFromGunid($gunid);
|
||||||
if(($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE){
|
if (($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
|
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
|
||||||
return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
|
return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
|
||||||
}
|
}
|
||||||
|
@ -284,9 +304,10 @@ class Backup
|
||||||
return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
|
return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the tarball - call the shell script
|
* Create the tarball - call the shell script
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function doIt()
|
function doIt()
|
||||||
|
@ -305,7 +326,8 @@ class Backup
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt - command:$command\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt - command:$command\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the real files into the tmp dirs to tar they.
|
* Copy the real files into the tmp dirs to tar they.
|
||||||
*
|
*
|
||||||
|
@ -315,7 +337,7 @@ class Backup
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." copyAllFiles\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." copyAllFiles\n");
|
||||||
}
|
}
|
||||||
//echo '<XMP>this->filenames:'; print_r($this->filenames); echo '</XMP>';
|
//echo '<XMP>this->filenames:'; print_r($this->filenames); echo '</XMP>';
|
||||||
if (is_array($this->filenames)) {
|
if (is_array($this->filenames)) {
|
||||||
foreach ($this->filenames as $v) {
|
foreach ($this->filenames as $v) {
|
||||||
# get the filename from full path
|
# get the filename from full path
|
||||||
|
@ -333,7 +355,8 @@ class Backup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figure out the enviroment to the backup
|
* Figure out the enviroment to the backup
|
||||||
*
|
*
|
||||||
|
@ -347,9 +370,9 @@ class Backup
|
||||||
if (is_null($this->token) && $createDir) {
|
if (is_null($this->token) && $createDir) {
|
||||||
$this->tmpName = tempnam($this->gb->bufferDir, ACCESS_TYPE.'_');
|
$this->tmpName = tempnam($this->gb->bufferDir, ACCESS_TYPE.'_');
|
||||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||||
$this->tmpDir = $this->tmpName.'.dir';
|
$this->tmpDir = $this->tmpName.'.dir';
|
||||||
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
||||||
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
||||||
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
||||||
touch($this->tmpFile);
|
touch($this->tmpFile);
|
||||||
mkdir($this->tmpDir);
|
mkdir($this->tmpDir);
|
||||||
|
@ -362,13 +385,13 @@ class Backup
|
||||||
if (is_link($symlink) && is_file(readlink($symlink))) {
|
if (is_link($symlink) && is_file(readlink($symlink))) {
|
||||||
$this->tmpName = str_replace('.tar','',readlink($symlink));
|
$this->tmpName = str_replace('.tar','',readlink($symlink));
|
||||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||||
$this->tmpDir = $this->tmpName.'.dir';
|
$this->tmpDir = $this->tmpName.'.dir';
|
||||||
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
||||||
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
||||||
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
||||||
} else {
|
} else {
|
||||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setEnviroment - Corrupt symbolic link.\n");
|
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setEnviroment - Corrupt symbolic link.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT.'.status';
|
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT.'.status';
|
||||||
|
@ -383,22 +406,26 @@ class Backup
|
||||||
$this->addLogItem("this->statusFile: $this->statusFile\n");
|
$this->addLogItem("this->statusFile: $this->statusFile\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a new token.
|
* Generate a new token.
|
||||||
*
|
* @return void
|
||||||
*/
|
*/
|
||||||
function genToken()
|
function genToken()
|
||||||
{
|
{
|
||||||
$acc = $this->gb->bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
|
$acc = $this->gb->bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
|
||||||
if($this->gb->dbc->isError($acc)){ return $acc; }
|
if ($this->gb->dbc->isError($acc)) {
|
||||||
|
return $acc;
|
||||||
|
}
|
||||||
$this->token = $acc['token'];
|
$this->token = $acc['token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a line to the logfile.
|
* Add a line to the logfile.
|
||||||
*
|
*
|
||||||
* @param item : string - the new row of log file
|
* @param string $item - the new row of log file
|
||||||
*/
|
*/
|
||||||
function addLogItem($item)
|
function addLogItem($item)
|
||||||
{
|
{
|
||||||
|
@ -407,27 +434,31 @@ class Backup
|
||||||
fclose($f);
|
fclose($f);
|
||||||
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
|
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a directory recursive
|
* Delete a directory recursive
|
||||||
*
|
*
|
||||||
* @param dirname : string - path of dir.
|
* @param string $dirname - path of dir.
|
||||||
*/
|
*/
|
||||||
function rRmDir($dirname)
|
function rRmDir($dirname)
|
||||||
{
|
{
|
||||||
if(is_dir($dirname))
|
if (is_dir($dirname)) {
|
||||||
$dir_handle = opendir($dirname);
|
$dir_handle = opendir($dirname);
|
||||||
while($file = readdir($dir_handle)) {
|
}
|
||||||
if($file!="." && $file!="..") {
|
while ($file = readdir($dir_handle)) {
|
||||||
if(!is_dir($dirname."/".$file))
|
if ( ($file != ".") && ($file != "..") ) {
|
||||||
|
if (!is_dir($dirname."/".$file)) {
|
||||||
unlink ($dirname."/".$file);
|
unlink ($dirname."/".$file);
|
||||||
else
|
} else {
|
||||||
Backup::rRmDir($dirname."/".$file);
|
Backup::rRmDir($dirname."/".$file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dir_handle);
|
closedir($dir_handle);
|
||||||
rmdir($dirname);
|
rmdir($dirname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // classs Backup
|
||||||
?>
|
?>
|
|
@ -1,32 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
define('GBERR_DENY', 40);
|
define('GBERR_DENY', 40);
|
||||||
define('GBERR_FILEIO', 41);
|
define('GBERR_FILEIO', 41);
|
||||||
define('GBERR_FILENEX', 42);
|
define('GBERR_FILENEX', 42);
|
||||||
|
@ -50,13 +22,15 @@ require_once "StoredFile.php";
|
||||||
require_once "Transport.php";
|
require_once "Transport.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BasicStor class
|
* BasicStor class
|
||||||
*
|
*
|
||||||
* Core of LiveSupport file storage module
|
* Core of Campcaster file storage module
|
||||||
*
|
*
|
||||||
* @author $Author$
|
* @author $Author$
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @see Alib
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib {
|
class BasicStor extends Alib {
|
||||||
var $filesTable;
|
var $filesTable;
|
||||||
|
@ -88,15 +62,15 @@ class BasicStor extends Alib {
|
||||||
$this->bufferDir = realpath($config['bufferDir']);
|
$this->bufferDir = realpath($config['bufferDir']);
|
||||||
$this->transDir = realpath($config['transDir']);
|
$this->transDir = realpath($config['transDir']);
|
||||||
$this->accessDir = realpath($config['accessDir']);
|
$this->accessDir = realpath($config['accessDir']);
|
||||||
if(!$install){
|
if (!$install) {
|
||||||
$this->rootId = $r = $this->getRootNode();
|
$this->rootId = $r = $this->getRootNode();
|
||||||
if ($this->dbc->isError($r)){
|
if ($this->dbc->isError($r)) {
|
||||||
trigger_error("BasicStor: ".
|
trigger_error("BasicStor: ".
|
||||||
$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
|
$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
|
||||||
}
|
}
|
||||||
$this->storId = $this->wd =
|
$this->storId = $this->wd =
|
||||||
$r = $this->getObjId('StorageRoot', $this->getRootNode());
|
$r = $this->getObjId('StorageRoot', $this->getRootNode());
|
||||||
if ($this->dbc->isError($r)){
|
if ($this->dbc->isError($r)) {
|
||||||
trigger_error("BasicStor: ".
|
trigger_error("BasicStor: ".
|
||||||
$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
|
$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +121,7 @@ class BasicStor extends Alib {
|
||||||
if ($this->dbc->isError($ac)){
|
if ($this->dbc->isError($ac)){
|
||||||
$res = $this->removeObj($id);
|
$res = $this->removeObj($id);
|
||||||
// catch constraint violations
|
// catch constraint violations
|
||||||
switch($ac->getCode()){
|
switch ($ac->getCode()){
|
||||||
case -3:
|
case -3:
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"BasicStor::bsPutFile: gunid duplication",
|
"BasicStor::bsPutFile: gunid duplication",
|
||||||
|
@ -1173,7 +1147,7 @@ class BasicStor extends Alib {
|
||||||
* @param int $parid, destination folder local id
|
* @param int $parid, destination folder local id
|
||||||
* @param string $plid, playlist gunid
|
* @param string $plid, playlist gunid
|
||||||
* @param string $aPath, absolute path part of imported file
|
* @param string $aPath, absolute path part of imported file
|
||||||
* (e.g. /home/user/livesupport)
|
* (e.g. /home/user/campcaster)
|
||||||
* @param string $rPath, relative path/filename part of imported file
|
* @param string $rPath, relative path/filename part of imported file
|
||||||
* (e.g. playlists/playlist_1.smil)
|
* (e.g. playlists/playlist_1.smil)
|
||||||
* @param string $ext, playlist extension (determines type of import)
|
* @param string $ext, playlist extension (determines type of import)
|
||||||
|
|
|
@ -1,32 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
define('USE_INTERSECT', TRUE);
|
define('USE_INTERSECT', TRUE);
|
||||||
|
|
||||||
require_once "XML/Util.php";
|
require_once "XML/Util.php";
|
||||||
|
@ -39,7 +11,7 @@ require_once "XML/Util.php";
|
||||||
* <li>filetype - string, type of searched files,
|
* <li>filetype - string, type of searched files,
|
||||||
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
|
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
|
||||||
* <li>operator - string, type of conditions join
|
* <li>operator - string, type of conditions join
|
||||||
* (any condition matches / all conditions match),
|
* (any condition matches / all conditions match),
|
||||||
* meaningful values: 'and', 'or', ''
|
* meaningful values: 'and', 'or', ''
|
||||||
* (may be empty or ommited only with less then 2 items in
|
* (may be empty or ommited only with less then 2 items in
|
||||||
* "conditions" field)
|
* "conditions" field)
|
||||||
|
@ -63,8 +35,12 @@ require_once "XML/Util.php";
|
||||||
* <li>cnt : integer - number of matching items</li>
|
* <li>cnt : integer - number of matching items</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @see MetaData
|
* @Author $Author$
|
||||||
* @see StoredFile
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see MetaData
|
||||||
|
* @see StoredFile
|
||||||
*/
|
*/
|
||||||
class DataEngine{
|
class DataEngine{
|
||||||
|
|
||||||
|
@ -136,7 +112,7 @@ class DataEngine{
|
||||||
}
|
}
|
||||||
return $whereArr;
|
return $whereArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method returning SQL query for search/browse with AND operator
|
* Method returning SQL query for search/browse with AND operator
|
||||||
* (without using INTERSECT command)
|
* (without using INTERSECT command)
|
||||||
|
@ -156,7 +132,7 @@ class DataEngine{
|
||||||
foreach($whereArr as $i=>$v){
|
foreach($whereArr as $i=>$v){
|
||||||
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
||||||
$lastTbl = ($i==0 ? "f" : "md".($i-1));
|
$lastTbl = ($i==0 ? "f" : "md".($i-1));
|
||||||
$innerBlocks[] =
|
$innerBlocks[] =
|
||||||
"INNER JOIN {$this->mdataTable} md$i ON md$i.gunid = $lastTbl.gunid\n";
|
"INNER JOIN {$this->mdataTable} md$i ON md$i.gunid = $lastTbl.gunid\n";
|
||||||
}
|
}
|
||||||
// query construcion:
|
// query construcion:
|
||||||
|
@ -173,7 +149,7 @@ class DataEngine{
|
||||||
if($browse) $sql .= "\nORDER BY br.object";
|
if($browse) $sql .= "\nORDER BY br.object";
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method returning SQL query for search/browse with AND operator
|
* Method returning SQL query for search/browse with AND operator
|
||||||
* (using INTERSECT command)
|
* (using INTERSECT command)
|
||||||
|
@ -194,13 +170,13 @@ class DataEngine{
|
||||||
$isectBlocks = array();
|
$isectBlocks = array();
|
||||||
foreach($whereArr as $i=>$v){
|
foreach($whereArr as $i=>$v){
|
||||||
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
||||||
$isectBlocks[] =
|
$isectBlocks[] =
|
||||||
" SELECT gunid FROM {$this->mdataTable} md$i\n".
|
" SELECT gunid FROM {$this->mdataTable} md$i\n".
|
||||||
" WHERE\n {$whereArr[$i]}";
|
" WHERE\n {$whereArr[$i]}";
|
||||||
}
|
}
|
||||||
// query construcion:
|
// query construcion:
|
||||||
if(count($isectBlocks)>0){
|
if(count($isectBlocks)>0){
|
||||||
$isectBlock =
|
$isectBlock =
|
||||||
"FROM\n(\n".join("INTERSECT\n", $isectBlocks).") sq\n".
|
"FROM\n(\n".join("INTERSECT\n", $isectBlocks).") sq\n".
|
||||||
"INNER JOIN {$this->filesTable} f ON f.gunid = sq.gunid";
|
"INNER JOIN {$this->filesTable} f ON f.gunid = sq.gunid";
|
||||||
}else{
|
}else{
|
||||||
|
@ -218,7 +194,7 @@ class DataEngine{
|
||||||
if($browse) $sql .= "\nORDER BY br.object";
|
if($browse) $sql .= "\nORDER BY br.object";
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method returning SQL query for search/browse with OR operator
|
* Method returning SQL query for search/browse with OR operator
|
||||||
*
|
*
|
||||||
|
@ -255,7 +231,7 @@ class DataEngine{
|
||||||
if($browse) $sql .= "\nORDER BY br.object";
|
if($browse) $sql .= "\nORDER BY br.object";
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search in local metadata database.
|
* Search in local metadata database.
|
||||||
*
|
*
|
||||||
|
@ -264,7 +240,7 @@ class DataEngine{
|
||||||
* @param offset int, starting point (0 means without offset)
|
* @param offset int, starting point (0 means without offset)
|
||||||
* @return hash, fields:
|
* @return hash, fields:
|
||||||
* results : array with gunid strings
|
* results : array with gunid strings
|
||||||
* cnt : integer - number of matching gunids
|
* cnt : integer - number of matching gunids
|
||||||
* of files have been found
|
* of files have been found
|
||||||
*/
|
*/
|
||||||
function localSearch($cri, $limit=0, $offset=0)
|
function localSearch($cri, $limit=0, $offset=0)
|
||||||
|
@ -273,7 +249,7 @@ class DataEngine{
|
||||||
// if(PEAR::isError($res)) return $res;
|
// if(PEAR::isError($res)) return $res;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search in local metadata database, more general version.
|
* Search in local metadata database, more general version.
|
||||||
*
|
*
|
||||||
|
@ -283,7 +259,7 @@ class DataEngine{
|
||||||
* @param brFldNs string - namespace prefix of category for browse
|
* @param brFldNs string - namespace prefix of category for browse
|
||||||
* @param brFld string, metadata category identifier for browse
|
* @param brFld string, metadata category identifier for browse
|
||||||
* @return arrays of hashes, fields:
|
* @return arrays of hashes, fields:
|
||||||
* cnt : integer - number of matching gunids
|
* cnt : integer - number of matching gunids
|
||||||
* of files have been found
|
* of files have been found
|
||||||
* results : array of hashes:
|
* results : array of hashes:
|
||||||
* gunid: string
|
* gunid: string
|
||||||
|
@ -393,7 +369,7 @@ class DataEngine{
|
||||||
* @param criteria hash
|
* @param criteria hash
|
||||||
* @return hash, fields:
|
* @return hash, fields:
|
||||||
* results : array with found values
|
* results : array with found values
|
||||||
* cnt : integer - number of matching values
|
* cnt : integer - number of matching values
|
||||||
*/
|
*/
|
||||||
function browseCategory($category, $limit=0, $offset=0, $criteria=NULL)
|
function browseCategory($category, $limit=0, $offset=0, $criteria=NULL)
|
||||||
{
|
{
|
||||||
|
@ -421,7 +397,7 @@ class DataEngine{
|
||||||
if(!is_array($res)) $res = array();
|
if(!is_array($res)) $res = array();
|
||||||
return array('results'=>$res, 'cnt'=>$cnt);
|
return array('results'=>$res, 'cnt'=>$cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of rows in query result
|
* Get number of rows in query result
|
||||||
*
|
*
|
||||||
|
@ -437,7 +413,7 @@ class DataEngine{
|
||||||
$rh->free();
|
$rh->free();
|
||||||
return $cnt;
|
return $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,42 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
require_once "BasicStor.php";
|
require_once "BasicStor.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GreenBox class
|
* GreenBox class
|
||||||
*
|
*
|
||||||
* LiveSupport file storage module
|
* File storage module.
|
||||||
*
|
*
|
||||||
* @author $Author$
|
* @author $Author$
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @see BasicStor
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see BasicStor
|
||||||
*/
|
*/
|
||||||
class GreenBox extends BasicStor {
|
class GreenBox extends BasicStor {
|
||||||
|
|
||||||
|
@ -77,7 +51,7 @@ class GreenBox extends BasicStor {
|
||||||
$mediaFileLP, $mdataFileLP, $sessid='',
|
$mediaFileLP, $mdataFileLP, $sessid='',
|
||||||
$gunid=NULL, $ftype='audioclip')
|
$gunid=NULL, $ftype='audioclip')
|
||||||
{
|
{
|
||||||
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
return $this->bsPutFile(
|
return $this->bsPutFile(
|
||||||
|
|
|
@ -1,39 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
require_once "BasicStor.php";
|
require_once "BasicStor.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LocStor class
|
* LocStor class
|
||||||
*
|
*
|
||||||
* Livesupport local storage interface
|
* Local storage interface
|
||||||
|
*
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
*/
|
*/
|
||||||
class LocStor extends BasicStor {
|
class LocStor extends BasicStor {
|
||||||
|
|
||||||
|
@ -1270,7 +1246,7 @@ class LocStor extends BasicStor {
|
||||||
|
|
||||||
/*===================================================== auxiliary methods */
|
/*===================================================== auxiliary methods */
|
||||||
/**
|
/**
|
||||||
* Dummy method - only returns livesupport version
|
* Dummy method - only returns Campcaster version
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?
|
<?
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomash $
|
|
||||||
Version : $Revision: 1848 $
|
|
||||||
Location : $URL: svn+ssh://tomash@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/storageServer/var/AccessRecur.php $
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
require_once "Playlist.php";
|
require_once "Playlist.php";
|
||||||
|
|
||||||
define('INDCH', ' ');
|
define('INDCH', ' ');
|
||||||
|
@ -35,9 +6,15 @@ define('AC_URL_RELPATH', '../audioClip/');
|
||||||
define('PL_URL_RELPATH', '../playlist/');
|
define('PL_URL_RELPATH', '../playlist/');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LsPlaylist class
|
* LsPlaylist class
|
||||||
*
|
*
|
||||||
* Livesupport internal playlist format helper
|
* Internal playlist format helper.
|
||||||
|
*
|
||||||
|
* @author $Author: tomash $
|
||||||
|
* @version $Revision: 1848 $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @todo Rename this class
|
||||||
*/
|
*/
|
||||||
class LsPlaylist extends Playlist
|
class LsPlaylist extends Playlist
|
||||||
{
|
{
|
||||||
|
@ -45,9 +22,9 @@ class LsPlaylist extends Playlist
|
||||||
* Create instance of LsPlaylist object and recall existing file
|
* Create instance of LsPlaylist object and recall existing file
|
||||||
* by gunid.<br/>
|
* by gunid.<br/>
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param Greenbox $gb, reference to GreenBox object
|
||||||
* @param gunid string, global unique id
|
* @param string $gunid, global unique id
|
||||||
* @param className string, optional classname to recall
|
* @param string $className, optional classname to recall
|
||||||
* @return instance of LsPlaylist object
|
* @return instance of LsPlaylist object
|
||||||
*/
|
*/
|
||||||
function &recallByGunid(&$gb, $gunid, $className='LsPlaylist')
|
function &recallByGunid(&$gb, $gunid, $className='LsPlaylist')
|
||||||
|
@ -55,13 +32,14 @@ class LsPlaylist extends Playlist
|
||||||
return parent::recallByGunid($gb, $gunid, $className);
|
return parent::recallByGunid($gb, $gunid, $className);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of LsPlaylist object and recall existing file
|
* Create instance of LsPlaylist object and recall existing file
|
||||||
* by access token.<br/>
|
* by access token.<br/>
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param GreenBox $gb, reference to GreenBox object
|
||||||
* @param token string, access token
|
* @param string $token, access token
|
||||||
* @param className string, optional classname to recall
|
* @param string $className, optional classname to recall
|
||||||
* @return instance of LsPlaylist object
|
* @return instance of LsPlaylist object
|
||||||
*/
|
*/
|
||||||
function &recallByToken(&$gb, $token, $className='LsPlaylist')
|
function &recallByToken(&$gb, $token, $className='LsPlaylist')
|
||||||
|
@ -69,23 +47,30 @@ class LsPlaylist extends Playlist
|
||||||
return parent::recallByToken($gb, $token, $className);
|
return parent::recallByToken($gb, $token, $className);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export playlist as simplified SMIL XML file
|
* Export playlist as simplified SMIL XML file
|
||||||
*
|
*
|
||||||
* @param toString boolean, if false don't real export,
|
* @param boolean $toString
|
||||||
* return misc info about playlist only
|
* if false don't real export,
|
||||||
* @return XML string or hasharray with misc info
|
* return misc info about playlist only
|
||||||
|
* @return string
|
||||||
|
* XML string or hasharray with misc info
|
||||||
*/
|
*/
|
||||||
function output2Smil($toString=TRUE)
|
function output2Smil($toString=TRUE)
|
||||||
{
|
{
|
||||||
$plGunid = $this->gunid;
|
$plGunid = $this->gunid;
|
||||||
$arr = $r = $this->md->genPhpArray();
|
$arr = $r = $this->md->genPhpArray();
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
if($toString){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($toString) {
|
||||||
$r = LsPlaylistTag::output2Smil($this, $arr);
|
$r = LsPlaylistTag::output2Smil($this, $arr);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}else{
|
} else {
|
||||||
return array(
|
return array(
|
||||||
'type' => 'playlist',
|
'type' => 'playlist',
|
||||||
'gunid' => $plGunid,
|
'gunid' => $plGunid,
|
||||||
|
@ -95,6 +80,7 @@ class LsPlaylist extends Playlist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export playlist as M3U file
|
* Export playlist as M3U file
|
||||||
*
|
*
|
||||||
|
@ -106,12 +92,16 @@ class LsPlaylist extends Playlist
|
||||||
{
|
{
|
||||||
$plGunid = $this->gunid;
|
$plGunid = $this->gunid;
|
||||||
$arr = $r = $this->md->genPhpArray();
|
$arr = $r = $this->md->genPhpArray();
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
if($toString){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($toString) {
|
||||||
$r = LsPlaylistTag::output2m3u($this, $arr);
|
$r = LsPlaylistTag::output2m3u($this, $arr);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}else{
|
} else {
|
||||||
return array(
|
return array(
|
||||||
'type' => 'playlist',
|
'type' => 'playlist',
|
||||||
'gunid' => $plGunid,
|
'gunid' => $plGunid,
|
||||||
|
@ -122,23 +112,30 @@ class LsPlaylist extends Playlist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export playlist as RSS XML file
|
* Export playlist as RSS XML file
|
||||||
*
|
*
|
||||||
* @param toString boolean, if false don't real export,
|
* @param boolean $toString
|
||||||
* return misc info about playlist only
|
* if false don't really export,
|
||||||
* @return XML string or hasharray with misc info
|
* return misc info about playlist only
|
||||||
|
* @return mixed
|
||||||
|
* XML string or hasharray with misc info
|
||||||
*/
|
*/
|
||||||
function output2RSS($toString=TRUE)
|
function output2RSS($toString=TRUE)
|
||||||
{
|
{
|
||||||
$plGunid = $this->gunid;
|
$plGunid = $this->gunid;
|
||||||
$arr = $r = $this->md->genPhpArray();
|
$arr = $r = $this->md->genPhpArray();
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
if($toString){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($toString) {
|
||||||
$r = LsPlaylistTag::output2RSS($this, $arr);
|
$r = LsPlaylistTag::output2RSS($this, $arr);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}else{
|
} else {
|
||||||
return array(
|
return array(
|
||||||
'type' => 'playlist',
|
'type' => 'playlist',
|
||||||
'gunid' => $plGunid,
|
'gunid' => $plGunid,
|
||||||
|
@ -147,28 +144,43 @@ class LsPlaylist extends Playlist
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // class LsPlaylist
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Several auxiliary classes follows
|
* Several auxiliary classes follows
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @todo Rename this class PlaylistTag
|
||||||
*/
|
*/
|
||||||
class LsPlaylistTag
|
class LsPlaylistTag
|
||||||
{
|
{
|
||||||
function output2Smil(&$pl, $plt, $ind='')
|
function output2Smil(&$pl, $plt, $ind='')
|
||||||
{
|
{
|
||||||
$ind2 = $ind.INDCH; $ind3 = $ind2.INDCH; $ind4 = $ind3.INDCH;
|
$ind2 = $ind.INDCH;
|
||||||
|
$ind3 = $ind2.INDCH;
|
||||||
|
$ind4 = $ind3.INDCH;
|
||||||
$res = "";
|
$res = "";
|
||||||
foreach($plt['children'] as $ple){
|
foreach ($plt['children'] as $ple) {
|
||||||
switch($ple['elementname']){
|
switch ($ple['elementname']) {
|
||||||
case"playlistElement":
|
case"playlistElement":
|
||||||
$r = LsPlaylistElement::output2Smil($pl, $ple, $ind4);
|
$r = LsPlaylistElement::output2Smil($pl, $ple, $ind4);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $res .= $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$res .= $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"metadata":
|
case"metadata":
|
||||||
$r = LsPlaylistMetadata::output2Smil($pl, $ple, $ind4);
|
$r = LsPlaylistMetadata::output2Smil($pl, $ple, $ind4);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $res .= $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$res .= $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@ -183,36 +195,53 @@ class LsPlaylistTag
|
||||||
"$ind</smil>\n";
|
"$ind</smil>\n";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output2m3u(&$pl, $plt, $ind='')
|
function output2m3u(&$pl, $plt, $ind='')
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
foreach($plt['children'] as $ple){
|
foreach ($plt['children'] as $ple) {
|
||||||
switch($ple['elementname']){
|
switch ($ple['elementname']) {
|
||||||
case"playlistElement":
|
case"playlistElement":
|
||||||
$r = LsPlaylistElement::output2m3u($pl, $ple);
|
$r = LsPlaylistElement::output2m3u($pl, $ple);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $res .= $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$res .= $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$res = "#EXTM3U\n$res";
|
$res = "#EXTM3U\n$res";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output2RSS(&$pl, $plt, $ind='')
|
function output2RSS(&$pl, $plt, $ind='')
|
||||||
{
|
{
|
||||||
$ind2 = $ind.INDCH; $ind3 = $ind2.INDCH;
|
$ind2 = $ind.INDCH;
|
||||||
|
$ind3 = $ind2.INDCH;
|
||||||
$res = "";
|
$res = "";
|
||||||
foreach($plt['children'] as $ple){
|
foreach ($plt['children'] as $ple) {
|
||||||
switch($ple['elementname']){
|
switch ($ple['elementname']) {
|
||||||
case"playlistElement":
|
case"playlistElement":
|
||||||
$r = LsPlaylistElement::output2RSS($pl, $ple, $ind3);
|
$r = LsPlaylistElement::output2RSS($pl, $ple, $ind3);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $res .= $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$res .= $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"metadata":
|
case"metadata":
|
||||||
$r = LsPlaylistMetadata::output2RSS($pl, $ple, $ind3);
|
$r = LsPlaylistMetadata::output2RSS($pl, $ple, $ind3);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $res .= $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$res .= $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@ -225,32 +254,57 @@ class LsPlaylistTag
|
||||||
"$ind</rss>\n";
|
"$ind</rss>\n";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
} // class LsPlaylistTag
|
||||||
class LsPlaylistElement{
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @todo Rename this class "PlaylistElement"
|
||||||
|
*/
|
||||||
|
class LsPlaylistElement {
|
||||||
|
|
||||||
|
|
||||||
function output2Smil(&$pl, $ple, $ind='')
|
function output2Smil(&$pl, $ple, $ind='')
|
||||||
{
|
{
|
||||||
$acOrPl = NULL; $finfo = array('fi'=>0, 'fo'=>0);
|
$acOrPl = NULL;
|
||||||
$ind2 = $ind.INDCH; $ind3 = $ind2.INDCH;
|
$finfo = array('fi'=>0, 'fo'=>0);
|
||||||
|
$ind2 = $ind.INDCH;
|
||||||
|
$ind3 = $ind2.INDCH;
|
||||||
$anim = '';
|
$anim = '';
|
||||||
foreach($ple['children'] as $ac){
|
foreach ($ple['children'] as $ac) {
|
||||||
switch($ac['elementname']){
|
switch ($ac['elementname']) {
|
||||||
case"audioClip":
|
case "audioClip":
|
||||||
$r = LsPlaylistAudioClip::output2Smil($pl, $ac, $ind2);
|
$r = LsPlaylistAudioClip::output2Smil($pl, $ac, $ind2);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $acOrPl = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$acOrPl = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"playlist":
|
case "playlist":
|
||||||
$gunid = $ac['attrs']['id'];
|
$gunid = $ac['attrs']['id'];
|
||||||
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
|
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $pl2->output2Smil(FALSE);
|
$r = $pl2->output2Smil(FALSE);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $acOrPl = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$acOrPl = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"fadeInfo":
|
case"fadeInfo":
|
||||||
$r = LsPlaylistFadeInfo::output2Smil($pl, $ac, $ind2);
|
$r = LsPlaylistFadeInfo::output2Smil($pl, $ac, $ind2);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $finfo = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$finfo = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
|
@ -266,8 +320,8 @@ class LsPlaylistElement{
|
||||||
$fiEndS = $pl->_plTimeToSecs($finfo['fi']);
|
$fiEndS = $pl->_plTimeToSecs($finfo['fi']);
|
||||||
$foBeginS = ($playlengthS - $fadeOutS);
|
$foBeginS = ($playlengthS - $fadeOutS);
|
||||||
$foEndS = $pl->_plTimeToSecs($acOrPl['playlength']);
|
$foEndS = $pl->_plTimeToSecs($acOrPl['playlength']);
|
||||||
foreach(array('fi','fo') as $ff){
|
foreach (array('fi','fo') as $ff) {
|
||||||
if(${$ff."EndS"} - ${$ff."BeginS"} > 0){
|
if (${$ff."EndS"} - ${$ff."BeginS"} > 0) {
|
||||||
$anim .= "{$ind2}<animate attributeName = \"soundLevel\"\n".
|
$anim .= "{$ind2}<animate attributeName = \"soundLevel\"\n".
|
||||||
"{$ind3}from = \"".($ff == 'fi' ? 0 : 100)."%\"\n".
|
"{$ind3}from = \"".($ff == 'fi' ? 0 : 100)."%\"\n".
|
||||||
"{$ind3}to = \"".($ff == 'fi' ? 100 : 0)."%\"\n".
|
"{$ind3}to = \"".($ff == 'fi' ? 100 : 0)."%\"\n".
|
||||||
|
@ -277,7 +331,6 @@ class LsPlaylistElement{
|
||||||
"{$ind3}fill = \"freeze\"\n".
|
"{$ind3}fill = \"freeze\"\n".
|
||||||
"{$ind2}/>\n"
|
"{$ind2}/>\n"
|
||||||
;
|
;
|
||||||
}else{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$src = $acOrPl['src'];
|
$src = $acOrPl['src'];
|
||||||
|
@ -287,27 +340,41 @@ class LsPlaylistElement{
|
||||||
"\n";
|
"\n";
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output2m3u(&$pl, $ple, $ind='')
|
function output2m3u(&$pl, $ple, $ind='')
|
||||||
{
|
{
|
||||||
$acOrPl = NULL;
|
$acOrPl = NULL;
|
||||||
foreach($ple['children'] as $ac){
|
foreach ($ple['children'] as $ac) {
|
||||||
switch($ac['elementname']){
|
switch ($ac['elementname']) {
|
||||||
case"audioClip":
|
case "audioClip":
|
||||||
$r = LsPlaylistAudioClip::output2m3u($pl, $ac);
|
$r = LsPlaylistAudioClip::output2m3u($pl, $ac);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $acOrPl = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$acOrPl = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"playlist":
|
case "playlist":
|
||||||
$gunid = $ac['attrs']['id'];
|
$gunid = $ac['attrs']['id'];
|
||||||
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
|
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $pl2->output2m3u(FALSE);
|
$r = $pl2->output2m3u(FALSE);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $acOrPl = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$acOrPl = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(is_null($acOrPl)) return '';
|
if (is_null($acOrPl)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
$playlength = ceil($pl->_plTimeToSecs($acOrPl['playlength']));
|
$playlength = ceil($pl->_plTimeToSecs($acOrPl['playlength']));
|
||||||
$title = $acOrPl['title'];
|
$title = $acOrPl['title'];
|
||||||
$uri = (isset($acOrPl['uri']) ? $acOrPl['uri'] : '???' );
|
$uri = (isset($acOrPl['uri']) ? $acOrPl['uri'] : '???' );
|
||||||
|
@ -315,25 +382,37 @@ class LsPlaylistElement{
|
||||||
$res .= "$uri\n";
|
$res .= "$uri\n";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output2RSS(&$pl, $ple, $ind='')
|
function output2RSS(&$pl, $ple, $ind='')
|
||||||
{
|
{
|
||||||
$acOrPl = NULL;
|
$acOrPl = NULL;
|
||||||
$ind2 = $ind.INDCH;
|
$ind2 = $ind.INDCH;
|
||||||
$anim = '';
|
$anim = '';
|
||||||
foreach($ple['children'] as $ac){
|
foreach ($ple['children'] as $ac) {
|
||||||
switch($ac['elementname']){
|
switch ($ac['elementname']) {
|
||||||
case"audioClip":
|
case "audioClip":
|
||||||
$r = LsPlaylistAudioClip::output2RSS($pl, $ac, $ind2);
|
$r = LsPlaylistAudioClip::output2RSS($pl, $ac, $ind2);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $acOrPl = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$acOrPl = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"playlist":
|
case"playlist":
|
||||||
$gunid = $ac['attrs']['id'];
|
$gunid = $ac['attrs']['id'];
|
||||||
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
|
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $pl2->output2RSS(FALSE);
|
$r = $pl2->output2RSS(FALSE);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if(!is_null($r)) $acOrPl = $r;
|
return $r;
|
||||||
|
}
|
||||||
|
if (!is_null($r)) {
|
||||||
|
$acOrPl = $r;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case"fadeInfo":
|
case"fadeInfo":
|
||||||
break;
|
break;
|
||||||
|
@ -356,15 +435,27 @@ class LsPlaylistElement{
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @todo Rename this class to PlaylistAudioClip (notice the caps)
|
||||||
|
*/
|
||||||
class LsPLaylistAudioClip
|
class LsPLaylistAudioClip
|
||||||
{
|
{
|
||||||
|
|
||||||
function output2Smil(&$pl, $plac, $ind='')
|
function output2Smil(&$pl, $plac, $ind='')
|
||||||
{
|
{
|
||||||
$gunid = $plac['attrs']['id'];
|
$gunid = $plac['attrs']['id'];
|
||||||
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
|
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$RADext = $r =$ac->_getExt();
|
$RADext = $r =$ac->_getExt();
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return array(
|
return array(
|
||||||
'type' => 'audioclip',
|
'type' => 'audioclip',
|
||||||
'gunid' => $gunid,
|
'gunid' => $gunid,
|
||||||
|
@ -372,31 +463,47 @@ class LsPLaylistAudioClip
|
||||||
'playlength' => $plac['attrs']['playlength'],
|
'playlength' => $plac['attrs']['playlength'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output2m3u(&$pl, $plac, $ind='')
|
function output2m3u(&$pl, $plac, $ind='')
|
||||||
{
|
{
|
||||||
$gunid = $plac['attrs']['id'];
|
$gunid = $plac['attrs']['id'];
|
||||||
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
|
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$RADext = $r =$ac->_getExt();
|
$RADext = $r =$ac->_getExt();
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return array(
|
return array(
|
||||||
'playlength' => $plac['attrs']['playlength'],
|
'playlength' => $plac['attrs']['playlength'],
|
||||||
'title' => $plac['attrs']['title'],
|
'title' => $plac['attrs']['title'],
|
||||||
'uri' => AC_URL_RELPATH."$gunid.$RADext",
|
'uri' => AC_URL_RELPATH."$gunid.$RADext",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output2RSS(&$pl, $plac, $ind='')
|
function output2RSS(&$pl, $plac, $ind='')
|
||||||
{
|
{
|
||||||
$gunid = $plac['attrs']['id'];
|
$gunid = $plac['attrs']['id'];
|
||||||
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
|
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$RADext = $r =$ac->_getExt();
|
$RADext = $r =$ac->_getExt();
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $pl->gb->bsGetMetadataValue($ac->getId(), 'dc:title');
|
$r = $pl->gb->bsGetMetadataValue($ac->getId(), 'dc:title');
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$title = ( isset($r[0]) ? $r[0]['value'] : '' );
|
$title = ( isset($r[0]) ? $r[0]['value'] : '' );
|
||||||
$r = $pl->gb->bsGetMetadataValue($ac->getId(), 'dc:description');
|
$r = $pl->gb->bsGetMetadataValue($ac->getId(), 'dc:description');
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$desc = ( isset($r[0]) ? $r[0]['value'] : '' );
|
$desc = ( isset($r[0]) ? $r[0]['value'] : '' );
|
||||||
return array(
|
return array(
|
||||||
'type' => 'audioclip',
|
'type' => 'audioclip',
|
||||||
|
@ -407,10 +514,17 @@ class LsPLaylistAudioClip
|
||||||
'desc' => $desc,
|
'desc' => $desc,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} // class LsPlaylistAudioClip
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @todo Rename this class "PlaylistFadeInfo" (notive the caps)
|
||||||
|
*/
|
||||||
class LsPLaylistFadeInfo
|
class LsPLaylistFadeInfo
|
||||||
{
|
{
|
||||||
|
|
||||||
function output2Smil(&$pl, $plfi, $ind='')
|
function output2Smil(&$pl, $plfi, $ind='')
|
||||||
{
|
{
|
||||||
$r = array(
|
$r = array(
|
||||||
|
@ -419,14 +533,44 @@ class LsPLaylistFadeInfo
|
||||||
);
|
);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
function output2m3u(&$pl, $plfa, $ind=''){ return ''; }
|
|
||||||
function output2RSS(&$pl, $plfa, $ind=''){ return ''; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
function output2m3u(&$pl, $plfa, $ind='')
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function output2RSS(&$pl, $plfa, $ind='')
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
} // class LsPlaylistFadeInfo
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @todo Rename this class to PlaylistMetadata (notive the caps)
|
||||||
|
*/
|
||||||
class LsPLaylistMetadata
|
class LsPLaylistMetadata
|
||||||
{
|
{
|
||||||
function output2Smil(&$pl, $md, $ind=''){ return NULL; }
|
function output2Smil(&$pl, $md, $ind='')
|
||||||
function output2m3u(&$pl, $md, $ind=''){ return NULL; }
|
{
|
||||||
function output2RSS(&$pl, $md, $ind=''){ return NULL; }
|
return NULL;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
||||||
|
function output2m3u(&$pl, $md, $ind='')
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function output2RSS(&$pl, $md, $ind='')
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} // class PlaylistMetadata
|
||||||
|
?>
|
|
@ -1,38 +1,13 @@
|
||||||
<?
|
<?
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomash $
|
|
||||||
Version : $Revision: 1848 $
|
|
||||||
Location : $URL: svn+ssh://tomash@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/storageServer/var/AccessRecur.php $
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
define('INDCH', ' ');
|
define('INDCH', ' ');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* M3uPlaylist class
|
* M3uPlaylist class
|
||||||
*
|
*
|
||||||
|
* @author $Author: tomash $
|
||||||
|
* @version : $Revision: 1848 $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
*/
|
*/
|
||||||
class M3uPlaylist {
|
class M3uPlaylist {
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +54,7 @@ class M3uPlaylist {
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param gb reference to GreenBox object
|
||||||
* @param aPath string, absolute path part of imported file
|
* @param aPath string, absolute path part of imported file
|
||||||
* (e.g. /home/user/livesupport)
|
* (e.g. /home/user/campcaster)
|
||||||
* @param rPath string, relative path/filename part of imported file
|
* @param rPath string, relative path/filename part of imported file
|
||||||
* (e.g. playlists/playlist_1.smil)
|
* (e.g. playlists/playlist_1.smil)
|
||||||
* @param gunids hasharray, hash relation from filenames to gunids
|
* @param gunids hasharray, hash relation from filenames to gunids
|
||||||
|
@ -135,13 +110,13 @@ class M3uPlaylist {
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
return $pl;
|
return $pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import M3U file to storage
|
* Import M3U file to storage
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param gb reference to GreenBox object
|
||||||
* @param data string, local path to M3U file
|
* @param data string, local path to M3U file
|
||||||
* @return XML string - playlist in Livesupport playlist format
|
* @return XML string - playlist in Campcaster playlist format
|
||||||
*/
|
*/
|
||||||
function convert2lspl(&$gb, $data){
|
function convert2lspl(&$gb, $data){
|
||||||
$arr = $r = M3uPlaylist::parse($data);
|
$arr = $r = M3uPlaylist::parse($data);
|
||||||
|
@ -302,4 +277,4 @@ class M3uPlaylistAnimateElement{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,192 +1,215 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefs class
|
* Preference storage class.
|
||||||
*
|
*
|
||||||
* LiveSupport preference storage class
|
* @author $Author$
|
||||||
*
|
* @version $Revision$
|
||||||
* @see StoredFile
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see StoredFile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ================== Prefs ================== */
|
/* ================== Prefs ================== */
|
||||||
class Prefs{
|
class Prefs {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param gb object, GreenBox object reference
|
* @param GreenBox $gb
|
||||||
|
* GreenBox object reference
|
||||||
*/
|
*/
|
||||||
function Prefs(&$gb)
|
function Prefs(&$gb)
|
||||||
{
|
{
|
||||||
$this->gb =& $gb;
|
$this->gb =& $gb;
|
||||||
$this->dbc =& $gb->dbc;
|
$this->dbc =& $gb->dbc;
|
||||||
$this->prefTable = $gb->config['tblNamePrefix'].'pref';
|
$this->prefTable = $gb->config['tblNamePrefix'].'pref';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ======================================================= public methods */
|
/* ======================================================= public methods */
|
||||||
/* ----------------------------------------------------- user preferences */
|
/* ----------------------------------------------------- user preferences */
|
||||||
/**
|
/**
|
||||||
* Read preference record by session id
|
* Read preference record by session id
|
||||||
*
|
*
|
||||||
* @param sessid string, session id
|
* @param string $sessid
|
||||||
* @param key string, preference key
|
* session id
|
||||||
* @return string, preference value
|
* @param string $key
|
||||||
|
* preference key
|
||||||
|
* @return string
|
||||||
|
* preference value
|
||||||
*/
|
*/
|
||||||
function loadPref($sessid, $key)
|
function loadPref($sessid, $key)
|
||||||
{
|
{
|
||||||
$subjid = $this->gb->getSessUserId($sessid);
|
$subjid = $this->gb->getSessUserId($sessid);
|
||||||
if(PEAR::isError($subjid)) return $subjid;
|
if (PEAR::isError($subjid)) {
|
||||||
if(is_null($subjid)){
|
return $subjid;
|
||||||
|
}
|
||||||
|
if (is_null($subjid)) {
|
||||||
return PEAR::raiseError("Prefs::loadPref: invalid session id",
|
return PEAR::raiseError("Prefs::loadPref: invalid session id",
|
||||||
GBERR_SESS);
|
GBERR_SESS);
|
||||||
}
|
}
|
||||||
$val = $this->readVal($subjid, $key);
|
$val = $this->readVal($subjid, $key);
|
||||||
if(PEAR::isError($val)) return $val;
|
if (PEAR::isError($val)) {
|
||||||
if($val === FALSE){
|
return $val;
|
||||||
|
}
|
||||||
|
if ($val === FALSE) {
|
||||||
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
|
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
|
||||||
GBERR_PREF);
|
GBERR_PREF);
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save preference record by session id
|
* Save preference record by session id
|
||||||
*
|
*
|
||||||
* @param sessid string, session id
|
* @param string $sessid
|
||||||
* @param key string, preference key
|
* session id
|
||||||
* @param value string, preference value
|
* @param string $key
|
||||||
* @return boolean
|
* preference key
|
||||||
|
* @param string $value
|
||||||
|
* preference value
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function savePref($sessid, $key, $value)
|
function savePref($sessid, $key, $value)
|
||||||
{
|
{
|
||||||
$subjid = $this->gb->getSessUserId($sessid);
|
$subjid = $this->gb->getSessUserId($sessid);
|
||||||
if(PEAR::isError($subjid)) return $subjid;
|
if (PEAR::isError($subjid)) {
|
||||||
if(is_null($subjid)){
|
return $subjid;
|
||||||
|
}
|
||||||
|
if (is_null($subjid)) {
|
||||||
return PEAR::raiseError("Prefs::savePref: invalid session id",
|
return PEAR::raiseError("Prefs::savePref: invalid session id",
|
||||||
GBERR_SESS);
|
GBERR_SESS);
|
||||||
}
|
}
|
||||||
$r = $this->update($subjid, $key, $value);
|
$r = $this->update($subjid, $key, $value);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($r === FALSE){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($r === FALSE) {
|
||||||
$r = $this->insert($subjid, $key, $value);
|
$r = $this->insert($subjid, $key, $value);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete preference record by session id
|
* Delete preference record by session id
|
||||||
*
|
*
|
||||||
* @param sessid string, session id
|
* @param string $sessid
|
||||||
* @param key string, preference key
|
* session id
|
||||||
* @return boolean
|
* @param string $key
|
||||||
|
* preference key
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function delPref($sessid, $key)
|
function delPref($sessid, $key)
|
||||||
{
|
{
|
||||||
$subjid = $this->gb->getSessUserId($sessid);
|
$subjid = $this->gb->getSessUserId($sessid);
|
||||||
if(PEAR::isError($subjid)) return $subjid;
|
if (PEAR::isError($subjid)) {
|
||||||
if(is_null($subjid)){
|
return $subjid;
|
||||||
|
}
|
||||||
|
if (is_null($subjid)) {
|
||||||
return PEAR::raiseError("Prefs::delPref: invalid session id",
|
return PEAR::raiseError("Prefs::delPref: invalid session id",
|
||||||
GBERR_SESS);
|
GBERR_SESS);
|
||||||
}
|
}
|
||||||
$r = $this->delete($subjid, $key);
|
$r = $this->delete($subjid, $key);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($r === FALSE){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($r === FALSE) {
|
||||||
return PEAR::raiseError("Prefs::delPref: invalid preference key",
|
return PEAR::raiseError("Prefs::delPref: invalid preference key",
|
||||||
GBERR_PREF);
|
GBERR_PREF);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------- group preferences */
|
/* ---------------------------------------------------- group preferences */
|
||||||
/**
|
/**
|
||||||
* Read group preference record
|
* Read group preference record
|
||||||
*
|
*
|
||||||
* @param sessid string, session id
|
* @param string $sessid
|
||||||
* @param group string, group name
|
* session id
|
||||||
* @param key string, preference key
|
* @param string $group
|
||||||
* @return string, preference value
|
* group name
|
||||||
|
* @param string $key
|
||||||
|
* preference key
|
||||||
|
* @return string
|
||||||
|
* preference value
|
||||||
*/
|
*/
|
||||||
function loadGroupPref($sessid, $group, $key)
|
function loadGroupPref($sessid, $group, $key)
|
||||||
{
|
{
|
||||||
// if sessid is would be used here fix Transport::cronCallMethod !
|
// if sessid is would be used here fix Transport::cronCallMethod !
|
||||||
$subjid = $this->gb->getSubjId($group);
|
$subjid = $this->gb->getSubjId($group);
|
||||||
if(PEAR::isError($subjid)) return $subjid;
|
if (PEAR::isError($subjid)) {
|
||||||
if(is_null($subjid)){
|
return $subjid;
|
||||||
|
}
|
||||||
|
if (is_null($subjid)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::loadGroupPref: invalid group name", ALIBERR_NOTGR);
|
"Prefs::loadGroupPref: invalid group name", ALIBERR_NOTGR);
|
||||||
}
|
}
|
||||||
$val = $this->readVal($subjid, $key);
|
$val = $this->readVal($subjid, $key);
|
||||||
if(PEAR::isError($val)) return $val;
|
if (PEAR::isError($val)) {
|
||||||
if($val === FALSE){
|
return $val;
|
||||||
|
}
|
||||||
|
if ($val === FALSE) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF);
|
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF);
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save group preference record
|
* Save group preference record
|
||||||
*
|
*
|
||||||
* @param sessid string, session id
|
* @param string $sessid
|
||||||
* @param group string, group name
|
* session id
|
||||||
* @param key string, preference key
|
* @param string $group
|
||||||
* @param value string, preference value
|
* group name
|
||||||
* @return boolean
|
* @param string $key
|
||||||
|
* preference key
|
||||||
|
* @param string $value
|
||||||
|
* preference value
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function saveGroupPref($sessid, $group, $key, $value)
|
function saveGroupPref($sessid, $group, $key, $value)
|
||||||
{
|
{
|
||||||
$uid = $this->gb->getSessUserId($sessid);
|
$uid = $this->gb->getSessUserId($sessid);
|
||||||
if(PEAR::isError($uid)) return $uid;
|
if (PEAR::isError($uid)) {
|
||||||
if(is_null($uid)){
|
return $uid;
|
||||||
|
}
|
||||||
|
if (is_null($uid)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::saveGroupPref: invalid session id", GBERR_SESS);
|
"Prefs::saveGroupPref: invalid session id", GBERR_SESS);
|
||||||
}
|
}
|
||||||
$gid = $this->gb->getSubjId($group);
|
$gid = $this->gb->getSubjId($group);
|
||||||
if(PEAR::isError($gid)) return $gid;
|
if (PEAR::isError($gid)) {
|
||||||
if(is_null($gid)){
|
return $gid;
|
||||||
|
}
|
||||||
|
if (is_null($gid)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::saveGroupPref: invalid group name", GBERR_SESS);
|
"Prefs::saveGroupPref: invalid group name", GBERR_SESS);
|
||||||
}
|
}
|
||||||
$memb = $this->gb->isMemberOf($uid, $gid);
|
$memb = $this->gb->isMemberOf($uid, $gid);
|
||||||
if(PEAR::isError($memb)) return $memb;
|
if (PEAR::isError($memb)) {
|
||||||
if(!$memb){
|
return $memb;
|
||||||
|
}
|
||||||
|
if (!$memb) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::saveGroupPref: access denied", GBERR_DENY);
|
"Prefs::saveGroupPref: access denied", GBERR_DENY);
|
||||||
}
|
}
|
||||||
$r = $this->update($gid, $key, $value);
|
$r = $this->update($gid, $key, $value);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($r === FALSE){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($r === FALSE) {
|
||||||
$r = $this->insert($gid, $key, $value);
|
$r = $this->insert($gid, $key, $value);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -194,68 +217,93 @@ class Prefs{
|
||||||
/**
|
/**
|
||||||
* Delete group preference record
|
* Delete group preference record
|
||||||
*
|
*
|
||||||
* @param sessid string, session id
|
* @param string $sessid
|
||||||
* @param group string, group name
|
* session id
|
||||||
* @param key string, preference key
|
* @param string $group
|
||||||
* @return boolean
|
* group name
|
||||||
|
* @param string $key
|
||||||
|
* preference key
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function delGroupPref($sessid, $group, $key)
|
function delGroupPref($sessid, $group, $key)
|
||||||
{
|
{
|
||||||
$uid = $this->gb->getSessUserId($sessid);
|
$uid = $this->gb->getSessUserId($sessid);
|
||||||
if(PEAR::isError($uid)) return $uid;
|
if (PEAR::isError($uid)) {
|
||||||
if(is_null($uid)){
|
return $uid;
|
||||||
|
}
|
||||||
|
if (is_null($uid)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::delGroupPref: invalid session id", GBERR_SESS);
|
"Prefs::delGroupPref: invalid session id", GBERR_SESS);
|
||||||
}
|
}
|
||||||
$gid = $this->gb->getSubjId($group);
|
$gid = $this->gb->getSubjId($group);
|
||||||
if(PEAR::isError($gid)) return $gid;
|
if (PEAR::isError($gid)) {
|
||||||
if(is_null($gid)){
|
return $gid;
|
||||||
|
}
|
||||||
|
if (is_null($gid)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::delGroupPref: invalid group name", GBERR_SESS);
|
"Prefs::delGroupPref: invalid group name", GBERR_SESS);
|
||||||
}
|
}
|
||||||
$memb = $this->gb->isMemberOf($uid, $gid);
|
$memb = $this->gb->isMemberOf($uid, $gid);
|
||||||
if(PEAR::isError($memb)) return $memb;
|
if (PEAR::isError($memb)) {
|
||||||
if(!$memb){
|
return $memb;
|
||||||
|
}
|
||||||
|
if (!$memb) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::delGroupPref: access denied", GBERR_DENY);
|
"Prefs::delGroupPref: access denied", GBERR_DENY);
|
||||||
}
|
}
|
||||||
$r = $this->delete($gid, $key);
|
$r = $this->delete($gid, $key);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($r === FALSE){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($r === FALSE) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Prefs::delGroupPref: invalid preference key", GBERR_PREF);
|
"Prefs::delGroupPref: invalid preference key", GBERR_PREF);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ==================================================== low level methods */
|
/* ==================================================== low level methods */
|
||||||
/**
|
/**
|
||||||
* Insert of new preference record
|
* Insert of new preference record
|
||||||
*
|
*
|
||||||
* @param subjid int, local user/group id
|
* @param int $subjid
|
||||||
* @param keystr string, preference key
|
* local user/group id
|
||||||
* @param valstr string, preference value
|
* @param string $keystr
|
||||||
* @return int, local user id
|
* preference key
|
||||||
|
* @param string $valstr
|
||||||
|
* preference value
|
||||||
|
* @return int
|
||||||
|
* local user id
|
||||||
*/
|
*/
|
||||||
function insert($subjid, $keystr, $valstr='')
|
function insert($subjid, $keystr, $valstr='')
|
||||||
{
|
{
|
||||||
$id = $this->dbc->nextId("{$this->prefTable}_id_seq");
|
$id = $this->dbc->nextId("{$this->prefTable}_id_seq");
|
||||||
if(PEAR::isError($id)) return $id;
|
if (PEAR::isError($id)) {
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
$r = $this->dbc->query("
|
$r = $this->dbc->query("
|
||||||
INSERT INTO {$this->prefTable}
|
INSERT INTO {$this->prefTable}
|
||||||
(id, subjid, keystr, valstr)
|
(id, subjid, keystr, valstr)
|
||||||
VALUES
|
VALUES
|
||||||
($id, $subjid, '$keystr', '$valstr')
|
($id, $subjid, '$keystr', '$valstr')
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read value of preference record
|
* Read value of preference record
|
||||||
*
|
*
|
||||||
* @param subjid int, local user/group id
|
* @param int $subjid
|
||||||
* @param keystr string, preference key
|
* local user/group id
|
||||||
* @return string, preference value
|
* @param string $keystr
|
||||||
|
* preference key
|
||||||
|
* @return string
|
||||||
|
* preference value
|
||||||
*/
|
*/
|
||||||
function readVal($subjid, $keystr)
|
function readVal($subjid, $keystr)
|
||||||
{
|
{
|
||||||
|
@ -263,16 +311,23 @@ class Prefs{
|
||||||
SELECT valstr FROM {$this->prefTable}
|
SELECT valstr FROM {$this->prefTable}
|
||||||
WHERE subjid=$subjid AND keystr='$keystr'
|
WHERE subjid=$subjid AND keystr='$keystr'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($val)) return $val;
|
if (PEAR::isError($val)) {
|
||||||
if(is_null($val)) return FALSE;
|
return $val;
|
||||||
|
}
|
||||||
|
if (is_null($val)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read all keys of subject's preferences
|
* Read all keys of subject's preferences
|
||||||
*
|
*
|
||||||
* @param subjid int, local user/group id
|
* @param int $subjid
|
||||||
* @return array, preference keys
|
* local user/group id
|
||||||
|
* @return array
|
||||||
|
* preference keys
|
||||||
*/
|
*/
|
||||||
function readKeys($subjid)
|
function readKeys($subjid)
|
||||||
{
|
{
|
||||||
|
@ -280,18 +335,26 @@ class Prefs{
|
||||||
SELECT keystr FROM {$this->prefTable}
|
SELECT keystr FROM {$this->prefTable}
|
||||||
WHERE subjid=$subjid
|
WHERE subjid=$subjid
|
||||||
");
|
");
|
||||||
if(PEAR::isError($res)) return $res;
|
if (PEAR::isError($res)) {
|
||||||
if(is_null($res)) return FALSE;
|
return $res;
|
||||||
|
}
|
||||||
|
if (is_null($res)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update value of preference record
|
* Update value of preference record
|
||||||
*
|
*
|
||||||
* @param subjid int, local user/group id
|
* @param int $subjid
|
||||||
* @param keystr string, preference key
|
* local user/group id
|
||||||
* @param newvalstr string, new preference value
|
* @param string $keystr
|
||||||
* @return boolean
|
* preference key
|
||||||
|
* @param string $newvalstr
|
||||||
|
* new preference value
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function update($subjid, $keystr, $newvalstr='')
|
function update($subjid, $keystr, $newvalstr='')
|
||||||
{
|
{
|
||||||
|
@ -300,29 +363,41 @@ class Prefs{
|
||||||
valstr='$newvalstr'
|
valstr='$newvalstr'
|
||||||
WHERE subjid=$subjid AND keystr='$keystr'
|
WHERE subjid=$subjid AND keystr='$keystr'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($this->dbc->affectedRows()<1) return FALSE;
|
return $r;
|
||||||
|
}
|
||||||
|
if ($this->dbc->affectedRows() < 1) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete preference record
|
* Delete preference record
|
||||||
*
|
*
|
||||||
* @param subjid int, local user/group id
|
* @param int $subjid
|
||||||
* @param keystr string, preference key
|
* local user/group id
|
||||||
* @return boolean
|
* @param string $keystr
|
||||||
|
* preference key
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function delete($subjid, $keystr)
|
function delete($subjid, $keystr)
|
||||||
{
|
{
|
||||||
$r = $this->dbc->query("
|
$r = $this->dbc->query("
|
||||||
DELETE FROM {$this->prefTable}
|
DELETE FROM {$this->prefTable}
|
||||||
WHERE subjid=$subjid AND keystr='$keystr'
|
WHERE subjid=$subjid AND keystr='$keystr'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($this->dbc->affectedRows()<1) return FALSE;
|
return $r;
|
||||||
|
}
|
||||||
|
if ($this->dbc->affectedRows() < 1) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ==================================================== auxiliary methods */
|
/* ==================================================== auxiliary methods */
|
||||||
/**
|
/**
|
||||||
* Test method
|
* Test method
|
||||||
|
@ -334,26 +409,31 @@ class Prefs{
|
||||||
$testkey = 'testKey';
|
$testkey = 'testKey';
|
||||||
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
|
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
|
||||||
$r = savePref($sessid, $testKey, $testVal);
|
$r = savePref($sessid, $testKey, $testVal);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$val = loadPref($sessid, $testKey);
|
$val = loadPref($sessid, $testKey);
|
||||||
if($val != $testVal){
|
if ($val != $testVal) {
|
||||||
echo "ERROR: preference storage test failed.\n ($testVal / $val)\n";
|
echo "ERROR: preference storage test failed.\n ($testVal / $val)\n";
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
$r = savePref($sessid, $testKey, '');
|
$r = savePref($sessid, $testKey, '');
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$val = loadPref($sessid, $testKey);
|
$val = loadPref($sessid, $testKey);
|
||||||
if($val != $testVal){
|
if ($val != $testVal) {
|
||||||
echo "ERROR: preference storage test failed.\n ('' / '$val')\n";
|
echo "ERROR: preference storage test failed.\n ('' / '$val')\n";
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install database table for preference storage
|
* Install database table for preference storage
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function install()
|
function install()
|
||||||
{
|
{
|
||||||
|
@ -364,7 +444,9 @@ class Prefs{
|
||||||
keystr varchar(255),
|
keystr varchar(255),
|
||||||
valstr text
|
valstr text
|
||||||
)");
|
)");
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
|
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
|
||||||
ON {$this->prefTable} (id)");
|
ON {$this->prefTable} (id)");
|
||||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
|
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
|
||||||
|
@ -372,19 +454,26 @@ class Prefs{
|
||||||
$this->dbc->query("CREATE INDEX {$this->prefTable}_subjid_idx
|
$this->dbc->query("CREATE INDEX {$this->prefTable}_subjid_idx
|
||||||
ON {$this->prefTable} (subjid)");
|
ON {$this->prefTable} (subjid)");
|
||||||
$stPrefGr = $this->gb->getSubjId($this->gb->config['StationPrefsGr']);
|
$stPrefGr = $this->gb->getSubjId($this->gb->config['StationPrefsGr']);
|
||||||
if(PEAR::isError($stPrefGr)) echo $stPrefGr->getMessage()."\n";
|
if (PEAR::isError($stPrefGr)) {
|
||||||
|
echo $stPrefGr->getMessage()."\n";
|
||||||
|
}
|
||||||
$r = $this->insert($stPrefGr, 'stationName', "Radio Station 1");
|
$r = $this->insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||||
if(PEAR::isError($r)) echo $r->getMessage()."\n";
|
if (PEAR::isError($r)) {
|
||||||
|
echo $r->getMessage()."\n";
|
||||||
|
}
|
||||||
$genres = file_get_contents( dirname(__FILE__).'/genres.xml');
|
$genres = file_get_contents( dirname(__FILE__).'/genres.xml');
|
||||||
$r = $this->insert($stPrefGr, 'genres', $genres);
|
$r = $this->insert($stPrefGr, 'genres', $genres);
|
||||||
if(PEAR::isError($r)) echo $r->getMessage()."\n";
|
if (PEAR::isError($r)) {
|
||||||
|
echo $r->getMessage()."\n";
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstall database table for preference storage
|
* Uninstall database table for preference storage
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function uninstall()
|
function uninstall()
|
||||||
{
|
{
|
||||||
|
@ -392,12 +481,5 @@ class Prefs{
|
||||||
$this->dbc->dropSequence("{$this->prefTable}_id_seq");
|
$this->dbc->dropSequence("{$this->prefTable}_id_seq");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
} // class Prefs
|
||||||
*
|
?>
|
||||||
* /
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
|
@ -1,136 +1,129 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RawMediaData class
|
* RawMediaData class
|
||||||
*
|
*
|
||||||
* LiveSupport file storage support class
|
* File storage support class
|
||||||
* Store media files in real filesystem and handle access to them.<br>
|
* Store media files in real filesystem and handle access to them.<br>
|
||||||
*
|
*
|
||||||
* @see StoredFile
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see StoredFile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RawMediaData{
|
class RawMediaData{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param gunid string, global unique id
|
* @param string $gunid
|
||||||
* @param resDir string, resource directory
|
* global unique id
|
||||||
* @return this
|
* @param string $resDir
|
||||||
|
* resource directory
|
||||||
*/
|
*/
|
||||||
function RawMediaData($gunid, $resDir)
|
function RawMediaData($gunid, $resDir)
|
||||||
{
|
{
|
||||||
$this->gunid = $gunid;
|
$this->gunid = $gunid;
|
||||||
$this->resDir = $resDir;
|
$this->resDir = $resDir;
|
||||||
$this->fname = $this->makeFname();
|
$this->fname = $this->makeFname();
|
||||||
$this->exists =
|
$this->exists =
|
||||||
is_file($this->fname) &&
|
is_file($this->fname) &&
|
||||||
is_readable($this->fname)
|
is_readable($this->fname)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert media file to filesystem
|
* Insert media file to filesystem
|
||||||
*
|
*
|
||||||
* @param mediaFileLP string, local path
|
* @param string $mediaFileLP
|
||||||
* @return true or PEAR::error
|
* local path
|
||||||
|
* @return mixed
|
||||||
|
* true or PEAR::error
|
||||||
*/
|
*/
|
||||||
function insert($mediaFileLP)
|
function insert($mediaFileLP)
|
||||||
{
|
{
|
||||||
if($this->exists) return FALSE;
|
if ($this->exists) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
// for files downloaded from archive:
|
// for files downloaded from archive:
|
||||||
if($mediaFileLP == $this->fname){
|
if ($mediaFileLP == $this->fname) {
|
||||||
$this->exists = TRUE;
|
$this->exists = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
umask(0002);
|
umask(0002);
|
||||||
if(@copy($mediaFileLP, $this->fname)){
|
if (@copy($mediaFileLP, $this->fname)) {
|
||||||
$this->exists = TRUE;
|
$this->exists = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}else{
|
} else {
|
||||||
//@unlink($this->fname); // maybe useless
|
//@unlink($this->fname); // maybe useless
|
||||||
$this->exists = FALSE;
|
$this->exists = FALSE;
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"RawMediaData::insert: file save failed".
|
"RawMediaData::insert: file save failed".
|
||||||
" ($mediaFileLP, {$this->fname})",GBERR_FILEIO
|
" ($mediaFileLP, {$this->fname})",GBERR_FILEIO
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete and insert media file
|
* Delete and insert media file
|
||||||
*
|
*
|
||||||
* @param mediaFileLP string, local path
|
* @param string $mediaFileLP, local path
|
||||||
* @return true or PEAR::error
|
* @return mixed
|
||||||
|
* true or PEAR::error
|
||||||
*/
|
*/
|
||||||
function replace($mediaFileLP)
|
function replace($mediaFileLP)
|
||||||
{
|
{
|
||||||
if($this->exists){ $r = $this->delete(); }
|
if ($this->exists) {
|
||||||
else{ $r = NULL; }
|
$r = $this->delete();
|
||||||
if(PEAR::isError($r)) return $r;
|
} else {
|
||||||
|
$r = NULL;
|
||||||
|
}
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $this->insert($mediaFileLP);
|
return $this->insert($mediaFileLP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if file corresponding to the object exists
|
* Return true if file corresponding to the object exists
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function exists()
|
function exists()
|
||||||
{
|
{
|
||||||
return $this->exists;
|
return $this->exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return filename
|
* Return filename
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getFname()
|
function getFname()
|
||||||
{
|
{
|
||||||
return $this->fname;
|
return $this->fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete media file from filesystem
|
* Delete media file from filesystem
|
||||||
*
|
*
|
||||||
* @return boolean or PEAR::error
|
* @return mixed
|
||||||
|
* boolean or PEAR::error
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
if(!$this->exists) return FALSE;
|
if (!$this->exists) {
|
||||||
if(@unlink($this->fname)){
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (@unlink($this->fname)) {
|
||||||
$this->exists = FALSE;
|
$this->exists = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}else{
|
} else {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"RawMediaData::delete: unlink failed ({$this->fname})",
|
"RawMediaData::delete: unlink failed ({$this->fname})",
|
||||||
GBERR_FILEIO
|
GBERR_FILEIO
|
||||||
|
@ -139,14 +132,18 @@ class RawMediaData{
|
||||||
return $this->exists;
|
return $this->exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyze media file with getid3 module
|
* Analyze media file with getid3 module
|
||||||
*
|
*
|
||||||
* @return hierarchical hasharray with information about media file
|
* @return array
|
||||||
|
* hierarchical hasharray with information about media file
|
||||||
*/
|
*/
|
||||||
function analyze()
|
function analyze()
|
||||||
{
|
{
|
||||||
if(!$this->exists) return FALSE;
|
if (!$this->exists) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
//$ia = @GetAllFileinfo($this->fname, 'mp3');
|
//$ia = @GetAllFileinfo($this->fname, 'mp3');
|
||||||
//prepared for getid3 upgrade:
|
//prepared for getid3 upgrade:
|
||||||
$getID3 = new getID3;
|
$getID3 = new getID3;
|
||||||
|
@ -154,70 +151,90 @@ class RawMediaData{
|
||||||
return $ia;
|
return $ia;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mime-type returned by getid3 module
|
* Get mime-type returned by getid3 module
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getMime()
|
function getMime()
|
||||||
{
|
{
|
||||||
$a = $this->analyze();
|
$a = $this->analyze();
|
||||||
if($a === FALSE) return $a;
|
if ($a === FALSE) {
|
||||||
if(isset($a['mime_type'])) return $a['mime_type'];
|
return $a;
|
||||||
|
}
|
||||||
|
if (isset($a['mime_type'])) {
|
||||||
|
return $a['mime_type'];
|
||||||
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contruct filepath of media file
|
* Contruct filepath of media file
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function makeFname()
|
function makeFname()
|
||||||
{
|
{
|
||||||
return "{$this->resDir}/{$this->gunid}";
|
return "{$this->resDir}/{$this->gunid}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method
|
* Test method
|
||||||
*
|
*
|
||||||
* @param testFname1 string
|
* @param string $testFname1
|
||||||
* @param testFname2 string
|
* @param string $testFname2
|
||||||
* @param accLinkFname string
|
* @param string $accLinkFname
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function test($testFname1, $testFname2, $accLinkFname)
|
function test($testFname1, $testFname2, $accLinkFname)
|
||||||
{
|
{
|
||||||
$log = '';
|
$log = '';
|
||||||
if($this->exists())
|
if ($this->exists()) {
|
||||||
$log .= "---: exists: YES\n";
|
$log .= "---: exists: YES\n";
|
||||||
else
|
} else {
|
||||||
$log .= "---: exists: NO\n";
|
$log .= "---: exists: NO\n";
|
||||||
if(!($r = $this->delete()))
|
}
|
||||||
|
if (!($r = $this->delete())) {
|
||||||
$log .= "---: delete: nothing to delete\n";
|
$log .= "---: delete: nothing to delete\n";
|
||||||
if(PEAR::isError($r))
|
}
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
$log .= "ERR: ".$r->getMessage()."\n";
|
$log .= "ERR: ".$r->getMessage()."\n";
|
||||||
if($r = $this->insert($testFname1))
|
}
|
||||||
|
if ($r = $this->insert($testFname1)) {
|
||||||
$log .= "---: insert: already exists\n";
|
$log .= "---: insert: already exists\n";
|
||||||
if(PEAR::isError($r))
|
}
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
$log .= "ERR: ".$r->getMessage()."\n";
|
$log .= "ERR: ".$r->getMessage()."\n";
|
||||||
if($r = $this->replace($testFname2))
|
}
|
||||||
|
if ($r = $this->replace($testFname2)) {
|
||||||
$log .= "---: replace: already exists\n";
|
$log .= "---: replace: already exists\n";
|
||||||
if(PEAR::isError($r))
|
}
|
||||||
|
if (PEAR::isError($r)) {
|
||||||
$log .= "ERR: ".$r->getMessage()."\n";
|
$log .= "ERR: ".$r->getMessage()."\n";
|
||||||
if($this->exists())
|
}
|
||||||
|
if ($this->exists()) {
|
||||||
$log .= "---: exists: YES\n";
|
$log .= "---: exists: YES\n";
|
||||||
else
|
} else {
|
||||||
$log .= "---: exists: NO\n";
|
$log .= "---: exists: NO\n";
|
||||||
if(!$this->access($accLinkFname))
|
}
|
||||||
|
if (!$this->access($accLinkFname)) {
|
||||||
$log .= "---: access: not exists\n";
|
$log .= "---: access: not exists\n";
|
||||||
if(($ft = filetype($accLinkFname)) == 'link'){
|
}
|
||||||
if(($rl = readlink($accLinkFname)) != $this->fname)
|
if (($ft = filetype($accLinkFname)) == 'link') {
|
||||||
|
if (($rl = readlink($accLinkFname)) != $this->fname) {
|
||||||
$log .= "ERR: wrong target ($rl)\n";
|
$log .= "ERR: wrong target ($rl)\n";
|
||||||
}else
|
}
|
||||||
|
} else {
|
||||||
$log .= "ERR: wrong file type ($ft)\n";
|
$log .= "ERR: wrong file type ($ft)\n";
|
||||||
if(!$this->release($accLinkFname))
|
}
|
||||||
|
if (!$this->release($accLinkFname)) {
|
||||||
$log .= "---: access: not exists\n";
|
$log .= "---: access: not exists\n";
|
||||||
|
}
|
||||||
return $log;
|
return $log;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
?>
|
} // class RawMediaData
|
||||||
|
?>
|
|
@ -1,67 +1,46 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomash $
|
|
||||||
Version : $Revision: 1949 $
|
|
||||||
Location : $URL: svn+ssh://tomash@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/storageServer/var/BasicStor.php $
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
define('RENDER_EXT', 'ogg');
|
define('RENDER_EXT', 'ogg');
|
||||||
|
|
||||||
require_once "LsPlaylist.php";
|
require_once "LsPlaylist.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer caller class
|
* Renderer caller class
|
||||||
*
|
*
|
||||||
* Playlist to file rendering - PHP layer, caller to the renderer executable
|
* Playlist to file rendering - PHP layer, caller to the renderer executable
|
||||||
*
|
*
|
||||||
* @author $Author: tomash $
|
* @author $Author: tomash $
|
||||||
* @version $Revision: 1949 $
|
* @version $Revision: 1949 $
|
||||||
* @see LocStor
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see LocStor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Renderer
|
class Renderer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render playlist to ogg file (open handle)
|
* Render playlist to ogg file (open handle)
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param plid : string - playlist gunid
|
* greenbox object reference
|
||||||
* @param owner: int - local subject id, owner of token
|
* @param string $plid
|
||||||
* @return hasharray:
|
* playlist gunid
|
||||||
|
* @param int $owner
|
||||||
|
* local subject id, owner of token
|
||||||
|
* @return array
|
||||||
* token: string - render token
|
* token: string - render token
|
||||||
*/
|
*/
|
||||||
function rnRender2FileOpen(&$gb, $plid, $owner=NULL)
|
function rnRender2FileOpen(&$gb, $plid, $owner=NULL)
|
||||||
{
|
{
|
||||||
// recall playlist:
|
// recall playlist:
|
||||||
$pl = $r = LsPlaylist::recallByGunid($gb, $plid);
|
$pl = $r = LsPlaylist::recallByGunid($gb, $plid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
// smil export:
|
// smil export:
|
||||||
$smil = $r = $pl->output2Smil();
|
$smil = $r = $pl->output2Smil();
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
// temporary file for smil:
|
// temporary file for smil:
|
||||||
$tmpn = tempnam($gb->bufferDir, 'plRender_');
|
$tmpn = tempnam($gb->bufferDir, 'plRender_');
|
||||||
$smilf = "$tmpn.smil";
|
$smilf = "$tmpn.smil";
|
||||||
|
@ -75,7 +54,9 @@ class Renderer
|
||||||
file_put_contents($logf, "--- ".date("Ymd-H:i:s")."\n", FILE_APPEND);
|
file_put_contents($logf, "--- ".date("Ymd-H:i:s")."\n", FILE_APPEND);
|
||||||
// open access to output file: /*gunid*/ /*parent*/
|
// open access to output file: /*gunid*/ /*parent*/
|
||||||
$acc = $gb->bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
|
$acc = $gb->bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
|
||||||
if($gb->dbc->isError($acc)){ return $acc; }
|
if ($gb->dbc->isError($acc)) {
|
||||||
|
return $acc;
|
||||||
|
}
|
||||||
extract($acc);
|
extract($acc);
|
||||||
$statf = Renderer::getStatusFile($gb, $token);
|
$statf = Renderer::getStatusFile($gb, $token);
|
||||||
file_put_contents($statf, "working");
|
file_put_contents($statf, "working");
|
||||||
|
@ -85,7 +66,7 @@ class Renderer
|
||||||
$command = "$renderExe -p $url -o $outf -s $statf >> $logf &";
|
$command = "$renderExe -p $url -o $outf -s $statf >> $logf &";
|
||||||
file_put_contents($logf, "$command\n", FILE_APPEND);
|
file_put_contents($logf, "$command\n", FILE_APPEND);
|
||||||
$res = system($command);
|
$res = system($command);
|
||||||
if($res === FALSE){
|
if ($res === FALSE) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'Renderer::rnRender2File: Error running renderer'
|
'Renderer::rnRender2File: Error running renderer'
|
||||||
);
|
);
|
||||||
|
@ -93,19 +74,22 @@ class Renderer
|
||||||
return array('token'=>$token);
|
return array('token'=>$token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render playlist to ogg file (check results)
|
* Render playlist to ogg file (check results)
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param token : string - render token
|
* GreenBox object reference
|
||||||
* @return hasharray:
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return array
|
||||||
* status : string - success | working | fault
|
* status : string - success | working | fault
|
||||||
* url : string - readable url
|
* url : string - readable url
|
||||||
*/
|
*/
|
||||||
function rnRender2FileCheck(&$gb, $token)
|
function rnRender2FileCheck(&$gb, $token)
|
||||||
{
|
{
|
||||||
$statf = Renderer::getStatusFile($gb, $token);
|
$statf = Renderer::getStatusFile($gb, $token);
|
||||||
if(!file_exists($statf)){
|
if (!file_exists($statf)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'Renderer::rnRender2FileCheck: Invalid token'
|
'Renderer::rnRender2FileCheck: Invalid token'
|
||||||
);
|
);
|
||||||
|
@ -116,13 +100,16 @@ class Renderer
|
||||||
return array('status'=>$status, 'url'=>$url, 'tmpfile'=>$tmpfile);
|
return array('status'=>$status, 'url'=>$url, 'tmpfile'=>$tmpfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render playlist to ogg file (list results)
|
* Render playlist to ogg file (list results)
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param stat : status (optional)
|
* greenbox object reference
|
||||||
* if this parameter is not set, then return with all unclosed backups
|
* @param string $stat
|
||||||
* @return array of hasharray:
|
* status (optional) if this parameter is not set, then return with all unclosed backups
|
||||||
|
* @return array
|
||||||
|
* array of hasharray:
|
||||||
* status : string - success | working | fault
|
* status : string - success | working | fault
|
||||||
* url : string - readable url
|
* url : string - readable url
|
||||||
*/
|
*/
|
||||||
|
@ -131,24 +118,30 @@ class Renderer
|
||||||
$tokens = $gb->getTokensByType('render');
|
$tokens = $gb->getTokensByType('render');
|
||||||
foreach ($tokens as $token) {
|
foreach ($tokens as $token) {
|
||||||
$st = Renderer::rnRender2FileCheck($gb, $token);
|
$st = Renderer::rnRender2FileCheck($gb, $token);
|
||||||
if ($stat=='' || $st['status']==$stat) {
|
if ( ($stat=='') || ($st['status']==$stat) ) {
|
||||||
$r[] = $st;
|
$r[] = $st;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render playlist to ogg file (close handle)
|
* Render playlist to ogg file (close handle)
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param token : string - render token
|
* greenbox object reference
|
||||||
* @return status : boolean
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return mixed
|
||||||
|
* TRUE or PEAR_Error
|
||||||
*/
|
*/
|
||||||
function rnRender2FileClose(&$gb, $token)
|
function rnRender2FileClose(&$gb, $token)
|
||||||
{
|
{
|
||||||
$r = $gb->bsRelease($token, 'render');
|
$r = $gb->bsRelease($token, 'render');
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$realOgg = $r['realFname'];
|
$realOgg = $r['realFname'];
|
||||||
$tmpn = "{$gb->bufferDir}/".basename($realOgg, '.'.RENDER_EXT);
|
$tmpn = "{$gb->bufferDir}/".basename($realOgg, '.'.RENDER_EXT);
|
||||||
$smilf = "$tmpn.smil";
|
$smilf = "$tmpn.smil";
|
||||||
|
@ -160,28 +153,35 @@ class Renderer
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render playlist to storage as audioClip (check results)
|
* Render playlist to storage as audioClip (check results)
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param token: string - render token
|
* greenbox object reference
|
||||||
* @return hasharray:
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return array
|
||||||
* status : string - success | working | fault
|
* status : string - success | working | fault
|
||||||
* gunid: string - global unique id of result file
|
* gunid: string - global unique id of result file
|
||||||
*/
|
*/
|
||||||
function rnRender2StorageCheck(&$gb, $token)
|
function rnRender2StorageCheck(&$gb, $token)
|
||||||
{
|
{
|
||||||
$r = Renderer::rnRender2FileCheck($gb, $token);
|
$r = Renderer::rnRender2FileCheck($gb, $token);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$status = $r['status'];
|
$status = $r['status'];
|
||||||
$res = array('status' => $status, 'gunid'=>'NULL');
|
$res = array('status' => $status, 'gunid'=>'NULL');
|
||||||
switch($status){
|
switch ($status) {
|
||||||
case"fault":
|
case "fault":
|
||||||
$res['faultString'] = "Error runing renderer";
|
$res['faultString'] = "Error runing renderer";
|
||||||
break;
|
break;
|
||||||
case"success":
|
case "success":
|
||||||
$r = Renderer::rnRender2StorageCore($gb, $token);
|
$r = Renderer::rnRender2StorageCore($gb, $token);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$res['gunid'] = $r['gunid'];
|
$res['gunid'] = $r['gunid'];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -190,33 +190,44 @@ class Renderer
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render playlist to storage as audioClip (core method)
|
* Render playlist to storage as audioClip (core method)
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param token: string - render token
|
* greenbox object reference
|
||||||
* @return hasharray:
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return array:
|
||||||
* gunid: string - global unique id of result file
|
* gunid: string - global unique id of result file
|
||||||
*/
|
*/
|
||||||
function rnRender2StorageCore(&$gb, $token)
|
function rnRender2StorageCore(&$gb, $token)
|
||||||
{
|
{
|
||||||
$r = $gb->bsRelease($token, 'render');
|
$r = $gb->bsRelease($token, 'render');
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$realOgg = $r['realFname'];
|
$realOgg = $r['realFname'];
|
||||||
$owner = $r['owner'];
|
$owner = $r['owner'];
|
||||||
$gunid = $r['gunid'];
|
$gunid = $r['gunid'];
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$parid = $r = $gb->_getHomeDirId($owner);
|
$parid = $r = $gb->_getHomeDirId($owner);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) return $r;
|
||||||
$fileName = 'rendered_playlist';
|
$fileName = 'rendered_playlist';
|
||||||
$id = $r = $gb->_idFromGunid($gunid);
|
$id = $r = $gb->_idFromGunid($gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$mdata = '';
|
$mdata = '';
|
||||||
foreach(array(
|
foreach (array(
|
||||||
'dc:title', 'dcterms:extent', 'dc:creator', 'dc:description'
|
'dc:title', 'dcterms:extent', 'dc:creator', 'dc:description'
|
||||||
) as $item){
|
) as $item) {
|
||||||
$md = $r = $gb->bsGetMetadataValue($id, $item);
|
$md = $r = $gb->bsGetMetadataValue($id, $item);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$val = ( isset($md[0]) ? ( isset($md[0]['value']) ? $md[0]['value'] : '') : '');
|
$val = ( isset($md[0]) ? ( isset($md[0]['value']) ? $md[0]['value'] : '') : '');
|
||||||
$mdata .= " <$item>$val</$item>\n";
|
$mdata .= " <$item>$val</$item>\n";
|
||||||
}
|
}
|
||||||
|
@ -224,18 +235,25 @@ class Renderer
|
||||||
//$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
|
//$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
|
||||||
$id = $r = $gb->bsPutFile($parid, $fileName, $realOgg, $mdata,
|
$id = $r = $gb->bsPutFile($parid, $fileName, $realOgg, $mdata,
|
||||||
NULL, 'audioclip', 'string');
|
NULL, 'audioclip', 'string');
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$ac = $r = StoredFile::recall($gb, $id);
|
$ac = $r = StoredFile::recall($gb, $id);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return array('gunid' => $ac->gunid);
|
return array('gunid' => $ac->gunid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return local filepath of rendered file
|
* Return local filepath of rendered file
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param Greenbox $gb
|
||||||
* @param token: string - render token
|
* greenbox object reference
|
||||||
* @return hasharray:
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getLocalFile(&$gb, $token)
|
function getLocalFile(&$gb, $token)
|
||||||
{
|
{
|
||||||
|
@ -243,30 +261,37 @@ class Renderer
|
||||||
return "{$gb->accessDir}/$token.".RENDER_EXT;
|
return "{$gb->accessDir}/$token.".RENDER_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return filepath of render status file
|
* Return filepath of render status file
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param token: string - render token
|
* greenbox object reference
|
||||||
* @return hasharray:
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getStatusFile(&$gb, $token)
|
function getStatusFile(&$gb, $token)
|
||||||
{
|
{
|
||||||
return Renderer::getLocalFile($gb, $token).".status";
|
return Renderer::getLocalFile($gb, $token).".status";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return remote accessible URL for rendered file
|
* Return remote accessible URL for rendered file
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
* @param token: string - render token
|
* greenbox object reference
|
||||||
* @return hasharray:
|
* @param string $token
|
||||||
|
* render token
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getUrl(&$gb, $token)
|
function getUrl(&$gb, $token)
|
||||||
{
|
{
|
||||||
$token = StoredFile::_normalizeGunid($token);
|
$token = StoredFile::_normalizeGunid($token);
|
||||||
return $gb->getUrlPart()."access/$token.".RENDER_EXT;
|
return $gb->getUrlPart()."access/$token.".RENDER_EXT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // class Renderer
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,6 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
define('ACCESS_TYPE', 'restore');
|
define('ACCESS_TYPE', 'restore');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author $Author: $
|
||||||
|
* @version $Revision: $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
*/
|
||||||
class Restore {
|
class Restore {
|
||||||
/**
|
/**
|
||||||
* string - name of logfile
|
* string - name of logfile
|
||||||
|
@ -23,69 +29,75 @@ class Restore {
|
||||||
/**
|
/**
|
||||||
* string - name of temporary directory, to here extract the backup tarball
|
* string - name of temporary directory, to here extract the backup tarball
|
||||||
*/
|
*/
|
||||||
var $tmpDir;
|
var $tmpDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string - loglevel
|
* string - loglevel
|
||||||
*/
|
*/
|
||||||
var $loglevel = 'warn';
|
var $loglevel = 'warn';
|
||||||
#var $loglevel = 'debug';
|
#var $loglevel = 'debug';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* greenbox object reference
|
* greenbox object reference
|
||||||
*/
|
*/
|
||||||
var $gb;
|
var $gb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param gb: greenbox object reference
|
* @param GreenBox $gb
|
||||||
|
* greenbox object reference
|
||||||
*/
|
*/
|
||||||
function Restore (&$gb) {
|
function Restore (&$gb) {
|
||||||
$this->gb =& $gb;
|
$this->gb =& $gb;
|
||||||
$this->token = null;
|
$this->token = null;
|
||||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel == 'debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call asyncronly the restore procedure
|
* Call asyncronously the restore procedure. Restore from backup.
|
||||||
* Restore from backup.
|
|
||||||
*
|
*
|
||||||
* @param sessid : string - session id
|
* @param string $sessid
|
||||||
* @param backup_file : path of the backup file
|
* session id
|
||||||
* @return hasharray with field:
|
* @param string $backup_file
|
||||||
|
* path of the backup file
|
||||||
|
* @return array
|
||||||
|
* hasharray with field:
|
||||||
* token string: backup token
|
* token string: backup token
|
||||||
*/
|
*/
|
||||||
function openRestore($sessid,$backup_file) {
|
function openRestore($sessid, $backup_file) {
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
$this->addLogItem("-I-".date("Ymd-H:i:s")." doRestore - sessid:$sessid\n");
|
$this->addLogItem("-I-".date("Ymd-H:i:s")." doRestore - sessid:$sessid\n");
|
||||||
}
|
}
|
||||||
$this->sessid = $sessid;
|
$this->sessid = $sessid;
|
||||||
|
|
||||||
//generate token
|
//generate token
|
||||||
$this->token = StoredFile::_createGunid();
|
$this->token = StoredFile::_createGunid();
|
||||||
|
|
||||||
// status file -> working
|
// status file -> working
|
||||||
$this->setEnviroment();
|
$this->setEnviroment();
|
||||||
file_put_contents($this->statusFile, 'working');
|
file_put_contents($this->statusFile, 'working');
|
||||||
|
|
||||||
//call the restore script in background
|
//call the restore script in background
|
||||||
$command = dirname(__FILE__).'/../bin/restore.php';
|
$command = dirname(__FILE__).'/../bin/restore.php';
|
||||||
$runLog = "/dev/null";
|
$runLog = "/dev/null";
|
||||||
$params = "{$backup_file} {$this->statusFile} {$this->token} {$sessid}>> $runLog &";
|
$params = "{$backup_file} {$this->statusFile} {$this->token} {$sessid}>> $runLog &";
|
||||||
system("$command $params");
|
system("$command $params");
|
||||||
|
|
||||||
return array('token'=>$this->token);
|
return array('token'=>$this->token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check the status of restore
|
* Check the status of restore
|
||||||
*
|
*
|
||||||
* @param token : token
|
* @param string $token
|
||||||
* @return hasharray with field:
|
* @return array
|
||||||
|
* hasharray with field:
|
||||||
* status : string - susccess | working | fault
|
* status : string - susccess | working | fault
|
||||||
* faultString : string - description of fault
|
* faultString : string - description of fault
|
||||||
* token : stirng - backup token
|
* token : stirng - backup token
|
||||||
|
@ -93,30 +105,34 @@ class Restore {
|
||||||
* tmpfile : string - access filename
|
* tmpfile : string - access filename
|
||||||
*/
|
*/
|
||||||
function checkRestore($token) {
|
function checkRestore($token) {
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel == 'debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||||
}
|
}
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
$this->setEnviroment();
|
$this->setEnviroment();
|
||||||
if (is_file($this->statusFile)) {
|
if (is_file($this->statusFile)) {
|
||||||
$stat = file_get_contents($this->statusFile);
|
$stat = file_get_contents($this->statusFile);
|
||||||
if (strpos($stat,'fault|')!==false) {
|
if (strpos($stat,'fault|') !== false) {
|
||||||
list($stat,$message) = explode('|',$stat);
|
list($stat,$message) = explode('|',$stat);
|
||||||
}
|
}
|
||||||
$r['status'] = $stat;
|
$r['status'] = $stat;
|
||||||
if ($stat=='fault') $r['faultString'] = $message;
|
if ($stat=='fault') {
|
||||||
$r['token'] = $token;
|
$r['faultString'] = $message;
|
||||||
|
}
|
||||||
|
$r['token'] = $token;
|
||||||
return $r;
|
return $r;
|
||||||
} else {
|
} else {
|
||||||
return PEAR::raiseError('Restore::checkRestore: invalid token!');
|
return PEAR::raiseError('Restore::checkRestore: invalid token!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check the status of restore
|
* Check the status of restore.
|
||||||
*
|
*
|
||||||
* @param token : token
|
* @param string $token
|
||||||
* @return hasharray with field:
|
* @return array
|
||||||
|
* hasharray with field:
|
||||||
* status : boolean - is susccess
|
* status : boolean - is susccess
|
||||||
*/
|
*/
|
||||||
function closeRestore($token) {
|
function closeRestore($token) {
|
||||||
|
@ -129,31 +145,35 @@ class Restore {
|
||||||
unlink($this->statusFile);
|
unlink($this->statusFile);
|
||||||
return !is_file($this->statusFile);
|
return !is_file($this->statusFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do restore in background
|
* Do restore in background
|
||||||
*
|
*
|
||||||
* this function is called from the asyncron commandline script
|
* this function is called from the asyncron commandline script
|
||||||
* ../bin/restore.php
|
* ../bin/restore.php
|
||||||
*
|
*
|
||||||
* @param backupfile : string - path of backupfile
|
* @param string $backupfile
|
||||||
* @param token : string - restore token
|
* path of backupfile
|
||||||
* @param sessid : string - session id
|
* @param string $token
|
||||||
|
* restore token
|
||||||
|
* @param string $sessid
|
||||||
|
* session id
|
||||||
*/
|
*/
|
||||||
function startRestore($backupfile,$token,$sessid) {
|
function startRestore($backupfile, $token, $sessid) {
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n");
|
||||||
}
|
}
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
$this->sessid = $sessid;
|
$this->sessid = $sessid;
|
||||||
$this->setEnviroment();
|
$this->setEnviroment();
|
||||||
|
|
||||||
// extract tarball
|
// extract tarball
|
||||||
$command = 'tar -xf '.$backupfile.' --directory '.$this->tmpDir;
|
$command = 'tar -xf '.$backupfile.' --directory '.$this->tmpDir;
|
||||||
$res = system($command);
|
$res = system($command);
|
||||||
#$this->addLogItem('command: '.$command."\n");
|
#$this->addLogItem('command: '.$command."\n");
|
||||||
#$this->addLogItem('res: '.$res."\n");
|
#$this->addLogItem('res: '.$res."\n");
|
||||||
|
|
||||||
//simple check of archive format
|
//simple check of archive format
|
||||||
if (is_dir($this->tmpDir.'audioClip/') &&
|
if (is_dir($this->tmpDir.'audioClip/') &&
|
||||||
is_dir($this->tmpDir.'meta-inf/') &&
|
is_dir($this->tmpDir.'meta-inf/') &&
|
||||||
|
@ -164,7 +184,7 @@ class Restore {
|
||||||
//add to storage server
|
//add to storage server
|
||||||
foreach ($this->metafiles as $info) {
|
foreach ($this->metafiles as $info) {
|
||||||
$r = $this->addFileToStorage($info['file'],$info['type'],$info['id']);
|
$r = $this->addFileToStorage($info['file'],$info['type'],$info['id']);
|
||||||
if(PEAR::isError($r)){
|
if (PEAR::isError($r)) {
|
||||||
$this->addLogItem("-E- ".date("Ymd-H:i:s").
|
$this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||||
" startRestore - addFileToStorage \n".
|
" startRestore - addFileToStorage \n".
|
||||||
"(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
"(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
||||||
|
@ -180,11 +200,13 @@ class Restore {
|
||||||
}
|
}
|
||||||
file_put_contents($this->statusFile, 'success');
|
file_put_contents($this->statusFile, 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the metafiles
|
* Get the metafiles.
|
||||||
*
|
*
|
||||||
* @return array of hasharray with field:
|
* @return array
|
||||||
|
* array of hasharray with field:
|
||||||
* file : string - metafile path
|
* file : string - metafile path
|
||||||
* type : stirng - audioClip | playlist
|
* type : stirng - audioClip | playlist
|
||||||
* id : string - the backuped gunid
|
* id : string - the backuped gunid
|
||||||
|
@ -195,29 +217,34 @@ class Restore {
|
||||||
}
|
}
|
||||||
$audioclips = scandir($this->tmpDir.'audioClip/');
|
$audioclips = scandir($this->tmpDir.'audioClip/');
|
||||||
$playlists = scandir($this->tmpDir.'playlist/');
|
$playlists = scandir($this->tmpDir.'playlist/');
|
||||||
for ($i=0;$i<count($audioclips);$i++) {
|
for ($i = 0; $i < count($audioclips); $i++) {
|
||||||
if (strpos($audioclips[$i],'xml')!==false)
|
if (strpos($audioclips[$i],'xml')!==false)
|
||||||
$r[]=array ( 'file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
|
$r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
|
||||||
'type' => 'audioClip',
|
'type' => 'audioClip',
|
||||||
'id' => str_replace('.xml','',$audioclips[$i]));
|
'id' => str_replace('.xml','',$audioclips[$i]));
|
||||||
}
|
}
|
||||||
for ($i=0;$i<count($playlists);$i++) {
|
for ($i = 0; $i < count($playlists); $i++) {
|
||||||
if (strpos($playlists[$i],'xml')!==false)
|
if (strpos($playlists[$i],'xml') !== false)
|
||||||
$r[]=array ( 'file' => $this->tmpDir.'playlist/'.$playlists[$i],
|
$r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i],
|
||||||
'type' => 'playlist',
|
'type' => 'playlist',
|
||||||
'id' => str_replace('.xml','',$playlists[$i]));
|
'id' => str_replace('.xml','',$playlists[$i]));
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the file to the storage server
|
* Add the file to the storage server.
|
||||||
*
|
*
|
||||||
* @param file : string - path of metafile
|
* @param string $file
|
||||||
* @param type : string - restore token
|
* path of metafile
|
||||||
* @param sessid : string - session id
|
* @param string $type
|
||||||
*
|
* restore token
|
||||||
* @return true if succes or PEAR error
|
* @param string $sessid
|
||||||
|
* session id
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* true if success or PEAR_error
|
||||||
*/
|
*/
|
||||||
function addFileToStorage($file,$type,$gunid) {
|
function addFileToStorage($file,$type,$gunid) {
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
|
@ -256,8 +283,12 @@ class Restore {
|
||||||
$parid = $this->gb->_getHomeDirIdFromSess($this->sessid);
|
$parid = $this->gb->_getHomeDirIdFromSess($this->sessid);
|
||||||
#$this->addLogItem("Parid:$parid\n");
|
#$this->addLogItem("Parid:$parid\n");
|
||||||
$name = $tree->children[0]->children[0]->content;
|
$name = $tree->children[0]->children[0]->content;
|
||||||
if(empty($name)) $name = $tree->attrs['title']->val;
|
if (empty($name)) {
|
||||||
if(empty($name)) $name = '???';
|
$name = $tree->attrs['title']->val;
|
||||||
|
}
|
||||||
|
if (empty($name)) {
|
||||||
|
$name = '???';
|
||||||
|
}
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
|
||||||
"$parid, $name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
|
"$parid, $name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
|
||||||
|
@ -285,84 +316,99 @@ class Restore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ac = $r = StoredFile::recallByGunid($this->gb, $gunid);
|
$ac = $r = StoredFile::recallByGunid($this->gb, $gunid);
|
||||||
if (PEAR::isError($r)) { return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$res = $r = $ac->setState('ready');
|
$res = $r = $ac->setState('ready');
|
||||||
if (PEAR::isError($r)) { return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figure out the enviroment to the backup
|
* Figure out the environment to the backup.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function setEnviroment() {
|
function setEnviroment() {
|
||||||
if ($this->loglevel=='debug') {
|
if ($this->loglevel=='debug') {
|
||||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n");
|
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.status';
|
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.status';
|
||||||
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
|
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
|
||||||
$this->rMkDir($this->tmpDir);
|
$this->rMkDir($this->tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a line to the logfile.
|
* Add a line to the logfile.
|
||||||
*
|
*
|
||||||
* @param item : string - the new row of log file
|
* @param string $item
|
||||||
|
* the new row of log file
|
||||||
*/
|
*/
|
||||||
function addLogItem($item) {
|
function addLogItem($item) {
|
||||||
$f = fopen ($this->logFile,'a');
|
$f = fopen ($this->logFile,'a');
|
||||||
flock($f,LOCK_SH);
|
flock($f,LOCK_SH);
|
||||||
fwrite($f,$item);
|
fwrite($f,$item);
|
||||||
flock($f,LOCK_UN);
|
flock($f,LOCK_UN);
|
||||||
fclose($f);
|
fclose($f);
|
||||||
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
|
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a directory recursive
|
* Delete a directory recursive
|
||||||
*
|
*
|
||||||
* @param dirname : string - path of dir.
|
* @param string $dirname
|
||||||
*
|
* path of dir
|
||||||
* @return boolean : is success
|
*
|
||||||
|
* @return boolean
|
||||||
|
* is success
|
||||||
*/
|
*/
|
||||||
function rRmDir($dirname) {
|
function rRmDir($dirname) {
|
||||||
if(is_dir($dirname))
|
if (is_dir($dirname)) {
|
||||||
$dir_handle = opendir($dirname);
|
$dir_handle = opendir($dirname);
|
||||||
while($file = readdir($dir_handle)) {
|
}
|
||||||
if($file!="." && $file!="..") {
|
while ($file = readdir($dir_handle)) {
|
||||||
if(!is_dir($dirname."/".$file))
|
if ($file!="." && $file!="..") {
|
||||||
|
if (!is_dir($dirname."/".$file)) {
|
||||||
unlink ($dirname."/".$file);
|
unlink ($dirname."/".$file);
|
||||||
else
|
} else {
|
||||||
Restore::rRmDir($dirname."/".$file);
|
Restore::rRmDir($dirname."/".$file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dir_handle);
|
closedir($dir_handle);
|
||||||
rmdir($dirname);
|
rmdir($dirname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory recursive
|
* Create a directory recursive
|
||||||
*
|
*
|
||||||
* @param dirname : string - path of dir.
|
* @param string $dirname
|
||||||
* @param mode : octal - rights of dir.
|
* path of dir.
|
||||||
* @param recursive : boolean - do it recursive.
|
* @param int $mode
|
||||||
*
|
* octal - rights of dir.
|
||||||
* @return boolean
|
* @param boolean $recursive
|
||||||
|
* do it recursive.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function rMkDir($dirname,$mode=0777,$recursive=true) {
|
function rMkDir($dirname,$mode=0777,$recursive=true) {
|
||||||
if( is_null($dirname) || $dirname === "" ){
|
if (is_null($dirname) || $dirname === "" ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( is_dir($dirname) || $dirname === "/" ){
|
if (is_dir($dirname) || $dirname === "/" ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if($this->rMkDir(dirname($dirname), $mode, $recursive)) {
|
if ($this->rMkDir(dirname($dirname), $mode, $recursive)) {
|
||||||
return mkdir($dirname, $mode);
|
return mkdir($dirname, $mode);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // class Restore
|
||||||
?>
|
?>
|
|
@ -1,108 +1,113 @@
|
||||||
<?
|
<?
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomash $
|
|
||||||
Version : $Revision: 1848 $
|
|
||||||
Location : $URL: svn+ssh://tomash@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/storageServer/var/AccessRecur.php $
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
define('INDCH', ' ');
|
define('INDCH', ' ');
|
||||||
|
|
||||||
require_once "XmlParser.php";
|
require_once "XmlParser.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmilPlaylist class
|
* SmilPlaylist class
|
||||||
*
|
*
|
||||||
|
* @author $Author: tomash $
|
||||||
|
* @version $Revision: 1848 $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
*/
|
*/
|
||||||
class SmilPlaylist {
|
class SmilPlaylist {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse SMIL file or string
|
* Parse SMIL file or string
|
||||||
*
|
*
|
||||||
* @param data string, local path to SMIL file or SMIL string
|
* @param string $data
|
||||||
* @param loc string, location: 'file'|'string'
|
* local path to SMIL file or SMIL string
|
||||||
* @return array reference, parse result tree (or PEAR::error)
|
* @param string $loc
|
||||||
|
* location: 'file'|'string'
|
||||||
|
* @return array
|
||||||
|
* reference, parse result tree (or PEAR::error)
|
||||||
*/
|
*/
|
||||||
function &parse($data='', $loc='file')
|
function &parse($data='', $loc='file')
|
||||||
{
|
{
|
||||||
return XmlParser::parse($data, $loc);
|
return XmlParser::parse($data, $loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import SMIL file to storage
|
* Import SMIL file to storage
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param aPath string, absolute path part of imported file
|
* reference to GreenBox object
|
||||||
* (e.g. /home/user/livesupport)
|
* @param string $aPath
|
||||||
* @param rPath string, relative path/filename part of imported file
|
* absolute path part of imported file (e.g. /home/user/campcaster)
|
||||||
* (e.g. playlists/playlist_1.smil)
|
* @param string $rPath
|
||||||
* @param gunids hasharray, hash relation from filenames to gunids
|
* relative path/filename part of imported file
|
||||||
* @param plid string, playlist gunid
|
* (e.g. playlists/playlist_1.smil)
|
||||||
* @param parid int, destination folder local id
|
* @param array $gunids
|
||||||
* @param subjid int, local subject (user) id (id of user doing the import)
|
* hash relation from filenames to gunids
|
||||||
* @return instance of Playlist object
|
* @param string $plid
|
||||||
|
* playlist gunid
|
||||||
|
* @param int $parid
|
||||||
|
* destination folder local id
|
||||||
|
* @param int $subjid
|
||||||
|
* local subject (user) id (id of user doing the import)
|
||||||
|
* @return Playlist
|
||||||
*/
|
*/
|
||||||
function &import(&$gb, $aPath, $rPath, &$gunids, $plid, $parid, $subjid=NULL){
|
function &import(&$gb, $aPath, $rPath, &$gunids, $plid, $parid, $subjid=NULL)
|
||||||
|
{
|
||||||
$parr = compact('parid', 'subjid', 'aPath', 'plid', 'rPath');
|
$parr = compact('parid', 'subjid', 'aPath', 'plid', 'rPath');
|
||||||
$path = realpath("$aPath/$rPath");
|
$path = realpath("$aPath/$rPath");
|
||||||
if(FALSE === $path){
|
if (FALSE === $path) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"SmilPlaylist::import: file doesn't exist ($aPath/$rPath)"
|
"SmilPlaylist::import: file doesn't exist ($aPath/$rPath)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$lspl = $r = SmilPlaylist::convert2lspl(
|
$lspl = $r = SmilPlaylist::convert2lspl(
|
||||||
$gb, $path, $gunids, $parr);
|
$gb, $path, $gunids, $parr);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
require_once "Playlist.php";
|
require_once "Playlist.php";
|
||||||
$pl =& Playlist::create($gb, $plid, "imported_SMIL", $parid);
|
$pl =& Playlist::create($gb, $plid, "imported_SMIL", $parid);
|
||||||
if(PEAR::isError($pl)) return $pl;
|
if (PEAR::isError($pl)) {
|
||||||
|
return $pl;
|
||||||
|
}
|
||||||
$r = $pl->lock($gb, $subjid);
|
$r = $pl->lock($gb, $subjid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $pl->replaceMetaData($lspl, 'string', 'playlist');
|
$r = $pl->replaceMetaData($lspl, 'string', 'playlist');
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $pl->unLock($gb);
|
$r = $pl->unLock($gb);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $pl;
|
return $pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import SMIL file to storage
|
* Import SMIL file to storage
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param data string, local path to SMIL file
|
* @param string $data
|
||||||
* @param gunids hasharray, hash relation from filenames to gunids
|
* local path to SMIL file
|
||||||
* @param parr hasharray, of parid, subjid, aPath, plid, rPath
|
* @param hasharray $gunids
|
||||||
* @return XML string - playlist in Livesupport playlist format
|
* hash relation from filenames to gunids
|
||||||
|
* @param array $parr
|
||||||
|
* array of parid, subjid, aPath, plid, rPath
|
||||||
|
* @return string
|
||||||
|
* XML of playlist in Campcaster playlist format
|
||||||
*/
|
*/
|
||||||
function convert2lspl(&$gb, $data, &$gunids, $parr){
|
function convert2lspl(&$gb, $data, &$gunids, $parr)
|
||||||
|
{
|
||||||
extract($parr);
|
extract($parr);
|
||||||
$tree = $r = SmilPlaylist::parse($data);
|
$tree = $r = SmilPlaylist::parse($data);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
if($tree->name != 'smil'){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($tree->name != 'smil') {
|
||||||
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
|
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
|
||||||
}
|
}
|
||||||
if(isset($tree->children[1])){
|
if (isset($tree->children[1])) {
|
||||||
return PEAR::raiseError(sprintf(
|
return PEAR::raiseError(sprintf(
|
||||||
"SmilPlaylist::parse: unexpected tag %s in tag smil",
|
"SmilPlaylist::parse: unexpected tag %s in tag smil",
|
||||||
$tree->children[1]->name
|
$tree->children[1]->name
|
||||||
|
@ -112,19 +117,23 @@ class SmilPlaylist {
|
||||||
$gb, $tree->children[0], &$gunids, $parr);
|
$gb, $tree->children[0], &$gunids, $parr);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // SmilPlaylist
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Several auxiliary classes follows
|
* Several auxiliary classes follows
|
||||||
*/
|
*/
|
||||||
class SmilPlaylistBodyElement{
|
class SmilPlaylistBodyElement {
|
||||||
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
|
|
||||||
|
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||||
|
{
|
||||||
extract($parr);
|
extract($parr);
|
||||||
$ind2 = $ind.INDCH;
|
$ind2 = $ind.INDCH;
|
||||||
if($tree->name != 'body'){
|
if ($tree->name != 'body') {
|
||||||
return PEAR::raiseError("SmilPlaylist::parse: body tag expected");
|
return PEAR::raiseError("SmilPlaylist::parse: body tag expected");
|
||||||
}
|
}
|
||||||
if(isset($tree->children[1])){
|
if (isset($tree->children[1])) {
|
||||||
return PEAR::raiseError(sprintf(
|
return PEAR::raiseError(sprintf(
|
||||||
"SmilPlaylist::parse: unexpected tag %s in tag body",
|
"SmilPlaylist::parse: unexpected tag %s in tag body",
|
||||||
$tree->children[1]->name
|
$tree->children[1]->name
|
||||||
|
@ -132,8 +141,10 @@ class SmilPlaylistBodyElement{
|
||||||
}
|
}
|
||||||
$res = $r = SmilPlaylistParElement::convert2lspl(
|
$res = $r = SmilPlaylistParElement::convert2lspl(
|
||||||
$gb, $tree->children[0], &$gunids, $parr, $ind2);
|
$gb, $tree->children[0], &$gunids, $parr, $ind2);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
$title = basename($rPath);
|
return $r;
|
||||||
|
}
|
||||||
|
$title = basename($rPath);
|
||||||
$playlength = '0';
|
$playlength = '0';
|
||||||
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
|
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
|
||||||
"$ind<playlist id=\"$plid\" playlength=\"$playlength\" title=\"$title\">\n".
|
"$ind<playlist id=\"$plid\" playlength=\"$playlength\" title=\"$title\">\n".
|
||||||
|
@ -142,123 +153,141 @@ class SmilPlaylistBodyElement{
|
||||||
"$ind</playlist>\n";
|
"$ind</playlist>\n";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class SmilPlaylistParElement{
|
} // class SmilPlaylistBodyElement
|
||||||
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
|
|
||||||
|
|
||||||
|
class SmilPlaylistParElement {
|
||||||
|
|
||||||
|
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||||
|
{
|
||||||
extract($parr);
|
extract($parr);
|
||||||
if($tree->name != 'par'){
|
if ($tree->name != 'par') {
|
||||||
return PEAR::raiseError("SmilPlaylist::parse: par tag expected");
|
return PEAR::raiseError("SmilPlaylist::parse: par tag expected");
|
||||||
}
|
}
|
||||||
$res = '';
|
$res = '';
|
||||||
foreach($tree->children as $i=>$ch){
|
foreach ($tree->children as $i => $ch) {
|
||||||
$ch =& $tree->children[$i];
|
$ch =& $tree->children[$i];
|
||||||
$r = SmilPlaylistAudioElement::convert2lspl(
|
$r = SmilPlaylistAudioElement::convert2lspl(
|
||||||
$gb, $ch, &$gunids, $parr, $ind.INDCH);
|
$gb, $ch, &$gunids, $parr, $ind.INDCH);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$res .= $r;
|
$res .= $r;
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SmilPlaylistAudioElement{
|
class SmilPlaylistAudioElement {
|
||||||
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
|
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||||
|
{
|
||||||
extract($parr);
|
extract($parr);
|
||||||
$uri = $tree->attrs['src']->val;
|
$uri = $tree->attrs['src']->val;
|
||||||
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
|
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
|
||||||
$ind2 = $ind.INDCH;
|
$ind2 = $ind.INDCH;
|
||||||
if($tree->name != 'audio'){
|
if ($tree->name != 'audio') {
|
||||||
return PEAR::raiseError("SmilPlaylist::parse: audio tag expected");
|
return PEAR::raiseError("SmilPlaylist::parse: audio tag expected");
|
||||||
}
|
}
|
||||||
if(isset($tree->children[2])){
|
if (isset($tree->children[2])) {
|
||||||
return PEAR::raiseError(sprintf(
|
return PEAR::raiseError(sprintf(
|
||||||
"SmilPlaylist::parse: unexpected tag %s in tag audio",
|
"SmilPlaylist::parse: unexpected tag %s in tag audio",
|
||||||
$tree->children[2]->name
|
$tree->children[2]->name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$res = ''; $fadeIn = 0; $fadeOut = 0;
|
$res = ''; $fadeIn = 0; $fadeOut = 0;
|
||||||
foreach($tree->children as $i=>$ch){
|
foreach ($tree->children as $i => $ch) {
|
||||||
$ch =& $tree->children[$i];
|
$ch =& $tree->children[$i];
|
||||||
$r = SmilPlaylistAnimateElement::convert2lspl(
|
$r = SmilPlaylistAnimateElement::convert2lspl(
|
||||||
$gb, $ch, &$gunids, $parr, $ind2);
|
$gb, $ch, &$gunids, $parr, $ind2);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
switch($r['type']){
|
return $r;
|
||||||
case"fadeIn": $fadeIn = $r['val']; break;
|
}
|
||||||
case"fadeOut": $fadeOut = $r['val']; break;
|
switch ($r['type']) {
|
||||||
|
case "fadeIn": $fadeIn = $r['val']; break;
|
||||||
|
case "fadeOut": $fadeOut = $r['val']; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($fadeIn > 0 || $fadeOut > 0){
|
if ($fadeIn > 0 || $fadeOut > 0) {
|
||||||
$fiGunid = StoredFile::_createGunid();
|
$fiGunid = StoredFile::_createGunid();
|
||||||
$fadeIn = Playlist::_secsToPlTime($fadeIn);
|
$fadeIn = Playlist::_secsToPlTime($fadeIn);
|
||||||
$fadeOut = Playlist::_secsToPlTime($fadeOut);
|
$fadeOut = Playlist::_secsToPlTime($fadeOut);
|
||||||
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
|
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
|
||||||
}else $fInfo = '';
|
} else {
|
||||||
|
$fInfo = '';
|
||||||
|
}
|
||||||
$plElGunid = StoredFile::_createGunid();
|
$plElGunid = StoredFile::_createGunid();
|
||||||
$acGunid = $gunid;
|
$acGunid = $gunid;
|
||||||
$type = 'audioClip';
|
$type = 'audioClip';
|
||||||
if(preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)){
|
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
|
||||||
switch(strtolower($ext = $va[1])){
|
switch (strtolower($ext = $va[1])) {
|
||||||
case"lspl":
|
case "lspl":
|
||||||
case"xml":
|
case "xml":
|
||||||
case"smil":
|
case "smil":
|
||||||
case"m3u":
|
case "m3u":
|
||||||
$type = 'playlist';
|
$type = 'playlist';
|
||||||
$acId = $r = $gb->bsImportPlaylistRaw($parid, $gunid,
|
$acId = $r = $gb->bsImportPlaylistRaw($parid, $gunid,
|
||||||
$aPath, $uri, $ext, $gunids, $subjid);
|
$aPath, $uri, $ext, $gunids, $subjid);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
//break;
|
//break;
|
||||||
default:
|
default:
|
||||||
$ac = $r = StoredFile::recallByGunid($gb, $gunid);
|
$ac = $r = StoredFile::recallByGunid($gb, $gunid);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$r = $ac->md->getMetadataEl('dcterms:extent');
|
$r = $ac->md->getMetadataEl('dcterms:extent');
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$playlength = $r[0]['value'];
|
$playlength = $r[0]['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$title = basename($tree->attrs['src']->val);
|
||||||
|
$offset = Playlist::_secsToPlTime($tree->attrs['begin']->val);
|
||||||
$title = basename($tree->attrs['src']->val);
|
|
||||||
$offset = Playlist::_secsToPlTime($tree->attrs['begin']->val);
|
|
||||||
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\">\n".
|
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\">\n".
|
||||||
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
|
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
|
||||||
$fInfo.
|
$fInfo.
|
||||||
"$ind</playlistElement>\n";
|
"$ind</playlistElement>\n";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
} // class SmilPlaylistAudioElement
|
||||||
|
|
||||||
class SmilPlaylistAnimateElement{
|
|
||||||
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
|
class SmilPlaylistAnimateElement {
|
||||||
|
|
||||||
|
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||||
|
{
|
||||||
extract($parr);
|
extract($parr);
|
||||||
if($tree->name != 'animate'){
|
if ($tree->name != 'animate') {
|
||||||
return PEAR::raiseError("SmilPlaylist::parse: animate tag expected");
|
return PEAR::raiseError("SmilPlaylist::parse: animate tag expected");
|
||||||
}
|
}
|
||||||
if($tree->attrs['attributeName']->val == 'soundLevel' &&
|
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
|
||||||
$tree->attrs['from']->val == '0%' &&
|
$tree->attrs['from']->val == '0%' &&
|
||||||
$tree->attrs['to']->val == '100%' &&
|
$tree->attrs['to']->val == '100%' &&
|
||||||
$tree->attrs['calcMode']->val == 'linear' &&
|
$tree->attrs['calcMode']->val == 'linear' &&
|
||||||
$tree->attrs['fill']->val == 'freeze' &&
|
$tree->attrs['fill']->val == 'freeze' &&
|
||||||
$tree->attrs['begin']->val == '0s' &&
|
$tree->attrs['begin']->val == '0s' &&
|
||||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
|
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
|
||||||
){
|
) {
|
||||||
return array('type'=>'fadeIn', 'val'=>intval($va[1]));
|
return array('type'=>'fadeIn', 'val'=>intval($va[1]));
|
||||||
}
|
}
|
||||||
if($tree->attrs['attributeName']->val == 'soundLevel' &&
|
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
|
||||||
$tree->attrs['from']->val == '100%' &&
|
$tree->attrs['from']->val == '100%' &&
|
||||||
$tree->attrs['to']->val == '0%' &&
|
$tree->attrs['to']->val == '0%' &&
|
||||||
$tree->attrs['calcMode']->val == 'linear' &&
|
$tree->attrs['calcMode']->val == 'linear' &&
|
||||||
$tree->attrs['fill']->val == 'freeze' &&
|
$tree->attrs['fill']->val == 'freeze' &&
|
||||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
|
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
|
||||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
|
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
|
||||||
){
|
) {
|
||||||
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
|
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
|
||||||
}
|
}
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
|
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} // class SmilPlaylistAnimateElement
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,32 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
require_once "RawMediaData.php";
|
require_once "RawMediaData.php";
|
||||||
require_once "MetaData.php";
|
require_once "MetaData.php";
|
||||||
require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
|
require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
|
||||||
|
@ -34,40 +6,46 @@ require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
|
||||||
/**
|
/**
|
||||||
* StoredFile class
|
* StoredFile class
|
||||||
*
|
*
|
||||||
* LiveSupport file storage support class.<br>
|
* Campcaster file storage support class.<br>
|
||||||
* Represents one virtual file in storage. Virtual file has up to two parts:
|
* Represents one virtual file in storage. Virtual file has up to two parts:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>metada in database - represented by MetaData class</li>
|
* <li>metada in database - represented by MetaData class</li>
|
||||||
* <li>binary media data in real file
|
* <li>binary media data in real file
|
||||||
* - represented by RawMediaData class</li>
|
* - represented by RawMediaData class</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @see GreenBox
|
*
|
||||||
* @see MetaData
|
* @author $Author$
|
||||||
* @see RawMediaData
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see GreenBox
|
||||||
|
* @see MetaData
|
||||||
|
* @see RawMediaData
|
||||||
*/
|
*/
|
||||||
class StoredFile {
|
class StoredFile {
|
||||||
/* ========================================================== constructor */
|
/* ========================================================== constructor */
|
||||||
/**
|
/**
|
||||||
* Constructor, but shouldn't be externally called
|
* Constructor, but shouldn't be externally called
|
||||||
*
|
*
|
||||||
* @param reference $gb to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param string $gunid, optional, globally unique id of file
|
* @param string $gunid
|
||||||
|
* optional, globally unique id of file
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
function StoredFile(&$gb, $gunid=NULL)
|
function StoredFile(&$gb, $gunid=NULL)
|
||||||
{
|
{
|
||||||
$this->gb =& $gb;
|
$this->gb =& $gb;
|
||||||
$this->dbc =& $gb->dbc;
|
$this->dbc =& $gb->dbc;
|
||||||
$this->filesTable = $gb->filesTable;
|
$this->filesTable = $gb->filesTable;
|
||||||
$this->accessTable= $gb->accessTable;
|
$this->accessTable= $gb->accessTable;
|
||||||
$this->gunid = $gunid;
|
$this->gunid = $gunid;
|
||||||
if (is_null($this->gunid)) {
|
if (is_null($this->gunid)) {
|
||||||
$this->gunid = $this->_createGunid();
|
$this->gunid = $this->_createGunid();
|
||||||
}
|
}
|
||||||
$this->resDir = $this->_getResDir($this->gunid);
|
$this->resDir = $this->_getResDir($this->gunid);
|
||||||
$this->accessDir = $this->gb->accessDir;
|
$this->accessDir = $this->gb->accessDir;
|
||||||
$this->rmd =& new RawMediaData($this->gunid, $this->resDir);
|
$this->rmd =& new RawMediaData($this->gunid, $this->resDir);
|
||||||
$this->md =& new MetaData($gb, $this->gunid, $this->resDir);
|
$this->md =& new MetaData($gb, $this->gunid, $this->resDir);
|
||||||
# return $this->gunid;
|
# return $this->gunid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,16 +54,24 @@ class StoredFile {
|
||||||
/**
|
/**
|
||||||
* Create instance of StoredFile object and insert new file
|
* Create instance of StoredFile object and insert new file
|
||||||
*
|
*
|
||||||
* @param reference $gb to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param int $oid, local object id in the tree
|
* @param int $oid
|
||||||
* @param string $name, name of new file
|
* local object id in the tree
|
||||||
* @param string $mediaFileLP, local path to media file
|
* @param string $name
|
||||||
* @param string $metadata, local path to metadata XML file or XML string
|
* name of new file
|
||||||
* @param string $mdataLoc 'file'|'string' (optional)
|
* @param string $mediaFileLP
|
||||||
* @param global $gunid unique id (optional) - for insert file with gunid
|
* local path to media file
|
||||||
* @param string $ftype, internal file type
|
* @param string $metadata
|
||||||
* @param string $className, class to be constructed (opt.)
|
* local path to metadata XML file or XML string
|
||||||
* @return instance of StoredFile object
|
* @param string $mdataLoc
|
||||||
|
* 'file'|'string' (optional)
|
||||||
|
* @param global $gunid
|
||||||
|
* unique id (optional) - for insert file with gunid
|
||||||
|
* @param string $ftype
|
||||||
|
* internal file type
|
||||||
|
* @param string $className
|
||||||
|
* class to be constructed (opt.)
|
||||||
|
* @return StoredFile
|
||||||
*/
|
*/
|
||||||
function &insert(&$gb, $oid, $name,
|
function &insert(&$gb, $oid, $name,
|
||||||
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
||||||
|
@ -171,14 +157,17 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of StoreFile object and recall existing file.<br>
|
* Create instance of StoreFile object and recall existing file.<br>
|
||||||
* Should be supplied oid XOR gunid - not both ;)
|
* Should be supplied oid XOR gunid - not both ;)
|
||||||
*
|
*
|
||||||
* @param reference $gb to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param int $oid, optional, local object id in the tree
|
* @param int $oid
|
||||||
* @param string $gunid, optional, global unique id of file
|
* optional, local object id in the tree
|
||||||
* @param string $className, optional classname to recall
|
* @param string $gunid
|
||||||
* @return instance of StoredFile object
|
* optional, global unique id of file
|
||||||
|
* @param string $className
|
||||||
|
* optional classname to recall
|
||||||
|
* @return StoredFile
|
||||||
*/
|
*/
|
||||||
function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||||
{
|
{
|
||||||
|
@ -210,13 +199,15 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of StoreFile object and recall existing file
|
* Create instance of StoreFile object and recall existing file
|
||||||
* by gunid.<br/>
|
* by gunid.
|
||||||
*
|
*
|
||||||
* @param reference $gb to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param string $gunid, optional, global unique id of file
|
* @param string $gunid
|
||||||
* @param string $className, optional classname to recall
|
* optional, global unique id of file
|
||||||
* @return instance of StoredFile object
|
* @param string $className
|
||||||
|
* optional classname to recall
|
||||||
|
* @return StoredFile
|
||||||
*/
|
*/
|
||||||
function &recallByGunid(&$gb, $gunid='', $className='StoredFile')
|
function &recallByGunid(&$gb, $gunid='', $className='StoredFile')
|
||||||
{
|
{
|
||||||
|
@ -225,13 +216,15 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of StoreFile object and recall existing file
|
* Create instance of StoreFile object and recall existing file
|
||||||
* by access token.<br/>
|
* by access token.
|
||||||
*
|
*
|
||||||
* @param reference $gb to GreenBox object
|
* @param GreenBox $gb
|
||||||
* @param string $token, access token
|
* @param string $token
|
||||||
* @param string $className, optional classname to recall
|
* access token
|
||||||
* @return instance of StoredFile object
|
* @param string $className
|
||||||
|
* optional classname to recall
|
||||||
|
* @return StoredFile
|
||||||
*/
|
*/
|
||||||
function recallByToken(&$gb, $token, $className='StoredFile')
|
function recallByToken(&$gb, $token, $className='StoredFile')
|
||||||
{
|
{
|
||||||
|
@ -253,10 +246,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of StoredFile object and make copy of existing file
|
* Create instance of StoredFile object and make copy of existing file
|
||||||
*
|
*
|
||||||
* @param reference $src to source object
|
* @param reference $src to source object
|
||||||
* @param int $nid, new local id
|
* @param int $nid
|
||||||
|
* new local id
|
||||||
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function ©Of(&$src, $nid)
|
function ©Of(&$src, $nid)
|
||||||
{
|
{
|
||||||
|
@ -276,11 +271,16 @@ class StoredFile {
|
||||||
/**
|
/**
|
||||||
* Replace existing file with new data
|
* Replace existing file with new data
|
||||||
*
|
*
|
||||||
* @param int $oid, local id
|
* @param int $oid
|
||||||
* @param string $name, name of file
|
* local id
|
||||||
* @param string $mediaFileLP, local path to media file
|
* @param string $name
|
||||||
* @param string $metadata, local path to metadata XML file or XML string
|
* name of file
|
||||||
* @param string $mdataLoc 'file'|'string'
|
* @param string $mediaFileLP
|
||||||
|
* local path to media file
|
||||||
|
* @param string $metadata
|
||||||
|
* local path to metadata XML file or XML string
|
||||||
|
* @param string $mdataLoc
|
||||||
|
* 'file'|'string'
|
||||||
*/
|
*/
|
||||||
function replace($oid, $name, $mediaFileLP='', $metadata='',
|
function replace($oid, $name, $mediaFileLP='', $metadata='',
|
||||||
$mdataLoc='file')
|
$mdataLoc='file')
|
||||||
|
@ -319,16 +319,18 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increase access counter, create access token, insert access record,
|
* Increase access counter, create access token, insert access record,
|
||||||
* call access method of RawMediaData
|
* call access method of RawMediaData
|
||||||
*
|
*
|
||||||
* @param int $parent parent token
|
* @param int $parent
|
||||||
* @return array with: access URL, access token
|
* parent token
|
||||||
|
* @return array
|
||||||
|
* array with: access URL, access token
|
||||||
*/
|
*/
|
||||||
function accessRawMediaData($parent='0')
|
function accessRawMediaData($parent='0')
|
||||||
{
|
{
|
||||||
$realFname = $this->_getRealRADFname();
|
$realFname = $this->_getRealRADFname();
|
||||||
$ext = $this->_getExt();
|
$ext = $this->_getExt();
|
||||||
$res = $this->gb->bsAccess($realFname, $ext, $this->gunid, 'access', $parent);
|
$res = $this->gb->bsAccess($realFname, $ext, $this->gunid, 'access', $parent);
|
||||||
if (PEAR::isError($res)) {
|
if (PEAR::isError($res)) {
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -340,11 +342,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrease access couter, delete access record,
|
* Decrease access couter, delete access record,
|
||||||
* call release method of RawMediaData
|
* call release method of RawMediaData
|
||||||
*
|
*
|
||||||
* @param string $token, access token
|
* @param string $token
|
||||||
* @return boolean
|
* access token
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function releaseRawMediaData($token)
|
function releaseRawMediaData($token)
|
||||||
{
|
{
|
||||||
|
@ -357,9 +360,10 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace media file only with new binary file
|
* Replace media file only with new binary file
|
||||||
*
|
*
|
||||||
* @param string $mediaFileLP, local path to media file
|
* @param string $mediaFileLP
|
||||||
|
* local path to media file
|
||||||
*/
|
*/
|
||||||
function replaceRawMediaData($mediaFileLP)
|
function replaceRawMediaData($mediaFileLP)
|
||||||
{
|
{
|
||||||
|
@ -382,14 +386,17 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace metadata with new XML file
|
* Replace metadata with new XML file
|
||||||
*
|
*
|
||||||
* @param string $metadata, local path to metadata XML file or XML string
|
* @param string $metadata
|
||||||
* @param string $mdataLoc 'file'|'string'
|
* local path to metadata XML file or XML string
|
||||||
* @param string $format, metadata format for validation
|
* @param string $mdataLoc
|
||||||
|
* 'file'|'string'
|
||||||
|
* @param string $format
|
||||||
|
* metadata format for validation
|
||||||
* ('audioclip' | 'playlist' | 'webstream' | NULL)
|
* ('audioclip' | 'playlist' | 'webstream' | NULL)
|
||||||
* (NULL = no validation)
|
* (NULL = no validation)
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function replaceMetaData($metadata, $mdataLoc='file', $format=NULL)
|
function replaceMetaData($metadata, $mdataLoc='file', $format=NULL)
|
||||||
{
|
{
|
||||||
|
@ -413,10 +420,10 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get metadata as XML string
|
* Get metadata as XML string
|
||||||
*
|
*
|
||||||
* @return XML string
|
* @return XML string
|
||||||
* @see MetaData
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
function getMetaData()
|
function getMetaData()
|
||||||
{
|
{
|
||||||
|
@ -425,12 +432,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyze file with getid3 module.<br>
|
* Analyze file with getid3 module.<br>
|
||||||
* Obtain some metadata stored in media file.<br>
|
* Obtain some metadata stored in media file.<br>
|
||||||
* This method should be used for prefilling metadata input form.
|
* This method should be used for prefilling metadata input form.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @see MetaData
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
function analyzeMediaFile()
|
function analyzeMediaFile()
|
||||||
{
|
{
|
||||||
|
@ -440,10 +447,11 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename stored virtual file
|
* Rename stored virtual file
|
||||||
*
|
*
|
||||||
* @param string $newname
|
* @param string $newname
|
||||||
* @return true or PEAR::error
|
* @return mixed
|
||||||
|
* true or PEAR::error
|
||||||
*/
|
*/
|
||||||
function rename($newname)
|
function rename($newname)
|
||||||
{
|
{
|
||||||
|
@ -460,12 +468,14 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set state of virtual file
|
* Set state of virtual file
|
||||||
*
|
*
|
||||||
* @param string $state, 'empty'|'incomplete'|'ready'|'edited'
|
* @param string $state
|
||||||
* @param int $editedby, user id | 'NULL' for clear editedBy field
|
* 'empty'|'incomplete'|'ready'|'edited'
|
||||||
|
* @param int $editedby
|
||||||
|
* user id | 'NULL' for clear editedBy field
|
||||||
* (optional)
|
* (optional)
|
||||||
* @return boolean or error
|
* @return boolean or error
|
||||||
*/
|
*/
|
||||||
function setState($state, $editedby=NULL)
|
function setState($state, $editedby=NULL)
|
||||||
{
|
{
|
||||||
|
@ -484,10 +494,11 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set mime-type of virtual file
|
* Set mime-type of virtual file
|
||||||
*
|
*
|
||||||
* @param string $mime, mime-type
|
* @param string $mime
|
||||||
* @return boolean or error
|
* mime-type
|
||||||
|
* @return boolean or error
|
||||||
*/
|
*/
|
||||||
function setMime($mime)
|
function setMime($mime)
|
||||||
{
|
{
|
||||||
|
@ -504,10 +515,10 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete stored virtual file
|
* Delete stored virtual file
|
||||||
*
|
*
|
||||||
* @see RawMediaData
|
* @see RawMediaData
|
||||||
* @see MetaData
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
|
@ -550,10 +561,11 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if virtual file is accessed.<br>
|
* Returns true if virtual file is accessed.<br>
|
||||||
* Static or dynamic call is possible.
|
* Static or dynamic call is possible.
|
||||||
*
|
*
|
||||||
* @param string $gunid, optional (for static call), global unique id
|
* @param string $gunid
|
||||||
|
* optional (for static call), global unique id
|
||||||
*/
|
*/
|
||||||
function isAccessed($gunid=NULL)
|
function isAccessed($gunid=NULL)
|
||||||
{
|
{
|
||||||
|
@ -575,10 +587,11 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if virtual file is edited
|
* Returns true if virtual file is edited
|
||||||
*
|
*
|
||||||
* @param string $playlistId, playlist global unique ID
|
* @param string $playlistId
|
||||||
* @return boolean
|
* playlist global unique ID
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isEdited($playlistId=NULL)
|
function isEdited($playlistId=NULL)
|
||||||
{
|
{
|
||||||
|
@ -594,10 +607,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns id of user editing playlist
|
* Returns id of user editing playlist
|
||||||
*
|
*
|
||||||
* @param string $playlistId, playlist global unique ID
|
* @param string $playlistId
|
||||||
* @return null or int, id of user editing it
|
* playlist global unique ID
|
||||||
|
* @return null or int
|
||||||
|
* id of user editing it
|
||||||
*/
|
*/
|
||||||
function isEditedBy($playlistId=NULL)
|
function isEditedBy($playlistId=NULL)
|
||||||
{
|
{
|
||||||
|
@ -660,7 +675,7 @@ class StoredFile {
|
||||||
{
|
{
|
||||||
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
|
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
|
||||||
$initString =
|
$initString =
|
||||||
microtime().$ip.rand()."org.mdlf.livesupport";
|
microtime().$ip.rand()."org.mdlf.campcaster";
|
||||||
$hash = md5($initString);
|
$hash = md5($initString);
|
||||||
// non-negative int8
|
// non-negative int8
|
||||||
$hsd = substr($hash, 0, 1);
|
$hsd = substr($hash, 0, 1);
|
||||||
|
@ -680,11 +695,11 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get local id from global id.
|
* Get local id from global id.
|
||||||
* Static or dynamic call is possible.
|
* Static or dynamic call is possible.
|
||||||
*
|
*
|
||||||
* @param string $gunid, optional (for static call),
|
* @param string $gunid
|
||||||
* global unique id of file
|
* optional (for static call), global unique id of file
|
||||||
*/
|
*/
|
||||||
function _idFromGunid($gunid=NULL)
|
function _idFromGunid($gunid=NULL)
|
||||||
{
|
{
|
||||||
|
@ -705,10 +720,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return suitable extension.<br>
|
* Return suitable extension.
|
||||||
* <b>TODO: make it general - is any tool for it?</b>
|
|
||||||
*
|
*
|
||||||
* @return string file extension without a dot
|
* @todo make it general - is any tool for it?
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* file extension without a dot
|
||||||
*/
|
*/
|
||||||
function _getExt()
|
function _getExt()
|
||||||
{
|
{
|
||||||
|
@ -741,10 +758,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mime-type from global id
|
* Get mime-type from global id
|
||||||
*
|
*
|
||||||
* @param string $gunid, optional, global unique id of file
|
* @param string $gunid
|
||||||
* @return string, mime-type
|
* optional, global unique id of file
|
||||||
|
* @return string
|
||||||
|
* mime-type
|
||||||
*/
|
*/
|
||||||
function _getMime($gunid=NULL)
|
function _getMime($gunid=NULL)
|
||||||
{
|
{
|
||||||
|
@ -759,10 +778,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get storage-internal file state
|
* Get storage-internal file state
|
||||||
*
|
*
|
||||||
* @param string $gunid, optional, global unique id of file
|
* @param string $gunid
|
||||||
* @return string, see install()
|
* optional, global unique id of file
|
||||||
|
* @return string
|
||||||
|
* see install()
|
||||||
*/
|
*/
|
||||||
function _getState($gunid=NULL)
|
function _getState($gunid=NULL)
|
||||||
{
|
{
|
||||||
|
@ -777,10 +798,12 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mnemonic file name
|
* Get mnemonic file name
|
||||||
*
|
*
|
||||||
* @param string $gunid, optional, global unique id of file
|
* @param string $gunid
|
||||||
* @return string, see install()
|
* optional, global unique id of file
|
||||||
|
* @return string
|
||||||
|
* see install()
|
||||||
*/
|
*/
|
||||||
function _getFileName($gunid=NULL)
|
function _getFileName($gunid=NULL)
|
||||||
{
|
{
|
||||||
|
@ -795,8 +818,8 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get and optionaly create subdirectory in real filesystem for storing
|
* Get and optionaly create subdirectory in real filesystem for storing
|
||||||
* raw media data
|
* raw media data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function _getResDir()
|
function _getResDir()
|
||||||
|
@ -813,9 +836,9 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get real filename of raw media data
|
* Get real filename of raw media data
|
||||||
*
|
*
|
||||||
* @see RawMediaData
|
* @see RawMediaData
|
||||||
*/
|
*/
|
||||||
function _getRealRADFname()
|
function _getRealRADFname()
|
||||||
{
|
{
|
||||||
|
@ -824,9 +847,9 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get real filename of metadata file
|
* Get real filename of metadata file
|
||||||
*
|
*
|
||||||
* @see MetaData
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
function _getRealMDFname()
|
function _getRealMDFname()
|
||||||
{
|
{
|
||||||
|
@ -835,9 +858,9 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and return name for temporary symlink.<br>
|
* Create and return name for temporary symlink.
|
||||||
* <b>TODO: Should be more unique</b>
|
|
||||||
*
|
*
|
||||||
|
* @todo Should be more unique
|
||||||
*/
|
*/
|
||||||
function _getAccessFname($token, $ext='EXT')
|
function _getAccessFname($token, $ext='EXT')
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,38 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomash $
|
|
||||||
Version : $Revision: 1946 $
|
|
||||||
Location : $URL: svn+ssh://tomash@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/storageServer/var/Transport.php $
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
define('TR_LEAVE_CLOSED', TRUE);
|
define('TR_LEAVE_CLOSED', TRUE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auxiliary class for ransport records
|
* Auxiliary class for transport records
|
||||||
*
|
*
|
||||||
**/
|
* @author $Author: tomash $
|
||||||
|
* @version $Revision: 1946 $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
*/
|
||||||
class TransportRecord
|
class TransportRecord
|
||||||
{
|
{
|
||||||
var $dbc;
|
var $dbc;
|
||||||
|
@ -42,26 +19,30 @@ class TransportRecord
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param tr Transport object reference
|
* @param Transport $tr object reference
|
||||||
* @return TransportRecord object instance
|
* @return TransportRecord object instance
|
||||||
*/
|
*/
|
||||||
function TransportRecord(&$tr)
|
function TransportRecord(&$tr)
|
||||||
{
|
{
|
||||||
$this->tr =& $tr;
|
$this->tr =& $tr;
|
||||||
$this->gb =& $tr->gb;
|
$this->gb =& $tr->gb;
|
||||||
$this->dbc =& $tr->gb->dbc;
|
$this->dbc =& $tr->gb->dbc;
|
||||||
$this->config = $tr->gb->config;
|
$this->config = $tr->gb->config;
|
||||||
$this->transTable = $tr->gb->config['tblNamePrefix'].'trans';
|
$this->transTable = $tr->gb->config['tblNamePrefix'].'trans';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method
|
* Factory method
|
||||||
*
|
*
|
||||||
* @param tr: Transport object reference
|
* @param Transport $tr
|
||||||
* @param trtype: string transport type (see Transport::install)
|
* @param string $trtype
|
||||||
* @param direction: string - 'up' | 'down'
|
* transport type (see Transport::install)
|
||||||
* @param defaults: array - default parameters (optional, internal use)
|
* @param string $direction
|
||||||
* @return TransportRecord instance
|
* 'up' | 'down'
|
||||||
|
* @param array $defaults
|
||||||
|
* default parameters (optional, internal use)
|
||||||
|
* @return TransportRecord
|
||||||
*/
|
*/
|
||||||
function create(&$tr, $trtype, $direction='up', $defaults=array())
|
function create(&$tr, $trtype, $direction='up', $defaults=array())
|
||||||
{
|
{
|
||||||
|
@ -70,16 +51,18 @@ class TransportRecord
|
||||||
$trec->row = array_merge($defaults,
|
$trec->row = array_merge($defaults,
|
||||||
array('trtype'=>$trtype, 'direction'=>$direction));
|
array('trtype'=>$trtype, 'direction'=>$direction));
|
||||||
$trec->recalled = TRUE;
|
$trec->recalled = TRUE;
|
||||||
if(!isset($defaults['title'])){
|
if (!isset($defaults['title'])) {
|
||||||
$defaults['title'] = $r = $trec->getTitle();
|
$defaults['title'] = $r = $trec->getTitle();
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
|
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
|
||||||
$names = "id, trtok, direction, state, trtype, start, ts";
|
$names = "id, trtok, direction, state, trtype, start, ts";
|
||||||
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
|
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
|
||||||
foreach($defaults as $k=>$v){
|
foreach ($defaults as $k=>$v) {
|
||||||
$sqlVal = $trec->_getSqlVal($k, $v);
|
$sqlVal = $trec->_getSqlVal($k, $v);
|
||||||
$names .= ", $k";
|
$names .= ", $k";
|
||||||
$values .= ", $sqlVal";
|
$values .= ", $sqlVal";
|
||||||
}
|
}
|
||||||
$res = $r = $trec->dbc->query("
|
$res = $r = $trec->dbc->query("
|
||||||
|
@ -88,16 +71,20 @@ class TransportRecord
|
||||||
VALUES
|
VALUES
|
||||||
($values)
|
($values)
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return $trec;
|
return $trec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recall transport record from DB
|
* Recall transport record from DB
|
||||||
*
|
*
|
||||||
* @param tr: Transport object reference
|
* @param Transport $tr
|
||||||
* @param trtok: string - transport token
|
* @param string $trtok
|
||||||
* @return TransportRecord instance
|
* transport token
|
||||||
|
* @return TransportRecord
|
||||||
*/
|
*/
|
||||||
function recall(&$tr, $trtok)
|
function recall(&$tr, $trtok)
|
||||||
{
|
{
|
||||||
|
@ -113,8 +100,10 @@ class TransportRecord
|
||||||
FROM {$trec->transTable}
|
FROM {$trec->transTable}
|
||||||
WHERE trtok='$trtok'
|
WHERE trtok='$trtok'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
if(is_null($row)){
|
return $r;
|
||||||
|
}
|
||||||
|
if (is_null($row)) {
|
||||||
return PEAR::raiseError("TransportRecord::recall:".
|
return PEAR::raiseError("TransportRecord::recall:".
|
||||||
" invalid transport token ($trtok)", TRERR_TOK
|
" invalid transport token ($trtok)", TRERR_TOK
|
||||||
);
|
);
|
||||||
|
@ -125,26 +114,30 @@ class TransportRecord
|
||||||
$trec->recalled = TRUE;
|
$trec->recalled = TRUE;
|
||||||
return $trec;
|
return $trec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set state of transport record
|
* Set state of transport record
|
||||||
*
|
*
|
||||||
* @param newState: string
|
* @param string $newState
|
||||||
* @param data: array - other data fields to set
|
* @param array $data
|
||||||
* @param oldState: string, (opt.) check old state and do nothing if differ
|
* other data fields to set
|
||||||
* @param lock: boolean, (opt.) check lock and do nothing if differ
|
* @param string $oldState
|
||||||
* @return boolean success
|
* (opt.) check old state and do nothing if differ
|
||||||
|
* @param boolean $lock
|
||||||
|
* (opt.) check lock and do nothing if differ
|
||||||
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
|
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
|
||||||
{
|
{
|
||||||
$set = " state='$newState', ts=now()";
|
$set = " state='$newState', ts=now()";
|
||||||
if(!is_null($lock)){
|
if (!is_null($lock)) {
|
||||||
$slock = ($lock ? 'Y' : 'N');
|
$slock = ($lock ? 'Y' : 'N');
|
||||||
$nlock = (!$lock);
|
$nlock = (!$lock);
|
||||||
$snlock = ($nlock ? 'Y' : 'N');
|
$snlock = ($nlock ? 'Y' : 'N');
|
||||||
$set .= ", lock='$snlock'";
|
$set .= ", lock='$snlock'";
|
||||||
}
|
}
|
||||||
foreach($data as $k=>$v){
|
foreach ($data as $k => $v) {
|
||||||
$set .= ", $k=".$this->_getSqlVal($k, $v);
|
$set .= ", $k=".$this->_getSqlVal($k, $v);
|
||||||
}
|
}
|
||||||
$r = $this->dbc->query("
|
$r = $this->dbc->query("
|
||||||
|
@ -154,37 +147,48 @@ class TransportRecord
|
||||||
(is_null($oldState) ? '' : " AND state='$oldState'").
|
(is_null($oldState) ? '' : " AND state='$oldState'").
|
||||||
(is_null($lock) ? '' : " AND lock = '$slock'")
|
(is_null($lock) ? '' : " AND lock = '$slock'")
|
||||||
);
|
);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
// return TRUE;
|
// return TRUE;
|
||||||
$affRows = $r = $this->dbc->affectedRows();
|
$affRows = $r = $this->dbc->affectedRows();
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return ($affRows == 1);
|
return ($affRows == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return state of transport record
|
* Return state of transport record
|
||||||
*
|
*
|
||||||
* @return string - state
|
* @return string
|
||||||
|
* state
|
||||||
*/
|
*/
|
||||||
function getState()
|
function getState()
|
||||||
{
|
{
|
||||||
if(!$this->recalled){
|
if (!$this->recalled) {
|
||||||
return PEAR::raiseError("TransportRecord::getState:".
|
return PEAR::raiseError("TransportRecord::getState:".
|
||||||
" not recalled ({$this->trtok})", TRERR_TOK
|
" not recalled ({$this->trtok})", TRERR_TOK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->row['state'];
|
return $this->row['state'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set lock on transport record
|
* Set lock on transport record
|
||||||
*
|
*
|
||||||
* @param lock: boolean - lock if true, release lock if false
|
* @param boolean $lock
|
||||||
* @return boolean true or error
|
* lock if true, release lock if false
|
||||||
|
* @return mixed
|
||||||
|
* true or error
|
||||||
*/
|
*/
|
||||||
function setLock($lock)
|
function setLock($lock)
|
||||||
{
|
{
|
||||||
if($this->dropped) return TRUE;
|
if ($this->dropped) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
$slock = ($lock ? 'Y' : 'N');
|
$slock = ($lock ? 'Y' : 'N');
|
||||||
$nlock = (!$lock);
|
$nlock = (!$lock);
|
||||||
$snlock = ($nlock ? 'Y' : 'N');
|
$snlock = ($nlock ? 'Y' : 'N');
|
||||||
|
@ -193,10 +197,14 @@ class TransportRecord
|
||||||
SET lock='$slock', ts=now()
|
SET lock='$slock', ts=now()
|
||||||
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
|
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
|
||||||
);
|
);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$affRows = $r = $this->dbc->affectedRows();
|
$affRows = $r = $this->dbc->affectedRows();
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
if($affRows != 1){
|
return $r;
|
||||||
|
}
|
||||||
|
if ($affRows != 1) {
|
||||||
$ltxt = ($lock ? 'lock' : 'unlock' );
|
$ltxt = ($lock ? 'lock' : 'unlock' );
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"TransportRecord::setLock: can't $ltxt ({$this->trtok})"
|
"TransportRecord::setLock: can't $ltxt ({$this->trtok})"
|
||||||
|
@ -204,83 +212,100 @@ class TransportRecord
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return type of transport
|
* Return type of transport
|
||||||
*
|
*
|
||||||
* @return string - trtype
|
* @return string
|
||||||
|
* Transport type
|
||||||
*/
|
*/
|
||||||
function getTransportType()
|
function getTransportType()
|
||||||
{
|
{
|
||||||
if(!$this->recalled){
|
if (!$this->recalled) {
|
||||||
return PEAR::raiseError("TransportRecord::getTransportType:".
|
return PEAR::raiseError("TransportRecord::getTransportType:".
|
||||||
" not recalled ({$this->trtok})", TRERR_TOK
|
" not recalled ({$this->trtok})", TRERR_TOK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->row['trtype'];
|
return $this->row['trtype'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set state to failed and set error message in transport record
|
* Set state to failed and set error message in transport record
|
||||||
*
|
*
|
||||||
* @param txt: string - base part of error message
|
* @param string $txt
|
||||||
* @param eo: PEAR error object - (opt.) error msg can be construct from it
|
* base part of error message
|
||||||
* @return boolean true or error
|
* @param PEAR_Error $eo
|
||||||
|
* (opt.) error msg can be construct from it
|
||||||
|
* @return mixed
|
||||||
|
* boolean true or error
|
||||||
*/
|
*/
|
||||||
function fail($txt='', $eo=NULL)
|
function fail($txt='', $eo=NULL)
|
||||||
{
|
{
|
||||||
if(!$this->recalled){
|
if (!$this->recalled) {
|
||||||
return PEAR::raiseError("TransportRecord::fail:".
|
return PEAR::raiseError("TransportRecord::fail:".
|
||||||
" not recalled ({$this->trtok})", TRERR_TOK
|
" not recalled ({$this->trtok})", TRERR_TOK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$msg = $txt;
|
$msg = $txt;
|
||||||
if(!is_null($eo)){
|
if (!is_null($eo)) {
|
||||||
$msg .= $eo->getMessage()." ".$eo->getUserInfo().
|
$msg .= $eo->getMessage()." ".$eo->getUserInfo().
|
||||||
" [".$eo->getCode()."]";
|
" [".$eo->getCode()."]";
|
||||||
}
|
}
|
||||||
$r = $this->setState('failed', array('errmsg'=>$msg));
|
$r = $this->setState('failed', array('errmsg'=>$msg));
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close transport record
|
* Close transport record
|
||||||
*
|
*
|
||||||
* @return boolean true or error
|
* @return mixed
|
||||||
|
* boolean true or error
|
||||||
*/
|
*/
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
if(!$this->recalled){
|
if (!$this->recalled) {
|
||||||
return PEAR::raiseError("TransportRecord::close:".
|
return PEAR::raiseError("TransportRecord::close:".
|
||||||
" not recalled ({$this->trtok})", TRERR_TOK
|
" not recalled ({$this->trtok})", TRERR_TOK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(TR_LEAVE_CLOSED){
|
if (TR_LEAVE_CLOSED) {
|
||||||
$r = $this->setState('closed');
|
$r = $this->setState('closed');
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
}else{
|
return $r;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$r = $this->dbc->query("
|
$r = $this->dbc->query("
|
||||||
DELETE FROM {$this->transTable}
|
DELETE FROM {$this->transTable}
|
||||||
WHERE trtok='{$this->trtok}'
|
WHERE trtok='{$this->trtok}'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$this->recalled = FALSE;
|
$this->recalled = FALSE;
|
||||||
$this->dropped = TRUE;
|
$this->dropped = TRUE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add field specific envelopes to values (e.g. ' around strings)
|
* Add field specific envelopes to values (e.g. ' around strings)
|
||||||
*
|
*
|
||||||
* @param fldName: string - field name
|
* @param string $fldName
|
||||||
* @param fldVal: mixed - field value
|
* field name
|
||||||
* @return string
|
* @param mixed $fldVal
|
||||||
|
* field value
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _getSqlVal($fldName, $fldVal)
|
function _getSqlVal($fldName, $fldVal)
|
||||||
{
|
{
|
||||||
switch($fldName){
|
switch ($fldName) {
|
||||||
case 'realsize':
|
case 'realsize':
|
||||||
case 'expectedsize':
|
case 'expectedsize':
|
||||||
case 'uid':
|
case 'uid':
|
||||||
|
@ -296,38 +321,46 @@ class TransportRecord
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get title from transported object's metadata (if exists)
|
* Get title from transported object's metadata (if exists)
|
||||||
*
|
*
|
||||||
* @return string - the title or descriptive string
|
* @return string
|
||||||
|
* the title or descriptive string
|
||||||
*/
|
*/
|
||||||
function getTitle()
|
function getTitle()
|
||||||
{
|
{
|
||||||
$defStr = 'unknown';
|
$defStr = 'unknown';
|
||||||
$trtype = $r = $this->getTransportType(); //contains recall check
|
$trtype = $r = $this->getTransportType(); //contains recall check
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if (PEAR::isError($r)) {
|
||||||
switch($trtype){
|
return $r;
|
||||||
case"audioclip":
|
}
|
||||||
case"playlist":
|
switch ($trtype) {
|
||||||
case"playlistPkg":
|
case "audioclip":
|
||||||
case"metadata":
|
case "playlist":
|
||||||
|
case "playlistPkg":
|
||||||
|
case "metadata":
|
||||||
$title = $r = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
|
$title = $r = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
|
||||||
if(PEAR::isError($r)){
|
if (PEAR::isError($r)) {
|
||||||
if($r->getCode()==GBERR_FOBJNEX) $title = $defStr;
|
if ($r->getCode()==GBERR_FOBJNEX) {
|
||||||
else return $r;
|
$title = $defStr;
|
||||||
|
} else {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case"searchjob":
|
case "searchjob":
|
||||||
$title = 'searchjob';
|
$title = 'searchjob';
|
||||||
break;
|
break;
|
||||||
case"file":
|
case "file":
|
||||||
$title = ( isset($this->row['localfile']) ?
|
$title = ( isset($this->row['localfile']) ?
|
||||||
basename($this->row['localfile']) : 'regular file');
|
basename($this->row['localfile']) : 'regular file');
|
||||||
break;
|
break;
|
||||||
default: $title = $defStr;
|
default:
|
||||||
|
$title = $defStr;
|
||||||
}
|
}
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // class TransportRecord
|
||||||
?>
|
?>
|
|
@ -1,32 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
define('VAL_ROOT', 110);
|
define('VAL_ROOT', 110);
|
||||||
define('VAL_NOREQE', 111);
|
define('VAL_NOREQE', 111);
|
||||||
define('VAL_NOONEOF', 112);
|
define('VAL_NOONEOF', 112);
|
||||||
|
@ -50,8 +22,13 @@ define('VAL_PREDXML', 121);
|
||||||
* <li>playlistFormat.php</li>
|
* <li>playlistFormat.php</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* It probably should be replaced by XML schema validation in the future.
|
* It probably should be replaced by XML schema validation in the future.
|
||||||
|
*
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
*/
|
*/
|
||||||
class Validator{
|
class Validator {
|
||||||
/**
|
/**
|
||||||
* string - format type of validated document
|
* string - format type of validated document
|
||||||
*/
|
*/
|
||||||
|
@ -64,12 +41,15 @@ class Validator{
|
||||||
* string - gunid of validated file for identification in mass input
|
* string - gunid of validated file for identification in mass input
|
||||||
*/
|
*/
|
||||||
var $gunid = NULL;
|
var $gunid = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param format string - format type of validated document
|
* @param string $format
|
||||||
* @param gunid string - gunid of validated file for identification
|
* format type of validated document
|
||||||
* in mass input
|
* @param string $gunid
|
||||||
|
* gunid of validated file for identification in mass input
|
||||||
*/
|
*/
|
||||||
function Validator($format, $gunid)
|
function Validator($format, $gunid)
|
||||||
{
|
{
|
||||||
|
@ -81,19 +61,26 @@ class Validator{
|
||||||
'playlist' => "playlistFormat",
|
'playlist' => "playlistFormat",
|
||||||
'webstream' => "webstreamFormat",
|
'webstream' => "webstreamFormat",
|
||||||
);
|
);
|
||||||
if(!isset($formats[$format])) return $this->_err(VAL_FORMAT);
|
if (!isset($formats[$format])) {
|
||||||
|
return $this->_err(VAL_FORMAT);
|
||||||
|
}
|
||||||
$formatName = $formats[$format];
|
$formatName = $formats[$format];
|
||||||
$formatFile = dirname(__FILE__)."/$formatName.php";
|
$formatFile = dirname(__FILE__)."/$formatName.php";
|
||||||
if(!file_exists($formatFile)) return $this->_err(VAL_FORMAT);
|
if (!file_exists($formatFile)) {
|
||||||
|
return $this->_err(VAL_FORMAT);
|
||||||
|
}
|
||||||
require $formatFile;
|
require $formatFile;
|
||||||
$this->formTree = $$formatName;
|
$this->formTree = $$formatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate document - only wrapper for validateNode method
|
* Validate document - only wrapper for validateNode method
|
||||||
*
|
*
|
||||||
* @param data object, validated object tree
|
* @param object $data
|
||||||
* @return TRUE or PEAR::error
|
* validated object tree
|
||||||
|
* @return mixed
|
||||||
|
* TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validate(&$data)
|
function validate(&$data)
|
||||||
{
|
{
|
||||||
|
@ -101,162 +88,205 @@ class Validator{
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate one metadata value (on insert/update)
|
* Validate one metadata value (on insert/update)
|
||||||
*
|
*
|
||||||
* @param fname string - parent element name
|
* @param string $fname
|
||||||
* @param category string - qualif.category name
|
* parent element name
|
||||||
* @param predxml string - 'A' | 'T' (attr or tag)
|
* @param string $category
|
||||||
* @param value string - validated element value
|
* qualif.category name
|
||||||
* @return TRUE or PEAR::error
|
* @param string $predxml
|
||||||
|
* 'A' | 'T' (attr or tag)
|
||||||
|
* @param string $value
|
||||||
|
* validated element value
|
||||||
|
* @return mixed
|
||||||
|
* TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validateOneValue($fname, $category, $predxml, $value)
|
function validateOneValue($fname, $category, $predxml, $value)
|
||||||
{
|
{
|
||||||
$formTree =& $this->formTree;
|
$formTree =& $this->formTree;
|
||||||
switch($predxml){
|
switch ($predxml) {
|
||||||
case'T':
|
case 'T':
|
||||||
if(!$this->isChildInFormat($fname, $category))
|
if (!$this->isChildInFormat($fname, $category)) {
|
||||||
return $this->_err(VAL_UNKNOWNE, "$category in $fname");
|
return $this->_err(VAL_UNKNOWNE, "$category in $fname");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case'A':
|
case 'A':
|
||||||
if(!$this->isAttrInFormat($fname, $category))
|
if (!$this->isAttrInFormat($fname, $category)) {
|
||||||
return $this->_err(VAL_UNKNOWNA, "$category in $fname");
|
return $this->_err(VAL_UNKNOWNA, "$category in $fname");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case'N':
|
case 'N':
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return $this->_err(VAL_PREDXML, $predxml);
|
return $this->_err(VAL_PREDXML, $predxml);
|
||||||
}
|
}
|
||||||
if(isset($formTree[$category]['regexp'])){
|
if (isset($formTree[$category]['regexp'])) {
|
||||||
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
||||||
if(!preg_match("|{$formTree[$category]['regexp']}|", $value))
|
if (!preg_match("|{$formTree[$category]['regexp']}|", $value)) {
|
||||||
return $this->_err(VAL_CONTENT, "$category/$value");
|
return $this->_err(VAL_CONTENT, "$category/$value");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation of one element node from object tree
|
* Validation of one element node from object tree
|
||||||
*
|
*
|
||||||
* @param node object - validated node
|
* @param object $node
|
||||||
* @param fname string - aktual name in format structure
|
* validated node
|
||||||
* @return TRUE or PEAR::error
|
* @param string $fname
|
||||||
|
* actual name in format structure
|
||||||
|
* @return mixed
|
||||||
|
* TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validateNode(&$node, $fname)
|
function validateNode(&$node, $fname)
|
||||||
{
|
{
|
||||||
$dname = (($node->ns? $node->ns.":" : '').$node->name);
|
$dname = (($node->ns? $node->ns.":" : '').$node->name);
|
||||||
$formTree =& $this->formTree;
|
$formTree =& $this->formTree;
|
||||||
if(DEBUG) echo"\nVAL::validateNode: 1 $dname/$fname\n";
|
if (DEBUG) {
|
||||||
|
echo"\nVAL::validateNode: 1 $dname/$fname\n";
|
||||||
|
}
|
||||||
// check root node name:
|
// check root node name:
|
||||||
if($dname != $fname) return $this->_err(VAL_ROOT, $fname);
|
if ($dname != $fname) {
|
||||||
|
return $this->_err(VAL_ROOT, $fname);
|
||||||
|
}
|
||||||
// check if this element is defined in format:
|
// check if this element is defined in format:
|
||||||
if(!isset($formTree[$fname])) return $this->_err(VAL_NOTDEF, $fname);
|
if (!isset($formTree[$fname])) {
|
||||||
|
return $this->_err(VAL_NOTDEF, $fname);
|
||||||
|
}
|
||||||
// check element content
|
// check element content
|
||||||
if(isset($formTree[$fname]['regexp'])){
|
if (isset($formTree[$fname]['regexp'])) {
|
||||||
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
||||||
if(!preg_match("|{$formTree[$fname]['regexp']}|", $node->content))
|
if (!preg_match("|{$formTree[$fname]['regexp']}|", $node->content)) {
|
||||||
return $this->_err(VAL_CONTENT, "$fname/{$node->content}");
|
return $this->_err(VAL_CONTENT, "$fname/{$node->content}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// validate attributes:
|
// validate attributes:
|
||||||
$ra = $this->validateAttributes($node, $fname);
|
$ra = $this->validateAttributes($node, $fname);
|
||||||
if(PEAR::isError($ra)) return $ra;
|
if (PEAR::isError($ra)) {
|
||||||
|
return $ra;
|
||||||
|
}
|
||||||
// validate children:
|
// validate children:
|
||||||
$r = $this->validateChildren($node, $fname);
|
$r = $this->validateChildren($node, $fname);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation of attributes
|
* Validation of attributes
|
||||||
*
|
*
|
||||||
* @param node object - validated node
|
* @param object $node
|
||||||
* @param fname string - aktual name in format structure
|
* validated node
|
||||||
* @return TRUE or PEAR::error
|
* @param string $fname
|
||||||
|
* actual name in format structure
|
||||||
|
* @return mixed
|
||||||
|
* TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validateAttributes(&$node, $fname)
|
function validateAttributes(&$node, $fname)
|
||||||
{
|
{
|
||||||
$formTree =& $this->formTree;
|
$formTree =& $this->formTree;
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
// check if all attrs are permitted here:
|
// check if all attrs are permitted here:
|
||||||
foreach($node->attrs as $i=>$attr){
|
foreach ($node->attrs as $i => $attr) {
|
||||||
$aname = (($attr->ns? $attr->ns.":" : '').$attr->name);
|
$aname = (($attr->ns? $attr->ns.":" : '').$attr->name);
|
||||||
$attrs[$aname] =& $node->attrs[$i];
|
$attrs[$aname] =& $node->attrs[$i];
|
||||||
if(!$this->isAttrInFormat($fname, $aname))
|
if (!$this->isAttrInFormat($fname, $aname)) {
|
||||||
return $this->_err(VAL_UNKNOWNA, $aname);
|
return $this->_err(VAL_UNKNOWNA, $aname);
|
||||||
|
}
|
||||||
// check attribute format
|
// check attribute format
|
||||||
// echo "XXA $aname\n";
|
// echo "XXA $aname\n";
|
||||||
if(isset($formTree[$aname]['regexp'])){
|
if (isset($formTree[$aname]['regexp'])) {
|
||||||
// echo "XAR {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
// echo "XAR {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
||||||
if(!preg_match("|{$formTree[$aname]['regexp']}|", $attr->val))
|
if (!preg_match("|{$formTree[$aname]['regexp']}|", $attr->val)) {
|
||||||
return $this->_err(VAL_ATTRIB, "$aname [".var_export($attr->val,TRUE)."]");
|
return $this->_err(VAL_ATTRIB, "$aname [".var_export($attr->val,TRUE)."]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if all required attrs are here:
|
// check if all required attrs are here:
|
||||||
if(isset($formTree[$fname]['attrs'])){
|
if (isset($formTree[$fname]['attrs'])) {
|
||||||
$fattrs =& $formTree[$fname]['attrs'];
|
$fattrs =& $formTree[$fname]['attrs'];
|
||||||
if(isset($fattrs['required'])){
|
if (isset($fattrs['required'])) {
|
||||||
foreach($fattrs['required'] as $i=>$attr){
|
foreach ($fattrs['required'] as $i => $attr) {
|
||||||
if(!isset($attrs[$attr]))
|
if (!isset($attrs[$attr])) {
|
||||||
return $this->_err(VAL_NOREQA, $attr);
|
return $this->_err(VAL_NOREQA, $attr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation children nodes
|
* Validation children nodes
|
||||||
*
|
*
|
||||||
* @param node object - validated node
|
* @param object $node
|
||||||
* @param fname string - aktual name in format structure
|
* validated node
|
||||||
* @return TRUE or PEAR::error
|
* @param string $fname
|
||||||
|
* actual name in format structure
|
||||||
|
* @return mixed
|
||||||
|
* TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validateChildren(&$node, $fname)
|
function validateChildren(&$node, $fname)
|
||||||
{
|
{
|
||||||
$formTree =& $this->formTree;
|
$formTree =& $this->formTree;
|
||||||
$childs = array();
|
$childs = array();
|
||||||
// check if all children are permitted here:
|
// check if all children are permitted here:
|
||||||
foreach($node->children as $i=>$ch){
|
foreach ($node->children as $i => $ch) {
|
||||||
$chname = (($ch->ns? $ch->ns.":" : '').$ch->name);
|
$chname = (($ch->ns? $ch->ns.":" : '').$ch->name);
|
||||||
// echo "XXE $chname\n";
|
// echo "XXE $chname\n";
|
||||||
if(!$this->isChildInFormat($fname, $chname))
|
if (!$this->isChildInFormat($fname, $chname)) {
|
||||||
return $this->_err(VAL_UNKNOWNE, $chname);
|
return $this->_err(VAL_UNKNOWNE, $chname);
|
||||||
|
}
|
||||||
// call children recursive:
|
// call children recursive:
|
||||||
$r = $this->validateNode($node->children[$i], $chname);
|
$r = $this->validateNode($node->children[$i], $chname);
|
||||||
if(PEAR::isError($r)) return $r;
|
if (PEAR::isError($r)) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
$childs[$chname] = TRUE;
|
$childs[$chname] = TRUE;
|
||||||
}
|
}
|
||||||
// check if all required children are here:
|
// check if all required children are here:
|
||||||
if(isset($formTree[$fname]['childs'])){
|
if (isset($formTree[$fname]['childs'])) {
|
||||||
$fchilds =& $formTree[$fname]['childs'];
|
$fchilds =& $formTree[$fname]['childs'];
|
||||||
if(isset($fchilds['required'])){
|
if (isset($fchilds['required'])) {
|
||||||
foreach($fchilds['required'] as $i=>$ch){
|
foreach ($fchilds['required'] as $i => $ch) {
|
||||||
if(!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
|
if (!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// required one from set
|
// required one from set
|
||||||
if(isset($fchilds['oneof'])){
|
if (isset($fchilds['oneof'])) {
|
||||||
$one = FALSE;
|
$one = FALSE;
|
||||||
foreach($fchilds['oneof'] as $i=>$ch){
|
foreach ($fchilds['oneof'] as $i => $ch) {
|
||||||
if(isset($childs[$ch])){
|
if (isset($childs[$ch])) {
|
||||||
if($one) return $this->_err(
|
if ($one) {
|
||||||
VAL_UNEXPONEOF, "$ch in $fname");
|
return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
|
||||||
|
}
|
||||||
$one = TRUE;
|
$one = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$one) return $this->_err(VAL_NOONEOF);
|
if (!$one) {
|
||||||
|
return $this->_err(VAL_NOONEOF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if child is presented in format structure
|
* Test if child is presented in format structure
|
||||||
*
|
*
|
||||||
* @param fname string - node name in format structure
|
* @param string $fname
|
||||||
* @param chname string - child node name
|
* node name in format structure
|
||||||
* @return boolean
|
* @param string $chname
|
||||||
|
* child node name
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isChildInFormat($fname, $chname)
|
function isChildInFormat($fname, $chname)
|
||||||
{
|
{
|
||||||
|
@ -266,12 +296,15 @@ class Validator{
|
||||||
return ($listo!==FALSE || $listr!==FALSE || $list1!==FALSE);
|
return ($listo!==FALSE || $listr!==FALSE || $list1!==FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if attribute is presented in format structure
|
* Test if attribute is presented in format structure
|
||||||
*
|
*
|
||||||
* @param fname string - node name in format structure
|
* @param string $fname
|
||||||
* @param aname string - attribute name
|
* node name in format structure
|
||||||
* @return boolean
|
* @param string $aname
|
||||||
|
* attribute name
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isAttrInFormat($fname, $aname)
|
function isAttrInFormat($fname, $aname)
|
||||||
{
|
{
|
||||||
|
@ -281,17 +314,23 @@ class Validator{
|
||||||
return ($listr!==FALSE || $listi!==FALSE || $listn!==FALSE);
|
return ($listr!==FALSE || $listi!==FALSE || $listn!==FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if node/attribute is presented in format structure
|
* Check if node/attribute is presented in format structure
|
||||||
*
|
*
|
||||||
* @param fname string - node name in format structure
|
* @param string $fname
|
||||||
* @param chname string - node/attribute name
|
* node name in format structure
|
||||||
* @param nType string - 'childs' | 'attrs'
|
* @param string $chname
|
||||||
* @param reqType string - <ul>
|
* node/attribute name
|
||||||
|
* @param string $nType
|
||||||
|
* 'childs' | 'attrs'
|
||||||
|
* @param string $reqType
|
||||||
|
* <ul>
|
||||||
* <li>for elements: 'required' | 'optional' | 'oneof'</li>
|
* <li>for elements: 'required' | 'optional' | 'oneof'</li>
|
||||||
* <li>for attributes: 'required' | 'implied' | 'normal'</li>
|
* <li>for attributes: 'required' | 'implied' | 'normal'</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @return boolean/int (index int format array returned if found)
|
* @return mixed
|
||||||
|
* boolean/int (index int format array returned if found)
|
||||||
*/
|
*/
|
||||||
function isInFormatAs($fname, $chname, $nType='childs', $reqType='required')
|
function isInFormatAs($fname, $chname, $nType='childs', $reqType='required')
|
||||||
{
|
{
|
||||||
|
@ -304,12 +343,15 @@ class Validator{
|
||||||
return $listed;
|
return $listed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error exception generator
|
* Error exception generator
|
||||||
*
|
*
|
||||||
* @param errno int - erron code
|
* @param int $errno
|
||||||
* @param par string - optional string for more descriptive error messages
|
* erron code
|
||||||
* @return PEAR::error
|
* @param string $par
|
||||||
|
* optional string for more descriptive error messages
|
||||||
|
* @return PEAR_Error
|
||||||
*/
|
*/
|
||||||
function _err($errno, $par='')
|
function _err($errno, $par='')
|
||||||
{
|
{
|
||||||
|
@ -333,16 +375,7 @@ class Validator{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
* /
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
} // class Validator
|
||||||
|
|
||||||
|
?>
|
|
@ -1,39 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
This file is part of the LiveSupport project.
|
* @subpackage StorageServer
|
||||||
http://livesupport.campware.org/
|
*/
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
require_once "XML/Util.php";
|
require_once "XML/Util.php";
|
||||||
|
|
||||||
/* ================================================================== Element */
|
/* ================================================================== Element */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representation of one XML element
|
* Object representation of one XML element
|
||||||
*
|
*
|
||||||
* @see MetaData
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
class XmlElement {
|
class XmlElement {
|
||||||
/**
|
/**
|
||||||
|
@ -47,27 +30,31 @@ class XmlElement {
|
||||||
/**
|
/**
|
||||||
* Attributes
|
* Attributes
|
||||||
*/
|
*/
|
||||||
var $attrs = array();
|
var $attrs = array();
|
||||||
/**
|
/**
|
||||||
* Namespace definitions
|
* Namespace definitions
|
||||||
*/
|
*/
|
||||||
var $nSpaces = array();
|
var $nSpaces = array();
|
||||||
/**
|
/**
|
||||||
* Child nodes
|
* Child nodes
|
||||||
*/
|
*/
|
||||||
var $children = array();
|
var $children = array();
|
||||||
/**
|
/**
|
||||||
* Text content of element
|
* Text content of element
|
||||||
*/
|
*/
|
||||||
var $content = '';
|
var $content = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param fullname string, fully qualified name of element
|
* @param string $fullname
|
||||||
* @param attrs hash of attributes
|
* Fully qualified name of element
|
||||||
* @param nSpaces hash of namespace definitions
|
* @param array $attrs
|
||||||
* @param children hash of child nodes
|
* hash of attributes
|
||||||
|
* @param array $nSpaces
|
||||||
|
* hash of namespace definitions
|
||||||
|
* @param array $children
|
||||||
|
* hash of child nodes
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
function XmlElement($fullname, $attrs, $nSpaces=array(), $children=array())
|
function XmlElement($fullname, $attrs, $nSpaces=array(), $children=array())
|
||||||
|
@ -79,13 +66,16 @@ class XmlElement {
|
||||||
$this->nSpaces = $nSpaces;
|
$this->nSpaces = $nSpaces;
|
||||||
$this->children = $children;
|
$this->children = $children;
|
||||||
}
|
}
|
||||||
}
|
} // class XmlElement
|
||||||
|
|
||||||
|
|
||||||
/* ================================================================ Attribute */
|
/* ================================================================ Attribute */
|
||||||
/**
|
/**
|
||||||
* Object representation of one XML attribute
|
* Object representation of one XML attribute
|
||||||
*
|
*
|
||||||
* @see MetaData
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
class XmlAttrib {
|
class XmlAttrib {
|
||||||
/**
|
/**
|
||||||
|
@ -103,9 +93,12 @@ class XmlAttrib {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param atns string, namespace prefix
|
* @param string $atns
|
||||||
* @param atnm string, attribute name
|
* namespace prefix
|
||||||
* @param atv string, attribute value
|
* @param string $atnm
|
||||||
|
* attribute name
|
||||||
|
* @param string $atv
|
||||||
|
* attribute value
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
function XmlAttrib($atns, $atnm, $atv)
|
function XmlAttrib($atns, $atnm, $atv)
|
||||||
|
@ -114,12 +107,15 @@ class XmlAttrib {
|
||||||
$this->name = $atnm;
|
$this->name = $atnm;
|
||||||
$this->val = $atv;
|
$this->val = $atv;
|
||||||
}
|
}
|
||||||
}
|
} // fn XmlAttrib
|
||||||
|
|
||||||
|
|
||||||
/* =================================================================== Parser */
|
/* =================================================================== Parser */
|
||||||
/**
|
/**
|
||||||
* XML parser object encapsulation
|
* XML parser object encapsulation
|
||||||
*
|
*
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
* @see MetaData
|
* @see MetaData
|
||||||
*/
|
*/
|
||||||
class XmlParser {
|
class XmlParser {
|
||||||
|
@ -135,10 +131,12 @@ class XmlParser {
|
||||||
* Error structure
|
* Error structure
|
||||||
*/
|
*/
|
||||||
var $err = array(FALSE, '');
|
var $err = array(FALSE, '');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param data string, XML string to be parsed
|
* @param string $data
|
||||||
|
* XML string to be parsed
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
function XmlParser($data){
|
function XmlParser($data){
|
||||||
|
@ -148,7 +146,7 @@ class XmlParser {
|
||||||
xml_set_element_handler($xml_parser, "startTag", "endTag");
|
xml_set_element_handler($xml_parser, "startTag", "endTag");
|
||||||
xml_set_character_data_handler($xml_parser, 'characterData');
|
xml_set_character_data_handler($xml_parser, 'characterData');
|
||||||
$res = xml_parse($xml_parser, $data, TRUE);
|
$res = xml_parse($xml_parser, $data, TRUE);
|
||||||
if(!$res) {
|
if (!$res) {
|
||||||
$this->err = array(TRUE,
|
$this->err = array(TRUE,
|
||||||
sprintf("XML error: %s at line %d\n",
|
sprintf("XML error: %s at line %d\n",
|
||||||
xml_error_string(xml_get_error_code($xml_parser)),
|
xml_error_string(xml_get_error_code($xml_parser)),
|
||||||
|
@ -160,65 +158,73 @@ class XmlParser {
|
||||||
xml_parser_free($xml_parser);
|
xml_parser_free($xml_parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse XML file or string
|
* Parse XML file or string
|
||||||
*
|
*
|
||||||
* @param data string, local path to XML file or XML string
|
* @param string $data
|
||||||
* @param loc string, location: 'file'|'string'
|
* local path to XML file or XML string
|
||||||
* @return array reference, parse result tree (or PEAR::error)
|
* @param string $loc
|
||||||
|
* location: 'file'|'string'
|
||||||
|
* @return array
|
||||||
|
* reference, parse result tree (or PEAR::error)
|
||||||
*/
|
*/
|
||||||
function &parse($data='', $loc='file')
|
function &parse($data='', $loc='file')
|
||||||
{
|
{
|
||||||
switch($loc){
|
switch ($loc) {
|
||||||
case"file":
|
case "file":
|
||||||
if(!is_file($data)){
|
if (!is_file($data)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"XmlParser::parse: file not found ($data)"
|
"XmlParser::parse: file not found ($data)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(!is_readable($data)){
|
if (!is_readable($data)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"XmlParser::parse: can't read file ($data)"
|
"XmlParser::parse: can't read file ($data)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$data = file_get_contents($data);
|
$data = file_get_contents($data);
|
||||||
case"string":
|
case "string":
|
||||||
$parser =& new XmlParser($data);
|
$parser =& new XmlParser($data);
|
||||||
if($parser->isError()){
|
if ($parser->isError()) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"SmilPlaylist::parse: ".$parser->getError()
|
"SmilPlaylist::parse: ".$parser->getError()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$tree = $parser->getTree();
|
$tree = $parser->getTree();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"XmlParser::parse: unsupported source location ($loc)"
|
"XmlParser::parse: unsupported source location ($loc)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $tree;
|
return $tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start tag handler
|
* Start tag handler
|
||||||
*
|
*
|
||||||
* @param parser resource, reference to parser resource
|
* @param resource $parser
|
||||||
* @param fullname string element name
|
* reference to parser resource
|
||||||
* @param attrs array of attributes
|
* @param string $fullname
|
||||||
* @return none
|
* element name
|
||||||
|
* @param array $attrs
|
||||||
|
* array of attributes
|
||||||
|
* @return none
|
||||||
*/
|
*/
|
||||||
function startTag($parser, $fullname, $attrs) {
|
function startTag($parser, $fullname, $attrs) {
|
||||||
$nSpaces = array();
|
$nSpaces = array();
|
||||||
foreach($attrs as $atn=>$atv){
|
foreach ($attrs as $atn => $atv) {
|
||||||
$a = XML_Util::splitQualifiedName($atn);
|
$a = XML_Util::splitQualifiedName($atn);
|
||||||
$atns = $a['namespace'];
|
$atns = $a['namespace'];
|
||||||
$atnm = $a['localPart'];
|
$atnm = $a['localPart'];
|
||||||
unset($attrs[$atn]);
|
unset($attrs[$atn]);
|
||||||
if($atns == 'xmlns') $nSpaces[$atnm] = $atv;
|
if ($atns == 'xmlns') {
|
||||||
else if ($atns == NULL && $atnm == 'xmlns'){
|
$nSpaces[$atnm] = $atv;
|
||||||
|
} else if ($atns == NULL && $atnm == 'xmlns') {
|
||||||
$nSpaces[''] = $atv;
|
$nSpaces[''] = $atv;
|
||||||
}else{
|
} else {
|
||||||
$attrs[$atn] = new XmlAttrib($atns, $atnm, $atv);
|
$attrs[$atn] = new XmlAttrib($atns, $atnm, $atv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,41 +232,50 @@ class XmlParser {
|
||||||
array_push($this->stack, $el);
|
array_push($this->stack, $el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End tag handler
|
* End tag handler
|
||||||
*
|
*
|
||||||
* @param parser resource, reference to parser resource
|
* @param resource $parser
|
||||||
* @param fullname string element name
|
* reference to parser resource
|
||||||
|
* @param string $fullname
|
||||||
|
* element name
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function endTag($parser, $fullname) {
|
function endTag($parser, $fullname) {
|
||||||
$cnt = count($this->stack);
|
$cnt = count($this->stack);
|
||||||
if($cnt>1){
|
if ($cnt > 1) {
|
||||||
$this->stack[$cnt-2]->children[] = $this->stack[$cnt-1];
|
$this->stack[$cnt-2]->children[] = $this->stack[$cnt-1];
|
||||||
$lastEl = array_pop($this->stack);
|
$lastEl = array_pop($this->stack);
|
||||||
}else{
|
} else {
|
||||||
$this->tree = $this->stack[0];
|
$this->tree = $this->stack[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Character data handler
|
* Character data handler
|
||||||
*
|
*
|
||||||
* @param parser resource, reference to parser resource
|
* @param resource $parser
|
||||||
* @param data string
|
* reference to parser resource
|
||||||
* @return none
|
* @param string $data
|
||||||
|
* @return none
|
||||||
*/
|
*/
|
||||||
function characterData($parser, $data) {
|
function characterData($parser, $data) {
|
||||||
$cnt = count($this->stack);
|
$cnt = count($this->stack);
|
||||||
if(trim($data)!=''){ $this->stack[$cnt-1]->content .= $data; }
|
if (trim($data)!='') {
|
||||||
|
$this->stack[$cnt-1]->content .= $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default handler
|
* Default handler
|
||||||
*
|
*
|
||||||
* @param parser resource, reference to parser resource
|
* @param resource $parser
|
||||||
* @param data string
|
* reference to parser resource
|
||||||
* @return none
|
* @param string $data
|
||||||
|
* @return none
|
||||||
*/
|
*/
|
||||||
function defaultHandler($parser, $data)
|
function defaultHandler($parser, $data)
|
||||||
{
|
{
|
||||||
|
@ -272,46 +287,58 @@ class XmlParser {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return result tree
|
* Return result tree
|
||||||
*
|
*
|
||||||
* @return hash, tree structure
|
* @return array
|
||||||
|
* tree structure
|
||||||
*/
|
*/
|
||||||
function getTree(){
|
function getTree()
|
||||||
|
{
|
||||||
return $this->tree;
|
return $this->tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return error string
|
|
||||||
*
|
|
||||||
* @return boolean if error occured
|
|
||||||
*/
|
|
||||||
function isError(){
|
|
||||||
return $this->err[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return error string
|
* Return error string
|
||||||
*
|
*
|
||||||
* @return string, error message
|
* @return boolean
|
||||||
|
* whether error occured
|
||||||
*/
|
*/
|
||||||
function getError(){
|
function isError()
|
||||||
|
{
|
||||||
|
return $this->err[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return error string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* error message
|
||||||
|
*/
|
||||||
|
function getError()
|
||||||
|
{
|
||||||
return $this->err[1];
|
return $this->err[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------- auxiliary methos for serialization */
|
/* ----------------------------------- auxiliary methos for serialization */
|
||||||
/**
|
/**
|
||||||
* Serialize metadata of one file
|
* Serialize metadata of one file
|
||||||
*
|
*
|
||||||
* @return string, serialized XML
|
* @return string, serialized XML
|
||||||
*/
|
*/
|
||||||
function serialize(){
|
function serialize()
|
||||||
|
{
|
||||||
$res = '<?xml version="1.0" encoding="utf-8"?>';
|
$res = '<?xml version="1.0" encoding="utf-8"?>';
|
||||||
$res .= $this->serializeEl($this->tree);
|
$res .= $this->serializeEl($this->tree);
|
||||||
$res .= "\n";
|
$res .= "\n";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize one metadata element
|
* Serialize one metadata element
|
||||||
*
|
*
|
||||||
|
@ -319,7 +346,8 @@ class XmlParser {
|
||||||
* @param lvl int, level for indentation
|
* @param lvl int, level for indentation
|
||||||
* @return string, serialized XML
|
* @return string, serialized XML
|
||||||
*/
|
*/
|
||||||
function serializeEl($el, $lvl=0){
|
function serializeEl($el, $lvl=0)
|
||||||
|
{
|
||||||
$ind = str_repeat(" ", $lvl);
|
$ind = str_repeat(" ", $lvl);
|
||||||
$elNs = $el->ns;
|
$elNs = $el->ns;
|
||||||
$elName = $el->name;
|
$elName = $el->name;
|
||||||
|
@ -327,22 +355,26 @@ class XmlParser {
|
||||||
$fullName = ($elNs=='' ? '' : "$elNs:")."$elName";
|
$fullName = ($elNs=='' ? '' : "$elNs:")."$elName";
|
||||||
$res = "\n{$ind}<{$fullName}{$attrs}>";
|
$res = "\n{$ind}<{$fullName}{$attrs}>";
|
||||||
$haveCh = (count($el->children)>0);
|
$haveCh = (count($el->children)>0);
|
||||||
foreach($el->children as $ch){
|
foreach ($el->children as $ch) {
|
||||||
$res .= $this->serializeEl($ch, $lvl+1);
|
$res .= $this->serializeEl($ch, $lvl+1);
|
||||||
}
|
}
|
||||||
$res .= XML_Util::replaceEntities("{$el->content}");
|
$res .= XML_Util::replaceEntities("{$el->content}");
|
||||||
if($haveCh) $res .= "\n{$ind}";
|
if ($haveCh) {
|
||||||
|
$res .= "\n{$ind}";
|
||||||
|
}
|
||||||
$res .= "</{$fullName}>";
|
$res .= "</{$fullName}>";
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------- debug methods */
|
/* -------------------------------------------------------- debug methods */
|
||||||
/**
|
/**
|
||||||
* Debug dump of tree
|
* Debug dump of tree
|
||||||
*
|
*
|
||||||
* @return hash, tree structure
|
* @return hash, tree structure
|
||||||
*/
|
*/
|
||||||
function dump(){
|
function dump()
|
||||||
|
{
|
||||||
var_dump($this->tree);
|
var_dump($this->tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
* @version $Revision$
|
||||||
|
*
|
||||||
This file is part of the LiveSupport project.
|
*/
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
$audioClipFormat = array(
|
$audioClipFormat = array(
|
||||||
'_root'=>'audioClip',
|
'_root'=>'audioClip',
|
||||||
|
@ -343,7 +320,7 @@ $audioClipFormat = array(
|
||||||
'area'=>'Talk',
|
'area'=>'Talk',
|
||||||
'attrs'=>array('implied'=>array('xml:lang')),
|
'attrs'=>array('implied'=>array('xml:lang')),
|
||||||
),
|
),
|
||||||
|
|
||||||
'ls:filename'=>array(
|
'ls:filename'=>array(
|
||||||
'type'=>'Text',
|
'type'=>'Text',
|
||||||
'attrs'=>array('implied'=>array('xml:lang')),
|
'attrs'=>array('implied'=>array('xml:lang')),
|
||||||
|
@ -365,4 +342,4 @@ $audioClipFormat = array(
|
||||||
?
|
?
|
||||||
ls:filename Text auto
|
ls:filename Text auto
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
|
@ -1,38 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file conf.php
|
* StorageServer configuration file
|
||||||
* storageServer configuration file
|
*
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
define('LS_VERSION', '1.1');
|
define('LS_VERSION', '1.1');
|
||||||
define('PHP5', version_compare( phpversion(), "5.0.0", ">=" ));
|
define('PHP5', version_compare( phpversion(), "5.0.0", ">=" ));
|
||||||
|
|
||||||
|
@ -75,7 +49,7 @@ $config = array(
|
||||||
'password' => 'test',
|
'password' => 'test',
|
||||||
'hostspec' => 'localhost',
|
'hostspec' => 'localhost',
|
||||||
'phptype' => 'pgsql',
|
'phptype' => 'pgsql',
|
||||||
'database' => 'LiveSupport-test',
|
'database' => 'Campcaster-test',
|
||||||
),
|
),
|
||||||
'tblNamePrefix' => 'ls_',
|
'tblNamePrefix' => 'ls_',
|
||||||
|
|
||||||
|
@ -96,13 +70,13 @@ $config = array(
|
||||||
'useTrash' => TRUE,
|
'useTrash' => TRUE,
|
||||||
|
|
||||||
/* ==================================================== URL configuration */
|
/* ==================================================== URL configuration */
|
||||||
'storageUrlPath' => '/livesupportStorageServer',
|
'storageUrlPath' => '/campcasterStorageServer',
|
||||||
'storageXMLRPC' => 'xmlrpc/xrLocStor.php',
|
'storageXMLRPC' => 'xmlrpc/xrLocStor.php',
|
||||||
'storageUrlHost' => 'localhost',
|
'storageUrlHost' => 'localhost',
|
||||||
'storageUrlPort' => 80,
|
'storageUrlPort' => 80,
|
||||||
|
|
||||||
/* ================================================ archive configuration */
|
/* ================================================ archive configuration */
|
||||||
'archiveUrlPath' => '/livesupportArchiveServer',
|
'archiveUrlPath' => '/campcasterArchiveServer',
|
||||||
'archiveXMLRPC' => 'xmlrpc/xrArchive.php',
|
'archiveXMLRPC' => 'xmlrpc/xrArchive.php',
|
||||||
'archiveUrlHost' => 'localhost',
|
'archiveUrlHost' => 'localhost',
|
||||||
'archiveUrlPort' => 80,
|
'archiveUrlPort' => 80,
|
||||||
|
@ -141,7 +115,7 @@ $config = array(
|
||||||
/* ============================================== auxiliary configuration */
|
/* ============================================== auxiliary configuration */
|
||||||
'RootNode' => 'RootNode',
|
'RootNode' => 'RootNode',
|
||||||
'tmpRootPass' => 'q',
|
'tmpRootPass' => 'q',
|
||||||
|
|
||||||
/* =================================================== cron configuration */
|
/* =================================================== cron configuration */
|
||||||
'cronUserName' => 'www-data',
|
'cronUserName' => 'www-data',
|
||||||
'lockfile' => dirname(__FILE__).'/cron/cron.lock',
|
'lockfile' => dirname(__FILE__).'/cron/cron.lock',
|
||||||
|
@ -154,7 +128,7 @@ $config['sysSubjs'] = array(
|
||||||
$old_ip = get_include_path();
|
$old_ip = get_include_path();
|
||||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||||
|
|
||||||
// see if a ~/.livesupport/storageServer.conf.php exists, and
|
// see if a ~/.campcaster/storageServer.conf.php exists, and
|
||||||
// overwrite the settings from there if any
|
// overwrite the settings from there if any
|
||||||
|
|
||||||
$this_file = null;
|
$this_file = null;
|
||||||
|
@ -168,7 +142,7 @@ if(!is_null($this_file)){
|
||||||
$fileowner_array = posix_getpwuid($fileowner_id);
|
$fileowner_array = posix_getpwuid($fileowner_id);
|
||||||
$fileowner_homedir = $fileowner_array['dir'];
|
$fileowner_homedir = $fileowner_array['dir'];
|
||||||
$fileowner_name = $fileowner_array['name'];
|
$fileowner_name = $fileowner_array['name'];
|
||||||
$home_conf = $fileowner_homedir . '/.livesupport/storageServer.conf.php';
|
$home_conf = $fileowner_homedir . '/.campcaster/storageServer.conf.php';
|
||||||
if (file_exists($home_conf)) {
|
if (file_exists($home_conf)) {
|
||||||
$default_config = $config;
|
$default_config = $config;
|
||||||
$developer_name = $fileowner_name;
|
$developer_name = $fileowner_name;
|
||||||
|
|
|
@ -3,8 +3,8 @@ require_once (dirname(__FILE__).'/Crontab.php');
|
||||||
require_once (dirname(__FILE__).'/../conf.php');
|
require_once (dirname(__FILE__).'/../conf.php');
|
||||||
/**
|
/**
|
||||||
* This class can call a PHP function from crontab.
|
* This class can call a PHP function from crontab.
|
||||||
*
|
|
||||||
* Example:
|
* Example:
|
||||||
|
* <pre>
|
||||||
* $cron = new Cron();
|
* $cron = new Cron();
|
||||||
* $access = $cron->openCrontab('write');
|
* $access = $cron->openCrontab('write');
|
||||||
* if ($access != 'write') {
|
* if ($access != 'write') {
|
||||||
|
@ -17,7 +17,9 @@ require_once (dirname(__FILE__).'/../conf.php');
|
||||||
* array('first','secound','third')
|
* array('first','secound','third')
|
||||||
* );
|
* );
|
||||||
* $cron->closeCrontab();
|
* $cron->closeCrontab();
|
||||||
*
|
* </pre>
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer.Cron
|
||||||
*/
|
*/
|
||||||
class Cron {
|
class Cron {
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +37,7 @@ class Cron {
|
||||||
* @var string available values: read | write
|
* @var string available values: read | write
|
||||||
*/
|
*/
|
||||||
var $ctAccess = 'read';
|
var $ctAccess = 'read';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -47,13 +49,13 @@ class Cron {
|
||||||
$this->cronUserName = $config['cronUserName'];
|
$this->cronUserName = $config['cronUserName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ==================================================== Cronjob functions */
|
/* ==================================================== Cronjob functions */
|
||||||
/**
|
/**
|
||||||
* Add a cronjob to the crontab
|
* Add a cronjob to the crontab
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $m minute
|
* @param string $m minute
|
||||||
* @param string $h hour
|
* @param string $h hour
|
||||||
* @param string $dom day of month
|
* @param string $dom day of month
|
||||||
* @param string $mo month
|
* @param string $mo month
|
||||||
|
@ -65,7 +67,7 @@ class Cron {
|
||||||
function addCronJob($m, $h, $dom, $mo, $dow, $className, $params)
|
function addCronJob($m, $h, $dom, $mo, $dow, $className, $params)
|
||||||
{
|
{
|
||||||
if ($this->ctAccess == 'write') {
|
if ($this->ctAccess == 'write') {
|
||||||
$this->ct->addCron($m, $h, $dom, $mo, $dow,
|
$this->ct->addCron($m, $h, $dom, $mo, $dow,
|
||||||
$this->getCommand($className, $params));
|
$this->getCommand($className, $params));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,7 +78,7 @@ class Cron {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function return with the active cronjobs
|
* This function return with the active cronjobs
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return array array of cronjob struct
|
* @return array array of cronjob struct
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +89,7 @@ class Cron {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a cronjob.
|
* Remove a cronjob.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $index index of the cronjobs' array.
|
* @param int $index index of the cronjobs' array.
|
||||||
* @return bool true if success else PEAR error.
|
* @return bool true if success else PEAR error.
|
||||||
|
@ -106,17 +108,17 @@ class Cron {
|
||||||
/* ==================================================== Crontab functions */
|
/* ==================================================== Crontab functions */
|
||||||
/**
|
/**
|
||||||
* Open the crontab
|
* Open the crontab
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $access only for listing 'read', for add and delete 'write'
|
* @param string $access only for listing 'read', for add and delete 'write'
|
||||||
* @return string sucessed access - available values read | write
|
* @return string sucessed access - available values read | write
|
||||||
*/
|
*/
|
||||||
function openCrontab($access = 'read')
|
function openCrontab($access = 'read')
|
||||||
{
|
{
|
||||||
$access = strtolower($access);
|
$access = strtolower($access);
|
||||||
$this->ct = new Crontab($this->cronUserName);
|
$this->ct = new Crontab($this->cronUserName);
|
||||||
if ($access == 'write' &&
|
if ($access == 'write' &&
|
||||||
$this->isCrontabWritable() &&
|
$this->isCrontabWritable() &&
|
||||||
$this->lockCrontab()) {
|
$this->lockCrontab()) {
|
||||||
$this->ctAccess = $access;
|
$this->ctAccess = $access;
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,7 +129,7 @@ class Cron {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the crontab
|
* Close the crontab
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return bool true if everything is ok, false is the lock file can't delete
|
* @return bool true if everything is ok, false is the lock file can't delete
|
||||||
*/
|
*/
|
||||||
|
@ -141,7 +143,7 @@ class Cron {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the crontab is writable
|
* Check the crontab is writable
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -152,18 +154,18 @@ class Cron {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to lock the crontab
|
* Try to lock the crontab
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return bool true if the locking is success
|
* @return bool true if the locking is success
|
||||||
*/
|
*/
|
||||||
function lockCrontab()
|
function lockCrontab()
|
||||||
{
|
{
|
||||||
return touch($this->lockfile);
|
return touch($this->lockfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to unlock the crontab
|
* Try to unlock the crontab
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return bool true if the unlocking is success
|
* @return bool true if the unlocking is success
|
||||||
*/
|
*/
|
||||||
|
@ -173,9 +175,9 @@ class Cron {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the crontab opened with read access. This function force set
|
* If the crontab opened with read access. This function force set
|
||||||
* the access to write.
|
* the access to write.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return bool true if the setting is success
|
* @return bool true if the setting is success
|
||||||
*/
|
*/
|
||||||
|
@ -191,7 +193,7 @@ class Cron {
|
||||||
/* ======================================================= Misc functions */
|
/* ======================================================= Misc functions */
|
||||||
/**
|
/**
|
||||||
* Get the shell command for the cronjob
|
* Get the shell command for the cronjob
|
||||||
*
|
*
|
||||||
* @param string $className name of the class what is called by croncall.php
|
* @param string $className name of the class what is called by croncall.php
|
||||||
* @param mixed $params with this parameter could be called the execute() of class
|
* @param mixed $params with this parameter could be called the execute() of class
|
||||||
* @return string shell command
|
* @return string shell command
|
||||||
|
@ -199,7 +201,7 @@ class Cron {
|
||||||
function getCommand($className, $params)
|
function getCommand($className, $params)
|
||||||
{
|
{
|
||||||
$this->params = array (
|
$this->params = array (
|
||||||
'class' => $className,
|
'class' => $className,
|
||||||
'params' => $params
|
'params' => $params
|
||||||
);
|
);
|
||||||
return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"';
|
return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"';
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Cron jobs handling abstract class
|
* Cron jobs handling abstract class
|
||||||
|
*
|
||||||
|
* @author $Author: $
|
||||||
|
* @version $Revision: $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer.Cron
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CronJob
|
class CronJob
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -12,11 +16,4 @@ class CronJob
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class that interfaces with the crontab. (cjpa@audiophile.com)
|
|
||||||
*
|
|
||||||
* This class lets you manipulate the crontab. It lets you add delete update entries easily.
|
|
||||||
**/
|
|
||||||
|
|
||||||
define('CRON_COMMENT', 0);
|
define('CRON_COMMENT', 0);
|
||||||
define('CRON_ASSIGN', 1);
|
define('CRON_ASSIGN', 1);
|
||||||
define('CRON_CMD', 2);
|
define('CRON_CMD', 2);
|
||||||
define('CRON_SPECIAL', 3);
|
define('CRON_SPECIAL', 3);
|
||||||
define('CRON_EMPTY', 4);
|
define('CRON_EMPTY', 4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class that interfaces with the crontab. (cjpa@audiophile.com)
|
||||||
|
*
|
||||||
|
* This class lets you manipulate the crontab. It lets you add delete update entries easily.
|
||||||
|
* @author $Author: $
|
||||||
|
* @version $Revision: $
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer.Cron
|
||||||
|
*/
|
||||||
class Crontab
|
class Crontab
|
||||||
{
|
{
|
||||||
// {{{ properties
|
// {{{ properties
|
||||||
/**
|
/**
|
||||||
* @var array holds all the different lines.
|
* @var array holds all the different lines.
|
||||||
* Lines are associative arrays with the following fields:
|
* Lines are associative arrays with the following fields:
|
||||||
* "minute" : holds the minutes (0-59)
|
* "minute" : holds the minutes (0-59)
|
||||||
* "hour" : holds the hour (0-23)
|
* "hour" : holds the hour (0-23)
|
||||||
* "dayofmonth" : holds the day of the month (1-31)
|
* "dayofmonth" : holds the day of the month (1-31)
|
||||||
* "month" : the month (1-12 or the names)
|
* "month" : the month (1-12 or the names)
|
||||||
* "dayofweek" : 0-7 (or the names)
|
* "dayofweek" : 0-7 (or the names)
|
||||||
*
|
*
|
||||||
* or a line can be a 2-value array that represents an assignment:
|
* or a line can be a 2-value array that represents an assignment:
|
||||||
* "name" => "value"
|
* "name" => "value"
|
||||||
* or a line can be a comment (string beginning with #)
|
* or a line can be a comment (string beginning with #)
|
||||||
* or it can be a special command (beginning with an @)
|
* or it can be a special command (beginning with an @)
|
||||||
|
@ -38,19 +39,19 @@ class Crontab
|
||||||
var $user;
|
var $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Lists the type of line of each line in $crontabs.
|
* @var string Lists the type of line of each line in $crontabs.
|
||||||
* can be: any of the CRON_* constants.
|
* can be: any of the CRON_* constants.
|
||||||
* so $linetype[5] is the type of $crontabs[5].
|
* so $linetype[5] is the type of $crontabs[5].
|
||||||
*/
|
*/
|
||||||
var $linetypes;
|
var $linetypes;
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* Initialises $this->crontabs
|
* Initialises $this->crontabs
|
||||||
*
|
*
|
||||||
* @param string $user the user for whom the crontab will be manipulated
|
* @param string $user the user for whom the crontab will be manipulated
|
||||||
*/
|
*/
|
||||||
function Crontab($user)
|
function Crontab($user)
|
||||||
|
@ -61,7 +62,7 @@ class Crontab
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This reads the crontab of $this->user and parses it in $this->crontabs
|
* This reads the crontab of $this->user and parses it in $this->crontabs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function readCrontab()
|
function readCrontab()
|
||||||
{
|
{
|
||||||
|
@ -91,7 +92,7 @@ class Crontab
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking if this is an assignment
|
// Checking if this is an assignment
|
||||||
if (ereg("(.*)=(.*)", $line, $assign))
|
if (ereg("(.*)=(.*)", $line, $assign))
|
||||||
{
|
{
|
||||||
$this->crontabs[] = array ("name" => $assign[1], "value" => $assign[2]);
|
$this->crontabs[] = array ("name" => $assign[1], "value" => $assign[2]);
|
||||||
|
@ -175,7 +176,7 @@ class Crontab
|
||||||
/**
|
/**
|
||||||
* Add a item of type CRON_CMD to the end of $this->crontabs
|
* Add a item of type CRON_CMD to the end of $this->crontabs
|
||||||
*
|
*
|
||||||
* @param string $m minute
|
* @param string $m minute
|
||||||
* @param string $h hour
|
* @param string $h hour
|
||||||
* @param string $dom day of month
|
* @param string $dom day of month
|
||||||
* @param string $mo month
|
* @param string $mo month
|
||||||
|
@ -191,7 +192,7 @@ class Crontab
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a comment to the cron to the end of $this->crontabs
|
* Add a comment to the cron to the end of $this->crontabs
|
||||||
*
|
*
|
||||||
* @param string $comment comment
|
* @param string $comment comment
|
||||||
*/
|
*/
|
||||||
function addComment($comment)
|
function addComment($comment)
|
||||||
|
@ -202,7 +203,7 @@ class Crontab
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a special command (check man 5 crontab for more information)
|
* Add a special command (check man 5 crontab for more information)
|
||||||
*
|
*
|
||||||
* @param string $sdate special date
|
* @param string $sdate special date
|
||||||
* string meaning
|
* string meaning
|
||||||
* ------ -------
|
* ------ -------
|
||||||
|
@ -224,7 +225,7 @@ class Crontab
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an assignment (name = value)
|
* Add an assignment (name = value)
|
||||||
*
|
*
|
||||||
* @param string $name name of assingation
|
* @param string $name name of assingation
|
||||||
* @param string $value value
|
* @param string $value value
|
||||||
*/
|
*/
|
||||||
|
@ -236,7 +237,7 @@ class Crontab
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a line from the arrays.
|
* Delete a line from the arrays.
|
||||||
*
|
*
|
||||||
* @param int $index the index in $this->crontabs
|
* @param int $index the index in $this->crontabs
|
||||||
*/
|
*/
|
||||||
function delEntry($index)
|
function delEntry($index)
|
||||||
|
@ -247,7 +248,7 @@ class Crontab
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the lines of a certain type in an array
|
* Get all the lines of a certain type in an array
|
||||||
*
|
*
|
||||||
* @param string $type linetype
|
* @param string $type linetype
|
||||||
*/
|
*/
|
||||||
function getByType($type)
|
function getByType($type)
|
||||||
|
|
|
@ -13,16 +13,18 @@ $gb =& new LocStor($dbc, $config);
|
||||||
$tr =& new Transport($gb);
|
$tr =& new Transport($gb);
|
||||||
|
|
||||||
list(, $trtok) = $_SERVER['argv'];
|
list(, $trtok) = $_SERVER['argv'];
|
||||||
if(TR_LOG_LEVEL>1){ $tr->trLog("transportCronJob start ($trtok)"); }
|
if (TR_LOG_LEVEL>1) {
|
||||||
|
$tr->trLog("transportCronJob start ($trtok)");
|
||||||
|
}
|
||||||
|
|
||||||
// 4-pass on job:
|
// 4-pass on job:
|
||||||
$cnt = 4;
|
$cnt = 4;
|
||||||
for($i=0; $i<$cnt; $i++, sleep(1)){
|
for ($i = 0; $i < $cnt; $i++, sleep(1)){
|
||||||
// run the action:
|
// run the action:
|
||||||
$r = $tr->cronCallMethod($trtok);
|
$r = $tr->cronCallMethod($trtok);
|
||||||
if(PEAR::isError($r)){
|
if (PEAR::isError($r)) {
|
||||||
$tr->trLogPear("transportCronJob: ($trtok): ", $r);
|
$tr->trLogPear("transportCronJob: ($trtok): ", $r);
|
||||||
}else{
|
} else {
|
||||||
# $tr->trLog("X transportCronJob: ".var_export($r, TRUE));
|
# $tr->trLog("X transportCronJob: ".var_export($r, TRUE));
|
||||||
if($r!==TRUE) $tr->trLog("transportCronJob: ($trtok): nonTRUE returned");
|
if($r!==TRUE) $tr->trLog("transportCronJob: ($trtok): nonTRUE returned");
|
||||||
}
|
}
|
||||||
|
@ -30,6 +32,8 @@ for($i=0; $i<$cnt; $i++, sleep(1)){
|
||||||
#sleep(2);
|
#sleep(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TR_LOG_LEVEL>1){ $tr->trLog("transportCronJob end ($trtok)"); }
|
if (TR_LOG_LEVEL>1) {
|
||||||
|
$tr->trLog("transportCronJob end ($trtok)");
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
?>
|
?>
|
|
@ -1,32 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
* @version $Revision$
|
||||||
|
*/
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
header ("location: html/");
|
header ("location: html/");
|
||||||
exit;
|
exit;
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* This (web-callable) script returns group running httpd
|
* This (web-callable) script returns group running httpd
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* This script returns real dir of php scipts for debugging purposes
|
* This script returns real dir of php scipts for debugging purposes
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* This script returns storage root URL
|
* This script returns storage root URL
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* This script returns storage XMLRPC root URL
|
* This script returns storage XMLRPC root URL
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
header ("location: ../");
|
header ("location: ../");
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
|
@ -1,32 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
// no remote execution
|
// no remote execution
|
||||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||||
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){
|
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){
|
||||||
|
|
|
@ -1,32 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
// no remote execution
|
// no remote execution
|
||||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||||
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){
|
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){
|
||||||
|
|
|
@ -1,32 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Campcaster
|
||||||
|
* @subpackage StorageServer
|
||||||
|
*/
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
$playlistFormat = array(
|
$playlistFormat = array(
|
||||||
'_root'=>'playlist',
|
'_root'=>'playlist',
|
||||||
|
@ -135,4 +114,4 @@ $playlistFormat = array(
|
||||||
?
|
?
|
||||||
ls:filename Text auto
|
ls:filename Text auto
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
header ("location: ../");
|
header ("location: ../");
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
|
@ -1,32 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
header("Content-type: text/plain");
|
header("Content-type: text/plain");
|
||||||
echo "\n# Transport test:\n";
|
echo "\n# Transport test:\n";
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
header("Content-type: text/plain");
|
header("Content-type: text/plain");
|
||||||
echo "\n#StorageServer storeWebstream test:\n";
|
echo "\n#StorageServer storeWebstream test:\n";
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
* @version $Revision$
|
||||||
|
*/
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
$webstreamFormat = array(
|
$webstreamFormat = array(
|
||||||
'_root'=>'audioClip',
|
'_root'=>'audioClip',
|
||||||
|
@ -366,4 +342,4 @@ $webstreamFormat = array(
|
||||||
?
|
?
|
||||||
ls:filename Text auto
|
ls:filename Text auto
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
|
@ -1,44 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
require_once dirname(__FILE__).'/../LocStor.php';
|
require_once dirname(__FILE__).'/../LocStor.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML-RPC interface for LocStor class
|
* XML-RPC interface for LocStor class
|
||||||
*
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class XR_LocStor extends LocStor{
|
class XR_LocStor extends LocStor{
|
||||||
|
|
||||||
/* ----------------------------------------------------------- getVersion */
|
/* ----------------------------------------------------------- getVersion */
|
||||||
/**
|
/**
|
||||||
* Dummy method - only returns livesupport version
|
* Dummy method - only returns Campcaster version
|
||||||
*
|
*
|
||||||
* The XML-RPC name of this method is "locstor.getVersion".
|
* The XML-RPC name of this method is "locstor.getVersion".
|
||||||
*
|
*
|
||||||
|
@ -240,7 +213,7 @@ class XR_LocStor extends LocStor{
|
||||||
* (returned by subsequent storeAudioClipClose call)
|
* (returned by subsequent storeAudioClipClose call)
|
||||||
* </li>
|
* </li>
|
||||||
* <li> metadata : string - metadata XML string
|
* <li> metadata : string - metadata XML string
|
||||||
* (as defined in LiveSupport::Core::AudioClip Class Reference,
|
* (as defined in Campcaster::Core::AudioClip Class Reference,
|
||||||
* examples are in storageServer/var/tests/*.xml)
|
* examples are in storageServer/var/tests/*.xml)
|
||||||
* </li>
|
* </li>
|
||||||
* <li> fname : string - human readable mnemonic file name
|
* <li> fname : string - human readable mnemonic file name
|
||||||
|
@ -333,7 +306,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store audio stream identified by URL - no raw audio data
|
* Store audio stream identified by URL - no raw audio data
|
||||||
*
|
*
|
||||||
* The XML-RPC name of this method is "locstor.storeWebstream".
|
* The XML-RPC name of this method is "locstor.storeWebstream".
|
||||||
*
|
*
|
||||||
|
@ -2249,7 +2222,7 @@ class XR_LocStor extends LocStor{
|
||||||
* <li>filetype : string - type of searched files,
|
* <li>filetype : string - type of searched files,
|
||||||
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
|
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
|
||||||
* <li>operator : string - type of conditions join
|
* <li>operator : string - type of conditions join
|
||||||
* (any condition matches / all conditions match),
|
* (any condition matches / all conditions match),
|
||||||
* meaningful values: 'and', 'or', ''
|
* meaningful values: 'and', 'or', ''
|
||||||
* (may be empty or ommited only with less then 2 items in
|
* (may be empty or ommited only with less then 2 items in
|
||||||
* "conditions" field)
|
* "conditions" field)
|
||||||
|
@ -2276,7 +2249,7 @@ class XR_LocStor extends LocStor{
|
||||||
*
|
*
|
||||||
* On success, returns a XML-RPC array of structs with fields:
|
* On success, returns a XML-RPC array of structs with fields:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>cnt : integer - number of matching gunids
|
* <li>cnt : integer - number of matching gunids
|
||||||
* of files have been found</li>
|
* of files have been found</li>
|
||||||
* <li>results : array of hashes:
|
* <li>results : array of hashes:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -2373,7 +2346,7 @@ class XR_LocStor extends LocStor{
|
||||||
if(PEAR::isError($res)){
|
if(PEAR::isError($res)){
|
||||||
return new XML_RPC_Response(0, 805,
|
return new XML_RPC_Response(0, 805,
|
||||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$xv = new XML_RPC_Value;
|
$xv = new XML_RPC_Value;
|
||||||
|
@ -2434,7 +2407,7 @@ class XR_LocStor extends LocStor{
|
||||||
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
|
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
|
||||||
return new XML_RPC_Response(0, $ec,
|
return new XML_RPC_Response(0, $ec,
|
||||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res)));
|
||||||
|
@ -2586,11 +2559,11 @@ class XR_LocStor extends LocStor{
|
||||||
$ec0 = intval($res->getCode());
|
$ec0 = intval($res->getCode());
|
||||||
$ec = (
|
$ec = (
|
||||||
$ec0 == GBERR_SESS || $ec0 == GBERR_PREF || $ec0==ALIBERR_NOTGR
|
$ec0 == GBERR_SESS || $ec0 == GBERR_PREF || $ec0==ALIBERR_NOTGR
|
||||||
? 800+$ec0 : 805
|
? 800+$ec0 : 805
|
||||||
);
|
);
|
||||||
return new XML_RPC_Response(0, $ec,
|
return new XML_RPC_Response(0, $ec,
|
||||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res)));
|
||||||
|
@ -2756,7 +2729,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause, resume or cancel transport
|
* Pause, resume or cancel transport
|
||||||
*
|
*
|
||||||
|
@ -2806,7 +2779,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------ methods for ls-archive-format file transports */
|
/* ------------------------ methods for ls-archive-format file transports */
|
||||||
/**
|
/**
|
||||||
* Open async file transfer from local storageServer to network hub,
|
* Open async file transfer from local storageServer to network hub,
|
||||||
|
@ -2858,7 +2831,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of prepared transfers initiated by hub
|
* Get list of prepared transfers initiated by hub
|
||||||
*
|
*
|
||||||
|
@ -2911,7 +2884,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start of download initiated by hub
|
* Start of download initiated by hub
|
||||||
*
|
*
|
||||||
|
@ -2960,7 +2933,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------- special methods for audioClip/webstream object transport */
|
/* ------------- special methods for audioClip/webstream object transport */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3012,7 +2985,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start download of audioclip or playlist from hub to local storageServer
|
* Start download of audioclip or playlist from hub to local storageServer
|
||||||
*
|
*
|
||||||
|
@ -3063,7 +3036,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------ global-search methods */
|
/* ------------------------------------------------ global-search methods */
|
||||||
/**
|
/**
|
||||||
* Start search job on network hub
|
* Start search job on network hub
|
||||||
|
@ -3114,7 +3087,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get results from search job on network hub.
|
* Get results from search job on network hub.
|
||||||
* (returns error if not finished)
|
* (returns error if not finished)
|
||||||
|
@ -3129,7 +3102,7 @@ class XR_LocStor extends LocStor{
|
||||||
*
|
*
|
||||||
* On success, returns a XML-RPC array of structs with fields:
|
* On success, returns a XML-RPC array of structs with fields:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>cnt : integer - number of matching gunids
|
* <li>cnt : integer - number of matching gunids
|
||||||
* of files have been found</li>
|
* of files have been found</li>
|
||||||
* <li>results : array of hashes:
|
* <li>results : array of hashes:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -3177,7 +3150,7 @@ class XR_LocStor extends LocStor{
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode($res));
|
return new XML_RPC_Response(XML_RPC_encode($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OBSOLETE
|
* OBSOLETE
|
||||||
* Starts upload audioclip to remote archive
|
* Starts upload audioclip to remote archive
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
header ("location: xrLocStor.php");
|
header ("location: xrLocStor.php");
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file put.php
|
* \file put.php
|
||||||
* Store PUT data as temporary file.
|
* Store PUT data as temporary file.
|
||||||
|
@ -53,6 +24,8 @@
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @see XR_LocStor
|
* @see XR_LocStor
|
||||||
|
* @author : $Author$
|
||||||
|
* @version : $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname(__FILE__).'/../conf.php';
|
require_once dirname(__FILE__).'/../conf.php';
|
||||||
|
|
|
@ -1,32 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
* @version $Revision$
|
||||||
|
*/
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* ================================================================= includes */
|
/* ================================================================= includes */
|
||||||
include_once dirname(__FILE__)."/../conf.php";
|
include_once dirname(__FILE__)."/../conf.php";
|
||||||
|
@ -405,7 +381,7 @@ class SchedulerPhpClient{
|
||||||
$serverPath =
|
$serverPath =
|
||||||
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
|
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
|
||||||
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
|
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
|
||||||
#$serverPath = "http://localhost:80/livesupportStorageServerCVS/xmlrpc/xrLocStor.php";
|
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||||
if($this->verbose) echo "serverPath: $serverPath\n";
|
if($this->verbose) echo "serverPath: $serverPath\n";
|
||||||
$url = parse_url($serverPath);
|
$url = parse_url($serverPath);
|
||||||
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
|
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file simpleGet.php
|
* \file simpleGet.php
|
||||||
* Returns stored media file identified by global unique ID.
|
* Returns stored media file identified by global unique ID.
|
||||||
|
@ -51,6 +22,8 @@
|
||||||
* <li> 404 - File not found</li>
|
* <li> 404 - File not found</li>
|
||||||
* <li> 500 - Application error</li>
|
* <li> 500 - Application error</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
* @author $Author$
|
||||||
|
* @version $Revision$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -130,4 +103,4 @@ switch($ftype){
|
||||||
// var_dump($ftype);
|
// var_dump($ftype);
|
||||||
http_error(500, "500 Unknown ftype ($ftype)");
|
http_error(500, "500 Unknown ftype ($ftype)");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1,32 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
/**
|
||||||
|
* @author $Author$
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
* @version : $Revision$
|
||||||
|
*/
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* ====================================================== specific PHP config */
|
/* ====================================================== specific PHP config */
|
||||||
ini_set("mbstring.internal_encoding", 'UTF-8');
|
ini_set("mbstring.internal_encoding", 'UTF-8');
|
||||||
|
@ -189,4 +165,4 @@ foreach($methods as $method=>$description){
|
||||||
|
|
||||||
$s=new XML_RPC_Server( $defs );
|
$s=new XML_RPC_Server( $defs );
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,33 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2004 Media Development Loan Fund
|
|
||||||
|
|
||||||
This file is part of the LiveSupport project.
|
|
||||||
http://livesupport.campware.org/
|
|
||||||
To report bugs, send an e-mail to bugs@campware.org
|
|
||||||
|
|
||||||
LiveSupport is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
LiveSupport is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with LiveSupport; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
|
|
||||||
Author : $Author$
|
|
||||||
Version : $Revision$
|
|
||||||
Location : $URL$
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
require_once dirname(__FILE__).'/../conf.php';
|
require_once dirname(__FILE__).'/../conf.php';
|
||||||
include_once "XML/RPC.php";
|
include_once "XML/RPC.php";
|
||||||
include_once dirname(__FILE__)."/../conf.php";
|
include_once dirname(__FILE__)."/../conf.php";
|
||||||
|
@ -46,7 +17,7 @@ if($pars[0] == '-s'){
|
||||||
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
#$serverPath = "http://localhost:80/livesupportStorageServerCVS/xmlrpc/xrLocStor.php";
|
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||||
|
|
||||||
$url = parse_url($serverPath);
|
$url = parse_url($serverPath);
|
||||||
$client = new XML_RPC_Client($url['path'], $url['host']);
|
$client = new XML_RPC_Client($url['path'], $url['host']);
|
||||||
|
@ -184,7 +155,7 @@ $infos = array(
|
||||||
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
|
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
|
||||||
|
|
||||||
"getTransportInfo" => array('m'=>"locstor.getTransportInfo",
|
"getTransportInfo" => array('m'=>"locstor.getTransportInfo",
|
||||||
'p'=>array('trtok'),
|
'p'=>array('trtok'),
|
||||||
'r'=>array('state', 'realsize', 'expectedsize', 'realchsum', 'expectedchsum')),
|
'r'=>array('state', 'realsize', 'expectedsize', 'realchsum', 'expectedchsum')),
|
||||||
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
|
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
|
||||||
'p'=>array('sessid', 'onOff'), 'r'=>array('state')),
|
'p'=>array('sessid', 'onOff'), 'r'=>array('state')),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue