Started to convert code to PHP5 using public/private/protected/static and __construct() method, got rid of =& when constructing objects. Improved documentation in many places. Commented out functions that are no longer in use. Got rid of double-copy operations when checking for errors (e.g. $foo = $r = myMethod()). Tweaked code here and there to fit coding conventions.

This commit is contained in:
paul 2006-11-14 19:09:20 +00:00
parent 8b979c9f76
commit bb00be70bb
36 changed files with 1920 additions and 1455 deletions

View File

@ -5,24 +5,28 @@
* Handles recursive accessPlaylist/releasePlaylist. * Handles recursive accessPlaylist/releasePlaylist.
* Should be 'required_once' from LocStor.php only. * Should be 'required_once' from LocStor.php only.
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class AccessRecur { class AccessRecur {
function AccessRecur(&$ls, $sessid) public function __construct(&$ls, $sessid)
{ {
$this->ls =& $ls; $this->ls =& $ls;
$this->dbc =& $ls->dbc; $this->dbc =& $ls->dbc;
$this->sessid = $sessid; $this->sessid = $sessid;
} }
function accessPlaylist(&$ls, $sessid, $plid, $parent='0') function accessPlaylist(&$ls, $sessid, $plid, $parent='0')
{ {
$ppa =& new AccessRecur($ls, $sessid); $ppa = new AccessRecur($ls, $sessid);
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent); $r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
@ -49,7 +53,7 @@ class AccessRecur {
function releasePlaylist(&$ls, $sessid, $token) function releasePlaylist(&$ls, $sessid, $token)
{ {
$ppa =& new AccessRecur($ls, $sessid); $ppa = new AccessRecur($ls, $sessid);
$r = $ppa->dbc->getAll(" $r = $ppa->dbc->getAll("
SELECT to_hex(token)as token2, to_hex(gunid)as gunid SELECT to_hex(token)as token2, to_hex(gunid)as gunid
FROM {$ppa->ls->accessTable} FROM {$ppa->ls->accessTable}
@ -68,14 +72,14 @@ class AccessRecur {
$ftype = $r; $ftype = $r;
# echo "$ftype/$token2\n"; # echo "$ftype/$token2\n";
switch (strtolower($ftype)) { switch (strtolower($ftype)) {
case"audioclip": case "audioclip":
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2); $r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
if ($ppa->dbc->isError($r)) { if ($ppa->dbc->isError($r)) {
return $r; return $r;
} }
# var_dump($r); # var_dump($r);
break; break;
case"playlist": case "playlist":
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2); $r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
if ($ppa->dbc->isError($r)) { if ($ppa->dbc->isError($r)) {
return $r; return $r;
@ -98,7 +102,7 @@ class AccessRecur {
$res = array(); $res = array();
foreach ($pla['children'] as $ple) { foreach ($pla['children'] as $ple) {
switch ($ple['elementname']) { switch ($ple['elementname']) {
case"playlistElement": case "playlistElement":
$r = $this->processPlEl($ple, $parent); $r = $this->processPlEl($ple, $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
@ -127,14 +131,13 @@ class AccessRecur {
{ {
foreach ($ple['children'] as $ac) { foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) { switch ($ac['elementname']) {
case"audioClip": case "audioClip":
$r = $this->processAc($ac['attrs']['id'], $parent); $r = $this->processAc($ac['attrs']['id'], $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return $r; return $r;
break; case "playlist":
case"playlist":
// if(empty($ac['children'])){ // if(empty($ac['children'])){
$r = $this->accessPlaylist($this->ls, $this->sessid, $r = $this->accessPlaylist($this->ls, $this->sessid,
$ac['attrs']['id'], $parent); $ac['attrs']['id'], $parent);

View File

@ -3,103 +3,128 @@ define('BACKUP_EXT', 'tar');
define('ACCESS_TYPE', 'backup'); define('ACCESS_TYPE', 'backup');
/** /**
* @author $Author: $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: $ * @version $Revision: $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class Backup class Backup
{ {
/** /**
* string - name of logfile * Name of logfile
* @var string
*/ */
var $logFile; private $logFile;
/** /**
* string - session id * Session id
* @var string
*/ */
var $sessid; private $sessid;
/**
* struct - see search criteria
*/
var $criteria;
/** /**
* string - token * struct - see search criteria
* @var array
*/ */
var $token; private $criteria;
/**
* string - name of statusfile
*/
var $statusFile;
/**
* array - affected gunids
*/
var $ids;
/**
* array - array of affected filenames
*/
var $filenames = array();
/** /**
* string - base tmp name * @var string
*/ */
var $tmpName; private $token;
/**
* stirng - name of temporary tarball file
*/
var $tmpFile;
/**
* string - name of temporary directory
*/
var $tmpDir;
/**
* string - name of temporary playlist directory
*/
var $tmpDirPlaylist;
/**
* string - name of temporary audioclip directory
*/
var $tmpDirClip;
/**
* string - name of temporary metafile directory
*/
var $tmpDirMeta;
/** /**
* string - loglevel * name of statusfile
* @var string
*/ */
var $loglevel = 'warn'; # 'debug'; private $statusFile;
/** /**
* greenbox object reference * Affected gunids
* @var array
*/ */
var $gb; private $ids;
/** /**
* Constructor * Array of affected filenames
* * @var array
* @param gb: greenbox object reference
*/ */
function Backup (&$gb) private $filenames = array();
/**
* Base tmp name
* @var string
*/
private $tmpName;
/**
* Name of temporary tarball file
* @var string
*/
private $tmpFile;
/**
* Name of temporary directory
* @var string
*/
private $tmpDir;
/**
* Name of temporary playlist directory
* @var string
*/
private $tmpDirPlaylist;
/**
* Name of temporary audioclip directory
* @var string
*/
private $tmpDirClip;
/**
* Name of temporary metafile directory
* @var string
*/
private $tmpDirMeta;
/**
* @var string
*/
private $loglevel = 'warn'; # 'debug';
/**
* @var GreenBox
*/
private $gb;
/**
* @param GreeenBox $gb
*/
public function __construct(&$gb)
{ {
$this->gb =& $gb; $this->gb =& $gb;
$this->token = null; $this->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log'; $this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n"); $this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
} }
/** /**
* Open a backup * Open a backup
* Create a backup file (tarball) * Create a backup file (tarball)
* *
* @param sessid : string - session id * @param string $sessid
* @param criteria : struct - see search criteria * @param array $criteria
* @return hasharray with field: * struct - see search criteria
* @return array
* hasharray with field:
* token string: backup token * token string: backup token
*/ */
function openBackup($sessid,$criteria='') function openBackup($sessid, $criteria='')
{ {
if ($this->loglevel=='debug') { if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n"); $this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n");
@ -108,9 +133,9 @@ class Backup
$this->criteria = $criteria; $this->criteria = $criteria;
# get ids (and real filenames) which files match with criteria # get ids (and real filenames) which files match with criteria
$srch = $r = $this->gb->localSearch($this->criteria,$this->sessid); $srch = $this->gb->localSearch($this->criteria,$this->sessid);
if (PEAR::isError($r)) { if (PEAR::isError($srch)) {
return $r; return $srch;
} }
$this->setIDs($srch); $this->setIDs($srch);
#echo '<XMP>this->ids:'; print_r($this->ids); echo '</XMP>'; #echo '<XMP>this->ids:'; print_r($this->ids); echo '</XMP>';
@ -217,7 +242,7 @@ class Backup
/** /**
* list of unclosed backups * list of unclosed backups
* *
* @param string $stat (optional) * @param string $stat
* if this parameter is not set, then return with all unclosed backups * if this parameter is not set, then return with all unclosed backups
* @return array of hasharray with field: * @return array of hasharray with field:
* status : string - susccess | working | fault * status : string - susccess | working | fault
@ -274,9 +299,9 @@ class Backup
foreach ($this->ids as $i=>$item) { foreach ($this->ids as $i=>$item) {
$gunid = $item['gunid']; $gunid = $item['gunid'];
# get a stored file object of this gunid # get a stored file object of this gunid
$sf = $r = StoredFile::recallByGunid($this->gb, $gunid); $sf = StoredFile::recallByGunid($this->gb, $gunid);
if (PEAR::isError($r)) { if (PEAR::isError($sf)) {
return $r; return $sf;
} }
$lid = $this->gb->_idFromGunid($gunid); $lid = $this->gb->_idFromGunid($gunid);
if (($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE) { if (($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE) {
@ -425,7 +450,8 @@ class Backup
/** /**
* Add a line to the logfile. * Add a line to the logfile.
* *
* @param string $item - the new row of log file * @param string $item
* the new row of log file
*/ */
function addLogItem($item) function addLogItem($item)
{ {
@ -439,7 +465,8 @@ class Backup
/** /**
* Delete a directory recursive * Delete a directory recursive
* *
* @param string $dirname - path of dir. * @param string $dirname
* path of dir.
*/ */
function rRmDir($dirname) function rRmDir($dirname)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -42,10 +42,14 @@ require_once "XML/Util.php";
* <li>cnt : integer - number of matching items</li> * <li>cnt : integer - number of matching items</li>
* </ul> * </ul>
* *
* @Author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see MetaData * @see MetaData
* @see StoredFile * @see StoredFile
*/ */
@ -56,7 +60,7 @@ class DataEngine {
* *
* @param BasicStor $gb * @param BasicStor $gb
*/ */
function DataEngine(&$gb) public function __construct(&$gb)
{ {
$this->gb =& $gb; $this->gb =& $gb;
$this->dbc =& $gb->dbc; $this->dbc =& $gb->dbc;

File diff suppressed because it is too large Load Diff

View File

@ -6,26 +6,37 @@ require_once "BasicStor.php";
* *
* Local storage interface * Local storage interface
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class LocStor extends BasicStor { class LocStor extends BasicStor {
/* ---------------------------------------------------------------- store */ /* ---------------------------------------------------------------- store */
/** /**
* Store or replace existing audio clip * Store or replace existing audio clip
* *
* @param string $sessid, session id * @param string $sessid
* @param string $gunid, global unique id * session id
* @param string $metadata, metadata XML string * @param string $gunid
* @param string $fname, human readable menmonic file name * global unique id
* with extension corresponding to filetype * @param string $metadata
* @param string $chsum, md5 checksum of media file * metadata XML string
* @param string $ftype audioclip | playlist | webstream * @param string $fname
* @return struct {url:writable URL for HTTP PUT, token:access token * human readable menmonic file name
* with extension corresponding to filetype
* @param string $chsum
* md5 checksum of media file
* @param string $ftype
* audioclip | playlist | webstream
* @return array
* {url:writable URL for HTTP PUT, token:access token}
*/ */
function storeAudioClipOpen( function storeAudioClipOpen(
$sessid, $gunid, $metadata, $fname, $chsum, $ftype='audioclip' $sessid, $gunid, $metadata, $fname, $chsum, $ftype='audioclip'
@ -98,11 +109,11 @@ class LocStor extends BasicStor {
/** /**
* Store or replace existing audio clip * Store or replace existing audio clip
* *
* @param string $sessid * @param string $sessid
* @param string $token * @param string $token
* @return string gunid or PEAR::error * @return string gunid|PEAR_Error
*/ */
function storeAudioClipClose($sessid, $token) function storeAudioClipClose($sessid, $token)
{ {
@ -133,10 +144,12 @@ class LocStor extends BasicStor {
/** /**
* Check uploaded file * Check uploaded file
* *
* @param string $token, put token * @param string $token
* @return hash, (status: boolean, size: int - filesize) * "put" token
* @return array
* hash, (status: boolean, size: int - filesize)
*/ */
function uploadCheck($token) function uploadCheck($token)
{ {
@ -145,15 +158,20 @@ class LocStor extends BasicStor {
/** /**
* Store webstream * Store webstream
* *
* @param string $sessid, session id * @param string $sessid
* @param string $gunid, global unique id * session id
* @param string $metadata, metadata XML string * @param string $gunid
* @param string $fname, human readable menmonic file name * global unique id
* with extension corresponding to filetype * @param string $metadata
* @param string $url, wewbstream url * metadata XML string
* @return string, gunid * @param string $fname
* human readable menmonic file name with extension corresponding to filetype
* @param string $url
* webstream url
* @return string
* gunid
*/ */
function storeWebstream($sessid, $gunid, $metadata, $fname, $url) function storeWebstream($sessid, $gunid, $metadata, $fname, $url)
{ {
@ -182,12 +200,14 @@ class LocStor extends BasicStor {
/* --------------------------------------------------------------- access */ /* --------------------------------------------------------------- access */
/** /**
* Make access to audio clip * Make access to audio clip
* *
* @param string $sessid * @param string $sessid
* @param string $gunid * @param string $gunid
* @param int $parent parent token * @param int $parent
* @return array with: seekable filehandle, access token * parent token
* @return array
* with: seekable filehandle, access token
*/ */
function accessRawAudioData($sessid, $gunid, $parent='0') function accessRawAudioData($sessid, $gunid, $parent='0')
{ {
@ -203,11 +223,12 @@ class LocStor extends BasicStor {
/** /**
* Release access to audio clip * Release access to audio clip
* *
* @param string $sessid * @param string $sessid
* @param string $token, access token * @param string $token
* @return boolean or PEAR::error * access token
* @return boolean|PEAR_Error
*/ */
function releaseRawAudioData($sessid, $token) function releaseRawAudioData($sessid, $token)
{ {
@ -221,11 +242,14 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------------- download */ /* ------------------------------------------------------------- download */
/** /**
* Create and return downloadable URL for audio file * Create and return downloadable URL for audio file
* *
* @param string $sessid, session id * @param string $sessid
* @param string $gunid, global unique id * session id
* @return array with strings: * @param string $gunid
* global unique id
* @return array
* array with strings:
* downloadable URL, download token, chsum, size, filename * downloadable URL, download token, chsum, size, filename
*/ */
function downloadRawAudioDataOpen($sessid, $gunid) function downloadRawAudioDataOpen($sessid, $gunid)
@ -249,10 +273,12 @@ class LocStor extends BasicStor {
/** /**
* Discard downloadable URL for audio file * Discard downloadable URL for audio file
* *
* @param string $token, download token * @param string $token
* @return string, gunid * download token
* @return string
* gunid
*/ */
function downloadRawAudioDataClose($token) function downloadRawAudioDataClose($token)
{ {
@ -261,11 +287,14 @@ class LocStor extends BasicStor {
/** /**
* Create and return downloadable URL for metadata * Create and return downloadable URL for metadata
* *
* @param string $sessid, session id * @param string $sessid
* @param string $gunid, global unique id * session id
* @return array with strings: * @param string $gunid
* global unique id
* @return array
* array with strings:
* downloadable URL, download token, chsum, filename * downloadable URL, download token, chsum, filename
*/ */
function downloadMetadataOpen($sessid, $gunid) function downloadMetadataOpen($sessid, $gunid)
@ -288,10 +317,12 @@ class LocStor extends BasicStor {
/** /**
* Discard downloadable URL for metadata * Discard downloadable URL for metadata
* *
* @param string $token, download token * @param string $token
* @return string, gunid * download token
* @return string
* gunid
*/ */
function downloadMetadataClose($token) function downloadMetadataClose($token)
{ {
@ -300,11 +331,11 @@ class LocStor extends BasicStor {
/** /**
* Return metadata as XML * Return metadata as XML
* *
* @param string $sessid * @param string $sessid
* @param string $gunid * @param string $gunid
* @return string or PEAR::error * @return string|PEAR_Error
*/ */
function getAudioClip($sessid, $gunid) function getAudioClip($sessid, $gunid)
{ {
@ -326,10 +357,11 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- search, browse */ /* ------------------------------------------------------- search, browse */
/** /**
* Search in metadata database * Search in metadata database
* *
* @param string $sessid * @param string $sessid
* @param hash $criteria, with following structure:<br> * @param array $criteria
* with following structure:<br>
* <ul> * <ul>
* <li>filetype - string, type of searched files, * <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li> * meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
@ -389,8 +421,6 @@ class LocStor extends BasicStor {
/** /**
* Enter description here...
*
* @param array $criteria * @param array $criteria
* @param mixed $sessid - this variable isnt used * @param mixed $sessid - this variable isnt used
* @return unknown * @return unknown
@ -408,13 +438,16 @@ class LocStor extends BasicStor {
/** /**
* Return values of specified metadata category * Return values of specified metadata category
* *
* @param string $category, metadata category name * @param string $category
* with or without namespace prefix (dc:title, author) * metadata category name
* @param hash $criteria, see searchMetadata method * with or without namespace prefix (dc:title, author)
* @param string $sessid * @param hash $criteria
* @return hash, fields: * see searchMetadata method
* @param string $sessid
* @return array
* hash, fields:
* results : array with found values * results : array with found values
* cnt : integer - number of matching values * cnt : integer - number of matching values
* @see BasicStor::bsBrowseCategory * @see BasicStor::bsBrowseCategory
@ -430,11 +463,11 @@ class LocStor extends BasicStor {
/* ----------------------------------------------------------------- etc. */ /* ----------------------------------------------------------------- etc. */
/** /**
* Check if audio clip exists * Check if audio clip exists
* *
* @param string $sessid * @param string $sessid
* @param string $gunid * @param string $gunid
* @return boolean * @return boolean
*/ */
function existsAudioClip($sessid, $gunid) function existsAudioClip($sessid, $gunid)
{ {
@ -458,12 +491,13 @@ class LocStor extends BasicStor {
/** /**
* Check if file exists in the storage * Check if file exists in the storage
* *
* @param string $sessid * @param string $sessid
* @param string $gunid * @param string $gunid
* @param string $ftype, internal file type * @param string $ftype
* @return boolean * internal file type
* @return boolean
*/ */
function existsFile($sessid, $gunid, $ftype=NULL) function existsFile($sessid, $gunid, $ftype=NULL)
{ {
@ -480,12 +514,13 @@ class LocStor extends BasicStor {
/** /**
* Delete existing audio clip * Delete existing audio clip
* *
* @param string $sessid * @param string $sessid
* @param string $gunid * @param string $gunid
* @param boolean $forced, if true don't use trash * @param boolean $forced
* @return boolean or PEAR::error * if true, don't use trash
* @return boolean|PEAR_Error
*/ */
function deleteAudioClip($sessid, $gunid, $forced=FALSE) function deleteAudioClip($sessid, $gunid, $forced=FALSE)
{ {
@ -508,12 +543,13 @@ class LocStor extends BasicStor {
/** /**
* Update existing audio clip metadata * Update existing audio clip metadata
* *
* @param string $sessid * @param string $sessid
* @param string $gunid * @param string $gunid
* @param string $metadata, metadata XML string * @param string $metadata
* @return boolean or PEAR::error * metadata XML string
* @return boolean|PEAR_Error
*/ */
function updateAudioClipMetadata($sessid, $gunid, $metadata) function updateAudioClipMetadata($sessid, $gunid, $metadata)
{ {
@ -530,12 +566,16 @@ class LocStor extends BasicStor {
/*====================================================== playlist methods */ /*====================================================== playlist methods */
/** /**
* Create a new empty playlist. * Create a new empty playlist.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistId, playlist global unique ID * session ID
* @param string $fname, human readable mnemonic file name * @param string $playlistId
* @return string, playlist global unique ID * playlist global unique ID
* @param string $fname
* human readable mnemonic file name
* @return string
* playlist global unique ID
*/ */
function createPlaylist($sessid, $playlistId, $fname) function createPlaylist($sessid, $playlistId, $fname)
{ {
@ -588,12 +628,14 @@ class LocStor extends BasicStor {
/** /**
* Open a Playlist metafile for editing. * Open a Playlist metafile for editing.
* Open readable URL and mark file as beeing edited. * Open readable URL and mark file as beeing edited.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistId, playlist global unique ID * session ID
* @return struct * @param string $playlistId
* playlist global unique ID
* @return struct
* {url:readable URL for HTTP GET, token:access token, chsum:checksum} * {url:readable URL for HTTP GET, token:access token, chsum:checksum}
*/ */
function editPlaylist($sessid, $playlistId) function editPlaylist($sessid, $playlistId)
@ -634,12 +676,16 @@ class LocStor extends BasicStor {
/** /**
* Store a new Playlist metafile in place of the old one. * Store a new Playlist metafile in place of the old one.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistToken, playlist access token * session ID
* @param string $newPlaylist, new playlist as XML string * @param string $playlistToken
* @return string, playlistId * playlist access token
* @param string $newPlaylist
* new playlist as XML string
* @return string
* playlistId
*/ */
function savePlaylist($sessid, $playlistToken, $newPlaylist) function savePlaylist($sessid, $playlistToken, $newPlaylist)
{ {
@ -664,11 +710,14 @@ class LocStor extends BasicStor {
/** /**
* RollBack playlist changes to the locked state * RollBack playlist changes to the locked state
* *
* @param string $playlistToken, playlist access token * @param string $playlistToken
* @param string $sessid, session ID * playlist access token
* @return string gunid of playlist * @param string $sessid
* session ID
* @return string
* gunid of playlist
*/ */
function revertEditedPlaylist($playlistToken, $sessid='') function revertEditedPlaylist($playlistToken, $sessid='')
{ {
@ -695,12 +744,15 @@ class LocStor extends BasicStor {
/** /**
* Delete a Playlist metafile. * Delete a Playlist metafile.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistId, playlist global unique ID * session ID
* @param boolean $forced, if true don't use trash * @param string $playlistId
* @return boolean * playlist global unique ID
* @param boolean $forced
* if true don't use trash
* @return boolean
*/ */
function deletePlaylist($sessid, $playlistId, $forced=FALSE) function deletePlaylist($sessid, $playlistId, $forced=FALSE)
{ {
@ -733,14 +785,17 @@ class LocStor extends BasicStor {
/** /**
* Access (read) a Playlist metafile. * Access (read) a Playlist metafile.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistId, playlist global unique ID * session ID
* @param boolean $recursive, flag for recursive access content * @param string $playlistId
* inside playlist (optional, default: false) * playlist global unique ID
* @param int $parent parent token * @param boolean $recursive
* @return struct { * flag for recursive access content inside playlist
* @param int $parent
* parent token
* @return struct {
* url: readable URL for HTTP GET, * url: readable URL for HTTP GET,
* token: access token, * token: access token,
* chsum: checksum, * chsum: checksum,
@ -779,13 +834,16 @@ class LocStor extends BasicStor {
/** /**
* Release the resources obtained earlier by accessPlaylist(). * Release the resources obtained earlier by accessPlaylist().
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistToken, playlist access token * session ID
* @param boolean $recursive, flag for recursive access content * @param string $playlistToken
* inside playlist (optional, default: false) * playlist access token
* @return string, playlist ID * @param boolean $recursive
* flag for recursive access content inside playlist
* @return string
* playlist ID
*/ */
function releasePlaylist($sessid, $playlistToken, $recursive=FALSE) function releasePlaylist($sessid, $playlistToken, $recursive=FALSE)
{ {
@ -802,16 +860,18 @@ class LocStor extends BasicStor {
/** /**
* Create a tarfile with playlist export - playlist and all matching * Create a tarfile with playlist export - playlist and all matching
* sub-playlists and media files (if desired) * sub-playlists and media files (if desired)
* *
* @param sessid - string, session ID * @param string $sessid
* @param plids - array of strings, playlist global unique IDs * session ID
* (one gunid is accepted too) * @param array $plids
* @param type - string, playlist format, values: lspl | smil | m3u * array of strings, playlist global unique IDs (one gunid is accepted too)
* @param standalone - boolean, if only playlist should be exported or * @param string $type
* with all related files * playlist format, values: lspl | smil | m3u
* @return hasharray with fields: * @param boolean $standalone
* if only playlist should be exported or with all related files
* @return hasharray with fields:
* url string: readable url, * url string: readable url,
* token string: access token * token string: access token
* chsum string: md5 checksum, * chsum string: md5 checksum,
@ -834,11 +894,11 @@ class LocStor extends BasicStor {
/** /**
* Close playlist export previously opened by the exportPlaylistOpen method * Close playlist export previously opened by the exportPlaylistOpen method
* *
* @param token - string, access token obtained from exportPlaylistOpen * @param string $token
* method call * access token obtained from exportPlaylistOpen method call
* @return boolean true or error object * @return boolean|PEAR_Error
*/ */
function exportPlaylistClose($token) function exportPlaylistClose($token)
{ {
@ -847,11 +907,13 @@ class LocStor extends BasicStor {
/** /**
* Open writable handle for import playlist in LS Archive format * Open writable handle for import playlist in LS Archive format
* *
* @param string $sessid, session id * @param string $sessid
* @param string $chsum, md5 checksum of imported file * session id
* @return hasharray with: * @param string $chsum
* md5 checksum of imported file
* @return hasharray with:
* url string: writable URL * url string: writable URL
* token string: PUT token * token string: PUT token
*/ */
@ -870,10 +932,12 @@ class LocStor extends BasicStor {
/** /**
* Close import-handle and import playlist * Close import-handle and import playlist
* *
* @param string $token, import token obtained by importPlaylistOpen method * @param string $token
* @return string, result file global id (or error object) * import token obtained by importPlaylistOpen method
* @return string
* result file global id (or error object)
*/ */
function importPlaylistClose($token) function importPlaylistClose($token)
{ {
@ -902,11 +966,13 @@ class LocStor extends BasicStor {
/** /**
* Check whether a Playlist metafile with the given playlist ID exists. * Check whether a Playlist metafile with the given playlist ID exists.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistId, playlist global unique ID * session ID
* @return boolean * @param string $playlistId
* playlist global unique ID
* @return boolean
*/ */
function existsPlaylist($sessid, $playlistId) function existsPlaylist($sessid, $playlistId)
{ {
@ -915,14 +981,17 @@ class LocStor extends BasicStor {
/** /**
* Check whether a Playlist metafile with the given playlist ID * Check whether a Playlist metafile with the given playlist ID
* is available for editing, i.e., exists and is not marked as * is available for editing, i.e., exists and is not marked as
* beeing edited. * being edited.
* *
* @param string $sessid, session ID * @param string $sessid
* @param string $playlistId, playlist global unique ID * session ID
* @param boolean $getUid, optional flag for returning editedby uid * @param string $playlistId
* @return boolean * playlist global unique ID
* @param boolean $getUid
* flag for returning editedby uid
* @return boolean
*/ */
function playlistIsAvailable($sessid, $playlistId, $getUid=FALSE) function playlistIsAvailable($sessid, $playlistId, $getUid=FALSE)
{ {
@ -948,11 +1017,13 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- render methods */ /* ------------------------------------------------------- render methods */
/** /**
* Render playlist to ogg file (open handle) * Render playlist to ogg file (open handle)
* *
* @param string $sessid - session id * @param string $sessid
* @param string $plid - playlist gunid * session id
* @return hasharray: * @param string $plid
* playlist gunid
* @return hasharray
* token: string - render token * token: string - render token
*/ */
function renderPlaylistToFileOpen($sessid, $plid) function renderPlaylistToFileOpen($sessid, $plid)
@ -967,10 +1038,11 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to ogg file (check results) * Render playlist to ogg file (check results)
* *
* @param string $token - render token * @param string $token
* @return hasharray: * render token
* @return hasharray:
* status : string - success | working | fault * status : string - success | working | fault
* url : string - readable url * url : string - readable url
*/ */
@ -986,10 +1058,11 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to ogg file (close handle) * Render playlist to ogg file (close handle)
* *
* @param string $token - render token * @param string $token
* @return boolean status * render token
* @return boolean status
*/ */
function renderPlaylistToFileClose($token) function renderPlaylistToFileClose($token)
{ {
@ -1003,11 +1076,14 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to storage media clip (open handle) * Render playlist to storage media clip (open handle)
* *
* @param string $sessid - session id * @param string $sessid
* @param string $plid - playlist gunid * session id
* @return string - render token * @param string $plid
* playlist gunid
* @return string
* render token
*/ */
function renderPlaylistToStorageOpen($sessid, $plid) function renderPlaylistToStorageOpen($sessid, $plid)
{ {
@ -1025,10 +1101,11 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to storage media clip (check results) * Render playlist to storage media clip (check results)
* *
* @param string $token - render token * @param string $token
* @return hasharray: * render token
* @return hasharray:
* status : string - success | working | fault * status : string - success | working | fault
* gunid : string - gunid of result file * gunid : string - gunid of result file
*/ */
@ -1044,11 +1121,14 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to RSS file (open handle) * Render playlist to RSS file (open handle)
* *
* @param string $sessid - session id * @param string $sessid
* @param string $plid - playlist gunid * session id
* @return string - render token * @param string $plid
* playlist gunid
* @return string
* render token
*/ */
function renderPlaylistToRSSOpen($sessid, $plid) function renderPlaylistToRSSOpen($sessid, $plid)
{ {
@ -1060,10 +1140,11 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to RSS file (check results) * Render playlist to RSS file (check results)
* *
* @param string $token - render token * @param string $token
* @return hasharray : * render token
* @return hasharray :
* status : string - success | working | fault * status : string - success | working | fault
* url : string - readable url * url : string - readable url
*/ */
@ -1084,10 +1165,12 @@ class LocStor extends BasicStor {
/** /**
* Render playlist to RSS file (close handle) * Render playlist to RSS file (close handle)
* *
* @param string $token - render token * @param string $token
* @return boolean status * render token
* @return boolean
* status
*/ */
function renderPlaylistToRSSClose($token) function renderPlaylistToRSSClose($token)
{ {
@ -1107,19 +1190,21 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- backup methods */ /* ------------------------------------------------------- backup methods */
/** /**
* Create backup of storage (open handle) * Create backup of storage (open handle)
* *
* @param string $sessid - session id * @param string $sessid
* @param array $criteria - see search criteria * session id
* @return hasharray: * @param array $criteria
* see search criteria
* @return array
* token : string - backup token * token : string - backup token
*/ */
function createBackupOpen($sessid, $criteria='') function createBackupOpen($sessid, $criteria='')
{ {
require_once "Backup.php"; require_once("Backup.php");
$bu = $r = new Backup($this); $bu = new Backup($this);
if (PEAR::isError($r)) { if (PEAR::isError($bu)) {
return $r; return $bu;
} }
$r = $bu->openBackup($sessid,$criteria); $r = $bu->openBackup($sessid,$criteria);
if ($r === FALSE) { if ($r === FALSE) {
@ -1132,10 +1217,12 @@ class LocStor extends BasicStor {
/** /**
* Create backup of storage (check results) * Create backup of storage (check results)
* *
* @param string $token - backup token * @param string $token
* @return hasharray with field: * backup token
* @return hasharray
* with field:
* status : string - susccess | working | fault * status : string - susccess | working | fault
* faultString: string - description of fault * faultString: string - description of fault
* token : stirng - backup token * token : stirng - backup token
@ -1143,49 +1230,53 @@ class LocStor extends BasicStor {
*/ */
function createBackupCheck($token) function createBackupCheck($token)
{ {
require_once "Backup.php"; require_once("Backup.php");
$bu = $r = new Backup($this); $bu = new Backup($this);
if (PEAR::isError($r)) { if (PEAR::isError($bu)) {
return $r; return $bu;
} }
return $bu->checkBackup($token); return $bu->checkBackup($token);
} }
/** /**
* Create backup of storage (list results) * Create backup of storage (list results)
* *
* @param string $sessid - session id * @param string $sessid
* @param status $stat (optional) * session id
* @param status $stat
* if this parameter is not set, then return with all unclosed backups * if this parameter is not set, then return with all unclosed backups
* @return array of hasharray with field: * @return array
* array of hasharray with field:
* status : string - susccess | working | fault * status : string - susccess | working | fault
* token : stirng - backup token * token : stirng - backup token
* url : string - access url * url : string - access url
*/ */
function createBackupList($sessid, $stat='') function createBackupList($sessid, $stat='')
{ {
require_once "Backup.php"; require_once("Backup.php");
$bu = $r = new Backup($this); $bu = new Backup($this);
if (PEAR::isError($r)) { if (PEAR::isError($bu)) {
return $r; return $bu;
} }
return $bu->listBackups($stat); return $bu->listBackups($stat);
} }
/** /**
* Create backup of storage (close handle) * Create backup of storage (close handle)
* *
* @param string $token - backup token * @param string $token
* @return boolean status * backup token
* @return boolean
* status
*/ */
function createBackupClose($token) function createBackupClose($token)
{ {
require_once "Backup.php"; require_once("Backup.php");
$bu = $r = new Backup($this); $bu = new Backup($this);
if (PEAR::isError($r)) { if (PEAR::isError($bu)) {
return $r; return $bu;
} }
return $bu->closeBackup($token); return $bu->closeBackup($token);
} }
@ -1194,10 +1285,12 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------ restore methods */ /* ------------------------------------------------------ restore methods */
/** /**
* Restore a backup file (open handle) * Restore a backup file (open handle)
* *
* @param string $sessid - session id * @param string $sessid
* @param string $chsum, md5 checksum of imported file * session id
* @param string $chsum
* md5 checksum of imported file
* @return array * @return array
* array with: * array with:
* url string: writable URL * url string: writable URL
@ -1206,9 +1299,9 @@ class LocStor extends BasicStor {
*/ */
function restoreBackupOpen($sessid, $chsum) function restoreBackupOpen($sessid, $chsum)
{ {
$userid = $r =$this->getSessUserId($sessid); $userid = $this->getSessUserId($sessid);
if ($this->dbc->isError($r)) { if ($this->dbc->isError($userid)) {
return $r; return $userid;
} }
$r = $this->bsOpenPut($chsum, NULL, $userid); $r = $this->bsOpenPut($chsum, NULL, $userid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
@ -1219,19 +1312,22 @@ class LocStor extends BasicStor {
/** /**
* Restore a backup file (close put handle) * Restore a backup file (close put handle)
* *
* @param string $sessid - session id * @param string $sessid
* @param string $token - put token * session id
* @return string $token - restore token * @param string $token
* "put" token
* @return string $token
* restore token
*/ */
function restoreBackupClosePut($sessid, $token) { function restoreBackupClosePut($sessid, $token) {
$arr = $r = $this->bsClosePut($token); $arr = $this->bsClosePut($token);
if (PEAR::isError($r)) { if (PEAR::isError($arr)) {
return $r; return $arr;
} }
$fname = $arr['fname']; $fname = $arr['fname'];
require_once 'Restore.php'; require_once('Restore.php');
$rs = new Restore($this); $rs = new Restore($this);
if (PEAR::isError($rs)) { if (PEAR::isError($rs)) {
return $rs; return $rs;
@ -1239,18 +1335,21 @@ class LocStor extends BasicStor {
return $rs->openRestore($sessid, $fname); return $rs->openRestore($sessid, $fname);
} }
/** /**
* Restore a backup file (check state) * Restore a backup file (check state)
* *
* @param string $token - restore token * @param string $token
* @return array status - fields: * restore token
* token: string - restore token * @return array
* status: string - working | fault | success * status - fields:
* faultString: string - description of fault * token: string - restore token
* status: string - working | fault | success
* faultString: string - description of fault
*/ */
function restoreBackupCheck($token) function restoreBackupCheck($token)
{ {
require_once 'Restore.php'; require_once('Restore.php');
$rs = new Restore($this); $rs = new Restore($this);
if (PEAR::isError($rs)) { if (PEAR::isError($rs)) {
return $rs; return $rs;
@ -1260,15 +1359,17 @@ class LocStor extends BasicStor {
/** /**
* Restore a backup file (close handle) * Restore a backup file (close handle)
* *
* @param string $token - restore token * @param string $token
* @return array status - fields: * restore token
* token: string - restore token * @return array
* status: string - working | fault | success * status - fields:
* token: string - restore token
* status: string - working | fault | success
*/ */
function restoreBackupClose($token) { function restoreBackupClose($token) {
require_once 'Restore.php'; require_once('Restore.php');
$rs = new Restore($this); $rs = new Restore($this);
if (PEAR::isError($rs)) { if (PEAR::isError($rs)) {
return $rs; return $rs;

View File

@ -10,10 +10,14 @@ define('PL_URL_RELPATH', '../playlist/');
* *
* Internal playlist format helper. * Internal playlist format helper.
* *
* @author $Author: tomash $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: 1848 $ * @version $Revision: 1848 $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @todo Rename this class * @todo Rename this class
*/ */
class LsPlaylist extends Playlist class LsPlaylist extends Playlist
@ -150,8 +154,13 @@ class LsPlaylist extends Playlist
/** /**
* Several auxiliary classes follows * Several auxiliary classes follows
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @todo Rename this class PlaylistTag * @todo Rename this class PlaylistTag
*/ */
class LsPlaylistTag class LsPlaylistTag
@ -258,8 +267,13 @@ class LsPlaylistTag
/** /**
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @todo Rename this class "PlaylistElement" * @todo Rename this class "PlaylistElement"
*/ */
class LsPlaylistElement { class LsPlaylistElement {
@ -438,8 +452,13 @@ class LsPlaylistElement {
/** /**
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @todo Rename this class to PlaylistAudioClip (notice the caps) * @todo Rename this class to PlaylistAudioClip (notice the caps)
*/ */
class LsPLaylistAudioClip class LsPLaylistAudioClip
@ -518,8 +537,13 @@ class LsPLaylistAudioClip
/** /**
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @todo Rename this class "PlaylistFadeInfo" (notive the caps) * @todo Rename this class "PlaylistFadeInfo" (notive the caps)
*/ */
class LsPLaylistFadeInfo class LsPLaylistFadeInfo
@ -550,9 +574,14 @@ class LsPLaylistFadeInfo
/** /**
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @todo Rename this class to PlaylistMetadata (notive the caps) * @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @todo Rename this class to PlaylistMetadata (notice the caps)
*/ */
class LsPLaylistMetadata class LsPLaylistMetadata
{ {

View File

@ -4,10 +4,14 @@ define('INDCH', ' ');
/** /**
* M3uPlaylist class * M3uPlaylist class
* *
* @author $Author: tomash $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version : $Revision: 1848 $ * @version : $Revision: 1848 $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class M3uPlaylist { class M3uPlaylist {
@ -195,10 +199,14 @@ class M3uPlaylist {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class M3uPlaylistBodyElement { class M3uPlaylistBodyElement {
function convert2lspl(&$tree, $ind='') function convert2lspl(&$tree, $ind='')
@ -231,10 +239,14 @@ class M3uPlaylistBodyElement {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class M3uPlaylistParElement { class M3uPlaylistParElement {
function convert2lspl(&$tree, $ind='') function convert2lspl(&$tree, $ind='')
@ -257,10 +269,14 @@ class M3uPlaylistParElement {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class M3uPlaylistAudioElement { class M3uPlaylistAudioElement {
function convert2lspl(&$tree, $ind='') function convert2lspl(&$tree, $ind='')
@ -313,10 +329,14 @@ class M3uPlaylistAudioElement {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class M3uPlaylistAnimateElement { class M3uPlaylistAnimateElement {
function convert2lspl(&$tree, $ind='') { function convert2lspl(&$tree, $ind='') {

View File

@ -9,39 +9,45 @@ require_once "XML/Util.php";
* File storage support class. * File storage support class.
* Store metadata tree in relational database.<br> * Store metadata tree in relational database.<br>
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see StoredFile * @see StoredFile
* @see XmlParser * @see XmlParser
* @see DataEngine * @see DataEngine
*/ */
class MetaData { class MetaData {
public $config;
public $dbc;
public $mdataTable;
public $gunid;
public $resDir;
public $fname;
public $exists;
/** /**
* Constructor * @param Greenbox $gb
*
* @param Greenbox $gb
* A reference to GreenBox object * A reference to GreenBox object
* @param string $gunid * @param string $gunid
* global unique id * global unique id
* @param string $resDir * @param string $resDir
* resource directory * resource directory
* @return this
*/ */
function MetaData(&$gb, $gunid, $resDir) public function __construct(&$gb, $gunid, $resDir)
{ {
$this->config =& $gb->config; $this->config =& $gb->config;
$this->dbc =& $gb->dbc; $this->dbc =& $gb->dbc;
$this->mdataTable = $gb->mdataTable; $this->mdataTable = $gb->mdataTable;
$this->gunid = $gunid; $this->gunid = $gunid;
$this->resDir = $resDir; $this->resDir = $resDir;
$this->fname = $this->makeFname(); $this->fname = $this->makeFname();
$this->exists = $this->exists = null;
$this->dbCheck($gunid) &&
is_file($this->fname) &&
is_readable($this->fname);
} }
@ -60,7 +66,7 @@ class MetaData {
*/ */
function insert($mdata, $loc='file', $format=NULL) function insert($mdata, $loc='file', $format=NULL)
{ {
if ($this->exists) { if ($this->exists()) {
return FALSE; return FALSE;
} }
$tree =& $this->parse($mdata, $loc); $tree =& $this->parse($mdata, $loc);
@ -128,7 +134,7 @@ class MetaData {
*/ */
function replace($mdata, $loc='file', $format=NULL) function replace($mdata, $loc='file', $format=NULL)
{ {
if ($this->exists) { if ($this->exists()) {
$res = $this->delete(); $res = $this->delete();
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
@ -139,20 +145,25 @@ class MetaData {
/** /**
* Return true if metadata exists * Return true if metadata exists
* *
* @return boolean * @return boolean
*/ */
function exists() function exists()
{ {
if (is_null($this->exists)) {
$this->exists = $this->dbCheck($gunid) &&
is_file($this->fname) &&
is_readable($this->fname);
}
return $this->exists; return $this->exists;
} }
/** /**
* Delete all file's metadata * Delete all file's metadata
* *
* @return true or PEAR::error * @return TRUE|PEAR_Error
*/ */
function delete() function delete()
{ {
@ -616,7 +627,7 @@ class MetaData {
{ {
if ($this->config['validate'] && !is_null($this->format)) { if ($this->config['validate'] && !is_null($this->format)) {
require_once("Validator.php"); require_once("Validator.php");
$val =& new Validator($this->format, $this->gunid); $val = new Validator($this->format, $this->gunid);
if (PEAR::isError($val)) { if (PEAR::isError($val)) {
return $val; return $val;
} }
@ -646,7 +657,7 @@ class MetaData {
{ {
if ($this->config['validate'] && !is_null($this->format)) { if ($this->config['validate'] && !is_null($this->format)) {
require_once("Validator.php"); require_once("Validator.php");
$val =& new Validator($this->format, $this->gunid); $val = new Validator($this->format, $this->gunid);
if (PEAR::isError($val)) { if (PEAR::isError($val)) {
return $val; return $val;
} }

View File

@ -4,10 +4,14 @@
* *
* remark: dcterms:extent format: hh:mm:ss.ssssss * remark: dcterms:extent format: hh:mm:ss.ssssss
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class Playlist extends StoredFile { class Playlist extends StoredFile {
@ -185,15 +189,15 @@ class Playlist extends StoredFile {
function setAuxMetadata() function setAuxMetadata()
{ {
// get info about playlist // get info about playlist
$plInfo = $r = $this->getPlInfo(); $plInfo = $this->getPlInfo();
if (PEAR::isError($r)) { if (PEAR::isError($plInfo)) {
return $r; return $plInfo;
} }
extract($plInfo); // 'plLen', 'parid', 'metaParid' extract($plInfo); // 'plLen', 'parid', 'metaParid'
// set gunid as id attr in playlist tag: // set gunid as id attr in playlist tag:
$mid = $r = $this->_getMidOrInsert('id', $parid, $this->gunid, 'A'); $mid = $this->_getMidOrInsert('id', $parid, $this->gunid, 'A');
if (PEAR::isError($r)) { if (PEAR::isError($mid)) {
return $r; return $mid;
} }
$r = $this->_setValueOrInsert( $r = $this->_setValueOrInsert(
$mid, $this->gunid, $parid, 'id', 'A'); $mid, $this->gunid, $parid, 'id', 'A');
@ -1160,11 +1164,16 @@ class Playlist extends StoredFile {
/** /**
* Auxiliary class for GB playlist editing methods * Auxiliary class for GB playlist editing methods
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class PlaylistElement { class PlaylistElement {
var $pl = NULL; private $pl = NULL;
var $plEl = NULL; private $plEl = NULL;
function PlaylistElement(&$pl, $plEl) function PlaylistElement(&$pl, $plEl)
{ {

View File

@ -3,10 +3,14 @@
/** /**
* Preference storage class. * Preference storage class.
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see StoredFile * @see StoredFile
*/ */
/* ================== Prefs ================== */ /* ================== Prefs ================== */
@ -18,7 +22,7 @@ class Prefs {
* @param GreenBox $gb * @param GreenBox $gb
* GreenBox object reference * GreenBox object reference
*/ */
function Prefs(&$gb) public function __construct(&$gb)
{ {
$this->gb =& $gb; $this->gb =& $gb;
$this->dbc =& $gb->dbc; $this->dbc =& $gb->dbc;

View File

@ -217,10 +217,14 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
* File storage support class * File storage support class
* Store media files in real filesystem and handle access to them. * Store media files in real filesystem and handle access to them.
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see StoredFile * @see StoredFile
*/ */
class RawMediaData { class RawMediaData {
@ -233,7 +237,7 @@ class RawMediaData {
* @param string $resDir * @param string $resDir
* resource directory * resource directory
*/ */
function RawMediaData($gunid, $resDir) public function __construct($gunid, $resDir)
{ {
$this->gunid = $gunid; $this->gunid = $gunid;
$this->resDir = $resDir; $this->resDir = $resDir;

View File

@ -8,10 +8,14 @@ require_once "LsPlaylist.php";
* *
* Playlist to file rendering - PHP layer, caller to the renderer executable * Playlist to file rendering - PHP layer, caller to the renderer executable
* *
* @author $Author: tomash $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: 1949 $ * @version $Revision: 1949 $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see LocStor * @see LocStor
*/ */
class Renderer class Renderer

View File

@ -2,53 +2,61 @@
define('ACCESS_TYPE', 'restore'); define('ACCESS_TYPE', 'restore');
/** /**
* @author $Author: $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: $ * @version $Revision: $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class Restore { class Restore {
/** /**
* string - name of logfile * Name of logfile
* @var string
*/ */
var $logFile; private $logFile;
/** /**
* string - session id * session id
* @var string
*/ */
var $sessid; private $sessid;
/** /**
* string - token * @var string
*/ */
var $token; private $token;
/**
* string - name of statusfile
*/
var $statusFile;
/**
* string - name of temporary directory, to here extract the backup tarball
*/
var $tmpDir;
/** /**
* string - loglevel * Name of statusfile
* @var string
*/ */
var $loglevel = 'warn'; private $statusFile;
#var $loglevel = 'debug';
/** /**
* greenbox object reference * Name of temporary directory, to here extract the backup tarball
* @var string
*/ */
var $gb; private $tmpDir;
/**
* @var string
*/
private $loglevel = 'warn';
#private $loglevel = 'debug';
/**
* @var GreenBox
*/
private $gb;
/** /**
* Constructor
*
* @param GreenBox $gb * @param GreenBox $gb
* greenbox object reference * greenbox object reference
*/ */
function Restore (&$gb) { public function __construct(&$gb) {
$this->gb =& $gb; $this->gb =& $gb;
$this->token = null; $this->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log'; $this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';

View File

@ -6,10 +6,14 @@ require_once "XmlParser.php";
/** /**
* SmilPlaylist class * SmilPlaylist class
* *
* @author $Author: tomash $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: 1848 $ * @version $Revision: 1848 $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class SmilPlaylist { class SmilPlaylist {
@ -122,10 +126,14 @@ class SmilPlaylist {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class SmilPlaylistBodyElement { class SmilPlaylistBodyElement {
@ -161,10 +169,14 @@ class SmilPlaylistBodyElement {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class SmilPlaylistParElement { class SmilPlaylistParElement {
@ -190,10 +202,14 @@ class SmilPlaylistParElement {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class SmilPlaylistAudioElement { class SmilPlaylistAudioElement {
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
@ -273,10 +289,14 @@ class SmilPlaylistAudioElement {
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class SmilPlaylistAnimateElement { class SmilPlaylistAnimateElement {

View File

@ -14,24 +14,50 @@ require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
* - represented by RawMediaData class</li> * - represented by RawMediaData class</li>
* </ul> * </ul>
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see GreenBox * @see GreenBox
* @see MetaData * @see MetaData
* @see RawMediaData * @see RawMediaData
*/ */
class StoredFile { class StoredFile {
var $gb; /**
var $dbc; * @var GreenBox
var $filesTable; */
var $accessTable; public $gb;
var $gunid;
var $resDir; /**
var $accessDir; * @var DB
var $rmd; */
var $md; public $dbc;
/**
* Name of a database table.
* @var string
*/
public $filesTable;
/**
* Name of a database table.
* @var string
*/
public $accessTable;
public $gunid;
private $resDir;
private $accessDir;
/**
* @var RawMediaData
*/
public $rmd;
public $md;
/* ========================================================== constructor */ /* ========================================================== constructor */
/** /**
@ -39,10 +65,9 @@ class StoredFile {
* *
* @param GreenBox $gb * @param GreenBox $gb
* @param string $gunid * @param string $gunid
* optional, globally unique id of file * globally unique id of file
* @return this
*/ */
function StoredFile(&$gb, $gunid=NULL) public function __construct(&$gb, $gunid=NULL)
{ {
$this->gb =& $gb; $this->gb =& $gb;
$this->dbc =& $gb->dbc; $this->dbc =& $gb->dbc;
@ -54,8 +79,8 @@ class StoredFile {
} }
$this->resDir = $this->_getResDir($this->gunid); $this->resDir = $this->_getResDir($this->gunid);
$this->accessDir = $this->gb->accessDir; $this->accessDir = $this->gb->accessDir;
$this->rmd =& new RawMediaData($this->gunid, $this->resDir); $this->rmd = new RawMediaData($this->gunid, $this->resDir);
$this->md =& new MetaData($gb, $this->gunid, $this->resDir); $this->md = new MetaData($gb, $this->gunid, $this->resDir);
# return $this->gunid; # return $this->gunid;
} }
@ -87,7 +112,7 @@ class StoredFile {
$mediaFileLP='', $metadata='', $mdataLoc='file', $mediaFileLP='', $metadata='', $mdataLoc='file',
$gunid=NULL, $ftype=NULL, $className='StoredFile') $gunid=NULL, $ftype=NULL, $className='StoredFile')
{ {
$ac =& new $className($gb, ($gunid ? $gunid : NULL)); $ac = new $className($gb, ($gunid ? $gunid : NULL));
if (PEAR::isError($ac)) { if (PEAR::isError($ac)) {
return $ac; return $ac;
} }
@ -200,7 +225,7 @@ class StoredFile {
return $r; return $r;
} }
$gunid = StoredFile::_normalizeGunid($row['gunid']); $gunid = StoredFile::_normalizeGunid($row['gunid']);
$ac =& new $className($gb, $gunid); $ac = new $className($gb, $gunid);
$ac->mime = $row['mime']; $ac->mime = $row['mime'];
$ac->name = $row['name']; $ac->name = $row['name'];
$ac->id = $row['id']; $ac->id = $row['id'];
@ -259,10 +284,11 @@ 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 StoredFile $src
* source object
* @param int $nid * @param int $nid
* new local id * new local id
* @return unknown * @return StoredFile
*/ */
function &copyOf(&$src, $nid) function &copyOf(&$src, $nid)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -3,26 +3,60 @@
define('TR_LEAVE_CLOSED', TRUE); define('TR_LEAVE_CLOSED', TRUE);
/** /**
* Auxiliary class for transport records * Auxiliary class for transport records
* *
* @author $Author: tomash $ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: 1946 $ * @version $Revision: 1946 $
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class TransportRecord class TransportRecord
{ {
var $dbc; /**
var $recalled = FALSE; * @var DB
var $dropped = FALSE; */
public $dbc;
/** /**
* Constructor * @var GreenBox
*
* @param Transport $tr object reference
* @return TransportRecord object instance
*/ */
function TransportRecord(&$tr) private $gb;
/**
* @var array
*/
private $config;
/**
* @var string
*/
private $transTable;
/**
* @var Transport
*/
private $tr;
/**
* @var boolean
*/
private $recalled = FALSE;
/**
* @var boolean
*/
private $dropped = FALSE;
/**
* @param Transport $tr
* @return TransportRecord
*/
public function __construct(&$tr)
{ {
$this->tr =& $tr; $this->tr =& $tr;
$this->gb =& $tr->gb; $this->gb =& $tr->gb;
@ -46,8 +80,8 @@ class TransportRecord
*/ */
function create(&$tr, $trtype, $direction='up', $defaults=array()) function create(&$tr, $trtype, $direction='up', $defaults=array())
{ {
$trec =& new TransportRecord($tr); $trec = new TransportRecord($tr);
$trec->trtok = $trtok = $tr->_createTrtok(); $trec->trtok = $trtok = $tr->_createTransportToken();
$trec->row = array_merge($defaults, $trec->row = array_merge($defaults,
array('trtype'=>$trtype, 'direction'=>$direction)); array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE; $trec->recalled = TRUE;
@ -60,7 +94,7 @@ class TransportRecord
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq"); $id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
$names = "id, trtok, direction, state, trtype, start, ts"; $names = "id, trtok, direction, state, trtype, start, ts";
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()"; $values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
foreach ($defaults as $k=>$v) { foreach ($defaults as $k => $v) {
$sqlVal = $trec->_getSqlVal($k, $v); $sqlVal = $trec->_getSqlVal($k, $v);
$names .= ", $k"; $names .= ", $k";
$values .= ", $sqlVal"; $values .= ", $sqlVal";
@ -71,16 +105,16 @@ class TransportRecord
VALUES VALUES
($values) ($values)
"; ";
$res = $r = $trec->dbc->query($query); $res = $trec->dbc->query($query);
if (PEAR::isError($r)) { if (PEAR::isError($res)) {
return $r; return $res;
} }
return $trec; return $trec;
} }
/** /**
* Recall transport record from DB * Recall transport record from DB
* *
* @param Transport $tr * @param Transport $tr
* @param string $trtok * @param string $trtok
@ -89,9 +123,9 @@ class TransportRecord
*/ */
function recall(&$tr, $trtok) function recall(&$tr, $trtok)
{ {
$trec =& new TransportRecord($tr); $trec = new TransportRecord($tr);
$trec->trtok = $trtok; $trec->trtok = $trtok;
$row = $r = $trec->dbc->getRow(" $row = $trec->dbc->getRow("
SELECT SELECT
id, trtok, state, trtype, direction, id, trtok, state, trtype, direction,
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken, to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
@ -101,8 +135,8 @@ class TransportRecord
FROM {$trec->transTable} FROM {$trec->transTable}
WHERE trtok='$trtok' WHERE trtok='$trtok'
"); ");
if (PEAR::isError($r)) { if (PEAR::isError($row)) {
return $r; return $row;
} }
if (is_null($row)) { if (is_null($row)) {
return PEAR::raiseError("TransportRecord::recall:". return PEAR::raiseError("TransportRecord::recall:".
@ -118,15 +152,15 @@ class TransportRecord
/** /**
* Set state of transport record * Set state of transport record
* *
* @param string $newState * @param string $newState
* @param array $data * @param array $data
* other data fields to set * other data fields to set
* @param string $oldState * @param string $oldState
* (opt.) check old state and do nothing if differ * check old state and do nothing if differ
* @param boolean $lock * @param boolean $lock
* (opt.) check lock and do nothing if differ * check lock and do nothing if differ
* @return boolean success * @return boolean success
*/ */
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL) function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
@ -152,9 +186,9 @@ class TransportRecord
return $r; return $r;
} }
// return TRUE; // return TRUE;
$affRows = $r = $this->dbc->affectedRows(); $affRows = $this->dbc->affectedRows();
if (PEAR::isError($r)) { if (PEAR::isError($affRows)) {
return $r; return $affRows;
} }
return ($affRows == 1); return ($affRows == 1);
} }
@ -201,9 +235,9 @@ class TransportRecord
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$affRows = $r = $this->dbc->affectedRows(); $affRows = $this->dbc->affectedRows();
if (PEAR::isError($r)) { if (PEAR::isError($affRows)) {
return $r; return $affRows;
} }
if ($affRows != 1) { if ($affRows != 1) {
$ltxt = ($lock ? 'lock' : 'unlock' ); $ltxt = ($lock ? 'lock' : 'unlock' );
@ -333,21 +367,21 @@ class TransportRecord
function getTitle() function getTitle()
{ {
$defStr = 'unknown'; $defStr = 'unknown';
$trtype = $r = $this->getTransportType(); //contains recall check $trtype = $this->getTransportType(); //contains recall check
if (PEAR::isError($r)) { if (PEAR::isError($trtype)) {
return $r; return $trtype;
} }
switch ($trtype) { switch ($trtype) {
case "audioclip": case "audioclip":
case "playlist": case "playlist":
case "playlistPkg": case "playlistPkg":
case "metadata": case "metadata":
$title = $r = $this->gb->bsGetTitle(NULL, $this->row['gunid']); $title = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
if (PEAR::isError($r)) { if (PEAR::isError($title)) {
if ($r->getCode()==GBERR_FOBJNEX) { if ($title->getCode() == GBERR_FOBJNEX) {
$title = $defStr; $title = $defStr;
} else { } else {
return $r; return $title;
} }
} }
break; break;

View File

@ -23,24 +23,33 @@ define('VAL_PREDXML', 121);
* </ul> * </ul>
* It probably should be replaced by XML schema validation in the future. * It probably should be replaced by XML schema validation in the future.
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
class Validator { class Validator {
/** /**
* string - format type of validated document * Format type of validated document
* @var string
*/ */
var $format = NULL; private $format = NULL;
/** /**
* Preloaded format tree structure * Preloaded format tree structure
* @var array
*/ */
var $formTree = NULL; private $formTree = NULL;
/** /**
* string - gunid of validated file for identification in mass input * Gunid of validated file for identification in mass input
* @var string
*/ */
var $gunid = NULL; private $gunid = NULL;
/** /**
@ -51,11 +60,11 @@ class Validator {
* @param string $gunid * @param string $gunid
* gunid of validated file for identification in mass input * gunid of validated file for identification in mass input
*/ */
function Validator($format, $gunid) public function __construct($format, $gunid)
{ {
$format = strtolower($format); $format = strtolower($format);
$this->format = $format; $this->format = $format;
$this->gunid = $gunid; $this->gunid = $gunid;
$formats = array( $formats = array(
'audioclip' => "audioClipFormat", 'audioclip' => "audioClipFormat",
'playlist' => "playlistFormat", 'playlist' => "playlistFormat",
@ -69,7 +78,7 @@ class Validator {
if (!file_exists($formatFile)) { if (!file_exists($formatFile)) {
return $this->_err(VAL_FORMAT); return $this->_err(VAL_FORMAT);
} }
require $formatFile; require($formatFile);
$this->formTree = $$formatName; $this->formTree = $$formatName;
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
@ -12,58 +13,71 @@ require_once "XML/Util.php";
/** /**
* Object representation of one XML element * Object representation of one XML element
* *
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see MetaData * @see MetaData
*/ */
class XmlElement { class XmlElement {
/** /**
* Namespace prefix * Namespace prefix
* @var string
*/ */
var $ns; public $ns;
/**
* Element name
*/
var $name;
/**
* Attributes
*/
var $attrs = array();
/**
* Namespace definitions
*/
var $nSpaces = array();
/**
* Child nodes
*/
var $children = array();
/**
* Text content of element
*/
var $content = '';
/** /**
* Constructor * Element name
* * @var string
* @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()) public $name;
/**
* Attributes
* @var array
*/
public $attrs = array();
/**
* Namespace definitions
* @var array
*/
public $nSpaces = array();
/**
* Child nodes
* @var array
*/
public $children = array();
/**
* Text content of element
* @var string
*/
public $content = '';
/**
* @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
*/
public function __construct($fullname, $attrs, $nSpaces=array(), $children=array())
{ {
$a = XML_Util::splitQualifiedName($fullname); $a = XML_Util::splitQualifiedName($fullname);
$this->ns = $a['namespace']; $this->ns = $a['namespace'];
$this->name = $a['localPart']; $this->name = $a['localPart'];
$this->attrs = $attrs; $this->attrs = $attrs;
$this->nSpaces = $nSpaces; $this->nSpaces = $nSpaces;
$this->children = $children; $this->children = $children;
} }
} // class XmlElement } // class XmlElement
@ -73,39 +87,47 @@ class XmlElement {
/** /**
* Object representation of one XML attribute * Object representation of one XML attribute
* *
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see MetaData * @see MetaData
*/ */
class XmlAttrib { class XmlAttrib {
/** /**
* Namespace prefix * Namespace prefix
* @var string
*/ */
var $ns; public $ns;
/** /**
* Attribute name * Attribute name
* @var string
*/ */
var $name; public $name;
/** /**
* Attribute value * Attribute value
* @var string
*/ */
var $val; public $val;
/** /**
* Constructor * @param string $atns
*
* @param string $atns
* namespace prefix * namespace prefix
* @param string $atnm * @param string $atnm
* attribute name * attribute name
* @param string $atv * @param string $atv
* attribute value * attribute value
* @return this
*/ */
function XmlAttrib($atns, $atnm, $atv) public function __construct($atns, $atnm, $atv)
{ {
$this->ns = $atns; $this->ns = $atns;
$this->name = $atnm; $this->name = $atnm;
$this->val = $atv; $this->val = $atv;
} }
} // fn XmlAttrib } // fn XmlAttrib
@ -114,32 +136,39 @@ class XmlAttrib {
/** /**
* XML parser object encapsulation * XML parser object encapsulation
* *
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @see MetaData * @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see MetaData
*/ */
class XmlParser { class XmlParser {
/** /**
* Tree of nodes * Tree of nodes
* @var array
*/ */
var $tree = NULL; private $tree = NULL;
/**
* Parse stack
*/
var $stack = array();
/**
* Error structure
*/
var $err = array(FALSE, '');
/** /**
* Constructor * Parse stack
* * @var array
* @param string $data
* XML string to be parsed
* @return this
*/ */
function XmlParser($data){ private $stack = array();
/**
* Error structure
* @var array
*/
private $err = array(FALSE, '');
/**
* @param string $data
* XML string to be parsed
*/
public function __construct($data){
$xml_parser = xml_parser_create('UTF-8'); $xml_parser = xml_parser_create('UTF-8');
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE);
xml_set_object($xml_parser, $this); xml_set_object($xml_parser, $this);
@ -185,7 +214,7 @@ class XmlParser {
} }
$data = file_get_contents($data); $data = file_get_contents($data);
case "string": case "string":
$parser =& new XmlParser($data); $parser = new XmlParser($data);
if ($parser->isError()) { if ($parser->isError()) {
return PEAR::raiseError( return PEAR::raiseError(
"SmilPlaylist::parse: ".$parser->getError() "SmilPlaylist::parse: ".$parser->getError()
@ -234,13 +263,13 @@ class XmlParser {
/** /**
* End tag handler * End tag handler
* *
* @param resource $parser * @param resource $parser
* reference to parser resource * reference to parser resource
* @param string $fullname * @param string $fullname
* element name * element name
* @return none * @return none
*/ */
function endTag($parser, $fullname) { function endTag($parser, $fullname) {
$cnt = count($this->stack); $cnt = count($this->stack);

View File

@ -23,20 +23,24 @@ require_once (dirname(__FILE__).'/../conf.php');
*/ */
class Cron { class Cron {
/** /**
* @var reference Crontab object reference * @var Crontab
*/ */
var $ct; public $ct;
/** /**
* @var array This array created with getCommand() function * @var array This array created with getCommand() function
* @access private
*/ */
var $params; private $params;
/** /**
* @var string available values: read | write * @var string available values: read | write
*/ */
var $ctAccess = 'read'; private $ctAccess = 'read';
private $lockfile;
private $cronfile;
private $paramdir;
private $cronUserName;
/** /**
* Constructor * Constructor

View File

@ -9,6 +9,7 @@ define('CRON_EMPTY', 4);
* A class that interfaces with the crontab. (cjpa@audiophile.com) * 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. * This class lets you manipulate the crontab. It lets you add delete update entries easily.
*
* @author $Author: $ * @author $Author: $
* @version $Revision: $ * @version $Revision: $
* @package Campcaster * @package Campcaster
@ -18,7 +19,7 @@ class Crontab
{ {
// {{{ properties // {{{ properties
/** /**
* @var array holds all the different lines. * Holds all the different lines.
* Lines are associative arrays with the following fields: * Lines are associative arrays with the following fields:
* "minute" : holds the minutes (0-59) * "minute" : holds the minutes (0-59)
* "hour" : holds the hour (0-23) * "hour" : holds the hour (0-23)
@ -30,20 +31,23 @@ class Crontab
* "name" => "value" * "name" => "value"
* or a line can be a comment (string beginning with #) * or a line can be a comment (string beginning with #)
* or it can be a special command (beginning with an @) * or it can be a special command (beginning with an @)
* @var array
*/ */
var $crontabs; private $crontabs;
/** /**
* @var string the user for whom the crontab will be manipulated * The user for whom the crontab will be manipulated
* @var string
*/ */
var $user; private $user;
/** /**
* @var string Lists the type of line of each line in $crontabs. * Lists the type of line of each line in $crontabs.
* can be: any of the CRON_* constants. * can be: any of the CRON_* constants.
* so $linetype[5] is the type of $crontabs[5]. * so $linetype[5] is the type of $crontabs[5].
* @var string
*/ */
var $linetypes; private $linetypes;
// }}} // }}}

View File

@ -9,8 +9,8 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new LocStor($dbc, $config); $gb = new LocStor($dbc, $config);
$tr =& new Transport($gb); $tr = new Transport($gb);
$r = $tr->cronMain(); $r = $tr->cronMain();
if(!$r) exit(1); if(!$r) exit(1);

View File

@ -9,24 +9,26 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new LocStor($dbc, $config); $gb = new LocStor($dbc, $config);
$tr =& new Transport($gb); $tr = new Transport($gb);
list(, $trtok) = $_SERVER['argv']; list(, $trtok) = $_SERVER['argv'];
if (TR_LOG_LEVEL>1) { if (TR_LOG_LEVEL > 1) {
$tr->trLog("transportCronJob start ($trtok)"); $tr->trLog("transportCronJob start ($trtok)");
} }
// 4-pass on job: // 4-pass on job:
$cnt = 4; $cnt = 4;
for ($i = 0; $i < $cnt; $i++, sleep(1)){ for ($i = 0; $i < $cnt; $i++, sleep(1)) {
// run the action: // run the action:
$r = $tr->cronCallMethod($trtok); $r = $tr->cronCallMethod($trtok);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
$tr->trLogPear("transportCronJob: ($trtok): ", $r); $tr->trLogPear("transportCronJob: ($trtok): ", $r);
} else { } else {
# $tr->trLog("X transportCronJob: ".var_export($r, TRUE)); # $tr->trLog("X transportCronJob: ".var_export($r, TRUE));
if($r!==TRUE) $tr->trLog("transportCronJob: ($trtok): nonTRUE returned"); if ($r !== TRUE) {
$tr->trLog("transportCronJob: ($trtok): nonTRUE returned");
}
} }
#if(!$r) exit(1); #if(!$r) exit(1);
#sleep(2); #sleep(2);

View File

@ -49,9 +49,9 @@ if(PEAR::isError($dbc)){
} }
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new GreenBox($dbc, $config, TRUE); $gb = new GreenBox($dbc, $config, TRUE);
$tr =& new Transport($gb); $tr = new Transport($gb);
$pr =& new Prefs($gb); $pr = new Prefs($gb);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// install // install

View File

@ -42,9 +42,9 @@ if(PEAR::isError($dbc)){
echo "#StorageServer uninstall:\n"; echo "#StorageServer uninstall:\n";
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config, TRUE); $gb = new GreenBox($dbc, $config, TRUE);
$tr =& new Transport($gb); $tr = new Transport($gb);
$pr =& new Prefs($gb); $pr = new Prefs($gb);
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);
echo "# Uninstall Prefs submodule"; echo "# Uninstall Prefs submodule";

View File

@ -1,9 +1,13 @@
<?php <?php
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @package Campcaster * @package Campcaster
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */

View File

@ -11,11 +11,11 @@ require_once '../conf.php';
require_once 'DB.php'; require_once 'DB.php';
require_once '../GreenBox.php'; require_once '../GreenBox.php';
#$rmd =& new RawMediaData('qwerty', '../stor'); #$rmd = new RawMediaData('qwerty', '../stor');
#$r = $rmd->insert('./ex1.mp3', 'mp3'); #$r = $rmd->insert('./ex1.mp3', 'mp3');
#$r = $rmd->test('./ex1.mp3', './ex2.wav', '../access/xyz.ext'); #$r = $rmd->test('./ex1.mp3', './ex2.wav', '../access/xyz.ext');
$rmd =& new RawMediaData($gunid, '../stor/'.substr($gunid, 0, 3)); $rmd = new RawMediaData($gunid, '../stor/'.substr($gunid, 0, 3));
$r = $rmd->analyze(); $r = $rmd->analyze();
echo "r=$r (".gettype($r).")\n"; echo "r=$r (".gettype($r).")\n";

View File

@ -11,9 +11,9 @@ require_once '../LocStor.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN); PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE); $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config); $gb = new GreenBox($dbc, $config);
$tr = &new Transport($gb); $tr = new Transport($gb);
$ls = &new LocStor($dbc, $config); $ls = new LocStor($dbc, $config);
@unlink("{$tr->transDir}/activity.log"); @unlink("{$tr->transDir}/activity.log");
@unlink("{$tr->transDir}/debug.log"); @unlink("{$tr->transDir}/debug.log");
$tr->_cleanUp(); $tr->_cleanUp();

View File

@ -10,7 +10,7 @@ require_once '../GreenBox.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN); PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE); $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config); $gb = new GreenBox($dbc, $config);
#$gunid = "123456789abcdee0"; #$gunid = "123456789abcdee0";
$gunid = ""; $gunid = "";

View File

@ -1,7 +1,11 @@
<?php <?php
/** /**
* @author $Author$ * @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$ * @version $Revision$
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/ */
$webstreamFormat = array( $webstreamFormat = array(

View File

@ -2,12 +2,12 @@
require_once dirname(__FILE__).'/../LocStor.php'; require_once dirname(__FILE__).'/../LocStor.php';
/** /**
* XML-RPC interface for LocStor class * XML-RPC interface for LocStor class
* @author $Author$ * @author $Author$
* @version $Revision$ * @version $Revision$
* *
*/ */
class XR_LocStor extends LocStor{ class XR_LocStor extends LocStor {
/* ----------------------------------------------------------- getVersion */ /* ----------------------------------------------------------- getVersion */
/** /**
@ -39,9 +39,11 @@ class XR_LocStor extends LocStor{
function xr_getVersion($input) function xr_getVersion($input)
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if (!$ok) {
return $r;
}
$res = $this->getVersion(); $res = $this->getVersion();
if(PEAR::isError($res)){ if (PEAR::isError($res)) {
return new XML_RPC_Response(0, 805, return new XML_RPC_Response(0, 805,
"xr_getVersion: ".$res->getMessage(). "xr_getVersion: ".$res->getMessage().
" ".$res->getUserInfo() " ".$res->getUserInfo()
@ -52,6 +54,7 @@ class XR_LocStor extends LocStor{
); );
} }
/* ------------------------------------------------------- authentication */ /* ------------------------------------------------------- authentication */
/** /**
* Checks the login name and password of the user and return * Checks the login name and password of the user and return
@ -85,9 +88,11 @@ class XR_LocStor extends LocStor{
function xr_authenticate($input) function xr_authenticate($input)
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if (!$ok) {
return $r;
}
$res = $this->authenticate($r['login'], $r['pass']); $res = $this->authenticate($r['login'], $r['pass']);
if(PEAR::isError($res)){ if (PEAR::isError($res)) {
return new XML_RPC_Response(0, 804, return new XML_RPC_Response(0, 804,
"xr_authenticate: ".$res->getMessage(). "xr_authenticate: ".$res->getMessage().
" ".$res->getUserInfo() " ".$res->getUserInfo()
@ -99,6 +104,7 @@ class XR_LocStor extends LocStor{
); );
} }
/** /**
* Checks the login name and password of the user. If the login is * Checks the login name and password of the user. If the login is
* correct, a new session ID string is generated, to be used in all * correct, a new session ID string is generated, to be used in all
@ -2451,7 +2457,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php'; require_once dirname(__FILE__).'/../Prefs.php';
$pr =& new Prefs($this); $pr = new Prefs($this);
$res = $pr->loadPref($r['sessid'], $r['key']); $res = $pr->loadPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2502,7 +2508,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php'; require_once dirname(__FILE__).'/../Prefs.php';
$pr =& new Prefs($this); $pr = new Prefs($this);
$res = $pr->savePref($r['sessid'], $r['key'], $r['value']); $res = $pr->savePref($r['sessid'], $r['key'], $r['value']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2552,7 +2558,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php'; require_once dirname(__FILE__).'/../Prefs.php';
$pr =& new Prefs($this); $pr = new Prefs($this);
$res = $pr->delPref($r['sessid'], $r['key']); $res = $pr->delPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2604,7 +2610,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php'; require_once dirname(__FILE__).'/../Prefs.php';
$pr =& new Prefs($this); $pr = new Prefs($this);
$res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']); $res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2660,7 +2666,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php'; require_once dirname(__FILE__).'/../Prefs.php';
$pr =& new Prefs($this); $pr = new Prefs($this);
$res = $pr->saveGroupPref($r['sessid'], $r['group'], $r['key'], $r['value']); $res = $pr->saveGroupPref($r['sessid'], $r['group'], $r['key'], $r['value']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2719,7 +2725,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->getTransportInfo($r['trtok']); $res = $tr->getTransportInfo($r['trtok']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2769,7 +2775,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->turnOnOffTransports($r['onOff']); $res = $tr->turnOnOffTransports($r['onOff']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2819,7 +2825,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->doTransportAction($r['trtok'], $r['action']); $res = $tr->doTransportAction($r['trtok'], $r['action']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2870,7 +2876,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->uploadFile2Hub($r['filePath']); // local files on XML-RPC :( $res = $tr->uploadFile2Hub($r['filePath']); // local files on XML-RPC :(
// there should be something as uploadFile2storageServer // there should be something as uploadFile2storageServer
if(PEAR::isError($res)){ if(PEAR::isError($res)){
@ -2924,7 +2930,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->getHubInitiatedTransfers(); $res = $tr->getHubInitiatedTransfers();
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2972,8 +2978,8 @@ class XR_LocStor extends LocStor{
function xr_startHubInitiatedTransfer($input) { function xr_startHubInitiatedTransfer($input) {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once('../Transport.php');
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->startHubInitiatedTransfer($r['trtok']); $res = $tr->startHubInitiatedTransfer($r['trtok']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -3025,7 +3031,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->upload2Hub($r['gunid']); $res = $tr->upload2Hub($r['gunid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -3075,7 +3081,7 @@ class XR_LocStor extends LocStor{
list($ok, $par) = $this->_xr_getPars($input); list($ok, $par) = $this->_xr_getPars($input);
if(!$ok) return $par; if(!$ok) return $par;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$uid = $r = $this->getSessUserId($par['sessid']); // ### $uid = $r = $this->getSessUserId($par['sessid']); // ###
$res = $tr->downloadFromHub($uid, $par['gunid']); $res = $tr->downloadFromHub($uid, $par['gunid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
@ -3127,7 +3133,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->globalSearch($r['criteria']); $res = $tr->globalSearch($r['criteria']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -3189,7 +3195,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once '../Transport.php'; require_once '../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->getSearchResults($r['trtok']); $res = $tr->getSearchResults($r['trtok']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -3241,7 +3247,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php'; require_once dirname(__FILE__).'/../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->uploadToArchive($r['gunid'], $r['sessid']); $res = $tr->uploadToArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -3291,7 +3297,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php'; require_once dirname(__FILE__).'/../Transport.php';
$tr =& new Transport($this); $tr = new Transport($this);
$res = $tr->downloadFromArchive($r['gunid'], $r['sessid']); $res = $tr->downloadFromArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());

View File

@ -35,7 +35,7 @@ require_once dirname(__FILE__).'/../LocStor.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN); PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE); $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new LocStor($dbc, $config); $gb = new LocStor($dbc, $config);
function http_error($code, $err){ function http_error($code, $err){
header("HTTP/1.1 $code"); header("HTTP/1.1 $code");

View File

@ -5,9 +5,9 @@
*/ */
/* ================================================================= includes */ /* ================================================================= includes */
include_once dirname(__FILE__)."/../conf.php"; include_once(dirname(__FILE__)."/../conf.php");
require_once 'DB.php'; require_once('DB.php');
include_once "XML/RPC.php"; include_once("XML/RPC.php");
/* ================================================== method definition array */ /* ================================================== method definition array */
/** /**
@ -333,42 +333,54 @@ $mdefs = array(
/* ======================================================== class definitions */ /* ======================================================== class definitions */
class SchedulerPhpClient{ class SchedulerPhpClient {
/** /**
* Databases object reference * Databases object reference
* @var DB
*/ */
var $dbc = NULL; public $dbc = NULL;
/** /**
* Array with methods description * Array with methods description
* @var array
*/ */
var $mdefs = array(); private $mdefs = array();
/** /**
* Confiduration array from ../conf.php * Confiduration array from ../conf.php
* @var array
*/ */
var $config = array(); public $config = array();
/** /**
* XMLRPC client object reference * XMLRPC client object reference
*/ */
var $client = NULL; private $client = NULL;
/** /**
* Verbosity flag * Verbosity flag
*/ */
var $verbose = FALSE; private $verbose = FALSE;
/** /**
* XMLRPC debug flag * XMLRPC debug flag
*/ */
var $debug = 0; private $debug = 0;
/** /**
* Constructor - pelase DON'T CALL IT, use factory method instead * Constructor - please DON'T CALL IT, use factory method instead
* *
* @param dbc object, database object reference * @param DB $dbc
* @param mdefs array, hash array with methods description * @param array $mdefs
* @param config array, hash array with configuration * hash array with methods description
* @param debug int, XMLRPC debug flag * @param array $config
* @param verbose boolean, verbosity flag * hash array with configuration
* @return this * @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
*/ */
function SchedulerPhpClient( public function __construct(
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE) &$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{ {
$this->dbc = $dbc; $this->dbc = $dbc;
@ -382,32 +394,40 @@ class SchedulerPhpClient{
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}". "http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}"; "{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php"; #$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
if($this->verbose) echo "serverPath: $serverPath\n"; if ($this->verbose) {
echo "serverPath: $serverPath\n";
}
$url = parse_url($serverPath); $url = parse_url($serverPath);
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']); $this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
} }
/** /**
* Factory, create object instance * Factory, create object instance
* *
* In fact it doesn't create instance of SchedulerPhpClient, but * In fact it doesn't create instance of SchedulerPhpClient, but
* dynamically extend this class with set of methods based on $mdefs array * dynamically extend this class with set of methods based on $mdefs array
* (using eval function) and instantiate resulting class * (using eval function) and instantiate resulting class
* SchedulerPhpClientCore instead. * SchedulerPhpClientCore instead.
* Each new method in this subclass accepts parameters according to $mdefs * Each new method in this subclass accepts parameters according to $mdefs
* array, call wrapper callMethod(methodname, parameters) and return its * array, call wrapper callMethod(methodname, parameters) and return its
* result. * result.
* *
* @param dbc object, database object reference * @param DB $dbc
* @param mdefs array, hash array with methods description * @param array $mdefs
* @param config array, hash array with configuration * hash array with methods description
* @param debug int, XMLRPC debug flag * @param array $config
* @param verbose boolean, verbosity flag * hash array with configuration
* @return object, created object instance * @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
* @return SchedulerPhpClientCore
*/ */
function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE){ function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{
$f = ''; $f = '';
foreach($mdefs as $fn=>$farr){ foreach ($mdefs as $fn => $farr) {
$f .= $f .=
' function '.$fn.'(){'."\n". ' function '.$fn.'(){'."\n".
' $pars = func_get_args();'."\n". ' $pars = func_get_args();'."\n".
@ -420,32 +440,38 @@ class SchedulerPhpClient{
"$f\n". "$f\n".
"}\n"; "}\n";
# echo $e; # echo $e;
if(FALSE === eval($e)) return $dbc->raiseError("Eval failed"); if (FALSE === eval($e)) {
$spc =& new SchedulerPhpClientCore( return $dbc->raiseError("Eval failed");
}
$spc = new SchedulerPhpClientCore(
$dbc, $mdefs, $config, $debug, $verbose); $dbc, $mdefs, $config, $debug, $verbose);
return $spc; return $spc;
} }
/** /**
* XMLRPC methods wrapper * XMLRPC methods wrapper
* Encode XMLRPC request message, send it, receive and decode response. * Encode XMLRPC request message, send it, receive and decode response.
* *
* @param method string, method name * @param string $method
* @param gettedPars array, returned by func_get_args() in called method * method name
* @return array, PHP hash with response * @param array $gettedPars
* returned by func_get_args() in called method
* @return array
* PHP hash with response
*/ */
function callMethod($method, $gettedPars) function callMethod($method, $gettedPars)
{ {
$parr = array(); $parr = array();
$XML_RPC_val = new XML_RPC_Value; $XML_RPC_val = new XML_RPC_Value;
foreach($this->mdefs[$method]['p'] as $i=>$p){ foreach ($this->mdefs[$method]['p'] as $i => $p) {
$parr[$p] = new XML_RPC_Value; $parr[$p] = new XML_RPC_Value;
$parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]); $parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]);
} }
$XML_RPC_val->addStruct($parr); $XML_RPC_val->addStruct($parr);
$fullmethod = $this->mdefs[$method]['m']; $fullmethod = $this->mdefs[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val)); $msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
if($this->verbose){ if ($this->verbose) {
echo "parr:\n"; echo "parr:\n";
var_dump($parr); var_dump($parr);
echo "message:\n"; echo "message:\n";
@ -453,14 +479,14 @@ class SchedulerPhpClient{
} }
$this->client->setDebug($this->debug); $this->client->setDebug($this->debug);
$res = $this->client->send($msg); $res = $this->client->send($msg);
if($res->faultCode() > 0) { if ($res->faultCode() > 0) {
return PEAR::raiseError( return PEAR::raiseError(
"SchedulerPhpClient::$method:".$res->faultString()." ". "SchedulerPhpClient::$method:".$res->faultString()." ".
$res->faultCode()."\n", $res->faultCode(), $res->faultCode()."\n", $res->faultCode(),
PEAR_ERROR_RETURN PEAR_ERROR_RETURN
); );
} }
if($this->verbose){ if ($this->verbose) {
echo "result:\n"; echo "result:\n";
echo $res->serialize(); echo $res->serialize();
} }
@ -469,7 +495,7 @@ class SchedulerPhpClient{
return $resp; return $resp;
} }
} } // class SchedulerPhpClient
/* ======================================================== class definitions */ /* ======================================================== class definitions */
@ -485,8 +511,8 @@ $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);
// scheduler client instantiation: // scheduler client instantiation:
$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config); $spc = SchedulerPhpClient::factory($dbc, $mdefs, $config);
#$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE); #$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE);
if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; } if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; }
// call of chosen function by name according to key values in $mdefs array: // call of chosen function by name according to key values in $mdefs array:
@ -504,4 +530,4 @@ $r = $spc->DisplayScheduleMethod($this->Base->sessid, '20040101T00:00:00', '2005
#$r = $spc->GetSchedulerTimeMethod(); var_dump($r); #$r = $spc->GetSchedulerTimeMethod(); var_dump($r);
================= */ ================= */
?> ?>

View File

@ -35,7 +35,7 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$locStor = &new LocStor($dbc, $config); $locStor = new LocStor($dbc, $config);
function http_error($code, $err){ function http_error($code, $err){
header("HTTP/1.1 $code"); header("HTTP/1.1 $code");

View File

@ -44,7 +44,7 @@ function errHndl($errno, $errmsg, $filename, $linenum, $vars)
return; return;
break; break;
default: default:
$xr =& new XML_RPC_Response(0, 805, $xr = new XML_RPC_Response(0, 805,
htmlspecialchars("ERROR:xrLocStor: $errno $errmsg ($filename:$linenum)")); htmlspecialchars("ERROR:xrLocStor: $errno $errmsg ($filename:$linenum)"));
header("Content-type: text/xml"); header("Content-type: text/xml");
echo $xr->serialize(); echo $xr->serialize();
@ -58,14 +58,14 @@ if (PHP5) {
} }
/* ============================================================= runable code */ /* ============================================================= runable code */
$r = $dbc =& DB::connect($config['dsn'], TRUE); $r = $dbc = DB::connect($config['dsn'], TRUE);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
trigger_error("DB::connect: ".$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR); trigger_error("DB::connect: ".$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
} }
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$locStor = &new XR_LocStor($dbc, $config); $locStor = new XR_LocStor($dbc, $config);
$methods = array( $methods = array(
'test' => 'Tests toupper and checks sessid, params: '. 'test' => 'Tests toupper and checks sessid, params: '.