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

View File

@ -3,103 +3,128 @@ define('BACKUP_EXT', 'tar');
define('ACCESS_TYPE', 'backup');
/**
* @author $Author: $
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: $
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class Backup
{
/**
* string - name of logfile
* Name of logfile
* @var string
*/
var $logFile;
private $logFile;
/**
* string - session id
* Session id
* @var string
*/
var $sessid;
/**
* struct - see search criteria
*/
var $criteria;
private $sessid;
/**
* string - token
* struct - see search criteria
* @var array
*/
var $token;
/**
* string - name of statusfile
*/
var $statusFile;
/**
* array - affected gunids
*/
var $ids;
/**
* array - array of affected filenames
*/
var $filenames = array();
private $criteria;
/**
* string - base tmp name
* @var string
*/
var $tmpName;
/**
* 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;
private $token;
/**
* 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
*
* @param gb: greenbox object reference
* Array of affected filenames
* @var array
*/
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->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
$this->gb =& $gb;
$this->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
}
/**
* Open a backup
* Open a backup
* Create a backup file (tarball)
*
* @param sessid : string - session id
* @param criteria : struct - see search criteria
* @return hasharray with field:
* @param string $sessid
* @param array $criteria
* struct - see search criteria
* @return array
* hasharray with field:
* token string: backup token
*/
function openBackup($sessid,$criteria='')
function openBackup($sessid, $criteria='')
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n");
@ -108,9 +133,9 @@ class Backup
$this->criteria = $criteria;
# get ids (and real filenames) which files match with criteria
$srch = $r = $this->gb->localSearch($this->criteria,$this->sessid);
if (PEAR::isError($r)) {
return $r;
$srch = $this->gb->localSearch($this->criteria,$this->sessid);
if (PEAR::isError($srch)) {
return $srch;
}
$this->setIDs($srch);
#echo '<XMP>this->ids:'; print_r($this->ids); echo '</XMP>';
@ -217,7 +242,7 @@ class Backup
/**
* list of unclosed backups
*
* @param string $stat (optional)
* @param string $stat
* if this parameter is not set, then return with all unclosed backups
* @return array of hasharray with field:
* status : string - susccess | working | fault
@ -274,9 +299,9 @@ class Backup
foreach ($this->ids as $i=>$item) {
$gunid = $item['gunid'];
# get a stored file object of this gunid
$sf = $r = StoredFile::recallByGunid($this->gb, $gunid);
if (PEAR::isError($r)) {
return $r;
$sf = StoredFile::recallByGunid($this->gb, $gunid);
if (PEAR::isError($sf)) {
return $sf;
}
$lid = $this->gb->_idFromGunid($gunid);
if (($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE) {
@ -425,7 +450,8 @@ class Backup
/**
* 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)
{
@ -439,7 +465,8 @@ class Backup
/**
* Delete a directory recursive
*
* @param string $dirname - path of dir.
* @param string $dirname
* path of dir.
*/
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>
* </ul>
*
* @Author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see MetaData
* @see StoredFile
*/
@ -56,7 +60,7 @@ class DataEngine {
*
* @param BasicStor $gb
*/
function DataEngine(&$gb)
public function __construct(&$gb)
{
$this->gb =& $gb;
$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
*
* @author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class LocStor extends BasicStor {
/* ---------------------------------------------------------------- store */
/**
* Store or replace existing audio clip
* Store or replace existing audio clip
*
* @param string $sessid, session id
* @param string $gunid, global unique id
* @param string $metadata, metadata XML string
* @param string $fname, 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 struct {url:writable URL for HTTP PUT, token:access token
* @param string $sessid
* session id
* @param string $gunid
* global unique id
* @param string $metadata
* metadata XML string
* @param string $fname
* 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(
$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 $token
* @return string gunid or PEAR::error
* @param string $sessid
* @param string $token
* @return string gunid|PEAR_Error
*/
function storeAudioClipClose($sessid, $token)
{
@ -133,10 +144,12 @@ class LocStor extends BasicStor {
/**
* Check uploaded file
* Check uploaded file
*
* @param string $token, put token
* @return hash, (status: boolean, size: int - filesize)
* @param string $token
* "put" token
* @return array
* hash, (status: boolean, size: int - filesize)
*/
function uploadCheck($token)
{
@ -145,15 +158,20 @@ class LocStor extends BasicStor {
/**
* Store webstream
* Store webstream
*
* @param string $sessid, session id
* @param string $gunid, global unique id
* @param string $metadata, metadata XML string
* @param string $fname, human readable menmonic file name
* with extension corresponding to filetype
* @param string $url, wewbstream url
* @return string, gunid
* @param string $sessid
* session id
* @param string $gunid
* global unique id
* @param string $metadata
* metadata XML string
* @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)
{
@ -182,12 +200,14 @@ class LocStor extends BasicStor {
/* --------------------------------------------------------------- access */
/**
* Make access to audio clip
* Make access to audio clip
*
* @param string $sessid
* @param string $gunid
* @param int $parent parent token
* @return array with: seekable filehandle, access token
* @param string $sessid
* @param string $gunid
* @param int $parent
* parent token
* @return array
* with: seekable filehandle, access token
*/
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 $token, access token
* @return boolean or PEAR::error
* @param string $sessid
* @param string $token
* access token
* @return boolean|PEAR_Error
*/
function releaseRawAudioData($sessid, $token)
{
@ -221,11 +242,14 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------------- download */
/**
* Create and return downloadable URL for audio file
* Create and return downloadable URL for audio file
*
* @param string $sessid, session id
* @param string $gunid, global unique id
* @return array with strings:
* @param string $sessid
* session id
* @param string $gunid
* global unique id
* @return array
* array with strings:
* downloadable URL, download token, chsum, size, filename
*/
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
* @return string, gunid
* @param string $token
* download token
* @return string
* gunid
*/
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 $gunid, global unique id
* @return array with strings:
* @param string $sessid
* session id
* @param string $gunid
* global unique id
* @return array
* array with strings:
* downloadable URL, download token, chsum, filename
*/
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
* @return string, gunid
* @param string $token
* download token
* @return string
* gunid
*/
function downloadMetadataClose($token)
{
@ -300,11 +331,11 @@ class LocStor extends BasicStor {
/**
* Return metadata as XML
* Return metadata as XML
*
* @param string $sessid
* @param string $gunid
* @return string or PEAR::error
* @param string $sessid
* @param string $gunid
* @return string|PEAR_Error
*/
function getAudioClip($sessid, $gunid)
{
@ -326,10 +357,11 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- search, browse */
/**
* Search in metadata database
* Search in metadata database
*
* @param string $sessid
* @param hash $criteria, with following structure:<br>
* @param string $sessid
* @param array $criteria
* with following structure:<br>
* <ul>
* <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
@ -389,8 +421,6 @@ class LocStor extends BasicStor {
/**
* Enter description here...
*
* @param array $criteria
* @param mixed $sessid - this variable isnt used
* @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
* with or without namespace prefix (dc:title, author)
* @param hash $criteria, see searchMetadata method
* @param string $sessid
* @return hash, fields:
* @param string $category
* metadata category name
* with or without namespace prefix (dc:title, author)
* @param hash $criteria
* see searchMetadata method
* @param string $sessid
* @return array
* hash, fields:
* results : array with found values
* cnt : integer - number of matching values
* @see BasicStor::bsBrowseCategory
@ -430,11 +463,11 @@ class LocStor extends BasicStor {
/* ----------------------------------------------------------------- etc. */
/**
* Check if audio clip exists
* Check if audio clip exists
*
* @param string $sessid
* @param string $gunid
* @return boolean
* @param string $sessid
* @param string $gunid
* @return boolean
*/
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 $gunid
* @param string $ftype, internal file type
* @return boolean
* @param string $sessid
* @param string $gunid
* @param string $ftype
* internal file type
* @return boolean
*/
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 $gunid
* @param boolean $forced, if true don't use trash
* @return boolean or PEAR::error
* @param string $sessid
* @param string $gunid
* @param boolean $forced
* if true, don't use trash
* @return boolean|PEAR_Error
*/
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 $gunid
* @param string $metadata, metadata XML string
* @return boolean or PEAR::error
* @param string $sessid
* @param string $gunid
* @param string $metadata
* metadata XML string
* @return boolean|PEAR_Error
*/
function updateAudioClipMetadata($sessid, $gunid, $metadata)
{
@ -530,12 +566,16 @@ class LocStor extends BasicStor {
/*====================================================== playlist methods */
/**
* Create a new empty playlist.
* Create a new empty playlist.
*
* @param string $sessid, session ID
* @param string $playlistId, playlist global unique ID
* @param string $fname, human readable mnemonic file name
* @return string, playlist global unique ID
* @param string $sessid
* session ID
* @param string $playlistId
* playlist global unique ID
* @param string $fname
* human readable mnemonic file name
* @return string
* playlist global unique ID
*/
function createPlaylist($sessid, $playlistId, $fname)
{
@ -588,12 +628,14 @@ class LocStor extends BasicStor {
/**
* Open a Playlist metafile for editing.
* Open readable URL and mark file as beeing edited.
* Open a Playlist metafile for editing.
* Open readable URL and mark file as beeing edited.
*
* @param string $sessid, session ID
* @param string $playlistId, playlist global unique ID
* @return struct
* @param string $sessid
* session ID
* @param string $playlistId
* playlist global unique ID
* @return struct
* {url:readable URL for HTTP GET, token:access token, chsum:checksum}
*/
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 $playlistToken, playlist access token
* @param string $newPlaylist, new playlist as XML string
* @return string, playlistId
* @param string $sessid
* session ID
* @param string $playlistToken
* playlist access token
* @param string $newPlaylist
* new playlist as XML string
* @return string
* playlistId
*/
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 $sessid, session ID
* @return string gunid of playlist
* @param string $playlistToken
* playlist access token
* @param string $sessid
* session ID
* @return string
* gunid of playlist
*/
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 $playlistId, playlist global unique ID
* @param boolean $forced, if true don't use trash
* @return boolean
* @param string $sessid
* session ID
* @param string $playlistId
* playlist global unique ID
* @param boolean $forced
* if true don't use trash
* @return boolean
*/
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 $playlistId, playlist global unique ID
* @param boolean $recursive, flag for recursive access content
* inside playlist (optional, default: false)
* @param int $parent parent token
* @return struct {
* @param string $sessid
* session ID
* @param string $playlistId
* playlist global unique ID
* @param boolean $recursive
* flag for recursive access content inside playlist
* @param int $parent
* parent token
* @return struct {
* url: readable URL for HTTP GET,
* token: access token,
* 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 $playlistToken, playlist access token
* @param boolean $recursive, flag for recursive access content
* inside playlist (optional, default: false)
* @return string, playlist ID
* @param string $sessid
* session ID
* @param string $playlistToken
* playlist access token
* @param boolean $recursive
* flag for recursive access content inside playlist
* @return string
* playlist ID
*/
function releasePlaylist($sessid, $playlistToken, $recursive=FALSE)
{
@ -802,16 +860,18 @@ class LocStor extends BasicStor {
/**
* Create a tarfile with playlist export - playlist and all matching
* sub-playlists and media files (if desired)
* Create a tarfile with playlist export - playlist and all matching
* sub-playlists and media files (if desired)
*
* @param sessid - string, session ID
* @param plids - array of strings, playlist global unique IDs
* (one gunid is accepted too)
* @param type - string, playlist format, values: lspl | smil | m3u
* @param standalone - boolean, if only playlist should be exported or
* with all related files
* @return hasharray with fields:
* @param string $sessid
* session ID
* @param array $plids
* array of strings, playlist global unique IDs (one gunid is accepted too)
* @param string $type
* playlist format, values: lspl | smil | m3u
* @param boolean $standalone
* if only playlist should be exported or with all related files
* @return hasharray with fields:
* url string: readable url,
* token string: access token
* 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
* method call
* @return boolean true or error object
* @param string $token
* access token obtained from exportPlaylistOpen method call
* @return boolean|PEAR_Error
*/
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 $chsum, md5 checksum of imported file
* @return hasharray with:
* @param string $sessid
* session id
* @param string $chsum
* md5 checksum of imported file
* @return hasharray with:
* url string: writable URL
* 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
* @return string, result file global id (or error object)
* @param string $token
* import token obtained by importPlaylistOpen method
* @return string
* result file global id (or error object)
*/
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 $playlistId, playlist global unique ID
* @return boolean
* @param string $sessid
* session ID
* @param string $playlistId
* playlist global unique ID
* @return boolean
*/
function existsPlaylist($sessid, $playlistId)
{
@ -915,14 +981,17 @@ class LocStor extends BasicStor {
/**
* Check whether a Playlist metafile with the given playlist ID
* is available for editing, i.e., exists and is not marked as
* beeing edited.
* Check whether a Playlist metafile with the given playlist ID
* is available for editing, i.e., exists and is not marked as
* being edited.
*
* @param string $sessid, session ID
* @param string $playlistId, playlist global unique ID
* @param boolean $getUid, optional flag for returning editedby uid
* @return boolean
* @param string $sessid
* session ID
* @param string $playlistId
* playlist global unique ID
* @param boolean $getUid
* flag for returning editedby uid
* @return boolean
*/
function playlistIsAvailable($sessid, $playlistId, $getUid=FALSE)
{
@ -948,11 +1017,13 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- render methods */
/**
* Render playlist to ogg file (open handle)
* Render playlist to ogg file (open handle)
*
* @param string $sessid - session id
* @param string $plid - playlist gunid
* @return hasharray:
* @param string $sessid
* session id
* @param string $plid
* playlist gunid
* @return hasharray
* token: string - render token
*/
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
* @return hasharray:
* @param string $token
* render token
* @return hasharray:
* status : string - success | working | fault
* 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
* @return boolean status
* @param string $token
* render token
* @return boolean status
*/
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 $plid - playlist gunid
* @return string - render token
* @param string $sessid
* session id
* @param string $plid
* playlist gunid
* @return string
* render token
*/
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
* @return hasharray:
* @param string $token
* render token
* @return hasharray:
* status : string - success | working | fault
* 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 $plid - playlist gunid
* @return string - render token
* @param string $sessid
* session id
* @param string $plid
* playlist gunid
* @return string
* render token
*/
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
* @return hasharray :
* @param string $token
* render token
* @return hasharray :
* status : string - success | working | fault
* 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
* @return boolean status
* @param string $token
* render token
* @return boolean
* status
*/
function renderPlaylistToRSSClose($token)
{
@ -1107,19 +1190,21 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- backup methods */
/**
* Create backup of storage (open handle)
* Create backup of storage (open handle)
*
* @param string $sessid - session id
* @param array $criteria - see search criteria
* @return hasharray:
* @param string $sessid
* session id
* @param array $criteria
* see search criteria
* @return array
* token : string - backup token
*/
function createBackupOpen($sessid, $criteria='')
{
require_once "Backup.php";
$bu = $r = new Backup($this);
if (PEAR::isError($r)) {
return $r;
require_once("Backup.php");
$bu = new Backup($this);
if (PEAR::isError($bu)) {
return $bu;
}
$r = $bu->openBackup($sessid,$criteria);
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
* @return hasharray with field:
* @param string $token
* backup token
* @return hasharray
* with field:
* status : string - susccess | working | fault
* faultString: string - description of fault
* token : stirng - backup token
@ -1143,49 +1230,53 @@ class LocStor extends BasicStor {
*/
function createBackupCheck($token)
{
require_once "Backup.php";
$bu = $r = new Backup($this);
if (PEAR::isError($r)) {
return $r;
require_once("Backup.php");
$bu = new Backup($this);
if (PEAR::isError($bu)) {
return $bu;
}
return $bu->checkBackup($token);
}
/**
* Create backup of storage (list results)
* Create backup of storage (list results)
*
* @param string $sessid - session id
* @param status $stat (optional)
* @param string $sessid
* session id
* @param status $stat
* 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
* token : stirng - backup token
* url : string - access url
*/
function createBackupList($sessid, $stat='')
{
require_once "Backup.php";
$bu = $r = new Backup($this);
if (PEAR::isError($r)) {
return $r;
require_once("Backup.php");
$bu = new Backup($this);
if (PEAR::isError($bu)) {
return $bu;
}
return $bu->listBackups($stat);
}
/**
* Create backup of storage (close handle)
* Create backup of storage (close handle)
*
* @param string $token - backup token
* @return boolean status
* @param string $token
* backup token
* @return boolean
* status
*/
function createBackupClose($token)
{
require_once "Backup.php";
$bu = $r = new Backup($this);
if (PEAR::isError($r)) {
return $r;
require_once("Backup.php");
$bu = new Backup($this);
if (PEAR::isError($bu)) {
return $bu;
}
return $bu->closeBackup($token);
}
@ -1194,10 +1285,12 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------ restore methods */
/**
* Restore a backup file (open handle)
* Restore a backup file (open handle)
*
* @param string $sessid - session id
* @param string $chsum, md5 checksum of imported file
* @param string $sessid
* session id
* @param string $chsum
* md5 checksum of imported file
* @return array
* array with:
* url string: writable URL
@ -1206,9 +1299,9 @@ class LocStor extends BasicStor {
*/
function restoreBackupOpen($sessid, $chsum)
{
$userid = $r =$this->getSessUserId($sessid);
if ($this->dbc->isError($r)) {
return $r;
$userid = $this->getSessUserId($sessid);
if ($this->dbc->isError($userid)) {
return $userid;
}
$r = $this->bsOpenPut($chsum, NULL, $userid);
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 $token - put token
* @return string $token - restore token
* @param string $sessid
* session id
* @param string $token
* "put" token
* @return string $token
* restore token
*/
function restoreBackupClosePut($sessid, $token) {
$arr = $r = $this->bsClosePut($token);
if (PEAR::isError($r)) {
return $r;
$arr = $this->bsClosePut($token);
if (PEAR::isError($arr)) {
return $arr;
}
$fname = $arr['fname'];
require_once 'Restore.php';
require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
@ -1239,18 +1335,21 @@ class LocStor extends BasicStor {
return $rs->openRestore($sessid, $fname);
}
/**
* Restore a backup file (check state)
*
* @param string $token - restore token
* @return array status - fields:
* token: string - restore token
* status: string - working | fault | success
* faultString: string - description of fault
* Restore a backup file (check state)
*
* @param string $token
* restore token
* @return array
* status - fields:
* token: string - restore token
* status: string - working | fault | success
* faultString: string - description of fault
*/
function restoreBackupCheck($token)
{
require_once 'Restore.php';
require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($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
* @return array status - fields:
* token: string - restore token
* status: string - working | fault | success
* @param string $token
* restore token
* @return array
* status - fields:
* token: string - restore token
* status: string - working | fault | success
*/
function restoreBackupClose($token) {
require_once 'Restore.php';
require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -217,10 +217,14 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
* File storage support class
* 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$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see StoredFile
*/
class RawMediaData {
@ -233,7 +237,7 @@ class RawMediaData {
* @param string $resDir
* resource directory
*/
function RawMediaData($gunid, $resDir)
public function __construct($gunid, $resDir)
{
$this->gunid = $gunid;
$this->resDir = $resDir;

View File

@ -8,10 +8,14 @@ require_once "LsPlaylist.php";
*
* 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 $
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see LocStor
*/
class Renderer

View File

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

View File

@ -6,10 +6,14 @@ require_once "XmlParser.php";
/**
* SmilPlaylist class
*
* @author $Author: tomash $
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision: 1848 $
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class SmilPlaylist {
@ -122,10 +126,14 @@ class SmilPlaylist {
/**
* @author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class SmilPlaylistBodyElement {
@ -161,10 +169,14 @@ class SmilPlaylistBodyElement {
/**
* @author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class SmilPlaylistParElement {
@ -190,10 +202,14 @@ class SmilPlaylistParElement {
/**
* @author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class SmilPlaylistAudioElement {
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$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class SmilPlaylistAnimateElement {

View File

@ -14,24 +14,50 @@ require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
* - represented by RawMediaData class</li>
* </ul>
*
* @author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
* @see GreenBox
* @see MetaData
* @see RawMediaData
*/
class StoredFile {
var $gb;
var $dbc;
var $filesTable;
var $accessTable;
var $gunid;
var $resDir;
var $accessDir;
var $rmd;
var $md;
/**
* @var GreenBox
*/
public $gb;
/**
* @var DB
*/
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 */
/**
@ -39,10 +65,9 @@ class StoredFile {
*
* @param GreenBox $gb
* @param string $gunid
* optional, globally unique id of file
* @return this
* globally unique id of file
*/
function StoredFile(&$gb, $gunid=NULL)
public function __construct(&$gb, $gunid=NULL)
{
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
@ -54,8 +79,8 @@ class StoredFile {
}
$this->resDir = $this->_getResDir($this->gunid);
$this->accessDir = $this->gb->accessDir;
$this->rmd =& new RawMediaData($this->gunid, $this->resDir);
$this->md =& new MetaData($gb, $this->gunid, $this->resDir);
$this->rmd = new RawMediaData($this->gunid, $this->resDir);
$this->md = new MetaData($gb, $this->gunid, $this->resDir);
# return $this->gunid;
}
@ -87,7 +112,7 @@ class StoredFile {
$mediaFileLP='', $metadata='', $mdataLoc='file',
$gunid=NULL, $ftype=NULL, $className='StoredFile')
{
$ac =& new $className($gb, ($gunid ? $gunid : NULL));
$ac = new $className($gb, ($gunid ? $gunid : NULL));
if (PEAR::isError($ac)) {
return $ac;
}
@ -200,7 +225,7 @@ class StoredFile {
return $r;
}
$gunid = StoredFile::_normalizeGunid($row['gunid']);
$ac =& new $className($gb, $gunid);
$ac = new $className($gb, $gunid);
$ac->mime = $row['mime'];
$ac->name = $row['name'];
$ac->id = $row['id'];
@ -259,10 +284,11 @@ class StoredFile {
/**
* 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
* new local id
* @return unknown
* @return StoredFile
*/
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);
/**
* 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 $
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
class TransportRecord
{
var $dbc;
var $recalled = FALSE;
var $dropped = FALSE;
/**
* @var DB
*/
public $dbc;
/**
* Constructor
*
* @param Transport $tr object reference
* @return TransportRecord object instance
* @var GreenBox
*/
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->gb =& $tr->gb;
@ -46,8 +80,8 @@ class TransportRecord
*/
function create(&$tr, $trtype, $direction='up', $defaults=array())
{
$trec =& new TransportRecord($tr);
$trec->trtok = $trtok = $tr->_createTrtok();
$trec = new TransportRecord($tr);
$trec->trtok = $trtok = $tr->_createTransportToken();
$trec->row = array_merge($defaults,
array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE;
@ -60,7 +94,7 @@ class TransportRecord
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
$names = "id, trtok, direction, state, trtype, start, ts";
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
foreach ($defaults as $k=>$v) {
foreach ($defaults as $k => $v) {
$sqlVal = $trec->_getSqlVal($k, $v);
$names .= ", $k";
$values .= ", $sqlVal";
@ -71,16 +105,16 @@ class TransportRecord
VALUES
($values)
";
$res = $r = $trec->dbc->query($query);
if (PEAR::isError($r)) {
return $r;
$res = $trec->dbc->query($query);
if (PEAR::isError($res)) {
return $res;
}
return $trec;
}
/**
* Recall transport record from DB
* Recall transport record from DB
*
* @param Transport $tr
* @param string $trtok
@ -89,9 +123,9 @@ class TransportRecord
*/
function recall(&$tr, $trtok)
{
$trec =& new TransportRecord($tr);
$trec = new TransportRecord($tr);
$trec->trtok = $trtok;
$row = $r = $trec->dbc->getRow("
$row = $trec->dbc->getRow("
SELECT
id, trtok, state, trtype, direction,
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
@ -101,8 +135,8 @@ class TransportRecord
FROM {$trec->transTable}
WHERE trtok='$trtok'
");
if (PEAR::isError($r)) {
return $r;
if (PEAR::isError($row)) {
return $row;
}
if (is_null($row)) {
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 array $data
* other data fields to set
* @param string $oldState
* (opt.) check old state and do nothing if differ
* check old state and do nothing if differ
* @param boolean $lock
* (opt.) check lock and do nothing if differ
* check lock and do nothing if differ
* @return boolean success
*/
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
@ -152,9 +186,9 @@ class TransportRecord
return $r;
}
// return TRUE;
$affRows = $r = $this->dbc->affectedRows();
if (PEAR::isError($r)) {
return $r;
$affRows = $this->dbc->affectedRows();
if (PEAR::isError($affRows)) {
return $affRows;
}
return ($affRows == 1);
}
@ -201,9 +235,9 @@ class TransportRecord
if (PEAR::isError($r)) {
return $r;
}
$affRows = $r = $this->dbc->affectedRows();
if (PEAR::isError($r)) {
return $r;
$affRows = $this->dbc->affectedRows();
if (PEAR::isError($affRows)) {
return $affRows;
}
if ($affRows != 1) {
$ltxt = ($lock ? 'lock' : 'unlock' );
@ -333,21 +367,21 @@ class TransportRecord
function getTitle()
{
$defStr = 'unknown';
$trtype = $r = $this->getTransportType(); //contains recall check
if (PEAR::isError($r)) {
return $r;
$trtype = $this->getTransportType(); //contains recall check
if (PEAR::isError($trtype)) {
return $trtype;
}
switch ($trtype) {
case "audioclip":
case "playlist":
case "playlistPkg":
case "metadata":
$title = $r = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
if (PEAR::isError($r)) {
if ($r->getCode()==GBERR_FOBJNEX) {
$title = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
if (PEAR::isError($title)) {
if ($title->getCode() == GBERR_FOBJNEX) {
$title = $defStr;
} else {
return $r;
return $title;
}
}
break;

View File

@ -23,24 +23,33 @@ define('VAL_PREDXML', 121);
* </ul>
* 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$
* @package Campcaster
* @subpackage StorageServer
* @copyright 2006 MDLF, Inc.
* @license http://www.gnu.org/licenses/gpl.txt
* @link http://www.campware.org
*/
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
* gunid of validated file for identification in mass input
*/
function Validator($format, $gunid)
public function __construct($format, $gunid)
{
$format = strtolower($format);
$this->format = $format;
$this->gunid = $gunid;
$format = strtolower($format);
$this->format = $format;
$this->gunid = $gunid;
$formats = array(
'audioclip' => "audioClipFormat",
'playlist' => "playlistFormat",
@ -69,7 +78,7 @@ class Validator {
if (!file_exists($formatFile)) {
return $this->_err(VAL_FORMAT);
}
require $formatFile;
require($formatFile);
$this->formTree = $$formatName;
}

View File

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

View File

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

View File

@ -9,6 +9,7 @@ define('CRON_EMPTY', 4);
* A class that interfaces with the crontab. (cjpa@audiophile.com)
*
* This class lets you manipulate the crontab. It lets you add delete update entries easily.
*
* @author $Author: $
* @version $Revision: $
* @package Campcaster
@ -18,7 +19,7 @@ class Crontab
{
// {{{ properties
/**
* @var array holds all the different lines.
* Holds all the different lines.
* Lines are associative arrays with the following fields:
* "minute" : holds the minutes (0-59)
* "hour" : holds the hour (0-23)
@ -30,20 +31,23 @@ class Crontab
* "name" => "value"
* or a line can be a comment (string beginning with #)
* 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.
* 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->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new LocStor($dbc, $config);
$tr =& new Transport($gb);
$gb = new LocStor($dbc, $config);
$tr = new Transport($gb);
$r = $tr->cronMain();
if(!$r) exit(1);

View File

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

View File

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

View File

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

View File

@ -1,9 +1,13 @@
<?php
/**
* @author $Author$
* @author Tomas Hlava <th@red2head.com>
* @author Paul Baranowski <paul@paulbaranowski.org>
* @version $Revision$
* @package Campcaster
* @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 '../GreenBox.php';
#$rmd =& new RawMediaData('qwerty', '../stor');
#$rmd = new RawMediaData('qwerty', '../stor');
#$r = $rmd->insert('./ex1.mp3', 'mp3');
#$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();
echo "r=$r (".gettype($r).")\n";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,9 +5,9 @@
*/
/* ================================================================= includes */
include_once dirname(__FILE__)."/../conf.php";
require_once 'DB.php';
include_once "XML/RPC.php";
include_once(dirname(__FILE__)."/../conf.php");
require_once('DB.php');
include_once("XML/RPC.php");
/* ================================================== method definition array */
/**
@ -333,42 +333,54 @@ $mdefs = array(
/* ======================================================== 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
*/
var $verbose = FALSE;
private $verbose = FALSE;
/**
* 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 mdefs array, hash array with methods description
* @param config array, hash array with configuration
* @param debug int, XMLRPC debug flag
* @param verbose boolean, verbosity flag
* @return this
* @param DB $dbc
* @param array $mdefs
* hash array with methods description
* @param array $config
* hash array with configuration
* @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
*/
function SchedulerPhpClient(
public function __construct(
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{
$this->dbc = $dbc;
@ -382,32 +394,40 @@ class SchedulerPhpClient{
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
#$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);
$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
* dynamically extend this class with set of methods based on $mdefs array
* (using eval function) and instantiate resulting class
* SchedulerPhpClientCore instead.
* Each new method in this subclass accepts parameters according to $mdefs
* array, call wrapper callMethod(methodname, parameters) and return its
* result.
* In fact it doesn't create instance of SchedulerPhpClient, but
* dynamically extend this class with set of methods based on $mdefs array
* (using eval function) and instantiate resulting class
* SchedulerPhpClientCore instead.
* Each new method in this subclass accepts parameters according to $mdefs
* array, call wrapper callMethod(methodname, parameters) and return its
* result.
*
* @param dbc object, database object reference
* @param mdefs array, hash array with methods description
* @param config array, hash array with configuration
* @param debug int, XMLRPC debug flag
* @param verbose boolean, verbosity flag
* @return object, created object instance
* @param DB $dbc
* @param array $mdefs
* hash array with methods description
* @param array $config
* hash array with configuration
* @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 = '';
foreach($mdefs as $fn=>$farr){
foreach ($mdefs as $fn => $farr) {
$f .=
' function '.$fn.'(){'."\n".
' $pars = func_get_args();'."\n".
@ -420,32 +440,38 @@ class SchedulerPhpClient{
"$f\n".
"}\n";
# echo $e;
if(FALSE === eval($e)) return $dbc->raiseError("Eval failed");
$spc =& new SchedulerPhpClientCore(
if (FALSE === eval($e)) {
return $dbc->raiseError("Eval failed");
}
$spc = new SchedulerPhpClientCore(
$dbc, $mdefs, $config, $debug, $verbose);
return $spc;
}
/**
* XMLRPC methods wrapper
* Encode XMLRPC request message, send it, receive and decode response.
*
* @param method string, method name
* @param gettedPars array, returned by func_get_args() in called method
* @return array, PHP hash with response
* @param string $method
* method name
* @param array $gettedPars
* returned by func_get_args() in called method
* @return array
* PHP hash with response
*/
function callMethod($method, $gettedPars)
{
$parr = array();
$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]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]);
}
$XML_RPC_val->addStruct($parr);
$fullmethod = $this->mdefs[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
if($this->verbose){
if ($this->verbose) {
echo "parr:\n";
var_dump($parr);
echo "message:\n";
@ -453,14 +479,14 @@ class SchedulerPhpClient{
}
$this->client->setDebug($this->debug);
$res = $this->client->send($msg);
if($res->faultCode() > 0) {
if ($res->faultCode() > 0) {
return PEAR::raiseError(
"SchedulerPhpClient::$method:".$res->faultString()." ".
$res->faultCode()."\n", $res->faultCode(),
PEAR_ERROR_RETURN
);
}
if($this->verbose){
if ($this->verbose) {
echo "result:\n";
echo $res->serialize();
}
@ -469,7 +495,7 @@ class SchedulerPhpClient{
return $resp;
}
}
} // class SchedulerPhpClient
/* ======================================================== class definitions */
@ -485,8 +511,8 @@ $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
// scheduler client instantiation:
$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config);
#$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE);
$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config);
#$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE);
if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; }
// 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);
================= */
?>
?>

View File

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

View File

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