diff --git a/campcaster/src/modules/storageServer/var/Backup.php b/campcaster/src/modules/storageServer/var/Backup.php
index a70dd8746..ae9b42358 100755
--- a/campcaster/src/modules/storageServer/var/Backup.php
+++ b/campcaster/src/modules/storageServer/var/Backup.php
@@ -313,16 +313,16 @@ class Backup
// if the file is a playlist then it have only meta file
if (strtolower($sf->md->format)!='playlist') {
$this->filenames[] = array(
- 'filename' => $sf->_getRealRADFname(), // get real filename of raw media data
+ 'filename' => $sf->getRealFileName(),
'format' => $sf->md->format
);
}
$this->filenames[] = array(
- 'filename' => $sf->_getRealMDFname(), # get real filename of metadata file
+ 'filename' => $sf->getRealMetadataFileName(),
'format' => $sf->md->format
);
if ($this->loglevel=='debug') {
- $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->_getRealMDFname()."\n");
+ $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
}
}
return $this->filenames;
diff --git a/campcaster/src/modules/storageServer/var/BasicStor.php b/campcaster/src/modules/storageServer/var/BasicStor.php
index 3827b33c6..f086baee9 100644
--- a/campcaster/src/modules/storageServer/var/BasicStor.php
+++ b/campcaster/src/modules/storageServer/var/BasicStor.php
@@ -239,7 +239,7 @@ class BasicStor {
}
if (!empty($mdataFileLP) &&
($mdataLoc!='file' || file_exists($mdataFileLP))) {
- $r = $ac->replaceMetaData($mdataFileLP, $mdataLoc);
+ $r = $ac->replaceMetadata($mdataFileLP, $mdataLoc);
if (PEAR::isError($r)) {
return $r;
}
@@ -521,14 +521,14 @@ class BasicStor {
$gunid = $ac->gunid;
switch ($part) {
case "media":
- $realfile = $ac->_getRealRADFname();
- $ext = $ac->_getExt();
- $filename = $ac->_getFileName();
+ $realfile = $ac->getRealFileName();
+ $ext = $ac->getFileExtension();
+ $filename = $ac->getFileName();
break;
case "metadata":
- $realfile = $ac->_getRealMDFname();
+ $realfile = $ac->getRealMetadataFileName();
$ext = "xml";
- $filename = $ac->_getFileName();
+ $filename = $ac->getFileName();
break;
default:
return PEAR::raiseError(
@@ -599,9 +599,8 @@ class BasicStor {
}
$escapedChsum = pg_escape_string($chsum);
$token = StoredFile::CreateGunid();
- $res = $CC_DBC->query("
- DELETE FROM ".$CC_CONFIG['accessTable']." WHERE token=x'$token'::bigint
- ");
+ $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable']
+ ." WHERE token=x'$token'::bigint");
if (PEAR::isError($res)) {
return $res;
}
@@ -612,8 +611,7 @@ class BasicStor {
(gunid, token, ext, chsum, type, owner, ts)
VALUES
($gunidSql, x'$token'::bigint,
- '', '$escapedChsum', 'put', $ownerSql, now())
- ");
+ '', '$escapedChsum', 'put', $ownerSql, now())");
if (PEAR::isError($res)) {
return $res;
}
@@ -639,39 +637,52 @@ class BasicStor {
{
global $CC_CONFIG, $CC_DBC;
$token = StoredFile::NormalizeGunid($token);
+
if (!BasicStor::bsCheckToken($token, 'put')) {
return PEAR::raiseError(
- "BasicStor::bsClosePut: invalid token ($token)",
- GBERR_TOKEN
- );
+ "BasicStor::bsClosePut: invalid token ($token)",
+ GBERR_TOKEN);
}
- $row = $CC_DBC->getRow("
- SELECT chsum, owner FROM ".$CC_CONFIG['accessTable']."
- WHERE token=x'{$token}'::bigint
- ");
+ $row = $CC_DBC->getRow(
+ "SELECT chsum, owner FROM ".$CC_CONFIG['accessTable']
+ ." WHERE token=x'{$token}'::bigint");
if (PEAR::isError($row)) {
return $row;
}
- $chsum = $row['chsum'];
- $owner = $row['owner'];
- $res = $CC_DBC->query("
- DELETE FROM ".$CC_CONFIG['accessTable']." WHERE token=x'$token'::bigint
- ");
- if (PEAR::isError($res)) {
- return $res;
- }
$fname = $CC_CONFIG['accessDir']."/$token";
$md5sum = md5_file($fname);
- if (trim($chsum) !='' && $chsum != $md5sum) {
+
+ $chsum = $row['chsum'];
+ $owner = $row['owner'];
+ $error = null;
+ if ( (trim($chsum) != '') && ($chsum != $md5sum) ) {
+ // Delete the file if the checksums do not match.
if (file_exists($fname)) {
@unlink($fname);
}
- return PEAR::raiseError(
+ $error = new PEAR_Error(
"BasicStor::bsClosePut: md5sum does not match (token=$token)".
" [$chsum/$md5sum]",
- GBERR_PUT
- );
+ GBERR_PUT);
+ } else {
+ // Remember the MD5 sum
+ $storedFile = StoredFile::recallByToken($token);
+ if (!PEAR::isError($storedFile)) {
+ $storedFile->setMd5($md5sum);
+ } else {
+ $error = $storedFile;
+ }
}
+
+ // Delete entry from access table.
+ $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable']
+ ." WHERE token=x'$token'::bigint");
+ if (PEAR::isError($error)) {
+ return $error;
+ } elseif (PEAR::isError($res)) {
+ return $res;
+ }
+
return array('fname'=>$fname, 'owner'=>$owner);
}
@@ -793,7 +804,7 @@ class BasicStor {
if (PEAR::isError($ac)) {
return $ac;
}
- return $ac->replaceMetaData($mdata, $mdataLoc);
+ return $ac->replaceMetadata($mdata, $mdataLoc);
}
@@ -1157,7 +1168,7 @@ class BasicStor {
if (PEAR::isError($ac)) {
return $ac;
}
- $MDfname = $ac->md->getFname();
+ $MDfname = $ac->md->getFileName();
if (PEAR::isError($MDfname)) {
return $MDfname;
}
@@ -1188,11 +1199,11 @@ class BasicStor {
copy($MDfname, "$tmpdc/{$it['gunid']}.xml"); break;
} // switch
} // if file_exists()
- $RADfname = $ac->_getRealRADFname();
+ $RADfname = $ac->getRealFileName();
if (PEAR::isError($RADfname)) {
return $RADfname;
}
- $RADext = $ac->_getExt();
+ $RADext = $ac->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
@@ -1278,9 +1289,7 @@ class BasicStor {
case "xml":
case "lspl":
$fname = $plid;
- $res = $this->bsPutFile($parid, $fname,
- NULL, $path, $plid, 'playlist'
- );
+ $res = $this->bsPutFile($parid, $fname, NULL, $path, $plid, 'playlist');
break;
case "smil":
require_once("SmilPlaylist.php");
@@ -1375,8 +1384,7 @@ class BasicStor {
}
if (!PEAR::isError($res) ) {
$res = $this->bsPutFile($parid, $gunid, $rawMedia, $metadata,
- $gunid, 'audioclip'
- );
+ $gunid, 'audioclip');
}
@unlink("$tmpdc/{$it['rawMedia']}");
@unlink("$tmpdc/{$it['metadata']}");
@@ -1431,7 +1439,7 @@ class BasicStor {
if (PEAR::isError($listArr)) {
return $listArr;
}
- foreach ($listArr as $i=>$v) {
+ foreach ($listArr as $i => $v) {
if ($v['type'] == 'Folder') {
break;
}
@@ -1449,8 +1457,8 @@ class BasicStor {
}
$listArr[$i]['gunid'] = $gunid;
- // THE BUG IS HERE - "_getState()" IS NOT A STATIC FUNCTION!
- if (StoredFile::_getState($gunid) == 'incomplete') {
+ // THE BUG IS HERE - "getState()" IS NOT A STATIC FUNCTION!
+ if (StoredFile::getState($gunid) == 'incomplete') {
unset($listArr[$i]);
}
}
@@ -1708,15 +1716,11 @@ class BasicStor {
* @param string $pass
* @return boolean|sessionId|PEAR_Error
*/
-// function login($login, $pass)
-// {
-// $r = $this->upgradeDbStructure();
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $r = parent::login($login, $pass);
-// return $r;
-// }
+ function login($login, $pass)
+ {
+ $r = Alib::Login($login, $pass);
+ return $r;
+ }
/* ================================================== "protected" methods */
@@ -1932,7 +1936,7 @@ class BasicStor {
if (PEAR::isError($ac)) {
return $ac;
}
- $state = $ac->_getState();
+ $state = $ac->getState();
if ($p_val) {
$r = $ac->setState('edited', $p_subjid);
} else {
@@ -2135,53 +2139,6 @@ class BasicStor {
}
- /**
- * Check and optionally upgrade LS db structure.
- * (add column suported only now)
- *
- * items in array with db changes:
- *
- * - tbl - table name
- * - fld - field name
- * - type - type of field
- *
- *
- * @return TRUE/error
- */
-// function upgradeDbStructure()
-// {
-// $chDb = array(
-// '1.1 Leon' => array(
-// array('tbl'=>$this->accessTable, 'fld'=>'owner',
-// 'type'=>"int REFERENCES {$this->subjTable}"
-// ),
-// ),
-// '1.1 Freetown' => array(
-// array('tbl'=>$this->filesTable, 'fld'=>'mtime',
-// 'type'=>'timestamp(6) with time zone'
-// ),
-// ),
-// );
-// foreach ($chDb as $version => $chArr) {
-// foreach ($chArr as $change) {
-// extract($change); // tbl, op, fld, type
-// $r = $CC_DBC->tableInfo($tbl, DB_TABLEINFO_ORDERTABLE);
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// if (!isset($r['ordertable'][$tbl][$fld])) {
-// $q = "ALTER table $tbl ADD $fld $type";
-// $r = $CC_DBC->query($q);
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// }
-// }
-// }
-// return TRUE;
-// }
-
-
/* =============================================== test and debug methods */
/**
* Reset storageServer for debugging.
@@ -2244,10 +2201,7 @@ class BasicStor {
$fname = basename($xml);
break;
}
- $r = $this->bsPutFile(
- $rootHD, $fname,
- $media, $xml, $gunid, $type
- );
+ $r = $this->bsPutFile($rootHD, $fname, $media, $xml, $gunid, $type);
if (PEAR::isError($r)) {
return $r;
}
@@ -2563,164 +2517,6 @@ class BasicStor {
}
- /**
- * install - create tables
- *
- * file states:
- *
- * - empty
- * - incomplete
- * - ready
- * - edited
- * - deleted
- *
- * file types:
- *
- * - audioclip
- * - playlist
- * - webstream
- *
- * access types:
- *
- * - access
- * - download
- *
- */
-// public function install()
-// {
-// parent::install();
-// $r = $CC_DBC->query("CREATE TABLE {$this->filesTable} (
-// id int not null,
-// gunid bigint not null, -- global unique ID
-// name varchar(255) not null default'', -- human file id ;)
-// mime varchar(255) not null default'', -- mime type
-// ftype varchar(128) not null default'', -- file type
-// state varchar(128) not null default'empty', -- file state
-// currentlyaccessing int not null default 0, -- access counter
-// editedby int REFERENCES {$this->subjTable}, -- who edits it
-// mtime timestamp(6) with time zone -- lst modif.time
-// )");
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $CC_DBC->query("CREATE UNIQUE INDEX {$this->filesTable}_id_idx
-// ON {$this->filesTable} (id)");
-// $CC_DBC->query("CREATE UNIQUE INDEX {$this->filesTable}_gunid_idx
-// ON {$this->filesTable} (gunid)");
-// $CC_DBC->query("CREATE INDEX {$this->filesTable}_name_idx
-// ON {$this->filesTable} (name)");
-//
-// $CC_DBC->createSequence("{$this->mdataTable}_id_seq");
-// $r = $CC_DBC->query("CREATE TABLE {$this->mdataTable} (
-// id int not null,
-// gunid bigint,
-// subjns varchar(255), -- subject namespace shortcut/uri
-// subject varchar(255) not null default '',
-// predns varchar(255), -- predicate namespace shortcut/uri
-// predicate varchar(255) not null,
-// predxml char(1) not null default 'T', -- Tag or Attribute
-// objns varchar(255), -- object namespace shortcut/uri
-// object text
-// )");
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $CC_DBC->query("CREATE UNIQUE INDEX {$this->mdataTable}_id_idx
-// ON {$this->mdataTable} (id)");
-// $CC_DBC->query("CREATE INDEX {$this->mdataTable}_gunid_idx
-// ON {$this->mdataTable} (gunid)");
-// $CC_DBC->query("CREATE INDEX {$this->mdataTable}_subj_idx
-// ON {$this->mdataTable} (subjns, subject)");
-// $CC_DBC->query("CREATE INDEX {$this->mdataTable}_pred_idx
-// ON {$this->mdataTable} (predns, predicate)");
-//
-// $r = $CC_DBC->query("CREATE TABLE {$this->accessTable} (
-// gunid bigint, -- global unique id
-// token bigint, -- access token
-// chsum char(32) not null default'', -- md5 checksum
-// ext varchar(128) not null default'', -- extension
-// type varchar(20) not null default'', -- access type
-// parent bigint, -- parent token
-// owner int REFERENCES {$this->subjTable}, -- subject have started it
-// ts timestamp
-// )");
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $CC_DBC->query("CREATE INDEX {$this->accessTable}_token_idx
-// ON {$this->accessTable} (token)");
-// $CC_DBC->query("CREATE INDEX {$this->accessTable}_gunid_idx
-// ON {$this->accessTable} (gunid)");
-// $CC_DBC->query("CREATE INDEX {$this->accessTable}_parent_idx
-// ON {$this->accessTable} (parent)");
-// if (!file_exists($this->storageDir)) {
-// mkdir($this->storageDir, 02775);
-// }
-// if (!file_exists($this->bufferDir)) {
-// mkdir($this->bufferDir, 02775);
-// }
-// $this->initData();
-// }
-
-
- /**
- * id subjns subject predns predicate objns object
- * y1 literal xmbf NULL namespace literal http://www.sotf.org/xbmf
- * x1 gunid xbmf contributor NULL NULL
- * x2 mdid x1 xbmf role literal Editor
- *
- * predefined shortcuts:
- * _L = literal
- * _G = gunid (global id of media file)
- * _I = mdid (local id of metadata record)
- * _nssshortcut = namespace shortcut definition
- * _blank = blank node
- */
-
- /**
- * uninstall
- *
- * @return void
- */
-// public function uninstall()
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['mdataTable']);
-// $CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq");
-// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['filesTable']);
-// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['accessTable']);
-// $d = @dir($CC_CONFIG['storageDir']);
-// while (is_object($d) && (false !== ($entry = $d->read()))){
-// if (filetype($CC_CONFIG['storageDir']."/$entry")=='dir') {
-// if ($entry!='CVS' && $entry!='tmp' && strlen($entry)==3) {
-// $dd = dir($CC_CONFIG['storageDir']."/$entry");
-// while (false !== ($ee = $dd->read())) {
-// if (substr($ee, 0, 1)!=='.') {
-// unlink($CC_CONFIG['storageDir']."/$entry/$ee");
-// }
-// }
-// $dd->close();
-// rmdir($CC_CONFIG['storageDir']."/$entry");
-// }
-// }
-// }
-// if (is_object($d)) {
-// $d->close();
-// }
-// if (file_exists($this->bufferDir)) {
-// $d = dir($this->bufferDir);
-// while (false !== ($entry = $d->read())) {
-// if(substr($entry,0,1)!='.') {
-// unlink("{$this->bufferDir}/$entry");
-// }
-// }
-// $d->close();
-// @rmdir($this->bufferDir);
-// }
-// parent::uninstall();
-// }
-
-
/**
* Aux logging for debug
*
diff --git a/campcaster/src/modules/storageServer/var/GreenBox.php b/campcaster/src/modules/storageServer/var/GreenBox.php
index 3ac18e5d8..05c5ebc0a 100644
--- a/campcaster/src/modules/storageServer/var/GreenBox.php
+++ b/campcaster/src/modules/storageServer/var/GreenBox.php
@@ -60,18 +60,15 @@ class GreenBox extends BasicStor {
* @param string $ftype
* Internal file type
* @return int
- * @exception PEAR::error
*/
- public function putFile($parid, $fileName,
- $mediaFileLP, $mdataFileLP, $sessid='',
- $gunid=NULL, $ftype='audioclip')
+ public function putFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
+ $sessid='', $gunid=NULL, $ftype='audioclip')
{
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
return $res;
}
- return $this->bsPutFile(
- $parid, $fileName, $mediaFileLP, $mdataFileLP, $gunid, $ftype
- );
+ return $this->bsPutFile($parid, $fileName, $mediaFileLP,
+ $mdataFileLP, $gunid, $ftype);
} // fn putFile
diff --git a/campcaster/src/modules/storageServer/var/LocStor.php b/campcaster/src/modules/storageServer/var/LocStor.php
index 3162d7446..71d4a3c75 100644
--- a/campcaster/src/modules/storageServer/var/LocStor.php
+++ b/campcaster/src/modules/storageServer/var/LocStor.php
@@ -38,17 +38,25 @@ class LocStor extends BasicStor {
* @return array
* {url:writable URL for HTTP PUT, token:access token}
*/
- protected function storeAudioClipOpen(
- $sessid, $gunid, $metadata, $fname, $chsum, $ftype='audioclip'
- )
+ protected function storeAudioClipOpen($sessid, $gunid, $metadata,
+ $fname, $chsum, $ftype='audioclip')
{
- // test of gunid format:
+ // Check the gunid format
if (!BasicStor::CheckGunid($gunid)) {
return PEAR::raiseError(
"LocStor::storeAudioClipOpen: Wrong gunid ($gunid)"
);
}
- // test if specified gunid exists:
+
+ // Check if we already have this file.
+ if ($duplicate = StoredFile::RecallByMd5($chsum)) {
+ return PEAR::raiseError(
+ "LocStor::storeAudioClipOpen: Duplicate file"
+ ." - Matched MD5 against '".$duplicate->getFileName()."'",
+ 888);
+ }
+
+ // Check if specified gunid exists.
$ac =& StoredFile::recallByGunid($gunid);
if (!PEAR::isError($ac)) {
// gunid exists - do replace
@@ -61,15 +69,13 @@ class LocStor extends BasicStor {
'LocStor::storeAudioClipOpen: is accessed'
);
}
- $res = $ac->replace(
- $oid, $ac->name, '', $metadata, 'string'
- );
+ $res = $ac->replace($oid, $ac->name, '', $metadata, 'string');
if (PEAR::isError($res)) {
return $res;
}
} else {
- // gunid doesn't exists - do insert:
- $tmpFname = uniqid('');
+ // gunid doesn't exist - do insert:
+ $tmpFname = uniqid();
$parid = $this->_getHomeDirIdFromSess($sessid);
if (PEAR::isError($parid)) {
return $parid;
@@ -555,7 +561,7 @@ class LocStor extends BasicStor {
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
return $res;
}
- return $ac->replaceMetaData($metadata, 'string');
+ return $ac->replaceMetadata($metadata, 'string');
}
@@ -692,7 +698,7 @@ class LocStor extends BasicStor {
if (PEAR::isError($ac)) {
return $ac;
}
- $res = $ac->replaceMetaData($newPlaylist, 'string', 'playlist');
+ $res = $ac->replaceMetadata($newPlaylist, 'string', 'playlist');
if (PEAR::isError($res)) {
return $res;
}
@@ -729,7 +735,7 @@ class LocStor extends BasicStor {
if (PEAR::isError($mdata)) {
return $mdata;
}
- $res = $ac->replaceMetaData($mdata, 'string');
+ $res = $ac->replaceMetadata($mdata, 'string');
if (PEAR::isError($res)) {
return $res;
}
diff --git a/campcaster/src/modules/storageServer/var/LsPlaylist.php b/campcaster/src/modules/storageServer/var/LsPlaylist.php
index 1c4460630..fc5454c62 100644
--- a/campcaster/src/modules/storageServer/var/LsPlaylist.php
+++ b/campcaster/src/modules/storageServer/var/LsPlaylist.php
@@ -473,7 +473,7 @@ class LsPlaylistAudioClip
if (PEAR::isError($ac)) {
return $ac;
}
- $RADext = $ac->_getExt();
+ $RADext = $ac->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
@@ -493,7 +493,7 @@ class LsPlaylistAudioClip
if (PEAR::isError($ac)) {
return $ac;
}
- $RADext = $ac->_getExt();
+ $RADext = $ac->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
@@ -512,7 +512,7 @@ class LsPlaylistAudioClip
if (PEAR::isError($ac)) {
return $ac;
}
- $RADext = $ac->_getExt();
+ $RADext = $ac->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
diff --git a/campcaster/src/modules/storageServer/var/MetaData.php b/campcaster/src/modules/storageServer/var/MetaData.php
index f59b1ce63..7d175a39f 100644
--- a/campcaster/src/modules/storageServer/var/MetaData.php
+++ b/campcaster/src/modules/storageServer/var/MetaData.php
@@ -29,8 +29,6 @@ class MetaData {
public $exists;
/**
- * @param Greenbox $gb
- * A reference to GreenBox object
* @param string $gunid
* global unique id
* @param string $resDir
@@ -40,7 +38,7 @@ class MetaData {
{
$this->gunid = $gunid;
$this->resDir = $resDir;
- $this->fname = $this->makeFname();
+ $this->fname = $this->makeFileName();
$this->exists = null;
}
@@ -554,7 +552,7 @@ class MetaData {
*
* @return string
*/
- private function makeFname()
+ private function makeFileName()
{
return "{$this->resDir}/{$this->gunid}.xml";
}
@@ -565,7 +563,7 @@ class MetaData {
*
* @return string
*/
- public function getFname()
+ public function getFileName()
{
return $this->fname;
}
diff --git a/campcaster/src/modules/storageServer/var/RawMediaData.php b/campcaster/src/modules/storageServer/var/RawMediaData.php
index d9f0d1a8b..610c5fd3c 100644
--- a/campcaster/src/modules/storageServer/var/RawMediaData.php
+++ b/campcaster/src/modules/storageServer/var/RawMediaData.php
@@ -17,7 +17,6 @@
*/
function camp_add_metadata(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859-1')
{
- #echo "$key($iEnc): $val\n";
if (!is_null($p_val)) {
$data = $p_val;
$outputEncoding = 'UTF-8';
@@ -69,7 +68,6 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
if (isset($infoFromFile['error'])) {
return new PEAR_Error(array_pop($infoFromFile['error']));
}
- #if(!$infoFromFile['fileformat']){ echo "???\n"; continue; }
if (!$infoFromFile['bitrate']) {
return new PEAR_Error("File given is not an audio file.");
}
@@ -239,13 +237,10 @@ class RawMediaData {
*/
public function __construct($gunid, $resDir)
{
- $this->gunid = $gunid;
+ $this->gunid = $gunid;
$this->resDir = $resDir;
- $this->fname = $this->makeFname();
- $this->exists =
- is_file($this->fname) &&
- is_readable($this->fname)
- ;
+ $this->fname = $this->makeFileName();
+ $this->exists = is_file($this->fname) && is_readable($this->fname);
}
@@ -256,8 +251,7 @@ class RawMediaData {
* local path
* @param boolean $copyMedia
* copy the media file if true, make symlink if false
- * @return mixed
- * true or PEAR::error
+ * @return TRUE|PEAR_Error
*/
function insert($mediaFileLP, $copyMedia=TRUE)
{
@@ -292,9 +286,9 @@ class RawMediaData {
/**
* Delete and insert media file
*
- * @param string $mediaFileLP, local path
- * @return mixed
- * true or PEAR::error
+ * @param string $mediaFileLP
+ * local path
+ * @return TRUE|PEAR_Error
*/
function replace($mediaFileLP)
{
@@ -326,7 +320,7 @@ class RawMediaData {
*
* @return string
*/
- function getFname()
+ function getFileName()
{
return $this->fname;
}
@@ -335,8 +329,7 @@ class RawMediaData {
/**
* Delete media file from filesystem
*
- * @return mixed
- * boolean or PEAR::error
+ * @return boolean|PEAR_Error
*/
function delete()
{
@@ -399,7 +392,7 @@ class RawMediaData {
*
* @return string
*/
- function makeFname()
+ function makeFileName()
{
return "{$this->resDir}/{$this->gunid}";
}
diff --git a/campcaster/src/modules/storageServer/var/SmilPlaylist.php b/campcaster/src/modules/storageServer/var/SmilPlaylist.php
index 6ac9d691e..cc00d8bb1 100644
--- a/campcaster/src/modules/storageServer/var/SmilPlaylist.php
+++ b/campcaster/src/modules/storageServer/var/SmilPlaylist.php
@@ -75,7 +75,7 @@ class SmilPlaylist {
if (PEAR::isError($r)) {
return $r;
}
- $r = $pl->replaceMetaData($lspl, 'string', 'playlist');
+ $r = $pl->replaceMetadata($lspl, 'string', 'playlist');
if (PEAR::isError($r)) {
return $r;
}
diff --git a/campcaster/src/modules/storageServer/var/StoredFile.php b/campcaster/src/modules/storageServer/var/StoredFile.php
index d1270da9f..291034d62 100644
--- a/campcaster/src/modules/storageServer/var/StoredFile.php
+++ b/campcaster/src/modules/storageServer/var/StoredFile.php
@@ -21,16 +21,10 @@ require_once(dirname(__FILE__)."/../../getid3/var/getid3.php");
* @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 DB
- */
- public $dbc;
-
/**
* Unique ID for the file.
*
@@ -82,9 +76,9 @@ class StoredFile {
*
* @param int $oid
* local object id in the tree
- * @param string $name
+ * @param string $filename
* name of new file
- * @param string $mediaFileLP
+ * @param string $localFilePath
* local path to media file
* @param string $metadata
* local path to metadata XML file or XML string
@@ -94,38 +88,35 @@ class StoredFile {
* unique id - for insert file with gunid
* @param string $ftype
* internal file type
- * @param string $className
- * class to be constructed
* @param boolean $copyMedia
* copy the media file if true, make symlink if false
* @return StoredFile
*/
- public static function &insert($oid, $name,
- $mediaFileLP='', $metadata='', $mdataLoc='file',
- $gunid=NULL, $ftype=NULL, $className='StoredFile', $copyMedia=TRUE)
+ public static function &insert($oid, $filename, $localFilePath='',
+ $metadata='', $mdataLoc='file', $gunid=NULL, $ftype=NULL, $copyMedia=TRUE)
{
global $CC_CONFIG, $CC_DBC;
- $ac = new $className(($gunid ? $gunid : NULL));
+ $ac = new StoredFile(($gunid ? $gunid : NULL));
if (PEAR::isError($ac)) {
return $ac;
}
- $ac->name = $name;
+ $ac->name = $filename;
$ac->id = $oid;
$ac->mime = "unknown";
$emptyState = TRUE;
if ($ac->name == '') {
$ac->name = $ac->gunid;
}
- $escapedName = pg_escape_string($name);
+ $md5 = md5_file($localFilePath);
+ $escapedName = pg_escape_string($filename);
$escapedFtype = pg_escape_string($ftype);
$CC_DBC->query("BEGIN");
- $res = $CC_DBC->query("
- INSERT INTO ".$CC_CONFIG['filesTable']."
- (id, name, gunid, mime, state, ftype, mtime)
- VALUES
- ('$oid', '{$escapedName}', x'{$ac->gunid}'::bigint,
- '{$ac->mime}', 'incomplete', '$escapedFtype', now())
- ");
+ $sql = "INSERT INTO ".$CC_CONFIG['filesTable']
+ ."(id, name, gunid, mime, state, ftype, mtime, md5)"
+ ."VALUES ('$oid', '{$escapedName}', x'{$ac->gunid}'::bigint,
+ '{$ac->mime}', 'incomplete', '$escapedFtype', now(), '$md5')";
+ echo $sql;
+ $res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
$CC_DBC->query("ROLLBACK");
return $res;
@@ -147,12 +138,12 @@ class StoredFile {
return $res;
}
// --- media file insert:
- if ($mediaFileLP != '') {
- if (!file_exists($mediaFileLP)) {
+ if ($localFilePath != '') {
+ if (!file_exists($localFilePath)) {
return PEAR::raiseError("StoredFile::insert: ".
- "media file not found ($mediaFileLP)");
+ "media file not found ($localFilePath)");
}
- $res = $ac->rmd->insert($mediaFileLP, $copyMedia);
+ $res = $ac->rmd->insert($localFilePath, $copyMedia);
if (PEAR::isError($res)) {
$CC_DBC->query("ROLLBACK");
return $res;
@@ -191,11 +182,9 @@ class StoredFile {
* local object id in the tree
* @param string $gunid
* global unique id of file
- * @param string $className
- * classname to recall
* @return StoredFile
*/
- public static function &recall($oid='', $gunid='', $className='StoredFile')
+ public static function &recall($oid='', $gunid='')
{
global $CC_DBC;
global $CC_CONFIG;
@@ -218,7 +207,7 @@ class StoredFile {
return $r;
}
$gunid = StoredFile::NormalizeGunid($row['gunid']);
- $ac = new $className($gunid);
+ $ac = new StoredFile($gunid);
$ac->mime = $row['mime'];
$ac->name = $row['name'];
$ac->id = $row['id'];
@@ -232,14 +221,12 @@ class StoredFile {
* by gunid.
*
* @param string $gunid
- * optional, global unique id of file
- * @param string $className
- * optional classname to recall
+ * global unique id of file
* @return StoredFile
*/
- public static function &recallByGunid($gunid='', $className='StoredFile')
+ public static function &recallByGunid($gunid='')
{
- return StoredFile::recall('', $gunid, $className);
+ return StoredFile::recall('', $gunid);
}
@@ -249,18 +236,15 @@ class StoredFile {
*
* @param string $token
* access token
- * @param string $className
- * optional classname to recall
* @return StoredFile
*/
- public static function recallByToken($token, $className='StoredFile')
+ public static function recallByToken($token)
{
global $CC_CONFIG, $CC_DBC;
$gunid = $CC_DBC->getOne("
- SELECT to_hex(gunid)as gunid
+ SELECT to_hex(gunid) as gunid
FROM ".$CC_CONFIG['accessTable']."
- WHERE token=x'$token'::bigint
- ");
+ WHERE token=x'$token'::bigint");
if (PEAR::isError($gunid)) {
return $gunid;
}
@@ -269,7 +253,32 @@ class StoredFile {
"StoredFile::recallByToken: invalid token ($token)", GBERR_AOBJNEX);
}
$gunid = StoredFile::NormalizeGunid($gunid);
- return StoredFile::recall('', $gunid, $className);
+ return StoredFile::recall('', $gunid);
+ }
+
+
+ /**
+ * Check if the MD5 value already exists.
+ *
+ * @param string $p_md5sum
+ * @return StoredFile|FALSE|PEAR_Error
+ */
+ public static function RecallByMd5($p_md5sum)
+ {
+ global $CC_CONFIG, $CC_DBC;
+ $gunid = $CC_DBC->getOne(
+ "SELECT to_hex(gunid) as gunid
+ FROM ".$CC_CONFIG['filesTable']."
+ WHERE md5='$p_md5sum'");
+ if (PEAR::isError($gunid)) {
+ return $gunid;
+ }
+ if ($gunid) {
+ $gunid = StoredFile::NormalizeGunid($gunid);
+ return StoredFile::recall('', $gunid);
+ } else {
+ return FALSE;
+ }
}
@@ -284,7 +293,7 @@ class StoredFile {
*/
public static function &CopyOf(&$src, $nid)
{
- $ac = StoredFile::insert($nid, $src->name, $src->_getRealRADFname(),
+ $ac = StoredFile::insert($nid, $src->name, $src->getRealFileName(),
'', '', NULL, BasicStor::GetType($src->gunid));
if (PEAR::isError($ac)) {
return $ac;
@@ -294,20 +303,20 @@ class StoredFile {
}
- /* ======================================================= public methods */
/**
- * Replace existing file with new data
+ * Replace existing file with new data.
*
- * @param int $oid
+ * @param int $oid
* local id
- * @param string $name
+ * @param string $name
* name of file
- * @param string $mediaFileLP
+ * @param string $mediaFileLP
* local path to media file
- * @param string $metadata
+ * @param string $metadata
* local path to metadata XML file or XML string
- * @param string $mdataLoc
+ * @param string $mdataLoc
* 'file'|'string'
+ * @return TRUE|PEAR_Error
*/
public function replace($oid, $name, $mediaFileLP='', $metadata='',
$mdataLoc='file')
@@ -319,7 +328,7 @@ class StoredFile {
$CC_DBC->query("ROLLBACK");
return $res;
}
- if ($mediaFileLP != '') { // media
+ if ($mediaFileLP != '') {
$res = $this->replaceRawMediaData($mediaFileLP);
} else {
$res = $this->rmd->delete();
@@ -328,8 +337,8 @@ class StoredFile {
$CC_DBC->query("ROLLBACK");
return $res;
}
- if ($metadata != '') { // metadata
- $res = $this->replaceMetaData($metadata, $mdataLoc);
+ if ($metadata != '') {
+ $res = $this->replaceMetadata($metadata, $mdataLoc);
} else {
$res = $this->md->delete();
}
@@ -357,8 +366,8 @@ class StoredFile {
*/
public function accessRawMediaData($parent='0')
{
- $realFname = $this->_getRealRADFname();
- $ext = $this->_getExt();
+ $realFname = $this->getRealFileName();
+ $ext = $this->getFileExtension();
$res = BasicStor::bsAccess($realFname, $ext, $this->gunid, 'access', $parent);
if (PEAR::isError($res)) {
return $res;
@@ -392,6 +401,7 @@ class StoredFile {
*
* @param string $mediaFileLP
* local path to media file
+ * @return void|PEAR_Error
*/
public function replaceRawMediaData($mediaFileLP)
{
@@ -426,7 +436,7 @@ class StoredFile {
* (NULL = no validation)
* @return boolean
*/
- public function replaceMetaData($metadata, $mdataLoc='file', $format=NULL)
+ public function replaceMetadata($metadata, $mdataLoc='file', $format=NULL)
{
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("BEGIN");
@@ -479,7 +489,7 @@ class StoredFile {
* Rename stored virtual file
*
* @param string $newname
- * @return TRUE/PEAR_Error
+ * @return TRUE|PEAR_Error
*/
public function rename($newname)
{
@@ -503,8 +513,7 @@ class StoredFile {
* 'empty'|'incomplete'|'ready'|'edited'
* @param int $editedby
* user id | 'NULL' for clear editedBy field
- * (optional)
- * @return TRUE/PEAR_Error
+ * @return TRUE|PEAR_Error
*/
public function setState($state, $editedby=NULL)
{
@@ -528,7 +537,7 @@ class StoredFile {
*
* @param string $mime
* mime-type
- * @return boolean or error
+ * @return boolean|PEAR_Error
*/
public function setMime($mime)
{
@@ -548,11 +557,33 @@ class StoredFile {
}
+ /**
+ * Set md5 of virtual file
+ *
+ * @param string $p_md5sum
+ * @return boolean|PEAR_Error
+ */
+ public function setMd5($p_md5sum)
+ {
+ global $CC_CONFIG, $CC_DBC;
+ $escapedMd5 = pg_escape_string($p_md5sum);
+ $res = $CC_DBC->query("
+ UPDATE ".$CC_CONFIG['filesTable']." SET md5='$escapedMd5', mtime=now()
+ WHERE gunid=x'{$this->gunid}'::bigint
+ ");
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+ return TRUE;
+ }
+
+
/**
* Delete stored virtual file
*
* @see RawMediaData
* @see MetaData
+ * @return TRUE|PEAR_Error
*/
public function delete()
{
@@ -571,7 +602,7 @@ class StoredFile {
");
if (is_array($tokens)) {
foreach($tokens as $i=>$item){
- $file = $this->_getAccessFname($item['token'], $item['ext']);
+ $file = $this->_getAccessFileName($item['token'], $item['ext']);
if (file_exists($file)) {
@unlink($file);
}
@@ -601,6 +632,7 @@ class StoredFile {
*
* @param string $gunid
* optional (for static call), global unique id
+ * @return boolean|PEAR_Error
*/
public function isAccessed($gunid=NULL)
{
@@ -634,7 +666,7 @@ class StoredFile {
if (is_null($playlistId)) {
$playlistId = $this->gunid;
}
- $state = $this->_getState($playlistId);
+ $state = $this->getState($playlistId);
if ($state != 'edited') {
return FALSE;
}
@@ -647,7 +679,7 @@ class StoredFile {
*
* @param string $playlistId
* playlist global unique ID
- * @return null or int
+ * @return int|null|PEAR_Error
* id of user editing it
*/
public function isEditedBy($playlistId=NULL)
@@ -671,8 +703,8 @@ class StoredFile {
/**
- * Returns local id of virtual file
- *
+ * Returns local id of virtual file
+ * @return int
*/
public function getId()
{
@@ -681,16 +713,15 @@ class StoredFile {
/**
- * Returns true if raw media file exists
- *
+ * Returns true if raw media file exists
+ * @return boolean|PEAR_Error
*/
public function exists()
{
global $CC_CONFIG, $CC_DBC;
- $indb = $CC_DBC->getRow("
- SELECT to_hex(gunid) FROM ".$CC_CONFIG['filesTable']."
- WHERE gunid=x'{$this->gunid}'::bigint
- ");
+ $indb = $CC_DBC->getRow(
+ "SELECT to_hex(gunid) FROM ".$CC_CONFIG['filesTable']
+ ." WHERE gunid=x'{$this->gunid}'::bigint");
if (PEAR::isError($indb)) {
return $indb;
}
@@ -704,16 +735,14 @@ class StoredFile {
}
- /* ==================================================== "private" methods */
/**
- * Create new global unique id
- *
+ * Create new global unique id
+ * @return string
*/
public static function CreateGunid()
{
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
- $initString =
- microtime().$ip.rand()."org.mdlf.campcaster";
+ $initString = microtime().$ip.rand()."org.mdlf.campcaster";
$hash = md5($initString);
// non-negative int8
$hsd = substr($hash, 0, 1);
@@ -727,9 +756,9 @@ class StoredFile {
*
* @return string
*/
- public static function NormalizeGunid($gunid0)
+ public static function NormalizeGunid($gunid)
{
- return str_pad($gunid0, 16, "0", STR_PAD_LEFT);
+ return str_pad($gunid, 16, "0", STR_PAD_LEFT);
}
@@ -767,9 +796,9 @@ class StoredFile {
* @return string
* file extension without a dot
*/
- public function _getExt()
+ public function getFileExtension()
{
- $fname = $this->_getFileName();
+ $fname = $this->getFileName();
$pos = strrpos($fname, '.');
if ($pos !== FALSE) {
$ext = substr($fname, $pos+1);
@@ -801,7 +830,7 @@ class StoredFile {
* Get mime-type from global id
*
* @param string $gunid
- * optional, global unique id of file
+ * global unique id of file
* @return string
* mime-type
*/
@@ -821,11 +850,11 @@ class StoredFile {
* Get storage-internal file state
*
* @param string $gunid
- * optional, global unique id of file
+ * global unique id of file
* @return string
* see install()
*/
- public function _getState($gunid=NULL)
+ public function getState($gunid=NULL)
{
global $CC_CONFIG, $CC_DBC;
if (is_null($gunid)) {
@@ -842,11 +871,10 @@ class StoredFile {
* Get mnemonic file name
*
* @param string $gunid
- * optional, global unique id of file
+ * global unique id of file
* @return string
- * see install()
*/
- public function _getFileName($gunid=NULL)
+ public function getFileName($gunid=NULL)
{
global $CC_CONFIG, $CC_DBC;
if (is_null($gunid)) {
@@ -860,9 +888,10 @@ class StoredFile {
/**
- * Get and optionaly create subdirectory in real filesystem for storing
- * raw media data
+ * Get and optionally create subdirectory in real filesystem for storing
+ * raw media data.
*
+ * @return string
*/
private function _getResDir()
{
@@ -881,22 +910,24 @@ class StoredFile {
/**
* Get real filename of raw media data
*
+ * @return string
* @see RawMediaData
*/
- public function _getRealRADFname()
+ public function getRealFileName()
{
- return $this->rmd->getFname();
+ return $this->rmd->getFileName();
}
/**
* Get real filename of metadata file
*
+ * @return string
* @see MetaData
*/
- public function _getRealMDFname()
+ public function getRealMetadataFileName()
{
- return $this->md->getFname();
+ return $this->md->getFileName();
}
@@ -904,8 +935,9 @@ class StoredFile {
* Create and return name for temporary symlink.
*
* @todo Should be more unique
+ * @return string
*/
- private function _getAccessFname($token, $ext='EXT')
+ private function _getAccessFileName($token, $ext='EXT')
{
global $CC_CONFIG;
$token = StoredFile::NormalizeGunid($token);
diff --git a/campcaster/src/modules/storageServer/var/Transport.php b/campcaster/src/modules/storageServer/var/Transport.php
index 2d6f9a19d..a18ff2311 100644
--- a/campcaster/src/modules/storageServer/var/Transport.php
+++ b/campcaster/src/modules/storageServer/var/Transport.php
@@ -292,7 +292,7 @@ class Transport
return $ac;
}
// handle metadata:
- $mdfpath = $ac->_getRealMDFname();
+ $mdfpath = $ac->getRealMetadataFileName();
if (PEAR::isError($mdfpath)) {
return $mdfpath;
}
@@ -303,11 +303,11 @@ class Transport
return $mdtrec;
}
// handle raw media file:
- $fpath = $ac->_getRealRADFname();
+ $fpath = $ac->getRealFileName();
if (PEAR::isError($fpath)) {
return $fpath;
}
- $fname = $ac->_getFileName();
+ $fname = $ac->getFileName();
if (PEAR::isError($fname)) {
return $fname;
}
@@ -329,7 +329,7 @@ class Transport
if (PEAR::isError($pl)) {
return $pl;
}
- $fname = $pl->_getFileName();
+ $fname = $pl->getFileName();
if (PEAR::isError($fname)) {
return $fname;
}
@@ -352,7 +352,7 @@ class Transport
$fname = $fname.".lspl";
$trtype = 'playlistPkg';
} else {
- $plfpath = $pl->_getRealMDFname();
+ $plfpath = $pl->getRealMetadataFileName();
if (PEAR::isError($plfpath)) {
return $plfpath;
}
diff --git a/campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.2.0.php b/campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.2.0.php
new file mode 100644
index 000000000..94dc9ddb0
--- /dev/null
+++ b/campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.2.0.php
@@ -0,0 +1,71 @@
+
+ * @version $Revision: 2834 $
+ * @package Campcaster
+ * @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
+ *
+ * Note: This file was broken into two parts: install.php and
+ * installMain.php so that the archive server could use the same
+ * installation script, but with just a different config file.
+ */
+
+// Do not allow remote execution
+$arr = array_diff_assoc($_SERVER, $_ENV);
+if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
+ header("HTTP/1.1 400");
+ header("Content-type: text/plain; charset=UTF-8");
+ echo "400 Not executable\r\n";
+ exit(1);
+}
+
+echo "**********************************\n";
+echo "* StorageServer Upgrade to 1.2.0 *\n";
+echo "**********************************\n";
+
+require_once('../../conf.php');
+require_once("../installInit.php");
+require_once("../../StoredFile.php");
+
+// Check to see if upgrade has already been applied
+//$sql = "SELECT md5 FROM ".$CC_CONFIG['filesTable']." LIMIT 1";
+//$result = $CC_DBC->query($sql);
+//if (!PEAR::isError($result)) {
+// echo "THIS UPGRADE HAS ALREADY BEEN APPLIED.\n";
+// exit(0);
+//}
+//
+//echo " * Modifying '".$CC_CONFIG['filesTable']." table...";
+//$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ADD COLUMN md5 char(32)";
+//camp_install_query($sql);
+//
+//$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ALTER COLUMN md5 SET STORAGE EXTENDED";
+//camp_install_query($sql);
+//
+//$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx ON ".$CC_CONFIG['filesTable']." (md5)";
+//camp_install_query($sql);
+
+// Get MD5 values for all files
+$sql = "SELECT gunid FROM ".$CC_CONFIG['filesTable'] ." WHERE ftype='audioclip'";
+$rows = $CC_DBC->GetAll($sql);
+foreach ($rows as $row) {
+ echo $row['gunid']."\n";
+ $gunid = StoredFile::NormalizeGunid($gunid);
+ $storedFile = new StoredFile($row['gunid']);
+ $fileName = $storedFile->getRealFileName();
+ echo $fileName."\n";
+ if (file_exists($fileName)) {
+ $md5 = md5_file($fileName);
+ $storedFile->setMd5($md5);
+ }
+}
+
+
+echo "**********************************\n";
+echo "* StorageServer Install Complete *\n";
+echo "**********************************\n";
+
+?>
\ No newline at end of file
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
index 5a35033e3..dbda3d119 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
@@ -252,6 +252,8 @@ class XR_LocStor extends LocStor {
* 801 - wrong 1st parameter, struct expected.
* 805 - xr_storeAudioClipOpen:
* <message from lower layer>
+ * 888 - If the file being uploaded is a duplicate of
+ * a file already in the system.
*
*
* @param XML_RPC_Message $input
@@ -264,11 +266,14 @@ class XR_LocStor extends LocStor {
if (!$ok) {
return $r;
}
- $res = $this->storeAudioClipOpen(
- $r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['chsum']
- );
+ $res = $this->storeAudioClipOpen($r['sessid'], $r['gunid'],
+ $r['metadata'], $r['fname'], $r['chsum']);
if (PEAR::isError($res)) {
- return new XML_RPC_Response(0, 805,
+ $code = 805;
+ if ($res->getCode() == 888) {
+ $code = 888;
+ }
+ return new XML_RPC_Response(0, $code,
"xr_storeAudioClipOpen: ".$res->getMessage().
" ".$res->getUserInfo()
);
@@ -3221,7 +3226,7 @@ class XR_LocStor extends LocStor {
}
require_once('../Transport.php');
$tr = new Transport($this);
- $uid = Alib::GetSessUserId($par['sessid']);
+ $uid = Alib::GetSessUserId($par['sessid']);
$res = $tr->downloadFromHub($uid, $par['gunid']);
if (PEAR::isError($res)) {
$ec0 = intval($res->getCode());
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/put.php b/campcaster/src/modules/storageServer/var/xmlrpc/put.php
index cb088da4d..0ec8787dc 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/put.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/put.php
@@ -32,16 +32,17 @@
define('USE_FLOCK', TRUE);
-require_once dirname(__FILE__).'/../conf.php';
-require_once 'DB.php';
-require_once dirname(__FILE__).'/../LocStor.php';
+require_once(dirname(__FILE__).'/../conf.php');
+require_once('DB.php');
+require_once(dirname(__FILE__).'/../LocStor.php');
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = new LocStor();
-function http_error($code, $err) {
+function http_error($code, $err)
+{
header("HTTP/1.1 $code");
header("Content-type: text/plain; charset=UTF-8");
echo "$err\r\n";
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php b/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php
index d95df7540..f0331b1cf 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php
@@ -83,7 +83,7 @@ if (PEAR::isError($ftype)) {
}
switch ($ftype) {
case "audioclip":
- $realFname = $ac->_getRealRADFname();
+ $realFname = $ac->getRealFileName();
$mime = $ac->rmd->getMime();
header("Content-type: $mime");
header("Content-length: ".filesize($realFname));
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php
index 4332798a4..3bb833bed 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php
@@ -72,9 +72,9 @@ $methods = array(
'logout' => 'Logout from storage.',
'existsAudioClip' => 'Checks if an Audio clip with the specified '.
'id is stored in local storage.',
- 'storeAudioClipOpen' => 'Open channel for store a new audio clip '.
+ 'storeAudioClipOpen' => 'Open channel to store a new audio clip '.
'or replace an existing one.',
- 'storeAudioClipClose' => 'Close channel for store a new audio clip'.
+ 'storeAudioClipClose' => 'Close channel to store a new audio clip'.
' or replace an existing one.',
'downloadRawAudioDataOpen'=> 'Create and return downloadable URL'.
'for audio file',
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/xr_cli_test.php b/campcaster/src/modules/storageServer/var/xmlrpc/xr_cli_test.php
index 18934dd3c..a31b1571e 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/xr_cli_test.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/xr_cli_test.php
@@ -1,163 +1,182 @@
debug = 1;
- echo "serverPath: $serverPath\n";
- echo "host: {$url['host']}, path: {$url['path']}\n";
- echo "method: $method\n";
- echo "pars:\n";
+ echo "ServerPath: $serverPath\n";
+ echo "Host: {$url['host']}, path: {$url['path']}\n";
+ echo "Method: $method\n";
+ echo "Parameters:\n";
var_dump($pars);
}
$infos = array(
- "listMethods" => array('m'=>"system.listMethods", 'p'=>NULL),
- "methodHelp" => array('m'=>"system.methodHelp", 'p'=>0),
- "methodSignature" => array('m'=>"system.methodSignature", 'p'=>0),
- "test" =>
- array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')),
- "getVersion" => array('m'=>"locstor.getVersion",
- 'p'=>array(), 'r'=>'version'),
- "authenticate" => array('m'=>"locstor.authenticate",
- 'p'=>array('login', 'pass'), 'r'=>'authenticate'),
- "login" => array('m'=>"locstor.login",
- 'p'=>array('login', 'pass'), 'r'=>'sessid'),
- "logout" => array('m'=>"locstor.logout",
- 'p'=>array('sessid'), 'r'=>'status'),
-
- "storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen",
+ "listMethods" => array('m'=>"system.listMethods", 'p'=>NULL),
+ "methodHelp" => array('m'=>"system.methodHelp", 'p'=>0),
+ "methodSignature" => array('m'=>"system.methodSignature", 'p'=>0),
+ "test" => array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')),
+ "getVersion" => array('m'=>"locstor.getVersion", 'p'=>array(), 'r'=>'version'),
+ "authenticate" => array('m'=>"locstor.authenticate", 'p'=>array('login', 'pass'), 'r'=>'authenticate'),
+ "login" => array('m'=>"locstor.login", 'p'=>array('login', 'pass'), 'r'=>'sessid'),
+ "logout" => array('m'=>"locstor.logout", 'p'=>array('sessid'), 'r'=>'status'),
+ "storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen",
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'),
'r'=>array('url', 'token')
),
- "storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose",
+ "storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose",
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
- "accessRawAudioData" => array('m'=>"locstor.accessRawAudioData",
+ "accessRawAudioData" => array('m'=>"locstor.accessRawAudioData",
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
- "releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData",
+ "releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData",
'p'=>array('token'), 'r'=>'status'),
- "downloadRawAudioDataOpen" =>
+ "downloadRawAudioDataOpen" =>
array('m'=>"locstor.downloadRawAudioDataOpen",
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
"downloadRawAudioDataClose" =>
array('m'=>"locstor.downloadRawAudioDataClose",
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
- "downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen",
+ "downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen",
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
- "downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose",
+ "downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose",
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
- "deleteAudioClip" =>
+ "deleteAudioClip" =>
array('m'=>"locstor.deleteAudioClip",
'p'=>array('sessid', 'gunid', 'forced'), 'r'=>'status'),
- "existsAudioClip" => array('m'=>"locstor.existsAudioClip",
+ "existsAudioClip" => array('m'=>"locstor.existsAudioClip",
'p'=>array('sessid', 'gunid'), 'r'=>'exists'),
- "getAudioClip" => array('m'=>"locstor.getAudioClip",
+ "getAudioClip" => array('m'=>"locstor.getAudioClip",
'p'=>array('sessid', 'gunid'), 'r'=>'metadata'),
- "updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
+ "updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
- "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
- "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
- "resetStorage" => array('m'=>"locstor.resetStorage",
+ "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
+ "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
+ "resetStorage" => array('m'=>"locstor.resetStorage",
'p'=>array()),
# 'p'=>array('loadSampleData', 'invalidateSessionIds')),
- "storeWebstream" => array('m'=>"locstor.storeWebstream",
+ "storeWebstream" => array('m'=>"locstor.storeWebstream",
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'),
'r'=>array('gunid')
),
- "createPlaylist" => array('m'=>"locstor.createPlaylist",
+ "createPlaylist" => array('m'=>"locstor.createPlaylist",
'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'),
- "editPlaylist" => array('m'=>"locstor.editPlaylist",
+ "editPlaylist" => array('m'=>"locstor.editPlaylist",
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
- "savePlaylist" => array('m'=>"locstor.savePlaylist",
+ "savePlaylist" => array('m'=>"locstor.savePlaylist",
'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'),
- "revertEditedPlaylist" => array('m'=>"locstor.revertEditedPlaylist",
+ "revertEditedPlaylist" => array('m'=>"locstor.revertEditedPlaylist",
'p'=>array('sessid', 'token'), 'r'=>'plid'),
- "deletePlaylist" => array('m'=>"locstor.deletePlaylist",
+ "deletePlaylist" => array('m'=>"locstor.deletePlaylist",
'p'=>array('sessid', 'plid', 'forced'), 'r'=>'status'),
- "accessPlaylist" => array('m'=>"locstor.accessPlaylist",
+ "accessPlaylist" => array('m'=>"locstor.accessPlaylist",
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
- "releasePlaylist" => array('m'=>"locstor.releasePlaylist",
+ "releasePlaylist" => array('m'=>"locstor.releasePlaylist",
'p'=>array('token'), 'r'=>'plid'),
- "existsPlaylist" => array('m'=>"locstor.existsPlaylist",
+ "existsPlaylist" => array('m'=>"locstor.existsPlaylist",
'p'=>array('sessid', 'plid'), 'r'=>'exists'),
- "playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable",
+ "playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable",
'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')),
- "exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen",
+ "exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen",
'p'=>array('sessid', 'plids', 'type', 'standalone'),
'r'=>array('url', 'token')),
- "exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose",
+ "exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose",
'p'=>array('token'), 'r'=>array('status')),
- "importPlaylistOpen" => array('m'=>"locstor.importPlaylistOpen",
+ "importPlaylistOpen" => array('m'=>"locstor.importPlaylistOpen",
'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')),
- "importPlaylistClose" => array('m'=>"locstor.importPlaylistClose",
+ "importPlaylistClose" => array('m'=>"locstor.importPlaylistClose",
'p'=>array('token'), 'r'=>array('gunid')),
- "renderPlaylistToFileOpen" => array('m'=>"locstor.renderPlaylistToFileOpen",
+ "renderPlaylistToFileOpen" => array('m'=>"locstor.renderPlaylistToFileOpen",
'p'=>array('sessid', 'plid'),
'r'=>array('token')),
- "renderPlaylistToFileCheck" => array('m'=>"locstor.renderPlaylistToFileCheck",
+ "renderPlaylistToFileCheck" => array('m'=>"locstor.renderPlaylistToFileCheck",
'p'=>array('token'), 'r'=>array('status', 'url')),
"renderPlaylistToFileClose" => array('m'=>"locstor.renderPlaylistToFileClose",
'p'=>array('token'), 'r'=>array('status')),
"renderPlaylistToStorageOpen" => array('m'=>"locstor.renderPlaylistToStorageOpen",
'p'=>array('sessid', 'plid'),
'r'=>array('token')),
- "renderPlaylistToStorageCheck" => array('m'=>"locstor.renderPlaylistToStorageCheck",
+ "renderPlaylistToStorageCheck" => array('m'=>"locstor.renderPlaylistToStorageCheck",
'p'=>array('token'), 'r'=>array('status', 'gunid')),
"renderPlaylistToRSSOpen" => array('m'=>"locstor.renderPlaylistToRSSOpen",
'p'=>array('sessid', 'plid'),
'r'=>array('token')),
- "renderPlaylistToRSSCheck" => array('m'=>"locstor.renderPlaylistToRSSCheck",
+ "renderPlaylistToRSSCheck" => array('m'=>"locstor.renderPlaylistToRSSCheck",
'p'=>array('token'), 'r'=>array('status', 'url')),
- "renderPlaylistToRSSClose" => array('m'=>"locstor.renderPlaylistToRSSClose",
+ "renderPlaylistToRSSClose" => array('m'=>"locstor.renderPlaylistToRSSClose",
'p'=>array('token'), 'r'=>array('status')),
- "loadPref" => array('m'=>"locstor.loadPref",
+ "loadPref" => array('m'=>"locstor.loadPref",
'p'=>array('sessid', 'key'), 'r'=>'value'),
- "savePref" => array('m'=>"locstor.savePref",
+ "savePref" => array('m'=>"locstor.savePref",
'p'=>array('sessid', 'key', 'value'), 'r'=>'status'),
- "delPref" => array('m'=>"locstor.delPref",
+ "delPref" => array('m'=>"locstor.delPref",
'p'=>array('sessid', 'key'), 'r'=>'status'),
- "loadGroupPref" => array('m'=>"locstor.loadGroupPref",
+ "loadGroupPref" => array('m'=>"locstor.loadGroupPref",
'p'=>array('sessid', 'group', 'key'), 'r'=>'value'),
- "saveGroupPref" => array('m'=>"locstor.saveGroupPref",
+ "saveGroupPref" => array('m'=>"locstor.saveGroupPref",
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
- "getTransportInfo" => array('m'=>"locstor.getTransportInfo",
+ "getTransportInfo" => array('m'=>"locstor.getTransportInfo",
'p'=>array('trtok'),
'r'=>array('state', 'realsize', 'expectedsize', 'realsum', 'expectedsum')),
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
@@ -207,66 +226,66 @@ $infos = array(
);
-switch($method){
-case"searchMetadata":
-case"globalSearch":
-case"createBackupOpen":
- $parr = array(
- 'sessid'=>$pars[0],
- 'criteria'=>array(
- 'filetype'=>'audioclip',
- 'operator'=>'and',
- 'limit'=> 0,
- 'offset'=> 0,
- 'conditions'=>array(
- array('cat'=>$pars[1], 'op'=>'partial', 'val'=>$pars[2])
- )
- ),
- );
- break;
-case"browseCategory":
- $parr = array(
- 'sessid'=>$pars[0],
- 'category'=>$pars[1],
- 'criteria'=>array(
- 'filetype'=>'audioclip',
- 'operator'=>'and',
- 'limit'=> 0,
- 'offset'=> 0,
- 'conditions'=>array(
- array('cat'=>$pars[2], 'op'=>'partial', 'val'=>$pars[3])
- )
- ),
- );
- break;
-case"resetStorage":
- $parr = array(
- 'loadSampleData'=>(boolean)$pars[0],
- 'invalidateSessionIds'=>(boolean)$pars[1],
- );
- break;
-default:
- $pinfo = $infos[$method]['p'];
- if(is_null($pinfo)){
- $parr = NULL;
- }elseif(!is_array($pinfo)){
- $parr = $pars[0];
- #echo "pinfo not null and not array.\n"; exit;
- }elseif(count($pinfo) == 0){
- $parr = (object)array();
- }else{
- $parr = array(); $i=0;
- foreach($pinfo as $it){
- if(isset($pars[$i])) $parr[$it] = $pars[$i];
- $i++;
+switch ($method) {
+ case "searchMetadata":
+ case "globalSearch":
+ case "createBackupOpen":
+ $parr = array(
+ 'sessid'=>$pars[0],
+ 'criteria'=>array(
+ 'filetype'=>'audioclip',
+ 'operator'=>'and',
+ 'limit'=> 0,
+ 'offset'=> 0,
+ 'conditions'=>array(
+ array('cat'=>$pars[1], 'op'=>'partial', 'val'=>$pars[2])
+ )
+ ),
+ );
+ break;
+ case "browseCategory":
+ $parr = array(
+ 'sessid'=>$pars[0],
+ 'category'=>$pars[1],
+ 'criteria'=>array(
+ 'filetype'=>'audioclip',
+ 'operator'=>'and',
+ 'limit'=> 0,
+ 'offset'=> 0,
+ 'conditions'=>array(
+ array('cat'=>$pars[2], 'op'=>'partial', 'val'=>$pars[3])
+ )
+ ),
+ );
+ break;
+ case "resetStorage":
+ $parr = array(
+ 'loadSampleData'=>(boolean)$pars[0],
+ 'invalidateSessionIds'=>(boolean)$pars[1],
+ );
+ break;
+ default:
+ $pinfo = $infos[$method]['p'];
+ if (is_null($pinfo)) {
+ $parr = NULL;
+ } elseif(!is_array($pinfo)) {
+ $parr = $pars[0];
+ #echo "pinfo not null and not array.\n"; exit;
+ } elseif(count($pinfo) == 0) {
+ $parr = (object)array();
+ } else {
+ $parr = array(); $i=0;
+ foreach($pinfo as $it){
+ if(isset($pars[$i])) $parr[$it] = $pars[$i];
+ $i++;
+ }
}
- }
} // switch
$fullmethod = $infos[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($parr)));
-if($verbose){
+if ($verbose) {
echo "parr:\n";
var_dump($parr);
echo "message:\n";
@@ -275,62 +294,68 @@ if($verbose){
#$client->setDebug(1);
$res = $client->send($msg);
-if($res->faultCode() > 0) {
+if ($res->faultCode() > 0) {
echo "xr_cli_test.php: ".$res->faultString()." ".$res->faultCode()."\n";
# echo var_export($res);
exit(1);
}
-if($verbose){
+if ($verbose) {
echo "result:\n";
echo $res->serialize();
}
$resp = XML_RPC_decode($res->value());
-if(isset($infos[$method]['r'])){
+if (isset($infos[$method]['r'])) {
$pom = $infos[$method]['r'];
- if(is_array($pom)){
- foreach($pom as $k=>$it) $pom[$k] = $resp[$it];
+ if (is_array($pom)) {
+ foreach ($pom as $k => $it) {
+ $pom[$k] = $resp[$it];
+ }
echo join(' ', $pom)."\n";
- }else switch($pom){
- case"status":
- case"exists":
- echo ($resp[$pom]=='1' ? "TRUE" : "FALSE" )."\n";
+ } else {
+ switch ($pom) {
+ case "status":
+ case "exists":
+ echo ($resp[$pom]=='1' ? "TRUE" : "FALSE" )."\n";
+ break;
+ default:
+ echo "{$resp[$pom]}\n";
+ }
+ }
+} else {
+ switch ($method) {
+ case "searchMetadata":
+ case "getSearchResults":
+ $acCnt = 0;
+ $acGunids = array();
+ $plCnt = 0;
+ $plGunids = array();
+ $fld = (isset($options['category']) ? $options['category'] : 'gunid' );
+ foreach ($resp['results'] as $k => $v) {
+ if ($v['type']=='audioclip') {
+ $acCnt++;
+ $acGunids[] = $v[$fld];
+ }
+ if ($v['type']=='playlist') {
+ $plCnt++;
+ $plGunids[] = $v[$fld];
+ }
+ }
+ echo "AC({$acCnt}): ".
+ join(", ", $acGunids).
+ " | PL({$plCnt}): ".
+ join(", ", $plGunids).
+ "\n";
+ break;
+ case "browseCategory":
+ echo "RES({$resp['cnt']}): ".
+ join(", ", $resp['results']).
+ "\n";
break;
default:
- echo "{$resp[$pom]}\n";
- }
-}else{
- switch($method){
- case"searchMetadata":
- case"getSearchResults":
- $acCnt = 0; $acGunids = array();
- $plCnt = 0; $plGunids = array();
- $fld = (isset($options['category']) ? $options['category'] : 'gunid' );
- foreach($resp['results'] as $k=>$v){
- if($v['type']=='audioclip'){ $acCnt++;
- $acGunids[] = $v[$fld];
- }
- if($v['type']=='playlist'){ $plCnt++;
- $plGunids[] = $v[$fld];
- }
- }
- echo
- "AC({$acCnt}): ".
- join(", ", $acGunids).
- " | PL({$plCnt}): ".
- join(", ", $plGunids).
- "\n";
- break;
- case"browseCategory":
- echo
- "RES({$resp['cnt']}): ".
- join(", ", $resp['results']).
- "\n";
- break;
- default:
- print_r($resp);
+ print_r($resp);
}
}
-?>
+?>
\ No newline at end of file