Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
5490c9935a
3998 changed files with 3612 additions and 1011803 deletions
|
@ -24,28 +24,26 @@ $CC_CONFIG = array(
|
|||
/* ================================================ storage configuration */
|
||||
|
||||
'apiKey' => array('AAA'),
|
||||
|
||||
|
||||
'baseFilesDir' => __DIR__."/../../files",
|
||||
// main directory for storing binary media files
|
||||
'storageDir' => dirname(__FILE__).'/../../stor',
|
||||
'storageDir' => __DIR__.'/../../files/stor',
|
||||
|
||||
// directory for temporary files
|
||||
'bufferDir' => dirname(__FILE__).'/../../stor/buffer',
|
||||
'bufferDir' => __DIR__.'/../../files/stor/buffer',
|
||||
|
||||
// directory for incomplete transferred files
|
||||
'transDir' => dirname(__FILE__).'/trans',
|
||||
'transDir' => __DIR__.'/../../files/trans',
|
||||
|
||||
// directory for symlinks to accessed files
|
||||
'accessDir' => dirname(__FILE__).'/access',
|
||||
'cronDir' => dirname(__FILE__).'/backend/cron',
|
||||
'accessDir' => __DIR__.'/../../files/access',
|
||||
'cronDir' => __DIR__.'/../../files/cron',
|
||||
|
||||
"rootDir" => __DIR__."/../..",
|
||||
'pearPath' => dirname(__FILE__).'/../../library/pear',
|
||||
'zendPath' => dirname(__FILE__).'/../../library/Zend',
|
||||
'phingPath' => dirname(__FILE__).'/../../library/phing',
|
||||
|
||||
"rootDir" => dirname(__FILE__),
|
||||
"smartyTemplate" => dirname(__FILE__)."/htmlUI/templates",
|
||||
"smartyTemplateCompiled" => dirname(__FILE__)."/htmlUI/templates_c",
|
||||
'pearPath' => dirname(__FILE__).'/3rd_party/php/pear',
|
||||
'zendPath' => dirname(__FILE__).'/3rd_party/php/Zend',
|
||||
'phingPath' => dirname(__FILE__).'/3rd_party/php/phing',
|
||||
'LogPath' => dirname(__FILE__).'/3rd_party/php/Log',
|
||||
|
||||
// secret token cookie name
|
||||
'authCookieName'=> 'campcaster_session_id',
|
||||
|
||||
|
@ -164,30 +162,4 @@ set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
|
|||
.PATH_SEPARATOR.$CC_CONFIG['zendPath']
|
||||
.PATH_SEPARATOR.$old_include_path);
|
||||
|
||||
// Check that all the required directories exist.
|
||||
//foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'cronDir') as $d) {
|
||||
// $test = file_exists($CC_CONFIG[$d]);
|
||||
// if ( $test === FALSE ) {
|
||||
// echo " * Error: directory {$CC_CONFIG[$d]} is missing.\n";
|
||||
// echo " * Please run the install script again.\n";
|
||||
// exit(1);
|
||||
// } else {
|
||||
// $rp = realpath($CC_CONFIG[$d]);
|
||||
// }
|
||||
// $CC_CONFIG[$d] = $rp;
|
||||
//}
|
||||
|
||||
// Check that htmlUI/templates_c has the right permissions
|
||||
//$ss=@stat($CC_CONFIG["smartyTemplateCompiled"]);
|
||||
//$groupOwner = (function_exists('posix_getgrgid'))?@posix_getgrgid($ss['gid']):'';
|
||||
//if (!empty($groupOwner) && ($groupOwner["name"] != $CC_CONFIG["webServerUser"])) {
|
||||
// echo " * Error: Your directory permissions for {$CC_CONFIG['smartyTemplateCompiled']} are not set correctly.<br>\n";
|
||||
// echo " * The group perms need to be set to the web server user, in this case '{$CC_CONFIG['webServerUser']}'.<br>\n";
|
||||
// exit(1);
|
||||
//}
|
||||
//$fileperms=@fileperms($CC_CONFIG["smartyTemplateCompiled"]);
|
||||
//if (!($fileperms & 0x0400)) {
|
||||
// echo " * Error: Sticky bit not set for {$CC_CONFIG['smartyTemplateCompiled']}.<br>\n";
|
||||
// exit(1);
|
||||
//}
|
||||
?>
|
||||
?>
|
|
@ -26,22 +26,22 @@ class AccessRecur {
|
|||
$ppa = new AccessRecur($ls, $sessid);
|
||||
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$plRes = $r;
|
||||
$r = StoredFile::RecallByGunid($plid);
|
||||
if (is_null($r) || PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$ac = $r;
|
||||
$r = $ac->md->genPhpArray();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$pla = $r;
|
||||
$r = $ppa->processPlaylist($pla, $plRes['token']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$plRes['content'] = $r;
|
||||
return $plRes;
|
||||
|
@ -58,14 +58,14 @@ class AccessRecur {
|
|||
WHERE parent=x'{$token}'::bigint
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$arr = $r;
|
||||
foreach ($arr as $i => $item) {
|
||||
extract($item); // token2, gunid
|
||||
$r = BasicStor::GetType($gunid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$ftype = $r;
|
||||
# echo "$ftype/$token2\n";
|
||||
|
@ -73,23 +73,23 @@ class AccessRecur {
|
|||
case "audioclip":
|
||||
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
# var_dump($r);
|
||||
break;
|
||||
break;
|
||||
case "playlist":
|
||||
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
# var_dump($r);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
@ -103,11 +103,11 @@ class AccessRecur {
|
|||
case "playlistElement":
|
||||
$r = $this->processPlaylistElement($ple, $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
// $res = array_merge($res, $r);
|
||||
$res[] = $r;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class AccessRecur {
|
|||
{
|
||||
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
@ -132,48 +132,48 @@ class AccessRecur {
|
|||
case "audioClip":
|
||||
$r = $this->processAudioClip($ac['attrs']['id'], $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
case "playlist":
|
||||
// if(empty($ac['children'])){
|
||||
$r = $this->accessPlaylist($this->ls, $this->sessid,
|
||||
$ac['attrs']['id'], $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
if ($r->getCode() != GBERR_NOTF) {
|
||||
return $r;
|
||||
} else {
|
||||
$r = $this->processPlaylist($ac, $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = array(
|
||||
// if(empty($ac['children'])){
|
||||
$r = $this->accessPlaylist($this->ls, $this->sessid,
|
||||
$ac['attrs']['id'], $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
if ($r->getCode() != GBERR_NOTF) {
|
||||
return $r;
|
||||
} else {
|
||||
$r = $this->processPlaylist($ac, $parent);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = array(
|
||||
'content' => $r,
|
||||
'url' => NULL,
|
||||
'token' => NULL,
|
||||
'chsum' => NULL,
|
||||
'size' => NULL,
|
||||
'warning' => 'inline playlist?',
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
return $r;
|
||||
/*
|
||||
}else{
|
||||
$r = $this->processPlaylist($ac, $parent);
|
||||
if(PEAR::isError($r)) return $r;
|
||||
$res = array(
|
||||
'content' => $r,
|
||||
'url' => NULL,
|
||||
'token' => NULL,
|
||||
'chsum' => NULL,
|
||||
'size' => NULL,
|
||||
'warning' => 'inline playlist',
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
*/
|
||||
break;
|
||||
return $r;
|
||||
/*
|
||||
}else{
|
||||
$r = $this->processPlaylist($ac, $parent);
|
||||
if(PEAR::isError($r)) return $r;
|
||||
$res = array(
|
||||
'content' => $r,
|
||||
'url' => NULL,
|
||||
'token' => NULL,
|
||||
'chsum' => NULL,
|
||||
'size' => NULL,
|
||||
'warning' => 'inline playlist',
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class Alib {
|
|||
}
|
||||
$userid = Subjects::GetSubjId($login);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['sessTable']." (sessid, userid, login, ts)"
|
||||
." VALUES('$sessid', '$userid', '$login', now())";
|
||||
." VALUES('$sessid', '$userid', '$login', now())";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -60,12 +60,12 @@ class Alib {
|
|||
$ct = Alib::CheckAuthToken($sessid);
|
||||
if ($ct === FALSE) {
|
||||
return PEAR::raiseError("Alib::logout: not logged ($sessid)",
|
||||
ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
|
||||
ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
|
||||
} elseif (PEAR::isError($ct)) {
|
||||
return $ct;
|
||||
} else {
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['sessTable']
|
||||
." WHERE sessid='$sessid'";
|
||||
." WHERE sessid='$sessid'";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -85,7 +85,7 @@ class Alib {
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable']
|
||||
." WHERE sessid='$sessid'";
|
||||
." WHERE sessid='$sessid'";
|
||||
$c = $CC_DBC->getOne($sql);
|
||||
return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE ));
|
||||
} //fn checkAuthToken
|
||||
|
@ -97,18 +97,18 @@ class Alib {
|
|||
* @param string $sessid
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
// public function setAuthToken($sessid)
|
||||
// {
|
||||
// $r = $this->checkAuthToken($sessid);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// if (!$r) {
|
||||
// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
|
||||
// }
|
||||
// //$this->sessid = $sessid;
|
||||
// return TRUE;
|
||||
// } // fn setAuthToken
|
||||
// public function setAuthToken($sessid)
|
||||
// {
|
||||
// $r = $this->checkAuthToken($sessid);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// if (!$r) {
|
||||
// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
|
||||
// }
|
||||
// //$this->sessid = $sessid;
|
||||
// return TRUE;
|
||||
// } // fn setAuthToken
|
||||
|
||||
|
||||
/* -------------------------------------------------------- authorization */
|
||||
|
@ -130,7 +130,7 @@ class Alib {
|
|||
global $CC_CONFIG, $CC_DBC;
|
||||
$permid = $CC_DBC->nextId($CC_CONFIG['permSequence']);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['permTable']." (permid, subj, action, obj, type)"
|
||||
." VALUES ($permid, $sid, '$action', $oid, '$type')";
|
||||
." VALUES ($permid, $sid, '$action', $oid, '$type')";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return($r);
|
||||
|
@ -213,85 +213,85 @@ class Alib {
|
|||
*/
|
||||
public static function CheckPerm($sid, $action, $oid=NULL)
|
||||
{
|
||||
return TRUE;
|
||||
// global $CC_DBC;
|
||||
// global $CC_CONFIG;
|
||||
// if (!is_numeric($sid)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
//// if (is_null($oid) or $oid=='') {
|
||||
//// $oid = M2tree::GetRootNode();
|
||||
//// }
|
||||
//// if (PEAR::isError($oid)) {
|
||||
//// return $oid;
|
||||
//// }
|
||||
// if (!is_numeric($oid)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
// // query construction
|
||||
// // shortcuts:
|
||||
// // p: permTable,
|
||||
// // s: subjTable, m smembTable,
|
||||
// // t: treeTable ts: structTable,
|
||||
// // c: classTable, cm: cmembTable
|
||||
// // main query elements:
|
||||
// $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
|
||||
// $q_from = $CC_CONFIG['permTable']." p ";
|
||||
// // joins for solving users/groups:
|
||||
// $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj ";
|
||||
// $q_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
|
||||
// $q_cond = "p.action in('_all', '$action') AND
|
||||
// (s.id=$sid OR m.uid=$sid) ";
|
||||
// // coalesce -1 for higher priority of nongroup rows:
|
||||
// // action DESC order for lower priority of '_all':
|
||||
// $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
|
||||
// $q_flds0 = $q_flds;
|
||||
// $q_from0 = $q_from;
|
||||
// $q_join0 = $q_join;
|
||||
// $q_cond0 = $q_cond;
|
||||
// $q_ordb0 = $q_ordb;
|
||||
// // joins for solving object tree:
|
||||
// $q_flds .= ", t.name, ts.level as tlevel";
|
||||
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['treeTable']." t ON t.id=p.obj ";
|
||||
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=p.obj ";
|
||||
// //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
|
||||
// // action DESC order is hack for lower priority of '_all':
|
||||
// $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
|
||||
// // query by tree:
|
||||
// $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
|
||||
// $r1 = $CC_DBC->getAll($query1);
|
||||
// if (PEAR::isError($r1)) {
|
||||
// return($r1);
|
||||
// }
|
||||
// // if there is row with type='A' on the top => permit
|
||||
// //$AllowedByTree =
|
||||
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
|
||||
// //$DeniedByTree =
|
||||
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
|
||||
//
|
||||
// if (!USE_ALIB_CLASSES) {
|
||||
// return $AllowedbyTree;
|
||||
// }
|
||||
//
|
||||
// // joins for solving object classes:
|
||||
// $q_flds = $q_flds0.", c.cname ";
|
||||
// $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj ";
|
||||
// $q_join .= "LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON cm.cid=p.obj ";
|
||||
// $q_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
|
||||
// $q_ordb = $q_ordb0;
|
||||
// // query by class:
|
||||
// $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
|
||||
// $r2 = $CC_DBC->getAll($query2);
|
||||
// if (PEAR::isError($r2)) {
|
||||
// return $r2;
|
||||
// }
|
||||
// $AllowedByClass =
|
||||
// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
|
||||
// // not used now:
|
||||
// // $DeniedByClass =
|
||||
// // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
|
||||
// $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
|
||||
// return $res;
|
||||
return TRUE;
|
||||
// global $CC_DBC;
|
||||
// global $CC_CONFIG;
|
||||
// if (!is_numeric($sid)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
//// if (is_null($oid) or $oid=='') {
|
||||
//// $oid = M2tree::GetRootNode();
|
||||
//// }
|
||||
//// if (PEAR::isError($oid)) {
|
||||
//// return $oid;
|
||||
//// }
|
||||
// if (!is_numeric($oid)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
// // query construction
|
||||
// // shortcuts:
|
||||
// // p: permTable,
|
||||
// // s: subjTable, m smembTable,
|
||||
// // t: treeTable ts: structTable,
|
||||
// // c: classTable, cm: cmembTable
|
||||
// // main query elements:
|
||||
// $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
|
||||
// $q_from = $CC_CONFIG['permTable']." p ";
|
||||
// // joins for solving users/groups:
|
||||
// $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj ";
|
||||
// $q_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
|
||||
// $q_cond = "p.action in('_all', '$action') AND
|
||||
// (s.id=$sid OR m.uid=$sid) ";
|
||||
// // coalesce -1 for higher priority of nongroup rows:
|
||||
// // action DESC order for lower priority of '_all':
|
||||
// $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
|
||||
// $q_flds0 = $q_flds;
|
||||
// $q_from0 = $q_from;
|
||||
// $q_join0 = $q_join;
|
||||
// $q_cond0 = $q_cond;
|
||||
// $q_ordb0 = $q_ordb;
|
||||
// // joins for solving object tree:
|
||||
// $q_flds .= ", t.name, ts.level as tlevel";
|
||||
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['treeTable']." t ON t.id=p.obj ";
|
||||
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=p.obj ";
|
||||
// //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
|
||||
// // action DESC order is hack for lower priority of '_all':
|
||||
// $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
|
||||
// // query by tree:
|
||||
// $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
|
||||
// $r1 = $CC_DBC->getAll($query1);
|
||||
// if (PEAR::isError($r1)) {
|
||||
// return($r1);
|
||||
// }
|
||||
// // if there is row with type='A' on the top => permit
|
||||
// //$AllowedByTree =
|
||||
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
|
||||
// //$DeniedByTree =
|
||||
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
|
||||
//
|
||||
// if (!USE_ALIB_CLASSES) {
|
||||
// return $AllowedbyTree;
|
||||
// }
|
||||
//
|
||||
// // joins for solving object classes:
|
||||
// $q_flds = $q_flds0.", c.cname ";
|
||||
// $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj ";
|
||||
// $q_join .= "LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON cm.cid=p.obj ";
|
||||
// $q_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
|
||||
// $q_ordb = $q_ordb0;
|
||||
// // query by class:
|
||||
// $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
|
||||
// $r2 = $CC_DBC->getAll($query2);
|
||||
// if (PEAR::isError($r2)) {
|
||||
// return $r2;
|
||||
// }
|
||||
// $AllowedByClass =
|
||||
// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
|
||||
// // not used now:
|
||||
// // $DeniedByClass =
|
||||
// // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
|
||||
// $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
|
||||
// return $res;
|
||||
} // fn CheckPerm
|
||||
|
||||
|
||||
|
@ -326,7 +326,7 @@ class Alib {
|
|||
}
|
||||
if (is_null($uid)){
|
||||
return $CC_DBC->raiseError("Alib::removeSubj: Subj not found ($login)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
$r = Alib::RemovePerm(NULL, $uid);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -354,7 +354,7 @@ class Alib {
|
|||
if (is_null($r)){
|
||||
return PEAR::raiseError("Alib::GetSessLogin:".
|
||||
" invalid session id ($sessid)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
return $r;
|
||||
} // fn GetSessLogin
|
||||
|
@ -377,7 +377,7 @@ class Alib {
|
|||
if (is_null($r)) {
|
||||
return PEAR::raiseError("Alib::getSessUserId:".
|
||||
" invalid session id ($p_sessid)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
return $r;
|
||||
} // fn getSessUserId
|
||||
|
@ -394,7 +394,7 @@ class Alib {
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT s.login, p.* FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
|
||||
." WHERE s.id=p.subj AND p.obj=$id";
|
||||
." WHERE s.id=p.subj AND p.obj=$id";
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn GetObjPerms
|
||||
|
||||
|
@ -409,11 +409,11 @@ class Alib {
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT *"
|
||||
." FROM ".$CC_CONFIG['permTable']
|
||||
." WHERE p.subj=$sid";
|
||||
// $sql = "SELECT t.name, t.type as otype , p.*"
|
||||
// ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
|
||||
// ." WHERE t.id=p.obj AND p.subj=$sid";
|
||||
." FROM ".$CC_CONFIG['permTable']
|
||||
." WHERE p.subj=$sid";
|
||||
// $sql = "SELECT t.name, t.type as otype , p.*"
|
||||
// ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
|
||||
// ." WHERE t.id=p.obj AND p.subj=$sid";
|
||||
$a1 = $CC_DBC->getAll($sql);
|
||||
return $a1;
|
||||
} // fn GetSubjPerms
|
||||
|
@ -463,7 +463,7 @@ class Alib {
|
|||
for ($c = 1; $c > 0; ){
|
||||
$sessid = md5(uniqid(rand()));
|
||||
$sql = "SELECT count(*) FROM ".$CC_CONFIG['sessTable']
|
||||
." WHERE sessid='$sessid'";
|
||||
." WHERE sessid='$sessid'";
|
||||
$c = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($c)) {
|
||||
return $c;
|
||||
|
@ -488,19 +488,19 @@ class Alib {
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT s.login, p.action, p.type"
|
||||
." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
|
||||
." WHERE s.id=p.subj"
|
||||
." ORDER BY p.permid";
|
||||
." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
|
||||
." WHERE s.id=p.subj"
|
||||
." ORDER BY p.permid";
|
||||
$arr = $CC_DBC->getAll($sql);
|
||||
if (PEAR::isError($arr)) {
|
||||
return $arr;
|
||||
}
|
||||
$r = $ind.join(', ', array_map(create_function('$v',
|
||||
'return "{$v[\'login\']}/{$v[\'action\']}/{$v[\'type\']}";'
|
||||
),
|
||||
$arr
|
||||
))."\n";
|
||||
return $r;
|
||||
),
|
||||
$arr
|
||||
))."\n";
|
||||
return $r;
|
||||
} // fn dumpPerms
|
||||
|
||||
|
||||
|
@ -532,16 +532,16 @@ class Alib {
|
|||
$s =& $tdata['subjects'];
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
$perms = array(
|
||||
array($s['root'], '_all', $t['root'], 'A'),
|
||||
array($s['test1'], '_all', $t['pa'], 'A'),
|
||||
array($s['test1'], 'read', $t['s2b'], 'D'),
|
||||
array($s['test2'], 'addChilds', $t['pa'], 'D'),
|
||||
array($s['test2'], 'read', $t['i2'], 'A'),
|
||||
array($s['test2'], 'edit', $t['s1a'], 'A'),
|
||||
array($s['test1'], 'addChilds', $t['s2a'], 'D'),
|
||||
array($s['test1'], 'addChilds', $t['s2c'], 'D'),
|
||||
array($s['gr2'], 'addChilds', $t['i2'], 'A'),
|
||||
array($s['test3'], '_all', $t['t1'], 'D'),
|
||||
array($s['root'], '_all', $t['root'], 'A'),
|
||||
array($s['test1'], '_all', $t['pa'], 'A'),
|
||||
array($s['test1'], 'read', $t['s2b'], 'D'),
|
||||
array($s['test2'], 'addChilds', $t['pa'], 'D'),
|
||||
array($s['test2'], 'read', $t['i2'], 'A'),
|
||||
array($s['test2'], 'edit', $t['s1a'], 'A'),
|
||||
array($s['test1'], 'addChilds', $t['s2a'], 'D'),
|
||||
array($s['test1'], 'addChilds', $t['s2c'], 'D'),
|
||||
array($s['gr2'], 'addChilds', $t['i2'], 'A'),
|
||||
array($s['test3'], '_all', $t['t1'], 'D'),
|
||||
);
|
||||
if (USE_ALIB_CLASSES){
|
||||
$perms[] = array($s['test3'], 'read', $c['cl_sa'], 'D');
|
||||
|
@ -587,14 +587,14 @@ class Alib {
|
|||
return $r;
|
||||
}
|
||||
$test_dump = $r.
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'read',
|
||||
$tdata['tree']['t1']
|
||||
)? 'yes':'no').", ".
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'addChilds',
|
||||
$tdata['tree']['i2']
|
||||
)? 'yes':'no')."\n"
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'read',
|
||||
$tdata['tree']['t1']
|
||||
)? 'yes':'no').", ".
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'addChilds',
|
||||
$tdata['tree']['i2']
|
||||
)? 'yes':'no')."\n"
|
||||
;
|
||||
Alib::RemovePerm($tdata['perms'][1]);
|
||||
Alib::RemovePerm($tdata['perms'][3]);
|
||||
|
|
|
@ -132,7 +132,7 @@ class Backup
|
|||
// get ids (and real filenames) which files match with criteria
|
||||
$srch = $this->gb->localSearch($this->criteria,$this->sessid);
|
||||
if (PEAR::isError($srch)) {
|
||||
return $srch;
|
||||
return $srch;
|
||||
}
|
||||
$this->setIDs($srch);
|
||||
|
||||
|
@ -167,7 +167,7 @@ class Backup
|
|||
|
||||
return array('token'=>$this->token);
|
||||
} else {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ class Backup
|
|||
unlink($this->statusFile);
|
||||
unlink($this->tmpFile);
|
||||
if (is_file($this->tmpName)) {
|
||||
unlink($this->tmpName);
|
||||
unlink($this->tmpName);
|
||||
}
|
||||
return !is_file($this->tmpFile);
|
||||
}
|
||||
|
@ -288,42 +288,42 @@ class Backup
|
|||
*/
|
||||
private function setFilenames()
|
||||
{
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
||||
// }
|
||||
// if (is_array($this->ids)) {
|
||||
// foreach ($this->ids as $i => $item) {
|
||||
// $gunid = $item['gunid'];
|
||||
// // get a stored file object of this gunid
|
||||
// $sf = StoredFile::RecallByGunid($gunid);
|
||||
// if (is_null($sf) || PEAR::isError($sf)) {
|
||||
// return $sf;
|
||||
// }
|
||||
// $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.');
|
||||
// }
|
||||
// // if the file is a playlist then it has only a meta file
|
||||
// if (strtolower($sf->md->format) != 'playlist') {
|
||||
// $this->filenames[] = array(
|
||||
// 'filename' => $sf->getRealFileName(),
|
||||
// 'format' => $sf->md->format
|
||||
// );
|
||||
// }
|
||||
// $this->filenames[] = array(
|
||||
// 'filename' => $sf->getRealMetadataFileName(),
|
||||
// 'format' => $sf->md->format
|
||||
// );
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
|
||||
// }
|
||||
// }
|
||||
// return $this->filenames;
|
||||
// } else {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
|
||||
// return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
|
||||
// }
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
||||
// }
|
||||
// if (is_array($this->ids)) {
|
||||
// foreach ($this->ids as $i => $item) {
|
||||
// $gunid = $item['gunid'];
|
||||
// // get a stored file object of this gunid
|
||||
// $sf = StoredFile::RecallByGunid($gunid);
|
||||
// if (is_null($sf) || PEAR::isError($sf)) {
|
||||
// return $sf;
|
||||
// }
|
||||
// $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.');
|
||||
// }
|
||||
// // if the file is a playlist then it has only a meta file
|
||||
// if (strtolower($sf->md->format) != 'playlist') {
|
||||
// $this->filenames[] = array(
|
||||
// 'filename' => $sf->getRealFileName(),
|
||||
// 'format' => $sf->md->format
|
||||
// );
|
||||
// }
|
||||
// $this->filenames[] = array(
|
||||
// 'filename' => $sf->getRealMetadataFileName(),
|
||||
// 'format' => $sf->md->format
|
||||
// );
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
|
||||
// }
|
||||
// }
|
||||
// return $this->filenames;
|
||||
// } else {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
|
||||
// return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -337,10 +337,10 @@ class Backup
|
|||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n");
|
||||
}
|
||||
$command = dirname(__FILe__)."/../bin/backup.sh"
|
||||
." {$this->tmpDir}"
|
||||
." {$this->tmpFile}"
|
||||
." {$this->statusFile}"
|
||||
." >> {$this->logFile} &";
|
||||
." {$this->tmpDir}"
|
||||
." {$this->tmpFile}"
|
||||
." {$this->statusFile}"
|
||||
." >> {$this->logFile} &";
|
||||
$res = system("$command");
|
||||
sleep(2);
|
||||
if ($this->loglevel=='debug') {
|
||||
|
@ -438,7 +438,7 @@ class Backup
|
|||
{
|
||||
$acc = BasicStor::bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
return $acc;
|
||||
}
|
||||
$this->token = $acc['token'];
|
||||
}
|
||||
|
@ -484,4 +484,4 @@ class Backup
|
|||
}
|
||||
|
||||
} // classs Backup
|
||||
?>
|
||||
?>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -50,7 +50,7 @@ class LocStor extends BasicStor {
|
|||
* {url:writable URL for HTTP PUT, token:access token}
|
||||
*/
|
||||
protected function storeAudioClipOpen($sessid, $gunid, $metadata,
|
||||
$fname, $chsum, $ftype='audioclip')
|
||||
$fname, $chsum, $ftype='audioclip')
|
||||
{
|
||||
// Check the gunid format
|
||||
if (!BasicStor::CheckGunid($gunid)) {
|
||||
|
@ -79,7 +79,7 @@ class LocStor extends BasicStor {
|
|||
if ($storedFile->isAccessed()) {
|
||||
return PEAR::raiseError(
|
||||
'LocStor::storeAudioClipOpen: is accessed'
|
||||
);
|
||||
);
|
||||
}
|
||||
$res = $storedFile->replace($oid, $storedFile->getName(), '', $metadata, 'string');
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -182,7 +182,7 @@ class LocStor extends BasicStor {
|
|||
protected function storeWebstream($sessid, $gunid, $metadata, $fname, $url)
|
||||
{
|
||||
$a = $this->storeAudioClipOpen(
|
||||
$sessid, $gunid, $metadata, $fname, md5(''), 'webstream');
|
||||
$sessid, $gunid, $metadata, $fname, md5(''), 'webstream');
|
||||
if (PEAR::isError($a)) {
|
||||
return $a;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class LocStor extends BasicStor {
|
|||
if (is_null($id) || !$ex) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
|
||||
GBERR_NOTF
|
||||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
|
@ -304,8 +304,8 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function downloadMetadataOpen($sessid, $gunid)
|
||||
{
|
||||
// $res = $this->existsAudioClip($sessid, $gunid);
|
||||
// if(PEAR::isError($res)) return $res;
|
||||
// $res = $this->existsAudioClip($sessid, $gunid);
|
||||
// if(PEAR::isError($res)) return $res;
|
||||
$media = StoredFile::RecallByGunid($gunid)
|
||||
$id = $media->getGunid();
|
||||
if (is_null($id)) {
|
||||
|
@ -414,7 +414,7 @@ class LocStor extends BasicStor {
|
|||
* </li>
|
||||
* </ul>
|
||||
* @see BasicStor::localSearch
|
||||
*/
|
||||
*/
|
||||
public function searchMetadata($sessid, $criteria)
|
||||
{
|
||||
if (($res = BasicStor::Authorize('read', $this->storId, $sessid)) !== TRUE) {
|
||||
|
@ -592,7 +592,7 @@ class LocStor extends BasicStor {
|
|||
if ($ex) {
|
||||
return PEAR::raiseError(
|
||||
'LocStor::createPlaylist: already exists'
|
||||
);
|
||||
);
|
||||
}
|
||||
$tmpFname = uniqid('');
|
||||
if (($res = BasicStor::Authorize('write', null, $sessid)) !== TRUE) {
|
||||
|
@ -608,7 +608,7 @@ class LocStor extends BasicStor {
|
|||
$fname = "newFile.xml";
|
||||
}
|
||||
$storedFile->setName($fname);
|
||||
$storedFile->setState('ready');
|
||||
$storedFile->setState('ready');
|
||||
$storedFile->setMime('application/smil');
|
||||
return $storedFile->gunid;
|
||||
}
|
||||
|
@ -634,12 +634,12 @@ class LocStor extends BasicStor {
|
|||
if (!$ex) {
|
||||
return PEAR::raiseError(
|
||||
'LocStor::editPlaylist: playlist not exists'
|
||||
);
|
||||
);
|
||||
}
|
||||
if ($this->isEdited($playlistId) !== FALSE) {
|
||||
return PEAR::raiseError(
|
||||
'LocStor::editPlaylist: playlist already edited'
|
||||
);
|
||||
);
|
||||
}
|
||||
$storedFile =& StoredFile::RecallByGunid($playlistId);
|
||||
if (is_null($storedFile) || PEAR::isError($storedFile)) {
|
||||
|
@ -753,7 +753,7 @@ class LocStor extends BasicStor {
|
|||
}
|
||||
return PEAR::raiseError(
|
||||
'LocStor::deletePlaylist: playlist not exists',
|
||||
GBERR_FILENEX
|
||||
GBERR_FILENEX
|
||||
);
|
||||
}
|
||||
$storedFile =& StoredFile::RecallByGunid($playlistId);
|
||||
|
@ -791,32 +791,32 @@ class LocStor extends BasicStor {
|
|||
* }
|
||||
*/
|
||||
public function accessPlaylist($sessid, $playlistId, $recursive=FALSE, $parent='0')
|
||||
// {
|
||||
// if ($recursive) {
|
||||
// require_once("AccessRecur.php");
|
||||
// $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// return $r;
|
||||
// }
|
||||
// $ex = $this->existsPlaylist($sessid, $playlistId);
|
||||
// if (PEAR::isError($ex)) {
|
||||
// return $ex;
|
||||
// }
|
||||
// if (!$ex) {
|
||||
// return PEAR::raiseError(
|
||||
// "LocStor::accessPlaylist: playlist not found ($playlistId)",
|
||||
// GBERR_NOTF
|
||||
// );
|
||||
// }
|
||||
// $id = BasicStor::IdFromGunid($playlistId);
|
||||
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// $res = $this->bsOpenDownload($id, 'metadata', $parent);
|
||||
// #unset($res['filename']);
|
||||
// return $res;
|
||||
// {
|
||||
// if ($recursive) {
|
||||
// require_once("AccessRecur.php");
|
||||
// $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// return $r;
|
||||
// }
|
||||
// $ex = $this->existsPlaylist($sessid, $playlistId);
|
||||
// if (PEAR::isError($ex)) {
|
||||
// return $ex;
|
||||
// }
|
||||
// if (!$ex) {
|
||||
// return PEAR::raiseError(
|
||||
// "LocStor::accessPlaylist: playlist not found ($playlistId)",
|
||||
// GBERR_NOTF
|
||||
// );
|
||||
// }
|
||||
// $id = BasicStor::IdFromGunid($playlistId);
|
||||
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// $res = $this->bsOpenDownload($id, 'metadata', $parent);
|
||||
// #unset($res['filename']);
|
||||
// return $res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -983,7 +983,7 @@ class LocStor extends BasicStor {
|
|||
if (!$ex) {
|
||||
return PEAR::raiseError(
|
||||
'LocStor::playlistIsAvailable: playlist not exists'
|
||||
);
|
||||
);
|
||||
}
|
||||
$ie = $this->isEdited($playlistId);
|
||||
if ($ie === FALSE) {
|
||||
|
@ -1159,7 +1159,7 @@ class LocStor extends BasicStor {
|
|||
if ($token != '123456789abcdeff') {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::renderPlaylistToRSSClose: invalid token"
|
||||
);
|
||||
);
|
||||
}
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
unlink($fakeFile);
|
||||
|
@ -1192,7 +1192,7 @@ class LocStor extends BasicStor {
|
|||
if ($r === FALSE) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::createBackupOpen: false returned from Backup"
|
||||
);
|
||||
);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
@ -1351,12 +1351,12 @@ class LocStor extends BasicStor {
|
|||
* status: string - working | fault | success
|
||||
*/
|
||||
protected function restoreBackupClose($token) {
|
||||
require_once('Restore.php');
|
||||
$rs = new Restore($this);
|
||||
if (PEAR::isError($rs)) {
|
||||
return $rs;
|
||||
}
|
||||
return $rs->closeRestore($token);
|
||||
require_once('Restore.php');
|
||||
$rs = new Restore($this);
|
||||
if (PEAR::isError($rs)) {
|
||||
return $rs;
|
||||
}
|
||||
return $rs->closeRestore($token);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1387,11 +1387,11 @@ class LocStor extends BasicStor {
|
|||
{
|
||||
$owner = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($owner)) {
|
||||
return $owner;
|
||||
return $owner;
|
||||
}
|
||||
$res = $this->bsOpenPut($chsum, NULL, $owner);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
return array('url'=>$res['url'], 'token'=>$res['token']);
|
||||
}
|
||||
|
@ -1412,7 +1412,7 @@ class LocStor extends BasicStor {
|
|||
{
|
||||
$res = $this->bsClosePut($token);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
extract($res); // fname, owner
|
||||
switch ($trtype) {
|
||||
|
@ -1420,11 +1420,11 @@ class LocStor extends BasicStor {
|
|||
$mdtoken = $pars['mdpdtoken'];
|
||||
$res = $this->bsClosePut($mdtoken);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
$mdfname = $res['fname'];
|
||||
if ($gunid == '') {
|
||||
$gunid = NULL;
|
||||
$gunid = NULL;
|
||||
}
|
||||
$values = array(
|
||||
"filename" => $pars['name'],
|
||||
|
@ -1432,45 +1432,45 @@ class LocStor extends BasicStor {
|
|||
"metadata" => $mdfname,
|
||||
"gunid" => $pars['gunid'],
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
$res = $storedFile->getId();
|
||||
@unlink($fname);
|
||||
@unlink($mdfname);
|
||||
break;
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
$res = $storedFile->getId();
|
||||
@unlink($fname);
|
||||
@unlink($mdfname);
|
||||
break;
|
||||
case "playlist":
|
||||
if ($gunid == '') {
|
||||
$gunid = NULL;
|
||||
$gunid = NULL;
|
||||
}
|
||||
$values = array(
|
||||
"filename" => $pars['name'],
|
||||
"metadata" => $fname,
|
||||
"gunid" => $pars['gunid'],
|
||||
"filetype" => "playlist"
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
$res = $storedFile->getId();
|
||||
@unlink($fname);
|
||||
break;
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
$res = $storedFile->getId();
|
||||
@unlink($fname);
|
||||
break;
|
||||
case "playlistPkg":
|
||||
$chsum = md5_file($fname);
|
||||
// importPlaylistOpen:
|
||||
$res = $this->bsOpenPut($chsum, NULL, $owner);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
$dest = $res['fname'];
|
||||
$token = $res['token'];
|
||||
copy($fname, $dest);
|
||||
$r = $this->importPlaylistClose($token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
@unlink($fname);
|
||||
return $r;
|
||||
|
@ -1481,14 +1481,14 @@ class LocStor extends BasicStor {
|
|||
@unlink($fname);
|
||||
$results = $this->localSearch($criteria);
|
||||
if (PEAR::isError($results)) {
|
||||
return $results;
|
||||
return $results;
|
||||
}
|
||||
$realfile = tempnam($this->accessDir, 'searchjob_');
|
||||
@chmod($realfile, 0660);
|
||||
$len = file_put_contents($realfile, serialize($results));
|
||||
$acc = BasicStor::bsAccess($realfile, '', NULL, 'download');
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
return $acc;
|
||||
}
|
||||
$url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
$chsum = md5_file($realfile);
|
||||
|
@ -1523,227 +1523,227 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
function downloadOpen($sessid, $trtype, $pars=array())
|
||||
{
|
||||
// global $CC_CONFIG;
|
||||
// switch ($trtype) {
|
||||
// case "unknown":
|
||||
// case "audioclip":
|
||||
// case "metadata":
|
||||
// case "playlist":
|
||||
// case "playlistPkg":
|
||||
// if (!isset($pars['gunid'])) {
|
||||
// return PEAR::raiseError("Archive::downloadOpen: gunid not set");
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// $gunid = $pars['gunid'];
|
||||
// // resolve trtype by object type:
|
||||
// if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
|
||||
// $media = StoredFile::RecallByGunid($gunid);
|
||||
// $trtype2 = $media->getType();
|
||||
// if (PEAR::isError($trtype2)) {
|
||||
// return $trtype2;
|
||||
// }
|
||||
// // required with content:
|
||||
// $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
|
||||
// 'playlistPkg' : $trtype2);
|
||||
// //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
|
||||
// }
|
||||
// switch ($trtype) {
|
||||
// case "audioclip":
|
||||
// $res = $this->downloadRawAudioDataOpen($sessid, $gunid);
|
||||
// break;
|
||||
// case "metadata":
|
||||
// $res = $this->downloadMetadataOpen($sessid, $gunid);
|
||||
// break;
|
||||
// case "playlist":
|
||||
// $res = $this->accessPlaylist($sessid, $gunid);
|
||||
// break;
|
||||
// case "playlistPkg":
|
||||
// $res = $this->bsExportPlaylistOpen($gunid);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
// $plfpath = "$tmpn.lspl";
|
||||
// copy($res['fname'], $plfpath);
|
||||
// $res = $this->bsExportPlaylistClose($res['token']);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $fname = "transported_playlist.lspl";
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
|
||||
// if (PEAR::isError($acc)) {
|
||||
// return $acc;
|
||||
// }
|
||||
// $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
// $chsum = md5_file($plfpath);
|
||||
// $size = filesize($plfpath);
|
||||
// $res = array(
|
||||
// 'url'=>$url, 'token'=>$acc['token'],
|
||||
// 'chsum'=>$chsum, 'size'=>$size,
|
||||
// 'filename'=>$fname
|
||||
// );
|
||||
// break;
|
||||
// case "searchjob":
|
||||
// $res = $pars;
|
||||
// break;
|
||||
// case "file":
|
||||
// $res = array();
|
||||
// break;
|
||||
// default:
|
||||
// return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
|
||||
// }
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// switch ($trtype) {
|
||||
// case "audioclip":
|
||||
// case "metadata":
|
||||
// case "playlist":
|
||||
// case "playlistPkg":
|
||||
// $f = StoredFile::RecallByGunid($gunid);
|
||||
// $title = $f->getTitle();
|
||||
// break;
|
||||
// case "searchjob":
|
||||
// $title = 'searchjob';
|
||||
// break;
|
||||
// case "file":
|
||||
// $title = 'regular file';
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
// $res['title'] = $title;
|
||||
// $res['trtype'] = $trtype;
|
||||
// return $res;
|
||||
}
|
||||
// global $CC_CONFIG;
|
||||
// switch ($trtype) {
|
||||
// case "unknown":
|
||||
// case "audioclip":
|
||||
// case "metadata":
|
||||
// case "playlist":
|
||||
// case "playlistPkg":
|
||||
// if (!isset($pars['gunid'])) {
|
||||
// return PEAR::raiseError("Archive::downloadOpen: gunid not set");
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// $gunid = $pars['gunid'];
|
||||
// // resolve trtype by object type:
|
||||
// if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
|
||||
// $media = StoredFile::RecallByGunid($gunid);
|
||||
// $trtype2 = $media->getType();
|
||||
// if (PEAR::isError($trtype2)) {
|
||||
// return $trtype2;
|
||||
// }
|
||||
// // required with content:
|
||||
// $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
|
||||
// 'playlistPkg' : $trtype2);
|
||||
// //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
|
||||
// }
|
||||
// switch ($trtype) {
|
||||
// case "audioclip":
|
||||
// $res = $this->downloadRawAudioDataOpen($sessid, $gunid);
|
||||
// break;
|
||||
// case "metadata":
|
||||
// $res = $this->downloadMetadataOpen($sessid, $gunid);
|
||||
// break;
|
||||
// case "playlist":
|
||||
// $res = $this->accessPlaylist($sessid, $gunid);
|
||||
// break;
|
||||
// case "playlistPkg":
|
||||
// $res = $this->bsExportPlaylistOpen($gunid);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
// $plfpath = "$tmpn.lspl";
|
||||
// copy($res['fname'], $plfpath);
|
||||
// $res = $this->bsExportPlaylistClose($res['token']);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $fname = "transported_playlist.lspl";
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
|
||||
// if (PEAR::isError($acc)) {
|
||||
// return $acc;
|
||||
// }
|
||||
// $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
// $chsum = md5_file($plfpath);
|
||||
// $size = filesize($plfpath);
|
||||
// $res = array(
|
||||
// 'url'=>$url, 'token'=>$acc['token'],
|
||||
// 'chsum'=>$chsum, 'size'=>$size,
|
||||
// 'filename'=>$fname
|
||||
// );
|
||||
// break;
|
||||
// case "searchjob":
|
||||
// $res = $pars;
|
||||
// break;
|
||||
// case "file":
|
||||
// $res = array();
|
||||
// break;
|
||||
// default:
|
||||
// return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
|
||||
// }
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// switch ($trtype) {
|
||||
// case "audioclip":
|
||||
// case "metadata":
|
||||
// case "playlist":
|
||||
// case "playlistPkg":
|
||||
// $f = StoredFile::RecallByGunid($gunid);
|
||||
// $title = $f->getTitle();
|
||||
// break;
|
||||
// case "searchjob":
|
||||
// $title = 'searchjob';
|
||||
// break;
|
||||
// case "file":
|
||||
// $title = 'regular file';
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
// $res['title'] = $title;
|
||||
// $res['trtype'] = $trtype;
|
||||
// return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close download transport
|
||||
*
|
||||
* @param string $token
|
||||
* transport token
|
||||
* @param string $trtype
|
||||
* transport type
|
||||
* @return array
|
||||
* hasharray with:
|
||||
* url string: writable URL
|
||||
* token string: PUT token
|
||||
*/
|
||||
function downloadClose($token, $trtype)
|
||||
{
|
||||
switch ($trtype) {
|
||||
case "audioclip":
|
||||
$res = $this->downloadRawAudioDataClose($token);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return $res;
|
||||
case "metadata":
|
||||
$res = $this->downloadMetadataClose($token);
|
||||
return $res;
|
||||
case "playlist":
|
||||
$res = $this->releasePlaylist(NULL/*$sessid*/, $token);
|
||||
return $res;
|
||||
case "playlistPkg":
|
||||
$res = BasicStor::bsRelease($token, 'download');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$realFname = $r['realFname'];
|
||||
@unlink($realFname);
|
||||
if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) {
|
||||
list(,$tmpn) = $va;
|
||||
$tmpn = $CC_CONFIG['transDir']."/$tmpn";
|
||||
if (file_exists($tmpn)) {
|
||||
@unlink($tmpn);
|
||||
/**
|
||||
* Close download transport
|
||||
*
|
||||
* @param string $token
|
||||
* transport token
|
||||
* @param string $trtype
|
||||
* transport type
|
||||
* @return array
|
||||
* hasharray with:
|
||||
* url string: writable URL
|
||||
* token string: PUT token
|
||||
*/
|
||||
function downloadClose($token, $trtype)
|
||||
{
|
||||
switch ($trtype) {
|
||||
case "audioclip":
|
||||
$res = $this->downloadRawAudioDataClose($token);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
case "searchjob":
|
||||
$res = BasicStor::bsRelease($token, 'download');
|
||||
return $res;
|
||||
case "file":
|
||||
return array();
|
||||
default:
|
||||
return PEAR::raiseError("Archive::downloadClose: NotImpl ($trtype)");
|
||||
return $res;
|
||||
case "metadata":
|
||||
$res = $this->downloadMetadataClose($token);
|
||||
return $res;
|
||||
case "playlist":
|
||||
$res = $this->releasePlaylist(NULL/*$sessid*/, $token);
|
||||
return $res;
|
||||
case "playlistPkg":
|
||||
$res = BasicStor::bsRelease($token, 'download');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$realFname = $r['realFname'];
|
||||
@unlink($realFname);
|
||||
if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) {
|
||||
list(,$tmpn) = $va;
|
||||
$tmpn = $CC_CONFIG['transDir']."/$tmpn";
|
||||
if (file_exists($tmpn)) {
|
||||
@unlink($tmpn);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
case "searchjob":
|
||||
$res = BasicStor::bsRelease($token, 'download');
|
||||
return $res;
|
||||
case "file":
|
||||
return array();
|
||||
default:
|
||||
return PEAR::raiseError("Archive::downloadClose: NotImpl ($trtype)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare hub initiated transport
|
||||
*
|
||||
* @param string $target
|
||||
* hostname of transport target
|
||||
* @param string $trtype
|
||||
* transport type
|
||||
* @param string $direction
|
||||
* 'up' | 'down'
|
||||
* @param array $pars
|
||||
* transport parameters
|
||||
* @return mixed
|
||||
*/
|
||||
function prepareHubInitiatedTransfer(
|
||||
/**
|
||||
* Prepare hub initiated transport
|
||||
*
|
||||
* @param string $target
|
||||
* hostname of transport target
|
||||
* @param string $trtype
|
||||
* transport type
|
||||
* @param string $direction
|
||||
* 'up' | 'down'
|
||||
* @param array $pars
|
||||
* transport parameters
|
||||
* @return mixed
|
||||
*/
|
||||
function prepareHubInitiatedTransfer(
|
||||
$target, $trtype='file', $direction='up',$pars=array())
|
||||
{
|
||||
$tr = new Transport($this);
|
||||
$trec = TransportRecord::create($tr, $trtype, $direction,
|
||||
{
|
||||
$tr = new Transport($this);
|
||||
$trec = TransportRecord::create($tr, $trtype, $direction,
|
||||
array_merge($pars, array('target'=>$target)));
|
||||
if (PEAR::isError($trec)) {
|
||||
return $trec;
|
||||
if (PEAR::isError($trec)) {
|
||||
return $trec;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List hub initiated transports
|
||||
*
|
||||
* @param string $target
|
||||
* hostname of transport target
|
||||
* @param string $direction
|
||||
* 'up' | 'down'
|
||||
* @param string $trtok
|
||||
* transport token
|
||||
* @return mixed
|
||||
*/
|
||||
function listHubInitiatedTransfers(
|
||||
/**
|
||||
* List hub initiated transports
|
||||
*
|
||||
* @param string $target
|
||||
* hostname of transport target
|
||||
* @param string $direction
|
||||
* 'up' | 'down'
|
||||
* @param string $trtok
|
||||
* transport token
|
||||
* @return mixed
|
||||
*/
|
||||
function listHubInitiatedTransfers(
|
||||
$target=NULL, $direction=NULL, $trtok=NULL)
|
||||
{
|
||||
$tr = new Transport($this);
|
||||
$res = $tr->getTransports($direction, $target, $trtok);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set state of hub initiated transport
|
||||
*
|
||||
* @param string $target
|
||||
* hostname of transport target
|
||||
* @param string $trtok
|
||||
* transport token
|
||||
* @param string $state
|
||||
* transport state
|
||||
* @return TransportRecord|PEAR_Error
|
||||
*/
|
||||
function setHubInitiatedTransfer($target, $trtok, $state)
|
||||
{
|
||||
$tr = new Transport($this);
|
||||
$trec = TransportRecord::recall($tr, $trtok);
|
||||
if (PEAR::isError($trec)) {
|
||||
return $trec;
|
||||
{
|
||||
$tr = new Transport($this);
|
||||
$res = $tr->getTransports($direction, $target, $trtok);
|
||||
return $res;
|
||||
}
|
||||
$r = $trec->setState($state);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $trec;
|
||||
}
|
||||
|
||||
/* ==================================================== auxiliary methods */
|
||||
|
||||
/**
|
||||
* Set state of hub initiated transport
|
||||
*
|
||||
* @param string $target
|
||||
* hostname of transport target
|
||||
* @param string $trtok
|
||||
* transport token
|
||||
* @param string $state
|
||||
* transport state
|
||||
* @return TransportRecord|PEAR_Error
|
||||
*/
|
||||
function setHubInitiatedTransfer($target, $trtok, $state)
|
||||
{
|
||||
$tr = new Transport($this);
|
||||
$trec = TransportRecord::recall($tr, $trtok);
|
||||
if (PEAR::isError($trec)) {
|
||||
return $trec;
|
||||
}
|
||||
$r = $trec->setState($state);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $trec;
|
||||
}
|
||||
|
||||
/* ==================================================== auxiliary methods */
|
||||
|
||||
} // class LocStor
|
||||
?>
|
|
@ -44,19 +44,19 @@ class Prefs {
|
|||
{
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
return $subjid;
|
||||
}
|
||||
if (is_null($subjid)) {
|
||||
return PEAR::raiseError("Prefs::loadPref: invalid session id",
|
||||
GBERR_SESS);
|
||||
GBERR_SESS);
|
||||
}
|
||||
$val = $this->readVal($subjid, $key);
|
||||
if (PEAR::isError($val)) {
|
||||
return $val;
|
||||
return $val;
|
||||
}
|
||||
if ($val === FALSE) {
|
||||
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
|
||||
GBERR_PREF);
|
||||
GBERR_PREF);
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
@ -77,20 +77,19 @@ class Prefs {
|
|||
{
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
return $subjid;
|
||||
}
|
||||
if (is_null($subjid)) {
|
||||
return PEAR::raiseError("Prefs::savePref: invalid session id",
|
||||
GBERR_SESS);
|
||||
return PEAR::raiseError("Prefs::savePref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$r = $this->update($subjid, $key, $value);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
if ($r === FALSE) {
|
||||
$r = $this->insert($subjid, $key, $value);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -110,19 +109,17 @@ class Prefs {
|
|||
{
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
return $subjid;
|
||||
}
|
||||
if (is_null($subjid)) {
|
||||
return PEAR::raiseError("Prefs::delPref: invalid session id",
|
||||
GBERR_SESS);
|
||||
return PEAR::raiseError("Prefs::delPref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$r = $this->delete($subjid, $key);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
if ($r === FALSE) {
|
||||
return PEAR::raiseError("Prefs::delPref: invalid preference key",
|
||||
GBERR_PREF);
|
||||
return PEAR::raiseError("Prefs::delPref: invalid preference key", GBERR_PREF);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -146,7 +143,7 @@ class Prefs {
|
|||
// if sessid is would be used here fix Transport::cronCallMethod !
|
||||
$subjid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
return $subjid;
|
||||
}
|
||||
if (is_null($subjid)) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -154,7 +151,7 @@ class Prefs {
|
|||
}
|
||||
$val = $this->readVal($subjid, $key);
|
||||
if (PEAR::isError($val)) {
|
||||
return $val;
|
||||
return $val;
|
||||
}
|
||||
if ($val === FALSE) {
|
||||
if ($returnErrorIfKeyNotExists) {
|
||||
|
@ -185,7 +182,7 @@ class Prefs {
|
|||
{
|
||||
$uid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
return $uid;
|
||||
}
|
||||
if (is_null($uid)) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -193,7 +190,7 @@ class Prefs {
|
|||
}
|
||||
$gid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
return $gid;
|
||||
}
|
||||
if (is_null($gid)) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -201,7 +198,7 @@ class Prefs {
|
|||
}
|
||||
$memb = Subjects::IsMemberOf($uid, $gid);
|
||||
if (PEAR::isError($memb)) {
|
||||
return $memb;
|
||||
return $memb;
|
||||
}
|
||||
if (!$memb) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -209,12 +206,12 @@ class Prefs {
|
|||
}
|
||||
$r = $this->update($gid, $key, $value);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
if ($r === FALSE) {
|
||||
$r = $this->insert($gid, $key, $value);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -235,7 +232,7 @@ class Prefs {
|
|||
{
|
||||
$uid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
return $uid;
|
||||
}
|
||||
if (is_null($uid)) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -243,7 +240,7 @@ class Prefs {
|
|||
}
|
||||
$gid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
return $gid;
|
||||
}
|
||||
if (is_null($gid)) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -251,7 +248,7 @@ class Prefs {
|
|||
}
|
||||
$memb = Subjects::IsMemberOf($uid, $gid);
|
||||
if (PEAR::isError($memb)) {
|
||||
return $memb;
|
||||
return $memb;
|
||||
}
|
||||
if (!$memb) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -259,7 +256,7 @@ class Prefs {
|
|||
}
|
||||
$r = $this->delete($gid, $key);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
if ($r === FALSE) {
|
||||
return PEAR::raiseError(
|
||||
|
@ -287,7 +284,7 @@ class Prefs {
|
|||
global $CC_CONFIG, $CC_DBC;
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['prefSequence']);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
return $id;
|
||||
}
|
||||
$r = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['prefTable']."
|
||||
|
@ -296,7 +293,7 @@ class Prefs {
|
|||
($id, $subjid, '$keystr', '$valstr')
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
@ -320,10 +317,10 @@ class Prefs {
|
|||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($val)) {
|
||||
return $val;
|
||||
return $val;
|
||||
}
|
||||
if (is_null($val)) {
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
@ -345,10 +342,10 @@ class Prefs {
|
|||
WHERE subjid=$subjid
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
if (is_null($res)) {
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
@ -374,10 +371,10 @@ class Prefs {
|
|||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
if ($CC_DBC->affectedRows() < 1) {
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -400,10 +397,10 @@ class Prefs {
|
|||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
if ($CC_DBC->affectedRows() < 1) {
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -422,7 +419,7 @@ class Prefs {
|
|||
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
|
||||
$r = savePref($sessid, $testKey, $testVal);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$val = loadPref($sessid, $testKey);
|
||||
if ($val != $testVal) {
|
||||
|
@ -431,7 +428,7 @@ class Prefs {
|
|||
}
|
||||
$r = savePref($sessid, $testKey, '');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$val = loadPref($sessid, $testKey);
|
||||
if ($val != $testVal) {
|
||||
|
|
|
@ -35,12 +35,12 @@ class Renderer
|
|||
// recall playlist:
|
||||
$pl = StoredFile::RecallByGunid($plid);
|
||||
if (is_null($pl) || PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
return $pl;
|
||||
}
|
||||
// smil export:
|
||||
$smil = $pl->outputToSmil();
|
||||
if (PEAR::isError($smil)) {
|
||||
return $smil;
|
||||
return $smil;
|
||||
}
|
||||
// temporary file for smil:
|
||||
$tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_');
|
||||
|
@ -56,7 +56,7 @@ class Renderer
|
|||
// open access to output file: /*gunid*/ /*parent*/
|
||||
$acc = BasicStor::bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
return $acc;
|
||||
}
|
||||
extract($acc);
|
||||
$statf = Renderer::getStatusFile($gb, $token);
|
||||
|
@ -70,7 +70,7 @@ class Renderer
|
|||
if ($res === FALSE) {
|
||||
return PEAR::raiseError(
|
||||
'Renderer::rnRender2File: Error running renderer'
|
||||
);
|
||||
);
|
||||
}
|
||||
return array('token'=>$token);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class Renderer
|
|||
if (!file_exists($statf)) {
|
||||
return PEAR::raiseError(
|
||||
'Renderer::rnRender2FileCheck: Invalid token'
|
||||
);
|
||||
);
|
||||
}
|
||||
$status = trim(file_get_contents($statf));
|
||||
$url = Renderer::getUrl($gb, $token);
|
||||
|
@ -142,7 +142,7 @@ class Renderer
|
|||
global $CC_CONFIG;
|
||||
$r = BasicStor::bsRelease($token, 'render');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$realOgg = $r['realFname'];
|
||||
$tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT);
|
||||
|
@ -171,7 +171,7 @@ class Renderer
|
|||
{
|
||||
$r = Renderer::rnRender2FileCheck($gb, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$status = $r['status'];
|
||||
$res = array('status' => $status, 'gunid'=>'NULL');
|
||||
|
@ -182,7 +182,7 @@ class Renderer
|
|||
case "success":
|
||||
$r = Renderer::rnRender2StorageCore($gb, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$res['gunid'] = $r['gunid'];
|
||||
break;
|
||||
|
@ -205,36 +205,36 @@ class Renderer
|
|||
*/
|
||||
function rnRender2StorageCore(&$gb, $token)
|
||||
{
|
||||
// $r = BasicStor::bsRelease($token, 'render');
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// $realOgg = $r['realFname'];
|
||||
// $owner = $r['owner'];
|
||||
// $gunid = $r['gunid'];
|
||||
// $fileName = 'rendered_playlist';
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// if (PEAR::isError($id)) {
|
||||
// return $id;
|
||||
// }
|
||||
// $mdata = '';
|
||||
// foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
|
||||
// $val = $gb->bsGetMetadataValue($id, $item);
|
||||
// $mdata .= " <$item>$val</$item>\n";
|
||||
// }
|
||||
// $mdata = "<audioClip>\n <metadata>\n$mdata </metadata>\n</audioClip>\n";
|
||||
// //$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
|
||||
// $values = array(
|
||||
// "filename" => $fileName,
|
||||
// "filepath" => $realOgg,
|
||||
// "metadata" => $mdata,
|
||||
// "filetype" => "audioclip"
|
||||
// );
|
||||
// $storedFile = $gb->bsPutFile($values);
|
||||
// if (PEAR::isError($storedFile)) {
|
||||
// return $storedFile;
|
||||
// }
|
||||
// return array('gunid' => $storedFile->getGunid());
|
||||
// $r = BasicStor::bsRelease($token, 'render');
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// $realOgg = $r['realFname'];
|
||||
// $owner = $r['owner'];
|
||||
// $gunid = $r['gunid'];
|
||||
// $fileName = 'rendered_playlist';
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// if (PEAR::isError($id)) {
|
||||
// return $id;
|
||||
// }
|
||||
// $mdata = '';
|
||||
// foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
|
||||
// $val = $gb->bsGetMetadataValue($id, $item);
|
||||
// $mdata .= " <$item>$val</$item>\n";
|
||||
// }
|
||||
// $mdata = "<audioClip>\n <metadata>\n$mdata </metadata>\n</audioClip>\n";
|
||||
// //$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
|
||||
// $values = array(
|
||||
// "filename" => $fileName,
|
||||
// "filepath" => $realOgg,
|
||||
// "metadata" => $mdata,
|
||||
// "filetype" => "audioclip"
|
||||
// );
|
||||
// $storedFile = $gb->bsPutFile($values);
|
||||
// if (PEAR::isError($storedFile)) {
|
||||
// return $storedFile;
|
||||
// }
|
||||
// return array('gunid' => $storedFile->getGunid());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class Restore {
|
|||
$this->token = null;
|
||||
$this->logFile = $CC_CONFIG['bufferDir'].'/'.$this->ACCESS_TYPE.'.log';
|
||||
if ($this->loglevel == 'debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,9 +131,9 @@ class Restore {
|
|||
}
|
||||
$r['status'] = $stat;
|
||||
if ($stat=='fault') {
|
||||
$r['faultString'] = $message;
|
||||
$r['faultString'] = $message;
|
||||
} else {
|
||||
$r['faultString'] = '';
|
||||
$r['faultString'] = '';
|
||||
}
|
||||
return $r;
|
||||
} else {
|
||||
|
@ -193,8 +193,8 @@ class Restore {
|
|||
|
||||
//simple check of archive format
|
||||
if (is_dir($this->tmpDir.'audioClip/') &&
|
||||
is_dir($this->tmpDir.'meta-inf/') &&
|
||||
is_dir($this->tmpDir.'playlist/')) {
|
||||
is_dir($this->tmpDir.'meta-inf/') &&
|
||||
is_dir($this->tmpDir.'playlist/')) {
|
||||
//search metafiles
|
||||
$this->metafiles = $this->getMetaFiles();
|
||||
#$this->addLogItem('metafiles:'.print_r($this->metafiles,true));
|
||||
|
@ -205,15 +205,15 @@ class Restore {
|
|||
$this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
" startRestore - addFileToStorage \n".
|
||||
"(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
||||
);
|
||||
file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
|
||||
return;
|
||||
);
|
||||
file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." startRestore - invalid archive format\n");
|
||||
file_put_contents($this->statusFile, 'fault|invalid archive format');
|
||||
return;
|
||||
file_put_contents($this->statusFile, 'fault|invalid archive format');
|
||||
return;
|
||||
}
|
||||
file_put_contents($this->statusFile, 'success');
|
||||
// unlink($backupfile);
|
||||
|
@ -238,13 +238,13 @@ class Restore {
|
|||
$playlists = scandir($this->tmpDir.'playlist/');
|
||||
for ($i = 0; $i < count($audioclips); $i++) {
|
||||
if (strpos($audioclips[$i],'xml')!==false)
|
||||
$r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
|
||||
$r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
|
||||
'type' => 'audioClip',
|
||||
'id' => str_replace('.xml','',$audioclips[$i]));
|
||||
}
|
||||
for ($i = 0; $i < count($playlists); $i++) {
|
||||
if (strpos($playlists[$i],'xml') !== false)
|
||||
$r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i],
|
||||
$r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i],
|
||||
'type' => 'playlist',
|
||||
'id' => str_replace('.xml','',$playlists[$i]));
|
||||
}
|
||||
|
@ -265,83 +265,83 @@ class Restore {
|
|||
* @return mixed
|
||||
* true if success or PEAR_error
|
||||
*/
|
||||
// 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");
|
||||
// }
|
||||
// require_once("XmlParser.php");
|
||||
// $tree = XmlParser::parse($file);
|
||||
// $mediaFileLP = str_replace('.xml','',$file);
|
||||
// $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:'';
|
||||
// $ex = $this->gb->existsFile($this->sessid,$gunid);
|
||||
// if (PEAR::isError($ex)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - existsFile($gunid) ".
|
||||
// "(".$ex->getMessage()."/".$ex->getUserInfo().")\n"
|
||||
// );
|
||||
// }
|
||||
// if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
|
||||
// //replace it
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// $replace = $this->gb->replaceFile(
|
||||
// $id, # id int, virt.file's local id
|
||||
// $mediaFileLP, # mediaFileLP string, local path of media file
|
||||
// $file, # mdataFileLP string, local path of metadata file
|
||||
// $this->sessid); # sessid string, session id
|
||||
// if (PEAR::isError($replace)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - replaceFile Error ".
|
||||
// "(".$replace->getMessage()."/".$replace->getUserInfo().")\n"
|
||||
// );
|
||||
// file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo());
|
||||
// return $replace;
|
||||
// }
|
||||
// #$this->addLogItem("replace it \n");
|
||||
// } else {
|
||||
// // add as new
|
||||
// $name = $tree->children[0]->children[0]->content;
|
||||
// if (empty($name)) {
|
||||
// $name = $tree->attrs['title']->val;
|
||||
// }
|
||||
// if (empty($name)) {
|
||||
// $name = '???';
|
||||
// }
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
|
||||
// "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
|
||||
// );
|
||||
// }
|
||||
// $values = array(
|
||||
// "filename" => $name,
|
||||
// "filepath" => $mediaFileLP,
|
||||
// "metadata" => $file,
|
||||
// "gunid" => $gunid,
|
||||
// "filetype" => $type
|
||||
// );
|
||||
// $put = $this->gb->putFile($values, $this->sessid);
|
||||
// //$this->addLogItem("add as new \n");
|
||||
// if (PEAR::isError($put)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - putFile Error ".
|
||||
// "(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
||||
// ."\n---\n".file_get_contents($file)."\n---\n"
|
||||
// );
|
||||
// file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
|
||||
// //$this->addLogItem("Error Object: ".print_r($put,true)."\n");
|
||||
// return $put;
|
||||
// }
|
||||
// }
|
||||
// $ac = StoredFile::RecallByGunid($gunid);
|
||||
// if (is_null($ac) || PEAR::isError($ac)) {
|
||||
// return $ac;
|
||||
// }
|
||||
// $res = $ac->setState('ready');
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// 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");
|
||||
// }
|
||||
// require_once("XmlParser.php");
|
||||
// $tree = XmlParser::parse($file);
|
||||
// $mediaFileLP = str_replace('.xml','',$file);
|
||||
// $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:'';
|
||||
// $ex = $this->gb->existsFile($this->sessid,$gunid);
|
||||
// if (PEAR::isError($ex)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - existsFile($gunid) ".
|
||||
// "(".$ex->getMessage()."/".$ex->getUserInfo().")\n"
|
||||
// );
|
||||
// }
|
||||
// if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
|
||||
// //replace it
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// $replace = $this->gb->replaceFile(
|
||||
// $id, # id int, virt.file's local id
|
||||
// $mediaFileLP, # mediaFileLP string, local path of media file
|
||||
// $file, # mdataFileLP string, local path of metadata file
|
||||
// $this->sessid); # sessid string, session id
|
||||
// if (PEAR::isError($replace)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - replaceFile Error ".
|
||||
// "(".$replace->getMessage()."/".$replace->getUserInfo().")\n"
|
||||
// );
|
||||
// file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo());
|
||||
// return $replace;
|
||||
// }
|
||||
// #$this->addLogItem("replace it \n");
|
||||
// } else {
|
||||
// // add as new
|
||||
// $name = $tree->children[0]->children[0]->content;
|
||||
// if (empty($name)) {
|
||||
// $name = $tree->attrs['title']->val;
|
||||
// }
|
||||
// if (empty($name)) {
|
||||
// $name = '???';
|
||||
// }
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
|
||||
// "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
|
||||
// );
|
||||
// }
|
||||
// $values = array(
|
||||
// "filename" => $name,
|
||||
// "filepath" => $mediaFileLP,
|
||||
// "metadata" => $file,
|
||||
// "gunid" => $gunid,
|
||||
// "filetype" => $type
|
||||
// );
|
||||
// $put = $this->gb->putFile($values, $this->sessid);
|
||||
// //$this->addLogItem("add as new \n");
|
||||
// if (PEAR::isError($put)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - putFile Error ".
|
||||
// "(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
||||
// ."\n---\n".file_get_contents($file)."\n---\n"
|
||||
// );
|
||||
// file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
|
||||
// //$this->addLogItem("Error Object: ".print_r($put,true)."\n");
|
||||
// return $put;
|
||||
// }
|
||||
// }
|
||||
// $ac = StoredFile::RecallByGunid($gunid);
|
||||
// if (is_null($ac) || PEAR::isError($ac)) {
|
||||
// return $ac;
|
||||
// }
|
||||
// $res = $ac->setState('ready');
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -433,4 +433,4 @@ class Restore {
|
|||
}
|
||||
|
||||
} // class Restore
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -4,421 +4,556 @@ require_once("BasicStor.php");
|
|||
|
||||
class ScheduleGroup {
|
||||
|
||||
private $groupId;
|
||||
private $groupId;
|
||||
|
||||
public function __construct($p_groupId = null) {
|
||||
$this->groupId = $p_groupId;
|
||||
}
|
||||
public function __construct($p_groupId = null) {
|
||||
$this->groupId = $p_groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a date to an ID by stripping out all characters
|
||||
* and padding with zeros.
|
||||
*
|
||||
* @param string $p_dateStr
|
||||
*/
|
||||
public static function dateToId($p_dateStr) {
|
||||
$p_dateStr = str_replace(":", "", $p_dateStr);
|
||||
$p_dateStr = str_replace(" ", "", $p_dateStr);
|
||||
$p_dateStr = str_replace(".", "", $p_dateStr);
|
||||
$p_dateStr = str_replace("-", "", $p_dateStr);
|
||||
$p_dateStr = substr($p_dateStr, 0, 17);
|
||||
$p_dateStr = str_pad($p_dateStr, 17, "0");
|
||||
return $p_dateStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the two times together, return the result.
|
||||
*
|
||||
* @param string $p_baseTime
|
||||
* Specified as YYYY-MM-DD HH:MM:SS
|
||||
*
|
||||
* @param string $p_addTime
|
||||
* Specified as HH:MM:SS.nnnnnn
|
||||
*
|
||||
* @return string
|
||||
* The end time, to the nearest second.
|
||||
*/
|
||||
// protected function calculateEndTime($p_startTime, $p_trackTime) {
|
||||
// $p_trackTime = substr($p_startTime, 0, );
|
||||
// $start = new DateTime();
|
||||
// $interval = new DateInterval()
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Add a music clip or playlist to the schedule.
|
||||
*
|
||||
* @param $p_datetime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
||||
* @param $p_audioFileId
|
||||
* (optional, either this or $p_playlistId must be set) DB ID of the audio file
|
||||
* @param $p_playlistId
|
||||
* (optional, either this of $p_audioFileId must be set) DB ID of the playlist
|
||||
* @param $p_options
|
||||
* Does nothing at the moment.
|
||||
*
|
||||
* @return int|PEAR_Error
|
||||
* Return PEAR_Error if the item could not be added.
|
||||
* Error code 555 is a scheduling conflict.
|
||||
*/
|
||||
public function add($p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!is_null($p_audioFileId)) {
|
||||
// Schedule a single audio track
|
||||
|
||||
// Load existing track
|
||||
$track = StoredFile::Recall($p_audioFileId);
|
||||
if (is_null($track)) {
|
||||
return new PEAR_Error("Could not find audio track.");
|
||||
}
|
||||
|
||||
// Check if there are any conflicts with existing entries
|
||||
$metadata = $track->getMetadata();
|
||||
$length = trim($metadata["length"]);
|
||||
if (empty($length)) {
|
||||
return new PEAR_Error("Length is empty.");
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
|
||||
return new PEAR_Error("Schedule conflict.", 555);
|
||||
}
|
||||
|
||||
// Insert into the table
|
||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||
$id = $this->dateToId($p_datetime);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (id, playlist_id, starts, ends, clip_length, group_id, file_id)"
|
||||
." VALUES ($id, 0, TIMESTAMP '$p_datetime', "
|
||||
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
|
||||
." '$length',"
|
||||
." {$this->groupId}, $p_audioFileId)";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
var_dump($sql);
|
||||
return $result;
|
||||
}
|
||||
return $this->groupId;
|
||||
|
||||
} elseif (!is_null($p_playlistId)){
|
||||
// Schedule a whole playlist
|
||||
|
||||
// Load existing playlist
|
||||
$playlist = Playlist::Recall($p_playlistId);
|
||||
if (is_null($playlist)) {
|
||||
return new PEAR_Error("Could not find playlist.");
|
||||
}
|
||||
|
||||
// Check if there are any conflicts with existing entries
|
||||
$length = trim($playlist->getLength());
|
||||
if (empty($length)) {
|
||||
return new PEAR_Error("Length is empty.");
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
|
||||
return new PEAR_Error("Schedule conflict.", 555);
|
||||
}
|
||||
|
||||
// Insert all items into the schedule
|
||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||
$id = $this->dateToId($p_datetime);
|
||||
$itemStartTime = $p_datetime;
|
||||
|
||||
$plItems = $playlist->getContents();
|
||||
foreach ($plItems as $row) {
|
||||
$trackLength = $row["cliplength"];
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (id, playlist_id, starts, ends, group_id, file_id,"
|
||||
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
||||
." VALUES ($id, $p_playlistId, TIMESTAMP '$itemStartTime', "
|
||||
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
|
||||
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
|
||||
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
/**
|
||||
* Return true if the schedule group exists in the DB.
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG['scheduleTable']
|
||||
." WHERE group_id=".$this->groupId;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
var_dump($sql);
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
||||
$id = $this->dateToId($itemStartTime);
|
||||
}
|
||||
return $this->groupId;
|
||||
return $result != "0";
|
||||
}
|
||||
}
|
||||
|
||||
public function addAfter($p_groupId, $p_audioFileId) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// Get the end time for the given entry
|
||||
$sql = "SELECT ends FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE group_id=$p_groupId";
|
||||
$startTime = $CC_DBC->GetOne($sql);
|
||||
return $this->add($startTime, $p_audioFileId);
|
||||
}
|
||||
|
||||
public function update() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the group from the schedule.
|
||||
* Note: does not check if it is in the past, you can remove anything.
|
||||
*
|
||||
* @return boolean
|
||||
* TRUE on success, false if there is no group ID defined.
|
||||
*/
|
||||
public function remove() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($this->groupId) || !is_numeric($this->groupId)) {
|
||||
return false;
|
||||
/**
|
||||
* Convert a date to an ID by stripping out all characters
|
||||
* and padding with zeros.
|
||||
*
|
||||
* @param string $p_dateStr
|
||||
*/
|
||||
public static function dateToId($p_dateStr) {
|
||||
$p_dateStr = str_replace(":", "", $p_dateStr);
|
||||
$p_dateStr = str_replace(" ", "", $p_dateStr);
|
||||
$p_dateStr = str_replace(".", "", $p_dateStr);
|
||||
$p_dateStr = str_replace("-", "", $p_dateStr);
|
||||
$p_dateStr = substr($p_dateStr, 0, 17);
|
||||
$p_dateStr = str_pad($p_dateStr, 17, "0");
|
||||
return $p_dateStr;
|
||||
}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE group_id = ".$this->groupId;
|
||||
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
/**
|
||||
* Add the two times together, return the result.
|
||||
*
|
||||
* @param string $p_baseTime
|
||||
* Specified as YYYY-MM-DD HH:MM:SS
|
||||
*
|
||||
* @param string $p_addTime
|
||||
* Specified as HH:MM:SS.nnnnnn
|
||||
*
|
||||
* @return string
|
||||
* The end time, to the nearest second.
|
||||
*/
|
||||
// protected function calculateEndTime($p_startTime, $p_trackTime) {
|
||||
// $p_trackTime = substr($p_startTime, 0, );
|
||||
// $start = new DateTime();
|
||||
// $interval = new DateInterval()
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return the number of items in this group.
|
||||
* @return string
|
||||
*/
|
||||
public function count() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM {$CC_CONFIG['scheduleTable']}"
|
||||
." WHERE group_id={$this->groupId}";
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
/**
|
||||
* Add a music clip or playlist to the schedule.
|
||||
*
|
||||
* @param $p_datetime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
||||
* @param $p_audioFileId
|
||||
* (optional, either this or $p_playlistId must be set) DB ID of the audio file
|
||||
* @param $p_playlistId
|
||||
* (optional, either this of $p_audioFileId must be set) DB ID of the playlist
|
||||
* @param $p_options
|
||||
* Does nothing at the moment.
|
||||
*
|
||||
* @return int|PEAR_Error
|
||||
* Return PEAR_Error if the item could not be added.
|
||||
* Error code 555 is a scheduling conflict.
|
||||
*/
|
||||
public function add($p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!is_null($p_audioFileId)) {
|
||||
// Schedule a single audio track
|
||||
|
||||
/*
|
||||
* Return the list of items in this group as a 2D array.
|
||||
* @return array
|
||||
*/
|
||||
public function getItems() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT * FROM {$CC_CONFIG['scheduleTable']}"
|
||||
." WHERE group_id={$this->groupId}";
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
// Load existing track
|
||||
$track = StoredFile::Recall($p_audioFileId);
|
||||
if (is_null($track)) {
|
||||
return new PEAR_Error("Could not find audio track.");
|
||||
}
|
||||
|
||||
public function reschedule($toDateTime) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends="
|
||||
}
|
||||
// Check if there are any conflicts with existing entries
|
||||
$metadata = $track->getMetadata();
|
||||
$length = trim($metadata["length"]);
|
||||
if (empty($length)) {
|
||||
return new PEAR_Error("Length is empty.");
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
|
||||
return new PEAR_Error("Schedule conflict.", 555);
|
||||
}
|
||||
|
||||
// Insert into the table
|
||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||
$id = $this->dateToId($p_datetime);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (id, playlist_id, starts, ends, clip_length, group_id, file_id)"
|
||||
." VALUES ($id, 0, TIMESTAMP '$p_datetime', "
|
||||
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
|
||||
." '$length',"
|
||||
." {$this->groupId}, $p_audioFileId)";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
//var_dump($sql);
|
||||
return $result;
|
||||
}
|
||||
return $this->groupId;
|
||||
|
||||
} elseif (!is_null($p_playlistId)){
|
||||
// Schedule a whole playlist
|
||||
|
||||
// Load existing playlist
|
||||
$playlist = Playlist::Recall($p_playlistId);
|
||||
if (is_null($playlist)) {
|
||||
return new PEAR_Error("Could not find playlist.");
|
||||
}
|
||||
|
||||
// Check if there are any conflicts with existing entries
|
||||
$length = trim($playlist->getLength());
|
||||
//var_dump($length);
|
||||
if (empty($length)) {
|
||||
return new PEAR_Error("Length is empty.");
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
|
||||
return new PEAR_Error("Schedule conflict.", 555);
|
||||
}
|
||||
|
||||
// Insert all items into the schedule
|
||||
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
|
||||
$id = $this->dateToId($p_datetime);
|
||||
$itemStartTime = $p_datetime;
|
||||
|
||||
$plItems = $playlist->getContents();
|
||||
//var_dump($plItems);
|
||||
foreach ($plItems as $row) {
|
||||
$trackLength = $row["cliplength"];
|
||||
//var_dump($trackLength);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (id, playlist_id, starts, ends, group_id, file_id,"
|
||||
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
||||
." VALUES ($id, $p_playlistId, TIMESTAMP '$itemStartTime', "
|
||||
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
|
||||
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
|
||||
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
//var_dump($sql);
|
||||
return $result;
|
||||
}
|
||||
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
||||
$id = $this->dateToId($itemStartTime);
|
||||
}
|
||||
return $this->groupId;
|
||||
}
|
||||
}
|
||||
|
||||
public function addAfter($p_groupId, $p_audioFileId) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// Get the end time for the given entry
|
||||
$sql = "SELECT ends FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE group_id=$p_groupId";
|
||||
$startTime = $CC_DBC->GetOne($sql);
|
||||
return $this->add($startTime, $p_audioFileId);
|
||||
}
|
||||
|
||||
public function update() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the group from the schedule.
|
||||
* Note: does not check if it is in the past, you can remove anything.
|
||||
*
|
||||
* @return boolean
|
||||
* TRUE on success, false if there is no group ID defined.
|
||||
*/
|
||||
public function remove() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($this->groupId) || !is_numeric($this->groupId)) {
|
||||
return false;
|
||||
}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE group_id = ".$this->groupId;
|
||||
//echo $sql;
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of items in this group.
|
||||
* @return string
|
||||
*/
|
||||
public function count() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM {$CC_CONFIG['scheduleTable']}"
|
||||
." WHERE group_id={$this->groupId}";
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the list of items in this group as a 2D array.
|
||||
* @return array
|
||||
*/
|
||||
public function getItems() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT * FROM {$CC_CONFIG['scheduleTable']}"
|
||||
." WHERE group_id={$this->groupId}";
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
public function reschedule($toDateTime) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends="
|
||||
}
|
||||
|
||||
public function notifyGroupStartPlay() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||
." SET schedule_group_played=TRUE"
|
||||
." WHERE group_id=".$this->groupId;
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public function notifyMediaItemStartPlay($p_fileId) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||
." SET media_item_played=TRUE"
|
||||
." WHERE group_id=".$this->groupId
|
||||
." AND file_id=".pg_escape_string($p_fileId);
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
class Schedule {
|
||||
|
||||
function __construct() {
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is nothing in the schedule for the given times.
|
||||
*
|
||||
* @param string $p_datetime
|
||||
* @param string $p_length
|
||||
*
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function isScheduleEmptyInRange($p_datetime, $p_length) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (empty($p_length)) {
|
||||
return new PEAR_Error("Schedule::isSchedulerEmptyInRange: param p_length is empty.");
|
||||
}
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE (starts >= '$p_datetime') "
|
||||
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
|
||||
//$_SESSION["debug"] = $sql;
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
return ($count == '0');
|
||||
}
|
||||
|
||||
// public function onAddTrackToPlaylist($playlistId, $audioTrackId) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return TRUE if file is going to be played in the future.
|
||||
*
|
||||
* @param string $p_fileId
|
||||
*/
|
||||
public function IsFileScheduledInTheFuture($p_fileId)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE file_id = {$p_fileId} AND starts > NOW()";
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
if (is_numeric($count) && ($count != '0')) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
/**
|
||||
* Return true if there is nothing in the schedule for the given start time
|
||||
* up to the length of time after that.
|
||||
*
|
||||
* @param string $p_datetime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
||||
* @param string $p_length
|
||||
* In the format HH:MM:SS.mmmmmm
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function isScheduleEmptyInRange($p_datetime, $p_length) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (empty($p_length)) {
|
||||
return new PEAR_Error("Schedule::isSchedulerEmptyInRange: param p_length is empty.");
|
||||
}
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE (starts >= '$p_datetime') "
|
||||
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
|
||||
//$_SESSION["debug"] = $sql;
|
||||
//var_dump($sql);
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
//var_dump($count);
|
||||
return ($count == '0');
|
||||
}
|
||||
|
||||
// public function onAddTrackToPlaylist($playlistId, $audioTrackId) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return TRUE if file is going to be played in the future.
|
||||
*
|
||||
* @param string $p_fileId
|
||||
*/
|
||||
public function IsFileScheduledInTheFuture($p_fileId)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE file_id = {$p_fileId} AND starts > NOW()";
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
if (is_numeric($count) && ($count != '0')) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns array indexed numberically of:
|
||||
* "playlistId"/"playlist_id" (aliases to the same thing)
|
||||
* "start"/"starts" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* "end"/"ends" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* "group_id"/"id" (aliases to the same thing)
|
||||
* "clip_length" (for playlists only, this is the length of the entire playlist)
|
||||
* "name" (playlist only)
|
||||
* "creator" (playlist only)
|
||||
* "file_id" (audioclip only)
|
||||
* "count" (number of items in the playlist, always 1 for audioclips.
|
||||
* Note that playlists with one item will also have count = 1.
|
||||
*
|
||||
* @param string $p_fromDateTime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* @param string $p_toDateTime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* @param boolean $p_playlistsOnly
|
||||
* Retreive playlists as a single item.
|
||||
* @return array
|
||||
* Returns empty array if nothing found
|
||||
*/
|
||||
public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$rows = array();
|
||||
if (!$p_playlistsOnly) {
|
||||
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
|
||||
/**
|
||||
* Returns array indexed numberically of:
|
||||
* "playlistId"/"playlist_id" (aliases to the same thing)
|
||||
* "start"/"starts" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* "end"/"ends" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* "group_id"/"id" (aliases to the same thing)
|
||||
* "clip_length" (for audio clips this is the length of the audio clip,
|
||||
* for playlists this is the length of the entire playlist)
|
||||
* "name" (playlist only)
|
||||
* "creator" (playlist only)
|
||||
* "file_id" (audioclip only)
|
||||
* "count" (number of items in the playlist, always 1 for audioclips.
|
||||
* Note that playlists with one item will also have count = 1.
|
||||
*
|
||||
* @param string $p_fromDateTime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* @param string $p_toDateTime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* @param boolean $p_playlistsOnly
|
||||
* Retreive playlists as a single item.
|
||||
* @return array
|
||||
* Returns empty array if nothing found
|
||||
*/
|
||||
public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$rows = array();
|
||||
if (!$p_playlistsOnly) {
|
||||
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') "
|
||||
." AND (ends <= TIMESTAMP '$p_toDateTime')";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
foreach ($rows as &$row) {
|
||||
$row["count"] = "1";
|
||||
$row["playlistId"] = $row["playlist_id"];
|
||||
$row["start"] = $row["starts"];
|
||||
$row["end"] = $row["ends"];
|
||||
$row["id"] = $row["group_id"];
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, "
|
||||
." SUM(clip_length) AS clip_length,"
|
||||
." MIN(file_id) AS file_id, COUNT(*) as count,"
|
||||
." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends"
|
||||
." FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." LEFT JOIN ".$CC_CONFIG["playListTable"]." ON playlist_id = ".$CC_CONFIG["playListTable"].".id"
|
||||
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')"
|
||||
." GROUP BY group_id"
|
||||
." ORDER BY starts";
|
||||
//var_dump($sql);
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (!PEAR::isError($rows)) {
|
||||
foreach ($rows as &$row) {
|
||||
$row["playlistId"] = $row["playlist_id"];
|
||||
$row["start"] = $row["starts"];
|
||||
$row["end"] = $row["ends"];
|
||||
$row["id"] = $row["group_id"];
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
foreach ($rows as &$row) {
|
||||
$row["count"] = "1";
|
||||
$row["playlistId"] = $row["playlist_id"];
|
||||
$row["start"] = $row["starts"];
|
||||
$row["end"] = $row["ends"];
|
||||
$row["id"] = $row["group_id"];
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, "
|
||||
." SUM(clip_length) AS clip_length,"
|
||||
." MIN(file_id) AS file_id, COUNT(*) as count,"
|
||||
." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends"
|
||||
." FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." LEFT JOIN ".$CC_CONFIG["playListTable"]." ON playlist_id = ".$CC_CONFIG["playListTable"].".id"
|
||||
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')"
|
||||
." GROUP BY group_id"
|
||||
." ORDER BY starts";
|
||||
//var_dump($sql);
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (!PEAR::isError($rows)) {
|
||||
foreach ($rows as &$row) {
|
||||
$row["playlistId"] = $row["playlist_id"];
|
||||
$row["start"] = $row["starts"];
|
||||
$row["end"] = $row["ends"];
|
||||
$row["id"] = $row["group_id"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getSchedulerTime() {
|
||||
public function getSchedulerTime() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentlyPlaying() {
|
||||
public function getCurrentlyPlaying() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getNextItem($nextCount = 1) {
|
||||
public function getNextItem($nextCount = 1) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getStatus() {
|
||||
public function getStatus() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static function CcTimeToPypoTime($p_time) {
|
||||
$p_time = substr($p_time, 0, 19);
|
||||
$p_time = str_replace(" ", "-", $p_time);
|
||||
$p_time = str_replace(":", "-", $p_time);
|
||||
return $p_time;
|
||||
}
|
||||
/**
|
||||
* Convert a time string in the format "YYYY-MM-DD HH:mm:SS"
|
||||
* to "YYYY-MM-DD-HH-mm-SS".
|
||||
*
|
||||
* @param string $p_time
|
||||
* @return string
|
||||
*/
|
||||
private static function CcTimeToPypoTime($p_time)
|
||||
{
|
||||
$p_time = substr($p_time, 0, 19);
|
||||
$p_time = str_replace(" ", "-", $p_time);
|
||||
$p_time = str_replace(":", "-", $p_time);
|
||||
return $p_time;
|
||||
}
|
||||
|
||||
private static function PypoTimeToCcTime($p_time) {
|
||||
$t = explode("-", $p_time);
|
||||
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
||||
}
|
||||
/**
|
||||
* Convert a time string in the format "YYYY-MM-DD-HH-mm-SS" to
|
||||
* "YYYY-MM-DD HH:mm:SS".
|
||||
*
|
||||
* @param string $p_time
|
||||
* @return string
|
||||
*/
|
||||
private static function PypoTimeToCcTime($p_time)
|
||||
{
|
||||
$t = explode("-", $p_time);
|
||||
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
||||
*
|
||||
* @param string $range
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param string $source
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
*/
|
||||
public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
|
||||
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
|
||||
$range_dt = array('start' => $range_start, 'end' => $range_end);
|
||||
//var_dump($range_dt);
|
||||
/**
|
||||
* Converts a time value as a string (with format HH:MM:SS.mmmmmm) to
|
||||
* millisecs.
|
||||
*
|
||||
* @param string $p_time
|
||||
* @return int
|
||||
*/
|
||||
private static function WallTimeToMillisecs($p_time)
|
||||
{
|
||||
$t = explode(":", $p_time);
|
||||
$millisecs = 0;
|
||||
if (strpos($t[2], ".")) {
|
||||
$secParts = explode(".", $t[2]);
|
||||
$millisecs = $secParts[1];
|
||||
$millisecs = substr($millisecs, 0, 3);
|
||||
$millisecs = intval($millisecs);
|
||||
$seconds = intval($secParts[0]);
|
||||
} else {
|
||||
$seconds = intval($t[2]);
|
||||
}
|
||||
$ret = $millisecs + ($seconds * 1000) + ($t[1] * 60 * 1000) + ($t[0] * 60 * 60 * 1000);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Scheduler wants everything in a playlist
|
||||
$data = Schedule::GetItems($range_start, $range_end, true);
|
||||
//echo "<pre>";var_dump($data);
|
||||
$playlists = array();
|
||||
|
||||
if (is_array($data) && count($data) > 0)
|
||||
{
|
||||
foreach ($data as $dx)
|
||||
{
|
||||
// Is this the first item in the playlist?
|
||||
$start = $dx['start'];
|
||||
// chop off subseconds
|
||||
$start = substr($start, 0, 19);
|
||||
/**
|
||||
* Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
|
||||
* Note: currently only supports calculating millisec differences.
|
||||
*
|
||||
* @param string $p_time1
|
||||
* @param string $p_time2
|
||||
* @return double
|
||||
*/
|
||||
private static function TimeDiff($p_time1, $p_time2)
|
||||
{
|
||||
$parts1 = explode(".", $p_time1);
|
||||
$parts2 = explode(".", $p_time2);
|
||||
$diff = 0;
|
||||
if ( (count($parts1) > 1) && (count($parts2) > 1) ) {
|
||||
$millisec1 = substr($parts1[1], 0, 3);
|
||||
$millisec1 = str_pad($millisec1, 3, "0");
|
||||
$millisec1 = intval($millisec1);
|
||||
$millisec2 = substr($parts2[1], 0, 3);
|
||||
$millisec2 = str_pad($millisec2, 3, "0");
|
||||
$millisec2 = intval($millisec2);
|
||||
$diff = abs(millisec1 - millisec2)/1000;
|
||||
}
|
||||
return $diff;
|
||||
}
|
||||
|
||||
// Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
||||
$pkey = Schedule::CcTimeToPypoTime($start);
|
||||
$timestamp = strtotime($start);
|
||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||
$playlists[$pkey]['x_ident'] = $dx["playlist_id"];
|
||||
$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
|
||||
$playlists[$pkey]['timestamp'] = $timestamp;
|
||||
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
||||
$playlists[$pkey]['played'] = '0';
|
||||
$playlists[$pkey]['schedule_id'] = $dx['group_id'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($playlists as &$playlist)
|
||||
{
|
||||
$scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
|
||||
$items = $scheduleGroup->getItems();
|
||||
$medias = array();
|
||||
$playlist['subtype'] = '1';
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$storedFile = StoredFile::Recall($item["file_id"]);
|
||||
$uri = $storedFile->getFileUrl();
|
||||
$medias[] = array(
|
||||
/**
|
||||
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
||||
*
|
||||
* @param string $range
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param string $source
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
*/
|
||||
public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
|
||||
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
|
||||
$range_dt = array('start' => $range_start, 'end' => $range_end);
|
||||
//var_dump($range_dt);
|
||||
|
||||
// Scheduler wants everything in a playlist
|
||||
$data = Schedule::GetItems($range_start, $range_end, true);
|
||||
//echo "<pre>";var_dump($data);
|
||||
$playlists = array();
|
||||
|
||||
if (is_array($data) && count($data) > 0)
|
||||
{
|
||||
foreach ($data as $dx)
|
||||
{
|
||||
// Is this the first item in the playlist?
|
||||
$start = $dx['start'];
|
||||
// chop off subseconds
|
||||
$start = substr($start, 0, 19);
|
||||
|
||||
// Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
||||
$pkey = Schedule::CcTimeToPypoTime($start);
|
||||
$timestamp = strtotime($start);
|
||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||
$playlists[$pkey]['x_ident'] = $dx["playlist_id"];
|
||||
$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
|
||||
$playlists[$pkey]['timestamp'] = $timestamp;
|
||||
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
||||
$playlists[$pkey]['played'] = '0';
|
||||
$playlists[$pkey]['schedule_id'] = $dx['group_id'];
|
||||
$playlists[$pkey]['user_id'] = 0;
|
||||
$playlists[$pkey]['id'] = $dx["playlist_id"];
|
||||
$playlists[$pkey]['start'] = Schedule::CcTimeToPypoTime($dx["start"]);
|
||||
$playlists[$pkey]['end'] = Schedule::CcTimeToPypoTime($dx["end"]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($playlists as &$playlist)
|
||||
{
|
||||
$scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
|
||||
$items = $scheduleGroup->getItems();
|
||||
$medias = array();
|
||||
$playlist['subtype'] = '1';
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$storedFile = StoredFile::Recall($item["file_id"]);
|
||||
$uri = $storedFile->getFileUrl();
|
||||
|
||||
// For pypo, a cueout of zero means no cueout
|
||||
$cueOut = "0";
|
||||
if (Schedule::TimeDiff($item["cue_out"], $item["clip_length"]) > 0.001) {
|
||||
$cueOut = Schedule::WallTimeToMillisecs($item["cue_out"]);
|
||||
}
|
||||
$medias[] = array(
|
||||
'id' => $storedFile->getGunid(), //$item["file_id"],
|
||||
'uri' => $uri,
|
||||
'fade_in' => $item["fade_in"],
|
||||
'fade_out' => $item["fade_out"],
|
||||
'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]),
|
||||
'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]),
|
||||
'fade_cross' => 0,
|
||||
'cue_in' => $item["cue_in"],
|
||||
'cue_out' => $item["cue_out"],
|
||||
);
|
||||
}
|
||||
$playlist['medias'] = $medias;
|
||||
}
|
||||
'cue_in' => Schedule::WallTimeToMillisecs($item["cue_in"]),
|
||||
'cue_out' => $cueOut,
|
||||
'export_source' => 'scheduler'
|
||||
);
|
||||
}
|
||||
$playlist['medias'] = $medias;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['status'] = array('range' => $range_dt, 'version' => 0.2);
|
||||
$result['playlists'] = $playlists;
|
||||
$result['check'] = 1;
|
||||
$result = array();
|
||||
$result['status'] = array('range' => $range_dt, 'version' => "0.2");
|
||||
$result['playlists'] = $playlists;
|
||||
$result['check'] = 1;
|
||||
|
||||
print json_encode($result);
|
||||
}
|
||||
print json_encode($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove all items from the schedule in the given range.
|
||||
*
|
||||
* @param string $p_start
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* @param string $p_end
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
*/
|
||||
public static function RemoveItemsInRange($p_start, $p_end)
|
||||
{
|
||||
$items = Schedule::GetItems($p_start, $p_end);
|
||||
foreach ($items as $item) {
|
||||
$scheduleGroup = new ScheduleGroup($item["group_id"]);
|
||||
$scheduleGroup->remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -58,24 +58,24 @@ class SmilPlaylist {
|
|||
}
|
||||
$lspl = SmilPlaylist::convert2lspl($gb, $path, $gunids, $parr);
|
||||
if (PEAR::isError($lspl)) {
|
||||
return $lspl;
|
||||
return $lspl;
|
||||
}
|
||||
require_once("Playlist.php");
|
||||
$pl =& Playlist::create($gb, $plid, "imported_SMIL");
|
||||
if (PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
return $pl;
|
||||
}
|
||||
$r = $pl->lock($gb, $subjid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$r = $pl->setMetadata($lspl, 'string', 'playlist');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$r = $pl->unlock($gb);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return $pl;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class SmilPlaylist {
|
|||
extract($parr);
|
||||
$tree = SmilPlaylist::parse($data);
|
||||
if (PEAR::isError($tree)) {
|
||||
return $tree;
|
||||
return $tree;
|
||||
}
|
||||
if ($tree->name != 'smil') {
|
||||
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
|
||||
|
@ -107,11 +107,11 @@ class SmilPlaylist {
|
|||
if (isset($tree->children[1])) {
|
||||
return PEAR::raiseError(sprintf(
|
||||
"SmilPlaylist::parse: unexpected tag %s in tag smil",
|
||||
$tree->children[1]->name
|
||||
$tree->children[1]->name
|
||||
));
|
||||
}
|
||||
$res = SmilPlaylistBodyElement::convert2lspl(
|
||||
$gb, $tree->children[0], &$gunids, $parr);
|
||||
$gb, $tree->children[0], &$gunids, $parr);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -136,13 +136,13 @@ class SmilPlaylistBodyElement {
|
|||
if (isset($tree->children[1])) {
|
||||
return PEAR::raiseError(sprintf(
|
||||
"SmilPlaylist::parse: unexpected tag %s in tag body",
|
||||
$tree->children[1]->name
|
||||
$tree->children[1]->name
|
||||
));
|
||||
}
|
||||
$res = SmilPlaylistParElement::convert2lspl(
|
||||
$gb, $tree->children[0], &$gunids, $parr, $ind2);
|
||||
$gb, $tree->children[0], &$gunids, $parr, $ind2);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
$title = basename($rPath);
|
||||
$playlength = '0';
|
||||
|
@ -165,7 +165,7 @@ class SmilPlaylistBodyElement {
|
|||
*/
|
||||
class SmilPlaylistParElement {
|
||||
|
||||
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||
{
|
||||
extract($parr);
|
||||
if ($tree->name != 'par') {
|
||||
|
@ -176,7 +176,7 @@ class SmilPlaylistParElement {
|
|||
$ch =& $tree->children[$i];
|
||||
$r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$res .= $r;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ class SmilPlaylistAudioElement {
|
|||
if (isset($tree->children[2])) {
|
||||
return PEAR::raiseError(sprintf(
|
||||
"SmilPlaylist::parse: unexpected tag %s in tag audio",
|
||||
$tree->children[2]->name
|
||||
$tree->children[2]->name
|
||||
));
|
||||
}
|
||||
$res = ''; $fadeIn = 0; $fadeOut = 0;
|
||||
|
@ -212,7 +212,7 @@ class SmilPlaylistAudioElement {
|
|||
$ch =& $tree->children[$i];
|
||||
$r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
switch ($r['type']) {
|
||||
case "fadeIn": $fadeIn = $r['val']; break;
|
||||
|
@ -225,7 +225,7 @@ class SmilPlaylistAudioElement {
|
|||
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
|
||||
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
|
||||
} else {
|
||||
$fInfo = '';
|
||||
$fInfo = '';
|
||||
}
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
$acGunid = $gunid;
|
||||
|
@ -238,19 +238,19 @@ class SmilPlaylistAudioElement {
|
|||
case "m3u":
|
||||
$type = 'playlist';
|
||||
$acId = $gb->bsImportPlaylistRaw($gunid,
|
||||
$aPath, $uri, $ext, $gunids, $subjid);
|
||||
$aPath, $uri, $ext, $gunids, $subjid);
|
||||
if (PEAR::isError($acId)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
//break;
|
||||
//break;
|
||||
default:
|
||||
$ac = StoredFile::RecallByGunid($gunid);
|
||||
if (is_null($ac) || PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
return $ac;
|
||||
}
|
||||
$r = $ac->md->getMetadataElement('dcterms:extent');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$playlength = $r[0]['value'];
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ class SmilPlaylistAudioElement {
|
|||
$clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val);
|
||||
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n".
|
||||
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
|
||||
$fInfo.
|
||||
$fInfo.
|
||||
"$ind</playlistElement>\n";
|
||||
return $res;
|
||||
}
|
||||
|
@ -278,35 +278,35 @@ class SmilPlaylistAudioElement {
|
|||
*/
|
||||
class SmilPlaylistAnimateElement {
|
||||
|
||||
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||
{
|
||||
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
|
||||
{
|
||||
extract($parr);
|
||||
if ($tree->name != 'animate') {
|
||||
return PEAR::raiseError("SmilPlaylist::parse: animate tag expected");
|
||||
}
|
||||
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
|
||||
$tree->attrs['from']->val == '0%' &&
|
||||
$tree->attrs['to']->val == '100%' &&
|
||||
$tree->attrs['calcMode']->val == 'linear' &&
|
||||
$tree->attrs['fill']->val == 'freeze' &&
|
||||
$tree->attrs['begin']->val == '0s' &&
|
||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
|
||||
$tree->attrs['from']->val == '0%' &&
|
||||
$tree->attrs['to']->val == '100%' &&
|
||||
$tree->attrs['calcMode']->val == 'linear' &&
|
||||
$tree->attrs['fill']->val == 'freeze' &&
|
||||
$tree->attrs['begin']->val == '0s' &&
|
||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
|
||||
) {
|
||||
return array('type'=>'fadeIn', 'val'=>intval($va[1]));
|
||||
}
|
||||
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
|
||||
$tree->attrs['from']->val == '100%' &&
|
||||
$tree->attrs['to']->val == '0%' &&
|
||||
$tree->attrs['calcMode']->val == 'linear' &&
|
||||
$tree->attrs['fill']->val == 'freeze' &&
|
||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
|
||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
|
||||
$tree->attrs['from']->val == '100%' &&
|
||||
$tree->attrs['to']->val == '0%' &&
|
||||
$tree->attrs['calcMode']->val == 'linear' &&
|
||||
$tree->attrs['fill']->val == 'freeze' &&
|
||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
|
||||
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
|
||||
) {
|
||||
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
|
||||
}
|
||||
return PEAR::raiseError(
|
||||
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
|
||||
);
|
||||
);
|
||||
}
|
||||
} // class SmilPlaylistAnimateElement
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,9 +12,9 @@ define('TR_LEAVE_CLOSED', TRUE);
|
|||
*/
|
||||
class TransportRecord
|
||||
{
|
||||
/**
|
||||
* @var DB
|
||||
*/
|
||||
/**
|
||||
* @var DB
|
||||
*/
|
||||
//public $dbc;
|
||||
|
||||
/**
|
||||
|
@ -72,12 +72,12 @@ class TransportRecord
|
|||
$trec = new TransportRecord($tr);
|
||||
$trec->trtok = $trtok = $tr->_createTransportToken();
|
||||
$trec->row = array_merge($defaults,
|
||||
array('trtype'=>$trtype, 'direction'=>$direction));
|
||||
array('trtype'=>$trtype, 'direction'=>$direction));
|
||||
$trec->recalled = TRUE;
|
||||
if (!isset($defaults['title'])) {
|
||||
$defaults['title'] = $trec->getTitle();
|
||||
if (PEAR::isError($defaults['title'])) {
|
||||
return $defaults['title'];
|
||||
return $defaults['title'];
|
||||
}
|
||||
}
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['transSequence']);
|
||||
|
@ -96,7 +96,7 @@ class TransportRecord
|
|||
";
|
||||
$res = $CC_DBC->query($query);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
return $trec;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class TransportRecord
|
|||
WHERE trtok='$trtok'
|
||||
");
|
||||
if (PEAR::isError($row)) {
|
||||
return $row;
|
||||
return $row;
|
||||
}
|
||||
if (is_null($row)) {
|
||||
return PEAR::raiseError("TransportRecord::recall:".
|
||||
|
@ -170,16 +170,16 @@ class TransportRecord
|
|||
UPDATE ".$CC_CONFIG['transTable']."
|
||||
SET $set
|
||||
WHERE trtok='{$this->trtok}'".
|
||||
(is_null($oldState) ? '' : " AND state='$oldState'").
|
||||
(is_null($lock) ? '' : " AND lock = '$slock'")
|
||||
(is_null($oldState) ? '' : " AND state='$oldState'").
|
||||
(is_null($lock) ? '' : " AND lock = '$slock'")
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
// return TRUE;
|
||||
$affRows = $CC_DBC->affectedRows();
|
||||
if (PEAR::isError($affRows)) {
|
||||
return $affRows;
|
||||
return $affRows;
|
||||
}
|
||||
return ($affRows == 1);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ class TransportRecord
|
|||
global $CC_CONFIG, $CC_DBC;
|
||||
$pidsql = (is_null($pid) ? "NULL" : "$pid" );
|
||||
if ($this->dropped) {
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
$slock = ($lock ? 'Y' : 'N');
|
||||
$nlock = (!$lock);
|
||||
|
@ -228,11 +228,11 @@ class TransportRecord
|
|||
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$affRows = $CC_DBC->affectedRows();
|
||||
if (PEAR::isError($affRows)) {
|
||||
return $affRows;
|
||||
return $affRows;
|
||||
}
|
||||
if ($affRows === 0) {
|
||||
$ltxt = ($lock ? 'lock' : 'unlock' );
|
||||
|
@ -303,7 +303,7 @@ class TransportRecord
|
|||
}
|
||||
$r = $this->setState('failed', array('errmsg'=>$msg));
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ class TransportRecord
|
|||
if (TR_LEAVE_CLOSED) {
|
||||
$r = $this->setState('closed');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
} else {
|
||||
$r = $CC_DBC->query("
|
||||
|
@ -334,7 +334,7 @@ class TransportRecord
|
|||
WHERE trtok='{$this->trtok}'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$this->recalled = FALSE;
|
||||
$this->dropped = TRUE;
|
||||
|
@ -383,7 +383,7 @@ class TransportRecord
|
|||
$defStr = 'unknown';
|
||||
$trtype = $this->getTransportType(); //contains recall check
|
||||
if (PEAR::isError($trtype)) {
|
||||
return $trtype;
|
||||
return $trtype;
|
||||
}
|
||||
switch ($trtype) {
|
||||
case "audioclip":
|
||||
|
@ -396,9 +396,9 @@ class TransportRecord
|
|||
}
|
||||
if (PEAR::isError($title)) {
|
||||
if ($title->getCode() == GBERR_FOBJNEX) {
|
||||
$title = $defStr;
|
||||
$title = $defStr;
|
||||
} else {
|
||||
return $title;
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -407,10 +407,10 @@ class TransportRecord
|
|||
break;
|
||||
case "file":
|
||||
$title = ( isset($this->row['localfile']) ?
|
||||
basename($this->row['localfile']) : 'regular file');
|
||||
basename($this->row['localfile']) : 'regular file');
|
||||
break;
|
||||
default:
|
||||
$title = $defStr;
|
||||
$title = $defStr;
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
|
|
@ -67,12 +67,12 @@ class Validator {
|
|||
'webstream' => "webstreamFormat",
|
||||
);
|
||||
if (!isset($formats[$format])) {
|
||||
return $this->_err(VAL_FORMAT);
|
||||
return $this->_err(VAL_FORMAT);
|
||||
}
|
||||
$formatName = $formats[$format];
|
||||
$formatFile = dirname(__FILE__)."/$formatName.php";
|
||||
if (!file_exists($formatFile)) {
|
||||
return $this->_err(VAL_FORMAT);
|
||||
return $this->_err(VAL_FORMAT);
|
||||
}
|
||||
require($formatFile);
|
||||
$this->formTree = $$formatName;
|
||||
|
@ -151,15 +151,15 @@ class Validator {
|
|||
$dname = (($node->ns? $node->ns.":" : '').$node->name);
|
||||
$formTree =& $this->formTree;
|
||||
if (DEBUG) {
|
||||
echo"\nVAL::validateNode: 1 $dname/$fname\n";
|
||||
echo"\nVAL::validateNode: 1 $dname/$fname\n";
|
||||
}
|
||||
// check root node name:
|
||||
if ($dname != $fname) {
|
||||
return $this->_err(VAL_ROOT, $fname);
|
||||
return $this->_err(VAL_ROOT, $fname);
|
||||
}
|
||||
// check if this element is defined in format:
|
||||
if (!isset($formTree[$fname])) {
|
||||
return $this->_err(VAL_NOTDEF, $fname);
|
||||
return $this->_err(VAL_NOTDEF, $fname);
|
||||
}
|
||||
// check element content
|
||||
if (isset($formTree[$fname]['regexp'])) {
|
||||
|
@ -171,12 +171,12 @@ class Validator {
|
|||
// validate attributes:
|
||||
$ra = $this->validateAttributes($node, $fname);
|
||||
if (PEAR::isError($ra)) {
|
||||
return $ra;
|
||||
return $ra;
|
||||
}
|
||||
// validate children:
|
||||
$r = $this->validateChildren($node, $fname);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class Validator {
|
|||
// call children recursive:
|
||||
$r = $this->validateNode($node->children[$i], $chname);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
return $r;
|
||||
}
|
||||
$childs[$chname] = TRUE;
|
||||
}
|
||||
|
@ -269,13 +269,13 @@ class Validator {
|
|||
foreach ($fchilds['oneof'] as $i => $ch) {
|
||||
if (isset($childs[$ch])) {
|
||||
if ($one) {
|
||||
return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
|
||||
return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
|
||||
}
|
||||
$one = TRUE;
|
||||
}
|
||||
}
|
||||
if (!$one) {
|
||||
return $this->_err(VAL_NOONEOF);
|
||||
return $this->_err(VAL_NOONEOF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,9 +340,9 @@ class Validator {
|
|||
{
|
||||
$formTree =& $this->formTree;
|
||||
$listed = (
|
||||
isset($formTree[$fname][$nType][$reqType]) ?
|
||||
array_search($chname, $formTree[$fname][$nType][$reqType]) :
|
||||
FALSE
|
||||
isset($formTree[$fname][$nType][$reqType]) ?
|
||||
array_search($chname, $formTree[$fname][$nType][$reqType]) :
|
||||
FALSE
|
||||
);
|
||||
return $listed;
|
||||
}
|
||||
|
@ -360,22 +360,22 @@ class Validator {
|
|||
function _err($errno, $par='')
|
||||
{
|
||||
$msg = array(
|
||||
VAL_ROOT => 'Wrong root element',
|
||||
VAL_NOREQE => 'Required element missing',
|
||||
VAL_NOONEOF => 'One-of element missing',
|
||||
VAL_UNKNOWNE => 'Unknown element',
|
||||
VAL_UNKNOWNA => 'Unknown attribute',
|
||||
VAL_NOTDEF => 'Not defined',
|
||||
VAL_UNEXPONEOF => 'Unexpected second object from one-of set',
|
||||
VAL_FORMAT => 'Unknown format',
|
||||
VAL_CONTENT => 'Invalid content',
|
||||
VAL_NOREQA => 'Required attribute missing',
|
||||
VAL_ATTRIB => 'Invalid attribute format',
|
||||
VAL_PREDXML => 'Invalid predicate type',
|
||||
VAL_ROOT => 'Wrong root element',
|
||||
VAL_NOREQE => 'Required element missing',
|
||||
VAL_NOONEOF => 'One-of element missing',
|
||||
VAL_UNKNOWNE => 'Unknown element',
|
||||
VAL_UNKNOWNA => 'Unknown attribute',
|
||||
VAL_NOTDEF => 'Not defined',
|
||||
VAL_UNEXPONEOF => 'Unexpected second object from one-of set',
|
||||
VAL_FORMAT => 'Unknown format',
|
||||
VAL_CONTENT => 'Invalid content',
|
||||
VAL_NOREQA => 'Required attribute missing',
|
||||
VAL_ATTRIB => 'Invalid attribute format',
|
||||
VAL_PREDXML => 'Invalid predicate type',
|
||||
);
|
||||
return PEAR::raiseError(
|
||||
"Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})",
|
||||
$errno
|
||||
$errno
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,12 +164,12 @@ class XmlParser {
|
|||
$res = xml_parse($xml_parser, $data, TRUE);
|
||||
if (!$res) {
|
||||
$this->err = array(TRUE,
|
||||
sprintf("XML error: %s at line %d\n",
|
||||
xml_error_string(xml_get_error_code($xml_parser)),
|
||||
xml_get_current_line_number($xml_parser)
|
||||
)
|
||||
sprintf("XML error: %s at line %d\n",
|
||||
xml_error_string(xml_get_error_code($xml_parser)),
|
||||
xml_get_current_line_number($xml_parser)
|
||||
)
|
||||
);
|
||||
// var_dump($data);
|
||||
// var_dump($data);
|
||||
}
|
||||
xml_parser_free($xml_parser);
|
||||
}
|
||||
|
@ -188,31 +188,31 @@ class XmlParser {
|
|||
function &parse($data='', $loc='file')
|
||||
{
|
||||
switch ($loc) {
|
||||
case "file":
|
||||
if (!is_file($data)) {
|
||||
return PEAR::raiseError(
|
||||
case "file":
|
||||
if (!is_file($data)) {
|
||||
return PEAR::raiseError(
|
||||
"XmlParser::parse: file not found ($data)"
|
||||
);
|
||||
}
|
||||
if (!is_readable($data)) {
|
||||
return PEAR::raiseError(
|
||||
);
|
||||
}
|
||||
if (!is_readable($data)) {
|
||||
return PEAR::raiseError(
|
||||
"XmlParser::parse: can't read file ($data)"
|
||||
);
|
||||
}
|
||||
$data = file_get_contents($data);
|
||||
case "string":
|
||||
$parser = new XmlParser($data);
|
||||
if ($parser->isError()) {
|
||||
return PEAR::raiseError(
|
||||
);
|
||||
}
|
||||
$data = file_get_contents($data);
|
||||
case "string":
|
||||
$parser = new XmlParser($data);
|
||||
if ($parser->isError()) {
|
||||
return PEAR::raiseError(
|
||||
"XmlParser::parse: ".$parser->getError()
|
||||
);
|
||||
}
|
||||
$tree = $parser->getTree();
|
||||
break;
|
||||
default:
|
||||
return PEAR::raiseError(
|
||||
);
|
||||
}
|
||||
$tree = $parser->getTree();
|
||||
break;
|
||||
default:
|
||||
return PEAR::raiseError(
|
||||
"XmlParser::parse: unsupported source location ($loc)"
|
||||
);
|
||||
);
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class XmlParser {
|
|||
$atnm = $a['localPart'];
|
||||
unset($attrs[$atn]);
|
||||
if ($atns == 'xmlns') {
|
||||
$nSpaces[$atnm] = $atv;
|
||||
$nSpaces[$atnm] = $atv;
|
||||
} else if ($atns == NULL && $atnm == 'xmlns') {
|
||||
$nSpaces[''] = $atv;
|
||||
} else {
|
||||
|
@ -280,7 +280,7 @@ class XmlParser {
|
|||
function characterData($parser, $data) {
|
||||
$cnt = count($this->stack);
|
||||
if (trim($data)!='') {
|
||||
$this->stack[$cnt-1]->content .= $data;
|
||||
$this->stack[$cnt-1]->content .= $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ class XmlParser {
|
|||
//if(substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";"){
|
||||
// $this->stack[$cnt-1]->content .= trim($data);
|
||||
//}else{
|
||||
$this->stack[$cnt-1]->content .= "*** $data ***";
|
||||
$this->stack[$cnt-1]->content .= "*** $data ***";
|
||||
//}
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ class XmlParser {
|
|||
}
|
||||
$res .= XML_Util::replaceEntities("{$el->content}");
|
||||
if ($haveCh) {
|
||||
$res .= "\n{$ind}";
|
||||
$res .= "\n{$ind}";
|
||||
}
|
||||
$res .= "</{$fullName}>";
|
||||
return $res;
|
||||
|
|
47
application/models/configure
vendored
47
application/models/configure
vendored
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen $*)
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure $*)
|
||||
|
BIN
application/models/tests/0000000000010001
Normal file
BIN
application/models/tests/0000000000010001
Normal file
Binary file not shown.
BIN
application/models/tests/0000000000010002
Normal file
BIN
application/models/tests/0000000000010002
Normal file
Binary file not shown.
24
application/models/tests/AllTests.php
Normal file
24
application/models/tests/AllTests.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
$path = dirname(__FILE__).'/../../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
$WHITE_SCREEN_OF_DEATH = false;
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
require_once 'StoredFileTests.php';
|
||||
require_once 'SchedulerTests.php';
|
||||
//require_once 'SchedulerExportTests.php';
|
||||
require_once 'PlaylistTests.php';
|
||||
|
||||
//$suite = new PHPUnit_TestSuite("PlayListTests");
|
||||
//$suite = new PHPUnit_TestSuite("SchedulerTests");
|
||||
$suite = new PHPUnit_TestSuite("StoredFileTest");
|
||||
$suite->addTestSuite("PlaylistTests");
|
||||
$suite->addTestSuite("SchedulerTests");
|
||||
//$suite->addTestSuite("SchedulerExportTests");
|
||||
$result = PHPUnit::run($suite);
|
||||
|
||||
echo $result->toString();
|
||||
|
||||
?>
|
181
application/models/tests/PlaylistTests.php
Normal file
181
application/models/tests/PlaylistTests.php
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
$path = dirname(__FILE__).'/../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../library/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../../configs/propel-config.php");
|
||||
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(dirname(__FILE__)."/../" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once(dirname(__FILE__).'/../GreenBox.php');
|
||||
require_once(dirname(__FILE__).'/../Playlist.php');
|
||||
|
||||
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'America/Toronto';
|
||||
date_default_timezone_set($tz);
|
||||
|
||||
//old database connection still needed to get a session instance.
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class PlaylistTests extends PHPUnit_TestCase {
|
||||
|
||||
private $greenbox;
|
||||
private $storedFile;
|
||||
private $storedFile2;
|
||||
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$this->greenbox = new GreenBox();
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
}
|
||||
|
||||
function testGBCreatePlaylist() {
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: create ".date("g:i a"));
|
||||
|
||||
if (!is_int($pl_id)) {
|
||||
$this->fail("problems creating playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Metadata: lock ".date("g:i a"));
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
$res = $this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems locking playlist for editing.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBUnLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: unlock ".date("g:i a"));
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
$this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
$res = $this->greenbox->releaseLockedPlaylist($pl_id, $sessid);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems unlocking playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBSetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: Set Metadata ".date("g:i a"));
|
||||
|
||||
$res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "Playlist Unit Test: Updated Title ".date("g:i a"));
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems setting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBGetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$name = "Playlist UnitTest: GetMetadata ".date("g:i a");
|
||||
$pl_id = $pl->create($name);
|
||||
|
||||
$res = $this->greenbox->getPLMetadataValue($pl_id, "dc:title");
|
||||
|
||||
if($res !== $name) {
|
||||
$this->fail("problems getting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAudioClip() {
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test ". date("g:i a"));
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip to playlist.");
|
||||
return;
|
||||
}
|
||||
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip 2 to playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testMoveAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test: Move ". date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
|
||||
$res = $this->greenbox->moveAudioClipInPlaylist($pl_id, 0, 1);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems moving audioclip in playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testDeleteAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: Delete ".date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
$res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems deleting audioclip from playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testFadeInfo() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test: Fade Info " . date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
|
||||
$res = $this->greenbox->changeFadeInfo($pl_id, 0, '00:00:01.14', null);
|
||||
|
||||
if(!is_array($res) && count($res) !== 2) {
|
||||
$this->fail("problems setting fade in playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
42
application/models/tests/SchedulerExportTests.php
Normal file
42
application/models/tests/SchedulerExportTests.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(__FILE__)."/../Schedule.php");
|
||||
|
||||
class SchedulerExportTests extends PHPUnit_TestCase {
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Clear the files table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
// Clear the schedule table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test");
|
||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
|
||||
// Schedule it
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
}
|
||||
|
||||
public function testExport() {
|
||||
echo Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
128
application/models/tests/SchedulerTests.php
Normal file
128
application/models/tests/SchedulerTests.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__)."/../Schedule.php");
|
||||
|
||||
class SchedulerTests extends PHPUnit_TestCase {
|
||||
|
||||
private $groupIdCreated;
|
||||
private $storedFile;
|
||||
private $storedFile2;
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Clear the files table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
// Clear the schedule table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
function testDateToId() {
|
||||
$dateStr = "2006-04-02 10:20:08.123456";
|
||||
$id = ScheduleGroup::dateToId($dateStr);
|
||||
$expected = "20060402102008123";
|
||||
if ($id != $expected) {
|
||||
$this->fail("Did not convert date to ID correctly #1: $id != $expected");
|
||||
}
|
||||
|
||||
$dateStr = "2006-04-02 10:20:08";
|
||||
$id = ScheduleGroup::dateToId($dateStr);
|
||||
$expected = "20060402102008000";
|
||||
if ($id != $expected) {
|
||||
$this->fail("Did not convert date to ID correctly #2: $id != $expected");
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAndRemoveAudioFile() {
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
|
||||
$i = new ScheduleGroup($this->groupIdCreated);
|
||||
$result = $i->remove();
|
||||
if ($result != 1) {
|
||||
$this->fail("Did not remove item.");
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAndRemovePlaylist() {
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test ".uniqid());
|
||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
$group = new ScheduleGroup($this->groupIdCreated);
|
||||
if ($group->count() != 3) {
|
||||
$this->fail("Wrong number of items added.");
|
||||
}
|
||||
$items = $group->getItems();
|
||||
if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
|
||||
$this->fail("Wrong start time for 2nd item.");
|
||||
}
|
||||
|
||||
$result = $group->remove();
|
||||
if ($result != 1) {
|
||||
$this->fail("Did not remove item.");
|
||||
}
|
||||
|
||||
Playlist::Delete($playlist->getId());
|
||||
}
|
||||
|
||||
function testIsScheduleEmptyInRange() {
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail($this->groupIdCreated->getMessage());
|
||||
return;
|
||||
}
|
||||
if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
|
||||
$this->fail("Reporting empty schedule when it isnt.");
|
||||
return;
|
||||
}
|
||||
// echo "groupid: ".$this->groupIdCreated."\n";
|
||||
$success = $i->remove();
|
||||
if ($success === false) {
|
||||
$this->fail("Failed to delete schedule group.");
|
||||
return;
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
|
||||
$this->fail("Reporting booked schedule when it isnt.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGetItems() {
|
||||
$i1 = new ScheduleGroup();
|
||||
$groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId());
|
||||
$i2 = new ScheduleGroup();
|
||||
$i2->addAfter($groupId1, $this->storedFile->getId());
|
||||
$items = Schedule::GetItems("2008-01-01", "2008-01-02");
|
||||
if (count($items) != 2) {
|
||||
$this->fail("Wrong number of items returned.");
|
||||
return;
|
||||
}
|
||||
$i1->remove();
|
||||
$i2->remove();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
87
application/models/tests/StoredFileTests.php
Normal file
87
application/models/tests/StoredFileTests.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../StoredFile.php');
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class StoredFileTest extends PHPUnit_TestCase {
|
||||
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
}
|
||||
|
||||
function testGetAudioMetadata() {
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
$metadata = camp_get_audio_metadata($filePath);
|
||||
if (PEAR::isError($metadata)) {
|
||||
$this->fail($metadata->getMessage());
|
||||
return;
|
||||
}
|
||||
if (($metadata["dc:description"] != "Tmu sem tam videla ...")
|
||||
|| ($metadata["audio"]["dataformat"] != "mp3")
|
||||
|| ($metadata["dc:type"] != "Speech")) {
|
||||
$str = " [dc:description] = " . $metadata["dc:description"] ."\n"
|
||||
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
|
||||
. " [dc:type] = ".$metadata["dc:type"]."\n";
|
||||
$this->fail("Metadata has unexpected values:\n".$str);
|
||||
}
|
||||
//var_dump($metadata);
|
||||
//$this->assertTrue(FALSE);
|
||||
}
|
||||
|
||||
function testDeleteAndPutFile() {
|
||||
$STORAGE_SERVER_PATH = dirname(__FILE__)."/../../";
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
|
||||
// Delete any old data from previous tests
|
||||
$md5 = md5_file($filePath);
|
||||
$duplicate = StoredFile::RecallByMd5($md5);
|
||||
if ($duplicate) {
|
||||
$duplicate->delete();
|
||||
}
|
||||
|
||||
// Test inserting a file by linking
|
||||
$values = array("filepath" => $filePath,
|
||||
"dc:description" => "Unit test ".time());
|
||||
$storedFile = StoredFile::Insert($values, false);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
|
||||
return;
|
||||
}
|
||||
//var_dump($storedFile);
|
||||
$id = $storedFile->getId();
|
||||
if (!is_numeric($id)) {
|
||||
$this->fail("StoredFile not created correctly. id = ".$id);
|
||||
return;
|
||||
}
|
||||
|
||||
// Test loading metadata
|
||||
$f = new StoredFile();
|
||||
$f->__setGunid($storedFile->getGunid());
|
||||
$f->loadMetadata();
|
||||
if (!is_array($md = $f->getMetadata())) {
|
||||
$this->fail("Unable to load metadata.");
|
||||
return;
|
||||
}
|
||||
//var_dump($md);
|
||||
|
||||
// Check if the length field has been set.
|
||||
$f2 = StoredFile::RecallByGunid($storedFile->getGunid());
|
||||
$m2 = $f2->getMetadata();
|
||||
if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") {
|
||||
$this->fail("Length not reporting correctly in metadata.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
25
application/models/tests/analyze.php
Executable file
25
application/models/tests/analyze.php
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
header("Content-type: text/plain");
|
||||
echo "TEST\n";
|
||||
|
||||
#$gunid = "5716b53127c3761f92fddde3412c7773";
|
||||
$gunid = $argv[1];
|
||||
echo "GUNID: $gunid\n";
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
$rmd = new StoredFile($gunid, '../stor/'.substr($gunid, 0, 3));
|
||||
$r = $rmd->analyzeFile();
|
||||
|
||||
echo "r=$r (".gettype($r).")\n";
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERR: ".$r->getMessage()."\n".$r->getUserInfo()."\n";
|
||||
}
|
||||
if (is_array($r)) {
|
||||
print_r($r);
|
||||
}
|
||||
echo"\n";
|
||||
?>
|
BIN
application/models/tests/ex1.mp3
Normal file
BIN
application/models/tests/ex1.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/ex2.ogg
Normal file
BIN
application/models/tests/ex2.ogg
Normal file
Binary file not shown.
BIN
application/models/tests/ex2.wav
Normal file
BIN
application/models/tests/ex2.wav
Normal file
Binary file not shown.
BIN
application/models/tests/ex3.wav
Normal file
BIN
application/models/tests/ex3.wav
Normal file
Binary file not shown.
BIN
application/models/tests/exportedPl_lspl.tar
Normal file
BIN
application/models/tests/exportedPl_lspl.tar
Normal file
Binary file not shown.
4
application/models/tests/index.php
Normal file
4
application/models/tests/index.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
header ("location: ../");
|
||||
exit;
|
||||
?>
|
22
application/models/tests/pdoTest.php
Normal file
22
application/models/tests/pdoTest.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
|
||||
$con = Propel::getConnection("campcaster");
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM cc_schedule WHERE (starts >= '2010-01-01 00:00:00.000') "
|
||||
." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))";
|
||||
$rows1 = $con->query($sql);
|
||||
var_dump($rows1->fetchAll());
|
||||
|
||||
$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents";
|
||||
$rows2 = $con->query($sql2);
|
||||
var_dump($rows2->fetchAll());
|
||||
|
||||
$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'";
|
||||
$result3 = $con->query($sql3);
|
||||
var_dump($result3->fetchAll());
|
||||
|
||||
?>
|
26
application/models/tests/plistEmbedded.xml
Normal file
26
application/models/tests/plistEmbedded.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0"?>
|
||||
<playlist id="0e22c20310212a51">
|
||||
<playlistElement id="0000000000000103" relativeOffset="00:00:00.000000" >
|
||||
<audioClip id="0000000000010003"
|
||||
playlength="00:00:11.500000"
|
||||
title = "three"
|
||||
uri="file:var/test10003.mp3"
|
||||
/>
|
||||
</playlistElement>
|
||||
<playlistElement id="0000000000000104" relativeOffset="00:00:11.500000">
|
||||
<playlist id="0000000000000001"
|
||||
playlength="01:30:00.000000"
|
||||
title="My First Playlist">
|
||||
</playlist>
|
||||
</playlistElement>
|
||||
<metadata
|
||||
xmlns="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
>
|
||||
<dc:title>embedded playlist</dc:title>
|
||||
<dcterms:extent>01:30:11.500000</dcterms:extent>
|
||||
</metadata>
|
||||
</playlist>
|
||||
|
85
application/models/tests/pypoTester.php
Normal file
85
application/models/tests/pypoTester.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
require_once '../../conf.php';
|
||||
require_once '../Playlist.php';
|
||||
require_once '../StoredFile.php';
|
||||
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
$playlistName = "pypo_playlist_test";
|
||||
$minutesFromNow = 1;
|
||||
|
||||
echo " ************************************************************** \n";
|
||||
echo " This script schedules a playlist to play $minutesFromNow minute(s) from now.\n";
|
||||
echo " This is a utility to help you debug the scheduler.\n";
|
||||
echo " ************************************************************** \n";
|
||||
echo "\n";
|
||||
echo "Deleting playlists with the name '$playlistName'...";
|
||||
// Delete any old playlists
|
||||
$pl2 = Playlist::findPlaylistByName($playlistName);
|
||||
foreach ($pl2 as $playlist) {
|
||||
//var_dump($playlist);
|
||||
$playlist->delete();
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
// Create a new playlist
|
||||
echo "Creating new playlist '$playlistName'...";
|
||||
$pl = new Playlist();
|
||||
$pl->create($playlistName);
|
||||
|
||||
// Add a media clip
|
||||
$mediaFile = StoredFile::findByOriginalName("Manolo Camp - Morning Coffee.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Manolo Camp - Morning Coffee.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
$mediaFile = StoredFile::findByOriginalName("Peter Rudenko - Opening.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Peter Rudenko - Opening.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
||||
//$pl2 = Playlist::findPlaylistByName("pypo_playlist_test");
|
||||
//var_dump($pl2);
|
||||
|
||||
// Get current time
|
||||
// In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
$startTime = date("Y-m-d H:i:s");
|
||||
$endTime = date("Y-m-d H:i:s", time()+(60*60));
|
||||
|
||||
echo "Removing everything from the scheduler between $startTime and $endTime...";
|
||||
// Scheduler: remove any playlists for the next hour
|
||||
Schedule::RemoveItemsInRange($startTime, $endTime);
|
||||
// Check for succcess
|
||||
$scheduleClear = Schedule::isScheduleEmptyInRange($startTime, "01:00:00");
|
||||
if (!$scheduleClear) {
|
||||
echo "\nERROR: Schedule could not be cleared.\n\n";
|
||||
var_dump(Schedule::GetItems($startTime, $endTime));
|
||||
exit;
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
// Schedule the playlist for two minutes from now
|
||||
echo "Scheduling new playlist...\n";
|
||||
$playTime = date("Y-m-d H:i:s", time()+(60*$minutesFromNow));
|
||||
$scheduleGroup = new ScheduleGroup();
|
||||
$scheduleGroup->add($playTime, null, $pl->getId());
|
||||
|
||||
echo " SUCCESS: Playlist scheduled at $playTime\n\n";
|
||||
?>
|
BIN
application/models/tests/question.wav
Normal file
BIN
application/models/tests/question.wav
Normal file
Binary file not shown.
BIN
application/models/tests/silence.wav
Normal file
BIN
application/models/tests/silence.wav
Normal file
Binary file not shown.
BIN
application/models/tests/test10001.mp3
Normal file
BIN
application/models/tests/test10001.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/test10002.mp3
Normal file
BIN
application/models/tests/test10002.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/test10003.mp3
Normal file
BIN
application/models/tests/test10003.mp3
Normal file
Binary file not shown.
143
application/models/tests/transTest.php
Normal file
143
application/models/tests/transTest.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
|
||||
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);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
$tr = new Transport($gb);
|
||||
$ls = new LocStor();
|
||||
@unlink($CC_CONFIG['transDir']."/activity.log");
|
||||
@unlink($CC_CONFIG['transDir']."/debug.log");
|
||||
$tr->_cleanUp();
|
||||
|
||||
$gunid = 'a23456789abcdefb';
|
||||
$mediaFile = '../tests/ex1.mp3';
|
||||
$mdataFile = '../tests/mdata1.xml';
|
||||
|
||||
// Test remote search
|
||||
$result = $tr->remoteSearch("");
|
||||
if (PEAR::isError($result)) {
|
||||
echo $result->message."\n";
|
||||
} else {
|
||||
var_dump($result);
|
||||
}
|
||||
|
||||
// ========== STORE ==========
|
||||
|
||||
echo"# Store: ";
|
||||
//$parid = $gb->_getHomeDirIdFromSess($sessid);
|
||||
$values = array(
|
||||
"filename" => "xx1.mp3",
|
||||
"filepath" => $mediaFile,
|
||||
"metadata" => $mdataFile,
|
||||
"gunid" => $gunid,
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
if ($storedFile->getCode()!=GBERR_GUNID) {
|
||||
echo "ERROR: ".$storedFile->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$oid = $storedFile->getId();
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
echo "$oid\n";
|
||||
|
||||
// ========== DELETE FROM HUB ==========
|
||||
echo"# loginToArchive: ";
|
||||
$r = $tr->loginToArchive();
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "{$r['sessid']}\n";
|
||||
$asessid = $r['sessid'];
|
||||
echo"# deleteAudioClip on Hub: ";
|
||||
$r = $tr->xmlrpcCall(
|
||||
'archive.deleteAudioClip',
|
||||
array(
|
||||
'sessid' => $asessid,
|
||||
'gunid' => $gunid,
|
||||
'forced' => TRUE,
|
||||
)
|
||||
);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; if($r->getCode()!=800+GBERR_FILENEX) exit(1); }
|
||||
else{ echo " {$r['status']}\n"; }
|
||||
echo"# logoutFromArchive: ";
|
||||
$r = $tr->logoutFromArchive($asessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
|
||||
|
||||
// ========== UPLOAD ==========
|
||||
echo "# UPLOAD test:\n";
|
||||
echo"# uploadAudioClip2Hub: ";
|
||||
$r = $gb->upload2Hub($gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
#$trtok='280a6f1c18389620';
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
// === DELETE LOCAL ===
|
||||
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 = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
|
||||
echo `$comm`;
|
||||
|
||||
// === DOWNLOAD ===
|
||||
echo "# DOWNLOAD test:\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# downloadAudioClipFromHub: ";
|
||||
$r = $gb->downloadFromHub($sessid, $gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
|
||||
if(file_exists("../trans/log")) echo `tail -n 25 ../trans/log`;
|
||||
echo "#Transport test: OK.\n\n";
|
||||
*/
|
||||
?>
|
62
application/models/tests/webstreamTest.php
Normal file
62
application/models/tests/webstreamTest.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
echo "\n#StorageServer storeWebstream test:\n";
|
||||
|
||||
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);
|
||||
$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 = Alib::Login('root', 'q'))."\n";
|
||||
$parid = $gb->_getHomeDirId($sessid);
|
||||
|
||||
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 = BasicStor::IdFromGunid($gunid);
|
||||
$id = $r;
|
||||
|
||||
echo "# getMdata: ";
|
||||
$r = $gb->getMetadata($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 "\n$r\n";
|
||||
|
||||
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"
|
||||
*/
|
||||
?>
|
14
application/models/tests/wstream1.xml
Normal file
14
application/models/tests/wstream1.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<audioClip>
|
||||
<metadata
|
||||
xmlns="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
||||
>
|
||||
<dc:title>Webstream test 1</dc:title>
|
||||
<dcterms:extent>01:30:00.000000</dcterms:extent>
|
||||
<ls:url>http://localhost/y</ls:url>
|
||||
</metadata>
|
||||
</audioClip>
|
Loading…
Add table
Add a link
Reference in a new issue