Refactored Alib to reveal its true nature: a bunch of static functions inside of classes. This makes it much easier to understand what is going on, and removes 4 layers of class heirarchies (now only 4 left). There are now two important global variables: CC_DBC, the database connection, and CC_CONFIG, the config variables. These used to be passed around to all classes, but since they are always the same they should be global. Refactored the StorageServer install scripts to live outside of the classes. They now live in the storageServer install scripts. A lot of functions in the StorageServer have become static as well, but there are definitely more that I didnt get to. Lots of code cleanup as well. This is a big update.
This commit is contained in:
parent
2ae9d1ff2e
commit
4733682a62
102 changed files with 4061 additions and 3326 deletions
|
@ -15,11 +15,12 @@
|
|||
* @link http://www.campware.org
|
||||
*/
|
||||
class AccessRecur {
|
||||
public $ls;
|
||||
public $sessid;
|
||||
|
||||
public function __construct(&$ls, $sessid)
|
||||
{
|
||||
$this->ls =& $ls;
|
||||
$this->dbc =& $ls->dbc;
|
||||
$this->sessid = $sessid;
|
||||
}
|
||||
|
||||
|
@ -53,20 +54,21 @@ class AccessRecur {
|
|||
|
||||
public static function releasePlaylist(&$ls, $sessid, $token)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ppa = new AccessRecur($ls, $sessid);
|
||||
$r = $ppa->dbc->getAll("
|
||||
$r = $CC_DBC->getAll("
|
||||
SELECT to_hex(token)as token2, to_hex(gunid)as gunid
|
||||
FROM {$ppa->ls->accessTable}
|
||||
FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE parent=x'{$token}'::bigint
|
||||
");
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$arr = $r;
|
||||
foreach ($arr as $i => $item) {
|
||||
extract($item); // token2, gunid
|
||||
$r = $ppa->ls->_getType($gunid);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
$r = BasicStor::GetType($gunid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$ftype = $r;
|
||||
|
@ -74,14 +76,14 @@ class AccessRecur {
|
|||
switch (strtolower($ftype)) {
|
||||
case "audioclip":
|
||||
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
# var_dump($r);
|
||||
break;
|
||||
case "playlist":
|
||||
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
# var_dump($r);
|
||||
|
@ -90,7 +92,7 @@ class AccessRecur {
|
|||
}
|
||||
}
|
||||
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
|
|
|
@ -106,9 +106,10 @@ class Backup
|
|||
*/
|
||||
public function __construct(&$gb)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$this->gb =& $gb;
|
||||
$this->token = null;
|
||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||
$this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log';
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||
}
|
||||
|
||||
|
@ -190,6 +191,7 @@ class Backup
|
|||
*/
|
||||
public function checkBackup($token)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -201,13 +203,13 @@ class Backup
|
|||
}
|
||||
switch ($status) {
|
||||
case 'success':
|
||||
$r['url'] = $this->gb->getUrlPart()."access/$token.".BACKUP_EXT;
|
||||
$r['tmpfile'] = $this->gb->accessDir."/$token.".BACKUP_EXT;
|
||||
$r['url'] = BasicStor::GetUrlPart()."access/$token.".BACKUP_EXT;
|
||||
$r['tmpfile'] = $CC_CONFIG['accessDir']."/$token.".BACKUP_EXT;
|
||||
case 'working':
|
||||
case 'fault':
|
||||
$r['status'] = $status;
|
||||
$r['status'] = $status;
|
||||
$r['faultString'] = $faultString;
|
||||
$r['token'] = $token;
|
||||
$r['token'] = $token;
|
||||
break;
|
||||
}
|
||||
return $r;
|
||||
|
@ -254,9 +256,9 @@ class Backup
|
|||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." listBackups - stat:$stat\n");
|
||||
}
|
||||
# open temporary dir
|
||||
$tokens = $this->gb->getTokensByType(ACCESS_TYPE);
|
||||
# echo '<XMP>tokens:'; print_r($tokens); echo '</XMP>';
|
||||
// open temporary dir
|
||||
$tokens = BasicStor::GetTokensByType(ACCESS_TYPE);
|
||||
// echo '<XMP>tokens:'; print_r($tokens); echo '</XMP>';
|
||||
foreach ($tokens as $token) {
|
||||
$st = $this->checkBackup($token);
|
||||
if ($stat=='' || $st['status']==$stat) {
|
||||
|
@ -303,8 +305,8 @@ class Backup
|
|||
if (PEAR::isError($sf)) {
|
||||
return $sf;
|
||||
}
|
||||
$lid = $this->gb->idFromGunid($gunid);
|
||||
if (($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||
$lid = BasicStor::IdFromGunid($gunid);
|
||||
if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
|
||||
return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
|
||||
}
|
||||
|
@ -388,17 +390,18 @@ class Backup
|
|||
*/
|
||||
private function setEnviroment($createDir=false)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment - createDirs:$createDir\n");
|
||||
}
|
||||
# create a temporary directories
|
||||
// create temporary directories
|
||||
if (is_null($this->token) && $createDir) {
|
||||
$this->tmpName = tempnam($this->gb->bufferDir, ACCESS_TYPE.'_');
|
||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||
$this->tmpDir = $this->tmpName.'.dir';
|
||||
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
||||
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
||||
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
||||
$this->tmpName = tempnam($CC_CONFIG['bufferDir'], ACCESS_TYPE.'_');
|
||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||
$this->tmpDir = $this->tmpName.'.dir';
|
||||
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
||||
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
||||
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
||||
touch($this->tmpFile);
|
||||
mkdir($this->tmpDir);
|
||||
mkdir($this->tmpDirPlaylist);
|
||||
|
@ -406,7 +409,7 @@ class Backup
|
|||
mkdir($this->tmpDirMeta);
|
||||
$this->genToken();
|
||||
} else {
|
||||
$symlink = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT;
|
||||
$symlink = $CC_CONFIG['accessDir'].'/'.$this->token.'.'.BACKUP_EXT;
|
||||
if (is_link($symlink) && is_file(readlink($symlink))) {
|
||||
$this->tmpName = str_replace('.tar','',readlink($symlink));
|
||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||
|
@ -419,7 +422,7 @@ class Backup
|
|||
return false;
|
||||
}
|
||||
}
|
||||
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT.'.status';
|
||||
$this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.'.BACKUP_EXT.'.status';
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("this->tmpName: $this->tmpName\n");
|
||||
$this->addLogItem("this->tmpFile: $this->tmpFile\n");
|
||||
|
@ -440,7 +443,7 @@ class Backup
|
|||
private function genToken()
|
||||
{
|
||||
$acc = $this->gb->bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
|
||||
if ($this->gb->dbc->isError($acc)) {
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
$this->token = $acc['token'];
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -63,9 +63,6 @@ class DataEngine {
|
|||
public function __construct(&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->mdataTable = $gb->mdataTable;
|
||||
$this->filesTable = $gb->filesTable;
|
||||
$this->filetypes = array(
|
||||
'all'=>NULL,
|
||||
'audioclip'=>'audioclip',
|
||||
|
@ -151,16 +148,17 @@ class DataEngine {
|
|||
private function _makeAndSqlWoIntersect($fldsPart, $whereArr, $fileCond, $browse,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$innerBlocks = array();
|
||||
foreach ($whereArr as $i => $v) {
|
||||
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
||||
$lastTbl = ($i==0 ? "f" : "md".($i-1));
|
||||
$innerBlocks[] = "INNER JOIN {$this->mdataTable} md$i ON md$i.gunid = $lastTbl.gunid\n";
|
||||
$innerBlocks[] = "INNER JOIN ".$CC_CONFIG['mdataTable']." md$i ON md$i.gunid = $lastTbl.gunid\n";
|
||||
}
|
||||
// query construcion:
|
||||
$sql = "SELECT $fldsPart\nFROM {$this->filesTable} f\n".join("", $innerBlocks);
|
||||
$sql = "SELECT $fldsPart FROM ".$CC_CONFIG['filesTable']." f ".join("", $innerBlocks);
|
||||
if ($browse) {
|
||||
$sql .= "INNER JOIN {$this->mdataTable} br".
|
||||
$sql .= "INNER JOIN ".$CC_CONFIG['mdataTable']." br".
|
||||
"\n ON br.gunid = f.gunid AND br.objns='_L'".
|
||||
" AND br.predicate='{$brFld}' AND br.predxml='T'";
|
||||
if (!is_null($brFldNs)) {
|
||||
|
@ -203,6 +201,7 @@ class DataEngine {
|
|||
private function _makeAndSql($fldsPart, $whereArr, $fileCond, $browse,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!USE_INTERSECT) {
|
||||
return $this->_makeAndSqlWoIntersect($fldsPart, $whereArr, $fileCond, $browse, $brFldNs, $brFld);
|
||||
}
|
||||
|
@ -210,20 +209,20 @@ class DataEngine {
|
|||
foreach ($whereArr as $i => $v) {
|
||||
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
||||
$isectBlocks[] =
|
||||
" SELECT gunid FROM {$this->mdataTable} md$i\n".
|
||||
" SELECT gunid FROM ".$CC_CONFIG['mdataTable']." md$i\n".
|
||||
" WHERE\n {$whereArr[$i]}";
|
||||
}
|
||||
// query construcion:
|
||||
if (count($isectBlocks)>0) {
|
||||
$isectBlock =
|
||||
"FROM\n(\n".join("INTERSECT\n", $isectBlocks).") sq\n".
|
||||
"INNER JOIN {$this->filesTable} f ON f.gunid = sq.gunid";
|
||||
"INNER JOIN ".$CC_CONFIG['filesTable']." f ON f.gunid = sq.gunid";
|
||||
} else {
|
||||
$isectBlock = "FROM {$this->filesTable} f";
|
||||
$isectBlock = "FROM ".$CC_CONFIG['filesTable']." f";
|
||||
}
|
||||
$sql = "SELECT $fldsPart\n".$isectBlock;
|
||||
if ($browse) {
|
||||
$sql .= "\nINNER JOIN {$this->mdataTable} br ON br.gunid = f.gunid\n".
|
||||
$sql .= "\nINNER JOIN ".$CC_CONFIG['mdataTable']." br ON br.gunid = f.gunid\n".
|
||||
"WHERE br.objns='_L' AND br.predxml='T' AND br.predicate='{$brFld}'";
|
||||
if (!is_null($brFldNs)) {
|
||||
$sql .= " AND br.predns='{$brFldNs}'";
|
||||
|
@ -262,14 +261,15 @@ class DataEngine {
|
|||
private function _makeOrSql($fldsPart, $whereArr, $fileCond, $browse,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//$whereArr[] = " FALSE\n";
|
||||
foreach ($whereArr as $i => $v) {
|
||||
$whereArr[$i] = sprintf($v, "md", "md", "md", "md", "md");
|
||||
}
|
||||
// query construcion:
|
||||
$sql = "SELECT $fldsPart\nFROM {$this->filesTable} f\n";
|
||||
$sql = "SELECT $fldsPart FROM ".$CC_CONFIG['filesTable']." f ";
|
||||
if ($browse) {
|
||||
$sql .= "INNER JOIN {$this->mdataTable} br".
|
||||
$sql .= "INNER JOIN ".$CC_CONFIG['mdataTable']." br".
|
||||
"\n ON br.gunid = f.gunid AND br.objns='_L'".
|
||||
" AND br.predxml='T' AND br.predicate='{$brFld}'";
|
||||
if (!is_null($brFldNs)) {
|
||||
|
@ -278,7 +278,7 @@ class DataEngine {
|
|||
$sql .= "\n";
|
||||
}
|
||||
if (count($whereArr) > 0) {
|
||||
$sql .= "INNER JOIN {$this->mdataTable} md ON md.gunid=f.gunid\n";
|
||||
$sql .= "INNER JOIN ".$CC_CONFIG['mdataTable']." md ON md.gunid=f.gunid\n";
|
||||
$sql .= "WHERE\n(\n".join(" OR\n", $whereArr).")";
|
||||
$glue = " AND";
|
||||
} else {
|
||||
|
@ -347,6 +347,7 @@ class DataEngine {
|
|||
private function _localGenSearch($criteria, $limit=0, $offset=0,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$filetype = (isset($criteria['filetype']) ? $criteria['filetype'] : 'all');
|
||||
$filetype = strtolower($filetype);
|
||||
if (!array_key_exists($filetype, $this->filetypes)) {
|
||||
|
@ -384,7 +385,7 @@ class DataEngine {
|
|||
$desc = (isset($descA[$j]) ? $descA[$j] : NULL);
|
||||
$retype = ($obLp == 'mtime' ? '::timestamp with time zone' : '' );
|
||||
$orderJoinSql[] =
|
||||
"LEFT JOIN {$this->mdataTable} m$i\n".
|
||||
"LEFT JOIN ".$CC_CONFIG['mdataTable']." m$i\n".
|
||||
" ON m$i.gunid = sq2.gunid AND m$i.predicate='$obLp'".
|
||||
" AND m$i.objns='_L' AND m$i.predxml='T'".
|
||||
(!is_null($obNs)? " AND m$i.predns='$obNs'":'');
|
||||
|
@ -423,7 +424,7 @@ class DataEngine {
|
|||
if (PEAR::isError($cnt)) {
|
||||
return $cnt;
|
||||
}
|
||||
$res = $this->dbc->getAll($sql.$limitPart);
|
||||
$res = $CC_DBC->getAll($sql.$limitPart);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -435,7 +436,7 @@ class DataEngine {
|
|||
//$categoryNames = array('dc:title', 'dc:creator', 'dc:source', 'dcterms:extent');
|
||||
foreach ($res as $it) {
|
||||
if (!$browse) {
|
||||
$gunid = StoredFile::_normalizeGunid($it['gunid']);
|
||||
$gunid = StoredFile::NormalizeGunid($it['gunid']);
|
||||
//$values = $this->gb->bsGetMetadataValue($it['id'], $categoryNames);
|
||||
$values = $this->gb->bsGetMetadataValue($it['id']);
|
||||
$eres[] = array(
|
||||
|
@ -473,6 +474,7 @@ class DataEngine {
|
|||
*/
|
||||
public function browseCategory($category, $limit=0, $offset=0, $criteria=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//$category = strtolower($category);
|
||||
$r = XML_Util::splitQualifiedName($category);
|
||||
$catNs = $r['namespace'];
|
||||
|
@ -487,14 +489,14 @@ class DataEngine {
|
|||
$limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
|
||||
($offset != 0 ? " OFFSET $offset" : '' );
|
||||
$sql =
|
||||
"SELECT DISTINCT m.object FROM {$this->mdataTable} m\n".
|
||||
"SELECT DISTINCT m.object FROM ".$CC_CONFIG['mdataTable']." m\n".
|
||||
"WHERE $sqlCond";
|
||||
// echo "\n---\n$sql\n---\n";
|
||||
$cnt = $this->_getNumRows($sql);
|
||||
if (PEAR::isError($cnt)) {
|
||||
return $cnt;
|
||||
}
|
||||
$res = $this->dbc->getCol($sql.$limitPart);
|
||||
$res = $CC_DBC->getCol($sql.$limitPart);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -515,7 +517,8 @@ class DataEngine {
|
|||
*/
|
||||
private function _getNumRows($query)
|
||||
{
|
||||
$rh = $this->dbc->query($query);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$rh = $CC_DBC->query($query);
|
||||
if (PEAR::isError($rh)) {
|
||||
return $rh;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function createFolder($parid, $folderName, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsCreateFolder($parid, $folderName);
|
||||
|
@ -66,7 +66,7 @@ class GreenBox extends BasicStor {
|
|||
$mediaFileLP, $mdataFileLP, $sessid='',
|
||||
$gunid=NULL, $ftype='audioclip')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsPutFile(
|
||||
|
@ -96,7 +96,7 @@ class GreenBox extends BasicStor {
|
|||
public function storeWebstream($parid, $fileName, $mdataFileLP, $sessid='',
|
||||
$gunid=NULL, $url)
|
||||
{
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
if (!file_exists($mdataFileLP)) {
|
||||
|
@ -128,10 +128,10 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
// function accessFile($id, $sessid='')
|
||||
// {
|
||||
// if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// $gunid = $this->gunidFromId($id);
|
||||
// $gunid = BasicStor::GunidFromId($id);
|
||||
// $r = $this->bsAccess(NULL, '', $gunid, 'access');
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
|
@ -171,7 +171,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function analyzeFile($id, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsAnalyzeFile($id);
|
||||
|
@ -190,8 +190,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function renameFile($id, $newName, $sessid='')
|
||||
{
|
||||
$parid = $this->getParent($id);
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($id);
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsRenameFile($id, $newName);
|
||||
|
@ -211,7 +211,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function moveFile($id, $did, $sessid='')
|
||||
{
|
||||
$res = $this->_authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
$res = BasicStor::Authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
if ($res !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function copyFile($id, $did, $sessid='')
|
||||
{
|
||||
$res = $this->_authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
$res = BasicStor::Authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
if($res !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsReplaceFile($id, $mediaFileLP, $mdataFileLP);
|
||||
|
@ -274,8 +274,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function deleteFile($id, $sessid='', $forced=FALSE)
|
||||
{
|
||||
$parid = $this->getParent($id);
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($id);
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsDeleteFile($id, $forced);
|
||||
|
@ -299,7 +299,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function replaceMetadata($id, $mdata, $mdataLoc='file', $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsReplaceMetadata($id, $mdata, $mdataLoc);
|
||||
|
@ -318,7 +318,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function getMdata($id, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsGetMetadata($id);
|
||||
|
@ -341,7 +341,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function getMdataArray($id, $sessid)
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
|
@ -399,7 +399,7 @@ class GreenBox extends BasicStor {
|
|||
public function getMetadataValue($id, $category, $sessid='',
|
||||
$lang=NULL, $deflang=NULL)
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsGetMetadataValue($id, $category);
|
||||
|
@ -425,7 +425,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function setMetadataValue($id, $category, $sessid, $value, $lang=NULL, $mid=NULL)
|
||||
{
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsSetMetadataValue($id, $category, $value, $lang, $mid);
|
||||
|
@ -535,14 +535,15 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function createPlaylist($parid, $fname, $sessid='')
|
||||
{
|
||||
$gunid = StoredFile::_createGunid();
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = StoredFile::CreateGunid();
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
$gunid2 = $lc->createPlaylist($sessid, $gunid, $fname);
|
||||
if (PEAR::isError($gunid2)) {
|
||||
return $gunid2;
|
||||
}
|
||||
// get local id:
|
||||
$id = $this->idFromGunid($gunid2);
|
||||
$id = BasicStor::IdFromGunid($gunid2);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -589,7 +590,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function getPlaylistArray($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$pl = StoredFile::recall($this, $id);
|
||||
if (PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
|
@ -611,8 +612,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function lockPlaylistForEdit($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
$res = $lc->editPlaylist($sessid, $gunid);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -644,7 +646,7 @@ class GreenBox extends BasicStor {
|
|||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->_setEditFlag($gunid, FALSE, $sessid);
|
||||
$this->setEditFlag($gunid, FALSE, $sessid);
|
||||
return $gunid;
|
||||
} // fn releaseLockedPlaylist
|
||||
|
||||
|
@ -677,7 +679,7 @@ class GreenBox extends BasicStor {
|
|||
if (PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
}
|
||||
$acGunid = $this->gunidFromId($acId);
|
||||
$acGunid = BasicStor::GunidFromId($acId);
|
||||
if ($pl->cyclicRecursion($acGunid)){
|
||||
return PEAR::raiseError(
|
||||
"GreenBox::addAudioClipToPlaylist: cyclic-recursion detected".
|
||||
|
@ -814,7 +816,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function revertEditedPlaylist($token, $sessid='')
|
||||
{
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->revertEditedPlaylist($token, $sessid);
|
||||
} // fn revertEditedPlaylist
|
||||
|
||||
|
@ -830,8 +833,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function deletePlaylist($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->deletePlaylist($sessid, $gunid);
|
||||
} // fn deletePlaylist
|
||||
|
||||
|
@ -872,7 +876,7 @@ class GreenBox extends BasicStor {
|
|||
return $res;
|
||||
}
|
||||
$res['title'] = NULL;
|
||||
$id = $this->idFromGunid($res['gunid']);
|
||||
$id = BasicStor::IdFromGunid($res['gunid']);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -934,8 +938,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function importPlaylistOpen($sessid, $chsum='')
|
||||
{
|
||||
$userid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($userid)) {
|
||||
$userid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($userid)) {
|
||||
return $userid;
|
||||
}
|
||||
$r = $this->bsOpenPut($chsum, NULL, $userid);
|
||||
|
@ -988,8 +992,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function existsPlaylist($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->existsPlaylist($sessid, $gunid);
|
||||
} // fn existsPlaylist
|
||||
|
||||
|
@ -1008,8 +1013,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function playlistIsAvailable($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->playlistIsAvailable($sessid, $gunid, TRUE);
|
||||
} // fn playlistIsAvailable
|
||||
|
||||
|
@ -1136,8 +1142,8 @@ class GreenBox extends BasicStor {
|
|||
public function renderPlaylistToStorageOpen($sessid, $plid)
|
||||
{
|
||||
require_once("Renderer.php");
|
||||
$owner = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($owner)) {
|
||||
$owner = GreenBox::getSessUserId($sessid);
|
||||
if (PEAR::isError($owner)) {
|
||||
return $owner;
|
||||
}
|
||||
$r = Renderer::rnRender2FileOpen($this, $plid, $owner);
|
||||
|
@ -1181,7 +1187,7 @@ class GreenBox extends BasicStor {
|
|||
public function renderPlaylistToRSSOpen($sessid, $plid)
|
||||
{
|
||||
$token = '123456789abcdeff';
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
file_put_contents($fakeFile, "fake rendered file");
|
||||
return array('token'=>$token);
|
||||
} // fn renderPlaylistToRSSOpen
|
||||
|
@ -1198,7 +1204,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function renderPlaylistToRSSCheck($token)
|
||||
{
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
if ($token != '123456789abcdeff' || !file_exists($fakeFile)){
|
||||
return PEAR::raiseError(
|
||||
"LocStor::renderPlaylistToRSSCheck: invalid token ($token)"
|
||||
|
@ -1245,7 +1251,7 @@ class GreenBox extends BasicStor {
|
|||
"GreenBox::renderPlaylistToRSSClose: invalid token"
|
||||
);
|
||||
}
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
unlink($fakeFile);
|
||||
return TRUE;
|
||||
} // fn renderPlaylistToRSSClose
|
||||
|
@ -1663,8 +1669,8 @@ class GreenBox extends BasicStor {
|
|||
* transport token
|
||||
*/
|
||||
public function downloadFromHub($sessid, $gunid, $withContent=TRUE){
|
||||
$uid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($uid)) {
|
||||
$uid = GreenBox::getSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
require_once("Transport.php");
|
||||
|
@ -1720,7 +1726,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function listFolder($id, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$listArr = $this->bsListFolder($id);
|
||||
|
@ -1733,12 +1739,11 @@ class GreenBox extends BasicStor {
|
|||
*
|
||||
* @param int $id
|
||||
* local id
|
||||
* @return string/err
|
||||
* @return string|PEAR_Error
|
||||
*/
|
||||
public function getFileType($id)
|
||||
public static function getFileType($id)
|
||||
{
|
||||
// $id = $this->idFromGunid($gunid);
|
||||
$type = $this->getObjType($id);
|
||||
$type = BasicStor::GetObjType($id);
|
||||
return $type;
|
||||
} // fn getFileType
|
||||
|
||||
|
@ -1756,9 +1761,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ex;
|
||||
|
@ -1772,9 +1777,9 @@ class GreenBox extends BasicStor {
|
|||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function getPath($id)
|
||||
public static function GetPath($id)
|
||||
{
|
||||
$pa = parent::getPath($id, 'id, name, type');
|
||||
$pa = M2tree::GetPath($id, 'id, name, type');
|
||||
array_shift($pa);
|
||||
return $pa;
|
||||
} // fn getPath
|
||||
|
@ -1788,11 +1793,11 @@ class GreenBox extends BasicStor {
|
|||
* HtmlUI depends on it.
|
||||
*
|
||||
* @param string $sessid
|
||||
* @return int|PEAR_Error
|
||||
* @return int|null|PEAR_Error
|
||||
*/
|
||||
public function getSessUserId($sessid)
|
||||
public static function GetSessUserId($sessid)
|
||||
{
|
||||
$r = parent::getSessUserId($sessid);
|
||||
$r = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
if ($r->getCode() == ALIBERR_NOTEXISTS) {
|
||||
return NULL;
|
||||
|
@ -1822,14 +1827,14 @@ class GreenBox extends BasicStor {
|
|||
public function passwd($login, $oldpass=null, $pass='', $sessid='')
|
||||
{
|
||||
if (is_null($oldpass) || ($oldpass == '') ) {
|
||||
if (($res = $this->_authorize('subjects', $this->rootId, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('subjects', $this->rootId, $sessid)) !== TRUE) {
|
||||
sleep(2);
|
||||
return $res;
|
||||
} else {
|
||||
$oldpass = null;
|
||||
}
|
||||
} else {
|
||||
if (FALSE === $this->authenticate($login, $oldpass)) {
|
||||
if (FALSE === Subjects::Authenticate($login, $oldpass)) {
|
||||
sleep(2);
|
||||
return PEAR::raiseError(
|
||||
"GreenBox::passwd: access denied (oldpass)", GBERR_DENY);
|
||||
|
@ -1860,8 +1865,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function addPerm($sid, $action, $oid, $type='A', $sessid='')
|
||||
{
|
||||
$parid = $this->getParent($oid);
|
||||
if (($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($oid);
|
||||
if (($res = BasicStor::Authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return parent::addPerm($sid, $action, $oid, $type);
|
||||
|
@ -1884,18 +1889,18 @@ class GreenBox extends BasicStor {
|
|||
public function removePerm($permid=NULL, $subj=NULL, $obj=NULL, $sessid='')
|
||||
{
|
||||
if (!is_null($permid)) {
|
||||
$oid = $this->_getPermOid($permid);
|
||||
$oid = Alib::GetPermOid($permid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
if (!is_null($oid)) {
|
||||
$parid = $this->getParent($oid);
|
||||
if (($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($oid);
|
||||
if (($res = BasicStor::Authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = parent::removePerm($permid, $subj, $obj);
|
||||
$res = Alib::RemovePerm($permid, $subj, $obj);
|
||||
return $res;
|
||||
} // fn removePerm
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class LocStor extends BasicStor {
|
|||
)
|
||||
{
|
||||
// test of gunid format:
|
||||
if (!$this->_checkGunid($gunid)) {
|
||||
if (!BasicStor::CheckGunid($gunid)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::storeAudioClipOpen: Wrong gunid ($gunid)"
|
||||
);
|
||||
|
@ -53,7 +53,7 @@ class LocStor extends BasicStor {
|
|||
if (!PEAR::isError($ac)) {
|
||||
// gunid exists - do replace
|
||||
$oid = $ac->getId();
|
||||
if (($res = $this->_authorize('write', $oid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $oid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
if ($ac->isAccessed()) {
|
||||
|
@ -74,10 +74,10 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$oid = $this->addObj($tmpFname, $ftype, $parid);
|
||||
$oid = BasicStor::AddObj($tmpFname, $ftype, $parid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ac->accessRawMediaData($parent);
|
||||
|
@ -258,14 +258,14 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ex)) {
|
||||
return $ex;
|
||||
}
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id) || !$ex) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
|
||||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsOpenDownload($id);
|
||||
|
@ -301,13 +301,13 @@ class LocStor extends BasicStor {
|
|||
{
|
||||
// $res = $this->existsAudioClip($sessid, $gunid);
|
||||
// if(PEAR::isError($res)) return $res;
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadMetadataOpen: gunid not found ($gunid)"
|
||||
);
|
||||
}
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
|
@ -343,7 +343,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$md = $this->bsGetMetadata($ac->getId());
|
||||
|
@ -411,7 +411,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function searchMetadata($sessid, $criteria)
|
||||
{
|
||||
if (($res = $this->_authorize('read', $this->storId, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $this->storId, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$criteria['resultMode'] = 'xmlrpc';
|
||||
|
@ -498,11 +498,11 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
|
@ -528,7 +528,7 @@ class LocStor extends BasicStor {
|
|||
}
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsDeleteFile($ac->getId(), $forced);
|
||||
|
@ -554,7 +554,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ac->replaceMetaData($metadata, 'string');
|
||||
|
@ -590,10 +590,10 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$oid = $this->addObj($tmpFname , 'playlist', $parid);
|
||||
$oid = BasicStor::AddObj($tmpFname , 'playlist', $parid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
|
@ -656,14 +656,14 @@ class LocStor extends BasicStor {
|
|||
return $ac;
|
||||
}
|
||||
$id = $ac->getId();
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$r = $this->_setEditFlag($playlistId, TRUE, $sessid);
|
||||
$r = $this->setEditFlag($playlistId, TRUE, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$r = $this->_setEditFlag($playlistId, FALSE, $sessid);
|
||||
$r = $this->setEditFlag($playlistId, FALSE, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$this->_setEditFlag($gunid, FALSE, $sessid);
|
||||
$this->setEditFlag($gunid, FALSE, $sessid);
|
||||
return $gunid;
|
||||
}
|
||||
|
||||
|
@ -770,7 +770,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsDeleteFile($ac->getId(), $forced);
|
||||
|
@ -820,8 +820,8 @@ class LocStor extends BasicStor {
|
|||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
$id = $this->idFromGunid($playlistId);
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
$id = BasicStor::IdFromGunid($playlistId);
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata', $parent);
|
||||
|
@ -876,10 +876,10 @@ class LocStor extends BasicStor {
|
|||
protected function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE)
|
||||
{
|
||||
$res = $this->bsExportPlaylistOpen($plids, $type, !$standalone);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$url = $this->getUrlPart()."access/".basename($res['fname']);
|
||||
$url = BasicStor::GetUrlPart()."access/".basename($res['fname']);
|
||||
$chsum = md5_file($res['fname']);
|
||||
$size = filesize($res['fname']);
|
||||
return array(
|
||||
|
@ -916,8 +916,8 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function importPlaylistOpen($sessid, $chsum)
|
||||
{
|
||||
$userid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($userid)) {
|
||||
$userid = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($userid)) {
|
||||
return $userid;
|
||||
}
|
||||
$r = $this->bsOpenPut($chsum, NULL, $userid);
|
||||
|
@ -958,7 +958,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return $this->gunidFromId($res);
|
||||
return BasicStor::GunidFromId($res);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToFileCheck($token)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
require_once("Renderer.php");
|
||||
$r = Renderer::rnRender2FileCheck($this, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -1063,7 +1063,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToFileClose($token)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
require_once("Renderer.php");
|
||||
$r = Renderer::rnRender2FileClose($this, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -1084,9 +1084,9 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToStorageOpen($sessid, $plid)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
$owner = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($owner)) {
|
||||
require_once("Renderer.php");
|
||||
$owner = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($owner)) {
|
||||
return $owner;
|
||||
}
|
||||
$r = Renderer::rnRender2FileOpen($this, $plid, $owner);
|
||||
|
@ -1108,7 +1108,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToStorageCheck($token)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
require_once("Renderer.php");
|
||||
$r = Renderer::rnRender2StorageCheck($this, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -1129,8 +1129,9 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToRSSOpen($sessid, $plid)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$token = '123456789abcdeff';
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
file_put_contents($fakeFile, "fake rendered file");
|
||||
return array('token'=>$token);
|
||||
}
|
||||
|
@ -1147,13 +1148,13 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToRSSCheck($token)
|
||||
{
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
if ($token != '123456789abcdeff' || !file_exists($fakeFile)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::renderPlaylistToRSSCheck: invalid token ($token)"
|
||||
);
|
||||
}
|
||||
$fakeFUrl = $this->getUrlPart()."access/$token.rss";
|
||||
$fakeFUrl = BasicStor::GetUrlPart()."access/$token.rss";
|
||||
return array(
|
||||
'status'=> 'success',
|
||||
'url' => $fakeFUrl,
|
||||
|
@ -1176,7 +1177,7 @@ class LocStor extends BasicStor {
|
|||
"LocStor::renderPlaylistToRSSClose: invalid token"
|
||||
);
|
||||
}
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
unlink($fakeFile);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1296,8 +1297,8 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function restoreBackupOpen($sessid, $chsum)
|
||||
{
|
||||
$userid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($userid)) {
|
||||
$userid = Alib::getSessUserId($sessid);
|
||||
if (PEAR::isError($userid)) {
|
||||
return $userid;
|
||||
}
|
||||
$r = $this->bsOpenPut($chsum, NULL, $userid);
|
||||
|
|
|
@ -101,9 +101,9 @@ class M3uPlaylist {
|
|||
foreach ($arr as $i => $it) {
|
||||
list($md, $uri) = preg_split("|\n|", $it);
|
||||
list($length, $title) = preg_split("|, *|", $md);
|
||||
// $gunid = StoredFile::_createGunid();
|
||||
// $gunid = StoredFile::CreateGunid();
|
||||
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
|
||||
$acId = $gb->idFromGunid($gunid);
|
||||
$acId = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($acId)) {
|
||||
return $acId;
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ class M3uPlaylist {
|
|||
foreach ($arr as $i => $it) {
|
||||
list($md, $uri) = preg_split("|\n|", $it);
|
||||
list($length, $title) = preg_split("|, *|", $md);
|
||||
$gunid = StoredFile::_createGunid();
|
||||
$gunid2 = StoredFile::_createGunid();
|
||||
$gunid = StoredFile::CreateGunid();
|
||||
$gunid2 = StoredFile::CreateGunid();
|
||||
$length = Playlist::secondsToPlaylistTime($length);
|
||||
$offset = '???';
|
||||
$uri_h = preg_replace("|--|", "d;d;", htmlspecialchars("$uri"));
|
||||
|
@ -225,7 +225,7 @@ class M3uPlaylistBodyElement {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$gunid = StoredFile::_createGunid();
|
||||
$gunid = StoredFile::CreateGunid();
|
||||
$playlength = '???'; // ***
|
||||
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
|
||||
"$ind<playlist id=\"$gunid\" playlength=\"$playlength\" title=\"\">\n".
|
||||
|
@ -313,8 +313,8 @@ class M3uPlaylistAudioElement {
|
|||
} else {
|
||||
$fInfo = '';
|
||||
}
|
||||
$plElGunid = StoredFile::_createGunid();
|
||||
$aGunid = StoredFile::_createGunid();
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
$aGunid = StoredFile::CreateGunid();
|
||||
$title = basename($tree->attrs['src']->val);
|
||||
$offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val);
|
||||
$playlength = '???'; # ***
|
||||
|
|
|
@ -23,9 +23,6 @@ require_once "XML/Util.php";
|
|||
*/
|
||||
class MetaData {
|
||||
|
||||
public $config;
|
||||
public $dbc;
|
||||
public $mdataTable;
|
||||
public $gunid;
|
||||
public $resDir;
|
||||
public $fname;
|
||||
|
@ -41,9 +38,6 @@ class MetaData {
|
|||
*/
|
||||
public function __construct(&$gb, $gunid, $resDir)
|
||||
{
|
||||
$this->config =& $gb->config;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->mdataTable = $gb->mdataTable;
|
||||
$this->gunid = $gunid;
|
||||
$this->resDir = $resDir;
|
||||
$this->fname = $this->makeFname();
|
||||
|
@ -139,11 +133,12 @@ class MetaData {
|
|||
*/
|
||||
public function delete()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (file_exists($this->fname)) {
|
||||
@unlink($this->fname);
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->mdataTable}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -177,10 +172,11 @@ class MetaData {
|
|||
*/
|
||||
public function getAllMetadata()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT predns, predicate, object
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint";
|
||||
$rows = $this->dbc->getAll($sql);
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$values = array();
|
||||
foreach ($rows as $row) {
|
||||
$values[$row["predns"].":".$row["predicate"]] = $row["object"];
|
||||
|
@ -202,6 +198,7 @@ class MetaData {
|
|||
*/
|
||||
public function getMetadataEl($category, $parid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// handle predicate namespace shortcut
|
||||
$a = XML_Util::splitQualifiedName($category);
|
||||
if (PEAR::isError($a)) {
|
||||
|
@ -217,10 +214,10 @@ class MetaData {
|
|||
$cond .= " AND subjns='_I' AND subject='$parid'";
|
||||
}
|
||||
$sql = "SELECT id as mid, object as value
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE $cond
|
||||
ORDER BY id";
|
||||
$all = $this->dbc->getAll($sql);
|
||||
$all = $CC_DBC->getAll($sql);
|
||||
foreach ($all as $i => $v) {
|
||||
if (is_null($all[$i]['value'])) {
|
||||
$all[$i]['value'] = '';
|
||||
|
@ -244,11 +241,12 @@ class MetaData {
|
|||
*/
|
||||
public function setMetadataEl($mid, $value=NULL)
|
||||
{
|
||||
$info = $this->dbc->getRow("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$info = $CC_DBC->getRow("
|
||||
SELECT parmd.predns as parns, parmd.predicate as parname,
|
||||
md.predxml, md.predns as chns, md.predicate as chname
|
||||
FROM {$this->mdataTable} parmd
|
||||
INNER JOIN {$this->mdataTable} md
|
||||
FROM ".$CC_CONFIG['mdataTable']." parmd
|
||||
INNER JOIN ".$CC_CONFIG['mdataTable']." md
|
||||
ON parmd.id=md.subject AND md.subjns='_I'
|
||||
WHERE md.id=$mid
|
||||
");
|
||||
|
@ -270,11 +268,11 @@ class MetaData {
|
|||
if (!is_null($value)) {
|
||||
$escapedValue = pg_escape_string($value);
|
||||
$sql = "
|
||||
UPDATE {$this->mdataTable}
|
||||
UPDATE ".$CC_CONFIG['mdataTable']."
|
||||
SET object='$escapedValue', objns='_L'
|
||||
WHERE id={$mid}
|
||||
";
|
||||
$res = $this->dbc->query($sql);
|
||||
$res = $CC_DBC->query($sql);
|
||||
} else {
|
||||
$res = $this->deleteRecord($mid);
|
||||
}
|
||||
|
@ -301,9 +299,10 @@ class MetaData {
|
|||
*/
|
||||
public function insertMetadataEl($parid, $category, $value=NULL, $predxml='T')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//$category = strtolower($category);
|
||||
$parent = $this->dbc->getRow("
|
||||
SELECT predns, predicate, predxml FROM {$this->mdataTable}
|
||||
$parent = $CC_DBC->getRow("
|
||||
SELECT predns, predicate, predxml FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint AND id=$parid
|
||||
");
|
||||
if (PEAR::isError($parent)) {
|
||||
|
@ -526,7 +525,9 @@ class MetaData {
|
|||
$atime = trim(`date +%Y-%m-%dT%H:%M:%S`).$tz;
|
||||
}
|
||||
$r = $this->setMetadataValue('ls:mtime', $atime);
|
||||
if(PEAR::isError($r)) return $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$fn = $this->fname;
|
||||
$xml = $this->genXMLDoc();
|
||||
if (PEAR::isError($xml)) {
|
||||
|
@ -589,9 +590,10 @@ class MetaData {
|
|||
*/
|
||||
private function dbCheck($gunid)
|
||||
{
|
||||
$cnt = $this->dbc->getOne("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$cnt = $CC_DBC->getOne("
|
||||
SELECT count(*)as cnt
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
if (PEAR::isError($cnt)) {
|
||||
|
@ -628,7 +630,8 @@ class MetaData {
|
|||
*/
|
||||
private function validate(&$tree)
|
||||
{
|
||||
if ($this->config['validate'] && !is_null($this->format)) {
|
||||
global $CC_CONFIG;
|
||||
if ($CC_CONFIG['validate'] && !is_null($this->format)) {
|
||||
require_once("Validator.php");
|
||||
$val = new Validator($this->format, $this->gunid);
|
||||
if (PEAR::isError($val)) {
|
||||
|
@ -658,7 +661,8 @@ class MetaData {
|
|||
*/
|
||||
private function validateOneValue($parName, $category, $predxml, $value)
|
||||
{
|
||||
if ($this->config['validate'] && !is_null($this->format)) {
|
||||
global $CC_CONFIG;
|
||||
if ($CC_CONFIG['validate'] && !is_null($this->format)) {
|
||||
require_once("Validator.php");
|
||||
$val = new Validator($this->format, $this->gunid);
|
||||
if (PEAR::isError($val)) {
|
||||
|
@ -682,15 +686,16 @@ class MetaData {
|
|||
*/
|
||||
private function storeDoc(&$tree)
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->storeNode($tree);
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -759,7 +764,7 @@ class MetaData {
|
|||
// {
|
||||
// $object_sql = is_null($object) ? "NULL" : "'".pg_escape_string($object)."'";
|
||||
// $objns_sql = is_null($objns) ? "NULL" : "'".pg_escape_string($objns)."'";
|
||||
// $res = $this->dbc->query("UPDATE {$this->mdataTable}
|
||||
// $res = $CC_DBC->query("UPDATE {$this->mdataTable}
|
||||
// SET objns = $objns_sql, object = $object_sql
|
||||
// WHERE gunid = x'{$this->gunid}'::bigint AND id='$mdid'
|
||||
// ");
|
||||
|
@ -796,6 +801,7 @@ class MetaData {
|
|||
private function storeRecord($subjns, $subject, $predns, $predicate, $predxml='T',
|
||||
$objns=NULL, $object=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//echo "$subjns, $subject, $predns, $predicate, $predxml, $objns, $object\n";
|
||||
//$predns = strtolower($predns);
|
||||
//$predicate = strtolower($predicate);
|
||||
|
@ -805,12 +811,12 @@ class MetaData {
|
|||
$predicate_sql = is_null($predicate) ? "NULL" : "'".pg_escape_string($predicate)."'";
|
||||
$objns_sql = is_null($objns) ? "NULL" : "'".pg_escape_string($objns)."'";
|
||||
$object_sql = is_null($object) ? "NULL" : "'".pg_escape_string($object)."'";
|
||||
$id = $this->dbc->nextId("{$this->mdataTable}_id_seq");
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['mdataTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
INSERT INTO {$this->mdataTable}
|
||||
$res = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['mdataTable']."
|
||||
(id , gunid, subjns, subject,
|
||||
predns, predicate, predxml,
|
||||
objns, object
|
||||
|
@ -837,10 +843,11 @@ class MetaData {
|
|||
*/
|
||||
private function deleteRecord($mid)
|
||||
{
|
||||
$sql = "SELECT id FROM {$this->mdataTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE subjns='_I' AND subject='{$mid}' AND
|
||||
gunid=x'{$this->gunid}'::bigint";
|
||||
$rh = $this->dbc->query($sql);
|
||||
$rh = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($rh)) {
|
||||
return $rh;
|
||||
}
|
||||
|
@ -851,10 +858,10 @@ class MetaData {
|
|||
}
|
||||
}
|
||||
$rh->free();
|
||||
$sql = "DELETE FROM {$this->mdataTable}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE id={$mid} AND
|
||||
gunid=x'{$this->gunid}'::bigint";
|
||||
$res = $this->dbc->query($sql);
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -871,9 +878,10 @@ class MetaData {
|
|||
*/
|
||||
public function genPhpArray()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$res = array();
|
||||
$row = $this->dbc->getRow("
|
||||
SELECT * FROM {$this->mdataTable}
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT * FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
AND subjns='_G' AND subject='{$this->gunid}'
|
||||
");
|
||||
|
@ -899,10 +907,11 @@ class MetaData {
|
|||
*/
|
||||
public function genXMLDoc()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
require_once("XML/Util.php");
|
||||
$res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n";
|
||||
$row = $this->dbc->getRow("
|
||||
SELECT * FROM {$this->mdataTable}
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT * FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
AND subjns='_G' AND subject='{$this->gunid}'
|
||||
");
|
||||
|
@ -939,7 +948,7 @@ class MetaData {
|
|||
private function genXMLNode($row, $genXML=TRUE)
|
||||
{
|
||||
if (DEBUG) {
|
||||
echo"genXMLNode:\n";
|
||||
echo "genXMLNode:\n";
|
||||
}
|
||||
if (DEBUG) {
|
||||
var_dump($row);
|
||||
|
@ -990,13 +999,14 @@ class MetaData {
|
|||
*/
|
||||
private function getSubrows($parid, $genXML=TRUE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (DEBUG) {
|
||||
echo" getSubrows:\n";
|
||||
}
|
||||
$qh = $this->dbc->query($q = "
|
||||
$qh = $CC_DBC->query($q = "
|
||||
SELECT
|
||||
id, predxml, predns, predicate, objns, object
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE
|
||||
subjns='_I' AND subject='$parid' AND
|
||||
gunid=x'{$this->gunid}'::bigint
|
||||
|
|
|
@ -102,7 +102,7 @@ class Playlist extends StoredFile {
|
|||
public function &create(&$gb, $plid, $fname=NULL, $parid=NULL)
|
||||
{
|
||||
$tmpFname = uniqid('');
|
||||
$oid = $gb->addObj($tmpFname , 'playlist', $parid);
|
||||
$oid = BasicStor::AddObj($tmpFname , 'playlist', $parid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class Playlist extends StoredFile {
|
|||
'Playlist::lock: playlist already locked'
|
||||
);
|
||||
}
|
||||
$r = $gb->_setEditFlag($this->gunid, $val, NULL, $subjid);
|
||||
$r = $gb->setEditFlag($this->gunid, $val, NULL, $subjid);
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ class Playlist extends StoredFile {
|
|||
} else {
|
||||
$acTit = $acGunid;
|
||||
}
|
||||
$elType = $this->gb->getObjType($acId);
|
||||
$elType = BasicStor::GetObjType($acId);
|
||||
$trTbl = array('audioclip'=>'audioClip', 'webstream'=>'audioClip',
|
||||
'playlist'=>'playlist');
|
||||
$elType = $trTbl[$elType];
|
||||
|
@ -381,7 +381,7 @@ class Playlist extends StoredFile {
|
|||
$plElId = $r;
|
||||
// create and insert gunid (id attribute)
|
||||
if (is_null($plElGunid)) {
|
||||
$plElGunid = StoredFile::_createGunid();
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
}
|
||||
$r = $this->md->insertMetadataEl($plElId, 'id', $plElGunid, 'A');
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -420,7 +420,7 @@ class Playlist extends StoredFile {
|
|||
return $r;
|
||||
}
|
||||
$fiId = $r;
|
||||
$fiGunid = StoredFile::_createGunid();
|
||||
$fiGunid = StoredFile::CreateGunid();
|
||||
$r = $this->md->insertMetadataEl($fiId, 'id', $fiGunid, 'A');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -687,7 +687,7 @@ class Playlist extends StoredFile {
|
|||
if (PEAR::isError($fiMid)) {
|
||||
return $fiMid;
|
||||
}
|
||||
$fiGunid = StoredFile::_createGunid();
|
||||
$fiGunid = StoredFile::CreateGunid();
|
||||
$r = $this->_getMidOrInsert('id', $fiMid, $fiGunid, 'A');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -773,7 +773,7 @@ class Playlist extends StoredFile {
|
|||
);
|
||||
}
|
||||
}
|
||||
$acId = $this->gb->idFromGunid($acGunid);
|
||||
$acId = BasicStor::IdFromGunid($acGunid);
|
||||
if (PEAR::isError($acId)) {
|
||||
return $acId;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
/* ================== Prefs ================== */
|
||||
class Prefs {
|
||||
|
||||
public $gb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -25,8 +27,6 @@ class Prefs {
|
|||
public function __construct(&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->prefTable = $gb->config['tblNamePrefix'].'pref';
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Prefs {
|
|||
*/
|
||||
function loadPref($sessid, $key)
|
||||
{
|
||||
$subjid = $this->gb->getSessUserId($sessid);
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class Prefs {
|
|||
*/
|
||||
function savePref($sessid, $key, $value)
|
||||
{
|
||||
$subjid = $this->gb->getSessUserId($sessid);
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class Prefs {
|
|||
*/
|
||||
function delPref($sessid, $key)
|
||||
{
|
||||
$subjid = $this->gb->getSessUserId($sessid);
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class Prefs {
|
|||
function loadGroupPref($sessid, $group, $key)
|
||||
{
|
||||
// if sessid is would be used here fix Transport::cronCallMethod !
|
||||
$subjid = $this->gb->getSubjId($group);
|
||||
$subjid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ class Prefs {
|
|||
*/
|
||||
function saveGroupPref($sessid, $group, $key, $value)
|
||||
{
|
||||
$uid = $this->gb->getSessUserId($sessid);
|
||||
$uid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::saveGroupPref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$gid = $this->gb->getSubjId($group);
|
||||
$gid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::saveGroupPref: invalid group name", GBERR_SESS);
|
||||
}
|
||||
$memb = $this->gb->isMemberOf($uid, $gid);
|
||||
$memb = Subjects::IsMemberOf($uid, $gid);
|
||||
if (PEAR::isError($memb)) {
|
||||
return $memb;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class Prefs {
|
|||
*/
|
||||
function delGroupPref($sessid, $group, $key)
|
||||
{
|
||||
$uid = $this->gb->getSessUserId($sessid);
|
||||
$uid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::delGroupPref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$gid = $this->gb->getSubjId($group);
|
||||
$gid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::delGroupPref: invalid group name", GBERR_SESS);
|
||||
}
|
||||
$memb = $this->gb->isMemberOf($uid, $gid);
|
||||
$memb = Subjects::IsMemberOf($uid, $gid);
|
||||
if (PEAR::isError($memb)) {
|
||||
return $memb;
|
||||
}
|
||||
|
@ -280,14 +280,15 @@ class Prefs {
|
|||
* @return int
|
||||
* local user id
|
||||
*/
|
||||
function insert($subjid, $keystr, $valstr='')
|
||||
public static function Insert($subjid, $keystr, $valstr='')
|
||||
{
|
||||
$id = $this->dbc->nextId("{$this->prefTable}_id_seq");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['prefTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$r = $this->dbc->query("
|
||||
INSERT INTO {$this->prefTable}
|
||||
$r = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['prefTable']."
|
||||
(id, subjid, keystr, valstr)
|
||||
VALUES
|
||||
($id, $subjid, '$keystr', '$valstr')
|
||||
|
@ -311,8 +312,9 @@ class Prefs {
|
|||
*/
|
||||
function readVal($subjid, $keystr)
|
||||
{
|
||||
$val = $this->dbc->getOne("
|
||||
SELECT valstr FROM {$this->prefTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$val = $CC_DBC->getOne("
|
||||
SELECT valstr FROM ".$CC_CONFIG['prefTable']."
|
||||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($val)) {
|
||||
|
@ -335,8 +337,9 @@ class Prefs {
|
|||
*/
|
||||
function readKeys($subjid)
|
||||
{
|
||||
$res = $this->dbc->getAll("
|
||||
SELECT keystr FROM {$this->prefTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$res = $CC_DBC->getAll("
|
||||
SELECT keystr FROM ".$CC_CONFIG['prefTable']."
|
||||
WHERE subjid=$subjid
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -362,15 +365,16 @@ class Prefs {
|
|||
*/
|
||||
function update($subjid, $keystr, $newvalstr='')
|
||||
{
|
||||
$r = $this->dbc->query("
|
||||
UPDATE {$this->prefTable} SET
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['prefTable']." SET
|
||||
valstr='$newvalstr'
|
||||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if ($this->dbc->affectedRows() < 1) {
|
||||
if ($CC_DBC->affectedRows() < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -388,14 +392,15 @@ class Prefs {
|
|||
*/
|
||||
function delete($subjid, $keystr)
|
||||
{
|
||||
$r = $this->dbc->query("
|
||||
DELETE FROM {$this->prefTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['prefTable']."
|
||||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if ($this->dbc->affectedRows() < 1) {
|
||||
if ($CC_DBC->affectedRows() < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -409,7 +414,8 @@ class Prefs {
|
|||
*/
|
||||
function test()
|
||||
{
|
||||
$sessid = $this->gb->login('root', $this->gb->config['tmpRootPass']);
|
||||
global $CC_CONFIG;
|
||||
$sessid = Alib::Login('root', $CC_CONFIG['tmpRootPass']);
|
||||
$testkey = 'testKey';
|
||||
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
|
||||
$r = savePref($sessid, $testKey, $testVal);
|
||||
|
@ -439,39 +445,40 @@ class Prefs {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function install()
|
||||
{
|
||||
$this->dbc->createSequence("{$this->prefTable}_id_seq");
|
||||
$r = $this->dbc->query("CREATE TABLE {$this->prefTable} (
|
||||
id int not null,
|
||||
subjid int REFERENCES {$this->gb->subjTable} ON DELETE CASCADE,
|
||||
keystr varchar(255),
|
||||
valstr text
|
||||
)");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
|
||||
ON {$this->prefTable} (id)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
|
||||
ON {$this->prefTable} (subjid, keystr)");
|
||||
$this->dbc->query("CREATE INDEX {$this->prefTable}_subjid_idx
|
||||
ON {$this->prefTable} (subjid)");
|
||||
$stPrefGr = $this->gb->getSubjId($this->gb->config['StationPrefsGr']);
|
||||
if (PEAR::isError($stPrefGr)) {
|
||||
echo $stPrefGr->getMessage()."\n";
|
||||
}
|
||||
$r = $this->insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
}
|
||||
$genres = file_get_contents( dirname(__FILE__).'/genres.xml');
|
||||
$r = $this->insert($stPrefGr, 'genres', $genres);
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
// function install()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->createSequence("{$this->prefTable}_id_seq");
|
||||
// $r = $CC_DBC->query("CREATE TABLE {$this->prefTable} (
|
||||
// id int not null,
|
||||
// subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
// keystr varchar(255),
|
||||
// valstr text
|
||||
// )");
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
|
||||
// ON {$this->prefTable} (id)");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
|
||||
// ON {$this->prefTable} (subjid, keystr)");
|
||||
// $CC_DBC->query("CREATE INDEX {$this->prefTable}_subjid_idx
|
||||
// ON {$this->prefTable} (subjid)");
|
||||
// $stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
|
||||
// if (PEAR::isError($stPrefGr)) {
|
||||
// echo $stPrefGr->getMessage()."\n";
|
||||
// }
|
||||
// $r = Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()."\n";
|
||||
// }
|
||||
// $genres = file_get_contents(dirname(__FILE__).'/../genres.xml');
|
||||
// $r = Prefs::Insert($stPrefGr, 'genres', $genres);
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()."\n";
|
||||
// }
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -479,11 +486,12 @@ class Prefs {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->prefTable}");
|
||||
$this->dbc->dropSequence("{$this->prefTable}_id_seq");
|
||||
}
|
||||
// function uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE {$this->prefTable}");
|
||||
// $CC_DBC->dropSequence("{$this->prefTable}_id_seq");
|
||||
// }
|
||||
|
||||
} // class Prefs
|
||||
?>
|
|
@ -35,6 +35,7 @@ class Renderer
|
|||
*/
|
||||
function rnRender2FileOpen(&$gb, $plid, $owner=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
// recall playlist:
|
||||
$pl = LsPlaylist::recallByGunid($gb, $plid);
|
||||
if (PEAR::isError($pl)) {
|
||||
|
@ -46,7 +47,7 @@ class Renderer
|
|||
return $smil;
|
||||
}
|
||||
// temporary file for smil:
|
||||
$tmpn = tempnam($gb->bufferDir, 'plRender_');
|
||||
$tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_');
|
||||
$smilf = "$tmpn.smil";
|
||||
file_put_contents($smilf, $smil);
|
||||
$url = "file://$smilf";
|
||||
|
@ -54,11 +55,11 @@ class Renderer
|
|||
$outf = "$tmpn.".RENDER_EXT;
|
||||
touch($outf);
|
||||
// logging:
|
||||
$logf = "{$gb->bufferDir}/renderer.log";
|
||||
$logf = $CC_CONFIG['bufferDir']."/renderer.log";
|
||||
file_put_contents($logf, "--- ".date("Ymd-H:i:s")."\n", FILE_APPEND);
|
||||
// open access to output file: /*gunid*/ /*parent*/
|
||||
$acc = $gb->bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
|
||||
if ($gb->dbc->isError($acc)) {
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
extract($acc);
|
||||
|
@ -118,8 +119,8 @@ class Renderer
|
|||
* url : string - readable url
|
||||
*/
|
||||
function rnRender2FileList(&$gb,$stat='') {
|
||||
# open temporary dir
|
||||
$tokens = $gb->getTokensByType('render');
|
||||
// open temporary dir
|
||||
$tokens = BasicStor::GetTokensByType('render');
|
||||
foreach ($tokens as $token) {
|
||||
$st = Renderer::rnRender2FileCheck($gb, $token);
|
||||
if ( ($stat=='') || ($st['status']==$stat) ) {
|
||||
|
@ -142,12 +143,13 @@ class Renderer
|
|||
*/
|
||||
function rnRender2FileClose(&$gb, $token)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$r = $gb->bsRelease($token, 'render');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$realOgg = $r['realFname'];
|
||||
$tmpn = "{$gb->bufferDir}/".basename($realOgg, '.'.RENDER_EXT);
|
||||
$tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT);
|
||||
$smilf = "$tmpn.smil";
|
||||
$statf = Renderer::getStatusFile($gb, $token);
|
||||
@unlink($statf);
|
||||
|
@ -219,7 +221,7 @@ class Renderer
|
|||
return $parid;
|
||||
}
|
||||
$fileName = 'rendered_playlist';
|
||||
$id = $gb->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -254,8 +256,9 @@ class Renderer
|
|||
*/
|
||||
function getLocalFile(&$gb, $token)
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return "{$gb->accessDir}/$token.".RENDER_EXT;
|
||||
global $CC_CONFIG;
|
||||
$token = StoredFile::NormalizeGunid($token);
|
||||
return $CC_CONFIG['accessDir']."/$token.".RENDER_EXT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,8 +288,8 @@ class Renderer
|
|||
*/
|
||||
function getUrl(&$gb, $token)
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return $gb->getUrlPart()."access/$token.".RENDER_EXT;
|
||||
$token = StoredFile::NormalizeGunid($token);
|
||||
return BasicStor::GetUrlPart()."access/$token.".RENDER_EXT;
|
||||
}
|
||||
|
||||
} // class Renderer
|
||||
|
|
|
@ -56,10 +56,12 @@ class Restore {
|
|||
* @param GreenBox $gb
|
||||
* greenbox object reference
|
||||
*/
|
||||
public function __construct(&$gb) {
|
||||
public function __construct(&$gb)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$this->gb =& $gb;
|
||||
$this->token = null;
|
||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||
$this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log';
|
||||
if ($this->loglevel == 'debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||
}
|
||||
|
@ -77,14 +79,15 @@ class Restore {
|
|||
* hasharray with field:
|
||||
* token string: backup token
|
||||
*/
|
||||
function openRestore($sessid, $backup_file) {
|
||||
function openRestore($sessid, $backup_file)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I-".date("Ymd-H:i:s")." doRestore - sessid:$sessid\n");
|
||||
}
|
||||
$this->sessid = $sessid;
|
||||
|
||||
//generate token
|
||||
$this->token = StoredFile::_createGunid();
|
||||
$this->token = StoredFile::CreateGunid();
|
||||
|
||||
// status file -> working
|
||||
$this->setEnviroment();
|
||||
|
@ -112,7 +115,8 @@ class Restore {
|
|||
* url : string - access url
|
||||
* tmpfile : string - access filename
|
||||
*/
|
||||
function checkRestore($token) {
|
||||
function checkRestore($token)
|
||||
{
|
||||
if ($this->loglevel == 'debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -145,7 +149,8 @@ class Restore {
|
|||
* hasharray with field:
|
||||
* status : boolean - is susccess
|
||||
*/
|
||||
function closeRestore($token) {
|
||||
function closeRestore($token)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -170,7 +175,8 @@ class Restore {
|
|||
* @param string $sessid
|
||||
* session id
|
||||
*/
|
||||
function startRestore($backupfile, $token, $sessid) {
|
||||
function startRestore($backupfile, $token, $sessid)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n");
|
||||
}
|
||||
|
@ -181,8 +187,8 @@ class Restore {
|
|||
// extract tarball
|
||||
$command = 'tar -xf '.$backupfile.' --directory '.$this->tmpDir;
|
||||
$res = system($command);
|
||||
#$this->addLogItem('command: '.$command."\n");
|
||||
#$this->addLogItem('res: '.$res."\n");
|
||||
//$this->addLogItem('command: '.$command."\n");
|
||||
//$this->addLogItem('res: '.$res."\n");
|
||||
|
||||
//simple check of archive format
|
||||
if (is_dir($this->tmpDir.'audioClip/') &&
|
||||
|
@ -221,7 +227,8 @@ class Restore {
|
|||
* type : stirng - audioClip | playlist
|
||||
* id : string - the backuped gunid
|
||||
*/
|
||||
function getMetaFiles() {
|
||||
function getMetaFiles()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." getMetaFiles - tmpDir:{$this->tmpDir}\n");
|
||||
}
|
||||
|
@ -256,7 +263,8 @@ class Restore {
|
|||
* @return mixed
|
||||
* true if success or PEAR_error
|
||||
*/
|
||||
function addFileToStorage($file,$type,$gunid) {
|
||||
function addFileToStorage($file,$type,$gunid)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n");
|
||||
}
|
||||
|
@ -273,7 +281,7 @@ class Restore {
|
|||
}
|
||||
if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
|
||||
//replace it
|
||||
$id = $this->gb->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$replace = $this->gb->replaceFile(
|
||||
$id, # id int, virt.file's local id
|
||||
$mediaFileLP, # mediaFileLP string, local path of media file
|
||||
|
@ -341,12 +349,13 @@ class Restore {
|
|||
* Figure out the environment to the backup.
|
||||
*
|
||||
*/
|
||||
function setEnviroment() {
|
||||
function setEnviroment()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n");
|
||||
}
|
||||
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.status';
|
||||
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
|
||||
$this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.status';
|
||||
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
|
||||
$this->rMkDir($this->tmpDir);
|
||||
}
|
||||
|
||||
|
@ -357,7 +366,8 @@ class Restore {
|
|||
* @param string $item
|
||||
* the new row of log file
|
||||
*/
|
||||
function addLogItem($item) {
|
||||
function addLogItem($item)
|
||||
{
|
||||
$f = fopen ($this->logFile,'a');
|
||||
flock($f,LOCK_SH);
|
||||
fwrite($f,$item);
|
||||
|
@ -376,7 +386,8 @@ class Restore {
|
|||
* @return boolean
|
||||
* is success
|
||||
*/
|
||||
function rRmDir($dirname) {
|
||||
function rRmDir($dirname)
|
||||
{
|
||||
if (is_dir($dirname)) {
|
||||
$dir_handle = opendir($dirname);
|
||||
}
|
||||
|
@ -407,7 +418,8 @@ class Restore {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function rMkDir($dirname,$mode=0777,$recursive=true) {
|
||||
function rMkDir($dirname, $mode=0777, $recursive=true)
|
||||
{
|
||||
if (is_null($dirname) || $dirname === "" ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -238,14 +238,14 @@ class SmilPlaylistAudioElement {
|
|||
}
|
||||
}
|
||||
if ($fadeIn > 0 || $fadeOut > 0) {
|
||||
$fiGunid = StoredFile::_createGunid();
|
||||
$fiGunid = StoredFile::CreateGunid();
|
||||
$fadeIn = Playlist::secondsToPlaylistTime($fadeIn);
|
||||
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
|
||||
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
|
||||
} else {
|
||||
$fInfo = '';
|
||||
}
|
||||
$plElGunid = StoredFile::_createGunid();
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
$acGunid = $gunid;
|
||||
$type = 'audioClip';
|
||||
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
|
||||
|
|
|
@ -40,13 +40,13 @@ class StoredFile {
|
|||
* Name of a database table.
|
||||
* @var string
|
||||
*/
|
||||
public $filesTable;
|
||||
//public $filesTable;
|
||||
|
||||
/**
|
||||
* Name of a database table.
|
||||
* @var string
|
||||
*/
|
||||
public $accessTable;
|
||||
//public $accessTable;
|
||||
|
||||
/**
|
||||
* Unique ID for the file.
|
||||
|
@ -57,7 +57,7 @@ class StoredFile {
|
|||
|
||||
/**
|
||||
* Directory where the file is located.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $resDir;
|
||||
|
@ -65,7 +65,7 @@ class StoredFile {
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessDir;
|
||||
//private $accessDir;
|
||||
|
||||
/**
|
||||
* @var RawMediaData
|
||||
|
@ -87,16 +87,17 @@ class StoredFile {
|
|||
*/
|
||||
public function __construct(&$gb, $gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
global $CC_DBC;
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->filesTable = $gb->filesTable;
|
||||
$this->accessTable= $gb->accessTable;
|
||||
//$this->filesTable = $CC_CONFIG['filesTable'];
|
||||
//$this->accessTable= $CC_CONFIG['accessTable'];
|
||||
$this->gunid = $gunid;
|
||||
if (is_null($this->gunid)) {
|
||||
$this->gunid = $this->_createGunid();
|
||||
$this->gunid = StoredFile::CreateGunid();
|
||||
}
|
||||
$this->resDir = $this->_getResDir($this->gunid);
|
||||
$this->accessDir = $this->gb->accessDir;
|
||||
//$this->accessDir = $this->gb->accessDir;
|
||||
$this->rmd = new RawMediaData($this->gunid, $this->resDir);
|
||||
$this->md = new MetaData($gb, $this->gunid, $this->resDir);
|
||||
}
|
||||
|
@ -129,6 +130,7 @@ class StoredFile {
|
|||
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
||||
$gunid=NULL, $ftype=NULL, $className='StoredFile')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ac = new $className($gb, ($gunid ? $gunid : NULL));
|
||||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
|
@ -142,16 +144,16 @@ class StoredFile {
|
|||
}
|
||||
$escapedName = pg_escape_string($name);
|
||||
$escapedFtype = pg_escape_string($ftype);
|
||||
$ac->dbc->query("BEGIN");
|
||||
$res = $ac->dbc->query("
|
||||
INSERT INTO {$ac->filesTable}
|
||||
$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())
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
// --- metadata insert:
|
||||
|
@ -167,7 +169,7 @@ class StoredFile {
|
|||
}
|
||||
$res = $ac->md->insert($metadata, $mdataLoc, $ftype);
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
// --- media file insert:
|
||||
|
@ -178,7 +180,7 @@ class StoredFile {
|
|||
}
|
||||
$res = $ac->rmd->insert($mediaFileLP);
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$mime = $ac->rmd->getMime();
|
||||
|
@ -186,7 +188,7 @@ class StoredFile {
|
|||
if ($mime !== FALSE) {
|
||||
$res = $ac->setMime($mime);
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
@ -195,13 +197,13 @@ class StoredFile {
|
|||
if (!$emptyState) {
|
||||
$res = $ac->setState('ready');
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
$res = $ac->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return $ac;
|
||||
|
@ -221,15 +223,17 @@ class StoredFile {
|
|||
* optional classname to recall
|
||||
* @return StoredFile
|
||||
*/
|
||||
public function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||
public static function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||
{
|
||||
global $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$cond = ($oid != ''
|
||||
? "id='".intval($oid)."'"
|
||||
: "gunid=x'$gunid'::bigint"
|
||||
);
|
||||
$row = $gb->dbc->getRow("
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT id, to_hex(gunid)as gunid, mime, name, ftype
|
||||
FROM {$gb->filesTable} WHERE $cond
|
||||
FROM ".$CC_CONFIG['filesTable']." WHERE $cond
|
||||
");
|
||||
if (PEAR::isError($row)) {
|
||||
return $row;
|
||||
|
@ -241,7 +245,7 @@ class StoredFile {
|
|||
);
|
||||
return $r;
|
||||
}
|
||||
$gunid = StoredFile::_normalizeGunid($row['gunid']);
|
||||
$gunid = StoredFile::NormalizeGunid($row['gunid']);
|
||||
$ac = new $className($gb, $gunid);
|
||||
$ac->mime = $row['mime'];
|
||||
$ac->name = $row['name'];
|
||||
|
@ -281,9 +285,10 @@ class StoredFile {
|
|||
*/
|
||||
public static function recallByToken(&$gb, $token, $className='StoredFile')
|
||||
{
|
||||
$gunid = $gb->dbc->getOne("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = $CC_DBC->getOne("
|
||||
SELECT to_hex(gunid)as gunid
|
||||
FROM {$gb->accessTable}
|
||||
FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE token=x'$token'::bigint
|
||||
");
|
||||
if (PEAR::isError($gunid)) {
|
||||
|
@ -293,7 +298,7 @@ class StoredFile {
|
|||
return PEAR::raiseError(
|
||||
"StoredFile::recallByToken: invalid token ($token)", GBERR_AOBJNEX);
|
||||
}
|
||||
$gunid = StoredFile::_normalizeGunid($gunid);
|
||||
$gunid = StoredFile::NormalizeGunid($gunid);
|
||||
return StoredFile::recall($gb, '', $gunid, $className);
|
||||
}
|
||||
|
||||
|
@ -307,11 +312,11 @@ class StoredFile {
|
|||
* new local id
|
||||
* @return StoredFile
|
||||
*/
|
||||
public function ©Of(&$src, $nid)
|
||||
public static function &CopyOf(&$src, $nid)
|
||||
{
|
||||
$ac = StoredFile::insert(
|
||||
$src->gb, $nid, $src->name, $src->_getRealRADFname(),
|
||||
'', '', NULL, $src->gb->_getType($src->gunid)
|
||||
'', '', NULL, BasicStor::GetType($src->gunid)
|
||||
);
|
||||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
|
@ -339,10 +344,11 @@ class StoredFile {
|
|||
public function replace($oid, $name, $mediaFileLP='', $metadata='',
|
||||
$mdataLoc='file')
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->rename($name);
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
if ($mediaFileLP != '') { // media
|
||||
|
@ -351,7 +357,7 @@ class StoredFile {
|
|||
$res = $this->rmd->delete();
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
if ($metadata != '') { // metadata
|
||||
|
@ -360,12 +366,12 @@ class StoredFile {
|
|||
$res = $this->md->delete();
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -454,18 +460,19 @@ class StoredFile {
|
|||
*/
|
||||
public function replaceMetaData($metadata, $mdataLoc='file', $format=NULL)
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->md->replace($metadata, $mdataLoc, $format);
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$r = $this->md->regenerateXmlFile();
|
||||
if (PEAR::isError($r)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $r;
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -508,9 +515,10 @@ class StoredFile {
|
|||
*/
|
||||
public function rename($newname)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$escapedName = pg_escape_string($newname);
|
||||
$res = $this->dbc->query("
|
||||
UPDATE {$this->filesTable} SET name='$escapedName', mtime=now()
|
||||
$res = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['filesTable']." SET name='$escapedName', mtime=now()
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -532,10 +540,11 @@ class StoredFile {
|
|||
*/
|
||||
public function setState($state, $editedby=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$escapedState = pg_escape_string($state);
|
||||
$eb = (!is_null($editedby) ? ", editedBy=$editedby" : '');
|
||||
$res = $this->dbc->query("
|
||||
UPDATE {$this->filesTable}
|
||||
$res = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['filesTable']."
|
||||
SET state='$escapedState'$eb, mtime=now()
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
|
@ -555,12 +564,13 @@ class StoredFile {
|
|||
*/
|
||||
public function setMime($mime)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if ( !is_string($mime)){
|
||||
$mime = 'application/octet-stream';
|
||||
}
|
||||
$escapedMime = pg_escape_string($mime);
|
||||
$res = $this->dbc->query("
|
||||
UPDATE {$this->filesTable} SET mime='$escapedMime', mtime=now()
|
||||
$res = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['filesTable']." SET mime='$escapedMime', mtime=now()
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -578,6 +588,7 @@ class StoredFile {
|
|||
*/
|
||||
public function delete()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$res = $this->rmd->delete();
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -586,8 +597,8 @@ class StoredFile {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$tokens = $this->dbc->getAll("
|
||||
SELECT to_hex(token)as token, ext FROM {$this->accessTable}
|
||||
$tokens = $CC_DBC->getAll("
|
||||
SELECT to_hex(token)as token, ext FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (is_array($tokens)) {
|
||||
|
@ -598,15 +609,15 @@ class StoredFile {
|
|||
}
|
||||
}
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->accessTable}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->filesTable}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -625,11 +636,12 @@ class StoredFile {
|
|||
*/
|
||||
public function isAccessed($gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($gunid)) {
|
||||
$gunid = $this->gunid;
|
||||
}
|
||||
$ca = $this->dbc->getOne("
|
||||
SELECT currentlyAccessing FROM {$this->filesTable}
|
||||
$ca = $CC_DBC->getOne("
|
||||
SELECT currentlyAccessing FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
if (is_null($ca)) {
|
||||
|
@ -672,14 +684,15 @@ class StoredFile {
|
|||
*/
|
||||
public function isEditedBy($playlistId=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($playlistId)) {
|
||||
$playlistId = $this->gunid;
|
||||
}
|
||||
$ca = $this->dbc->getOne("
|
||||
SELECT editedBy FROM {$this->filesTable}
|
||||
$ca = $CC_DBC->getOne("
|
||||
SELECT editedBy FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$playlistId'::bigint
|
||||
");
|
||||
if ($this->dbc->isError($ca)) {
|
||||
if (PEAR::isError($ca)) {
|
||||
return $ca;
|
||||
}
|
||||
if (is_null($ca)) {
|
||||
|
@ -705,8 +718,9 @@ class StoredFile {
|
|||
*/
|
||||
public function exists()
|
||||
{
|
||||
$indb = $this->dbc->getRow("
|
||||
SELECT to_hex(gunid) FROM {$this->filesTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$indb = $CC_DBC->getRow("
|
||||
SELECT to_hex(gunid) FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($indb)) {
|
||||
|
@ -715,7 +729,7 @@ class StoredFile {
|
|||
if (is_null($indb)) {
|
||||
return FALSE;
|
||||
}
|
||||
if ($this->gb->_getType($this->gunid) == 'audioclip') {
|
||||
if (BasicStor::GetType($this->gunid) == 'audioclip') {
|
||||
return $this->rmd->exists();
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -727,7 +741,7 @@ class StoredFile {
|
|||
* Create new global unique id
|
||||
*
|
||||
*/
|
||||
public static function _createGunid()
|
||||
public static function CreateGunid()
|
||||
{
|
||||
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
|
||||
$initString =
|
||||
|
@ -736,15 +750,16 @@ class StoredFile {
|
|||
// non-negative int8
|
||||
$hsd = substr($hash, 0, 1);
|
||||
$res = dechex(hexdec($hsd)>>1).substr($hash, 1, 15);
|
||||
return StoredFile::_normalizeGunid($res);
|
||||
return StoredFile::NormalizeGunid($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create new global unique id
|
||||
* Pad the gunid with zeros if it isnt 16 digits.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function _normalizeGunid($gunid0)
|
||||
public static function NormalizeGunid($gunid0)
|
||||
{
|
||||
return str_pad($gunid0, 16, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
@ -763,7 +778,7 @@ class StoredFile {
|
|||
// if (is_null($gunid)) {
|
||||
// $gunid = $this->$gunid;
|
||||
// }
|
||||
// $id = $this->dbc->getOne("
|
||||
// $id = $CC_DBC->getOne("
|
||||
// SELECT id FROM {$this->filesTable}
|
||||
// WHERE gunid=x'$gunid'::bigint
|
||||
// ");
|
||||
|
@ -827,7 +842,7 @@ class StoredFile {
|
|||
// if (is_null($gunid)) {
|
||||
// $gunid = $this->gunid;
|
||||
// }
|
||||
// return $this->dbc->getOne("
|
||||
// return $CC_DBC->getOne("
|
||||
// SELECT mime FROM {$this->filesTable}
|
||||
// WHERE gunid=x'$gunid'::bigint
|
||||
// ");
|
||||
|
@ -844,11 +859,12 @@ class StoredFile {
|
|||
*/
|
||||
public function _getState($gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($gunid)) {
|
||||
$gunid = $this->gunid;
|
||||
}
|
||||
return $this->dbc->getOne("
|
||||
SELECT state FROM {$this->filesTable}
|
||||
return $CC_DBC->getOne("
|
||||
SELECT state FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
}
|
||||
|
@ -864,11 +880,12 @@ class StoredFile {
|
|||
*/
|
||||
public function _getFileName($gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($gunid)) {
|
||||
$gunid = $this->gunid;
|
||||
}
|
||||
return $this->dbc->getOne("
|
||||
SELECT name FROM {$this->filesTable}
|
||||
return $CC_DBC->getOne("
|
||||
SELECT name FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
}
|
||||
|
@ -881,8 +898,9 @@ class StoredFile {
|
|||
*/
|
||||
private function _getResDir()
|
||||
{
|
||||
$resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3);
|
||||
#$this->gb->debugLog("$resDir");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3);
|
||||
//$this->gb->debugLog("$resDir");
|
||||
// see Transport::_getResDir too for resDir name create code
|
||||
if (!is_dir($resDir)) {
|
||||
mkdir($resDir, 02775);
|
||||
|
@ -921,8 +939,9 @@ class StoredFile {
|
|||
*/
|
||||
private function _getAccessFname($token, $ext='EXT')
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return "{$this->accessDir}/$token.$ext";
|
||||
global $CC_CONFIG;
|
||||
$token = StoredFile::NormalizeGunid($token);
|
||||
return $CC_CONFIG['accessDir']."/$token.$ext";
|
||||
}
|
||||
|
||||
} // class StoredFile
|
||||
|
|
|
@ -50,32 +50,11 @@ include_once("TransportRecord.php");
|
|||
*/
|
||||
class Transport
|
||||
{
|
||||
/**
|
||||
* Container for db connection instance
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc;
|
||||
|
||||
/**
|
||||
* @var GreenBox
|
||||
*/
|
||||
public $gb;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $transTable;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transDir;
|
||||
|
||||
/**
|
||||
* File name
|
||||
* @var string
|
||||
|
@ -145,10 +124,6 @@ class Transport
|
|||
public function __construct(&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->config =& $gb->config;
|
||||
$this->transTable = $gb->config['tblNamePrefix'].'trans';
|
||||
$this->transDir = $gb->config['transDir'];
|
||||
$this->cronJobScript = realpath(
|
||||
dirname(__FILE__).
|
||||
'/../../storageServer/var/cron/transportCronJob.php'
|
||||
|
@ -307,8 +282,9 @@ class Transport
|
|||
*/
|
||||
function upload2Hub($gunid, $withContent=TRUE, $pars=array())
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$this->trLog("upload2Hub start: ".strftime("%H:%M:%S"));
|
||||
switch ($ftype = $this->gb->_getType($gunid)) {
|
||||
switch ($ftype = BasicStor::GetType($gunid)) {
|
||||
case "audioclip":
|
||||
case "webstream":
|
||||
$ac = StoredFile::recallByGunid($this->gb, $gunid);
|
||||
|
@ -345,7 +321,7 @@ class Transport
|
|||
}
|
||||
$this->startCronJobProcess($mdtrec->trtok);
|
||||
break;
|
||||
|
||||
|
||||
case "playlist":
|
||||
$plid = $gunid;
|
||||
require_once("Playlist.php");
|
||||
|
@ -364,7 +340,7 @@ class Transport
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$tmpn = tempnam($this->transDir, 'plExport_');
|
||||
$tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
$plfpath = "$tmpn.lspl";
|
||||
$this->trLog("upload2Hub begin copy: ".strftime("%H:%M:%S"));
|
||||
copy($res['fname'], $plfpath);
|
||||
|
@ -441,6 +417,7 @@ class Transport
|
|||
*/
|
||||
function globalSearch($criteria, $resultMode='php', $pars=array())
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// testing of hub availability and hub account configuration.
|
||||
// it makes searchjob not async - should be removed for real async
|
||||
$r = $this->loginToArchive();
|
||||
|
@ -455,7 +432,7 @@ class Transport
|
|||
}
|
||||
$this->logoutFromArchive($r);
|
||||
$criteria['resultMode'] = $resultMode;
|
||||
$localfile = tempnam($this->transDir, 'searchjob_');
|
||||
$localfile = tempnam($CC_CONFIG['transDir'], 'searchjob_');
|
||||
@chmod($localfile, 0660);
|
||||
$len = file_put_contents($localfile, serialize($criteria));
|
||||
$trec = $this->_uploadGeneralFileToHub($localfile, 'searchjob', $pars);
|
||||
|
@ -579,7 +556,8 @@ class Transport
|
|||
*/
|
||||
function downloadFileFromHub($url, $chsum=NULL, $size=NULL, $pars=array())
|
||||
{
|
||||
$tmpn = tempnam($this->transDir, 'HITrans_');
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$tmpn = tempnam($CC_CONFIG['transDir'], 'HITrans_');
|
||||
$trec = TransportRecord::create($this, 'file', 'down',
|
||||
array_merge(array(
|
||||
'url' => $url,
|
||||
|
@ -730,10 +708,11 @@ class Transport
|
|||
*/
|
||||
function loginToArchive()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$res = $this->xmlrpcCall('archive.login',
|
||||
array(
|
||||
'login'=>$this->config['archiveAccountLogin'],
|
||||
'pass'=>$this->config['archiveAccountPass']
|
||||
'login' => $CC_CONFIG['archiveAccountLogin'],
|
||||
'pass' => $CC_CONFIG['archiveAccountPass']
|
||||
));
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -770,6 +749,7 @@ class Transport
|
|||
*/
|
||||
function cronMain($direction=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if (is_null($direction)) {
|
||||
$r = $this->cronMain('up');
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -795,7 +775,7 @@ class Transport
|
|||
}
|
||||
// ping to archive server:
|
||||
$r = $this->pingToArchive();
|
||||
chdir($this->config['transDir']);
|
||||
chdir($CC_CONFIG['transDir']);
|
||||
// for all opened transports:
|
||||
foreach ($transports as $i => $row) {
|
||||
$r = $this->startCronJobProcess($row['trtok']);
|
||||
|
@ -814,8 +794,9 @@ class Transport
|
|||
*/
|
||||
function startCronJobProcess($trtok)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (TR_LOG_LEVEL > 2) {
|
||||
$redirect = "{$this->transDir}/debug.log";
|
||||
$redirect = $CC_CONFIG['transDir']."/debug.log";
|
||||
} else {
|
||||
$redirect = "/dev/null";
|
||||
}
|
||||
|
@ -1029,7 +1010,7 @@ class Transport
|
|||
'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
|
||||
'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
|
||||
'fname'=>$ret['filename'],
|
||||
'localfile'=>"{$this->transDir}/$trtok",
|
||||
'localfile'=>$CC_CONFIG['transDir']."/$trtok",
|
||||
)));
|
||||
break;
|
||||
case "audioclip":
|
||||
|
@ -1048,7 +1029,7 @@ class Transport
|
|||
'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
|
||||
'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
|
||||
'fname'=>$ret['filename'], 'title'=>$title,
|
||||
'localfile'=>"{$this->transDir}/$trtok",
|
||||
'localfile'=>$CC_CONFIG['transDir']."/$trtok",
|
||||
)));
|
||||
}
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -1311,7 +1292,7 @@ class Transport
|
|||
$ep = $row['localfile'];
|
||||
@unlink($ep);
|
||||
if (preg_match("|/(plExport_[^\.]+)\.lspl$|", $ep, $va)) {
|
||||
list(,$tmpn) = $va; $tmpn = "{$this->transDir}/$tmpn";
|
||||
list(,$tmpn) = $va; $tmpn = $CC_CONFIG['transDir']."/$tmpn";
|
||||
if (file_exists($tmpn)) {
|
||||
@unlink($tmpn);
|
||||
}
|
||||
|
@ -1366,14 +1347,14 @@ class Transport
|
|||
return TRUE;
|
||||
case 'finished': // metadata finished, close main transport
|
||||
$parid = $this->gb->_getHomeDirId($trec->row['uid']);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
$mdtrec->setLock(FALSE);
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->gb->bsPutFile($parid, $row['fname'],
|
||||
$trec->row['localfile'], $mdtrec->row['localfile'],
|
||||
$row['gunid'], 'audioclip', 'file');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
$mdtrec->setLock(FALSE);
|
||||
return $res;
|
||||
}
|
||||
|
@ -1422,13 +1403,13 @@ class Transport
|
|||
switch ($row['trtype']) {
|
||||
case "playlist":
|
||||
$parid = $this->gb->_getHomeDirId($trec->row['uid']);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->gb->bsPutFile($parid, $row['fname'],
|
||||
'', $trec->row['localfile'],
|
||||
$row['gunid'], 'playlist', 'file');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
@unlink($row['localfile']);
|
||||
|
@ -1437,11 +1418,11 @@ class Transport
|
|||
$subjid = $trec->row['uid'];
|
||||
$fname = $trec->row['localfile'];
|
||||
$parid = $this->gb->_getHomeDirId($subjid);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->gb->bsImportPlaylist($parid, $fname, $subjid);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
@unlink($fname);
|
||||
|
@ -1532,6 +1513,7 @@ class Transport
|
|||
*/
|
||||
function getTransports($direction=NULL, $target=NULL, $trtok=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
switch ($direction) {
|
||||
case 'up':
|
||||
$dirCond = "direction='up' AND";
|
||||
|
@ -1553,13 +1535,13 @@ class Transport
|
|||
} else {
|
||||
$trtokCond = "trtok='$trtok' AND";
|
||||
}
|
||||
$rows = $this->dbc->getAll("
|
||||
$rows = $CC_DBC->getAll("
|
||||
SELECT
|
||||
id, trtok, state, trtype, direction,
|
||||
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
|
||||
fname, localfile, expectedsum, expectedsize, url,
|
||||
uid, target
|
||||
FROM {$this->transTable}
|
||||
FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE $dirCond $targetCond $trtokCond
|
||||
state not in ('closed', 'failed', 'paused')
|
||||
ORDER BY start DESC
|
||||
|
@ -1568,8 +1550,8 @@ class Transport
|
|||
return $rows;
|
||||
}
|
||||
foreach ($rows as $i => $row) {
|
||||
$rows[$i]['pdtoken'] = StoredFile::_normalizeGunid($row['pdtoken']);
|
||||
$rows[$i]['gunid'] = StoredFile::_normalizeGunid($row['gunid']);
|
||||
$rows[$i]['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']);
|
||||
$rows[$i]['gunid'] = StoredFile::NormalizeGunid($row['gunid']);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
@ -1617,11 +1599,11 @@ class Transport
|
|||
*/
|
||||
function xmlrpcCall($method, $pars=array())
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$xrp = XML_RPC_encode($pars);
|
||||
$c = new XML_RPC_Client(
|
||||
"{$this->config['archiveUrlPath']}/".
|
||||
"{$this->config['archiveXMLRPC']}",
|
||||
$this->config['archiveUrlHost'], $this->config['archiveUrlPort']
|
||||
$CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'],
|
||||
$CC_CONFIG['archiveUrlHost'], $CC_CONFIG['archiveUrlPort']
|
||||
);
|
||||
$f = new XML_RPC_Message($method, array($xrp));
|
||||
$r = $c->send($f);
|
||||
|
@ -1688,9 +1670,10 @@ class Transport
|
|||
*/
|
||||
function _cleanUp($interval='1 minute'/*'1 hour'*/, $forced=FALSE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$cond = ($forced ? '' : " AND state='closed' AND lock = 'N'");
|
||||
$r = $this->dbc->query("
|
||||
DELETE FROM {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE ts < now() - interval '$interval'".$cond
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -1736,7 +1719,7 @@ class Transport
|
|||
*/
|
||||
function trLog($msg)
|
||||
{
|
||||
$logfile = "{$this->transDir}/activity.log";
|
||||
$logfile = $CC_CONFIG['transDir']."/activity.log";
|
||||
if (FALSE === ($fp = fopen($logfile, "a"))) {
|
||||
return PEAR::raiseError(
|
||||
"Transport::trLog: Can't write to log ($logfile)"
|
||||
|
@ -1758,7 +1741,8 @@ class Transport
|
|||
*/
|
||||
function resetData()
|
||||
{
|
||||
return $this->dbc->query("DELETE FROM {$this->transTable}");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
return $CC_DBC->query("DELETE FROM ".$CC_CONFIG['transTable']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1770,76 +1754,78 @@ class Transport
|
|||
* trtype: audioclip | playlist | playlistPkg | searchjob | metadata | file
|
||||
*
|
||||
*/
|
||||
function install()
|
||||
{
|
||||
$r = $this->dbc->query("CREATE TABLE {$this->transTable} (
|
||||
id int not null, -- primary key
|
||||
trtok char(16) not null, -- transport token
|
||||
direction varchar(128) not null, -- direction: up|down
|
||||
state varchar(128) not null, -- state
|
||||
trtype varchar(128) not null, -- transport type
|
||||
lock char(1) not null default 'N',-- running lock
|
||||
target varchar(255) default NULL, -- target system,
|
||||
-- if NULL => predefined set
|
||||
rtrtok char(16) default NULL, -- remote hub's transport token
|
||||
mdtrtok char(16), -- metadata transport token
|
||||
gunid bigint, -- global unique id
|
||||
pdtoken bigint, -- put/download token from archive
|
||||
url varchar(255), -- url on remote side
|
||||
localfile varchar(255), -- pathname of local part
|
||||
fname varchar(255), -- mnemonic filename
|
||||
title varchar(255), -- dc:title mdata value (or filename ...)
|
||||
expectedsum char(32), -- expected file checksum
|
||||
realsum char(32), -- checksum of transported part
|
||||
expectedsize int, -- expected filesize in bytes
|
||||
realsize int, -- filesize of transported part
|
||||
uid int, -- local user id of transport owner
|
||||
errmsg varchar(255), -- error message string for failed tr.
|
||||
start timestamp, -- starttime
|
||||
ts timestamp -- mtime
|
||||
)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->createSequence("{$this->transTable}_id_seq");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_id_idx
|
||||
ON {$this->transTable} (id)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_trtok_idx
|
||||
ON {$this->transTable} (trtok)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_token_idx
|
||||
ON {$this->transTable} (pdtoken)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE INDEX {$this->transTable}_gunid_idx
|
||||
ON {$this->transTable} (gunid)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE INDEX {$this->transTable}_state_idx
|
||||
ON {$this->transTable} (state)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
}
|
||||
// function install()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $r = $CC_DBC->query("CREATE TABLE {$this->transTable} (
|
||||
// id int not null, -- primary key
|
||||
// trtok char(16) not null, -- transport token
|
||||
// direction varchar(128) not null, -- direction: up|down
|
||||
// state varchar(128) not null, -- state
|
||||
// trtype varchar(128) not null, -- transport type
|
||||
// lock char(1) not null default 'N',-- running lock
|
||||
// target varchar(255) default NULL, -- target system,
|
||||
// -- if NULL => predefined set
|
||||
// rtrtok char(16) default NULL, -- remote hub's transport token
|
||||
// mdtrtok char(16), -- metadata transport token
|
||||
// gunid bigint, -- global unique id
|
||||
// pdtoken bigint, -- put/download token from archive
|
||||
// url varchar(255), -- url on remote side
|
||||
// localfile varchar(255), -- pathname of local part
|
||||
// fname varchar(255), -- mnemonic filename
|
||||
// title varchar(255), -- dc:title mdata value (or filename ...)
|
||||
// expectedsum char(32), -- expected file checksum
|
||||
// realsum char(32), -- checksum of transported part
|
||||
// expectedsize int, -- expected filesize in bytes
|
||||
// realsize int, -- filesize of transported part
|
||||
// uid int, -- local user id of transport owner
|
||||
// errmsg varchar(255), -- error message string for failed tr.
|
||||
// start timestamp, -- starttime
|
||||
// ts timestamp -- mtime
|
||||
// )");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->createSequence("{$this->transTable}_id_seq");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE UNIQUE INDEX {$this->transTable}_id_idx
|
||||
// ON {$this->transTable} (id)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE UNIQUE INDEX {$this->transTable}_trtok_idx
|
||||
// ON {$this->transTable} (trtok)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE UNIQUE INDEX {$this->transTable}_token_idx
|
||||
// ON {$this->transTable} (pdtoken)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE INDEX {$this->transTable}_gunid_idx
|
||||
// ON {$this->transTable} (gunid)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE INDEX {$this->transTable}_state_idx
|
||||
// ON {$this->transTable} (state)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Uninstall method
|
||||
*/
|
||||
function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->transTable}");
|
||||
$this->dbc->dropSequence("{$this->transTable}_id_seq");
|
||||
}
|
||||
// function uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE {$this->transTable}");
|
||||
// $CC_DBC->dropSequence("{$this->transTable}_id_seq");
|
||||
// }
|
||||
}
|
||||
|
||||
?>
|
|
@ -19,7 +19,7 @@ class TransportRecord
|
|||
/**
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc;
|
||||
//public $dbc;
|
||||
|
||||
/**
|
||||
* @var GreenBox
|
||||
|
@ -29,12 +29,7 @@ class TransportRecord
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $transTable;
|
||||
//private $config;
|
||||
|
||||
/**
|
||||
* @var Transport
|
||||
|
@ -60,9 +55,6 @@ class TransportRecord
|
|||
{
|
||||
$this->tr =& $tr;
|
||||
$this->gb =& $tr->gb;
|
||||
$this->dbc =& $tr->gb->dbc;
|
||||
$this->config = $tr->gb->config;
|
||||
$this->transTable = $tr->gb->config['tblNamePrefix'].'trans';
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,6 +72,7 @@ class TransportRecord
|
|||
*/
|
||||
function create(&$tr, $trtype, $direction='up', $defaults=array())
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$trec = new TransportRecord($tr);
|
||||
$trec->trtok = $trtok = $tr->_createTransportToken();
|
||||
$trec->row = array_merge($defaults,
|
||||
|
@ -91,7 +84,7 @@ class TransportRecord
|
|||
return $defaults['title'];
|
||||
}
|
||||
}
|
||||
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['transTable']."_id_seq");
|
||||
$names = "id, trtok, direction, state, trtype, start, ts";
|
||||
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
|
||||
foreach ($defaults as $k => $v) {
|
||||
|
@ -100,12 +93,12 @@ class TransportRecord
|
|||
$values .= ", $sqlVal";
|
||||
}
|
||||
$query = "
|
||||
INSERT INTO {$trec->transTable}
|
||||
INSERT INTO ".$CC_CONFIG['transTable']."
|
||||
($names)
|
||||
VALUES
|
||||
($values)
|
||||
";
|
||||
$res = $trec->dbc->query($query);
|
||||
$res = $CC_DBC->query($query);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -123,16 +116,17 @@ class TransportRecord
|
|||
*/
|
||||
function recall(&$tr, $trtok)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$trec = new TransportRecord($tr);
|
||||
$trec->trtok = $trtok;
|
||||
$row = $trec->dbc->getRow("
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT
|
||||
id, trtok, state, trtype, direction,
|
||||
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
|
||||
fname, localfile, url, rtrtok, mdtrtok, uid,
|
||||
expectedsize, realsize, expectedsum, realsum,
|
||||
errmsg, title
|
||||
FROM {$trec->transTable}
|
||||
FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE trtok='$trtok'
|
||||
");
|
||||
if (PEAR::isError($row)) {
|
||||
|
@ -143,8 +137,8 @@ class TransportRecord
|
|||
" invalid transport token ($trtok)", TRERR_TOK
|
||||
);
|
||||
}
|
||||
$row['pdtoken'] = StoredFile::_normalizeGunid($row['pdtoken']);
|
||||
$row['gunid'] = StoredFile::_normalizeGunid($row['gunid']);
|
||||
$row['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']);
|
||||
$row['gunid'] = StoredFile::NormalizeGunid($row['gunid']);
|
||||
$trec->row = $row;
|
||||
$trec->recalled = TRUE;
|
||||
return $trec;
|
||||
|
@ -165,6 +159,7 @@ class TransportRecord
|
|||
*/
|
||||
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$set = " state='$newState', ts=now()";
|
||||
if (!is_null($lock)) {
|
||||
$slock = ($lock ? 'Y' : 'N');
|
||||
|
@ -175,8 +170,8 @@ class TransportRecord
|
|||
foreach ($data as $k => $v) {
|
||||
$set .= ", $k=".$this->_getSqlVal($k, $v);
|
||||
}
|
||||
$r = $this->dbc->query("
|
||||
UPDATE {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['transTable']."
|
||||
SET $set
|
||||
WHERE trtok='{$this->trtok}'".
|
||||
(is_null($oldState) ? '' : " AND state='$oldState'").
|
||||
|
@ -186,7 +181,7 @@ class TransportRecord
|
|||
return $r;
|
||||
}
|
||||
// return TRUE;
|
||||
$affRows = $this->dbc->affectedRows();
|
||||
$affRows = $CC_DBC->affectedRows();
|
||||
if (PEAR::isError($affRows)) {
|
||||
return $affRows;
|
||||
}
|
||||
|
@ -221,21 +216,22 @@ class TransportRecord
|
|||
*/
|
||||
function setLock($lock)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if ($this->dropped) {
|
||||
return TRUE;
|
||||
}
|
||||
$slock = ($lock ? 'Y' : 'N');
|
||||
$nlock = (!$lock);
|
||||
$snlock = ($nlock ? 'Y' : 'N');
|
||||
$r = $this->dbc->query("
|
||||
UPDATE {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['transTable']."
|
||||
SET lock='$slock', ts=now()
|
||||
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$affRows = $this->dbc->affectedRows();
|
||||
$affRows = $CC_DBC->affectedRows();
|
||||
if (PEAR::isError($affRows)) {
|
||||
return $affRows;
|
||||
}
|
||||
|
@ -304,6 +300,7 @@ class TransportRecord
|
|||
*/
|
||||
function close()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!$this->recalled) {
|
||||
return PEAR::raiseError("TransportRecord::close:".
|
||||
" not recalled ({$this->trtok})", TRERR_TOK
|
||||
|
@ -315,8 +312,8 @@ class TransportRecord
|
|||
return $r;
|
||||
}
|
||||
} else {
|
||||
$r = $this->dbc->query("
|
||||
DELETE FROM {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE trtok='{$this->trtok}'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
|
|
|
@ -329,17 +329,6 @@ $audioClipFormat = array(
|
|||
'type'=>'Int',
|
||||
// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$',
|
||||
),
|
||||
/*
|
||||
''=>array(
|
||||
'type'=>'',
|
||||
'area'=>'',
|
||||
'attrs'=>array(),
|
||||
),
|
||||
*/
|
||||
);
|
||||
|
||||
/*
|
||||
?
|
||||
ls:filename Text auto
|
||||
*/
|
||||
?>
|
|
@ -18,13 +18,13 @@
|
|||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (DB::isError($dbc)) {
|
||||
die($dbc->getMessage());
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$bs = new BasicStor($dbc, $config);
|
||||
$bs = new BasicStor();
|
||||
|
||||
$pass = $argv[1];
|
||||
$r = $bs->passwd('scheduler', NULL, $pass);
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
/**
|
||||
* StorageServer configuration file
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
/**
|
||||
* configuration structure:
|
||||
*
|
||||
* <dl>
|
||||
|
@ -39,9 +31,12 @@ define('CAMPCASTER_VERSION', '1.1.1');
|
|||
* </dl>
|
||||
*/
|
||||
|
||||
// these are the default values for the config
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
$config = array(
|
||||
// these are the default values for the config
|
||||
global $CC_CONFIG;
|
||||
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'test',
|
||||
|
@ -51,7 +46,6 @@ $config = array(
|
|||
'database' => 'Campcaster-test',
|
||||
),
|
||||
'tblNamePrefix' => 'ls_',
|
||||
|
||||
/* ================================================ storage configuration */
|
||||
'authCookieName'=> 'campcaster_session_id',
|
||||
'AdminsGr' => 'Admins',
|
||||
|
@ -123,11 +117,27 @@ $config = array(
|
|||
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
|
||||
'paramdir' => dirname(__FILE__).'/cron/params',
|
||||
);
|
||||
$config['sysSubjs'] = array(
|
||||
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||
|
||||
// Add database table names
|
||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
|
||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||
$CC_CONFIG['classTable'] = $CC_CONFIG['tblNamePrefix'].'classes';
|
||||
$CC_CONFIG['cmembTable'] = $CC_CONFIG['tblNamePrefix'].'cmemb';
|
||||
$CC_CONFIG['treeTable'] = $CC_CONFIG['tblNamePrefix'].'tree';
|
||||
$CC_CONFIG['structTable'] = $CC_CONFIG['tblNamePrefix'].'struct';
|
||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||
|
||||
$CC_CONFIG['sysSubjs'] = array(
|
||||
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr']
|
||||
);
|
||||
$old_ip = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
|
||||
// see if a ~/.campcaster/storageServer.conf.php exists, and
|
||||
// overwrite the settings from there if any
|
||||
|
@ -145,23 +155,23 @@ if (!is_null($this_file)) {
|
|||
$fileowner_name = $fileowner_array['name'];
|
||||
$home_conf = $fileowner_homedir . '/.campcaster/storageServer.conf.php';
|
||||
if (file_exists($home_conf)) {
|
||||
$default_config = $config;
|
||||
$default_config = $CC_CONFIG;
|
||||
$developer_name = $fileowner_name;
|
||||
include($home_conf);
|
||||
$user_config = $config;
|
||||
$config = $user_config + $default_config;
|
||||
$user_config = $CC_CONFIG;
|
||||
$CC_CONFIG = $user_config + $default_config;
|
||||
}
|
||||
}
|
||||
|
||||
// make dirpaths better (without ../)
|
||||
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
|
||||
$rp = realpath($config[$d]);
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
// workaround for missing dirs
|
||||
if ( $rp === FALSE ) {
|
||||
mkdir( $config[$d] );
|
||||
$rp = realpath($config[$d]);
|
||||
mkdir( $CC_CONFIG[$d] );
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
}
|
||||
$config[$d] = $rp;
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -1,13 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* StorageServer configuration file
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
/**
|
||||
*
|
||||
* configuration structure:
|
||||
*
|
||||
* <dl>
|
||||
|
@ -38,9 +32,11 @@ define('CAMPCASTER_VERSION', '1.1.1');
|
|||
* </dl>
|
||||
*/
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
// these are the default values for the config
|
||||
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'ls_dbuser',
|
||||
|
@ -121,21 +117,37 @@ $config = array(
|
|||
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
|
||||
'paramdir' => dirname(__FILE__).'/cron/params',
|
||||
);
|
||||
$config['sysSubjs'] = array(
|
||||
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||
|
||||
// Add database table names
|
||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
|
||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||
$CC_CONFIG['classTable'] = $CC_CONFIG['tblNamePrefix'].'classes';
|
||||
$CC_CONFIG['cmembTable'] = $CC_CONFIG['tblNamePrefix'].'cmemb';
|
||||
$CC_CONFIG['treeTable'] = $CC_CONFIG['tblNamePrefix'].'tree';
|
||||
$CC_CONFIG['structTable'] = $CC_CONFIG['tblNamePrefix'].'struct';
|
||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||
|
||||
$CC_CONFIG['sysSubjs'] = array(
|
||||
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr']
|
||||
);
|
||||
$old_ip = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
|
||||
// make dirpaths better (without ../)
|
||||
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
|
||||
$rp = realpath($config[$d]);
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
// workaround for missing dirs
|
||||
if ( $rp === FALSE ) {
|
||||
mkdir( $config[$d] );
|
||||
$rp = realpath($config[$d]);
|
||||
mkdir( $CC_CONFIG[$d] );
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
}
|
||||
$config[$d] = $rp;
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,11 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* StorageServer configuration file
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* configuration structure:
|
||||
*
|
||||
* <dl>
|
||||
|
@ -30,7 +26,7 @@
|
|||
* for login to archive
|
||||
* </dl>
|
||||
*/
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'ls_dbuser',
|
||||
|
@ -66,4 +62,4 @@ $config = array(
|
|||
'cronUserName' => $developer_name,
|
||||
|
||||
);
|
||||
?>
|
||||
?>
|
|
@ -9,7 +9,7 @@ require_once (dirname(__FILE__).'/../conf.php');
|
|||
* $access = $cron->openCrontab('write');
|
||||
* if ($access != 'write') {
|
||||
* do {
|
||||
* $access = $this->forceWriteable();
|
||||
* $access = $cron->forceWriteable();
|
||||
* } while ($access != 'write');
|
||||
* }
|
||||
* $cron->addCronJob('*','*','*','*','*',
|
||||
|
@ -46,11 +46,11 @@ class Cron {
|
|||
* Constructor
|
||||
*/
|
||||
function Cron() {
|
||||
global $config;
|
||||
$this->lockfile = $config['lockfile'];
|
||||
$this->cronfile = $config['cronfile'];
|
||||
$this->paramdir = $config['paramdir'];
|
||||
$this->cronUserName = $config['cronUserName'];
|
||||
global $CC_CONFIG;
|
||||
$this->lockfile = $CC_CONFIG['lockfile'];
|
||||
$this->cronfile = $CC_CONFIG['cronfile'];
|
||||
$this->paramdir = $CC_CONFIG['paramdir'];
|
||||
$this->cronUserName = $CC_CONFIG['cronUserName'];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
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);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$gb = new LocStor($dbc, $config);
|
||||
$gb = new LocStor();
|
||||
$tr = new Transport($gb);
|
||||
|
||||
$r = $tr->cronMain();
|
||||
if(!$r) exit(1);
|
||||
if (!$r) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
?>
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
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);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$gb = new LocStor($dbc, $config);
|
||||
$gb = new LocStor();
|
||||
$tr = new Transport($gb);
|
||||
|
||||
list(, $trtok) = $_SERVER['argv'];
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
* This (web-callable) script returns group running httpd
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
$egid = posix_getegid();
|
||||
$info = posix_getgrgid($egid);
|
||||
if($_SERVER["REMOTE_ADDR"] == "127.0.0.1") echo $info['name'];
|
||||
header("Content-type: text/plain");
|
||||
$egid = posix_getegid();
|
||||
$info = posix_getgrgid($egid);
|
||||
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") {
|
||||
echo $info['name'];
|
||||
}
|
||||
?>
|
|
@ -3,6 +3,8 @@
|
|||
* This script returns real dir of php scipts for debugging purposes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
if($_SERVER["REMOTE_ADDR"] == "127.0.0.1") echo `pwd`;
|
||||
header("Content-type: text/plain");
|
||||
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") {
|
||||
echo `pwd`;
|
||||
}
|
||||
?>
|
|
@ -3,8 +3,8 @@
|
|||
* This script returns storage root URL
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require "../conf.php";
|
||||
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}";
|
||||
header("Content-type: text/plain");
|
||||
require("../conf.php");
|
||||
echo "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}";
|
||||
?>
|
|
@ -3,8 +3,8 @@
|
|||
* This script returns storage XMLRPC root URL
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require "../conf.php";
|
||||
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
||||
header("Content-type: text/plain");
|
||||
require("../conf.php");
|
||||
echo "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}";
|
||||
?>
|
|
@ -1,120 +1,39 @@
|
|||
<?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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// no remote execution
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != "") {
|
||||
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);
|
||||
}
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once "../Transport.php";
|
||||
require_once "../Prefs.php";
|
||||
echo "*************************\n";
|
||||
echo "* StorageServer Install *\n";
|
||||
echo "*************************\n";
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if (assert_options(ASSERT_ACTIVE) == 1) {
|
||||
return;
|
||||
}
|
||||
echo "ERROR:\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo().
|
||||
"\nui:\n".$err->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
require_once('../conf.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('installMain.php');
|
||||
require_once('installStorage.php');
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
echo "**********************************\n";
|
||||
echo "* StorageServer Install Complete *\n";
|
||||
echo "**********************************\n";
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
echo $dbc->getMessage()."\n";
|
||||
echo $dbc->getUserInfo()."\n";
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in var/conf.php ".
|
||||
"(in storageServer directory).\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config, TRUE);
|
||||
$tr = new Transport($gb);
|
||||
$pr = new Prefs($gb);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// install
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
echo "#StorageServer install:\n";
|
||||
echo "# Install ...\n";
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n");
|
||||
#$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$r = $gb->install();
|
||||
if(PEAR::isError($r)){ echo $r->getMessage()."\n"; echo $r->getUserInfo()."\n"; exit(1); }
|
||||
#if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit(1); }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Storage directory writability test
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if(!($fp = @fopen($config['storageDir']."/_writeTest", 'w'))){
|
||||
echo "\n<b>make {$config['storageDir']} dir webdaemon-writeable</b>".
|
||||
"\nand run install again\n\n";
|
||||
exit(1);
|
||||
}else{
|
||||
fclose($fp); unlink($config['storageDir']."/_writeTest");
|
||||
echo "#storageServer main: OK\n";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Submodules
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
echo "# Install Transport submodule ...";
|
||||
$r = $tr->install();
|
||||
if(PEAR::isError($r)){ echo $r->getMessage()."\n"; echo $r->getUserInfo()."\n"; exit(1); }
|
||||
echo "\n";
|
||||
|
||||
echo "# Install Prefs submodule ...";
|
||||
$r = $pr->install();
|
||||
if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit(1); }
|
||||
echo "\n";
|
||||
|
||||
echo "# submodules: OK\n";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Cron configuration
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
echo "# Cron configuration ...";
|
||||
require_once dirname(__FILE__).'/../cron/Cron.php';
|
||||
$cron = new Cron();
|
||||
$access = $r = $cron->openCrontab('write');
|
||||
if ($access != 'write') {
|
||||
do {
|
||||
$r = $this->forceWriteable();
|
||||
} while ($r);
|
||||
}
|
||||
$cron->ct->addCron('*/2', '*', '*', '*', '*', realpath("{$config['cronDir']}/transportCron.php"));
|
||||
$r = $cron->closeCrontab();
|
||||
echo "# cron config: OK\n";
|
||||
|
||||
echo "#storageServer: OK\n\n";
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
||||
?>
|
371
campcaster/src/modules/storageServer/var/install/installMain.php
Normal file
371
campcaster/src/modules/storageServer/var/install/installMain.php
Normal file
|
@ -0,0 +1,371 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision: 2475 $
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
function camp_db_table_exists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo $CC_DBC->getMessage()."\n";
|
||||
echo $CC_DBC->getUserInfo()."\n";
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in var/conf.php ".
|
||||
"(in storageServer directory).\n";
|
||||
exit(1);
|
||||
} else {
|
||||
echo " * Connected to database\n";
|
||||
}
|
||||
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Install database tables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['treeTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['treeTable']."...";
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['treeTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
name varchar(255) not null default'',
|
||||
-- parid int,
|
||||
type varchar(255) not null default'',
|
||||
param varchar(255))");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
}
|
||||
$CC_DBC->createSequence($CC_CONFIG['treeTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['treeTable']."_id_idx
|
||||
ON ".$CC_CONFIG['treeTable']." (id)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['treeTable']."_name_idx
|
||||
ON ".$CC_CONFIG['treeTable']." (name)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['treeTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['structTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['structTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['structTable']." (
|
||||
rid int not null PRIMARY KEY,
|
||||
objid int not null REFERENCES ".$CC_CONFIG['treeTable']." ON DELETE CASCADE,
|
||||
parid int not null REFERENCES ".$CC_CONFIG['treeTable']." ON DELETE CASCADE,
|
||||
level int
|
||||
)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['structTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['structTable']."_rid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (rid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['structTable']."_objid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (objid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['structTable']."_parid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (parid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['structTable']."_level_idx
|
||||
ON ".$CC_CONFIG['structTable']." (level)");
|
||||
$CC_DBC->query("
|
||||
CREATE UNIQUE INDEX ".$CC_CONFIG['structTable']."_objid_level_idx
|
||||
ON ".$CC_CONFIG['structTable']." (objid, level)
|
||||
");
|
||||
$CC_DBC->query("
|
||||
CREATE UNIQUE INDEX ".$CC_CONFIG['structTable']."_objid_parid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (objid, parid)
|
||||
");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['structTable']."\n";
|
||||
}
|
||||
|
||||
//
|
||||
// Insert the RootNode if its not there yet.
|
||||
//
|
||||
$sql = "SELECT * FROM ".$CC_CONFIG['treeTable']
|
||||
." WHERE name='".$CC_CONFIG['RootNode']."'"
|
||||
." AND type='RootNode'";
|
||||
$row = $CC_DBC->GetRow($sql);
|
||||
if (!PEAR::isError($row) && !$row) {
|
||||
echo " * Creating ROOT NODE in ".$CC_CONFIG['treeTable']."...";
|
||||
$oid = $CC_DBC->nextId($CC_CONFIG['treeTable']."_id_seq");
|
||||
if (PEAR::isError($oid)) {
|
||||
echo $oid->getMessage()."\n";
|
||||
//print_r($oid);
|
||||
exit();
|
||||
}
|
||||
$CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['treeTable']."
|
||||
(id, name, type)
|
||||
VALUES
|
||||
($oid, '".$CC_CONFIG['RootNode']."', 'RootNode')
|
||||
");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: Root node already exists in ".$CC_CONFIG['treeTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['classTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['classTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['classTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
cname varchar(20)
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['classTable']."_id_idx
|
||||
ON ".$CC_CONFIG['classTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['classTable']."_cname_idx
|
||||
ON ".$CC_CONFIG['classTable']." (cname)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['classTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['cmembTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['cmembTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['cmembTable']." (
|
||||
objid int not null,
|
||||
cid int not null
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['cmembTable']."_idx
|
||||
ON ".$CC_CONFIG['cmembTable']." (objid, cid)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['cmembTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['subjTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['subjTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['subjTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
login varchar(255) not null default'',
|
||||
pass varchar(255) not null default'',
|
||||
type char(1) not null default 'U',
|
||||
realname varchar(255) not null default'',
|
||||
lastlogin timestamp,
|
||||
lastfail timestamp
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_id_idx
|
||||
ON ".$CC_CONFIG['subjTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_login_idx
|
||||
ON ".$CC_CONFIG['subjTable']." (login)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['subjTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['subjTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['smembTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['smembTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['smembTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
uid int not null default 0,
|
||||
gid int not null default 0,
|
||||
level int not null default 0,
|
||||
mid int
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['smembTable']."_id_idx
|
||||
ON ".$CC_CONFIG['smembTable']." (id)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['smembTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['smembTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['permTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['permTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['permTable']." (
|
||||
permid int not null PRIMARY KEY,
|
||||
subj int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
action varchar(20),
|
||||
obj int,
|
||||
type char(1)
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_permid_idx
|
||||
ON ".$CC_CONFIG['permTable']." (permid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['permTable']."_subj_obj_idx
|
||||
ON ".$CC_CONFIG['permTable']." (subj, obj)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_all_idx
|
||||
ON ".$CC_CONFIG['permTable']." (subj, action, obj)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['permTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['permTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['sessTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['sessTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['sessTable']." (
|
||||
sessid char(32) not null PRIMARY KEY,
|
||||
userid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
login varchar(255),
|
||||
ts timestamp
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['sessTable']."_sessid_idx
|
||||
ON ".$CC_CONFIG['sessTable']." (sessid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['sessTable']."_userid_idx
|
||||
ON ".$CC_CONFIG['sessTable']." (userid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['sessTable']."_login_idx
|
||||
ON ".$CC_CONFIG['sessTable']." (login)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['sessTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['filesTable']."...";
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['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 ".$CC_CONFIG['subjTable'].", -- who edits it
|
||||
mtime timestamp(6) with time zone -- lst modif.time
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_id_idx
|
||||
ON ".$CC_CONFIG['filesTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['filesTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx
|
||||
ON ".$CC_CONFIG['filesTable']." (name)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['mdataTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['mdataTable']."...";
|
||||
$CC_DBC->createSequence($CC_CONFIG['mdataTable']."_id_seq");
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['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
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['mdataTable']."_id_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (id)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['mdataTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['mdataTable']."_subj_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (subjns, subject)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['mdataTable']."_pred_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (predns, predicate)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['mdataTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['accessTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['accessTable']."...";
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['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 ".$CC_CONFIG['subjTable'].", -- subject have started it
|
||||
ts timestamp
|
||||
)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['accessTable']."_token_idx
|
||||
ON ".$CC_CONFIG['accessTable']." (token)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['accessTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['accessTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['accessTable']."_parent_idx
|
||||
ON ".$CC_CONFIG['accessTable']." (parent)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['accessTable']."\n";
|
||||
}
|
||||
|
||||
echo " * Inserting starting data into tables...";
|
||||
$gb = new GreenBox();
|
||||
$r = $gb->initData();
|
||||
echo "done.\n";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Submodules
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['transTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['transTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['transTable']." (
|
||||
id int not null, -- primary key
|
||||
trtok char(16) not null, -- transport token
|
||||
direction varchar(128) not null, -- direction: up|down
|
||||
state varchar(128) not null, -- state
|
||||
trtype varchar(128) not null, -- transport type
|
||||
lock char(1) not null default 'N',-- running lock
|
||||
target varchar(255) default NULL, -- target system,
|
||||
-- if NULL => predefined set
|
||||
rtrtok char(16) default NULL, -- remote hub's transport token
|
||||
mdtrtok char(16), -- metadata transport token
|
||||
gunid bigint, -- global unique id
|
||||
pdtoken bigint, -- put/download token from archive
|
||||
url varchar(255), -- url on remote side
|
||||
localfile varchar(255), -- pathname of local part
|
||||
fname varchar(255), -- mnemonic filename
|
||||
title varchar(255), -- dc:title mdata value (or filename ...)
|
||||
expectedsum char(32), -- expected file checksum
|
||||
realsum char(32), -- checksum of transported part
|
||||
expectedsize int, -- expected filesize in bytes
|
||||
realsize int, -- filesize of transported part
|
||||
uid int, -- local user id of transport owner
|
||||
errmsg varchar(255), -- error message string for failed tr.
|
||||
start timestamp, -- starttime
|
||||
ts timestamp -- mtime
|
||||
)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['transTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_id_idx
|
||||
ON ".$CC_CONFIG['transTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_trtok_idx
|
||||
ON ".$CC_CONFIG['transTable']." (trtok)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_token_idx
|
||||
ON ".$CC_CONFIG['transTable']." (pdtoken)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['transTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['transTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['transTable']."_state_idx
|
||||
ON ".$CC_CONFIG['transTable']." (state)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['transTable']."\n";
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['prefTable']."...";
|
||||
$CC_DBC->createSequence($CC_CONFIG['prefTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['prefTable']." (
|
||||
id int not null,
|
||||
subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
keystr varchar(255),
|
||||
valstr text
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_id_idx
|
||||
ON ".$CC_CONFIG['prefTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_subj_key_idx
|
||||
ON ".$CC_CONFIG['prefTable']." (subjid, keystr)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['prefTable']."_subjid_idx
|
||||
ON ".$CC_CONFIG['prefTable']." (subjid)");
|
||||
echo "done.\n";
|
||||
|
||||
echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."...";
|
||||
$stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
|
||||
Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||
$genres = file_get_contents( dirname(__FILE__).'/../genres.xml');
|
||||
Prefs::Insert($stPrefGr, 'genres', $genres);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Install storage directories
|
||||
//------------------------------------------------------------------------
|
||||
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
if ( $rp === FALSE ) {
|
||||
echo " * Creating directory ".$CC_CONFIG[$d]."...";
|
||||
mkdir($CC_CONFIG[$d], 02775);
|
||||
echo "done.\n";
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
} else {
|
||||
echo " * Skipping: directory already exists: $rp\n";
|
||||
}
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Storage directory writability test
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
echo " * Testing writability of ".$CC_CONFIG['storageDir']."...";
|
||||
if (!($fp = @fopen($CC_CONFIG['storageDir']."/_writeTest", 'w'))) {
|
||||
echo "\nPlease make directory {$CC_CONFIG['storageDir']} writeable by your webserver".
|
||||
"\nand run install again\n\n";
|
||||
exit(1);
|
||||
} else {
|
||||
fclose($fp);
|
||||
unlink($CC_CONFIG['storageDir']."/_writeTest");
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Install Cron job
|
||||
//------------------------------------------------------------------------
|
||||
require_once(dirname(__FILE__).'/../cron/Cron.php');
|
||||
|
||||
echo " * Adding cron job...";
|
||||
$cron = new Cron();
|
||||
$access = $cron->openCrontab('write');
|
||||
if ($access != 'write') {
|
||||
do {
|
||||
$r = $cron->forceWriteable();
|
||||
} while ($r);
|
||||
}
|
||||
$cron->ct->addCron('*/2', '*', '*', '*', '*', realpath("{$CC_CONFIG['cronDir']}/transportCron.php"));
|
||||
$cron->closeCrontab();
|
||||
echo "done.\n";
|
||||
|
||||
?>
|
|
@ -1,65 +1,35 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
// no remote execution
|
||||
// Do not allow remote execution.
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){
|
||||
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;
|
||||
}
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once "../Transport.php";
|
||||
require_once "../Prefs.php";
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if(assert_options(ASSERT_ACTIVE)==1) return;
|
||||
echo "ERROR:\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo().
|
||||
"\nui:\n".$err->getUserInfo()."\n</pre>\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "***************************\n";
|
||||
echo "* StorageServer Uninstall *\n";
|
||||
echo "***************************\n";
|
||||
|
||||
require_once('../conf.php');
|
||||
require_once('uninstallMain.php');
|
||||
require_once('uninstallStorage.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if(PEAR::isError($dbc)){
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "************************************\n";
|
||||
echo "* StorageServer Uninstall Complete *\n";
|
||||
echo "************************************\n";
|
||||
|
||||
echo "#StorageServer uninstall:\n";
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config, TRUE);
|
||||
$tr = new Transport($gb);
|
||||
$pr = new Prefs($gb);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
echo "# Uninstall Prefs submodule";
|
||||
$r = $pr->uninstall();
|
||||
if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit; }
|
||||
echo "\n";
|
||||
|
||||
echo "# Uninstall Transport submodule ...";
|
||||
$r = $tr->uninstall();
|
||||
if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit; }
|
||||
echo "\n";
|
||||
|
||||
echo "# Uninstall StorageServer ...\n";
|
||||
$gb->uninstall();
|
||||
echo "#StorageServer uninstall: OK\n";
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
||||
?>
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision: 2458 $
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
|
||||
function camp_db_table_exists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '".$CC_CONFIG['dsn']['database']."' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['transTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['transTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['mdataTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['mdataTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['mdataTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['mdataTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['filesTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['accessTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['permTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['permTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['sessTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['subjTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['smembTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['classTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['classTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['classTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['classTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['cmembTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['cmembTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['cmembTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['cmembTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['structTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['structTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['structTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['structTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['structTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['treeTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['treeTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['treeTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['treeTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['treeTable']."\n";
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision: 2458 $
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['prefTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
|
||||
}
|
||||
|
||||
|
||||
echo " * Removing all media files in ".$CC_CONFIG['storageDir']."...";
|
||||
$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) !== '.') {
|
||||
$filename = $CC_CONFIG['storageDir']."/$entry/$ee";
|
||||
echo " * Removing $filename...";
|
||||
unlink($filename);
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
$dd->close();
|
||||
rmdir($CC_CONFIG['storageDir']."/$entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_object($d)) {
|
||||
$d->close();
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
//echo " * Removing all temporary files in ".$CC_CONFIG['bufferDir']."...";
|
||||
//if (file_exists($CC_CONFIG['bufferDir'])) {
|
||||
// $d = dir($CC_CONFIG['bufferDir']);
|
||||
// while (false !== ($entry = $d->read())) {
|
||||
// if (substr($entry, 0, 1) != '.') {
|
||||
// unlink($CC_CONFIG['bufferDir']."/$entry");
|
||||
// }
|
||||
// }
|
||||
// $d->close();
|
||||
// @rmdir($this->bufferDir);
|
||||
//}
|
||||
//echo "done.\n";
|
||||
|
||||
|
||||
?>
|
|
@ -2,20 +2,20 @@
|
|||
header("Content-type: text/plain");
|
||||
echo "\n# Transport test:\n";
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once '../LocStor.php';
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('../LocStor.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
$tr = new Transport($gb);
|
||||
$ls = new LocStor($dbc, $config);
|
||||
@unlink("{$tr->transDir}/activity.log");
|
||||
@unlink("{$tr->transDir}/debug.log");
|
||||
$ls = new LocStor();
|
||||
@unlink($CC_CONFIG['transDir']."/activity.log");
|
||||
@unlink($CC_CONFIG['transDir']."/debug.log");
|
||||
$tr->_cleanUp();
|
||||
|
||||
$gunid = 'a23456789abcdefb';
|
||||
|
@ -24,25 +24,25 @@ $mdataFile = '../tests/mdata1.xml';
|
|||
|
||||
/* ========== PING ========== */
|
||||
/*
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# Ping: ";
|
||||
$r = $tr->pingToArchive();
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
*/
|
||||
/* ========== STORE ========== */
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# Store: ";
|
||||
$parid = $gb->_getHomeDirIdFromSess($sessid);
|
||||
$oid = $r = $gb->bsPutFile($parid, "xx1.mp3", $mediaFile, $mdataFile, $gunid, 'audioclip');
|
||||
if(PEAR::isError($r)){ if($r->getCode()!=GBERR_GUNID){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }}
|
||||
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
echo "$oid\n";
|
||||
|
||||
/* ========== DELETE FROM HUB ========== */
|
||||
|
@ -76,7 +76,7 @@ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n
|
|||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
/*
|
||||
|
@ -97,14 +97,21 @@ for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++,
|
|||
if($state=='failed') exit(1);
|
||||
|
||||
/* === DELETE LOCAL === */
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "# logout: "; $r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
|
||||
echo `$comm`;
|
||||
/*
|
||||
*/
|
||||
|
||||
|
@ -114,7 +121,7 @@ $comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
|||
|
||||
/* === DOWNLOAD === */
|
||||
echo "# DOWNLOAD test:\n";
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# downloadAudioClipFromHub: ";
|
||||
$r = $gb->downloadFromHub($sessid, $gunid);
|
||||
|
@ -122,7 +129,7 @@ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n
|
|||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
|
||||
|
@ -139,16 +146,16 @@ for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++,
|
|||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
/*
|
||||
*/
|
||||
|
||||
/*
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo"# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
*/
|
||||
|
|
|
@ -2,41 +2,58 @@
|
|||
header("Content-type: text/plain");
|
||||
echo "\n#StorageServer storeWebstream test:\n";
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
#$gunid = "123456789abcdee0";
|
||||
$gunid = "";
|
||||
#$mdataFileLP = '../tests/mdata1.xml';
|
||||
$mdataFileLP = NULL;
|
||||
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
$parid = $gb->_getHomeDirId($sessid);
|
||||
|
||||
echo"# storeWebstream: "; $r = $gb->storeWebstream(
|
||||
echo "# storeWebstream: ";
|
||||
$r = $gb->storeWebstream(
|
||||
$parid, 'test stream', $mdataFileLP, $sessid, $gunid, 'http://localhost/y');
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo ""; var_dump($r);
|
||||
#$id = $gb->idFromGunid($gunid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "";
|
||||
var_dump($r);
|
||||
//$id = BasicStor::IdFromGunid($gunid);
|
||||
$id = $r;
|
||||
|
||||
echo"# getMdata: "; $r = $gb->getMdata($id, $sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "# getMdata: ";
|
||||
$r = $gb->getMdata($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo"# deleteFile: "; $r = $gb->deleteFile($id, $sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "# deleteFile: ";
|
||||
$r = $gb->deleteFile($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "# logout: ";
|
||||
$r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
|
||||
echo "#storeWebstream test: OK.\n\n"
|
||||
|
|
|
@ -152,7 +152,7 @@ class XR_LocStor extends LocStor {
|
|||
if (!$ok) {
|
||||
return $r;
|
||||
}
|
||||
$res = $this->login($r['login'], $r['pass']);
|
||||
$res = Alib::Login($r['login'], $r['pass']);
|
||||
if (PEAR::isError($res)) {
|
||||
return new XML_RPC_Response(0, 804,
|
||||
"xr_login: ".$res->getMessage().
|
||||
|
@ -203,7 +203,7 @@ class XR_LocStor extends LocStor {
|
|||
if (!$ok) {
|
||||
return $r;
|
||||
}
|
||||
$res = $this->logout($r['sessid']);
|
||||
$res = Alib::Logout($r['sessid']);
|
||||
if (PEAR::isError($res)) {
|
||||
return new XML_RPC_Response(0, 803,
|
||||
"xr_logout: ".$res->getMessage().
|
||||
|
@ -1191,7 +1191,7 @@ class XR_LocStor extends LocStor {
|
|||
}
|
||||
$res = $this->playlistIsAvailable($r['sessid'], $r['plid'], TRUE);
|
||||
$ownerId = ($res === TRUE ? NULL : $res);
|
||||
$ownerLogin = (is_null($ownerId) ? NULL : $this->getSubjName($ownerId));
|
||||
$ownerLogin = (is_null($ownerId) ? NULL : Subjects::GetSubjName($ownerId));
|
||||
if (PEAR::isError($res)) {
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_playlistIsAvailable: ".$res->getMessage().
|
||||
|
@ -3221,7 +3221,7 @@ class XR_LocStor extends LocStor {
|
|||
}
|
||||
require_once('../Transport.php');
|
||||
$tr = new Transport($this);
|
||||
$uid = $this->getSessUserId($par['sessid']); // ###
|
||||
$uid = Alib::GetSessUserId($par['sessid']);
|
||||
$res = $tr->downloadFromHub($uid, $par['gunid']);
|
||||
if (PEAR::isError($res)) {
|
||||
$ec0 = intval($res->getCode());
|
||||
|
@ -3540,7 +3540,7 @@ class XR_LocStor extends LocStor {
|
|||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array(
|
||||
'str'=>strtoupper($r['teststring']),
|
||||
'login'=>$this->getSessLogin($r['sessid']),
|
||||
'login' => Alib::GetSessLogin($r['sessid']),
|
||||
'sessid'=>$r['sessid']
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ require_once 'DB.php';
|
|||
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);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new LocStor();
|
||||
|
||||
function http_error($code, $err) {
|
||||
header("HTTP/1.1 $code");
|
||||
|
@ -61,7 +61,7 @@ if(!$tc){ http_error(403, "put.php: Token not valid ($token)."); }
|
|||
|
||||
header("Content-type: text/plain");
|
||||
|
||||
$destfile = "{$config['accessDir']}/{$token}";
|
||||
$destfile = $CC_CONFIG['accessDir']."/{$token}";
|
||||
|
||||
/* PUT data comes in on the input stream */
|
||||
$putdata = @fopen("php://input", "r") or
|
||||
|
|
|
@ -334,24 +334,12 @@ $mdefs = array(
|
|||
/* ======================================================== class definitions */
|
||||
|
||||
class SchedulerPhpClient {
|
||||
/**
|
||||
* Databases object reference
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc = NULL;
|
||||
|
||||
/**
|
||||
* Array with methods description
|
||||
* @var array
|
||||
*/
|
||||
private $mdefs = array();
|
||||
|
||||
/**
|
||||
* Confiduration array from ../conf.php
|
||||
* @var array
|
||||
*/
|
||||
public $config = array();
|
||||
|
||||
/**
|
||||
* XMLRPC client object reference
|
||||
*/
|
||||
|
@ -380,20 +368,18 @@ class SchedulerPhpClient {
|
|||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
*/
|
||||
public function __construct(
|
||||
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
|
||||
public function __construct($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
$this->dbc = $dbc;
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$this->mdefs = $mdefs;
|
||||
$this->config = $config;
|
||||
$this->debug = $debug;
|
||||
$this->verbose = $verbose;
|
||||
$confPrefix = "scheduler";
|
||||
# $confPrefix = "storage";
|
||||
//$confPrefix = "storage";
|
||||
$serverPath =
|
||||
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
|
||||
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
|
||||
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||
"http://{$CC_CONFIG["{$confPrefix}UrlHost"]}:{$CC_CONFIG["{$confPrefix}UrlPort"]}".
|
||||
"{$CC_CONFIG["{$confPrefix}UrlPath"]}/{$CC_CONFIG["{$confPrefix}XMLRPC"]}";
|
||||
//$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||
if ($this->verbose) {
|
||||
echo "serverPath: $serverPath\n";
|
||||
}
|
||||
|
@ -413,19 +399,17 @@ class SchedulerPhpClient {
|
|||
* array, call wrapper callMethod(methodname, parameters) and return its
|
||||
* result.
|
||||
*
|
||||
* @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($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$f = '';
|
||||
foreach ($mdefs as $fn => $farr) {
|
||||
$f .=
|
||||
|
@ -441,10 +425,9 @@ class SchedulerPhpClient {
|
|||
"}\n";
|
||||
# echo $e;
|
||||
if (FALSE === eval($e)) {
|
||||
return $dbc->raiseError("Eval failed");
|
||||
return $CC_DBC->raiseError("Eval failed");
|
||||
}
|
||||
$spc = new SchedulerPhpClientCore(
|
||||
$dbc, $mdefs, $config, $debug, $verbose);
|
||||
$spc = new SchedulerPhpClientCore($mdefs, $debug, $verbose);
|
||||
return $spc;
|
||||
}
|
||||
|
||||
|
@ -506,13 +489,13 @@ class SchedulerPhpClient {
|
|||
|
||||
|
||||
// db object handling:
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_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($mdefs);
|
||||
#$spc = SchedulerPhpClient::factory($mdefs, 0, TRUE);
|
||||
if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; }
|
||||
|
||||
// call of chosen function by name according to key values in $mdefs array:
|
||||
|
|
|
@ -27,17 +27,18 @@
|
|||
*
|
||||
*/
|
||||
|
||||
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');
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$locStor = new LocStor($dbc, $config);
|
||||
$locStor = 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";
|
||||
|
@ -45,21 +46,21 @@ function http_error($code, $err){
|
|||
}
|
||||
|
||||
// parameter checking:
|
||||
if(preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])){
|
||||
if (preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])) {
|
||||
$sessid = $_REQUEST['sessid'];
|
||||
}else{
|
||||
} else {
|
||||
http_error(400, "Error on sessid parameter. ({$_REQUEST['sessid']})");
|
||||
}
|
||||
if(preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])){
|
||||
if (preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])) {
|
||||
$gunid = $_REQUEST['id'];
|
||||
}else{
|
||||
} else {
|
||||
http_error(400, "Error on id parameter. ({$_REQUEST['id']})");
|
||||
}
|
||||
|
||||
// stored file recall:
|
||||
$ac = StoredFile::recallByGunid($locStor, $gunid);
|
||||
if($dbc->isError($ac)){
|
||||
switch($ac->getCode()){
|
||||
if (PEAR::isError($ac)) {
|
||||
switch ($ac->getCode()) {
|
||||
case GBERR_DENY:
|
||||
http_error(403, "403 ".$ac->getMessage());
|
||||
case GBERR_FILENEX:
|
||||
|
@ -69,22 +70,26 @@ if($dbc->isError($ac)){
|
|||
http_error(500, "500 ".$ac->getMessage());
|
||||
}
|
||||
}
|
||||
$lid = $locStor->idFromGunid($gunid);
|
||||
if($dbc->isError($lid)){ http_error(500, $lid->getMessage()); }
|
||||
if(($res = $locStor->_authorize('read', $lid, $sessid)) !== TRUE){
|
||||
$lid = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($lid)) {
|
||||
http_error(500, $lid->getMessage());
|
||||
}
|
||||
if (($res = BasicStor::Authorize('read', $lid, $sessid)) !== TRUE) {
|
||||
http_error(403, "403 Access denied");
|
||||
}
|
||||
$ftype = $locStor->getObjType($lid);
|
||||
if($dbc->isError($ftype)){ http_error(500, $ftype->getMessage()); }
|
||||
switch($ftype){
|
||||
case"audioclip":
|
||||
$ftype = BasicStor::GetObjType($lid);
|
||||
if (PEAR::isError($ftype)) {
|
||||
http_error(500, $ftype->getMessage());
|
||||
}
|
||||
switch ($ftype) {
|
||||
case "audioclip":
|
||||
$realFname = $ac->_getRealRADFname();
|
||||
$mime = $ac->rmd->getMime();
|
||||
header("Content-type: $mime");
|
||||
header("Content-length: ".filesize($realFname));
|
||||
header("Content-length: ".filesize($realFname));
|
||||
readfile($realFname);
|
||||
break;
|
||||
case"webstream":
|
||||
case "webstream":
|
||||
$url = $locStor->bsGetMetadataValue($lid, 'ls:url');
|
||||
if (empty($url)) {
|
||||
http_error(500, "Unable to get ls:url value");
|
||||
|
@ -93,7 +98,7 @@ switch($ftype){
|
|||
header($txt);
|
||||
// echo "$txt\n";
|
||||
break;
|
||||
case"playlist";
|
||||
case "playlist";
|
||||
// $md = $locStor->bsGetMetadata($ac->getId(), $sessid);
|
||||
$md = $locStor->getAudioClip($sessid, $gunid);
|
||||
// header("Content-type: text/xml");
|
||||
|
|
|
@ -54,14 +54,14 @@ function errHndl($errno, $errmsg, $filename, $linenum, $vars)
|
|||
$old_error_handler = set_error_handler("errHndl", E_ALL);
|
||||
|
||||
/* ============================================================= runable code */
|
||||
$r = $dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($r)) {
|
||||
trigger_error("DB::connect: ".$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
trigger_error("DB::connect: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo(),E_USER_ERROR);
|
||||
}
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$locStor = new XR_LocStor($dbc, $config);
|
||||
$locStor = new XR_LocStor();
|
||||
|
||||
$methods = array(
|
||||
'test' => 'Tests toupper and checks sessid, params: '.
|
||||
|
|
|
@ -13,8 +13,8 @@ if($pars[0] == '-s'){
|
|||
$serverPath = array_shift($pars);
|
||||
}else{
|
||||
$serverPath =
|
||||
"http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
||||
"http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}";
|
||||
}
|
||||
$options = array();
|
||||
if($pars[0] == '-o'){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue