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:
paul 2006-10-14 15:34:00 +00:00
parent 56d250f21e
commit f4c68079d4
46 changed files with 3805 additions and 3252 deletions

View File

@ -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.
* Should be &quot;required_once&quot; from LocStor.php only.
* Handles recursive accessPlaylist/releasePlaylist.
* 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{
function AccessRecur(&$ls, $sessid){
class AccessRecur {
function AccessRecur(&$ls, $sessid)
{
$this->ls =& $ls;
$this->dbc =& $ls->dbc;
$this->sessid = $sessid;
}
function accessPlaylist(&$ls, $sessid, $plid, $parent='0'){
function accessPlaylist(&$ls, $sessid, $plid, $parent='0')
{
$ppa =& new AccessRecur($ls, $sessid);
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$plRes = $r;
$r = StoredFile::recallByGunid($ppa->ls, $plid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$ac = $r;
$r = $ac->md->genPhpArray();
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$pla = $r;
$r = $ppa->processPlaylist($pla, $plRes['token']);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$plRes['content'] = $r;
return $plRes;
}
function releasePlaylist(&$ls, $sessid, $token){
function releasePlaylist(&$ls, $sessid, $token)
{
$ppa =& new AccessRecur($ls, $sessid);
$r = $ppa->dbc->getAll("
SELECT to_hex(token)as token2, to_hex(gunid)as gunid
FROM {$ppa->ls->accessTable}
WHERE parent=x'{$token}'::bigint
");
if($ppa->dbc->isError($r)){ return $r; }
if ($ppa->dbc->isError($r)) {
return $r;
}
$arr = $r;
foreach($arr as $i=>$item){
foreach ($arr as $i => $item) {
extract($item); // token2, gunid
$r = $ppa->ls->_getType($gunid);
if($ppa->dbc->isError($r)){ return $r; }
if ($ppa->dbc->isError($r)) {
return $r;
}
$ftype = $r;
# echo "$ftype/$token2\n";
switch(strtolower($ftype)){
switch (strtolower($ftype)) {
case"audioclip":
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
if($ppa->dbc->isError($r)){ return $r; }
if ($ppa->dbc->isError($r)) {
return $r;
}
# var_dump($r);
break;
case"playlist":
$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);
break;
default:
}
}
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
if($ppa->dbc->isError($r)){ return $r; }
if ($ppa->dbc->isError($r)) {
return $r;
}
return $r;
}
function processPlaylist($pla, $parent){
function processPlaylist($pla, $parent)
{
$res = array();
foreach($pla['children'] as $ple){
switch($ple['elementname']){
foreach ($pla['children'] as $ple) {
switch ($ple['elementname']) {
case"playlistElement":
$r = $this->processPlEl($ple, $parent);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
// $res = array_merge($res, $r);
$res[] = $r;
break;
@ -106,28 +111,41 @@ class AccessRecur{
}
return $res;
}
function processAc($gunid, $parent){
function processAc($gunid, $parent)
{
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($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":
$r = $this->processAc($ac['attrs']['id'], $parent);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return $r;
break;
case"playlist":
// if(empty($ac['children'])){
$r = $this->accessPlaylist($this->ls, $this->sessid,
$ac['attrs']['id'], $parent);
if(PEAR::isError($r)){
if($r->getCode() != GBERR_NOTF) return $r;
else{
if (PEAR::isError($r)) {
if ($r->getCode() != GBERR_NOTF) {
return $r;
} else {
$r = $this->processPlaylist($ac, $parent);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$r = array(
'content' => $r,
'url' => NULL,
@ -160,5 +178,6 @@ class AccessRecur{
}
return array();
}
}
?>
} // class AccessRecur
?>

View File

@ -2,7 +2,13 @@
define('BACKUP_EXT', 'tar');
define('ACCESS_TYPE', 'backup');
class Backup
/**
* @author $Author: $
* @version $Revision: $
* @package Campcaster
* @subpackage StorageServer
*/
class Backup
{
/**
* string - name of logfile
@ -34,7 +40,7 @@ class Backup
* array - array of affected filenames
*/
var $filenames = array();
/**
* string - base tmp name
*/
@ -46,25 +52,25 @@ class Backup
/**
* string - name of temporary directory
*/
var $tmpDir;
var $tmpDir;
/**
* string - name of temporary playlist directory
*/
var $tmpDirPlaylist;
var $tmpDirPlaylist;
/**
* string - name of temporary audioclip directory
*/
var $tmpDirClip;
var $tmpDirClip;
/**
* string - name of temporary metafile directory
*/
var $tmpDirMeta;
var $tmpDirMeta;
/**
* string - loglevel
*/
var $loglevel = 'warn'; # 'debug';
/**
* greenbox object reference
*/
@ -82,14 +88,15 @@ class Backup
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
}
/**
* Open a backup
* Create a backup file (tarball)
*
* @param sessid : string - session id
* @param criteria : struct - see search criteria
* @return hasharray with field:
* @return hasharray with field:
* token string: backup token
*/
function openBackup($sessid,$criteria='')
@ -99,23 +106,25 @@ class Backup
}
$this->sessid = $sessid;
$this->criteria = $criteria;
# get ids (and real filenames) which files match with criteria
$srch = $r = $this->gb->localSearch($this->criteria,$this->sessid);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
$this->setIDs($srch);
#echo '<XMP>this->ids:'; print_r($this->ids); echo '</XMP>';
# get real filenames
if (is_array($this->ids)) {
$this->setFilenames();
#echo '<XMP>this->filenames:'; print_r($this->filenames); echo '</XMP>';
$this->setEnviroment(true);
# write a status file
file_put_contents($this->statusFile, 'working');
# save the metafile to tmpdir
$hostname = trim(`hostname`);
$ctime = time();
@ -129,22 +138,25 @@ class Backup
" hostname=\"$hostname\"\n".
"/><!-- $ctime_f -->\n"
);
# copy all file to tmpdir
$this->copyAllFiles();
# do everything
$this->doIt();
return array('token'=>$this->token);
} else return false;
} else {
return false;
}
}
/**
* check the status of backup
* Check the status of backup.
*
* @param token : token
* @return hasharray with field:
* @param unknown $token
* @return array
* status : string - susccess | working | fault
* faultString: string - description of fault
* token : stirng - backup token
@ -160,7 +172,7 @@ class Backup
$this->setEnviroment();
$status = file_get_contents($this->statusFile);
if (strpos($status,'fault')!==false) {
list($status,$faultString) = explode('|',$status);
list($status,$faultString) = explode('|',$status);
}
switch ($status) {
case 'success':
@ -175,12 +187,13 @@ class Backup
}
return $r;
}
/**
* Close a backup
* Close a backup
*
* @param token : token
* @return status : boolean
* @param unknown $token
* @return boolean
*/
function closeBackup($token)
{
@ -194,16 +207,19 @@ class Backup
Backup::rRmDir($this->tmpDir);
unlink($this->statusFile);
unlink($this->tmpFile);
if (is_file($this->tmpName)) unlink($this->tmpName);
if (is_file($this->tmpName)) {
unlink($this->tmpName);
}
return !is_file($this->tmpFile);
}
/**
* list of unclosed backups
*
* @param stat : status (optional)
* @param string $stat (optional)
* 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
* token : stirng - backup token
* url : string - access url
@ -224,11 +240,12 @@ class Backup
}
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)
{
@ -242,12 +259,13 @@ class Backup
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') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
@ -257,9 +275,11 @@ class Backup
$gunid = $item['gunid'];
# get a stored file object of this 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);
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");
return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
}
@ -284,9 +304,10 @@ class Backup
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()
@ -305,7 +326,8 @@ class Backup
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt - command:$command\n");
}
}
/**
* Copy the real files into the tmp dirs to tar they.
*
@ -315,7 +337,7 @@ class Backup
if ($this->loglevel=='debug') {
$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)) {
foreach ($this->filenames as $v) {
# get the filename from full path
@ -333,7 +355,8 @@ class Backup
}
}
}
/**
* Figure out the enviroment to the backup
*
@ -347,9 +370,9 @@ class Backup
if (is_null($this->token) && $createDir) {
$this->tmpName = tempnam($this->gb->bufferDir, ACCESS_TYPE.'_');
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
$this->tmpDir = $this->tmpName.'.dir';
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
$this->tmpDirClip = $this->tmpDir. '/audioClip';
$this->tmpDir = $this->tmpName.'.dir';
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
$this->tmpDirClip = $this->tmpDir. '/audioClip';
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
touch($this->tmpFile);
mkdir($this->tmpDir);
@ -362,13 +385,13 @@ class Backup
if (is_link($symlink) && is_file(readlink($symlink))) {
$this->tmpName = str_replace('.tar','',readlink($symlink));
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
$this->tmpDir = $this->tmpName.'.dir';
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
$this->tmpDirClip = $this->tmpDir. '/audioClip';
$this->tmpDir = $this->tmpName.'.dir';
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
$this->tmpDirClip = $this->tmpDir. '/audioClip';
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
} else {
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setEnviroment - Corrupt symbolic link.\n");
return false;
return false;
}
}
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT.'.status';
@ -383,22 +406,26 @@ class Backup
$this->addLogItem("this->statusFile: $this->statusFile\n");
}
}
/**
* generate a new token.
*
* Generate a new token.
* @return void
*/
function genToken()
{
$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'];
}
/**
* 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)
{
@ -407,27 +434,31 @@ class Backup
fclose($f);
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
}
/**
* Delete a directory recursive
*
* @param dirname : string - path of dir.
* @param string $dirname - path of dir.
*/
function rRmDir($dirname)
{
if(is_dir($dirname))
if (is_dir($dirname)) {
$dir_handle = opendir($dirname);
while($file = readdir($dir_handle)) {
if($file!="." && $file!="..") {
if(!is_dir($dirname."/".$file))
}
while ($file = readdir($dir_handle)) {
if ( ($file != ".") && ($file != "..") ) {
if (!is_dir($dirname."/".$file)) {
unlink ($dirname."/".$file);
else
} else {
Backup::rRmDir($dirname."/".$file);
}
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
}
} // classs Backup
?>

View File

@ -1,32 +1,4 @@
<?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_FILEIO', 41);
define('GBERR_FILENEX', 42);
@ -50,13 +22,15 @@ require_once "StoredFile.php";
require_once "Transport.php";
/**
* BasicStor class
* BasicStor class
*
* Core of LiveSupport file storage module
* Core of Campcaster file storage module
*
* @author $Author$
* @version $Revision$
* @see Alib
* @author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @see Alib
*/
class BasicStor extends Alib {
var $filesTable;
@ -88,15 +62,15 @@ class BasicStor extends Alib {
$this->bufferDir = realpath($config['bufferDir']);
$this->transDir = realpath($config['transDir']);
$this->accessDir = realpath($config['accessDir']);
if(!$install){
if (!$install) {
$this->rootId = $r = $this->getRootNode();
if ($this->dbc->isError($r)){
if ($this->dbc->isError($r)) {
trigger_error("BasicStor: ".
$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
}
$this->storId = $this->wd =
$r = $this->getObjId('StorageRoot', $this->getRootNode());
if ($this->dbc->isError($r)){
if ($this->dbc->isError($r)) {
trigger_error("BasicStor: ".
$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
}
@ -147,7 +121,7 @@ class BasicStor extends Alib {
if ($this->dbc->isError($ac)){
$res = $this->removeObj($id);
// catch constraint violations
switch($ac->getCode()){
switch ($ac->getCode()){
case -3:
return PEAR::raiseError(
"BasicStor::bsPutFile: gunid duplication",
@ -1173,7 +1147,7 @@ class BasicStor extends Alib {
* @param int $parid, destination folder local id
* @param string $plid, playlist gunid
* @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
* (e.g. playlists/playlist_1.smil)
* @param string $ext, playlist extension (determines type of import)

View File

@ -1,32 +1,4 @@
<?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);
require_once "XML/Util.php";
@ -39,7 +11,7 @@ require_once "XML/Util.php";
* <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
* <li>operator - string, type of conditions join
* (any condition matches / all conditions match),
* (any condition matches / all conditions match),
* meaningful values: 'and', 'or', ''
* (may be empty or ommited only with less then 2 items in
* &quot;conditions&quot; field)
@ -63,8 +35,12 @@ require_once "XML/Util.php";
* <li>cnt : integer - number of matching items</li>
* </ul>
*
* @see MetaData
* @see StoredFile
* @Author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @see MetaData
* @see StoredFile
*/
class DataEngine{
@ -136,7 +112,7 @@ class DataEngine{
}
return $whereArr;
}
/**
* Method returning SQL query for search/browse with AND operator
* (without using INTERSECT command)
@ -156,7 +132,7 @@ class DataEngine{
foreach($whereArr as $i=>$v){
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
$lastTbl = ($i==0 ? "f" : "md".($i-1));
$innerBlocks[] =
$innerBlocks[] =
"INNER JOIN {$this->mdataTable} md$i ON md$i.gunid = $lastTbl.gunid\n";
}
// query construcion:
@ -173,7 +149,7 @@ class DataEngine{
if($browse) $sql .= "\nORDER BY br.object";
return $sql;
}
/**
* Method returning SQL query for search/browse with AND operator
* (using INTERSECT command)
@ -194,13 +170,13 @@ class DataEngine{
$isectBlocks = array();
foreach($whereArr as $i=>$v){
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
$isectBlocks[] =
$isectBlocks[] =
" SELECT gunid FROM {$this->mdataTable} md$i\n".
" WHERE\n {$whereArr[$i]}";
}
// query construcion:
if(count($isectBlocks)>0){
$isectBlock =
$isectBlock =
"FROM\n(\n".join("INTERSECT\n", $isectBlocks).") sq\n".
"INNER JOIN {$this->filesTable} f ON f.gunid = sq.gunid";
}else{
@ -218,7 +194,7 @@ class DataEngine{
if($browse) $sql .= "\nORDER BY br.object";
return $sql;
}
/**
* Method returning SQL query for search/browse with OR operator
*
@ -255,7 +231,7 @@ class DataEngine{
if($browse) $sql .= "\nORDER BY br.object";
return $sql;
}
/**
* Search in local metadata database.
*
@ -264,7 +240,7 @@ class DataEngine{
* @param offset int, starting point (0 means without offset)
* @return hash, fields:
* results : array with gunid strings
* cnt : integer - number of matching gunids
* cnt : integer - number of matching gunids
* of files have been found
*/
function localSearch($cri, $limit=0, $offset=0)
@ -273,7 +249,7 @@ class DataEngine{
// if(PEAR::isError($res)) return $res;
return $res;
}
/**
* Search in local metadata database, more general version.
*
@ -283,7 +259,7 @@ class DataEngine{
* @param brFldNs string - namespace prefix of category for browse
* @param brFld string, metadata category identifier for browse
* @return arrays of hashes, fields:
* cnt : integer - number of matching gunids
* cnt : integer - number of matching gunids
* of files have been found
* results : array of hashes:
* gunid: string
@ -393,7 +369,7 @@ class DataEngine{
* @param criteria hash
* @return hash, fields:
* 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)
{
@ -421,7 +397,7 @@ class DataEngine{
if(!is_array($res)) $res = array();
return array('results'=>$res, 'cnt'=>$cnt);
}
/**
* Get number of rows in query result
*
@ -437,7 +413,7 @@ class DataEngine{
$rh->free();
return $cnt;
}
}
?>

View File

@ -1,42 +1,16 @@
<?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";
/**
* GreenBox class
* GreenBox class
*
* LiveSupport file storage module
* File storage module.
*
* @author $Author$
* @version $Revision$
* @see BasicStor
* @author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @see BasicStor
*/
class GreenBox extends BasicStor {
@ -77,7 +51,7 @@ class GreenBox extends BasicStor {
$mediaFileLP, $mdataFileLP, $sessid='',
$gunid=NULL, $ftype='audioclip')
{
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
return $res;
}
return $this->bsPutFile(

View File

@ -1,39 +1,15 @@
<?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";
/**
* LocStor class
* LocStor class
*
* Livesupport local storage interface
* Local storage interface
*
* @author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
*/
class LocStor extends BasicStor {
@ -1270,7 +1246,7 @@ class LocStor extends BasicStor {
/*===================================================== auxiliary methods */
/**
* Dummy method - only returns livesupport version
* Dummy method - only returns Campcaster version
*
* @return string
*/

View File

@ -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";
define('INDCH', ' ');
@ -35,9 +6,15 @@ define('AC_URL_RELPATH', '../audioClip/');
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
{
@ -45,9 +22,9 @@ class LsPlaylist extends Playlist
* Create instance of LsPlaylist object and recall existing file
* by gunid.<br/>
*
* @param gb reference to GreenBox object
* @param gunid string, global unique id
* @param className string, optional classname to recall
* @param Greenbox $gb, reference to GreenBox object
* @param string $gunid, global unique id
* @param string $className, optional classname to recall
* @return instance of LsPlaylist object
*/
function &recallByGunid(&$gb, $gunid, $className='LsPlaylist')
@ -55,13 +32,14 @@ class LsPlaylist extends Playlist
return parent::recallByGunid($gb, $gunid, $className);
}
/**
* Create instance of LsPlaylist object and recall existing file
* by access token.<br/>
*
* @param gb reference to GreenBox object
* @param token string, access token
* @param className string, optional classname to recall
* @param GreenBox $gb, reference to GreenBox object
* @param string $token, access token
* @param string $className, optional classname to recall
* @return instance of LsPlaylist object
*/
function &recallByToken(&$gb, $token, $className='LsPlaylist')
@ -69,23 +47,30 @@ class LsPlaylist extends Playlist
return parent::recallByToken($gb, $token, $className);
}
/**
* Export playlist as simplified SMIL XML file
*
* @param toString boolean, if false don't real export,
* return misc info about playlist only
* @return XML string or hasharray with misc info
* @param boolean $toString
* if false don't real export,
* return misc info about playlist only
* @return string
* XML string or hasharray with misc info
*/
function output2Smil($toString=TRUE)
{
$plGunid = $this->gunid;
$arr = $r = $this->md->genPhpArray();
if(PEAR::isError($r)){ return $r; }
if($toString){
if (PEAR::isError($r)) {
return $r;
}
if ($toString) {
$r = LsPlaylistTag::output2Smil($this, $arr);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
return $r;
}else{
} else {
return array(
'type' => 'playlist',
'gunid' => $plGunid,
@ -95,6 +80,7 @@ class LsPlaylist extends Playlist
}
}
/**
* Export playlist as M3U file
*
@ -106,12 +92,16 @@ class LsPlaylist extends Playlist
{
$plGunid = $this->gunid;
$arr = $r = $this->md->genPhpArray();
if(PEAR::isError($r)){ return $r; }
if($toString){
if (PEAR::isError($r)) {
return $r;
}
if ($toString) {
$r = LsPlaylistTag::output2m3u($this, $arr);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
return $r;
}else{
} else {
return array(
'type' => 'playlist',
'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,
* return misc info about playlist only
* @return XML string or hasharray with misc info
* @param boolean $toString
* if false don't really export,
* return misc info about playlist only
* @return mixed
* XML string or hasharray with misc info
*/
function output2RSS($toString=TRUE)
{
$plGunid = $this->gunid;
$arr = $r = $this->md->genPhpArray();
if(PEAR::isError($r)){ return $r; }
if($toString){
if (PEAR::isError($r)) {
return $r;
}
if ($toString) {
$r = LsPlaylistTag::output2RSS($this, $arr);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
return $r;
}else{
} else {
return array(
'type' => 'playlist',
'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
{
function output2Smil(&$pl, $plt, $ind='')
{
$ind2 = $ind.INDCH; $ind3 = $ind2.INDCH; $ind4 = $ind3.INDCH;
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$ind4 = $ind3.INDCH;
$res = "";
foreach($plt['children'] as $ple){
switch($ple['elementname']){
foreach ($plt['children'] as $ple) {
switch ($ple['elementname']) {
case"playlistElement":
$r = LsPlaylistElement::output2Smil($pl, $ple, $ind4);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $res .= $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
case"metadata":
$r = LsPlaylistMetadata::output2Smil($pl, $ple, $ind4);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $res .= $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
default:
}
@ -183,36 +195,53 @@ class LsPlaylistTag
"$ind</smil>\n";
return $res;
}
function output2m3u(&$pl, $plt, $ind='')
{
$res = "";
foreach($plt['children'] as $ple){
switch($ple['elementname']){
foreach ($plt['children'] as $ple) {
switch ($ple['elementname']) {
case"playlistElement":
$r = LsPlaylistElement::output2m3u($pl, $ple);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $res .= $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
}
}
$res = "#EXTM3U\n$res";
return $res;
}
function output2RSS(&$pl, $plt, $ind='')
{
$ind2 = $ind.INDCH; $ind3 = $ind2.INDCH;
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$res = "";
foreach($plt['children'] as $ple){
switch($ple['elementname']){
foreach ($plt['children'] as $ple) {
switch ($ple['elementname']) {
case"playlistElement":
$r = LsPlaylistElement::output2RSS($pl, $ple, $ind3);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $res .= $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
case"metadata":
$r = LsPlaylistMetadata::output2RSS($pl, $ple, $ind3);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $res .= $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
default:
}
@ -225,32 +254,57 @@ class LsPlaylistTag
"$ind</rss>\n";
return $res;
}
}
class LsPlaylistElement{
} // class LsPlaylistTag
/**
* @package Campcaster
* @subpackage StorageServer
* @todo Rename this class "PlaylistElement"
*/
class LsPlaylistElement {
function output2Smil(&$pl, $ple, $ind='')
{
$acOrPl = NULL; $finfo = array('fi'=>0, 'fo'=>0);
$ind2 = $ind.INDCH; $ind3 = $ind2.INDCH;
$acOrPl = NULL;
$finfo = array('fi'=>0, 'fo'=>0);
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$anim = '';
foreach($ple['children'] as $ac){
switch($ac['elementname']){
case"audioClip":
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = LsPlaylistAudioClip::output2Smil($pl, $ac, $ind2);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $acOrPl = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case"playlist":
case "playlist":
$gunid = $ac['attrs']['id'];
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$r = $pl2->output2Smil(FALSE);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $acOrPl = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case"fadeInfo":
$r = LsPlaylistFadeInfo::output2Smil($pl, $ac, $ind2);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $finfo = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$finfo = $r;
}
break;
default:
return PEAR::raiseError(
@ -266,8 +320,8 @@ class LsPlaylistElement{
$fiEndS = $pl->_plTimeToSecs($finfo['fi']);
$foBeginS = ($playlengthS - $fadeOutS);
$foEndS = $pl->_plTimeToSecs($acOrPl['playlength']);
foreach(array('fi','fo') as $ff){
if(${$ff."EndS"} - ${$ff."BeginS"} > 0){
foreach (array('fi','fo') as $ff) {
if (${$ff."EndS"} - ${$ff."BeginS"} > 0) {
$anim .= "{$ind2}<animate attributeName = \"soundLevel\"\n".
"{$ind3}from = \"".($ff == 'fi' ? 0 : 100)."%\"\n".
"{$ind3}to = \"".($ff == 'fi' ? 100 : 0)."%\"\n".
@ -277,7 +331,6 @@ class LsPlaylistElement{
"{$ind3}fill = \"freeze\"\n".
"{$ind2}/>\n"
;
}else{
}
}
$src = $acOrPl['src'];
@ -287,27 +340,41 @@ class LsPlaylistElement{
"\n";
return $str;
}
function output2m3u(&$pl, $ple, $ind='')
{
$acOrPl = NULL;
foreach($ple['children'] as $ac){
switch($ac['elementname']){
case"audioClip":
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = LsPlaylistAudioClip::output2m3u($pl, $ac);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $acOrPl = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case"playlist":
case "playlist":
$gunid = $ac['attrs']['id'];
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$r = $pl2->output2m3u(FALSE);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $acOrPl = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
}
}
if(is_null($acOrPl)) return '';
if (is_null($acOrPl)) {
return '';
}
$playlength = ceil($pl->_plTimeToSecs($acOrPl['playlength']));
$title = $acOrPl['title'];
$uri = (isset($acOrPl['uri']) ? $acOrPl['uri'] : '???' );
@ -315,25 +382,37 @@ class LsPlaylistElement{
$res .= "$uri\n";
return $res;
}
function output2RSS(&$pl, $ple, $ind='')
{
$acOrPl = NULL;
$ind2 = $ind.INDCH;
$anim = '';
foreach($ple['children'] as $ac){
switch($ac['elementname']){
case"audioClip":
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = LsPlaylistAudioClip::output2RSS($pl, $ac, $ind2);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $acOrPl = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case"playlist":
$gunid = $ac['attrs']['id'];
$pl2 = $r = LsPlaylist::recallByGunid($pl->gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$r = $pl2->output2RSS(FALSE);
if(PEAR::isError($r)) return $r;
if(!is_null($r)) $acOrPl = $r;
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case"fadeInfo":
break;
@ -356,15 +435,27 @@ class LsPlaylistElement{
return $str;
}
}
/**
* @package Campcaster
* @subpackage StorageServer
* @todo Rename this class to PlaylistAudioClip (notice the caps)
*/
class LsPLaylistAudioClip
{
function output2Smil(&$pl, $plac, $ind='')
{
$gunid = $plac['attrs']['id'];
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$RADext = $r =$ac->_getExt();
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return array(
'type' => 'audioclip',
'gunid' => $gunid,
@ -372,31 +463,47 @@ class LsPLaylistAudioClip
'playlength' => $plac['attrs']['playlength'],
);
}
function output2m3u(&$pl, $plac, $ind='')
{
$gunid = $plac['attrs']['id'];
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$RADext = $r =$ac->_getExt();
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return array(
'playlength' => $plac['attrs']['playlength'],
'title' => $plac['attrs']['title'],
'uri' => AC_URL_RELPATH."$gunid.$RADext",
);
}
function output2RSS(&$pl, $plac, $ind='')
{
$gunid = $plac['attrs']['id'];
$ac = $r = StoredFile::recallByGunid($pl->gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$RADext = $r =$ac->_getExt();
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$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'] : '' );
$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'] : '' );
return array(
'type' => 'audioclip',
@ -407,10 +514,17 @@ class LsPLaylistAudioClip
'desc' => $desc,
);
}
}
} // class LsPlaylistAudioClip
/**
* @package Campcaster
* @subpackage StorageServer
* @todo Rename this class "PlaylistFadeInfo" (notive the caps)
*/
class LsPLaylistFadeInfo
{
function output2Smil(&$pl, $plfi, $ind='')
{
$r = array(
@ -419,14 +533,44 @@ class LsPLaylistFadeInfo
);
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
{
function output2Smil(&$pl, $md, $ind=''){ return NULL; }
function output2m3u(&$pl, $md, $ind=''){ return NULL; }
function output2RSS(&$pl, $md, $ind=''){ return NULL; }
}
?>
function output2Smil(&$pl, $md, $ind='')
{
return NULL;
}
function output2m3u(&$pl, $md, $ind='')
{
return NULL;
}
function output2RSS(&$pl, $md, $ind='')
{
return NULL;
}
} // class PlaylistMetadata
?>

View File

@ -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', ' ');
/**
* M3uPlaylist class
* M3uPlaylist class
*
* @author $Author: tomash $
* @version : $Revision: 1848 $
* @package Campcaster
* @subpackage StorageServer
*/
class M3uPlaylist {
/**
@ -79,7 +54,7 @@ class M3uPlaylist {
*
* @param gb reference to GreenBox object
* @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
* (e.g. playlists/playlist_1.smil)
* @param gunids hasharray, hash relation from filenames to gunids
@ -135,13 +110,13 @@ class M3uPlaylist {
if(PEAR::isError($r)) return $r;
return $pl;
}
/**
* Import M3U file to storage
*
* @param gb reference to GreenBox object
* @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){
$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

View File

@ -1,192 +1,215 @@
<?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
*
* @see StoredFile
* @author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @see StoredFile
*/
/* ================== Prefs ================== */
class Prefs{
class Prefs {
/**
* Constructor
*
* @param gb object, GreenBox object reference
* @param GreenBox $gb
* GreenBox object reference
*/
function Prefs(&$gb)
{
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
$this->prefTable = $gb->config['tblNamePrefix'].'pref';
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
$this->prefTable = $gb->config['tblNamePrefix'].'pref';
}
/* ======================================================= public methods */
/* ----------------------------------------------------- user preferences */
/**
* Read preference record by session id
* Read preference record by session id
*
* @param sessid string, session id
* @param key string, preference key
* @return string, preference value
* @param string $sessid
* session id
* @param string $key
* preference key
* @return string
* preference value
*/
function loadPref($sessid, $key)
{
$subjid = $this->gb->getSessUserId($sessid);
if(PEAR::isError($subjid)) return $subjid;
if(is_null($subjid)){
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::loadPref: invalid session id",
GBERR_SESS);
}
$val = $this->readVal($subjid, $key);
if(PEAR::isError($val)) return $val;
if($val === FALSE){
if (PEAR::isError($val)) {
return $val;
}
if ($val === FALSE) {
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
GBERR_PREF);
}
return $val;
}
/**
* Save preference record by session id
* Save preference record by session id
*
* @param sessid string, session id
* @param key string, preference key
* @param value string, preference value
* @return boolean
* @param string $sessid
* session id
* @param string $key
* preference key
* @param string $value
* preference value
* @return boolean
*/
function savePref($sessid, $key, $value)
{
$subjid = $this->gb->getSessUserId($sessid);
if(PEAR::isError($subjid)) return $subjid;
if(is_null($subjid)){
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::savePref: invalid session id",
GBERR_SESS);
}
$r = $this->update($subjid, $key, $value);
if(PEAR::isError($r)) return $r;
if($r === FALSE){
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
$r = $this->insert($subjid, $key, $value);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
}
return TRUE;
}
/**
* Delete preference record by session id
*
* @param sessid string, session id
* @param key string, preference key
* @return boolean
* @param string $sessid
* session id
* @param string $key
* preference key
* @return boolean
*/
function delPref($sessid, $key)
{
$subjid = $this->gb->getSessUserId($sessid);
if(PEAR::isError($subjid)) return $subjid;
if(is_null($subjid)){
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::delPref: invalid session id",
GBERR_SESS);
}
$r = $this->delete($subjid, $key);
if(PEAR::isError($r)) return $r;
if($r === FALSE){
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
return PEAR::raiseError("Prefs::delPref: invalid preference key",
GBERR_PREF);
}
return TRUE;
}
/* ---------------------------------------------------- group preferences */
/**
* Read group preference record
*
* @param sessid string, session id
* @param group string, group name
* @param key string, preference key
* @return string, preference value
* @param string $sessid
* session id
* @param string $group
* group name
* @param string $key
* preference key
* @return string
* preference value
*/
function loadGroupPref($sessid, $group, $key)
{
// if sessid is would be used here fix Transport::cronCallMethod !
$subjid = $this->gb->getSubjId($group);
if(PEAR::isError($subjid)) return $subjid;
if(is_null($subjid)){
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError(
"Prefs::loadGroupPref: invalid group name", ALIBERR_NOTGR);
}
$val = $this->readVal($subjid, $key);
if(PEAR::isError($val)) return $val;
if($val === FALSE){
if (PEAR::isError($val)) {
return $val;
}
if ($val === FALSE) {
return PEAR::raiseError(
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF);
}
return $val;
}
/**
* Save group preference record
*
* @param sessid string, session id
* @param group string, group name
* @param key string, preference key
* @param value string, preference value
* @return boolean
* @param string $sessid
* session id
* @param string $group
* group name
* @param string $key
* preference key
* @param string $value
* preference value
* @return boolean
*/
function saveGroupPref($sessid, $group, $key, $value)
{
$uid = $this->gb->getSessUserId($sessid);
if(PEAR::isError($uid)) return $uid;
if(is_null($uid)){
if (PEAR::isError($uid)) {
return $uid;
}
if (is_null($uid)) {
return PEAR::raiseError(
"Prefs::saveGroupPref: invalid session id", GBERR_SESS);
}
$gid = $this->gb->getSubjId($group);
if(PEAR::isError($gid)) return $gid;
if(is_null($gid)){
if (PEAR::isError($gid)) {
return $gid;
}
if (is_null($gid)) {
return PEAR::raiseError(
"Prefs::saveGroupPref: invalid group name", GBERR_SESS);
}
$memb = $this->gb->isMemberOf($uid, $gid);
if(PEAR::isError($memb)) return $memb;
if(!$memb){
if (PEAR::isError($memb)) {
return $memb;
}
if (!$memb) {
return PEAR::raiseError(
"Prefs::saveGroupPref: access denied", GBERR_DENY);
}
$r = $this->update($gid, $key, $value);
if(PEAR::isError($r)) return $r;
if($r === FALSE){
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
$r = $this->insert($gid, $key, $value);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
}
return TRUE;
}
@ -194,68 +217,93 @@ class Prefs{
/**
* Delete group preference record
*
* @param sessid string, session id
* @param group string, group name
* @param key string, preference key
* @return boolean
* @param string $sessid
* session id
* @param string $group
* group name
* @param string $key
* preference key
* @return boolean
*/
function delGroupPref($sessid, $group, $key)
{
$uid = $this->gb->getSessUserId($sessid);
if(PEAR::isError($uid)) return $uid;
if(is_null($uid)){
if (PEAR::isError($uid)) {
return $uid;
}
if (is_null($uid)) {
return PEAR::raiseError(
"Prefs::delGroupPref: invalid session id", GBERR_SESS);
}
$gid = $this->gb->getSubjId($group);
if(PEAR::isError($gid)) return $gid;
if(is_null($gid)){
if (PEAR::isError($gid)) {
return $gid;
}
if (is_null($gid)) {
return PEAR::raiseError(
"Prefs::delGroupPref: invalid group name", GBERR_SESS);
}
$memb = $this->gb->isMemberOf($uid, $gid);
if(PEAR::isError($memb)) return $memb;
if(!$memb){
if (PEAR::isError($memb)) {
return $memb;
}
if (!$memb) {
return PEAR::raiseError(
"Prefs::delGroupPref: access denied", GBERR_DENY);
}
$r = $this->delete($gid, $key);
if(PEAR::isError($r)) return $r;
if($r === FALSE){
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
return PEAR::raiseError(
"Prefs::delGroupPref: invalid preference key", GBERR_PREF);
}
return TRUE;
}
/* ==================================================== low level methods */
/**
* Insert of new preference record
*
* @param subjid int, local user/group id
* @param keystr string, preference key
* @param valstr string, preference value
* @return int, local user id
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @param string $valstr
* preference value
* @return int
* local user id
*/
function insert($subjid, $keystr, $valstr='')
{
$id = $this->dbc->nextId("{$this->prefTable}_id_seq");
if(PEAR::isError($id)) return $id;
if (PEAR::isError($id)) {
return $id;
}
$r = $this->dbc->query("
INSERT INTO {$this->prefTable}
(id, subjid, keystr, valstr)
VALUES
($id, $subjid, '$keystr', '$valstr')
");
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return $id;
}
/**
* Read value of preference record
*
* @param subjid int, local user/group id
* @param keystr string, preference key
* @return string, preference value
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @return string
* preference value
*/
function readVal($subjid, $keystr)
{
@ -263,16 +311,23 @@ class Prefs{
SELECT valstr FROM {$this->prefTable}
WHERE subjid=$subjid AND keystr='$keystr'
");
if(PEAR::isError($val)) return $val;
if(is_null($val)) return FALSE;
if (PEAR::isError($val)) {
return $val;
}
if (is_null($val)) {
return FALSE;
}
return $val;
}
/**
* Read all keys of subject's preferences
*
* @param subjid int, local user/group id
* @return array, preference keys
* @param int $subjid
* local user/group id
* @return array
* preference keys
*/
function readKeys($subjid)
{
@ -280,18 +335,26 @@ class Prefs{
SELECT keystr FROM {$this->prefTable}
WHERE subjid=$subjid
");
if(PEAR::isError($res)) return $res;
if(is_null($res)) return FALSE;
if (PEAR::isError($res)) {
return $res;
}
if (is_null($res)) {
return FALSE;
}
return $res;
}
/**
* Update value of preference record
*
* @param subjid int, local user/group id
* @param keystr string, preference key
* @param newvalstr string, new preference value
* @return boolean
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @param string $newvalstr
* new preference value
* @return boolean
*/
function update($subjid, $keystr, $newvalstr='')
{
@ -300,29 +363,41 @@ class Prefs{
valstr='$newvalstr'
WHERE subjid=$subjid AND keystr='$keystr'
");
if(PEAR::isError($r)) return $r;
if($this->dbc->affectedRows()<1) return FALSE;
if (PEAR::isError($r)) {
return $r;
}
if ($this->dbc->affectedRows() < 1) {
return FALSE;
}
return TRUE;
}
/**
* Delete preference record
*
* @param subjid int, local user/group id
* @param keystr string, preference key
* @return boolean
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @return boolean
*/
function delete($subjid, $keystr)
{
$r = $this->dbc->query("
DELETE FROM {$this->prefTable}
DELETE FROM {$this->prefTable}
WHERE subjid=$subjid AND keystr='$keystr'
");
if(PEAR::isError($r)) return $r;
if($this->dbc->affectedRows()<1) return FALSE;
if (PEAR::isError($r)) {
return $r;
}
if ($this->dbc->affectedRows() < 1) {
return FALSE;
}
return TRUE;
}
/* ==================================================== auxiliary methods */
/**
* Test method
@ -334,26 +409,31 @@ class Prefs{
$testkey = 'testKey';
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
$r = savePref($sessid, $testKey, $testVal);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$val = loadPref($sessid, $testKey);
if($val != $testVal){
if ($val != $testVal) {
echo "ERROR: preference storage test failed.\n ($testVal / $val)\n";
return FALSE;
}
$r = savePref($sessid, $testKey, '');
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$val = loadPref($sessid, $testKey);
if($val != $testVal){
if ($val != $testVal) {
echo "ERROR: preference storage test failed.\n ('' / '$val')\n";
return FALSE;
}
return TRUE;
}
/**
* Install database table for preference storage
*
* @return boolean
* @return boolean
*/
function install()
{
@ -364,7 +444,9 @@ class Prefs{
keystr varchar(255),
valstr text
)");
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
ON {$this->prefTable} (id)");
$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
ON {$this->prefTable} (subjid)");
$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");
if(PEAR::isError($r)) echo $r->getMessage()."\n";
if (PEAR::isError($r)) {
echo $r->getMessage()."\n";
}
$genres = file_get_contents( dirname(__FILE__).'/genres.xml');
$r = $this->insert($stPrefGr, 'genres', $genres);
if(PEAR::isError($r)) echo $r->getMessage()."\n";
if (PEAR::isError($r)) {
echo $r->getMessage()."\n";
}
return TRUE;
}
/**
* Uninstall database table for preference storage
*
* @return boolean
* @return boolean
*/
function uninstall()
{
@ -392,12 +481,5 @@ class Prefs{
$this->dbc->dropSequence("{$this->prefTable}_id_seq");
}
/**
*
* /
function ()
{
}*/
}
?>
} // class Prefs
?>

View File

@ -1,136 +1,129 @@
<?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
* Store media files in real filesystem and handle access to them.<br>
* File storage support class
* 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{
/**
* Constructor
*
* @param gunid string, global unique id
* @param resDir string, resource directory
* @return this
* @param string $gunid
* global unique id
* @param string $resDir
* resource directory
*/
function RawMediaData($gunid, $resDir)
{
$this->gunid = $gunid;
$this->resDir = $resDir;
$this->fname = $this->makeFname();
$this->exists =
$this->exists =
is_file($this->fname) &&
is_readable($this->fname)
;
}
/**
* Insert media file to filesystem
*
* @param mediaFileLP string, local path
* @return true or PEAR::error
* @param string $mediaFileLP
* local path
* @return mixed
* true or PEAR::error
*/
function insert($mediaFileLP)
{
if($this->exists) return FALSE;
if ($this->exists) {
return FALSE;
}
// for files downloaded from archive:
if($mediaFileLP == $this->fname){
if ($mediaFileLP == $this->fname) {
$this->exists = TRUE;
return TRUE;
}
umask(0002);
if(@copy($mediaFileLP, $this->fname)){
if (@copy($mediaFileLP, $this->fname)) {
$this->exists = TRUE;
return TRUE;
}else{
} else {
//@unlink($this->fname); // maybe useless
$this->exists = FALSE;
$this->exists = FALSE;
return PEAR::raiseError(
"RawMediaData::insert: file save failed".
" ($mediaFileLP, {$this->fname})",GBERR_FILEIO
);
}
}
/**
* Delete and insert media file
*
* @param mediaFileLP string, local path
* @return true or PEAR::error
* @param string $mediaFileLP, local path
* @return mixed
* true or PEAR::error
*/
function replace($mediaFileLP)
{
if($this->exists){ $r = $this->delete(); }
else{ $r = NULL; }
if(PEAR::isError($r)) return $r;
if ($this->exists) {
$r = $this->delete();
} else {
$r = NULL;
}
if (PEAR::isError($r)) {
return $r;
}
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()
{
return $this->exists;
}
/**
* Return filename
* Return filename
*
* @return string
* @return string
*/
function getFname()
{
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()
{
if(!$this->exists) return FALSE;
if(@unlink($this->fname)){
if (!$this->exists) {
return FALSE;
}
if (@unlink($this->fname)) {
$this->exists = FALSE;
return TRUE;
}else{
} else {
return PEAR::raiseError(
"RawMediaData::delete: unlink failed ({$this->fname})",
GBERR_FILEIO
@ -139,14 +132,18 @@ class RawMediaData{
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()
{
if(!$this->exists) return FALSE;
if (!$this->exists) {
return FALSE;
}
//$ia = @GetAllFileinfo($this->fname, 'mp3');
//prepared for getid3 upgrade:
$getID3 = new getID3;
@ -154,70 +151,90 @@ class RawMediaData{
return $ia;
}
/**
* Get mime-type returned by getid3 module
* Get mime-type returned by getid3 module
*
* @return string
* @return string
*/
function getMime()
{
$a = $this->analyze();
if($a === FALSE) return $a;
if(isset($a['mime_type'])) return $a['mime_type'];
if ($a === FALSE) {
return $a;
}
if (isset($a['mime_type'])) {
return $a['mime_type'];
}
return '';
}
/**
* Contruct filepath of media file
* Contruct filepath of media file
*
* @return string
* @return string
*/
function makeFname()
{
return "{$this->resDir}/{$this->gunid}";
}
/**
* Test method
* Test method
*
* @param testFname1 string
* @param testFname2 string
* @param accLinkFname string
* @return string
* @param string $testFname1
* @param string $testFname2
* @param string $accLinkFname
* @return string
*/
function test($testFname1, $testFname2, $accLinkFname)
{
$log = '';
if($this->exists())
if ($this->exists()) {
$log .= "---: exists: YES\n";
else
} else {
$log .= "---: exists: NO\n";
if(!($r = $this->delete()))
}
if (!($r = $this->delete())) {
$log .= "---: delete: nothing to delete\n";
if(PEAR::isError($r))
}
if (PEAR::isError($r)) {
$log .= "ERR: ".$r->getMessage()."\n";
if($r = $this->insert($testFname1))
}
if ($r = $this->insert($testFname1)) {
$log .= "---: insert: already exists\n";
if(PEAR::isError($r))
}
if (PEAR::isError($r)) {
$log .= "ERR: ".$r->getMessage()."\n";
if($r = $this->replace($testFname2))
}
if ($r = $this->replace($testFname2)) {
$log .= "---: replace: already exists\n";
if(PEAR::isError($r))
}
if (PEAR::isError($r)) {
$log .= "ERR: ".$r->getMessage()."\n";
if($this->exists())
}
if ($this->exists()) {
$log .= "---: exists: YES\n";
else
} else {
$log .= "---: exists: NO\n";
if(!$this->access($accLinkFname))
}
if (!$this->access($accLinkFname)) {
$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";
}else
}
} else {
$log .= "ERR: wrong file type ($ft)\n";
if(!$this->release($accLinkFname))
}
if (!$this->release($accLinkFname)) {
$log .= "---: access: not exists\n";
}
return $log;
}
}
?>
} // class RawMediaData
?>

View File

@ -1,67 +1,46 @@
<?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');
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 $
* @version $Revision: 1949 $
* @see LocStor
* @author $Author: tomash $
* @version $Revision: 1949 $
* @package Campcaster
* @subpackage StorageServer
* @see LocStor
*/
class Renderer
{
/**
* Render playlist to ogg file (open handle)
*
* @param gb: greenbox object reference
* @param plid : string - playlist gunid
* @param owner: int - local subject id, owner of token
* @return hasharray:
* @param GreenBox $gb
* greenbox object reference
* @param string $plid
* playlist gunid
* @param int $owner
* local subject id, owner of token
* @return array
* token: string - render token
*/
function rnRender2FileOpen(&$gb, $plid, $owner=NULL)
{
// recall playlist:
$pl = $r = LsPlaylist::recallByGunid($gb, $plid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
// smil export:
$smil = $r = $pl->output2Smil();
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
// temporary file for smil:
$tmpn = tempnam($gb->bufferDir, 'plRender_');
$smilf = "$tmpn.smil";
@ -75,7 +54,9 @@ class Renderer
file_put_contents($logf, "--- ".date("Ymd-H:i:s")."\n", FILE_APPEND);
// open access to output file: /*gunid*/ /*parent*/
$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);
$statf = Renderer::getStatusFile($gb, $token);
file_put_contents($statf, "working");
@ -85,7 +66,7 @@ class Renderer
$command = "$renderExe -p $url -o $outf -s $statf >> $logf &";
file_put_contents($logf, "$command\n", FILE_APPEND);
$res = system($command);
if($res === FALSE){
if ($res === FALSE) {
return PEAR::raiseError(
'Renderer::rnRender2File: Error running renderer'
);
@ -93,19 +74,22 @@ class Renderer
return array('token'=>$token);
}
/**
* Render playlist to ogg file (check results)
* Render playlist to ogg file (check results)
*
* @param gb: greenbox object reference
* @param token : string - render token
* @return hasharray:
* @param GreenBox $gb
* GreenBox object reference
* @param string $token
* render token
* @return array
* status : string - success | working | fault
* url : string - readable url
*/
function rnRender2FileCheck(&$gb, $token)
{
$statf = Renderer::getStatusFile($gb, $token);
if(!file_exists($statf)){
if (!file_exists($statf)) {
return PEAR::raiseError(
'Renderer::rnRender2FileCheck: Invalid token'
);
@ -116,13 +100,16 @@ class Renderer
return array('status'=>$status, 'url'=>$url, 'tmpfile'=>$tmpfile);
}
/**
* Render playlist to ogg file (list results)
*
* @param gb: greenbox object reference
* @param stat : status (optional)
* if this parameter is not set, then return with all unclosed backups
* @return array of hasharray:
* @param GreenBox $gb
* greenbox object reference
* @param string $stat
* status (optional) if this parameter is not set, then return with all unclosed backups
* @return array
* array of hasharray:
* status : string - success | working | fault
* url : string - readable url
*/
@ -131,24 +118,30 @@ class Renderer
$tokens = $gb->getTokensByType('render');
foreach ($tokens as $token) {
$st = Renderer::rnRender2FileCheck($gb, $token);
if ($stat=='' || $st['status']==$stat) {
if ( ($stat=='') || ($st['status']==$stat) ) {
$r[] = $st;
}
}
return $r;
}
/**
* Render playlist to ogg file (close handle)
* Render playlist to ogg file (close handle)
*
* @param gb: greenbox object reference
* @param token : string - render token
* @return status : boolean
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return mixed
* TRUE or PEAR_Error
*/
function rnRender2FileClose(&$gb, $token)
{
$r = $gb->bsRelease($token, 'render');
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$realOgg = $r['realFname'];
$tmpn = "{$gb->bufferDir}/".basename($realOgg, '.'.RENDER_EXT);
$smilf = "$tmpn.smil";
@ -160,28 +153,35 @@ class Renderer
return TRUE;
}
/**
* Render playlist to storage as audioClip (check results)
* Render playlist to storage as audioClip (check results)
*
* @param gb: greenbox object reference
* @param token: string - render token
* @return hasharray:
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
* status : string - success | working | fault
* gunid: string - global unique id of result file
*/
function rnRender2StorageCheck(&$gb, $token)
{
$r = Renderer::rnRender2FileCheck($gb, $token);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$status = $r['status'];
$res = array('status' => $status, 'gunid'=>'NULL');
switch($status){
case"fault":
switch ($status) {
case "fault":
$res['faultString'] = "Error runing renderer";
break;
case"success":
case "success":
$r = Renderer::rnRender2StorageCore($gb, $token);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$res['gunid'] = $r['gunid'];
break;
default:
@ -190,33 +190,44 @@ class Renderer
return $res;
}
/**
* Render playlist to storage as audioClip (core method)
* Render playlist to storage as audioClip (core method)
*
* @param gb: greenbox object reference
* @param token: string - render token
* @return hasharray:
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array:
* gunid: string - global unique id of result file
*/
function rnRender2StorageCore(&$gb, $token)
{
$r = $gb->bsRelease($token, 'render');
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$realOgg = $r['realFname'];
$owner = $r['owner'];
$gunid = $r['gunid'];
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$parid = $r = $gb->_getHomeDirId($owner);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) return $r;
$fileName = 'rendered_playlist';
$id = $r = $gb->_idFromGunid($gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$mdata = '';
foreach(array(
foreach (array(
'dc:title', 'dcterms:extent', 'dc:creator', 'dc:description'
) as $item){
) as $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'] : '') : '');
$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";
$id = $r = $gb->bsPutFile($parid, $fileName, $realOgg, $mdata,
NULL, 'audioclip', 'string');
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$ac = $r = StoredFile::recall($gb, $id);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return array('gunid' => $ac->gunid);
}
/**
* Return local filepath of rendered file
* Return local filepath of rendered file
*
* @param gb: greenbox object reference
* @param token: string - render token
* @return hasharray:
* @param Greenbox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
*/
function getLocalFile(&$gb, $token)
{
@ -243,30 +261,37 @@ class Renderer
return "{$gb->accessDir}/$token.".RENDER_EXT;
}
/**
* Return filepath of render status file
* Return filepath of render status file
*
* @param gb: greenbox object reference
* @param token: string - render token
* @return hasharray:
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
*/
function getStatusFile(&$gb, $token)
{
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 token: string - render token
* @return hasharray:
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
*/
function getUrl(&$gb, $token)
{
$token = StoredFile::_normalizeGunid($token);
return $gb->getUrlPart()."access/$token.".RENDER_EXT;
}
}
} // class Renderer
?>

View File

@ -1,6 +1,12 @@
<?php
define('ACCESS_TYPE', 'restore');
/**
* @author $Author: $
* @version $Revision: $
* @package Campcaster
* @subpackage StorageServer
*/
class Restore {
/**
* string - name of logfile
@ -23,69 +29,75 @@ class Restore {
/**
* string - name of temporary directory, to here extract the backup tarball
*/
var $tmpDir;
var $tmpDir;
/**
* string - loglevel
*/
var $loglevel = 'warn';
#var $loglevel = 'debug';
/**
* greenbox object reference
*/
var $gb;
/**
* Constructor
* Constructor
*
* @param gb: greenbox object reference
* @param GreenBox $gb
* greenbox object reference
*/
function Restore (&$gb) {
$this->gb =& $gb;
$this->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
if ($this->loglevel=='debug') {
$this->gb =& $gb;
$this->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
if ($this->loglevel == 'debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
}
}
/**
* Call asyncronly the restore procedure
* Restore from backup.
* Call asyncronously the restore procedure. Restore from backup.
*
* @param sessid : string - session id
* @param backup_file : path of the backup file
* @return hasharray with field:
* @param string $sessid
* session id
* @param string $backup_file
* path of the backup file
* @return array
* hasharray with field:
* token string: backup token
*/
function openRestore($sessid,$backup_file) {
function openRestore($sessid, $backup_file) {
if ($this->loglevel=='debug') {
$this->addLogItem("-I-".date("Ymd-H:i:s")." doRestore - sessid:$sessid\n");
}
$this->sessid = $sessid;
//generate token
$this->token = StoredFile::_createGunid();
// status file -> working
$this->setEnviroment();
file_put_contents($this->statusFile, 'working');
//call the restore script in background
$command = dirname(__FILE__).'/../bin/restore.php';
$runLog = "/dev/null";
$params = "{$backup_file} {$this->statusFile} {$this->token} {$sessid}>> $runLog &";
system("$command $params");
return array('token'=>$this->token);
}
/**
* check the status of restore
* Check the status of restore
*
* @param token : token
* @return hasharray with field:
* @param string $token
* @return array
* hasharray with field:
* status : string - susccess | working | fault
* faultString : string - description of fault
* token : stirng - backup token
@ -93,30 +105,34 @@ class Restore {
* tmpfile : string - access filename
*/
function checkRestore($token) {
if ($this->loglevel=='debug') {
if ($this->loglevel == 'debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
}
$this->token = $token;
$this->setEnviroment();
if (is_file($this->statusFile)) {
$stat = file_get_contents($this->statusFile);
if (strpos($stat,'fault|')!==false) {
if (strpos($stat,'fault|') !== false) {
list($stat,$message) = explode('|',$stat);
}
$r['status'] = $stat;
if ($stat=='fault') $r['faultString'] = $message;
$r['token'] = $token;
$r['status'] = $stat;
if ($stat=='fault') {
$r['faultString'] = $message;
}
$r['token'] = $token;
return $r;
} else {
return PEAR::raiseError('Restore::checkRestore: invalid token!');
}
}
/**
* check the status of restore
* Check the status of restore.
*
* @param token : token
* @return hasharray with field:
* @param string $token
* @return array
* hasharray with field:
* status : boolean - is susccess
*/
function closeRestore($token) {
@ -129,31 +145,35 @@ class Restore {
unlink($this->statusFile);
return !is_file($this->statusFile);
}
/**
* Do restore in background
*
*
* this function is called from the asyncron commandline script
* ../bin/restore.php
*
* @param backupfile : string - path of backupfile
* @param token : string - restore token
* @param sessid : string - session id
* @param string $backupfile
* path of backupfile
* @param string $token
* restore token
* @param string $sessid
* session id
*/
function startRestore($backupfile,$token,$sessid) {
function startRestore($backupfile, $token, $sessid) {
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n");
}
$this->token = $token;
$this->sessid = $sessid;
$this->setEnviroment();
// extract tarball
$command = 'tar -xf '.$backupfile.' --directory '.$this->tmpDir;
$res = system($command);
#$this->addLogItem('command: '.$command."\n");
#$this->addLogItem('res: '.$res."\n");
//simple check of archive format
if (is_dir($this->tmpDir.'audioClip/') &&
is_dir($this->tmpDir.'meta-inf/') &&
@ -164,7 +184,7 @@ class Restore {
//add to storage server
foreach ($this->metafiles as $info) {
$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").
" startRestore - addFileToStorage \n".
"(".$put->getMessage()."/".$put->getUserInfo().")\n"
@ -180,11 +200,13 @@ class Restore {
}
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
* type : stirng - audioClip | playlist
* id : string - the backuped gunid
@ -195,29 +217,34 @@ class Restore {
}
$audioclips = scandir($this->tmpDir.'audioClip/');
$playlists = scandir($this->tmpDir.'playlist/');
for ($i=0;$i<count($audioclips);$i++) {
if (strpos($audioclips[$i],'xml')!==false)
$r[]=array ( 'file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
'type' => 'audioClip',
'id' => str_replace('.xml','',$audioclips[$i]));
for ($i = 0; $i < count($audioclips); $i++) {
if (strpos($audioclips[$i],'xml')!==false)
$r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
'type' => 'audioClip',
'id' => str_replace('.xml','',$audioclips[$i]));
}
for ($i=0;$i<count($playlists);$i++) {
if (strpos($playlists[$i],'xml')!==false)
$r[]=array ( 'file' => $this->tmpDir.'playlist/'.$playlists[$i],
'type' => 'playlist',
'id' => str_replace('.xml','',$playlists[$i]));
for ($i = 0; $i < count($playlists); $i++) {
if (strpos($playlists[$i],'xml') !== false)
$r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i],
'type' => 'playlist',
'id' => str_replace('.xml','',$playlists[$i]));
}
return $r;
}
/**
* Add the file to the storage server
* Add the file to the storage server.
*
* @param file : string - path of metafile
* @param type : string - restore token
* @param sessid : string - session id
*
* @return true if succes or PEAR error
* @param string $file
* path of metafile
* @param string $type
* restore token
* @param string $sessid
* session id
*
* @return mixed
* true if success or PEAR_error
*/
function addFileToStorage($file,$type,$gunid) {
if ($this->loglevel=='debug') {
@ -256,8 +283,12 @@ class Restore {
$parid = $this->gb->_getHomeDirIdFromSess($this->sessid);
#$this->addLogItem("Parid:$parid\n");
$name = $tree->children[0]->children[0]->content;
if(empty($name)) $name = $tree->attrs['title']->val;
if(empty($name)) $name = '???';
if (empty($name)) {
$name = $tree->attrs['title']->val;
}
if (empty($name)) {
$name = '???';
}
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
"$parid, $name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
@ -285,84 +316,99 @@ class Restore {
}
}
$ac = $r = StoredFile::recallByGunid($this->gb, $gunid);
if (PEAR::isError($r)) { return $r; }
if (PEAR::isError($r)) {
return $r;
}
$res = $r = $ac->setState('ready');
if (PEAR::isError($r)) { return $r; }
if (PEAR::isError($r)) {
return $r;
}
return true;
}
/**
* Figure out the enviroment to the backup
* Figure out the environment to the backup.
*
*/
function setEnviroment() {
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n");
}
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.status';
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
$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) {
$f = fopen ($this->logFile,'a');
flock($f,LOCK_SH);
flock($f,LOCK_SH);
fwrite($f,$item);
flock($f,LOCK_UN);
flock($f,LOCK_UN);
fclose($f);
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
}
/**
* Delete a directory recursive
*
* @param dirname : string - path of dir.
*
* @return boolean : is success
* @param string $dirname
* path of dir
*
* @return boolean
* is success
*/
function rRmDir($dirname) {
if(is_dir($dirname))
if (is_dir($dirname)) {
$dir_handle = opendir($dirname);
while($file = readdir($dir_handle)) {
if($file!="." && $file!="..") {
if(!is_dir($dirname."/".$file))
}
while ($file = readdir($dir_handle)) {
if ($file!="." && $file!="..") {
if (!is_dir($dirname."/".$file)) {
unlink ($dirname."/".$file);
else
} else {
Restore::rRmDir($dirname."/".$file);
}
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
/**
* Create a directory recursive
*
* @param dirname : string - path of dir.
* @param mode : octal - rights of dir.
* @param recursive : boolean - do it recursive.
*
* @return boolean
* @param string $dirname
* path of dir.
* @param int $mode
* octal - rights of dir.
* @param boolean $recursive
* do it recursive.
*
* @return boolean
*/
function rMkDir($dirname,$mode=0777,$recursive=true) {
if( is_null($dirname) || $dirname === "" ){
if (is_null($dirname) || $dirname === "" ) {
return false;
}
if( is_dir($dirname) || $dirname === "/" ){
if (is_dir($dirname) || $dirname === "/" ) {
return true;
}
if($this->rMkDir(dirname($dirname), $mode, $recursive)) {
if ($this->rMkDir(dirname($dirname), $mode, $recursive)) {
return mkdir($dirname, $mode);
}
return false;
}
}
} // class Restore
?>

View File

@ -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', ' ');
require_once "XmlParser.php";
/**
* SmilPlaylist class
* SmilPlaylist class
*
* @author $Author: tomash $
* @version $Revision: 1848 $
* @package Campcaster
* @subpackage StorageServer
*/
class SmilPlaylist {
/**
* Parse SMIL file or string
*
* @param data string, local path to SMIL file or SMIL string
* @param loc string, location: 'file'|'string'
* @return array reference, parse result tree (or PEAR::error)
* @param string $data
* local path to SMIL file or SMIL string
* @param string $loc
* location: 'file'|'string'
* @return array
* reference, parse result tree (or PEAR::error)
*/
function &parse($data='', $loc='file')
{
return XmlParser::parse($data, $loc);
}
/**
* Import SMIL file to storage
*
* @param gb reference to GreenBox object
* @param aPath string, absolute path part of imported file
* (e.g. /home/user/livesupport)
* @param rPath string, relative path/filename part of imported file
* (e.g. playlists/playlist_1.smil)
* @param gunids hasharray, hash relation from filenames to gunids
* @param plid string, playlist gunid
* @param parid int, destination folder local id
* @param subjid int, local subject (user) id (id of user doing the import)
* @return instance of Playlist object
* @param GreenBox $gb
* reference to GreenBox object
* @param string $aPath
* absolute path part of imported file (e.g. /home/user/campcaster)
* @param string $rPath
* relative path/filename part of imported file
* (e.g. playlists/playlist_1.smil)
* @param array $gunids
* hash relation from filenames to gunids
* @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');
$path = realpath("$aPath/$rPath");
if(FALSE === $path){
if (FALSE === $path) {
return PEAR::raiseError(
"SmilPlaylist::import: file doesn't exist ($aPath/$rPath)"
);
}
$lspl = $r = SmilPlaylist::convert2lspl(
$gb, $path, $gunids, $parr);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
require_once "Playlist.php";
$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);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$r = $pl->replaceMetaData($lspl, 'string', 'playlist');
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
$r = $pl->unLock($gb);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return $pl;
}
/**
* Import SMIL file to storage
*
* @param gb reference to GreenBox object
* @param data string, local path to SMIL file
* @param gunids hasharray, hash relation from filenames to gunids
* @param parr hasharray, of parid, subjid, aPath, plid, rPath
* @return XML string - playlist in Livesupport playlist format
* @param GreenBox $gb
* @param string $data
* local path to SMIL file
* @param hasharray $gunids
* 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);
$tree = $r = SmilPlaylist::parse($data);
if(PEAR::isError($r)) return $r;
if($tree->name != 'smil'){
if (PEAR::isError($r)) {
return $r;
}
if ($tree->name != 'smil') {
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
}
if(isset($tree->children[1])){
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag smil",
$tree->children[1]->name
@ -112,19 +117,23 @@ class SmilPlaylist {
$gb, $tree->children[0], &$gunids, $parr);
return $res;
}
}
} // SmilPlaylist
/**
* Several auxiliary classes follows
*/
class SmilPlaylistBodyElement{
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
class SmilPlaylistBodyElement {
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
$ind2 = $ind.INDCH;
if($tree->name != 'body'){
if ($tree->name != 'body') {
return PEAR::raiseError("SmilPlaylist::parse: body tag expected");
}
if(isset($tree->children[1])){
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag body",
$tree->children[1]->name
@ -132,8 +141,10 @@ class SmilPlaylistBodyElement{
}
$res = $r = SmilPlaylistParElement::convert2lspl(
$gb, $tree->children[0], &$gunids, $parr, $ind2);
if(PEAR::isError($r)) return $r;
$title = basename($rPath);
if (PEAR::isError($r)) {
return $r;
}
$title = basename($rPath);
$playlength = '0';
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"$ind<playlist id=\"$plid\" playlength=\"$playlength\" title=\"$title\">\n".
@ -142,123 +153,141 @@ class SmilPlaylistBodyElement{
"$ind</playlist>\n";
return $res;
}
}
class SmilPlaylistParElement{
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
} // class SmilPlaylistBodyElement
class SmilPlaylistParElement {
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
if($tree->name != 'par'){
if ($tree->name != 'par') {
return PEAR::raiseError("SmilPlaylist::parse: par tag expected");
}
$res = '';
foreach($tree->children as $i=>$ch){
foreach ($tree->children as $i => $ch) {
$ch =& $tree->children[$i];
$r = SmilPlaylistAudioElement::convert2lspl(
$gb, $ch, &$gunids, $parr, $ind.INDCH);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$res .= $r;
}
return $res;
}
}
class SmilPlaylistAudioElement{
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
class SmilPlaylistAudioElement {
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
$uri = $tree->attrs['src']->val;
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
$ind2 = $ind.INDCH;
if($tree->name != 'audio'){
if ($tree->name != 'audio') {
return PEAR::raiseError("SmilPlaylist::parse: audio tag expected");
}
if(isset($tree->children[2])){
if (isset($tree->children[2])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag audio",
$tree->children[2]->name
));
}
$res = ''; $fadeIn = 0; $fadeOut = 0;
foreach($tree->children as $i=>$ch){
foreach ($tree->children as $i => $ch) {
$ch =& $tree->children[$i];
$r = SmilPlaylistAnimateElement::convert2lspl(
$gb, $ch, &$gunids, $parr, $ind2);
if(PEAR::isError($r)) return $r;
switch($r['type']){
case"fadeIn": $fadeIn = $r['val']; break;
case"fadeOut": $fadeOut = $r['val']; break;
if (PEAR::isError($r)) {
return $r;
}
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();
$fadeIn = Playlist::_secsToPlTime($fadeIn);
$fadeOut = Playlist::_secsToPlTime($fadeOut);
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
}else $fInfo = '';
} else {
$fInfo = '';
}
$plElGunid = StoredFile::_createGunid();
$acGunid = $gunid;
$type = 'audioClip';
if(preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)){
switch(strtolower($ext = $va[1])){
case"lspl":
case"xml":
case"smil":
case"m3u":
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
switch (strtolower($ext = $va[1])) {
case "lspl":
case "xml":
case "smil":
case "m3u":
$type = 'playlist';
$acId = $r = $gb->bsImportPlaylistRaw($parid, $gunid,
$aPath, $uri, $ext, $gunids, $subjid);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
//break;
default:
$ac = $r = StoredFile::recallByGunid($gb, $gunid);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$r = $ac->md->getMetadataEl('dcterms:extent');
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
$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".
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
$fInfo.
"$ind</playlistElement>\n";
return $res;
}
}
} // class SmilPlaylistAudioElement
class SmilPlaylistAnimateElement{
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind=''){
class SmilPlaylistAnimateElement {
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
if($tree->name != 'animate'){
if ($tree->name != 'animate') {
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['to']->val == '100%' &&
$tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' &&
$tree->attrs['begin']->val == '0s' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
){
) {
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['to']->val == '0%' &&
$tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
){
) {
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
}
return PEAR::raiseError(
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
);
}
}
} // class SmilPlaylistAnimateElement
?>
?>

View File

@ -1,32 +1,4 @@
<?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 "MetaData.php";
require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
@ -34,40 +6,46 @@ require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
/**
* 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:
* <ul>
* <li>metada in database - represented by MetaData class</li>
* <li>binary media data in real file
* - represented by RawMediaData class</li>
* </ul>
* @see GreenBox
* @see MetaData
* @see RawMediaData
*
* @author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @see GreenBox
* @see MetaData
* @see RawMediaData
*/
class StoredFile {
/* ========================================================== constructor */
/**
* Constructor, but shouldn't be externally called
*
* @param reference $gb to GreenBox object
* @param string $gunid, optional, globally unique id of file
* @param GreenBox $gb
* @param string $gunid
* optional, globally unique id of file
* @return this
*/
function StoredFile(&$gb, $gunid=NULL)
{
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
$this->filesTable = $gb->filesTable;
$this->accessTable= $gb->accessTable;
$this->gunid = $gunid;
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
$this->filesTable = $gb->filesTable;
$this->accessTable= $gb->accessTable;
$this->gunid = $gunid;
if (is_null($this->gunid)) {
$this->gunid = $this->_createGunid();
}
$this->resDir = $this->_getResDir($this->gunid);
$this->accessDir = $this->gb->accessDir;
$this->rmd =& new RawMediaData($this->gunid, $this->resDir);
$this->md =& new MetaData($gb, $this->gunid, $this->resDir);
$this->resDir = $this->_getResDir($this->gunid);
$this->accessDir = $this->gb->accessDir;
$this->rmd =& new RawMediaData($this->gunid, $this->resDir);
$this->md =& new MetaData($gb, $this->gunid, $this->resDir);
# return $this->gunid;
}
@ -76,16 +54,24 @@ class StoredFile {
/**
* Create instance of StoredFile object and insert new file
*
* @param reference $gb to GreenBox object
* @param int $oid, local object id in the tree
* @param string $name, name of new file
* @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' (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 instance of StoredFile object
* @param GreenBox $gb
* @param int $oid
* local object id in the tree
* @param string $name
* name of new file
* @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' (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,
$mediaFileLP='', $metadata='', $mdataLoc='file',
@ -171,14 +157,17 @@ class StoredFile {
/**
* Create instance of StoreFile object and recall existing file.<br>
* Should be supplied oid XOR gunid - not both ;)
* Create instance of StoreFile object and recall existing file.<br>
* Should be supplied oid XOR gunid - not both ;)
*
* @param reference $gb to GreenBox object
* @param int $oid, optional, local object id in the tree
* @param string $gunid, optional, global unique id of file
* @param string $className, optional classname to recall
* @return instance of StoredFile object
* @param GreenBox $gb
* @param int $oid
* optional, local object id in the tree
* @param string $gunid
* optional, global unique id of file
* @param string $className
* optional classname to recall
* @return StoredFile
*/
function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
{
@ -210,13 +199,15 @@ class StoredFile {
/**
* Create instance of StoreFile object and recall existing file
* by gunid.<br/>
* Create instance of StoreFile object and recall existing file
* by gunid.
*
* @param reference $gb to GreenBox object
* @param string $gunid, optional, global unique id of file
* @param string $className, optional classname to recall
* @return instance of StoredFile object
* @param GreenBox $gb
* @param string $gunid
* optional, global unique id of file
* @param string $className
* optional classname to recall
* @return StoredFile
*/
function &recallByGunid(&$gb, $gunid='', $className='StoredFile')
{
@ -225,13 +216,15 @@ class StoredFile {
/**
* Create instance of StoreFile object and recall existing file
* by access token.<br/>
* Create instance of StoreFile object and recall existing file
* by access token.
*
* @param reference $gb to GreenBox object
* @param string $token, access token
* @param string $className, optional classname to recall
* @return instance of StoredFile object
* @param GreenBox $gb
* @param string $token
* access token
* @param string $className
* optional classname to recall
* @return 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 int $nid, new local id
* @param reference $src to source object
* @param int $nid
* new local id
* @return unknown
*/
function &copyOf(&$src, $nid)
{
@ -276,11 +271,16 @@ class StoredFile {
/**
* Replace existing file with new data
*
* @param int $oid, local id
* @param string $name, name of file
* @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'
* @param int $oid
* local id
* @param string $name
* name of file
* @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='',
$mdataLoc='file')
@ -319,16 +319,18 @@ class StoredFile {
/**
* Increase access counter, create access token, insert access record,
* call access method of RawMediaData
* Increase access counter, create access token, insert access record,
* call access method of RawMediaData
*
* @param int $parent parent token
* @return array with: access URL, access token
* @param int $parent
* parent token
* @return array
* array with: access URL, access token
*/
function accessRawMediaData($parent='0')
{
$realFname = $this->_getRealRADFname();
$ext = $this->_getExt();
$realFname = $this->_getRealRADFname();
$ext = $this->_getExt();
$res = $this->gb->bsAccess($realFname, $ext, $this->gunid, 'access', $parent);
if (PEAR::isError($res)) {
return $res;
@ -340,11 +342,12 @@ class StoredFile {
/**
* Decrease access couter, delete access record,
* call release method of RawMediaData
* Decrease access couter, delete access record,
* call release method of RawMediaData
*
* @param string $token, access token
* @return boolean
* @param string $token
* access token
* @return boolean
*/
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)
{
@ -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 $mdataLoc 'file'|'string'
* @param string $format, metadata format for validation
* @param string $metadata
* local path to metadata XML file or XML string
* @param string $mdataLoc
* 'file'|'string'
* @param string $format
* metadata format for validation
* ('audioclip' | 'playlist' | 'webstream' | NULL)
* (NULL = no validation)
* @return boolean
* @return boolean
*/
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
* @see MetaData
* @return XML string
* @see MetaData
*/
function getMetaData()
{
@ -425,12 +432,12 @@ class StoredFile {
/**
* Analyze file with getid3 module.<br>
* Obtain some metadata stored in media file.<br>
* This method should be used for prefilling metadata input form.
* Analyze file with getid3 module.<br>
* Obtain some metadata stored in media file.<br>
* This method should be used for prefilling metadata input form.
*
* @return array
* @see MetaData
* @return array
* @see MetaData
*/
function analyzeMediaFile()
{
@ -440,10 +447,11 @@ class StoredFile {
/**
* Rename stored virtual file
* Rename stored virtual file
*
* @param string $newname
* @return true or PEAR::error
* @param string $newname
* @return mixed
* true or PEAR::error
*/
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 int $editedby, user id | 'NULL' for clear editedBy field
* @param string $state
* 'empty'|'incomplete'|'ready'|'edited'
* @param int $editedby
* user id | 'NULL' for clear editedBy field
* (optional)
* @return boolean or error
* @return boolean or error
*/
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
* @return boolean or error
* @param string $mime
* mime-type
* @return boolean or error
*/
function setMime($mime)
{
@ -504,10 +515,10 @@ class StoredFile {
/**
* Delete stored virtual file
* Delete stored virtual file
*
* @see RawMediaData
* @see MetaData
* @see RawMediaData
* @see MetaData
*/
function delete()
{
@ -550,10 +561,11 @@ class StoredFile {
/**
* Returns true if virtual file is accessed.<br>
* Static or dynamic call is possible.
* Returns true if virtual file is accessed.<br>
* 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)
{
@ -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
* @return boolean
* @param string $playlistId
* playlist global unique ID
* @return boolean
*/
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
* @return null or int, id of user editing it
* @param string $playlistId
* playlist global unique ID
* @return null or int
* id of user editing it
*/
function isEditedBy($playlistId=NULL)
{
@ -660,7 +675,7 @@ class StoredFile {
{
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
$initString =
microtime().$ip.rand()."org.mdlf.livesupport";
microtime().$ip.rand()."org.mdlf.campcaster";
$hash = md5($initString);
// non-negative int8
$hsd = substr($hash, 0, 1);
@ -680,11 +695,11 @@ class StoredFile {
/**
* Get local id from global id.
* Static or dynamic call is possible.
* Get local id from global id.
* Static or dynamic call is possible.
*
* @param string $gunid, optional (for static call),
* global unique id of file
* @param string $gunid
* optional (for static call), global unique id of file
*/
function _idFromGunid($gunid=NULL)
{
@ -705,10 +720,12 @@ class StoredFile {
/**
* Return suitable extension.<br>
* <b>TODO: make it general - is any tool for it?</b>
* Return suitable extension.
*
* @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()
{
@ -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
* @return string, mime-type
* @param string $gunid
* optional, global unique id of file
* @return string
* mime-type
*/
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
* @return string, see install()
* @param string $gunid
* optional, global unique id of file
* @return string
* see install()
*/
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
* @return string, see install()
* @param string $gunid
* optional, global unique id of file
* @return string
* see install()
*/
function _getFileName($gunid=NULL)
{
@ -795,8 +818,8 @@ class StoredFile {
/**
* Get and optionaly create subdirectory in real filesystem for storing
* raw media data
* Get and optionaly create subdirectory in real filesystem for storing
* raw media data
*
*/
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()
{
@ -824,9 +847,9 @@ class StoredFile {
/**
* Get real filename of metadata file
* Get real filename of metadata file
*
* @see MetaData
* @see MetaData
*/
function _getRealMDFname()
{
@ -835,9 +858,9 @@ class StoredFile {
/**
* Create and return name for temporary symlink.<br>
* <b>TODO: Should be more unique</b>
* Create and return name for temporary symlink.
*
* @todo Should be more unique
*/
function _getAccessFname($token, $ext='EXT')
{

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,15 @@
<?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);
/**
* Auxiliary class for ransport records
* Auxiliary class for transport records
*
**/
* @author $Author: tomash $
* @version $Revision: 1946 $
* @package Campcaster
* @subpackage StorageServer
*/
class TransportRecord
{
var $dbc;
@ -42,26 +19,30 @@ class TransportRecord
/**
* Constructor
*
* @param tr Transport object reference
* @return TransportRecord object instance
* @param Transport $tr object reference
* @return TransportRecord object instance
*/
function TransportRecord(&$tr)
{
$this->tr =& $tr;
$this->gb =& $tr->gb;
$this->dbc =& $tr->gb->dbc;
$this->config = $tr->gb->config;
$this->tr =& $tr;
$this->gb =& $tr->gb;
$this->dbc =& $tr->gb->dbc;
$this->config = $tr->gb->config;
$this->transTable = $tr->gb->config['tblNamePrefix'].'trans';
}
/**
* Factory method
*
* @param tr: Transport object reference
* @param trtype: string transport type (see Transport::install)
* @param direction: string - 'up' | 'down'
* @param defaults: array - default parameters (optional, internal use)
* @return TransportRecord instance
* @param Transport $tr
* @param string $trtype
* transport type (see Transport::install)
* @param string $direction
* 'up' | 'down'
* @param array $defaults
* default parameters (optional, internal use)
* @return TransportRecord
*/
function create(&$tr, $trtype, $direction='up', $defaults=array())
{
@ -70,16 +51,18 @@ class TransportRecord
$trec->row = array_merge($defaults,
array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE;
if(!isset($defaults['title'])){
if (!isset($defaults['title'])) {
$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");
$names = "id, trtok, direction, state, trtype, start, ts";
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
foreach($defaults as $k=>$v){
foreach ($defaults as $k=>$v) {
$sqlVal = $trec->_getSqlVal($k, $v);
$names .= ", $k";
$names .= ", $k";
$values .= ", $sqlVal";
}
$res = $r = $trec->dbc->query("
@ -88,16 +71,20 @@ class TransportRecord
VALUES
($values)
");
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return $trec;
}
/**
* Recall transport record from DB
*
* @param tr: Transport object reference
* @param trtok: string - transport token
* @return TransportRecord instance
* @param Transport $tr
* @param string $trtok
* transport token
* @return TransportRecord
*/
function recall(&$tr, $trtok)
{
@ -113,8 +100,10 @@ class TransportRecord
FROM {$trec->transTable}
WHERE trtok='$trtok'
");
if(PEAR::isError($r)){ return $r; }
if(is_null($row)){
if (PEAR::isError($r)) {
return $r;
}
if (is_null($row)) {
return PEAR::raiseError("TransportRecord::recall:".
" invalid transport token ($trtok)", TRERR_TOK
);
@ -125,26 +114,30 @@ class TransportRecord
$trec->recalled = TRUE;
return $trec;
}
/**
* Set state of transport record
*
* @param newState: string
* @param data: array - other data fields to set
* @param oldState: string, (opt.) check old state and do nothing if differ
* @param lock: boolean, (opt.) check lock and do nothing if differ
* @return boolean success
*
* @param string $newState
* @param array $data
* other data fields to set
* @param string $oldState
* (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)
{
$set = " state='$newState', ts=now()";
if(!is_null($lock)){
if (!is_null($lock)) {
$slock = ($lock ? 'Y' : 'N');
$nlock = (!$lock);
$snlock = ($nlock ? 'Y' : 'N');
$set .= ", lock='$snlock'";
}
foreach($data as $k=>$v){
foreach ($data as $k => $v) {
$set .= ", $k=".$this->_getSqlVal($k, $v);
}
$r = $this->dbc->query("
@ -154,37 +147,48 @@ class TransportRecord
(is_null($oldState) ? '' : " AND state='$oldState'").
(is_null($lock) ? '' : " AND lock = '$slock'")
);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
// return TRUE;
$affRows = $r = $this->dbc->affectedRows();
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
return ($affRows == 1);
}
/**
* Return state of transport record
* Return state of transport record
*
* @return string - state
* @return string
* state
*/
function getState()
{
if(!$this->recalled){
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::getState:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
return $this->row['state'];
}
/**
* Set lock on transport record
* Set lock on transport record
*
* @param lock: boolean - lock if true, release lock if false
* @return boolean true or error
* @param boolean $lock
* lock if true, release lock if false
* @return mixed
* true or error
*/
function setLock($lock)
{
if($this->dropped) return TRUE;
if ($this->dropped) {
return TRUE;
}
$slock = ($lock ? 'Y' : 'N');
$nlock = (!$lock);
$snlock = ($nlock ? 'Y' : 'N');
@ -193,10 +197,14 @@ class TransportRecord
SET lock='$slock', ts=now()
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
);
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
$affRows = $r = $this->dbc->affectedRows();
if(PEAR::isError($r)){ return $r; }
if($affRows != 1){
if (PEAR::isError($r)) {
return $r;
}
if ($affRows != 1) {
$ltxt = ($lock ? 'lock' : 'unlock' );
return PEAR::raiseError(
"TransportRecord::setLock: can't $ltxt ({$this->trtok})"
@ -204,83 +212,100 @@ class TransportRecord
}
return TRUE;
}
/**
* Return type of transport
* Return type of transport
*
* @return string - trtype
* @return string
* Transport type
*/
function getTransportType()
{
if(!$this->recalled){
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::getTransportType:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
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 eo: PEAR error object - (opt.) error msg can be construct from it
* @return boolean true or error
* @param string $txt
* base part of error message
* @param PEAR_Error $eo
* (opt.) error msg can be construct from it
* @return mixed
* boolean true or error
*/
function fail($txt='', $eo=NULL)
{
if(!$this->recalled){
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::fail:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
$msg = $txt;
if(!is_null($eo)){
if (!is_null($eo)) {
$msg .= $eo->getMessage()." ".$eo->getUserInfo().
" [".$eo->getCode()."]";
}
$r = $this->setState('failed', array('errmsg'=>$msg));
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
}
/**
* Close transport record
* Close transport record
*
* @return boolean true or error
* @return mixed
* boolean true or error
*/
function close()
{
if(!$this->recalled){
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::close:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
if(TR_LEAVE_CLOSED){
if (TR_LEAVE_CLOSED) {
$r = $this->setState('closed');
if(PEAR::isError($r)){ return $r; }
}else{
if (PEAR::isError($r)) {
return $r;
}
} else {
$r = $this->dbc->query("
DELETE FROM {$this->transTable}
WHERE trtok='{$this->trtok}'
");
if(PEAR::isError($r)){ return $r; }
if (PEAR::isError($r)) {
return $r;
}
$this->recalled = FALSE;
$this->dropped = 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 fldVal: mixed - field value
* @return string
* @param string $fldName
* field name
* @param mixed $fldVal
* field value
* @return string
*/
function _getSqlVal($fldName, $fldVal)
{
switch($fldName){
switch ($fldName) {
case 'realsize':
case 'expectedsize':
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()
{
$defStr = 'unknown';
$trtype = $r = $this->getTransportType(); //contains recall check
if(PEAR::isError($r)){ return $r; }
switch($trtype){
case"audioclip":
case"playlist":
case"playlistPkg":
case"metadata":
if (PEAR::isError($r)) {
return $r;
}
switch ($trtype) {
case "audioclip":
case "playlist":
case "playlistPkg":
case "metadata":
$title = $r = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
if(PEAR::isError($r)){
if($r->getCode()==GBERR_FOBJNEX) $title = $defStr;
else return $r;
if (PEAR::isError($r)) {
if ($r->getCode()==GBERR_FOBJNEX) {
$title = $defStr;
} else {
return $r;
}
}
break;
case"searchjob":
case "searchjob":
$title = 'searchjob';
break;
case"file":
case "file":
$title = ( isset($this->row['localfile']) ?
basename($this->row['localfile']) : 'regular file');
break;
default: $title = $defStr;
default:
$title = $defStr;
}
return $title;
}
}
} // class TransportRecord
?>

View File

@ -1,32 +1,4 @@
<?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_NOREQE', 111);
define('VAL_NOONEOF', 112);
@ -50,8 +22,13 @@ define('VAL_PREDXML', 121);
* <li>playlistFormat.php</li>
* </ul>
* 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
*/
@ -64,12 +41,15 @@ class Validator{
* string - gunid of validated file for identification in mass input
*/
var $gunid = NULL;
/**
* Constructor
* Constructor
*
* @param format string - format type of validated document
* @param gunid string - gunid of validated file for identification
* in mass input
* @param string $format
* format type of validated document
* @param string $gunid
* gunid of validated file for identification in mass input
*/
function Validator($format, $gunid)
{
@ -81,19 +61,26 @@ class Validator{
'playlist' => "playlistFormat",
'webstream' => "webstreamFormat",
);
if(!isset($formats[$format])) return $this->_err(VAL_FORMAT);
if (!isset($formats[$format])) {
return $this->_err(VAL_FORMAT);
}
$formatName = $formats[$format];
$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;
$this->formTree = $$formatName;
}
/**
* Validate document - only wrapper for validateNode method
* Validate document - only wrapper for validateNode method
*
* @param data object, validated object tree
* @return TRUE or PEAR::error
* @param object $data
* validated object tree
* @return mixed
* TRUE or PEAR::error
*/
function validate(&$data)
{
@ -101,162 +88,205 @@ class Validator{
return $r;
}
/**
* Validate one metadata value (on insert/update)
* Validate one metadata value (on insert/update)
*
* @param fname string - parent element name
* @param category string - qualif.category name
* @param predxml string - 'A' | 'T' (attr or tag)
* @param value string - validated element value
* @return TRUE or PEAR::error
* @param string $fname
* parent element name
* @param string $category
* qualif.category name
* @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)
{
$formTree =& $this->formTree;
switch($predxml){
case'T':
if(!$this->isChildInFormat($fname, $category))
switch ($predxml) {
case 'T':
if (!$this->isChildInFormat($fname, $category)) {
return $this->_err(VAL_UNKNOWNE, "$category in $fname");
}
break;
case'A':
if(!$this->isAttrInFormat($fname, $category))
case 'A':
if (!$this->isAttrInFormat($fname, $category)) {
return $this->_err(VAL_UNKNOWNA, "$category in $fname");
}
break;
case'N':
case 'N':
return TRUE;
break;
default:
return $this->_err(VAL_PREDXML, $predxml);
}
if(isset($formTree[$category]['regexp'])){
if (isset($formTree[$category]['regexp'])) {
// 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");
}
}
}
/**
* Validation of one element node from object tree
* Validation of one element node from object tree
*
* @param node object - validated node
* @param fname string - aktual name in format structure
* @return TRUE or PEAR::error
* @param object $node
* validated node
* @param string $fname
* actual name in format structure
* @return mixed
* TRUE or PEAR::error
*/
function validateNode(&$node, $fname)
{
$dname = (($node->ns? $node->ns.":" : '').$node->name);
$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:
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:
if(!isset($formTree[$fname])) return $this->_err(VAL_NOTDEF, $fname);
if (!isset($formTree[$fname])) {
return $this->_err(VAL_NOTDEF, $fname);
}
// check element content
if(isset($formTree[$fname]['regexp'])){
if (isset($formTree[$fname]['regexp'])) {
// 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}");
}
}
// validate attributes:
$ra = $this->validateAttributes($node, $fname);
if(PEAR::isError($ra)) return $ra;
if (PEAR::isError($ra)) {
return $ra;
}
// validate children:
$r = $this->validateChildren($node, $fname);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
}
/**
* Validation of attributes
* Validation of attributes
*
* @param node object - validated node
* @param fname string - aktual name in format structure
* @return TRUE or PEAR::error
* @param object $node
* validated node
* @param string $fname
* actual name in format structure
* @return mixed
* TRUE or PEAR::error
*/
function validateAttributes(&$node, $fname)
{
$formTree =& $this->formTree;
$attrs = array();
// 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);
$attrs[$aname] =& $node->attrs[$i];
if(!$this->isAttrInFormat($fname, $aname))
if (!$this->isAttrInFormat($fname, $aname)) {
return $this->_err(VAL_UNKNOWNA, $aname);
}
// check attribute format
// echo "XXA $aname\n";
if(isset($formTree[$aname]['regexp'])){
if (isset($formTree[$aname]['regexp'])) {
// 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)."]");
}
}
}
// check if all required attrs are here:
if(isset($formTree[$fname]['attrs'])){
if (isset($formTree[$fname]['attrs'])) {
$fattrs =& $formTree[$fname]['attrs'];
if(isset($fattrs['required'])){
foreach($fattrs['required'] as $i=>$attr){
if(!isset($attrs[$attr]))
if (isset($fattrs['required'])) {
foreach ($fattrs['required'] as $i => $attr) {
if (!isset($attrs[$attr])) {
return $this->_err(VAL_NOREQA, $attr);
}
}
}
}
return TRUE;
}
/**
* Validation children nodes
* Validation children nodes
*
* @param node object - validated node
* @param fname string - aktual name in format structure
* @return TRUE or PEAR::error
* @param object $node
* validated node
* @param string $fname
* actual name in format structure
* @return mixed
* TRUE or PEAR::error
*/
function validateChildren(&$node, $fname)
{
$formTree =& $this->formTree;
$childs = array();
// 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);
// echo "XXE $chname\n";
if(!$this->isChildInFormat($fname, $chname))
if (!$this->isChildInFormat($fname, $chname)) {
return $this->_err(VAL_UNKNOWNE, $chname);
}
// call children recursive:
$r = $this->validateNode($node->children[$i], $chname);
if(PEAR::isError($r)) return $r;
if (PEAR::isError($r)) {
return $r;
}
$childs[$chname] = TRUE;
}
// check if all required children are here:
if(isset($formTree[$fname]['childs'])){
if (isset($formTree[$fname]['childs'])) {
$fchilds =& $formTree[$fname]['childs'];
if(isset($fchilds['required'])){
foreach($fchilds['required'] as $i=>$ch){
if(!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
if (isset($fchilds['required'])) {
foreach ($fchilds['required'] as $i => $ch) {
if (!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
}
}
// required one from set
if(isset($fchilds['oneof'])){
if (isset($fchilds['oneof'])) {
$one = FALSE;
foreach($fchilds['oneof'] as $i=>$ch){
if(isset($childs[$ch])){
if($one) return $this->_err(
VAL_UNEXPONEOF, "$ch in $fname");
foreach ($fchilds['oneof'] as $i => $ch) {
if (isset($childs[$ch])) {
if ($one) {
return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
}
$one = TRUE;
}
}
if(!$one) return $this->_err(VAL_NOONEOF);
if (!$one) {
return $this->_err(VAL_NOONEOF);
}
}
}
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 chname string - child node name
* @return boolean
* @param string $fname
* node name in format structure
* @param string $chname
* child node name
* @return boolean
*/
function isChildInFormat($fname, $chname)
{
@ -266,12 +296,15 @@ class Validator{
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 aname string - attribute name
* @return boolean
* @param string $fname
* node name in format structure
* @param string $aname
* attribute name
* @return boolean
*/
function isAttrInFormat($fname, $aname)
{
@ -281,17 +314,23 @@ class Validator{
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 chname string - node/attribute name
* @param nType string - 'childs' | 'attrs'
* @param reqType string - <ul>
* @param string $fname
* node name in format structure
* @param string $chname
* node/attribute name
* @param string $nType
* 'childs' | 'attrs'
* @param string $reqType
* <ul>
* <li>for elements: 'required' | 'optional' | 'oneof'</li>
* <li>for attributes: 'required' | 'implied' | 'normal'</li>
* </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')
{
@ -304,12 +343,15 @@ class Validator{
return $listed;
}
/**
* Error exception generator
* Error exception generator
*
* @param errno int - erron code
* @param par string - optional string for more descriptive error messages
* @return PEAR::error
* @param int $errno
* erron code
* @param string $par
* optional string for more descriptive error messages
* @return PEAR_Error
*/
function _err($errno, $par='')
{
@ -333,16 +375,7 @@ class Validator{
);
}
/**
*
*
* @param
* @return
* /
function ()
{
}
*/
}
?>
} // class Validator
?>

View File

@ -1,39 +1,22 @@
<?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$
------------------------------------------------------------------------------*/
/**
* @author $Author$
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
*/
require_once "XML/Util.php";
/* ================================================================== 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 {
/**
@ -47,27 +30,31 @@ class XmlElement {
/**
* Attributes
*/
var $attrs = array();
var $attrs = array();
/**
* Namespace definitions
*/
var $nSpaces = array();
var $nSpaces = array();
/**
* Child nodes
*/
var $children = array();
var $children = array();
/**
* Text content of element
*/
var $content = '';
var $content = '';
/**
* Constructor
*
* @param fullname string, fully qualified name of element
* @param attrs hash of attributes
* @param nSpaces hash of namespace definitions
* @param children hash of child nodes
* @param string $fullname
* Fully qualified name of element
* @param array $attrs
* hash of attributes
* @param array $nSpaces
* hash of namespace definitions
* @param array $children
* hash of child nodes
* @return this
*/
function XmlElement($fullname, $attrs, $nSpaces=array(), $children=array())
@ -79,13 +66,16 @@ class XmlElement {
$this->nSpaces = $nSpaces;
$this->children = $children;
}
}
} // class XmlElement
/* ================================================================ Attribute */
/**
* Object representation of one XML attribute
* Object representation of one XML attribute
*
* @see MetaData
* @package Campcaster
* @subpackage StorageServer
* @see MetaData
*/
class XmlAttrib {
/**
@ -103,9 +93,12 @@ class XmlAttrib {
/**
* Constructor
*
* @param atns string, namespace prefix
* @param atnm string, attribute name
* @param atv string, attribute value
* @param string $atns
* namespace prefix
* @param string $atnm
* attribute name
* @param string $atv
* attribute value
* @return this
*/
function XmlAttrib($atns, $atnm, $atv)
@ -114,12 +107,15 @@ class XmlAttrib {
$this->name = $atnm;
$this->val = $atv;
}
}
} // fn XmlAttrib
/* =================================================================== Parser */
/**
* XML parser object encapsulation
*
* @package Campcaster
* @subpackage StorageServer
* @see MetaData
*/
class XmlParser {
@ -135,10 +131,12 @@ class XmlParser {
* Error structure
*/
var $err = array(FALSE, '');
/**
* Constructor
*
* @param data string, XML string to be parsed
* @param string $data
* XML string to be parsed
* @return this
*/
function XmlParser($data){
@ -148,7 +146,7 @@ class XmlParser {
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_parser, 'characterData');
$res = xml_parse($xml_parser, $data, TRUE);
if(!$res) {
if (!$res) {
$this->err = array(TRUE,
sprintf("XML error: %s at line %d\n",
xml_error_string(xml_get_error_code($xml_parser)),
@ -160,65 +158,73 @@ class XmlParser {
xml_parser_free($xml_parser);
}
/**
* Parse XML file or string
*
* @param data string, local path to XML file or XML string
* @param loc string, location: 'file'|'string'
* @return array reference, parse result tree (or PEAR::error)
* @param string $data
* local path to XML file or XML string
* @param string $loc
* location: 'file'|'string'
* @return array
* reference, parse result tree (or PEAR::error)
*/
function &parse($data='', $loc='file')
{
switch($loc){
case"file":
if(!is_file($data)){
return PEAR::raiseError(
"XmlParser::parse: file not found ($data)"
);
}
if(!is_readable($data)){
return PEAR::raiseError(
"XmlParser::parse: can't read file ($data)"
);
}
$data = file_get_contents($data);
case"string":
$parser =& new XmlParser($data);
if($parser->isError()){
return PEAR::raiseError(
"SmilPlaylist::parse: ".$parser->getError()
);
}
$tree = $parser->getTree();
break;
default:
return PEAR::raiseError(
"XmlParser::parse: unsupported source location ($loc)"
);
switch ($loc) {
case "file":
if (!is_file($data)) {
return PEAR::raiseError(
"XmlParser::parse: file not found ($data)"
);
}
if (!is_readable($data)) {
return PEAR::raiseError(
"XmlParser::parse: can't read file ($data)"
);
}
$data = file_get_contents($data);
case "string":
$parser =& new XmlParser($data);
if ($parser->isError()) {
return PEAR::raiseError(
"SmilPlaylist::parse: ".$parser->getError()
);
}
$tree = $parser->getTree();
break;
default:
return PEAR::raiseError(
"XmlParser::parse: unsupported source location ($loc)"
);
}
return $tree;
}
/**
* Start tag handler
* Start tag handler
*
* @param parser resource, reference to parser resource
* @param fullname string element name
* @param attrs array of attributes
* @return none
* @param resource $parser
* reference to parser resource
* @param string $fullname
* element name
* @param array $attrs
* array of attributes
* @return none
*/
function startTag($parser, $fullname, $attrs) {
$nSpaces = array();
foreach($attrs as $atn=>$atv){
foreach ($attrs as $atn => $atv) {
$a = XML_Util::splitQualifiedName($atn);
$atns = $a['namespace'];
$atnm = $a['localPart'];
unset($attrs[$atn]);
if($atns == 'xmlns') $nSpaces[$atnm] = $atv;
else if ($atns == NULL && $atnm == 'xmlns'){
if ($atns == 'xmlns') {
$nSpaces[$atnm] = $atv;
} else if ($atns == NULL && $atnm == 'xmlns') {
$nSpaces[''] = $atv;
}else{
} else {
$attrs[$atn] = new XmlAttrib($atns, $atnm, $atv);
}
}
@ -226,41 +232,50 @@ class XmlParser {
array_push($this->stack, $el);
}
/**
* End tag handler
*
* @param parser resource, reference to parser resource
* @param fullname string element name
* @param resource $parser
* reference to parser resource
* @param string $fullname
* element name
* @return none
*/
function endTag($parser, $fullname) {
$cnt = count($this->stack);
if($cnt>1){
if ($cnt > 1) {
$this->stack[$cnt-2]->children[] = $this->stack[$cnt-1];
$lastEl = array_pop($this->stack);
}else{
} else {
$this->tree = $this->stack[0];
}
}
/**
* Character data handler
* Character data handler
*
* @param parser resource, reference to parser resource
* @param data string
* @return none
* @param resource $parser
* reference to parser resource
* @param string $data
* @return none
*/
function characterData($parser, $data) {
$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 data string
* @return none
* @param resource $parser
* reference to parser resource
* @param string $data
* @return none
*/
function defaultHandler($parser, $data)
{
@ -272,46 +287,58 @@ class XmlParser {
//}
}
/**
* Return result tree
*
* @return hash, tree structure
* @return array
* tree structure
*/
function getTree(){
function getTree()
{
return $this->tree;
}
/**
* Return error string
*
* @return boolean if error occured
*/
function isError(){
return $this->err[0];
}
/**
* 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];
}
/* ----------------------------------- auxiliary methos for serialization */
/**
* Serialize metadata of one file
*
* @return string, serialized XML
*/
function serialize(){
function serialize()
{
$res = '<?xml version="1.0" encoding="utf-8"?>';
$res .= $this->serializeEl($this->tree);
$res .= "\n";
return $res;
}
/**
* Serialize one metadata element
*
@ -319,7 +346,8 @@ class XmlParser {
* @param lvl int, level for indentation
* @return string, serialized XML
*/
function serializeEl($el, $lvl=0){
function serializeEl($el, $lvl=0)
{
$ind = str_repeat(" ", $lvl);
$elNs = $el->ns;
$elName = $el->name;
@ -327,22 +355,26 @@ class XmlParser {
$fullName = ($elNs=='' ? '' : "$elNs:")."$elName";
$res = "\n{$ind}<{$fullName}{$attrs}>";
$haveCh = (count($el->children)>0);
foreach($el->children as $ch){
foreach ($el->children as $ch) {
$res .= $this->serializeEl($ch, $lvl+1);
}
$res .= XML_Util::replaceEntities("{$el->content}");
if($haveCh) $res .= "\n{$ind}";
if ($haveCh) {
$res .= "\n{$ind}";
}
$res .= "</{$fullName}>";
return $res;
}
/* -------------------------------------------------------- debug methods */
/**
* Debug dump of tree
*
* @return hash, tree structure
*/
function dump(){
function dump()
{
var_dump($this->tree);
}

View File

@ -1,32 +1,9 @@
<?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$
------------------------------------------------------------------------------*/
/**
* @author $Author$
* @version $Revision$
*
*/
$audioClipFormat = array(
'_root'=>'audioClip',
@ -343,7 +320,7 @@ $audioClipFormat = array(
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:filename'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
@ -365,4 +342,4 @@ $audioClipFormat = array(
?
ls:filename Text auto
*/
?>
?>

View File

@ -1,38 +1,12 @@
<?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('PHP5', version_compare( phpversion(), "5.0.0", ">=" ));
@ -75,7 +49,7 @@ $config = array(
'password' => 'test',
'hostspec' => 'localhost',
'phptype' => 'pgsql',
'database' => 'LiveSupport-test',
'database' => 'Campcaster-test',
),
'tblNamePrefix' => 'ls_',
@ -96,13 +70,13 @@ $config = array(
'useTrash' => TRUE,
/* ==================================================== URL configuration */
'storageUrlPath' => '/livesupportStorageServer',
'storageUrlPath' => '/campcasterStorageServer',
'storageXMLRPC' => 'xmlrpc/xrLocStor.php',
'storageUrlHost' => 'localhost',
'storageUrlPort' => 80,
/* ================================================ archive configuration */
'archiveUrlPath' => '/livesupportArchiveServer',
'archiveUrlPath' => '/campcasterArchiveServer',
'archiveXMLRPC' => 'xmlrpc/xrArchive.php',
'archiveUrlHost' => 'localhost',
'archiveUrlPort' => 80,
@ -141,7 +115,7 @@ $config = array(
/* ============================================== auxiliary configuration */
'RootNode' => 'RootNode',
'tmpRootPass' => 'q',
/* =================================================== cron configuration */
'cronUserName' => 'www-data',
'lockfile' => dirname(__FILE__).'/cron/cron.lock',
@ -154,7 +128,7 @@ $config['sysSubjs'] = array(
$old_ip = get_include_path();
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
$this_file = null;
@ -168,7 +142,7 @@ if(!is_null($this_file)){
$fileowner_array = posix_getpwuid($fileowner_id);
$fileowner_homedir = $fileowner_array['dir'];
$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)) {
$default_config = $config;
$developer_name = $fileowner_name;

View File

@ -3,8 +3,8 @@ require_once (dirname(__FILE__).'/Crontab.php');
require_once (dirname(__FILE__).'/../conf.php');
/**
* This class can call a PHP function from crontab.
*
* Example:
* <pre>
* $cron = new Cron();
* $access = $cron->openCrontab('write');
* if ($access != 'write') {
@ -17,7 +17,9 @@ require_once (dirname(__FILE__).'/../conf.php');
* array('first','secound','third')
* );
* $cron->closeCrontab();
*
* </pre>
* @package Campcaster
* @subpackage StorageServer.Cron
*/
class Cron {
/**
@ -35,7 +37,7 @@ class Cron {
* @var string available values: read | write
*/
var $ctAccess = 'read';
/**
* Constructor
*/
@ -47,13 +49,13 @@ class Cron {
$this->cronUserName = $config['cronUserName'];
}
/* ==================================================== Cronjob functions */
/**
* Add a cronjob to the crontab
*
* @access public
* @param string $m minute
* @param string $m minute
* @param string $h hour
* @param string $dom day of month
* @param string $mo month
@ -65,7 +67,7 @@ class Cron {
function addCronJob($m, $h, $dom, $mo, $dow, $className, $params)
{
if ($this->ctAccess == 'write') {
$this->ct->addCron($m, $h, $dom, $mo, $dow,
$this->ct->addCron($m, $h, $dom, $mo, $dow,
$this->getCommand($className, $params));
return true;
} else {
@ -76,7 +78,7 @@ class Cron {
/**
* This function return with the active cronjobs
*
*
* @access public
* @return array array of cronjob struct
*/
@ -87,7 +89,7 @@ class Cron {
/**
* Remove a cronjob.
*
*
* @access public
* @param int $index index of the cronjobs' array.
* @return bool true if success else PEAR error.
@ -106,17 +108,17 @@ class Cron {
/* ==================================================== Crontab functions */
/**
* Open the crontab
*
*
* @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
*/
function openCrontab($access = 'read')
{
$access = strtolower($access);
$this->ct = new Crontab($this->cronUserName);
if ($access == 'write' &&
$this->isCrontabWritable() &&
if ($access == 'write' &&
$this->isCrontabWritable() &&
$this->lockCrontab()) {
$this->ctAccess = $access;
} else {
@ -127,7 +129,7 @@ class Cron {
/**
* Close the crontab
*
*
* @access public
* @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
*
*
* @access private
* @return bool
*/
@ -152,18 +154,18 @@ class Cron {
/**
* Try to lock the crontab
*
*
* @access private
* @return bool true if the locking is success
*/
*/
function lockCrontab()
{
{
return touch($this->lockfile);
}
/**
* Try to unlock the crontab
*
*
* @access private
* @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.
*
*
* @access public
* @return bool true if the setting is success
*/
@ -191,7 +193,7 @@ class Cron {
/* ======================================================= Misc functions */
/**
* Get the shell command for the cronjob
*
*
* @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
* @return string shell command
@ -199,7 +201,7 @@ class Cron {
function getCommand($className, $params)
{
$this->params = array (
'class' => $className,
'class' => $className,
'params' => $params
);
return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"';

View File

@ -1,8 +1,12 @@
<?php
/**
* Cron jobs handling abstract class
*
* @author $Author: $
* @version $Revision: $
* @package Campcaster
* @subpackage StorageServer.Cron
*/
class CronJob
{
/**
@ -12,11 +16,4 @@ class CronJob
{
}
}
?>
?>

View File

@ -1,31 +1,32 @@
<?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_ASSIGN', 1);
define('CRON_CMD', 2);
define('CRON_SPECIAL', 3);
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
{
// {{{ properties
/**
* @var array holds all the different lines.
* Lines are associative arrays with the following fields:
* @var array holds all the different lines.
* Lines are associative arrays with the following fields:
* "minute" : holds the minutes (0-59)
* "hour" : holds the hour (0-23)
* "dayofmonth" : holds the day of the month (1-31)
* "month" : the month (1-12 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"
* or a line can be a comment (string beginning with #)
* or it can be a special command (beginning with an @)
@ -38,19 +39,19 @@ class Crontab
var $user;
/**
* @var string Lists the type of line of each line in $crontabs.
* can be: any of the CRON_* constants.
* so $linetype[5] is the type of $crontabs[5].
* @var string Lists the type of line of each line in $crontabs.
* can be: any of the CRON_* constants.
* so $linetype[5] is the type of $crontabs[5].
*/
var $linetypes;
// }}}
// }}}
/**
* Constructor
*
*
* Initialises $this->crontabs
*
*
* @param string $user the user for whom the crontab will be manipulated
*/
function Crontab($user)
@ -61,7 +62,7 @@ class Crontab
/**
* This reads the crontab of $this->user and parses it in $this->crontabs
*
*
*/
function readCrontab()
{
@ -91,7 +92,7 @@ class Crontab
continue;
}
// Checking if this is an assignment
// Checking if this is an assignment
if (ereg("(.*)=(.*)", $line, $assign))
{
$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
*
* @param string $m minute
* @param string $m minute
* @param string $h hour
* @param string $dom day of month
* @param string $mo month
@ -191,7 +192,7 @@ class Crontab
/**
* Add a comment to the cron to the end of $this->crontabs
*
*
* @param string $comment comment
*/
function addComment($comment)
@ -202,7 +203,7 @@ class Crontab
/**
* Add a special command (check man 5 crontab for more information)
*
*
* @param string $sdate special date
* string meaning
* ------ -------
@ -224,7 +225,7 @@ class Crontab
/**
* Add an assignment (name = value)
*
*
* @param string $name name of assingation
* @param string $value value
*/
@ -236,7 +237,7 @@ class Crontab
/**
* Delete a line from the arrays.
*
*
* @param int $index the index in $this->crontabs
*/
function delEntry($index)
@ -247,7 +248,7 @@ class Crontab
/**
* Get all the lines of a certain type in an array
*
*
* @param string $type linetype
*/
function getByType($type)

View File

@ -13,16 +13,18 @@ $gb =& new LocStor($dbc, $config);
$tr =& new Transport($gb);
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:
$cnt = 4;
for($i=0; $i<$cnt; $i++, sleep(1)){
for ($i = 0; $i < $cnt; $i++, sleep(1)){
// run the action:
$r = $tr->cronCallMethod($trtok);
if(PEAR::isError($r)){
if (PEAR::isError($r)) {
$tr->trLogPear("transportCronJob: ($trtok): ", $r);
}else{
} else {
# $tr->trLog("X transportCronJob: ".var_export($r, TRUE));
if($r!==TRUE) $tr->trLog("transportCronJob: ($trtok): nonTRUE returned");
}
@ -30,6 +32,8 @@ for($i=0; $i<$cnt; $i++, sleep(1)){
#sleep(2);
}
if(TR_LOG_LEVEL>1){ $tr->trLog("transportCronJob end ($trtok)"); }
if (TR_LOG_LEVEL>1) {
$tr->trLog("transportCronJob end ($trtok)");
}
exit(0);
?>

View File

@ -1,32 +1,8 @@
<?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$
------------------------------------------------------------------------------*/
/**
* @author $Author$
* @version $Revision$
*/
header ("location: html/");
exit;
/*

View File

@ -1,33 +1,4 @@
<?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
*----------------------------------------------------------------------------*/

View File

@ -1,33 +1,4 @@
<?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
*----------------------------------------------------------------------------*/

View File

@ -1,33 +1,4 @@
<?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
*----------------------------------------------------------------------------*/

View File

@ -1,33 +1,4 @@
<?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
*----------------------------------------------------------------------------*/

View File

@ -1,33 +1,4 @@
<?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: ../");
exit;
?>
?>

View File

@ -1,32 +1,9 @@
<?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
$arr = array_diff_assoc($_SERVER, $_ENV);
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){

View File

@ -1,32 +1,9 @@
<?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
$arr = array_diff_assoc($_SERVER, $_ENV);
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){

View File

@ -1,32 +1,11 @@
<?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(
'_root'=>'playlist',
@ -135,4 +114,4 @@ $playlistFormat = array(
?
ls:filename Text auto
*/
?>
?>

View File

@ -1,33 +1,4 @@
<?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: ../");
exit;
?>
?>

View File

@ -1,32 +1,4 @@
<?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");
echo "\n# Transport test:\n";

View File

@ -1,32 +1,4 @@
<?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");
echo "\n#StorageServer storeWebstream test:\n";

View File

@ -1,32 +1,8 @@
<?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$
------------------------------------------------------------------------------*/
/**
* @author $Author$
* @version $Revision$
*/
$webstreamFormat = array(
'_root'=>'audioClip',
@ -366,4 +342,4 @@ $webstreamFormat = array(
?
ls:filename Text auto
*/
?>
?>

View File

@ -1,44 +1,17 @@
<?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';
/**
* XML-RPC interface for LocStor class
*
* XML-RPC interface for LocStor class
* @author $Author$
* @version $Revision$
*
*/
class XR_LocStor extends LocStor{
/* ----------------------------------------------------------- getVersion */
/**
* Dummy method - only returns livesupport version
* Dummy method - only returns Campcaster version
*
* The XML-RPC name of this method is "locstor.getVersion".
*
@ -240,7 +213,7 @@ class XR_LocStor extends LocStor{
* (returned by subsequent storeAudioClipClose call)
* </li>
* <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)
* </li>
* <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".
*
@ -2249,7 +2222,7 @@ class XR_LocStor extends LocStor{
* <li>filetype : string - type of searched files,
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
* <li>operator : string - type of conditions join
* (any condition matches / all conditions match),
* (any condition matches / all conditions match),
* meaningful values: 'and', 'or', ''
* (may be empty or ommited only with less then 2 items in
* &quot;conditions&quot; field)
@ -2276,7 +2249,7 @@ class XR_LocStor extends LocStor{
*
* On success, returns a XML-RPC array of structs with fields:
* <ul>
* <li>cnt : integer - number of matching gunids
* <li>cnt : integer - number of matching gunids
* of files have been found</li>
* <li>results : array of hashes:
* <ul>
@ -2373,7 +2346,7 @@ class XR_LocStor extends LocStor{
if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
);
}
$xv = new XML_RPC_Value;
@ -2434,7 +2407,7 @@ class XR_LocStor extends LocStor{
$ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res)));
@ -2586,11 +2559,11 @@ class XR_LocStor extends LocStor{
$ec0 = intval($res->getCode());
$ec = (
$ec0 == GBERR_SESS || $ec0 == GBERR_PREF || $ec0==ALIBERR_NOTGR
? 800+$ec0 : 805
? 800+$ec0 : 805
);
return new XML_RPC_Response(0, $ec,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
);
}
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)));
}
/**
* 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)));
}
/* ------------------------ methods for ls-archive-format file transports */
/**
* 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)));
}
/**
* 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));
}
/**
* 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)));
}
/* ------------- 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)));
}
/**
* 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)));
}
/* ------------------------------------------------ global-search methods */
/**
* 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)));
}
/**
* Get results from search job on network hub.
* (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:
* <ul>
* <li>cnt : integer - number of matching gunids
* <li>cnt : integer - number of matching gunids
* of files have been found</li>
* <li>results : array of hashes:
* <ul>
@ -3177,7 +3150,7 @@ class XR_LocStor extends LocStor{
}
return new XML_RPC_Response(XML_RPC_encode($res));
}
/**
* OBSOLETE
* Starts upload audioclip to remote archive

View File

@ -1,33 +1,4 @@
<?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");
exit;
?>
?>

View File

@ -1,33 +1,4 @@
<?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
* Store PUT data as temporary file.
@ -53,6 +24,8 @@
* </ul>
*
* @see XR_LocStor
* @author : $Author$
* @version : $Revision$
*/
require_once dirname(__FILE__).'/../conf.php';

View File

@ -1,32 +1,8 @@
<?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$
------------------------------------------------------------------------------*/
/**
* @author $Author$
* @version $Revision$
*/
/* ================================================================= includes */
include_once dirname(__FILE__)."/../conf.php";
@ -405,7 +381,7 @@ class SchedulerPhpClient{
$serverPath =
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
"{$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";
$url = parse_url($serverPath);
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);

View File

@ -1,33 +1,4 @@
<?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
* Returns stored media file identified by global unique ID.
@ -51,6 +22,8 @@
* <li> 404 - File not found</li>
* <li> 500 - Application error</li>
* </ul>
* @author $Author$
* @version $Revision$
*
*/
@ -130,4 +103,4 @@ switch($ftype){
// var_dump($ftype);
http_error(500, "500 Unknown ftype ($ftype)");
}
?>
?>

View File

@ -1,32 +1,8 @@
<?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$
------------------------------------------------------------------------------*/
/**
* @author $Author$
* @version : $Revision$
*/
/* ====================================================== specific PHP config */
ini_set("mbstring.internal_encoding", 'UTF-8');
@ -189,4 +165,4 @@ foreach($methods as $method=>$description){
$s=new XML_RPC_Server( $defs );
?>
?>

View File

@ -1,33 +1,4 @@
<?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';
include_once "XML/RPC.php";
include_once dirname(__FILE__)."/../conf.php";
@ -46,7 +17,7 @@ if($pars[0] == '-s'){
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
}
#$serverPath = "http://localhost:80/livesupportStorageServerCVS/xmlrpc/xrLocStor.php";
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
$url = parse_url($serverPath);
$client = new XML_RPC_Client($url['path'], $url['host']);
@ -184,7 +155,7 @@ $infos = array(
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
"getTransportInfo" => array('m'=>"locstor.getTransportInfo",
'p'=>array('trtok'),
'p'=>array('trtok'),
'r'=>array('state', 'realsize', 'expectedsize', 'realchsum', 'expectedchsum')),
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
'p'=>array('sessid', 'onOff'), 'r'=>array('state')),