Refactored Alib to reveal its true nature: a bunch of static functions inside of classes. This makes it much easier to understand what is going on, and removes 4 layers of class heirarchies (now only 4 left). There are now two important global variables: CC_DBC, the database connection, and CC_CONFIG, the config variables. These used to be passed around to all classes, but since they are always the same they should be global. Refactored the StorageServer install scripts to live outside of the classes. They now live in the storageServer install scripts. A lot of functions in the StorageServer have become static as well, but there are definitely more that I didnt get to. Lots of code cleanup as well. This is a big update.
This commit is contained in:
parent
2ae9d1ff2e
commit
4733682a62
|
@ -17,24 +17,9 @@ define('ALIBERR_NOTEXISTS', 31);
|
|||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
class Alib extends Subjects {
|
||||
/**
|
||||
* The name of a database table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $permTable;
|
||||
|
||||
/**
|
||||
* The name of a database table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sessTable;
|
||||
|
||||
//var $login = NULL;
|
||||
//var $userid = NULL;
|
||||
public $sessid = NULL;
|
||||
class Alib {
|
||||
//class Alib extends Subjects {
|
||||
//public $sessid = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -42,12 +27,10 @@ class Alib extends Subjects {
|
|||
* @param DB $dbc
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(&$dbc, $config)
|
||||
{
|
||||
parent::__construct($dbc, $config);
|
||||
$this->permTable = $config['tblNamePrefix'].'perms';
|
||||
$this->sessTable = $config['tblNamePrefix'].'sess';
|
||||
} // constructor
|
||||
// public function __construct(&$dbc, $config)
|
||||
// {
|
||||
// parent::__construct($dbc, $config);
|
||||
// } // constructor
|
||||
|
||||
|
||||
/* ======================================================= public methods */
|
||||
|
@ -61,27 +44,25 @@ class Alib extends Subjects {
|
|||
* @param string $pass
|
||||
* @return boolean|sessionId|PEAR_Error
|
||||
*/
|
||||
public function login($login, $pass)
|
||||
public static function Login($login, $pass)
|
||||
{
|
||||
if (FALSE === $this->authenticate($login, $pass)) {
|
||||
$this->setTimeStamp($login, TRUE);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (FALSE === Subjects::Authenticate($login, $pass)) {
|
||||
Subjects::SetTimeStamp($login, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
$sessid = $this->_createSessid();
|
||||
$sessid = Alib::_createSessid();
|
||||
if (PEAR::isError($sessid)) {
|
||||
return $sessid;
|
||||
}
|
||||
$userid = $this->getSubjId($login);
|
||||
$sql = "INSERT INTO {$this->sessTable} (sessid, userid, login, ts)
|
||||
$userid = Subjects::GetSubjId($login);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['sessTable']." (sessid, userid, login, ts)
|
||||
VALUES('$sessid', '$userid', '$login', now())";
|
||||
$r = $this->dbc->query($sql);
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
//$this->login = $login;
|
||||
//$this->userid = $userid;
|
||||
//$this->sessid = $sessid;
|
||||
$this->setTimeStamp($login, FALSE);
|
||||
Subjects::SetTimeStamp($login, FALSE);
|
||||
return $sessid;
|
||||
} // fn login
|
||||
|
||||
|
@ -92,24 +73,22 @@ class Alib extends Subjects {
|
|||
* @param string $sessid
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
public function logout($sessid)
|
||||
public static function Logout($sessid)
|
||||
{
|
||||
$ct = $this->checkAuthToken($sessid);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ct = Alib::CheckAuthToken($sessid);
|
||||
if ($ct === FALSE) {
|
||||
return PEAR::raiseError("Alib::logout: not logged ($sessid)",
|
||||
ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
|
||||
} elseif (PEAR::isError($ct)) {
|
||||
return $ct;
|
||||
} else {
|
||||
$sql = "DELETE FROM {$this->sessTable}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['sessTable']."
|
||||
WHERE sessid='$sessid'";
|
||||
$r = $this->dbc->query($sql);
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
//$this->login = NULL;
|
||||
//$this->userid = NULL;
|
||||
//$this->sessid = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
} // fn logout
|
||||
|
@ -121,11 +100,12 @@ class Alib extends Subjects {
|
|||
* @param string $sessid
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
private function checkAuthToken($sessid)
|
||||
private static function CheckAuthToken($sessid)
|
||||
{
|
||||
$sql = "SELECT count(*) as cnt FROM {$this->sessTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable']."
|
||||
WHERE sessid='$sessid'";
|
||||
$c = $this->dbc->getOne($sql);
|
||||
$c = $CC_DBC->getOne($sql);
|
||||
return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE ));
|
||||
} //fn checkAuthToken
|
||||
|
||||
|
@ -164,12 +144,13 @@ class Alib extends Subjects {
|
|||
* @return int
|
||||
* local permission id
|
||||
*/
|
||||
public function addPerm($sid, $action, $oid, $type='A')
|
||||
public static function AddPerm($sid, $action, $oid, $type='A')
|
||||
{
|
||||
$permid = $this->dbc->nextId("{$this->permTable}_id_seq");
|
||||
$sql = "INSERT INTO {$this->permTable} (permid, subj, action, obj, type)
|
||||
VALUES ($permid, $sid, '$action', $oid, '$type')";
|
||||
$r = $this->dbc->query($sql);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$permid = $CC_DBC->nextId($CC_CONFIG['permTable']."_id_seq");
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['permTable']." (permid, subj, action, obj, type)
|
||||
VALUES ($permid, $sid, '$action', $oid, '$type')";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return($r);
|
||||
}
|
||||
|
@ -188,8 +169,9 @@ class Alib extends Subjects {
|
|||
* local object id
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removePerm($permid=NULL, $subj=NULL, $obj=NULL)
|
||||
public static function RemovePerm($permid=NULL, $subj=NULL, $obj=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ca = array();
|
||||
if ($permid) {
|
||||
$ca[] = "permid=$permid";
|
||||
|
@ -204,8 +186,8 @@ class Alib extends Subjects {
|
|||
if (!$cond) {
|
||||
return TRUE;
|
||||
}
|
||||
$sql = "DELETE FROM {$this->permTable} WHERE $cond";
|
||||
return $this->dbc->query($sql);
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['permTable']." WHERE $cond";
|
||||
return $CC_DBC->query($sql);
|
||||
} // fn removePerm
|
||||
|
||||
|
||||
|
@ -217,12 +199,13 @@ class Alib extends Subjects {
|
|||
* @return int
|
||||
* local object id
|
||||
*/
|
||||
protected function _getPermOid($permid)
|
||||
protected static function GetPermOid($permid)
|
||||
{
|
||||
$sql = "SELECT obj FROM {$this->permTable} WHERE permid=$permid";
|
||||
$res = $this->dbc->getOne($sql);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT obj FROM ".$CC_CONFIG['permTable']." WHERE permid=$permid";
|
||||
$res = $CC_DBC->getOne($sql);
|
||||
return $res;
|
||||
} // fn _getPermOid
|
||||
} // fn GetPermOid
|
||||
|
||||
|
||||
/**
|
||||
|
@ -244,17 +227,18 @@ class Alib extends Subjects {
|
|||
* @param string $action
|
||||
* from set defined in config
|
||||
* @param int $oid
|
||||
* object id, optional (default: root node)
|
||||
* @return mixed
|
||||
* boolean/err
|
||||
* object id (default: root node)
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function checkPerm($sid, $action, $oid=NULL)
|
||||
public static function CheckPerm($sid, $action, $oid=NULL)
|
||||
{
|
||||
global $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
if (!is_numeric($sid)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (is_null($oid) or $oid=='') {
|
||||
$oid = $this->getRootNode();
|
||||
$oid = M2tree::GetRootNode();
|
||||
}
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
|
@ -270,10 +254,10 @@ class Alib extends Subjects {
|
|||
// c: classTable, cm: cmembTable
|
||||
// main query elements:
|
||||
$q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
|
||||
$q_from = "{$this->permTable} p ";
|
||||
$q_from = $CC_CONFIG['permTable']." p ";
|
||||
// joins for solving users/groups:
|
||||
$q_join = "LEFT JOIN {$this->subjTable} s ON s.id=p.subj ";
|
||||
$q_join .= "LEFT JOIN {$this->smembTable} m ON m.gid=p.subj ";
|
||||
$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:
|
||||
|
@ -286,14 +270,14 @@ class Alib extends Subjects {
|
|||
$q_ordb0 = $q_ordb;
|
||||
// joins for solving object tree:
|
||||
$q_flds .= ", t.name, ts.level as tlevel";
|
||||
$q_join .= "LEFT JOIN {$this->treeTable} t ON t.id=p.obj ";
|
||||
$q_join .= "LEFT JOIN {$this->structTable} ts ON ts.parid=p.obj ";
|
||||
$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 = $this->dbc->getAll($query1);
|
||||
$r1 = $CC_DBC->getAll($query1);
|
||||
if (PEAR::isError($r1)) {
|
||||
return($r1);
|
||||
}
|
||||
|
@ -309,15 +293,15 @@ class Alib extends Subjects {
|
|||
|
||||
// joins for solving object classes:
|
||||
$q_flds = $q_flds0.", c.cname ";
|
||||
$q_join = $q_join0."LEFT JOIN {$this->classTable} c ON c.id=p.obj ";
|
||||
$q_join .= "LEFT JOIN {$this->cmembTable} cm ON cm.cid=p.obj ";
|
||||
$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 = $this->dbc->getAll($query2);
|
||||
$r2 = $CC_DBC->getAll($query2);
|
||||
if (PEAR::isError($r2)) {
|
||||
return($r2);
|
||||
return $r2;
|
||||
}
|
||||
$AllowedByClass =
|
||||
(is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
|
||||
|
@ -325,9 +309,8 @@ class Alib extends Subjects {
|
|||
// $DeniedByClass =
|
||||
// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
|
||||
$res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
|
||||
# echo"<pre>\nsid=$sid, action=$action, oid=$oid\n"; var_dump($r1); echo"\n---\n$query1\n---\n\n"; var_dump($r2); echo"\n---\n$query2\n---\n\n"; exit;
|
||||
return $res;
|
||||
} // fn checkPerm
|
||||
} // fn CheckPerm
|
||||
|
||||
|
||||
/* ---------------------------------------------------------- object tree */
|
||||
|
@ -338,13 +321,13 @@ class Alib extends Subjects {
|
|||
* @param int $id
|
||||
* @return void|PEAR_Error
|
||||
*/
|
||||
public function removeObj($id)
|
||||
public static function RemoveObj($id)
|
||||
{
|
||||
$r = $this->removePerm(NULL, NULL, $id);
|
||||
$r = Alib::RemovePerm(NULL, NULL, $id);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return parent::removeObj($id);
|
||||
return ObjClasses::RemoveObj($id);
|
||||
} // fn removeObj
|
||||
|
||||
/* --------------------------------------------------------- users/groups */
|
||||
|
@ -355,22 +338,23 @@ class Alib extends Subjects {
|
|||
* @param string $login
|
||||
* @return void|PEAR_Error
|
||||
*/
|
||||
public function removeSubj($login)
|
||||
public static function RemoveSubj($login)
|
||||
{
|
||||
$uid = $this->getSubjId($login);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
if (is_null($uid)){
|
||||
return $this->dbc->raiseError("Alib::removeSubj: Subj not found ($login)",
|
||||
return $CC_DBC->raiseError("Alib::removeSubj: Subj not found ($login)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
$r = $this->removePerm(NULL, $uid);
|
||||
$r = Alib::RemovePerm(NULL, $uid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return parent::removeSubj($login, $uid);
|
||||
} // fn removeSubj
|
||||
return Subjects::RemoveSubj($login, $uid);
|
||||
} // fn RemoveSubj
|
||||
|
||||
|
||||
/* ------------------------------------------------------------- sessions */
|
||||
|
@ -380,38 +364,40 @@ class Alib extends Subjects {
|
|||
* @param string $sessid
|
||||
* @return string|PEAR_Error
|
||||
*/
|
||||
public function getSessLogin($sessid)
|
||||
public static function GetSessLogin($sessid)
|
||||
{
|
||||
$sql = "SELECT login FROM {$this->sessTable} WHERE sessid='$sessid'";
|
||||
$r = $this->dbc->getOne($sql);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT login FROM ".$CC_CONFIG['sessTable']." WHERE sessid='$sessid'";
|
||||
$r = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if (is_null($r)){
|
||||
return PEAR::raiseError("Alib::getSessLogin:".
|
||||
return PEAR::raiseError("Alib::GetSessLogin:".
|
||||
" invalid session id ($sessid)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
return $r;
|
||||
} // fn getSessLogin
|
||||
} // fn GetSessLogin
|
||||
|
||||
|
||||
/**
|
||||
* Get user id from session id.
|
||||
*
|
||||
* @param string $sessid
|
||||
* @param string $p_sessid
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
public function getSessUserId($sessid)
|
||||
public static function GetSessUserId($p_sessid)
|
||||
{
|
||||
$sql = "SELECT userid FROM {$this->sessTable} WHERE sessid='$sessid'";
|
||||
$r = $this->dbc->getOne($sql);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT userid FROM ".$CC_CONFIG['sessTable']." WHERE sessid='$p_sessid'";
|
||||
$r = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if (is_null($r)){
|
||||
if (is_null($r)) {
|
||||
return PEAR::raiseError("Alib::getSessUserId:".
|
||||
" invalid session id ($sessid)",
|
||||
" invalid session id ($p_sessid)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
return $r;
|
||||
|
@ -425,12 +411,13 @@ class Alib extends Subjects {
|
|||
* @param int $id
|
||||
* @return array|null|PEAR_Error
|
||||
*/
|
||||
public function getObjPerms($id)
|
||||
public static function GetObjPerms($id)
|
||||
{
|
||||
$sql = "SELECT s.login, p.* FROM {$this->permTable} p, {$this->subjTable} s
|
||||
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";
|
||||
return $this->dbc->getAll($sql);
|
||||
} // fn getObjPerms
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn GetObjPerms
|
||||
|
||||
|
||||
/**
|
||||
|
@ -439,32 +426,33 @@ class Alib extends Subjects {
|
|||
* @param int $sid
|
||||
* @return array
|
||||
*/
|
||||
public function getSubjPerms($sid)
|
||||
public static function GetSubjPerms($sid)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "
|
||||
SELECT t.name, t.type as otype , p.*
|
||||
FROM {$this->permTable} p, {$this->treeTable} t
|
||||
FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t
|
||||
WHERE t.id=p.obj AND p.subj=$sid";
|
||||
$a1 = $this->dbc->getAll($sql);
|
||||
$a1 = $CC_DBC->getAll($sql);
|
||||
if (PEAR::isError($a1)) {
|
||||
return $a1;
|
||||
}
|
||||
$sql2 = "
|
||||
SELECT c.cname as name, 'C'as otype, p.*
|
||||
FROM {$this->permTable} p, {$this->classTable} c
|
||||
FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['classTable']." c
|
||||
WHERE c.id=p.obj AND p.subj=$sid";
|
||||
$a2 = $this->dbc->getAll($sql2);
|
||||
$a2 = $CC_DBC->getAll($sql2);
|
||||
if (PEAR::isError($a2)) {
|
||||
return $a2;
|
||||
}
|
||||
return array_merge($a1, $a2);
|
||||
} // fn getSubjPerms
|
||||
} // fn GetSubjPerms
|
||||
|
||||
|
||||
/* ------------------------ info methods related to application structure */
|
||||
/* (this part should be added/rewritten to allow defining/modifying/using
|
||||
* application structure)
|
||||
* (only very simple structure definition - in $config - supported now)
|
||||
* (only very simple structure definition - in $CC_CONFIG - supported now)
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -472,10 +460,11 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllActions()
|
||||
public static function GetAllActions()
|
||||
{
|
||||
return $this->config['allActions'];
|
||||
} // fn getAllActions
|
||||
global $CC_CONFIG;
|
||||
return $CC_CONFIG['allActions'];
|
||||
} // fn GetAllActions
|
||||
|
||||
|
||||
/**
|
||||
|
@ -484,10 +473,11 @@ class Alib extends Subjects {
|
|||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedActions($type)
|
||||
public static function GetAllowedActions($type)
|
||||
{
|
||||
return $this->config['allowedActions'][$type];
|
||||
} // fn getAllowedActions
|
||||
global $CC_CONFIG;
|
||||
return $CC_CONFIG['allowedActions'][$type];
|
||||
} // fn GetAllowedActions
|
||||
|
||||
|
||||
/* ====================================================== private methods */
|
||||
|
@ -497,13 +487,14 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _createSessid()
|
||||
private static function _createSessid()
|
||||
{
|
||||
for ($c=1; $c>0;){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
for ($c = 1; $c > 0; ){
|
||||
$sessid = md5(uniqid(rand()));
|
||||
$sql = "SELECT count(*) FROM {$this->sessTable}
|
||||
$sql = "SELECT count(*) FROM ".$CC_CONFIG['sessTable']."
|
||||
WHERE sessid='$sessid'";
|
||||
$c = $this->dbc->getOne($sql);
|
||||
$c = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($c)) {
|
||||
return $c;
|
||||
}
|
||||
|
@ -523,11 +514,12 @@ class Alib extends Subjects {
|
|||
* actual indentation
|
||||
* @return string
|
||||
*/
|
||||
public function dumpPerms($indstr=' ', $ind='')
|
||||
public static function DumpPerms($indstr=' ', $ind='')
|
||||
{
|
||||
$arr = $this->dbc->getAll("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$arr = $CC_DBC->getAll("
|
||||
SELECT s.login, p.action, p.type
|
||||
FROM {$this->permTable} p, {$this->subjTable} s
|
||||
FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s
|
||||
WHERE s.id=p.subj
|
||||
ORDER BY p.permid
|
||||
");
|
||||
|
@ -548,11 +540,12 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteData()
|
||||
public static function DeleteData()
|
||||
{
|
||||
$this->dbc->query("DELETE FROM {$this->permTable}");
|
||||
$this->dbc->query("DELETE FROM {$this->sessTable}");
|
||||
parent::deleteData();
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['permTable']);
|
||||
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['sessTable']);
|
||||
Subjects::DeleteData();
|
||||
} // fn deleteData
|
||||
|
||||
|
||||
|
@ -561,13 +554,14 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testData()
|
||||
public static function TestData()
|
||||
{
|
||||
parent::testData();
|
||||
$t =& $this->tdata['tree'];
|
||||
$c =& $this->tdata['classes'];
|
||||
$s =& $this->tdata['subjects'];
|
||||
$this->dbc->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$tdata = Subjects::TestData();
|
||||
$t =& $tdata['tree'];
|
||||
$c =& $tdata['classes'];
|
||||
$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'),
|
||||
|
@ -585,12 +579,13 @@ class Alib extends Subjects {
|
|||
$perms[] = array($s['test4'], 'editPerms', $c['cl2'], 'A');
|
||||
}
|
||||
foreach ($perms as $p){
|
||||
$o[] = $r = $this->addPerm($p[0], $p[1], $p[2], $p[3]);
|
||||
$o[] = $r = Alib::AddPerm($p[0], $p[1], $p[2], $p[3]);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
$this->tdata['perms'] = $o;
|
||||
$tdata['perms'] = $o;
|
||||
return $tdata;
|
||||
} // fn testData
|
||||
|
||||
|
||||
|
@ -599,56 +594,58 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function test()
|
||||
public static function Test()
|
||||
{
|
||||
if (PEAR::isError($p = parent::test())) {
|
||||
$p = Subjects::test();
|
||||
if (PEAR::isError($p)) {
|
||||
return $p;
|
||||
}
|
||||
$this->deleteData();
|
||||
$r = $this->testData();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
Alib::DeleteData();
|
||||
$tdata = Alib::TestData();
|
||||
if (PEAR::isError($tdata)) {
|
||||
return $tdata;
|
||||
}
|
||||
$this->test_correct = "root/_all/A, test1/_all/A, test1/read/D,".
|
||||
$test_correct = "root/_all/A, test1/_all/A, test1/read/D,".
|
||||
" test2/addChilds/D, test2/read/A, test2/edit/A,".
|
||||
" test1/addChilds/D, test1/addChilds/D, gr2/addChilds/A,".
|
||||
" test3/_all/D";
|
||||
if (USE_ALIB_CLASSES){
|
||||
$this->test_correct .= ", test3/read/D, test4/editPerms/A";
|
||||
$test_correct .= ", test3/read/D, test4/editPerms/A";
|
||||
}
|
||||
$this->test_correct .= "\nno, yes\n";
|
||||
$r = $this->dumpPerms();
|
||||
$test_correct .= "\nno, yes\n";
|
||||
$r = Alib::DumpPerms();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->test_dump = $r.
|
||||
($this->checkPerm(
|
||||
$this->tdata['subjects']['test1'], 'read',
|
||||
$this->tdata['tree']['t1']
|
||||
$test_dump = $r.
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'read',
|
||||
$tdata['tree']['t1']
|
||||
)? 'yes':'no').", ".
|
||||
($this->checkPerm(
|
||||
$this->tdata['subjects']['test1'], 'addChilds',
|
||||
$this->tdata['tree']['i2']
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'addChilds',
|
||||
$tdata['tree']['i2']
|
||||
)? 'yes':'no')."\n"
|
||||
;
|
||||
$this->removePerm($this->tdata['perms'][1]);
|
||||
$this->removePerm($this->tdata['perms'][3]);
|
||||
$this->test_correct .= "root/_all/A, test1/read/D,".
|
||||
Alib::RemovePerm($tdata['perms'][1]);
|
||||
Alib::RemovePerm($tdata['perms'][3]);
|
||||
$test_correct .= "root/_all/A, test1/read/D,".
|
||||
" test2/read/A, test2/edit/A,".
|
||||
" test1/addChilds/D, test1/addChilds/D, gr2/addChilds/A,".
|
||||
" test3/_all/D";
|
||||
if (USE_ALIB_CLASSES){
|
||||
$this->test_correct .= ", test3/read/D, test4/editPerms/A";
|
||||
if (USE_ALIB_CLASSES) {
|
||||
$test_correct .= ", test3/read/D, test4/editPerms/A";
|
||||
}
|
||||
$this->test_correct .= "\n";
|
||||
$this->test_dump .= $this->dumpPerms();
|
||||
$this->deleteData();
|
||||
if ($this->test_dump==$this->test_correct) {
|
||||
$this->test_log.="alib: OK\n"; return TRUE;
|
||||
$test_correct .= "\n";
|
||||
$test_dump .= Alib::DumpPerms();
|
||||
Alib::DeleteData();
|
||||
if ($test_dump == $test_correct) {
|
||||
$test_log .= "alib: OK\n";
|
||||
return TRUE;
|
||||
} else {
|
||||
return PEAR::raiseError('Alib::test', 1, PEAR_ERROR_DIE, '%s'.
|
||||
"<pre>\ncorrect:\n{$this->test_correct}\n".
|
||||
"dump:\n{$this->test_dump}\n</pre>\n");
|
||||
"<pre>\ncorrect:\n{$test_correct}\n".
|
||||
"dump:\n{$test_dump}\n</pre>\n");
|
||||
}
|
||||
} // fn test
|
||||
|
||||
|
@ -658,37 +655,37 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
parent::install();
|
||||
$this->dbc->query("CREATE TABLE {$this->permTable} (
|
||||
permid int not null PRIMARY KEY,
|
||||
subj int REFERENCES {$this->subjTable} ON DELETE CASCADE,
|
||||
action varchar(20),
|
||||
obj int,
|
||||
type char(1)
|
||||
)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->permTable}_permid_idx
|
||||
ON {$this->permTable} (permid)");
|
||||
$this->dbc->query("CREATE INDEX {$this->permTable}_subj_obj_idx
|
||||
ON {$this->permTable} (subj, obj)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->permTable}_all_idx
|
||||
ON {$this->permTable} (subj, action, obj)");
|
||||
$this->dbc->createSequence("{$this->permTable}_id_seq");
|
||||
|
||||
$this->dbc->query("CREATE TABLE {$this->sessTable} (
|
||||
sessid char(32) not null PRIMARY KEY,
|
||||
userid int REFERENCES {$this->subjTable} ON DELETE CASCADE,
|
||||
login varchar(255),
|
||||
ts timestamp
|
||||
)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->sessTable}_sessid_idx
|
||||
ON {$this->sessTable} (sessid)");
|
||||
$this->dbc->query("CREATE INDEX {$this->sessTable}_userid_idx
|
||||
ON {$this->sessTable} (userid)");
|
||||
$this->dbc->query("CREATE INDEX {$this->sessTable}_login_idx
|
||||
ON {$this->sessTable} (login)");
|
||||
} // fn install
|
||||
// public function install()
|
||||
// {
|
||||
// parent::install();
|
||||
// $CC_DBC->query("CREATE TABLE {$this->permTable} (
|
||||
// permid int not null PRIMARY KEY,
|
||||
// subj int REFERENCES {$this->subjTable} ON DELETE CASCADE,
|
||||
// action varchar(20),
|
||||
// obj int,
|
||||
// type char(1)
|
||||
// )");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->permTable}_permid_idx
|
||||
// ON {$this->permTable} (permid)");
|
||||
// $CC_DBC->query("CREATE INDEX {$this->permTable}_subj_obj_idx
|
||||
// ON {$this->permTable} (subj, obj)");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->permTable}_all_idx
|
||||
// ON {$this->permTable} (subj, action, obj)");
|
||||
// $CC_DBC->createSequence("{$this->permTable}_id_seq");
|
||||
//
|
||||
// $CC_DBC->query("CREATE TABLE {$this->sessTable} (
|
||||
// sessid char(32) not null PRIMARY KEY,
|
||||
// userid int REFERENCES {$this->subjTable} ON DELETE CASCADE,
|
||||
// login varchar(255),
|
||||
// ts timestamp
|
||||
// )");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->sessTable}_sessid_idx
|
||||
// ON {$this->sessTable} (sessid)");
|
||||
// $CC_DBC->query("CREATE INDEX {$this->sessTable}_userid_idx
|
||||
// ON {$this->sessTable} (userid)");
|
||||
// $CC_DBC->query("CREATE INDEX {$this->sessTable}_login_idx
|
||||
// ON {$this->sessTable} (login)");
|
||||
// } // fn install
|
||||
|
||||
|
||||
/**
|
||||
|
@ -696,13 +693,14 @@ class Alib extends Subjects {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->permTable}");
|
||||
$this->dbc->dropSequence("{$this->permTable}_id_seq");
|
||||
$this->dbc->query("DROP TABLE {$this->sessTable}");
|
||||
parent::uninstall();
|
||||
} // fn uninstall
|
||||
// public function uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['permTable']);
|
||||
// $CC_DBC->dropSequence($CC_CONFIG['permTable']."_id_seq");
|
||||
// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['sessTable']);
|
||||
// parent::uninstall();
|
||||
// } // fn uninstall
|
||||
|
||||
} // class Alib
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -15,33 +15,18 @@ require_once("M2tree.php");
|
|||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
class ObjClasses extends M2tree {
|
||||
/**
|
||||
* The name of the database table ("PREFIXclasses")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $classTable;
|
||||
|
||||
/**
|
||||
* The name of a database table ("PREFIXcmemb")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $cmembTable;
|
||||
|
||||
class ObjClasses {
|
||||
//class ObjClasses extends M2tree {
|
||||
|
||||
/**
|
||||
* @param object $dbc
|
||||
* @param array $config
|
||||
* @return this
|
||||
*/
|
||||
public function __construct(&$dbc, $config)
|
||||
{
|
||||
parent::__construct($dbc, $config);
|
||||
$this->classTable = $config['tblNamePrefix'].'classes';
|
||||
$this->cmembTable = $config['tblNamePrefix'].'cmemb';
|
||||
}
|
||||
// public function __construct(&$dbc, $config)
|
||||
// {
|
||||
// parent::__construct($dbc, $config);
|
||||
// }
|
||||
|
||||
|
||||
/* ======================================================= public methods */
|
||||
|
@ -50,16 +35,17 @@ class ObjClasses extends M2tree {
|
|||
* Add new class of objects
|
||||
*
|
||||
* @param string $cname
|
||||
* @return id/error
|
||||
* @return id|PEAR_Error
|
||||
*/
|
||||
public function addClass($cname)
|
||||
public static function AddClass($cname)
|
||||
{
|
||||
$id = $this->dbc->nextId("{$this->treeTable}_id_seq");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['treeTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$r = $this->dbc->query("
|
||||
INSERT INTO {$this->classTable} (id, cname)
|
||||
$r = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['classTable']." (id, cname)
|
||||
VALUES ($id, '$cname')
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -73,32 +59,33 @@ class ObjClasses extends M2tree {
|
|||
* Remove class by name
|
||||
*
|
||||
* @param string $cname
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removeClass($cname)
|
||||
{
|
||||
$cid = $this->getClassId($cname);
|
||||
if (PEAR::isError($cid)) {
|
||||
return($cid);
|
||||
}
|
||||
return $this->removeClassById($cid);
|
||||
}
|
||||
// public static function RemoveClass($cname)
|
||||
// {
|
||||
// $cid = ObjClasses::GetClassId($cname);
|
||||
// if (PEAR::isError($cid)) {
|
||||
// return($cid);
|
||||
// }
|
||||
// return ObjClasses::RemoveClassById($cid);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Remove class by id
|
||||
*
|
||||
* @param int $cid
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removeClassById($cid)
|
||||
public static function RemoveClassById($cid)
|
||||
{
|
||||
$r = $this->dbc->query("DELETE FROM {$this->cmembTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['cmembTable']."
|
||||
WHERE cid=$cid");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = $this->dbc->query("DELETE FROM {$this->classTable}
|
||||
$r = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['classTable']."
|
||||
WHERE id=$cid");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -112,11 +99,12 @@ class ObjClasses extends M2tree {
|
|||
*
|
||||
* @param int $cid
|
||||
* @param int $oid
|
||||
* @return boolean/err
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
public function addObj2Class($cid, $oid)
|
||||
public static function AddObjectToClass($cid, $oid)
|
||||
{
|
||||
$r = $this->dbc->query("INSERT INTO {$this->cmembTable} (cid, objid)
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("INSERT INTO ".$CC_CONFIG['cmembTable']." (cid, objid)
|
||||
VALUES ($cid, $oid)");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -129,12 +117,13 @@ class ObjClasses extends M2tree {
|
|||
* Remove object from class
|
||||
*
|
||||
* @param int $oid
|
||||
* @param int $cid, optional, default: remove obj from all classes
|
||||
* @return boolean/err
|
||||
* @param int $cid, default: remove obj from all classes
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
public function removeObjFromClass($oid, $cid=NULL)
|
||||
public static function RemoveObjectFromClass($oid, $cid=NULL)
|
||||
{
|
||||
$r = $this->dbc->query("DELETE FROM {$this->cmembTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['cmembTable']."
|
||||
WHERE objid=$oid".(is_null($cid)? '':" AND cid=$cid"));
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -149,15 +138,15 @@ class ObjClasses extends M2tree {
|
|||
* Remove object from all classes and remove object itself
|
||||
*
|
||||
* @param int $id
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removeObj($id)
|
||||
public static function RemoveObj($id)
|
||||
{
|
||||
$r = $this->removeObjFromClass($id);
|
||||
$r = ObjClasses::RemoveObjectFromClass($id);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return parent::removeObj($id);
|
||||
return M2tree::RemoveObj($id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,12 +156,13 @@ class ObjClasses extends M2tree {
|
|||
* Get class id from name
|
||||
*
|
||||
* @param string $cname
|
||||
* @return int/err
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
public function getClassId($cname)
|
||||
public static function GetClassId($cname)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$cname = pg_escape_string($cname);
|
||||
return $this->dbc->getOne($query = "SELECT id FROM {$this->classTable}
|
||||
return $CC_DBC->getOne($query = "SELECT id FROM ".$CC_CONFIG['classTable']."
|
||||
WHERE cname='$cname'");
|
||||
}
|
||||
|
||||
|
@ -181,12 +171,13 @@ class ObjClasses extends M2tree {
|
|||
* Get class name from id
|
||||
*
|
||||
* @param int $id
|
||||
* @return string/err
|
||||
* @return string|PEAR_Error
|
||||
*/
|
||||
public function getClassName($id)
|
||||
public static function GetClassName($id)
|
||||
{
|
||||
return $this->dbc->getOne(
|
||||
$query = "SELECT cname FROM {$this->classTable} WHERE id=$id");
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$sql = "SELECT cname FROM ".$CC_CONFIG['classTable']." WHERE id=$id";
|
||||
return $CC_DBC->getOne($sql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,11 +185,12 @@ class ObjClasses extends M2tree {
|
|||
* Return true is object is class
|
||||
*
|
||||
* @param int $id
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function isClass($id)
|
||||
public static function IsClass($id)
|
||||
{
|
||||
$r = $this->dbc->getOne("SELECT count(*) FROM {$this->classTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->getOne("SELECT count(*) FROM ".$CC_CONFIG['classTable']."
|
||||
WHERE id=$id");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -210,11 +202,12 @@ class ObjClasses extends M2tree {
|
|||
/**
|
||||
* Return all classes
|
||||
*
|
||||
* @return array/err
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
public function getClasses()
|
||||
public static function GetClasses()
|
||||
{
|
||||
return $this->dbc->getAll("SELECT * FROM {$this->classTable}");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
return $CC_DBC->getAll("SELECT * FROM ".$CC_CONFIG['classTable']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,12 +215,13 @@ class ObjClasses extends M2tree {
|
|||
* Return all objects in class
|
||||
*
|
||||
* @param int $id
|
||||
* @return array/err
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
public function listClass($id)
|
||||
public static function ListClass($id)
|
||||
{
|
||||
return $this->dbc->getAll("
|
||||
SELECT t.* FROM {$this->cmembTable} cm, {$this->treeTable} t
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
return $CC_DBC->getAll("
|
||||
SELECT t.* FROM ".$CC_CONFIG['cmembTable']." cm, ".$CC_CONFIG['treeTable']." t
|
||||
WHERE cm.cid=$id AND cm.objid=t.id");
|
||||
}
|
||||
|
||||
|
@ -243,13 +237,14 @@ class ObjClasses extends M2tree {
|
|||
* actual indentation
|
||||
* @return string
|
||||
*/
|
||||
public function dumpClasses($indstr=' ', $ind='')
|
||||
public static function DumpClasses($indstr=' ', $ind='')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $ind.join(', ', array_map(
|
||||
create_function('$v', 'return "{$v[\'cname\']} ({$v[\'cnt\']})";'),
|
||||
$this->dbc->getAll("
|
||||
SELECT cname, count(cm.objid)as cnt FROM {$this->classTable} c
|
||||
LEFT JOIN {$this->cmembTable} cm ON c.id=cm.cid
|
||||
$CC_DBC->getAll("
|
||||
SELECT cname, count(cm.objid)as cnt FROM ".$CC_CONFIG['classTable']." c
|
||||
LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON c.id=cm.cid
|
||||
GROUP BY cname, c.id ORDER BY c.id
|
||||
")
|
||||
))."\n";
|
||||
|
@ -258,14 +253,15 @@ class ObjClasses extends M2tree {
|
|||
|
||||
|
||||
/**
|
||||
* Delete all classes and membeship records
|
||||
* Delete all classes and membership records.
|
||||
* @return void
|
||||
*/
|
||||
public function deleteData()
|
||||
public static function DeleteData()
|
||||
{
|
||||
$this->dbc->query("DELETE FROM {$this->cmembTable}");
|
||||
$this->dbc->query("DELETE FROM {$this->classTable}");
|
||||
parent::reset();
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['cmembTable']);
|
||||
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['classTable']);
|
||||
M2tree::reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,16 +269,17 @@ class ObjClasses extends M2tree {
|
|||
* Insert test data
|
||||
*
|
||||
*/
|
||||
public function testData()
|
||||
public static function TestData()
|
||||
{
|
||||
parent::testData();
|
||||
$o['cl_sa'] = $this->addClass('Sections a');
|
||||
$o['cl2'] = $this->addClass('Class 2');
|
||||
$this->addObj2Class($o['cl_sa'], $this->tdata['tree']['s1a']);
|
||||
$this->addObj2Class($o['cl_sa'], $this->tdata['tree']['s2a']);
|
||||
$this->addObj2Class($o['cl2'], $this->tdata['tree']['t1']);
|
||||
$this->addObj2Class($o['cl2'], $this->tdata['tree']['pb']);
|
||||
$this->tdata['classes'] = $o;
|
||||
$tdata = M2tree::testData();
|
||||
$o['cl_sa'] = ObjClasses::AddClass('Sections a');
|
||||
$o['cl2'] = ObjClasses::AddClass('Class 2');
|
||||
ObjClasses::AddObjectToClass($o['cl_sa'], $tdata['tree']['s1a']);
|
||||
ObjClasses::AddObjectToClass($o['cl_sa'], $tdata['tree']['s2a']);
|
||||
ObjClasses::AddObjectToClass($o['cl2'], $tdata['tree']['t1']);
|
||||
ObjClasses::AddObjectToClass($o['cl2'], $tdata['tree']['pb']);
|
||||
$tdata['classes'] = $o;
|
||||
return $tdata;
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,28 +287,30 @@ class ObjClasses extends M2tree {
|
|||
* Make basic test
|
||||
*
|
||||
*/
|
||||
public function test()
|
||||
public static function Test()
|
||||
{
|
||||
if (PEAR::isError($p = parent::test())) {
|
||||
$p = M2tree::test();
|
||||
if (PEAR::isError($p)) {
|
||||
return $p;
|
||||
}
|
||||
$this->deleteData();
|
||||
$this->testData();
|
||||
$this->test_correct = "Sections a (2), Class 2 (2)\n";
|
||||
$this->test_dump = $this->dumpClasses();
|
||||
$this->removeClass('Sections a');
|
||||
$this->removeObjFromClass($this->tdata['tree']['pb'],
|
||||
$this->tdata['classes']['cl2']);
|
||||
$this->test_correct .= "Class 2 (1)\n";
|
||||
$this->test_dump .= $this->dumpClasses();
|
||||
$this->deleteData();
|
||||
if ($this->test_dump==$this->test_correct) {
|
||||
$this->test_log.="class: OK\n"; return TRUE;
|
||||
ObjClasses::DeleteData();
|
||||
ObjClasses::TestData();
|
||||
$test_correct = "Sections a (2), Class 2 (2)\n";
|
||||
$test_dump = ObjClasses::DumpClasses();
|
||||
//$this->removeClass('Sections a');
|
||||
ObjClasses::RemoveObjectFromClass($tdata['tree']['pb'],
|
||||
$tdata['classes']['cl2']);
|
||||
$test_correct .= "Class 2 (1)\n";
|
||||
$test_dump .= ObjClasses::DumpClasses();
|
||||
ObjClasses::DeleteData();
|
||||
if ($test_dump == $test_correct) {
|
||||
$test_log .= "class: OK\n";
|
||||
return TRUE;
|
||||
} else {
|
||||
return PEAR::raiseError(
|
||||
'ObjClasses::test:', 1, PEAR_ERROR_DIE, '%s'.
|
||||
"<pre>\ncorrect:\n{$this->test_correct}\n".
|
||||
"dump:\n{$this->test_dump}\n</pre>\n");
|
||||
'ObjClasses::test:', 1, PEAR_ERROR_DIE, '%s'.
|
||||
"<pre>\ncorrect:\n{$test_correct}\n".
|
||||
"dump:\n{$test_dump}\n</pre>\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,36 +319,37 @@ class ObjClasses extends M2tree {
|
|||
* Create tables + initialize
|
||||
*
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
parent::install();
|
||||
$this->dbc->query("CREATE TABLE {$this->classTable} (
|
||||
id int not null PRIMARY KEY,
|
||||
cname varchar(20)
|
||||
)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->classTable}_id_idx
|
||||
ON {$this->classTable} (id)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->classTable}_cname_idx
|
||||
ON {$this->classTable} (cname)");
|
||||
|
||||
$this->dbc->query("CREATE TABLE {$this->cmembTable} (
|
||||
objid int not null,
|
||||
cid int not null
|
||||
)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->cmembTable}_idx
|
||||
ON {$this->cmembTable} (objid, cid)");
|
||||
}
|
||||
// public function install()
|
||||
// {
|
||||
// parent::install();
|
||||
// $CC_DBC->query("CREATE TABLE {$this->classTable} (
|
||||
// id int not null PRIMARY KEY,
|
||||
// cname varchar(20)
|
||||
// )");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->classTable}_id_idx
|
||||
// ON {$this->classTable} (id)");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->classTable}_cname_idx
|
||||
// ON {$this->classTable} (cname)");
|
||||
//
|
||||
// $CC_DBC->query("CREATE TABLE {$this->cmembTable} (
|
||||
// objid int not null,
|
||||
// cid int not null
|
||||
// )");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->cmembTable}_idx
|
||||
// ON {$this->cmembTable} (objid, cid)");
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Drop tables etc.
|
||||
*
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->classTable}");
|
||||
$this->dbc->query("DROP TABLE {$this->cmembTable}");
|
||||
parent::uninstall();
|
||||
}
|
||||
// public static function Uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['classTable']);
|
||||
// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['cmembTable']);
|
||||
// parent::uninstall();
|
||||
// }
|
||||
} // class ObjClasses
|
||||
?>
|
|
@ -21,21 +21,8 @@ define('ALIBERR_BADSMEMB', 21);
|
|||
* @see ObjClasses
|
||||
* @see Alib
|
||||
*/
|
||||
class Subjects extends ObjClasses {
|
||||
/**
|
||||
* The name of the 'Subjects' database table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subjTable;
|
||||
|
||||
/**
|
||||
* The name of a database table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $smembTable;
|
||||
|
||||
class Subjects {
|
||||
//class Subjects extends ObjClasses {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -44,12 +31,10 @@ class Subjects extends ObjClasses {
|
|||
* @param array $config
|
||||
* @return this
|
||||
*/
|
||||
public function __construct(&$dbc, $config)
|
||||
{
|
||||
parent::__construct($dbc, $config);
|
||||
$this->subjTable = $config['tblNamePrefix'].'subjs';
|
||||
$this->smembTable = $config['tblNamePrefix'].'smemb';
|
||||
} // constructor
|
||||
// public function __construct(&$dbc, $config)
|
||||
// {
|
||||
// parent::__construct($dbc, $config);
|
||||
// } // constructor
|
||||
|
||||
|
||||
/* ======================================================= public methods */
|
||||
|
@ -57,30 +42,31 @@ class Subjects extends ObjClasses {
|
|||
/**
|
||||
* Add new subject
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @param string $realname
|
||||
* @param boolean $passenc
|
||||
* @param string $p_login
|
||||
* @param string $p_pass
|
||||
* @param string $p_realname
|
||||
* @param boolean $p_passenc
|
||||
* password already encrypted if true
|
||||
* @return int/err
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
public function addSubj($login, $pass=NULL, $realname='', $passenc=FALSE)
|
||||
public static function AddSubj($p_login, $p_pass=NULL, $p_realname='', $p_passenc=FALSE)
|
||||
{
|
||||
if(!$login) {
|
||||
return $this->dbc->raiseError(get_class($this)."::addSubj: empty login");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!$p_login) {
|
||||
return $CC_DBC->raiseError("Subjects::AddSubj: empty login");
|
||||
}
|
||||
$id = $this->dbc->nextId("{$this->subjTable}_id_seq");
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['subjTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
if (!is_null($pass) && !$passenc) {
|
||||
$pass = md5($pass);
|
||||
if (!is_null($p_pass) && !$p_passenc) {
|
||||
$p_pass = md5($p_pass);
|
||||
}
|
||||
$sql = "INSERT INTO {$this->subjTable} (id, login, pass, type, realname)
|
||||
VALUES ($id, '$login', ".
|
||||
(is_null($pass) ? "'!', 'G'" : "'$pass', 'U'").",
|
||||
'$realname')";
|
||||
$r = $this->dbc->query($sql);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['subjTable']." (id, login, pass, type, realname)
|
||||
VALUES ($id, '$p_login', ".
|
||||
(is_null($p_pass) ? "'!', 'G'" : "'$p_pass', 'U'").",
|
||||
'$p_realname')";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -94,29 +80,30 @@ class Subjects extends ObjClasses {
|
|||
* @param string $login
|
||||
* @param int $uid
|
||||
* optional, default: null
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removeSubj($login, $uid=NULL)
|
||||
public static function RemoveSubj($login, $uid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($uid)) {
|
||||
$uid = $this->getSubjId($login);
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
}
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
$sql = "DELETE FROM {$this->smembTable}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE (uid='$uid' OR gid='$uid') AND mid is null";
|
||||
$r = $this->dbc->query($sql);
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$sql2 = "DELETE FROM {$this->subjTable}
|
||||
$sql2 = "DELETE FROM ".$CC_CONFIG['subjTable']."
|
||||
WHERE login='$login'";
|
||||
$r = $this->dbc->query($sql2);
|
||||
$r = $CC_DBC->query($sql2);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $this->_rebuildRels();
|
||||
return Subjects::_rebuildRels();
|
||||
} // fn removeSubj
|
||||
|
||||
|
||||
|
@ -126,14 +113,15 @@ class Subjects extends ObjClasses {
|
|||
* @param string $login
|
||||
* @param string $pass
|
||||
* optional
|
||||
* @return boolean/int/err
|
||||
* @return boolean|int|PEAR_Error
|
||||
*/
|
||||
public function authenticate($login, $pass='')
|
||||
public static function Authenticate($login, $pass='')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$cpass = md5($pass);
|
||||
$sql = "SELECT id FROM {$this->subjTable}
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']."
|
||||
WHERE login='$login' AND pass='$cpass' AND type='U'";
|
||||
$id = $this->dbc->getOne($sql);
|
||||
$id = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -147,14 +135,15 @@ class Subjects extends ObjClasses {
|
|||
* @param string $login
|
||||
* @param boolean $failed
|
||||
* true=> set lastfail, false=> set lastlogin
|
||||
* @return boolean/int/err
|
||||
* @return boolean|int|PEAR_Error
|
||||
*/
|
||||
public function setTimeStamp($login, $failed=FALSE)
|
||||
public static function SetTimeStamp($login, $failed=FALSE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$fld = ($failed ? 'lastfail' : 'lastlogin');
|
||||
$sql = "UPDATE {$this->subjTable} SET $fld=now()
|
||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET $fld=now()
|
||||
WHERE login='$login'";
|
||||
$r = $this->dbc->query($sql);
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -172,10 +161,11 @@ class Subjects extends ObjClasses {
|
|||
* optional
|
||||
* @param boolean $passenc
|
||||
* optional, password already encrypted if true
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
||||
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!$passenc) {
|
||||
$cpass = md5($pass);
|
||||
} else {
|
||||
|
@ -187,9 +177,9 @@ class Subjects extends ObjClasses {
|
|||
} else {
|
||||
$oldpCond = '';
|
||||
}
|
||||
$sql = "UPDATE {$this->subjTable} SET pass='$cpass'
|
||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'
|
||||
WHERE login='$login' $oldpCond AND type='U'";
|
||||
$r = $this->dbc->query($sql);
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -205,19 +195,19 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @param string $login
|
||||
* @param string $gname
|
||||
* @return int/err
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
public function addSubj2Gr($login, $gname)
|
||||
public static function AddSubjectToGroup($login, $gname)
|
||||
{
|
||||
$uid = $this->getSubjId($login);
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
$gid = $this->getSubjId($gname);
|
||||
$gid = Subjects::GetSubjId($gname);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
$isgr = $this->isGroup($gid);
|
||||
$isgr = Subjects::IsGroup($gid);
|
||||
if (PEAR::isError($isgr)) {
|
||||
return $isgr;
|
||||
}
|
||||
|
@ -225,17 +215,17 @@ class Subjects extends ObjClasses {
|
|||
return PEAR::raiseError("Subjects::addSubj2Gr: Not a group ($gname)", ALIBERR_NOTGR);
|
||||
}
|
||||
// add subject and all [in]direct members to group $gname:
|
||||
$mid = $this->_plainAddSubj2Gr($uid, $gid);
|
||||
$mid = Subjects::_plainAddSubjectToGroup($uid, $gid);
|
||||
if (PEAR::isError($mid)) {
|
||||
return $mid;
|
||||
}
|
||||
// add it to all groups where $gname is [in]direct member:
|
||||
$marr = $this->_listRMemb($gid);
|
||||
$marr = Subjects::_listRMemb($gid);
|
||||
if (PEAR::isError($marr)) {
|
||||
return $marr;
|
||||
}
|
||||
foreach($marr as $k=>$v){
|
||||
$r = $this->_plainAddSubj2Gr(
|
||||
foreach ($marr as $k => $v) {
|
||||
$r = Subjects::_plainAddSubjectToGroup(
|
||||
$uid, $v['gid'], intval($v['level'])+1, $v['id']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -250,21 +240,22 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @param string $login
|
||||
* @param string $gname
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removeSubjFromGr($login, $gname)
|
||||
public static function RemoveSubjectFromGroup($login, $gname)
|
||||
{
|
||||
$uid = $this->getSubjId($login);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
$gid = $this->getSubjId($gname);
|
||||
$gid = Subjects::GetSubjId($gname);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
$sql = "SELECT id FROM {$this->smembTable}
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE uid='$uid' AND gid='$gid' AND mid is null";
|
||||
$mid = $this->dbc->getOne($sql);
|
||||
$mid = $CC_DBC->getOne($sql);
|
||||
if (is_null($mid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -272,12 +263,12 @@ class Subjects extends ObjClasses {
|
|||
return $mid;
|
||||
}
|
||||
// remove it:
|
||||
$r = $this->_removeMemb($mid);
|
||||
$r = Subjects::_removeMemb($mid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
// and rebuild indirect memberships:
|
||||
$r = $this->_rebuildRels();
|
||||
$r = Subjects::_rebuildRels();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -291,13 +282,15 @@ class Subjects extends ObjClasses {
|
|||
* Get subject id from login
|
||||
*
|
||||
* @param string $login
|
||||
* @return int/err
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
public function getSubjId($login)
|
||||
public static function GetSubjId($login)
|
||||
{
|
||||
$sql = "SELECT id FROM {$this->subjTable}
|
||||
global $CC_CONFIG;
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']."
|
||||
WHERE login='$login'";
|
||||
return $this->dbc->getOne($sql);
|
||||
return $CC_DBC->getOne($sql);
|
||||
} // fn getSubjId
|
||||
|
||||
|
||||
|
@ -306,13 +299,15 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @param int $id
|
||||
* @param string $fld
|
||||
* @return string/err
|
||||
* @return string|PEAR_Error
|
||||
*/
|
||||
public function getSubjName($id, $fld='login')
|
||||
public static function GetSubjName($id, $fld='login')
|
||||
{
|
||||
$sql = "SELECT $fld FROM {$this->subjTable}
|
||||
global $CC_CONFIG;
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT $fld FROM ".$CC_CONFIG['subjTable']."
|
||||
WHERE id='$id'";
|
||||
return $this->dbc->getOne($sql);
|
||||
return $CC_DBC->getOne($sql);
|
||||
} // fn getSubjName
|
||||
|
||||
|
||||
|
@ -320,30 +315,32 @@ class Subjects extends ObjClasses {
|
|||
* Get all subjects
|
||||
*
|
||||
* @param string $flds
|
||||
* @return array/err
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
public function getSubjects($flds='id, login')
|
||||
public static function GetSubjects($flds='id, login')
|
||||
{
|
||||
$sql = "SELECT $flds FROM {$this->subjTable}";
|
||||
return $this->dbc->getAll($sql);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT $flds FROM ".$CC_CONFIG['subjTable'];
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn getSubjects
|
||||
|
||||
|
||||
/**
|
||||
* Get subjects with count of direct members
|
||||
*
|
||||
* @return array/err
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
public function getSubjectsWCnt()
|
||||
public static function GetSubjectsWCnt()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "
|
||||
SELECT count(m.uid)as cnt, s.id, s.login, s.type
|
||||
FROM {$this->subjTable} s
|
||||
LEFT JOIN {$this->smembTable} m ON m.gid=s.id
|
||||
FROM ".$CC_CONFIG['subjTable']." s
|
||||
LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=s.id
|
||||
WHERE m.mid is null
|
||||
GROUP BY s.id, s.login, s.type
|
||||
ORDER BY s.id";
|
||||
return $this->dbc->getAll($sql);
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn getSubjectsWCnt
|
||||
|
||||
|
||||
|
@ -351,13 +348,14 @@ class Subjects extends ObjClasses {
|
|||
* Return true if subject is a group
|
||||
*
|
||||
* @param int $gid
|
||||
* @return boolean/err
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function isGroup($gid)
|
||||
public static function IsGroup($gid)
|
||||
{
|
||||
$sql = "SELECT type FROM {$this->subjTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT type FROM ".$CC_CONFIG['subjTable']."
|
||||
WHERE id='$gid'";
|
||||
$r = $this->dbc->getOne($sql);
|
||||
$r = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -369,14 +367,15 @@ class Subjects extends ObjClasses {
|
|||
* List direct members of group
|
||||
*
|
||||
* @param int $gid
|
||||
* @return array/err
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
public function listGroup($gid)
|
||||
public static function ListGroup($gid)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT s.id, s.login, s.type
|
||||
FROM {$this->smembTable} m, {$this->subjTable} s
|
||||
FROM ".$CC_CONFIG['smembTable']." m, ".$CC_CONFIG['subjTable']." s
|
||||
WHERE m.uid=s.id AND m.mid is null AND m.gid='$gid'";
|
||||
return $this->dbc->getAll($sql);
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn listGroup
|
||||
|
||||
|
||||
|
@ -389,14 +388,15 @@ class Subjects extends ObjClasses {
|
|||
* local group id
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMemberOf($uid, $gid)
|
||||
public static function IsMemberOf($uid, $gid)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "
|
||||
SELECT count(*)as cnt
|
||||
FROM {$this->smembTable}
|
||||
FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE uid='$uid' AND gid='$gid'
|
||||
";
|
||||
$res = $this->dbc->getOne($sql);
|
||||
$res = $CC_DBC->getOne($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -413,16 +413,17 @@ class Subjects extends ObjClasses {
|
|||
* @param int $gid
|
||||
* @param int $level
|
||||
* @param int $mid
|
||||
* @return int/err
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
private function _addMemb($uid, $gid, $level=0, $mid='null')
|
||||
private static function _addMemb($uid, $gid, $level=0, $mid='null')
|
||||
{
|
||||
if($uid == $gid) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if ($uid == $gid) {
|
||||
return PEAR::raiseError("Subjects::_addMemb: uid==gid ($uid)", ALIBERR_BADSMEMB);
|
||||
}
|
||||
$sql = "SELECT id, level, mid FROM {$this->smembTable}
|
||||
$sql = "SELECT id, level, mid FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE uid='$uid' AND gid='$gid' ORDER BY level ASC";
|
||||
$a = $this->dbc->getAll($sql);
|
||||
$a = $CC_DBC->getAll($sql);
|
||||
if (PEAR::isError($a)) {
|
||||
return $a;
|
||||
}
|
||||
|
@ -430,23 +431,23 @@ class Subjects extends ObjClasses {
|
|||
$a0 = $a[0];
|
||||
$id = $a0['id'];
|
||||
if ($level < intval($a0['level'])){
|
||||
$sql2 = "UPDATE {$this->smembTable}
|
||||
$sql2 = "UPDATE ".$CC_CONFIG['smembTable']."
|
||||
SET level='$level', mid=$mid WHERE id='{$a0['id']}'";
|
||||
$r = $this->dbc->query($sql2);
|
||||
$r = $CC_DBC->query($sql2);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$id = $this->dbc->nextId("{$this->smembTable}_id_seq");
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['smembTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$sql3 = "
|
||||
INSERT INTO {$this->smembTable} (id, uid, gid, level, mid)
|
||||
INSERT INTO ".$CC_CONFIG['smembTable']." (id, uid, gid, level, mid)
|
||||
VALUES ($id, $uid, $gid, $level, $mid)
|
||||
";
|
||||
$r = $this->dbc->query($sql3);
|
||||
$r = $CC_DBC->query($sql3);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -461,11 +462,12 @@ class Subjects extends ObjClasses {
|
|||
* @param int $mid
|
||||
* @return null|PEAR_Error
|
||||
*/
|
||||
private function _removeMemb($mid)
|
||||
private static function _removeMemb($mid)
|
||||
{
|
||||
$sql = "DELETE FROM {$this->smembTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE id='$mid'";
|
||||
return $this->dbc->query($sql);
|
||||
return $CC_DBC->query($sql);
|
||||
} // fn _removeMemb
|
||||
|
||||
|
||||
|
@ -476,12 +478,13 @@ class Subjects extends ObjClasses {
|
|||
* @param int $uid
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
private function _listMemb($gid, $uid=NULL)
|
||||
private static function _listMemb($gid, $uid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "
|
||||
SELECT id, uid, level FROM {$this->smembTable}
|
||||
SELECT id, uid, level FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE gid='$gid'".(is_null($uid) ? '' : " AND uid='$uid'");
|
||||
return $this->dbc->getAll($sql);
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn _listMemb
|
||||
|
||||
|
||||
|
@ -490,14 +493,15 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @param int $gid
|
||||
* @param int $uid
|
||||
* @return array/err
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
private function _listRMemb($uid, $gid=NULL)
|
||||
private static function _listRMemb($uid, $gid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "
|
||||
SELECT id, gid, level FROM {$this->smembTable}
|
||||
SELECT id, gid, level FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE uid='$uid'".(is_null($gid) ? '' : " AND gid='$gid'");
|
||||
return $this->dbc->getAll($sql);
|
||||
return $CC_DBC->getAll($sql);
|
||||
} // fn listRMemb
|
||||
|
||||
|
||||
|
@ -510,18 +514,18 @@ class Subjects extends ObjClasses {
|
|||
* @param int $rmid
|
||||
* @return int|PEAR_Error
|
||||
*/
|
||||
private function _plainAddSubj2Gr($uid, $gid, $level=0, $rmid='null')
|
||||
private static function _plainAddSubjectToGroup($uid, $gid, $level=0, $rmid='null')
|
||||
{
|
||||
$mid = $this->_addMemb($uid, $gid, $level, $rmid);
|
||||
$mid = Subjects::_addMemb($uid, $gid, $level, $rmid);
|
||||
if (PEAR::isError($mid)) {
|
||||
return $mid;
|
||||
}
|
||||
$marr = $this->_listMemb($uid);
|
||||
$marr = Subjects::_listMemb($uid);
|
||||
if (PEAR::isError($marr)) {
|
||||
return $marr;
|
||||
}
|
||||
foreach ($marr as $k => $v) {
|
||||
$r = $this->_addMemb(
|
||||
$r = Subjects::_addMemb(
|
||||
$v['uid'], $gid, intval($v['level'])+$level+1, $mid
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -529,7 +533,7 @@ class Subjects extends ObjClasses {
|
|||
}
|
||||
}
|
||||
return $mid;
|
||||
} // fn _plainAddSubj2Gr
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -538,30 +542,31 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
private function _rebuildRels()
|
||||
private static function _rebuildRels()
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
$r = $this->dbc->query("LOCK TABLE {$this->smembTable}");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$r = $CC_DBC->query("LOCK TABLE ".$CC_CONFIG['smembTable']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = $this->dbc->query("DELETE FROM {$this->smembTable}
|
||||
$r = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['smembTable']."
|
||||
WHERE mid is not null");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$arr = $this->dbc->getAll("SELECT uid, gid FROM {$this->smembTable}");
|
||||
$arr = $CC_DBC->getAll("SELECT uid, gid FROM ".$CC_CONFIG['smembTable']);
|
||||
// WHERE mid is null
|
||||
if (PEAR::isError($arr)) {
|
||||
return $arr;
|
||||
}
|
||||
foreach ($arr as $it) {
|
||||
$marr = $this->_listRMemb($it['gid']);
|
||||
$marr = Subjects::_listRMemb($it['gid']);
|
||||
if (PEAR::isError($marr)) {
|
||||
return $marr;
|
||||
}
|
||||
foreach ($marr as $k => $v) {
|
||||
$r = $this->_plainAddSubj2Gr(
|
||||
$r = Subjects::_plainAddSubjectToGroup(
|
||||
$it['uid'], $v['gid'], intval($v['level'])+1, $v['id']
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -569,7 +574,10 @@ class Subjects extends ObjClasses {
|
|||
}
|
||||
}
|
||||
}
|
||||
$r = $this->dbc->query("COMMIT"); if(PEAR::isError($r)) return $r;
|
||||
$r = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return TRUE;
|
||||
} // fn _rebuildRels
|
||||
|
||||
|
@ -585,11 +593,11 @@ class Subjects extends ObjClasses {
|
|||
* actual indentation
|
||||
* @return string
|
||||
*/
|
||||
public function dumpSubjects($indstr=' ', $ind='')
|
||||
public static function DumpSubjects($indstr=' ', $ind='')
|
||||
{
|
||||
$r = $ind.join(', ', array_map(
|
||||
create_function('$v', 'return "{$v[\'login\']}({$v[\'cnt\']})";'),
|
||||
$this->getSubjectsWCnt()
|
||||
Subjects::GetSubjectsWCnt()
|
||||
))."\n";
|
||||
return $r;
|
||||
} // fn dumpSubjects
|
||||
|
@ -600,11 +608,12 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteData()
|
||||
public static function DeleteData()
|
||||
{
|
||||
$this->dbc->query("DELETE FROM {$this->subjTable}");
|
||||
$this->dbc->query("DELETE FROM {$this->smembTable}");
|
||||
parent::deleteData();
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['subjTable']);
|
||||
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['smembTable']);
|
||||
ObjClasses::DeleteData();
|
||||
} // fn deleteData
|
||||
|
||||
|
||||
|
@ -613,60 +622,62 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testData()
|
||||
public function TestData()
|
||||
{
|
||||
parent::testData();
|
||||
$o['root'] = $this->addSubj('root', 'q');
|
||||
$o['test1'] = $this->addSubj('test1', 'a');
|
||||
$o['test2'] = $this->addSubj('test2', 'a');
|
||||
$o['test3'] = $this->addSubj('test3', 'a');
|
||||
$o['test4'] = $this->addSubj('test4', 'a');
|
||||
$o['test5'] = $this->addSubj('test5', 'a');
|
||||
$o['gr1'] = $this->addSubj('gr1');
|
||||
$o['gr2'] = $this->addSubj('gr2');
|
||||
$o['gr3'] = $this->addSubj('gr3');
|
||||
$o['gr4'] = $this->addSubj('gr4');
|
||||
$this->addSubj2Gr('test1', 'gr1');
|
||||
$this->addSubj2Gr('test2', 'gr2');
|
||||
$this->addSubj2Gr('test3', 'gr3');
|
||||
$this->addSubj2Gr('test4', 'gr4');
|
||||
$this->addSubj2Gr('test5', 'gr1');
|
||||
$this->addSubj2Gr('gr4', 'gr3');
|
||||
$this->addSubj2Gr('gr3', 'gr2');
|
||||
return $this->tdata['subjects'] = $o;
|
||||
} // fn testData
|
||||
$tdata = ObjClasses::TestData();
|
||||
$o['root'] = Subjects::AddSubj('root', 'q');
|
||||
$o['test1'] = Subjects::AddSubj('test1', 'a');
|
||||
$o['test2'] = Subjects::AddSubj('test2', 'a');
|
||||
$o['test3'] = Subjects::AddSubj('test3', 'a');
|
||||
$o['test4'] = Subjects::AddSubj('test4', 'a');
|
||||
$o['test5'] = Subjects::AddSubj('test5', 'a');
|
||||
$o['gr1'] = Subjects::AddSubj('gr1');
|
||||
$o['gr2'] = Subjects::AddSubj('gr2');
|
||||
$o['gr3'] = Subjects::AddSubj('gr3');
|
||||
$o['gr4'] = Subjects::AddSubj('gr4');
|
||||
Subjects::AddSubjectToGroup('test1', 'gr1');
|
||||
Subjects::AddSubjectToGroup('test2', 'gr2');
|
||||
Subjects::AddSubjectToGroup('test3', 'gr3');
|
||||
Subjects::AddSubjectToGroup('test4', 'gr4');
|
||||
Subjects::AddSubjectToGroup('test5', 'gr1');
|
||||
Subjects::AddSubjectToGroup('gr4', 'gr3');
|
||||
Subjects::AddSubjectToGroup('gr3', 'gr2');
|
||||
$tdata['subjects'] = $o;
|
||||
return $tdata;
|
||||
} // fn TestData
|
||||
|
||||
|
||||
/**
|
||||
* Make basic test
|
||||
*
|
||||
*/
|
||||
public function test()
|
||||
public static function Test()
|
||||
{
|
||||
if (PEAR::isError($p = parent::test())) {
|
||||
$p = ObjClasses::Test();
|
||||
if (PEAR::isError($p)) {
|
||||
return $p;
|
||||
}
|
||||
$this->deleteData();
|
||||
$this->testData();
|
||||
$this->test_correct = "root(0), test1(0), test2(0), test3(0),".
|
||||
Subjects::DeleteData();
|
||||
Subjects::TestData();
|
||||
$test_correct = "root(0), test1(0), test2(0), test3(0),".
|
||||
" test4(0), test5(0), gr1(2), gr2(2), gr3(2), gr4(1)\n";
|
||||
$this->test_dump = $this->dumpSubjects();
|
||||
$this->removeSubj('test1');
|
||||
$this->removeSubj('test3');
|
||||
$this->removeSubjFromGr('test5', 'gr1');
|
||||
$this->removeSubjFromGr('gr3', 'gr2');
|
||||
$this->test_correct .= "root(0), test2(0), test4(0), test5(0),".
|
||||
$test_dump = Subjects::DumpSubjects();
|
||||
Subjects::RemoveSubj('test1');
|
||||
Subjects::RemoveSubj('test3');
|
||||
Subjects::RemoveSubjectFromGroup('test5', 'gr1');
|
||||
Subjects::RemoveSubjectFromGroup('gr3', 'gr2');
|
||||
$test_correct .= "root(0), test2(0), test4(0), test5(0),".
|
||||
" gr1(0), gr2(1), gr3(1), gr4(1)\n";
|
||||
$this->test_dump .= $this->dumpSubjects();
|
||||
$this->deleteData();
|
||||
if ($this->test_dump == $this->test_correct) {
|
||||
$this->test_log.="subj: OK\n";
|
||||
$test_dump .= Subjects::DumpSubjects();
|
||||
Subjects::DeleteData();
|
||||
if ($test_dump == $test_correct) {
|
||||
$test_log .= "subj: OK\n";
|
||||
return TRUE;
|
||||
} else {
|
||||
return PEAR::raiseError(
|
||||
'Subjects::test:', 1, PEAR_ERROR_DIE, '%s'.
|
||||
"<pre>\ncorrect:\n{$this->test_correct}\n".
|
||||
"dump:\n{$this->test_dump}\n</pre>\n");
|
||||
'Subjects::test:', 1, PEAR_ERROR_DIE, '%s'.
|
||||
"<pre>\ncorrect:\n{$test_correct}\n".
|
||||
"dump:\n{$test_dump}\n</pre>\n");
|
||||
}
|
||||
} // fn test
|
||||
|
||||
|
@ -675,35 +686,35 @@ class Subjects extends ObjClasses {
|
|||
* Create tables + initialize
|
||||
*
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
parent::install();
|
||||
$this->dbc->query("CREATE TABLE {$this->subjTable} (
|
||||
id int not null PRIMARY KEY,
|
||||
login varchar(255) not null default'',
|
||||
pass varchar(255) not null default'',
|
||||
type char(1) not null default 'U',
|
||||
realname varchar(255) not null default'',
|
||||
lastlogin timestamp,
|
||||
lastfail timestamp
|
||||
)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->subjTable}_id_idx
|
||||
ON {$this->subjTable} (id)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->subjTable}_login_idx
|
||||
ON {$this->subjTable} (login)");
|
||||
$this->dbc->createSequence("{$this->subjTable}_id_seq");
|
||||
|
||||
$this->dbc->query("CREATE TABLE {$this->smembTable} (
|
||||
id int not null PRIMARY KEY,
|
||||
uid int not null default 0,
|
||||
gid int not null default 0,
|
||||
level int not null default 0,
|
||||
mid int
|
||||
)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->smembTable}_id_idx
|
||||
ON {$this->smembTable} (id)");
|
||||
$this->dbc->createSequence("{$this->smembTable}_id_seq");
|
||||
} // fn install
|
||||
// public function install()
|
||||
// {
|
||||
// parent::install();
|
||||
// $CC_DBC->query("CREATE TABLE {$this->subjTable} (
|
||||
// id int not null PRIMARY KEY,
|
||||
// login varchar(255) not null default'',
|
||||
// pass varchar(255) not null default'',
|
||||
// type char(1) not null default 'U',
|
||||
// realname varchar(255) not null default'',
|
||||
// lastlogin timestamp,
|
||||
// lastfail timestamp
|
||||
// )");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->subjTable}_id_idx
|
||||
// ON {$this->subjTable} (id)");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->subjTable}_login_idx
|
||||
// ON {$this->subjTable} (login)");
|
||||
// $CC_DBC->createSequence("{$this->subjTable}_id_seq");
|
||||
//
|
||||
// $CC_DBC->query("CREATE TABLE {$this->smembTable} (
|
||||
// id int not null PRIMARY KEY,
|
||||
// uid int not null default 0,
|
||||
// gid int not null default 0,
|
||||
// level int not null default 0,
|
||||
// mid int
|
||||
// )");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->smembTable}_id_idx
|
||||
// ON {$this->smembTable} (id)");
|
||||
// $CC_DBC->createSequence("{$this->smembTable}_id_seq");
|
||||
// } // fn install
|
||||
|
||||
|
||||
/**
|
||||
|
@ -711,14 +722,15 @@ class Subjects extends ObjClasses {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->subjTable}");
|
||||
$this->dbc->dropSequence("{$this->subjTable}_id_seq");
|
||||
$this->dbc->query("DROP TABLE {$this->smembTable}");
|
||||
$this->dbc->dropSequence("{$this->smembTable}_id_seq");
|
||||
parent::uninstall();
|
||||
} // fn uninstall
|
||||
// public function uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['subjTable']);
|
||||
// $CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id_seq");
|
||||
// $CC_DBC->query("DROP TABLE ".$CC_CONFIG['smembTable']);
|
||||
// $CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id_seq");
|
||||
// parent::uninstall();
|
||||
// } // fn uninstall
|
||||
|
||||
} // class Subjects
|
||||
?>
|
|
@ -1,33 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
require_once "alib_h.php";
|
||||
require_once "alibExTestAuth.php";
|
||||
|
||||
if(isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id']; $list=false; }
|
||||
else $list=true;
|
||||
require_once("alib_h.php");
|
||||
require_once("alibExTestAuth.php");
|
||||
|
||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$list = false;
|
||||
} else {
|
||||
$list = true;
|
||||
}
|
||||
|
||||
// prefill data structure for template
|
||||
if($list){
|
||||
if ($list) {
|
||||
$d = array(
|
||||
'cls' => $alib->getClasses(),
|
||||
'cls' => ObjClasses::GetClasses(),
|
||||
'loggedAs' => $login,
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
$d = array(
|
||||
'rows' => $alib->listClass($id),
|
||||
'rows' => ObjClasses::ListClass($id),
|
||||
'id' => $id,
|
||||
'loggedAs' => $login,
|
||||
'cname' => $alib->getClassName($id),
|
||||
'cls' => $alib->getClasses(),
|
||||
'objs' => $alib->getSubTree(null, true)
|
||||
'cname' => ObjClasses::GetClassName($id),
|
||||
'cls' => ObjClasses::GetClasses(),
|
||||
'objs' => M2tree::GetSubTree(null, true)
|
||||
);
|
||||
}
|
||||
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
||||
$d['msg'] = $_SESSION['alertMsg'];
|
||||
unset($_SESSION['alertMsg']);
|
||||
|
||||
require_once "alib_f.php";
|
||||
require_once("alib_f.php");
|
||||
// template follows:
|
||||
?>
|
||||
<html><head>
|
||||
|
|
|
@ -7,9 +7,9 @@ require_once "alib_h.php";
|
|||
|
||||
// prefill data structure for template
|
||||
$d = array(
|
||||
'users' => $alib->getSubjects(),
|
||||
'actions' => $alib->getAllActions(),
|
||||
'objects' => $alib->getAllObjects(),
|
||||
'users' => Subjects::GetSubjects(),
|
||||
'actions' => Alib::GetAllActions(),
|
||||
'objects' => M2tree::GetAllObjects(),
|
||||
'msg' => $_SESSION['alertMsg']
|
||||
);
|
||||
unset($_SESSION['alertMsg']);
|
||||
|
|
|
@ -12,11 +12,11 @@ else $id=1;
|
|||
|
||||
// prefill data structure for template
|
||||
$d = array(
|
||||
'rows' => $alib->getSubjPerms($id),
|
||||
'rows' => Alib::GetSubjPerms($id),
|
||||
'id' => $id,
|
||||
'loggedAs' => $login,
|
||||
'actions' => $alib->getAllActions(),
|
||||
'name' => $alib->getSubjName($id)
|
||||
'actions' => Alib::GetAllActions(),
|
||||
'name' => Subjects::GetSubjName($id)
|
||||
);
|
||||
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
||||
|
||||
|
|
|
@ -1,27 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
require_once "alib_h.php";
|
||||
|
||||
$sid=$_GET['subj'];
|
||||
require_once("alib_h.php");
|
||||
|
||||
$all = $alib->getAllObjects();
|
||||
foreach($alib->getClasses() as $cl)
|
||||
$sid = $_GET['subj'];
|
||||
|
||||
$all = M2tree::GetAllObjects();
|
||||
foreach (ObjClasses::GetClasses() as $cl) {
|
||||
$all[] = array('name'=>$cl['cname']." (class)", 'id'=>$cl['id']);
|
||||
}
|
||||
|
||||
foreach($all as $it){
|
||||
$aa=array();
|
||||
foreach($alib->getAllActions() as $a){
|
||||
$aa[$a] = $r = $alib->checkPerm($sid, $a, $it['id']);
|
||||
if(PEAR::isError($r)){
|
||||
echo $r->getMessage()." ".$r->getUserInfo()."\n"; exit; }
|
||||
}
|
||||
$m[]=array($it['name'], $aa);
|
||||
foreach ($all as $it) {
|
||||
$aa = array();
|
||||
foreach (Alib::GetAllActions() as $a) {
|
||||
$aa[$a] = $r = Alib::CheckPerm($sid, $a, $it['id']);
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$m[] = array($it['name'], $aa);
|
||||
}
|
||||
#echo"<pre>\n"; var_dump($m);
|
||||
$u=$alib->getSubjName($sid);
|
||||
$u = Subjects::GetSubjName($sid);
|
||||
|
||||
?>
|
||||
<html><head>
|
||||
|
@ -32,7 +42,7 @@ $u=$alib->getSubjName($sid);
|
|||
<h2>User: <?php echo$u?></h2>
|
||||
<table style="border:1px solid black">
|
||||
<tr class="ev"><th>object</th>
|
||||
<?php foreach($alib->getAllActions() as $a){?>
|
||||
<?php foreach (Alib::GetAllActions() as $a){?>
|
||||
<th><?php echo$a?></th>
|
||||
<?php }?>
|
||||
</tr>
|
||||
|
@ -49,5 +59,5 @@ $u=$alib->getSubjName($sid);
|
|||
<a href="javascript:back()">Back</a>
|
||||
<hr>
|
||||
Tree dump:
|
||||
<pre><?php echo$alib->dumpTree()?></pre>
|
||||
<pre><?php echo M2tree::DumpTree()?></pre>
|
||||
</body></html>
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
require_once("alib_h.php");
|
||||
|
@ -9,26 +16,26 @@ require_once("alibExTestAuth.php");
|
|||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
} else {
|
||||
$id = $alib->getRootNode();
|
||||
$id = M2tree::GetRootNode();
|
||||
}
|
||||
|
||||
// prefill data structure for template
|
||||
if (!$alib->isClass($id)) {
|
||||
if (!ObjClasses::IsClass($id)) {
|
||||
$d = array(
|
||||
'path' => $alib->getPath($id, 'id,name'),
|
||||
'perms' => $alib->getObjPerms($id),
|
||||
'actions' => $alib->getAllowedActions($alib->getObjType($id)),
|
||||
'subjects' => $alib->getSubjects(),
|
||||
'path' => M2tree::GetPath($id, 'id,name'),
|
||||
'perms' => Alib::GetObjPerms($id),
|
||||
'actions' => Alib::GetAllowedActions(M2tree::GetObjType($id)),
|
||||
'subjects' => Subjects::GetSubjects(),
|
||||
'id' => $id,
|
||||
'loggedAs' => $login
|
||||
);
|
||||
} else {
|
||||
$d = array(
|
||||
'path' => '',
|
||||
'name' => $alib->getClassName($id),
|
||||
'perms' => $alib->getObjPerms($id),
|
||||
'actions' => $alib->getAllowedActions('_class'),
|
||||
'subjects' => $alib->getSubjects(),
|
||||
'name' => ObjClasses::GetClassName($id),
|
||||
'perms' => Alib::GetObjPerms($id),
|
||||
'actions' => Alib::GetAllowedActions('_class'),
|
||||
'subjects' => Subjects::GetSubjects(),
|
||||
'id' => $id,
|
||||
'loggedAs' => $login
|
||||
);
|
||||
|
|
|
@ -13,16 +13,16 @@ else $list=true;
|
|||
// prefill data structure for template
|
||||
if($list){
|
||||
$d = array(
|
||||
'subj' => $alib->getSubjectsWCnt(),
|
||||
'subj' => Subjects::GetSubjectsWCnt(),
|
||||
'loggedAs' => $login
|
||||
);
|
||||
}else{
|
||||
$d = array(
|
||||
'rows' => $alib->listGroup($id),
|
||||
'rows' => Subjects::ListGroup($id),
|
||||
'id' => $id,
|
||||
'loggedAs' => $login,
|
||||
'gname' => $alib->getSubjName($id),
|
||||
'subj' => $alib->getSubjects()
|
||||
'gname' => Subjects::GetSubjName($id),
|
||||
'subj' => Subjects::GetSubjects()
|
||||
);
|
||||
}
|
||||
$d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
$login = $alib->getSessLogin($_REQUEST['alibsid']);
|
||||
$login = Alib::GetSessLogin($_REQUEST['alibsid']);
|
||||
if(!isset($login)||$login==''){
|
||||
$_SESSION['alertMsg'] = "Login required";
|
||||
header("Location: alibExLogin.php");
|
||||
|
|
|
@ -8,16 +8,16 @@ require_once "alib_h.php";
|
|||
require_once "alibExTestAuth.php";
|
||||
|
||||
if(isset($_GET['id']) && is_numeric($_GET['id'])) $id = $_GET['id'];
|
||||
else $id = $alib->getRootNode();
|
||||
else $id = M2tree::GetRootNode();
|
||||
|
||||
// prefill data structure for template
|
||||
$d = array(
|
||||
'parid' => $alib->getParent($id),
|
||||
'oname' => $alib->getObjName($id),
|
||||
'path' => $alib->getPath($id, 'id, name'),
|
||||
'rows' => $alib->getDir($id, 'id, name, type'),
|
||||
'addtypes' => $alib->getAllowedChildTypes($alib->getObjType($id)),
|
||||
'dump' => $alib->dumpTree($id),
|
||||
'oname' => M2tree::GetObjName($id),
|
||||
'path' => M2tree::GetPath($id, 'id, name'),
|
||||
'rows' => M2tree::GetDir($id, 'id, name, type'),
|
||||
'addtypes' => M2tree::GetAllowedChildTypes(M2tree::GetObjType($id)),
|
||||
'dump' => M2tree::DumpTree($id),
|
||||
'id' => $id,
|
||||
'loggedAs' => $login
|
||||
);
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
require_once "alib_h.php";
|
||||
require_once("alib_h.php");
|
||||
|
||||
#echo"<pre>\nGET:\n"; print_r($_GET); echo"POST:\n"; print_r($_POST); exit;
|
||||
|
||||
|
@ -12,140 +18,162 @@ function getPGval($vn, $dfl='')
|
|||
return (isset($_POST[$vn])?$_POST[$vn]:(isset($_GET[$vn])?$_GET[$vn]:$dfl));
|
||||
}
|
||||
|
||||
$userid = $alib->getSessUserId($_REQUEST['alibsid']);
|
||||
$login = $alib->getSessLogin($_REQUEST['alibsid']);
|
||||
$userid = Alib::GetSessUserId($_REQUEST['alibsid']);
|
||||
$login = Alib::GetSessLogin($_REQUEST['alibsid']);
|
||||
|
||||
$redirUrl="alibExTree.php".(($reid=getPGval('reid', '')) ? "?id=$reid":"");
|
||||
$act = getPGval('act', 'nop');
|
||||
switch($act)
|
||||
{
|
||||
case"login";
|
||||
if($sessid = $alib->login($_POST['login'], $_POST['pass'])){
|
||||
switch ($act) {
|
||||
case "login";
|
||||
if ($sessid = Alib::Login($_POST['login'], $_POST['pass'])) {
|
||||
setcookie('alibsid', $sessid);
|
||||
$redirUrl="alibExTree.php";
|
||||
}else{
|
||||
} else {
|
||||
$redirUrl="alibExLogin.php"; $_SESSION['alertMsg']='Login failed.';
|
||||
}
|
||||
break;
|
||||
case"logout";
|
||||
$r = $alib->logout($_REQUEST['alibsid']);
|
||||
if(PEAR::isError($r)){
|
||||
break;
|
||||
case "logout";
|
||||
$r = Alib::Logout($_REQUEST['alibsid']);
|
||||
if (PEAR::isError($r)) {
|
||||
$_SESSION['alertMsg'] = $r->getMessage().", ".$r->getUserInfo();
|
||||
}
|
||||
setcookie('alibsid', '');
|
||||
$redirUrl="alibExLogin.php";
|
||||
break;
|
||||
case"addNode";
|
||||
if($alib->checkPerm($userid, 'addChilds', $_POST['id'])
|
||||
break;
|
||||
case "addNode";
|
||||
if (Alib::CheckPerm($userid, 'addChilds', $_POST['id'])
|
||||
&& $_POST['type']!=''
|
||||
&& $_POST['name']!=''
|
||||
){
|
||||
&& $_POST['name']!='') {
|
||||
$position = ($_POST['position']=='I' ? null : $_POST['position']);
|
||||
$oid = $alib->addObj(
|
||||
$_POST['name'], $_POST['type'], $_POST['id'], $position
|
||||
);
|
||||
if(PEAR::isError($oid)){
|
||||
$oid = M2tree::AddObj($_POST['name'], $_POST['type'], $_POST['id']);
|
||||
if (PEAR::isError($oid)) {
|
||||
$_SESSION['alertMsg'] =
|
||||
$oid->getMessage().", ".$oid->getUserInfo();
|
||||
}else $r = $alib->addPerm($userid, '_all', $oid);
|
||||
if(PEAR::isError($r)){
|
||||
} else {
|
||||
$r = Alib::AddPerm($userid, '_all', $oid);
|
||||
}
|
||||
if (PEAR::isError($r)) {
|
||||
$_SESSION['alertMsg'] = $r->getMessage().", ".$r->getUserInfo();
|
||||
}
|
||||
}else $_SESSION['alertMsg']='Access denied.';
|
||||
break;
|
||||
case"deleteNode";
|
||||
if($alib->checkPerm($userid, 'delete', $_REQUEST['id']))
|
||||
$alib->removeObj($_GET['id']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
break;
|
||||
case"addPerm";
|
||||
$a = $alib->isClass($_POST['id']) ? 'classes':'editPerms';
|
||||
$id = $alib->isClass($_POST['id']) ? '':$_POST['id'];
|
||||
if($alib->checkPerm($userid, $a, $id)){
|
||||
$alib->addPerm(
|
||||
} else {
|
||||
$_SESSION['alertMsg'] = 'Access denied.';
|
||||
}
|
||||
break;
|
||||
case "deleteNode";
|
||||
if (Alib::CheckPerm($userid, 'delete', $_REQUEST['id'])) {
|
||||
Alib::RemoveObj($_GET['id']);
|
||||
} else {
|
||||
$_SESSION['alertMsg'] = 'Access denied.';
|
||||
}
|
||||
break;
|
||||
case "addPerm";
|
||||
$a = ObjClasses::IsClass($_POST['id']) ? 'classes':'editPerms';
|
||||
$id = ObjClasses::IsClass($_POST['id']) ? '':$_POST['id'];
|
||||
if (Alib::CheckPerm($userid, $a, $id)) {
|
||||
Alib::AddPerm(
|
||||
$_POST['subj'], $_POST['permAction'],
|
||||
$_POST['id'], $_POST['allowDeny']
|
||||
);
|
||||
}else $_SESSION['alertMsg']='Access denied.';
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExPerms.php".
|
||||
(($reid=getPGval('reid', '')) ? "?id=$reid":"");
|
||||
break;
|
||||
case"removePerm";
|
||||
$a = $alib->isClass($_REQUEST['oid']) ? 'classes':'editPerms';
|
||||
$oid = $alib->isClass($_REQUEST['oid']) ? NULL:$_REQUEST['oid'];
|
||||
if($alib->checkPerm($userid, $a, $oid))
|
||||
$alib->removePerm($_GET['permid']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
break;
|
||||
case "removePerm";
|
||||
$a = ObjClasses::IsClass($_REQUEST['oid']) ? 'classes':'editPerms';
|
||||
$oid = ObjClasses::IsClass($_REQUEST['oid']) ? NULL:$_REQUEST['oid'];
|
||||
if (Alib::CheckPerm($userid, $a, $oid)) {
|
||||
Alib::RemovePerm($_GET['permid']);
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied.';
|
||||
}
|
||||
$redirUrl =
|
||||
($_REQUEST['reurl']==plist ? "alibExPList.php":"alibExPerms.php").
|
||||
(($reid=getPGval('reid', '')) ? "?id=$reid":"");
|
||||
break;
|
||||
case"checkPerm";
|
||||
$res = $alib->checkPerm(
|
||||
break;
|
||||
case "checkPerm";
|
||||
$res = Alib::CheckPerm(
|
||||
$_POST['subj'], $_POST['permAction'], $_POST['obj']
|
||||
);
|
||||
$_SESSION['alertMsg'] = ($res ? "permitted: ":"DENIED: ").
|
||||
" {$_POST['permAction']} for ".$alib->getSubjName($_POST['subj']).
|
||||
" on ".$alib->getObjName($_POST['obj']);
|
||||
" {$_POST['permAction']} for ".Subjects::GetSubjName($_POST['subj']).
|
||||
" on ".M2tree::GetObjName($_POST['obj']);
|
||||
$_SESSION['lastPost']=$_POST;
|
||||
$redirUrl="alibExLogin.php";
|
||||
break;
|
||||
case"addClass";
|
||||
if($alib->checkPerm($userid, 'classes'))
|
||||
$alib->addClass($_POST['name']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
$redirUrl = "alibExLogin.php";
|
||||
break;
|
||||
case "addClass";
|
||||
if (Alib::CheckPerm($userid, 'classes')) {
|
||||
ObjClasses::AddClass($_POST['name']);
|
||||
} else {
|
||||
$_SESSION['alertMsg'] = 'Access denied.';
|
||||
}
|
||||
$redirUrl="alibExCls.php";
|
||||
break;
|
||||
case"removeClass";
|
||||
if($alib->checkPerm($userid, 'classes'))
|
||||
$alib->removeClassById($_GET['id']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
$redirUrl="alibExCls.php";
|
||||
break;
|
||||
case"addSubj";
|
||||
if($alib->checkPerm($userid, 'subjects'))
|
||||
$alib->addSubj($_POST['login'], $_POST['pass']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
$redirUrl="alibExSubj.php";
|
||||
break;
|
||||
case"removeSubj";
|
||||
if($alib->checkPerm($userid, 'subjects'))
|
||||
$alib->removeSubj($_GET['login']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
$redirUrl="alibExSubj.php";
|
||||
break;
|
||||
case"addSubj2Gr";
|
||||
if($alib->checkPerm($userid, 'subjects'))
|
||||
$alib->addSubj2Gr($_POST['login'], $_POST['gname']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
break;
|
||||
case "removeClass";
|
||||
if (Alib::CheckPerm($userid, 'classes')) {
|
||||
ObjClasses::RemoveClassById($_GET['id']);
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExCls.php";
|
||||
break;
|
||||
case "addSubj";
|
||||
if (Alib::CheckPerm($userid, 'subjects')) {
|
||||
Subjects::AddSubj($_POST['login'], $_POST['pass']);
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExSubj.php";
|
||||
break;
|
||||
case "removeSubj";
|
||||
if (Alib::CheckPerm($userid, 'subjects')) {
|
||||
Alib::RemoveSubj($_GET['login']);
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExSubj.php";
|
||||
break;
|
||||
case "addSubj2Gr";
|
||||
if (Alib::CheckPerm($userid, 'subjects')) {
|
||||
Subjects::AddSubjectToGroup($_POST['login'], $_POST['gname']);
|
||||
} else {
|
||||
$_SESSION['alertMsg'] = 'Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExSubj.php".
|
||||
(($id=getPGval('reid', '')) ? "?id=$reid":"");
|
||||
break;
|
||||
case"removeSubjFromGr";
|
||||
if($alib->checkPerm($userid, 'subjects'))
|
||||
$alib->removeSubjFromGr($_GET['login'], $_GET['gname']);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
break;
|
||||
case "removeSubjFromGr";
|
||||
if (Alib::CheckPerm($userid, 'subjects')) {
|
||||
Subjects::RemoveSubjectFromGroup($_GET['login'], $_GET['gname']);
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExSubj.php".
|
||||
(($id=getPGval('reid', '')) ? "?id=$reid":"");
|
||||
break;
|
||||
case"addObj2Class";
|
||||
if($alib->checkPerm($userid, 'classes'))
|
||||
$alib->addObj2Class($_POST['id'], $_POST['oid']);
|
||||
else $_SESSION['alertMsg']='Access denied. X1';
|
||||
break;
|
||||
case "addObj2Class";
|
||||
if (Alib::CheckPerm($userid, 'classes')) {
|
||||
ObjClasses::AddObjectToClass($_POST['id'], $_POST['oid']);
|
||||
} else {
|
||||
$_SESSION['alertMsg']='Access denied. X1';
|
||||
}
|
||||
$redirUrl="alibExCls.php".(($id=getPGval('id', '')) ? "?id=$id":"");
|
||||
break;
|
||||
case"removeObjFromClass";
|
||||
$id=getPGval('id', '');
|
||||
if($alib->checkPerm($userid, 'classes'))
|
||||
$alib->removeObjFromClass($_GET['oid'], $id);
|
||||
else $_SESSION['alertMsg']='Access denied.';
|
||||
$redirUrl="alibExCls.php".($id ? "?id=$id":"");
|
||||
break;
|
||||
break;
|
||||
case "removeObjFromClass";
|
||||
$id = getPGval('id', '');
|
||||
if (Alib::CheckPerm($userid, 'classes')) {
|
||||
ObjClasses::RemoveObjectFromClass($_GET['oid'], $id);
|
||||
} else {
|
||||
$_SESSION['alertMsg'] = 'Access denied.';
|
||||
}
|
||||
$redirUrl = "alibExCls.php".($id ? "?id=$id":"");
|
||||
break;
|
||||
default:
|
||||
$_SESSION['alertMsg']="Unknown method: $act";
|
||||
}
|
||||
|
||||
require_once"alib_f.php";
|
||||
require_once("alib_f.php");
|
||||
|
||||
header("Location: $redirUrl");
|
||||
?>
|
|
@ -1,4 +1,4 @@
|
|||
<?
|
||||
// $Id: alib_f.php 6 2004-07-23 00:22:13Z tomas $
|
||||
$dbc->disconnect();
|
||||
$CC_DBC->disconnect();
|
||||
?>
|
|
@ -15,7 +15,9 @@ PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallback');
|
|||
|
||||
function errCallback($err)
|
||||
{
|
||||
if(assert_options(ASSERT_ACTIVE)==1) return;
|
||||
if (assert_options(ASSERT_ACTIVE)==1) {
|
||||
return;
|
||||
}
|
||||
echo "<pre>\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "\ngm:\n".$err->getMessage()."\nui:\n".$err->getUserInfo()."\n";
|
||||
|
@ -25,7 +27,7 @@ function errCallback($err)
|
|||
exit;
|
||||
}
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$alib = new Alib($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$alib = new Alib();
|
||||
?>
|
|
@ -4,7 +4,7 @@
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
'dsn' => array( // data source definition
|
||||
'username' => 'test',
|
||||
'password' => 'test',
|
||||
|
|
|
@ -19,47 +19,48 @@ function errCallback($err)
|
|||
}
|
||||
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists with corresponding permissions.\n";
|
||||
echo "Check if database '".$CC_CONFIG['dsn']['database']."' exists with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit;
|
||||
}
|
||||
#$dbc->setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
#$$dbc->setErrorHandling(PEAR_ERROR_DIE, "%s<hr>\n");
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$alib = new Alib($dbc, $config);
|
||||
$alib = new Alib();
|
||||
|
||||
echo "\n\n======\n".
|
||||
"This is Alib standalone installation script, it is NOT needed to run ".
|
||||
"for Campcaster.\nAlib is automatically used by storageServer without it.".
|
||||
"\n======\n\n";
|
||||
|
||||
echo "Alib: uninstall ...\n";
|
||||
$alib->uninstall();
|
||||
exit;
|
||||
|
||||
$dbc->setErrorHandling(PEAR_ERROR_DIE, "%s<hr>\n");
|
||||
echo "Alib: install ...\n";
|
||||
$alib->install();
|
||||
//echo "Alib: uninstall ...\n";
|
||||
//$alib->uninstall();
|
||||
|
||||
#$alib->testData(); echo $alib->dumpTree(); exit;
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_DIE, "%s<hr>\n");
|
||||
//echo "Alib: install ...\n";
|
||||
//$alib->install();
|
||||
|
||||
echo " Testing ...\n";
|
||||
$r = $alib->test();
|
||||
if($dbc->isError($r)) if($dbc->isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||
$r = Alib::Test();
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n".$r->getUserInfo()."\n";
|
||||
exit;
|
||||
}
|
||||
$log = $alib->test_log;
|
||||
echo " TESTS:\n$log\n---\n";
|
||||
|
||||
echo " clean up + testdata insert ...\n";
|
||||
$alib->deleteData();
|
||||
$alib->testData();
|
||||
Alib::DeleteData();
|
||||
Alib::TestData();
|
||||
|
||||
echo " TREE DUMP:\n";
|
||||
echo $alib->dumpTree();
|
||||
echo M2tree::DumpTree();
|
||||
echo "\n Alib is probably installed OK\n";
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
||||
$CC_DBC->disconnect();
|
||||
?>
|
|
@ -19,22 +19,20 @@ function errCallback($err)
|
|||
}
|
||||
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists with corresponding permissions.\n";
|
||||
echo "Check if database '".$CC_CONFIG['dsn']['database']."' exists with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$alib = new Alib($dbc, $config);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
//$alib = new Alib();
|
||||
//
|
||||
//echo "Trying to uninstall all ...\n";
|
||||
//$alib->uninstall();
|
||||
|
||||
# $dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
echo "Trying to uninstall all ...\n";
|
||||
$alib->uninstall();
|
||||
|
||||
$dbc->disconnect();
|
||||
$CC_DBC->disconnect();
|
||||
?>
|
|
@ -1,34 +1,45 @@
|
|||
<?php
|
||||
require_once("M2tree.php");
|
||||
|
||||
class M2treeTest extends M2tree {
|
||||
//class M2treeTest extends M2tree {
|
||||
class M2treeTest {
|
||||
|
||||
function _test_init()
|
||||
{
|
||||
for($i=1; $i<=3; $i++){
|
||||
$r = $this->addObj("Publication$i", "Publication");
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
$r = M2tree::AddObj("Publication$i", "Publication");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->_t["p$i"] = $r;
|
||||
}
|
||||
for($i=1; $i<=3; $i++){
|
||||
$r = $this->addObj("Issue$i", "Issue",
|
||||
$this->_t[$i<=2 ? 'p1' : 'p2']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
for ($i = 1; $i <= 3; $i++){
|
||||
$r = M2tree::AddObj("Issue$i", "Issue", $this->_t[$i<=2 ? 'p1' : 'p2']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->_t["i$i"] = $r;
|
||||
}
|
||||
for($i=1; $i<=4; $i++){
|
||||
$r = $this->addObj("Section$i", "Section",
|
||||
$this->_t[$i<=3 ? 'i1' : 'i3']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
for ($i = 1; $i <= 4; $i++){
|
||||
$r = M2tree::AddObj("Section$i", "Section", $this->_t[$i<=3 ? 'i1' : 'i3']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->_t["s$i"] = $r;
|
||||
}
|
||||
$r = $this->addObj("Par1", "Par", $this->_t["s2"]);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = M2tree::AddObj("Par1", "Par", $this->_t["s2"]);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->_t["r1"] = $r;
|
||||
}
|
||||
|
||||
|
||||
function _test_check($title, $expected, $returned)
|
||||
{
|
||||
if($expected !== $returned){
|
||||
return $this->dbc->raiseError(
|
||||
global $CC_DBC;
|
||||
if ($expected !== $returned){
|
||||
return $CC_DBC->raiseError(
|
||||
"m2tree::$title FAILED:\n".
|
||||
" ###expected:\n$expected\n ---\n".
|
||||
" ###returned:\n$returned\n ---\n"
|
||||
|
@ -36,13 +47,17 @@ class M2treeTest extends M2tree {
|
|||
}
|
||||
return "# ".get_class($this)."::$title: OK\n";
|
||||
}
|
||||
|
||||
|
||||
function _test()
|
||||
{
|
||||
echo "# M2tree test:\n";
|
||||
|
||||
// addObj/dumpTree test:
|
||||
$r = $this->_test_init();
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$expected = "RootNode
|
||||
Publication1
|
||||
Issue1
|
||||
|
@ -56,27 +71,46 @@ class M2treeTest extends M2tree {
|
|||
Section4
|
||||
Publication3
|
||||
";
|
||||
$returned = $this->dumpTree(NULL, ' ', '', '{name}');
|
||||
if($this->dbc->isError($returned)) return $returned;
|
||||
$returned = M2tree::DumpTree(NULL, ' ', '', '{name}');
|
||||
if (PEAR::isError($returned)) {
|
||||
return $returned;
|
||||
}
|
||||
$r = $this->_test_check('addObj/dumpTree', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// shaking test:
|
||||
$nid = $this->copyObj($this->_t['s2'], $this->_t['s4']);
|
||||
if($this->dbc->isError($nid)) return $nid;
|
||||
$r = $this->removeObj($this->_t['s2']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = $this->moveObj($nid, $this->_t['i1']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$returned = $this->dumpTree(NULL, ' ', '', '{name}');
|
||||
if($this->dbc->isError($returned)) return $returned;
|
||||
$nid = M2tree::CopyObj($this->_t['s2'], $this->_t['s4']);
|
||||
if (PEAR::isError($nid)) {
|
||||
return $nid;
|
||||
}
|
||||
$r = M2tree::RemoveObj($this->_t['s2']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = M2tree::MoveObj($nid, $this->_t['i1']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$returned = M2tree::DumpTree(NULL, ' ', '', '{name}');
|
||||
if (PEAR::isError($returned)) {
|
||||
return $returned;
|
||||
}
|
||||
$r = $this->_test_check('shaking test', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// removeObj test:
|
||||
$r = $this->removeObj($this->_t['p2']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = M2tree::RemoveObj($this->_t['p2']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$expected = "RootNode
|
||||
Publication1
|
||||
Issue1
|
||||
|
@ -87,67 +121,111 @@ class M2treeTest extends M2tree {
|
|||
Issue2
|
||||
Publication3
|
||||
";
|
||||
$returned = $this->dumpTree(NULL, ' ', '', '{name}');
|
||||
$returned = M2tree::DumpTree(NULL, ' ', '', '{name}');
|
||||
$r = $this->_test_check('removeObj', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// renameObj/getObjName test:
|
||||
$original = $this->getObjName($this->_t['i2']);
|
||||
if($this->dbc->isError($original)) return $original;
|
||||
$original = M2tree::GetObjName($this->_t['i2']);
|
||||
if (PEAR::isError($original)) {
|
||||
return $original;
|
||||
}
|
||||
$changed = 'Issue2_changed';
|
||||
$expected = $original.$changed;
|
||||
$r = $this->renameObj($this->_t['i2'], $changed);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = $this->getObjName($this->_t['i2']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = M2tree::RenameObj($this->_t['i2'], $changed);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = M2tree::GetObjName($this->_t['i2']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$returned = $r;
|
||||
$r = $this->renameObj($this->_t['i2'], $original);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = $this->getObjName($this->_t['i2']);
|
||||
$r = M2tree::RenameObj($this->_t['i2'], $original);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = M2tree::GetObjName($this->_t['i2']);
|
||||
$returned = $r.$returned;
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$r = $this->_test_check('renameObj/getObjName', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// getPath test:
|
||||
$expected = "RootNode, Publication1, Issue1, Section3";
|
||||
$r = $this->getPath($this->_t['s3'], 'name');
|
||||
$r = M2tree::GetPath($this->_t['s3'], 'name');
|
||||
$returned = join(', ', array_map(create_function('$it', 'return $it["name"];'), $r));
|
||||
$r = $this->_test_check('getPath', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// getObjType test:
|
||||
$expected = 'Issue';
|
||||
$returned = $this->getObjType($this->_t['i2']);
|
||||
$returned = M2tree::GetObjType($this->_t['i2']);
|
||||
$r = $this->_test_check('getObjType', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// getParent test:
|
||||
$expected = $this->_t['p1'];
|
||||
$returned = $this->getParent($this->_t['i2']);
|
||||
$returned = M2tree::GetParent($this->_t['i2']);
|
||||
$r = $this->_test_check('getParent', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// getDir test:
|
||||
$expected = "Issue1, Issue2";
|
||||
$r = $this->getDir($this->_t['p1'], 'name');
|
||||
$r = M2tree::GetDir($this->_t['p1'], 'name');
|
||||
$returned = join(', ', array_map(create_function('$it', 'return $it["name"];'), $r));
|
||||
$r = $this->_test_check('getDir', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// getObjId test:
|
||||
$expected = $this->_t['i2'];
|
||||
$returned = $this->getObjId('Issue2', $this->_t['p1']);
|
||||
$returned = M2tree::GetObjId('Issue2', $this->_t['p1']);
|
||||
$r = $this->_test_check('getObjId', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// getObjLevel test:
|
||||
$expected = 2;
|
||||
$r = $this->getObjLevel($this->_t['i2']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$r = M2tree::GetObjLevel($this->_t['i2']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$returned = $r['level'];
|
||||
$r = $this->_test_check('getObjLevel', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// copyObj test:
|
||||
$expected = "RootNode
|
||||
|
@ -165,12 +243,18 @@ class M2treeTest extends M2tree {
|
|||
Par1
|
||||
Section3
|
||||
";
|
||||
$nid = $this->copyObj($this->_t['i1'], $this->_t['p3']);
|
||||
if($this->dbc->isError($nid)) return $nid;
|
||||
$returned = $this->dumpTree(NULL, ' ', '', '{name}');
|
||||
$nid = M2tree::CopyObj($this->_t['i1'], $this->_t['p3']);
|
||||
if (PEAR::isError($nid)) {
|
||||
return $nid;
|
||||
}
|
||||
$returned = M2tree::DumpTree(NULL, ' ', '', '{name}');
|
||||
$r = $this->_test_check('copyObj', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
$this->removeObj($nid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
M2tree::RemoveObj($nid);
|
||||
|
||||
// moveObj test:
|
||||
$expected = "RootNode
|
||||
|
@ -183,24 +267,36 @@ class M2treeTest extends M2tree {
|
|||
Par1
|
||||
Section3
|
||||
";
|
||||
$r = $this->moveObj($this->_t['i1'], $this->_t['p3']);
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$returned = $this->dumpTree(NULL, ' ', '', '{name}');
|
||||
$r = M2tree::MoveObj($this->_t['i1'], $this->_t['p3']);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$returned = M2tree::DumpTree(NULL, ' ', '', '{name}');
|
||||
$r = $this->_test_check('moveObj', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
// _cutSubtree test:
|
||||
// _pasteSubtree test:
|
||||
|
||||
echo $this->dumpTree();
|
||||
echo M2tree::DumpTree();
|
||||
|
||||
// reset test:
|
||||
$expected = "RootNode\n";
|
||||
$r = $this->reset();
|
||||
if($this->dbc->isError($r)) return $r;
|
||||
$returned = $this->dumpTree(NULL, ' ', '', '{name}');
|
||||
$r = M2tree::reset();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$returned = M2tree::DumpTree(NULL, ' ', '', '{name}');
|
||||
$r = $this->_test_check('reset', $expected, $returned);
|
||||
if($this->dbc->isError($r)) return $r; else echo $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
} else {
|
||||
echo $r;
|
||||
}
|
||||
|
||||
echo "# M2tree OK\n";
|
||||
return TRUE;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
require_once 'DB.php';
|
||||
require_once './m2treeTest.php';
|
||||
require_once"./conf.php";
|
||||
require_once('DB.php');
|
||||
require_once('./m2treeTest.php');
|
||||
require_once("./conf.php");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_DIE);
|
||||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallback');
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if(assert_options(ASSERT_ACTIVE)==1) return;
|
||||
if (assert_options(ASSERT_ACTIVE)==1) {
|
||||
return;
|
||||
}
|
||||
echo "<pre>\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "\ngm:\n".$err->getMessage()."\nui:\n".$err->getUserInfo()."\n";
|
||||
|
@ -17,47 +19,52 @@ function errCallback($err)
|
|||
exit;
|
||||
}
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$m2 = new M2treeTest($dbc, $config);
|
||||
$m2 = new M2treeTest();
|
||||
#$m2->uninstall();
|
||||
#exit;
|
||||
#$r = $m2->install(); if($dbc->isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||
#$r = $m2->install(); if(PEAR::isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||
|
||||
$m2->reset();
|
||||
#$r = $m2->_test_addObj(); if($dbc->isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||
$r = $m2->_test(); if($dbc->isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||
M2tree::reset();
|
||||
#$r = $m2->_test_addObj(); if(PEAR::isError($r)){ echo $r->getMessage()."\n".$r->getUserInfo()."\n"; exit; }
|
||||
$r = $m2->_test();
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n".$r->getUserInfo()."\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
$parid = $m2->_t['s1'];
|
||||
for($i=1; $i<=20; $i++){
|
||||
$r = $m2->addObj("X$i", "XX", $parid);
|
||||
if($m2->dbc->isError($r)) return $r;
|
||||
if (PEAR::isError($r)) return $r;
|
||||
$parid = $r;
|
||||
//$m2->_t["p$i"] = $r;
|
||||
}
|
||||
$r = $m2->dumpTree(); echo "$r\n";
|
||||
$r = M2tree::DumpTree(); echo "$r\n";
|
||||
*/
|
||||
|
||||
|
||||
#$r = $m2->getSubTree($m2->_t['i1'], TRUE); var_dump($r);
|
||||
#$r = M2tree::GetSubTree($m2->_t['i1'], TRUE); var_dump($r);
|
||||
#$r = $m2->getPath($m2->_t['r1'], 'id, name, level'); var_dump($r);
|
||||
#$r = $m2->getPath($m2->_t['r1'], 'id, name, level', TRUE); var_dump($r);
|
||||
/*
|
||||
foreach($m2->getAllObjects() as $k=>$obj){
|
||||
$r = $m2->isChildOf($m2->_t['r1'], $obj['id'], TRUE);
|
||||
foreach(M2tree::GetAllObjects() as $k=>$obj){
|
||||
$r = M2tree::IsChildOf($m2->_t['r1'], $obj['id'], TRUE);
|
||||
echo "{$obj['name']}: $r\n";
|
||||
}
|
||||
*/
|
||||
#$r = $m2->getDir($m2->_t['i1'], 'id, name, level'); var_dump($r);
|
||||
#$r = $m2->getPath($m2->_t['s3'], 'name'); var_dump($r);
|
||||
#$r = $m2->addObj("Issue1", "XX", $m2->_t["s4"]); var_dump($r);
|
||||
#$r = $m2->moveObj($m2->_t['i1'], $m2->_t['s4']); var_dump($r);
|
||||
#$r = $m2->copyObj($m2->_t['i1'], $m2->_t['s4']); var_dump($r);
|
||||
#$r = $m2->removeObj($m2->_t['p2']); var_dump($r);
|
||||
#$r = M2tree::MoveObj($m2->_t['i1'], $m2->_t['s4']); var_dump($r);
|
||||
#$r = M2tree::CopyObj($m2->_t['i1'], $m2->_t['s4']); var_dump($r);
|
||||
#$r = M2tree::RemoveObj($m2->_t['p2']); var_dump($r);
|
||||
#$r = $m2->renameObj($m2->_t['s1'], 'Section2'); var_dump($r);
|
||||
#$r = $m2->renameObj($m2->_t['s3'], 'Section2'); var_dump($r);
|
||||
|
||||
$r = $m2->dumpTree(); echo "$r\n";
|
||||
$r = M2tree::DumpTree();
|
||||
echo "$r\n";
|
||||
?>
|
|
@ -1,95 +1,147 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage Alib
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
include_once "xmlrpc.inc";
|
||||
include_once "xmlrpcs.inc";
|
||||
require_once "../example/alib_h.php";
|
||||
include_once("xmlrpc.inc");
|
||||
include_once("xmlrpcs.inc");
|
||||
require_once("../example/alib_h.php");
|
||||
|
||||
function v2xr($var, $struct=true){
|
||||
if(is_array($var)){
|
||||
function v2xr($var, $struct=true)
|
||||
{
|
||||
if (is_array($var)) {
|
||||
$r = array();
|
||||
foreach($var as $k=>$v) if($struct) $r[$k]=v2xr($v); else $r[]=v2xr($v);
|
||||
foreach ($var as $k => $v) {
|
||||
if ($struct) {
|
||||
$r[$k] = v2xr($v);
|
||||
} else {
|
||||
$r[] = v2xr($v);
|
||||
}
|
||||
}
|
||||
return new xmlrpcval($r, ($struct ? "struct":"array"));
|
||||
}else if(is_int($var)){
|
||||
} else if(is_int($var)) {
|
||||
return new xmlrpcval($var, "int");
|
||||
}else{
|
||||
} else {
|
||||
return new xmlrpcval($var, "string");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* XMLRPC interface for Alib class<br>
|
||||
* only for testing now (with example) - Campcaster uses special interface
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @see Subjects
|
||||
* @see GreenBox
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage Alib
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
class XR_Alib extends Alib{
|
||||
function xr_test($input){
|
||||
$p1=$input->getParam(0);
|
||||
if(isset($p1) && $p1->scalartyp()=="string") $s=$p1->scalarval();
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 1st parameter, string expected.");
|
||||
$p2=$input->getParam(1);
|
||||
if(isset($p2) && $p2->scalartyp()=="string") $sessid=$p2->scalarval();
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
return new xmlrpcresp(
|
||||
v2xr(strtoupper($s)."_".$this->getSessLogin($sessid)."_".$sessid, false)
|
||||
);
|
||||
}
|
||||
function xr_login($input){
|
||||
$p1=$input->getParam(0);
|
||||
if(isset($p1) && $p1->scalartyp()=="string") $login=$p1->scalarval();
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 1st parameter, string expected.");
|
||||
$p2=$input->getParam(1);
|
||||
if(isset($p2) && $p2->scalartyp()=="string") $pass=$p2->scalarval();
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
if(!($res = $this->login($login, $pass)))
|
||||
return new xmlrpcresp(0, 802,
|
||||
"xr_login: login failed - incorrect username or password.");
|
||||
else
|
||||
class XR_Alib {
|
||||
//class XR_Alib extends Alib {
|
||||
function xr_test($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (isset($p1) && $p1->scalartyp()=="string") {
|
||||
$s = $p1->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 1st parameter, string expected.");
|
||||
}
|
||||
$p2 = $input->getParam(1);
|
||||
if (isset($p2) && $p2->scalartyp() == "string") {
|
||||
$sessid=$p2->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
}
|
||||
return new xmlrpcresp(
|
||||
v2xr(strtoupper($s)."_".Alib::GetSessLogin($sessid)."_".$sessid, false)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function xr_login($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (isset($p1) && $p1->scalartyp()=="string") {
|
||||
$login = $p1->scalarval();
|
||||
}
|
||||
else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 1st parameter, string expected.");
|
||||
}
|
||||
$p2 = $input->getParam(1);
|
||||
if (isset($p2) && $p2->scalartyp() == "string") {
|
||||
$pass = $p2->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
}
|
||||
if (!($res = Alib::Login($login, $pass))) {
|
||||
return new xmlrpcresp(0, 802,
|
||||
"xr_login: login failed - incorrect username or password.");
|
||||
} else {
|
||||
return new xmlrpcresp(v2xr($res, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function xr_logout($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (isset($p1) && $p1->scalartyp()=="string") {
|
||||
$sessid=$p1->scalarval();
|
||||
} else {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
}
|
||||
$res = Alib::Logout($sessid);
|
||||
if (!PEAR::isError($res)) {
|
||||
return new xmlrpcresp(v2xr('Bye', false));
|
||||
} else {
|
||||
return new xmlrpcresp(0, 803,
|
||||
"xr_logout: logout failed - not logged.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function xr_getDir($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (!(isset($p1) && ($p1->scalartyp()=="int") && is_numeric($id=$p1->scalarval()))) {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_getDir: wrong 1st parameter, int expected.");
|
||||
}
|
||||
$res = M2tree::GetDir($id, 'name');
|
||||
return new xmlrpcresp(v2xr($res, false));
|
||||
}
|
||||
function xr_logout($input){
|
||||
$p1=$input->getParam(0);
|
||||
if(isset($p1) && $p1->scalartyp()=="string") $sessid=$p1->scalarval();
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_login: wrong 2nd parameter, string expected.");
|
||||
$res = $this->logout($sessid);
|
||||
if(!PEAR::isError($res)) return new xmlrpcresp(v2xr('Bye', false));
|
||||
else return new xmlrpcresp(0, 803,
|
||||
"xr_logout: logout failed - not logged.");
|
||||
}
|
||||
function xr_getDir($input){
|
||||
$p1=$input->getParam(0);
|
||||
if(isset($p1) && ($p1->scalartyp()=="int") &&
|
||||
is_numeric($id=$p1->scalarval()));
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_getDir: wrong 1st parameter, int expected.");
|
||||
$res = $this->getDir($id, 'name');
|
||||
return new xmlrpcresp(v2xr($res, false));
|
||||
}
|
||||
function xr_getPath($input){
|
||||
$p1=$input->getParam(0);
|
||||
if(isset($p1) && ($p1->scalartyp()=="int") &&
|
||||
is_numeric($id=$p1->scalarval()));
|
||||
else return new xmlrpcresp(0, 801,
|
||||
"xr_getPath: wrong 1st parameter, int expected.");
|
||||
$res = $this->getPath($id, 'id, name');
|
||||
return new xmlrpcresp(v2xr($res, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function xr_getPath($input)
|
||||
{
|
||||
$p1 = $input->getParam(0);
|
||||
if (!(isset($p1) && ($p1->scalartyp()=="int") && is_numeric($id=$p1->scalarval()))) {
|
||||
return new xmlrpcresp(0, 801,
|
||||
"xr_getPath: wrong 1st parameter, int expected.");
|
||||
}
|
||||
$res = M2tree::GetPath($id, 'id, name');
|
||||
return new xmlrpcresp(v2xr($res, false));
|
||||
}
|
||||
} // class XR_Alib
|
||||
|
||||
$alib = new XR_Alib($dbc, $config);
|
||||
$alib = new XR_Alib();
|
||||
|
||||
$s=new xmlrpc_server( array(
|
||||
$s = new xmlrpc_server( array(
|
||||
"alib.xrTest" => array(
|
||||
"function" => array(&$alib, 'xr_test'),
|
||||
"signature" => array(array($xmlrpcString, $xmlrpcString, $xmlrpcString)),
|
||||
|
@ -118,5 +170,5 @@ $s=new xmlrpc_server( array(
|
|||
)
|
||||
));
|
||||
|
||||
require_once"../example/alib_f.php";
|
||||
require_once("../example/alib_f.php");
|
||||
?>
|
|
@ -30,12 +30,12 @@ class Archive extends XR_LocStor {
|
|||
*/
|
||||
function uploadOpen($sessid, $chsum)
|
||||
{
|
||||
$owner = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($owner)) {
|
||||
$owner = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($owner)) {
|
||||
return $owner;
|
||||
}
|
||||
$res = $this->bsOpenPut($chsum, NULL, $owner);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return array('url'=>$res['url'], 'token'=>$res['token']);
|
||||
|
@ -70,7 +70,7 @@ class Archive extends XR_LocStor {
|
|||
function uploadClose($token, $trtype, $pars=array())
|
||||
{
|
||||
$res = $this->bsClosePut($token);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
extract($res); // fname, owner
|
||||
|
@ -78,7 +78,7 @@ class Archive extends XR_LocStor {
|
|||
case "audioclip":
|
||||
$mdtoken = $pars['mdpdtoken'];
|
||||
$res = $this->bsClosePut($mdtoken);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$mdfname = $res['fname'];
|
||||
|
@ -86,13 +86,13 @@ class Archive extends XR_LocStor {
|
|||
$gunid = NULL;
|
||||
}
|
||||
$parid = $this->_getHomeDirId($owner);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->bsPutFile($parid, $pars['name'],
|
||||
$fname, $mdfname,
|
||||
$pars['gunid'], 'audioclip', 'file');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
@unlink($fname);
|
||||
|
@ -103,13 +103,13 @@ class Archive extends XR_LocStor {
|
|||
$gunid = NULL;
|
||||
}
|
||||
$parid = $this->_getHomeDirId($owner);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->bsPutFile($parid, $pars['name'],
|
||||
'', $fname,
|
||||
$pars['gunid'], 'playlist', 'file');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
@unlink($fname);
|
||||
|
@ -118,14 +118,14 @@ class Archive extends XR_LocStor {
|
|||
$chsum = md5_file($fname);
|
||||
// importPlaylistOpen:
|
||||
$res = $this->bsOpenPut($chsum, NULL, $owner);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$dest = $res['fname'];
|
||||
$token = $res['token'];
|
||||
copy($fname, $dest);
|
||||
$r = $this->importPlaylistClose($token);
|
||||
if ($this->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
@unlink($fname);
|
||||
|
@ -136,17 +136,17 @@ class Archive extends XR_LocStor {
|
|||
$criteria = unserialize($crits);
|
||||
@unlink($fname);
|
||||
$results = $this->localSearch($criteria);
|
||||
if ($this->dbc->isError($results)) {
|
||||
if (PEAR::isError($results)) {
|
||||
return $results;
|
||||
}
|
||||
$realfile = tempnam($this->accessDir, 'searchjob_');
|
||||
@chmod($realfile, 0660);
|
||||
$len = file_put_contents($realfile, serialize($results));
|
||||
$acc = $this->bsAccess($realfile, '', NULL, 'download');
|
||||
if ($this->dbc->isError($acc)) {
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
$url = $this->getUrlPart()."access/".basename($acc['fname']);
|
||||
$url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
$chsum = md5_file($realfile);
|
||||
$size = filesize($realfile);
|
||||
$res = array(
|
||||
|
@ -179,6 +179,7 @@ class Archive extends XR_LocStor {
|
|||
*/
|
||||
function downloadOpen($sessid, $trtype, $pars=array())
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
switch ($trtype) {
|
||||
case "unknown":
|
||||
case "audioclip":
|
||||
|
@ -193,8 +194,8 @@ class Archive extends XR_LocStor {
|
|||
$gunid = $pars['gunid'];
|
||||
// resolve trtype by object type:
|
||||
if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
|
||||
$trtype2 = $this->_getType($gunid);
|
||||
if ($this->dbc->isError($trtype2)) {
|
||||
$trtype2 = BasicStor::GetType($gunid);
|
||||
if (PEAR::isError($trtype2)) {
|
||||
return $trtype2;
|
||||
}
|
||||
// required with content:
|
||||
|
@ -214,10 +215,10 @@ class Archive extends XR_LocStor {
|
|||
break;
|
||||
case "playlistPkg":
|
||||
$res = $this->bsExportPlaylistOpen($gunid);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$tmpn = tempnam($this->transDir, 'plExport_');
|
||||
$tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
$plfpath = "$tmpn.lspl";
|
||||
copy($res['fname'], $plfpath);
|
||||
$res = $this->bsExportPlaylistClose($res['token']);
|
||||
|
@ -225,12 +226,12 @@ class Archive extends XR_LocStor {
|
|||
return $res;
|
||||
}
|
||||
$fname = "transported_playlist.lspl";
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$acc = $this->bsAccess($plfpath, 'lspl', NULL, 'download');
|
||||
if ($this->dbc->isError($acc)) {
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
$url = $this->getUrlPart()."access/".basename($acc['fname']);
|
||||
$url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
$chsum = md5_file($plfpath);
|
||||
$size = filesize($plfpath);
|
||||
$res = array(
|
||||
|
@ -248,7 +249,7 @@ class Archive extends XR_LocStor {
|
|||
default:
|
||||
return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
|
||||
}
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
switch ($trtype) {
|
||||
|
@ -289,7 +290,7 @@ class Archive extends XR_LocStor {
|
|||
switch ($trtype) {
|
||||
case "audioclip":
|
||||
$res = $this->downloadRawAudioDataClose($token);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return $res;
|
||||
|
@ -301,14 +302,14 @@ class Archive extends XR_LocStor {
|
|||
return $res;
|
||||
case "playlistPkg":
|
||||
$res = $this->bsRelease($token, 'download');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$realFname = $r['realFname'];
|
||||
@unlink($realFname);
|
||||
if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) {
|
||||
list(,$tmpn) = $va;
|
||||
$tmpn = "{$this->transDir}/$tmpn";
|
||||
$tmpn = $CC_CONFIG['transDir']."/$tmpn";
|
||||
if (file_exists($tmpn)) {
|
||||
@unlink($tmpn);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* ArchiveServer configuration file
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage ArchiveServer
|
||||
*/
|
||||
|
||||
define('LS_VERSION', '1.0');
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
/**
|
||||
* configuration structure:
|
||||
|
@ -37,14 +32,14 @@ define('LS_VERSION', '1.0');
|
|||
|
||||
// these are the default values for the config
|
||||
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'test',
|
||||
'password' => 'test',
|
||||
'hostspec' => 'localhost',
|
||||
'phptype' => 'pgsql',
|
||||
'database' => 'Campcaster-test',
|
||||
'database' => 'Campcaster-paul',
|
||||
),
|
||||
'tblNamePrefix' => 'as_',
|
||||
|
||||
|
@ -101,32 +96,50 @@ $config = array(
|
|||
'RootNode' => 'RootNode',
|
||||
'tmpRootPass' => 'q',
|
||||
);
|
||||
$config['sysSubjs'] = array(
|
||||
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||
|
||||
// Add database table names
|
||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
|
||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||
$CC_CONFIG['classTable'] = $CC_CONFIG['tblNamePrefix'].'classes';
|
||||
$CC_CONFIG['cmembTable'] = $CC_CONFIG['tblNamePrefix'].'cmemb';
|
||||
$CC_CONFIG['treeTable'] = $CC_CONFIG['tblNamePrefix'].'tree';
|
||||
$CC_CONFIG['structTable'] = $CC_CONFIG['tblNamePrefix'].'struct';
|
||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||
|
||||
$CC_CONFIG['sysSubjs'] = array(
|
||||
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr']
|
||||
);
|
||||
$old_ip = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
|
||||
// see if a ~/.campcaster/archiveServer.conf.php exists, and
|
||||
// overwrite the settings from there if any
|
||||
|
||||
$this_file = null;
|
||||
if(isset($_SERVER["SCRIPT_FILENAME"])){
|
||||
$this_file = $_SERVER["SCRIPT_FILENAME"];
|
||||
}elseif(isset($argv[0])){
|
||||
$this_file = $argv[0];
|
||||
//
|
||||
// See if a ~/.campcaster/archiveServer.conf.php exists, and
|
||||
// overwrite the settings from there, if any.
|
||||
//
|
||||
$this_file = null;
|
||||
if (isset($_SERVER["SCRIPT_FILENAME"])) {
|
||||
$this_file = $_SERVER["SCRIPT_FILENAME"];
|
||||
} elseif(isset($argv[0])) {
|
||||
$this_file = $argv[0];
|
||||
}
|
||||
if(!is_null($this_file)){
|
||||
$fileowner_id = fileowner($this_file);
|
||||
$fileowner_array = posix_getpwuid($fileowner_id);
|
||||
|
||||
if (!is_null($this_file)) {
|
||||
$fileowner_id = fileowner($this_file);
|
||||
$fileowner_array = posix_getpwuid($fileowner_id);
|
||||
$fileowner_homedir = $fileowner_array['dir'];
|
||||
$home_conf = $fileowner_homedir . '/.campcaster/archiveServer.conf.php';
|
||||
$home_conf = $fileowner_homedir . '/.campcaster/archiveServer.conf.php';
|
||||
if (file_exists($home_conf)) {
|
||||
$default_config = $config;
|
||||
include $home_conf;
|
||||
$user_config = $config;
|
||||
$config = $user_config + $default_config;
|
||||
$default_config = $CC_CONFIG;
|
||||
include($home_conf);
|
||||
$user_config = $CC_CONFIG;
|
||||
$CC_CONFIG = $user_config + $default_config;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -1,15 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* ArchiveServer configuration file
|
||||
*
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage ArchiveServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
@ -41,7 +32,7 @@ define('CAMPCASTER_VERSION', '1.1.1');
|
|||
|
||||
// these are the default values for the config
|
||||
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'ls_dbuser',
|
||||
|
@ -105,9 +96,25 @@ $config = array(
|
|||
'RootNode' => 'RootNode',
|
||||
'tmpRootPass' => 'q',
|
||||
);
|
||||
$config['sysSubjs'] = array(
|
||||
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||
|
||||
// Add database table names
|
||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
|
||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||
$CC_CONFIG['classTable'] = $CC_CONFIG['tblNamePrefix'].'classes';
|
||||
$CC_CONFIG['cmembTable'] = $CC_CONFIG['tblNamePrefix'].'cmemb';
|
||||
$CC_CONFIG['treeTable'] = $CC_CONFIG['tblNamePrefix'].'tree';
|
||||
$CC_CONFIG['structTable'] = $CC_CONFIG['tblNamePrefix'].'struct';
|
||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||
|
||||
$CC_CONFIG['sysSubjs'] = array(
|
||||
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr']
|
||||
);
|
||||
$old_ip = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
?>
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
?>
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* ArchiveServer configuration file
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage ArchiveServer
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -29,7 +24,7 @@
|
|||
* <dt>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
|
||||
* </dl>
|
||||
*/
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'ls_dbuser',
|
||||
|
@ -52,4 +47,4 @@ $config = array(
|
|||
#'archiveUrlPort' => ls_php_port,
|
||||
|
||||
);
|
||||
?>
|
||||
?>
|
|
@ -8,8 +8,8 @@
|
|||
* This script returns storage root URL
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require "../conf.php";
|
||||
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}";
|
||||
header("Content-type: text/plain");
|
||||
require("../conf.php");
|
||||
echo "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}";
|
||||
?>
|
|
@ -8,8 +8,8 @@
|
|||
* This script returns storage XMLRPC root URL
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require "../conf.php";
|
||||
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
||||
header("Content-type: text/plain");
|
||||
require("../conf.php");
|
||||
echo "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}";
|
||||
?>
|
|
@ -1,7 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage ArchiveServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*
|
||||
*/
|
||||
|
||||
// no remote execution
|
||||
|
@ -13,89 +20,16 @@ if (isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != "") {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../Archive.php';
|
||||
echo "*************************\n";
|
||||
echo "* ArchiveServer Install *\n";
|
||||
echo "*************************\n";
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if (assert_options(ASSERT_ACTIVE) == 1) {
|
||||
return;
|
||||
}
|
||||
echo "ERROR:\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo().
|
||||
"\nui:\n".$err->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
require_once('../conf.php');
|
||||
require_once('../../../storageServer/var/GreenBox.php');
|
||||
require_once('../../../storageServer/var/install/installMain.php');
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
echo "**********************************\n";
|
||||
echo "* ArchiveServer Install Complete *\n";
|
||||
echo "**********************************\n";
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
echo $dbc->getMessage()."\n";
|
||||
echo $dbc->getUserInfo()."\n";
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in var/conf.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new Archive($dbc, $config, TRUE);
|
||||
$tr = new Transport($gb);
|
||||
|
||||
echo "# archiveServer step 2:\n# trying uninstall ...\n";
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$gb->uninstall();
|
||||
$tr->uninstall();
|
||||
|
||||
echo "# Install ...\n";
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s<hr>\n");
|
||||
$r = $gb->install();
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "# Testing ...\n";
|
||||
$r = $gb->test();
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$log = $gb->test_log;
|
||||
if ($log) {
|
||||
echo "# testlog:\n{$log}";
|
||||
}
|
||||
|
||||
echo "# Delete test data ...\n";
|
||||
$gb->deleteData();
|
||||
|
||||
if (!($fp = @fopen($config['storageDir']."/_writeTest", 'w'))) {
|
||||
echo "\n<b>make {$config['storageDir']} dir webdaemon-writeable</b>".
|
||||
"\nand run install again\n\n";
|
||||
exit(1);
|
||||
} else {
|
||||
fclose($fp); unlink($config['storageDir']."/_writeTest");
|
||||
echo "#archiveServer install: OK\n\n";
|
||||
}
|
||||
|
||||
echo "# Install Transport submodule ...";
|
||||
$r = $tr->install();
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
echo $r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "# OK\n";
|
||||
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
|
@ -1,52 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage ArchiveServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../Archive.php';
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if (assert_options(ASSERT_ACTIVE) == 1) {
|
||||
return;
|
||||
}
|
||||
echo "ERROR:\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo().
|
||||
"\nui:\n".$err->getUserInfo()."\n</pre>\n";
|
||||
exit(1);
|
||||
// Do not allow remote execution.
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "***************************\n";
|
||||
echo "* ArchiveServer Uninstall *\n";
|
||||
echo "***************************\n";
|
||||
|
||||
echo "#ArchiveServer uninstall:\n";
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new Archive($dbc, $config, TRUE);
|
||||
$tr = new Transport($gb);
|
||||
require_once('../conf.php');
|
||||
require_once('../../../storageServer/var/install/uninstallMain.php');
|
||||
|
||||
echo "************************************\n";
|
||||
echo "* ArchiveServer Uninstall Complete *\n";
|
||||
echo "************************************\n";
|
||||
|
||||
echo "# Uninstall Transport submodule ...";
|
||||
$r = $tr->uninstall();
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getUserInfo()."\n";
|
||||
exit;
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$gb->uninstall();
|
||||
echo "#ArchiveServer uninstall: OK\n";
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
|
@ -105,7 +105,7 @@ class XR_Archive extends Archive {
|
|||
|
||||
|
||||
/**
|
||||
* @param XMLRPC_strcut $input
|
||||
* @param XML_RPC_Message $input
|
||||
* @return XML_RPC_Response
|
||||
*/
|
||||
function xr_downloadOpen($input)
|
||||
|
|
|
@ -32,16 +32,17 @@
|
|||
|
||||
define('USE_FLOCK', TRUE);
|
||||
|
||||
require_once dirname(__FILE__).'/../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once dirname(__FILE__).'/../Archive.php';
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/../Archive.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new Archive($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new Archive($CC_DBC, $CC_CONFIG);
|
||||
|
||||
function http_error($code, $err) {
|
||||
function http_error($code, $err)
|
||||
{
|
||||
header("HTTP/1.1 $code");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "$err\r\n";
|
||||
|
@ -61,7 +62,7 @@ if(!$tc){ http_error(403, "put.php: Token not valid ($token)."); }
|
|||
|
||||
header("Content-type: text/plain");
|
||||
|
||||
$destfile = "{$config['accessDir']}/{$token}";
|
||||
$destfile = "{$CC_CONFIG['accessDir']}/{$token}";
|
||||
|
||||
/* PUT data comes in on the input stream */
|
||||
$putdata = @fopen("php://input", "r") or
|
||||
|
|
|
@ -61,14 +61,14 @@ $old_error_handler = set_error_handler("errHndl", E_ALL);
|
|||
|
||||
|
||||
/* ============================================================= runable code */
|
||||
$dbc =& DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
trigger_error("DB::connect: ".$dbc->getMessage()." ".$dbc->getUserInfo(),E_USER_ERROR);
|
||||
$CC_DBC =& DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
trigger_error("DB::connect: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo(),E_USER_ERROR);
|
||||
}
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$archive = new XR_Archive($dbc, $config);
|
||||
$archive = new XR_Archive($CC_DBC, $CC_CONFIG);
|
||||
|
||||
$methods = array(
|
||||
'test' => 'Tests toupper and checks sessid, params: '.
|
||||
|
|
|
@ -133,7 +133,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
|
|||
|
||||
case "PL.downloadExportedFile":
|
||||
$exportedPlaylist = $uiBrowser->gb->exportPlaylistOpen($uiBrowser->sessid,
|
||||
$uiBrowser->gb->gunidFromId($_REQUEST['id']),
|
||||
BasicStor::GunidFromId($_REQUEST['id']),
|
||||
$_REQUEST['playlisttype'],
|
||||
$_REQUEST['exporttype']=='playlistOnly'?true:false);
|
||||
$fp = fopen($exportedPlaylist['fname'],'r');
|
||||
|
|
|
@ -5,32 +5,32 @@ function login(&$data)
|
|||
include_once(dirname(__FILE__).'/../../../storageServer/var/GreenBox.php');
|
||||
include_once('DB.php');
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
|
||||
if (DB::isError($dbc)) {
|
||||
die($dbc->getMessage());
|
||||
if (DB::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
if (!$data['PHP_AUTH_USER'] || !$data['PHP_AUTH_PW']) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$sessid = $gb->login($data['PHP_AUTH_USER'], $data['PHP_AUTH_PW']);
|
||||
$sessid = Alib::Login($data['PHP_AUTH_USER'], $data['PHP_AUTH_PW']);
|
||||
|
||||
if (!$sessid || PEAR::isError($sessid)){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
setcookie($config['authCookieName'], $sessid);
|
||||
setcookie($CC_CONFIG['authCookieName'], $sessid);
|
||||
|
||||
if ($gb->isMemberOf($gb->getSessUserId($sessid), $gb->getSubjId('Admins')) !== TRUE) {
|
||||
if (Subjects::IsMemberOf(GreenBox::GetSessUserId($sessid), Subjects::GetSubjId('Admins')) !== TRUE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$id = $gb->getObjId($data['PHP_AUTH_USER'], $gb->storId);
|
||||
$id = M2tree::GetObjId($data['PHP_AUTH_USER'], $gb->storId);
|
||||
|
||||
if (PEAR::isError($id)) {
|
||||
return FALSE;
|
||||
|
|
|
@ -53,7 +53,7 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
|
|||
<li><a href="{$UI_HANDLER}?act=SCHEDULER.set&view=week&target=SCHEDULER">##Week##</a></li>
|
||||
<li><a href="{$UI_HANDLER}?act=SCHEDULER.set&view=day&target=SCHEDULER">##Day##</a></li>
|
||||
<li><a href="{$UI_HANDLER}?act=SCHEDULER.set&view=day&today=1&target=SCHEDULER">##Today##</a></li>
|
||||
{* if $SUBJECTS->Base->gb->checkPerm($SUBJECTS->Base->userid, 'schedulerStatus') *}
|
||||
{* if Alib::CheckPerm($SUBJECTS->Base->userid, 'schedulerStatus') *}
|
||||
<li><a href="{$UI_HANDLER}?act=SCHEDULER.set&view=status&target=SCHEDULER">##Status##</a></li>
|
||||
{* /if *}
|
||||
{* if $SUBJECTS->isMemberOf('Backup') *}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<li><a href="javascript: hpopup('{$UI_HANDLER}?act=SCHEDULER.set&view=week')">##Week##</a></li>
|
||||
<li><a href="javascript: hpopup('{$UI_HANDLER}?act=SCHEDULER.set&view=month')">##Month##</a></li>
|
||||
<li><a href="javascript: hpopup('{$UI_HANDLER}?act=SCHEDULER.set&view=day&today=1')">##Today##</a></li>
|
||||
{* if $SUBJECTS->Base->gb->checkPerm($SUBJECTS->Base->userid, 'schedulerStatus') *}
|
||||
{* if Alib::CheckPerm($SUBJECTS->Base->userid, 'schedulerStatus') *}
|
||||
<li><a href="javascript: hpopup('{$UI_HANDLER}?act=SCHEDULER.set&view=status'); location.href='{$UI_BROWSER}?act=SCHEDULER'">##Status##</a></li>
|
||||
{* /if *}
|
||||
{* if $SUBJECTS->isMemberOf('Backup') *}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{assign var="dynform" value=$SUBJECTS->getChgPasswdForm($SUBJECTS->Base->gb->getSubjName($_REQUEST.id), false)}
|
||||
{assign var="dynform" value=$SUBJECTS->getChgPasswdForm(Subjects::GetSubjName($_REQUEST.id), false)}
|
||||
|
||||
<div class="container_elements" style="width: 607px;">
|
||||
<h1>{tra str='Change password for: $1' 1=$SUBJECTS->Base->gb->getSubjName($_REQUEST.id)}</h1>
|
||||
<h1>{tra str='Change password for: $1' 1=Subjects::GetSubjName($_REQUEST.id)}</h1>
|
||||
{include file="sub/dynForm_plain.tpl"}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{assign var="_gname" value=$SUBJECTS->Base->gb->getSubjName($_REQUEST.id)}
|
||||
{assign var="_gname" value=Subjects::GetSubjName($_REQUEST.id)}
|
||||
|
||||
<div class="container_elements" style="width: 607px;">
|
||||
<h1>{tra str='Manage Group: $1' 1=$_gname}</h1>
|
||||
|
|
|
@ -183,12 +183,7 @@ class uiBase
|
|||
/**
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $config;
|
||||
//public $dbc;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -218,36 +213,31 @@ class uiBase
|
|||
* @param array $config
|
||||
* configuration data
|
||||
*/
|
||||
public function __construct(&$config)
|
||||
public function __construct()
|
||||
{
|
||||
$this->dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (DB::isError($this->dbc)) {
|
||||
die($this->dbc->getMessage());
|
||||
}
|
||||
$this->dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$this->gb = new GreenBox($this->dbc, $config);
|
||||
$this->config =& $config;
|
||||
$this->config['accessRawAudioUrl'] = $config['storageUrlPath'].'/xmlrpc/simpleGet.php';
|
||||
$this->sessid = isset($_REQUEST[$config['authCookieName']]) ?
|
||||
$_REQUEST[$config['authCookieName']] : null;
|
||||
$this->userid = $this->gb->getSessUserId($this->sessid);
|
||||
$this->login = $this->gb->getSessLogin($this->sessid);
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$this->gb = new GreenBox();
|
||||
$CC_CONFIG['accessRawAudioUrl'] = $CC_CONFIG['storageUrlPath'].'/xmlrpc/simpleGet.php';
|
||||
$this->sessid = isset($_REQUEST[$CC_CONFIG['authCookieName']]) ?
|
||||
$_REQUEST[$CC_CONFIG['authCookieName']] : null;
|
||||
$this->userid = GreenBox::GetSessUserId($this->sessid);
|
||||
$this->login = Alib::GetSessLogin($this->sessid);
|
||||
if (PEAR::isError($this->login)) {
|
||||
$this->login = null;
|
||||
}
|
||||
$this->langid =& $_SESSION['langid'];
|
||||
|
||||
if (!is_null($this->login)) {
|
||||
if (isset($_REQUEST['id'])) {
|
||||
if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
|
||||
$this->id = $_REQUEST['id'];
|
||||
} else {
|
||||
$this->id = $this->gb->getObjId($this->login, $this->gb->storId);
|
||||
$this->id = M2tree::GetObjId($this->login, $this->gb->storId);
|
||||
}
|
||||
$this->pid = $this->gb->getparent($this->id) != 1 ?
|
||||
$this->gb->getparent($this->id) : FALSE;
|
||||
$this->type = $this->gb->getFileType($this->id);
|
||||
$parentId = M2tree::GetParent($this->id);
|
||||
$this->pid = ($parentId != 1) ? $parentId : FALSE;
|
||||
$this->type = Greenbox::getFileType($this->id);
|
||||
$this->fid = ($this->type == 'Folder') ? $this->id : $this->pid;
|
||||
$this->homeid = $this->gb->getObjId($this->login, $this->gb->storId);
|
||||
$this->homeid = M2tree::GetObjId($this->login, $this->gb->storId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -286,8 +276,9 @@ class uiBase
|
|||
$this->STATIONPREFS[$val['element']] = $setting;
|
||||
} elseif ($val['required']) {
|
||||
// set default values on first login
|
||||
$this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $val['default']);
|
||||
$this->STATIONPREFS[$val['element']] = $val['default'];
|
||||
$default = isset($val['default'])?$val['default']:null;
|
||||
$this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $default);
|
||||
$this->STATIONPREFS[$val['element']] = $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +464,8 @@ class uiBase
|
|||
|
||||
public function toHex($gunid)
|
||||
{
|
||||
$res = $this->dbc->query("SELECT to_hex($gunid)");
|
||||
global $CC_DBC;
|
||||
$res = $CC_DBC->query("SELECT to_hex($gunid)");
|
||||
$row = $res->fetchRow();
|
||||
return $row['to_hex'];
|
||||
} // fn toHex
|
||||
|
@ -481,7 +473,8 @@ class uiBase
|
|||
|
||||
public function toInt8($gunid)
|
||||
{
|
||||
$res = $this->dbc->query("SELECT x'$gunid'::bigint");
|
||||
global $CC_DBC;
|
||||
$res = $CC_DBC->query("SELECT x'$gunid'::bigint");
|
||||
$row = $res->fetchRow();
|
||||
return $row['int8'];
|
||||
} // fn toInt8
|
||||
|
@ -504,9 +497,9 @@ class uiBase
|
|||
|
||||
public function getMetaInfo($id)
|
||||
{
|
||||
$type = strtolower($this->gb->getFileType($id));
|
||||
$type = strtolower(GreenBox::getFileType($id));
|
||||
$data = array('id' => $id,
|
||||
'gunid' => $this->gb->gunidFromId($id),
|
||||
'gunid' => BasicStor::GunidFromId($id),
|
||||
'title' => $this->getMetadataValue($id, UI_MDATA_KEY_TITLE),
|
||||
'creator' => $this->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
|
||||
'duration' => $this->getMetadataValue($id, UI_MDATA_KEY_DURATION),
|
||||
|
@ -549,7 +542,7 @@ class uiBase
|
|||
*/
|
||||
private function _getFileTitle($id)
|
||||
{
|
||||
if (is_array($arr = $this->gb->getPath($id))) {
|
||||
if (is_array($arr = GreenBox::GetPath($id))) {
|
||||
$file = array_pop($arr);
|
||||
return $file['name'];
|
||||
}
|
||||
|
@ -559,7 +552,7 @@ class uiBase
|
|||
|
||||
// function _isFolder($id)
|
||||
// {
|
||||
// if (strtolower($this->gb->getFileType($id)) != 'folder') {
|
||||
// if (strtolower(GreenBox::getFileType($id)) != 'folder') {
|
||||
// return FALSE;
|
||||
// }
|
||||
// return TRUE;
|
||||
|
|
|
@ -250,7 +250,7 @@ class uiBrowse
|
|||
|
||||
$this->results['cnt'] = $results['cnt'];
|
||||
foreach ($results['results'] as $rec) {
|
||||
$tmpId = $this->Base->gb->idFromGunid($rec["gunid"]);
|
||||
$tmpId = BasicStor::IdFromGunid($rec["gunid"]);
|
||||
$this->results['items'][] = $this->Base->getMetaInfo($tmpId);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,10 @@ class uiBrowser extends uiBase {
|
|||
/**
|
||||
* Initialize a new Browser Class.
|
||||
* Call uiBase constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* configurartion data
|
||||
*/
|
||||
public function __construct(&$config)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($config);
|
||||
parent::__construct();
|
||||
} // constructor
|
||||
|
||||
|
||||
|
@ -86,8 +83,8 @@ class uiBrowser extends uiBase {
|
|||
*/
|
||||
function getUserInfo()
|
||||
{
|
||||
return array('uname'=>$this->gb->getSessLogin($this->sessid),
|
||||
'uid' =>$this->gb->getSessUserId($this->sessid));
|
||||
return array('uname'=> Alib::GetSessLogin($this->sessid),
|
||||
'uid' => GreenBox::GetSessUserId($this->sessid));
|
||||
} // fn getUserInfo
|
||||
|
||||
|
||||
|
@ -102,14 +99,14 @@ class uiBrowser extends uiBase {
|
|||
function getStructure($id)
|
||||
{
|
||||
$data = array(
|
||||
'pathdata' => $this->gb->getPath($id, $this->sessid),
|
||||
'listdata' => $this->gb->getObjType($id)=='Folder' ? $this->gb->listFolder($id, $this->sessid) : array(),
|
||||
'pathdata' => GreenBox::GetPath($id, $this->sessid),
|
||||
'listdata' => BasicStor::GetObjType($id)=='Folder' ? $this->gb->listFolder($id, $this->sessid) : array(),
|
||||
);
|
||||
$tree = isset($_REQUEST['tree']) ? $_REQUEST['tree'] : null;
|
||||
if ($tree == 'Y') {
|
||||
$tmp = $this->gb->getSubTree($id, $this->sessid);
|
||||
$tmp = M2tree::GetSubTree($id, $this->sessid);
|
||||
foreach ($tmp as $key=>$val) {
|
||||
$val['type'] = $this->gb->getFileType($val['id']);
|
||||
$val['type'] = Greenbox::getFileType($val['id']);
|
||||
$data['treedata'][$key] = $val;
|
||||
}
|
||||
}
|
||||
|
@ -213,9 +210,9 @@ class uiBrowser extends uiBase {
|
|||
*/
|
||||
function permissions($id)
|
||||
{
|
||||
return array('pathdata' => $this->gb->getPath($id),
|
||||
'perms' => $this->gb->getObjPerms($id),
|
||||
'actions' => $this->gb->getAllowedActions($this->gb->getObjType($id)),
|
||||
return array('pathdata' => GreenBox::GetPath($id),
|
||||
'perms' => Alib::GetObjPerms($id),
|
||||
'actions' => Alib::GetAllowedActions(BasicStor::GetObjType($id)),
|
||||
'subjects' => $this->gb->getSubjects(),
|
||||
'id' => $id,
|
||||
'loggedAs' => $this->login
|
||||
|
@ -407,7 +404,7 @@ class uiBrowser extends uiBase {
|
|||
if ($type = stristr($val, "content-type:")) {
|
||||
$type = explode(':', $type);
|
||||
|
||||
foreach ($this->config['stream_types'] as $t) {
|
||||
foreach ($CC_CONFIG['stream_types'] as $t) {
|
||||
if (preg_match('/'.str_replace('/', '\/', $t).'/i', $type[1])) {
|
||||
$match = TRUE;
|
||||
break;
|
||||
|
@ -447,11 +444,12 @@ class uiBrowser extends uiBase {
|
|||
*/
|
||||
function listen2Audio($clipid)
|
||||
{
|
||||
$id = $this->gb->idFromGunid($clipid);
|
||||
$type = $this->gb->getFileType($id);
|
||||
global $CC_CONFIG;
|
||||
$id = BasicStor::IdFromGunid($clipid);
|
||||
$type = Greenbox::getFileType($id);
|
||||
|
||||
if (strtolower($type) === strtolower(UI_FILETYPE_AUDIOCLIP)) {
|
||||
$m3u = "http://{$_SERVER['SERVER_NAME']}".$this->config['accessRawAudioUrl']."?sessid={$this->sessid}&id=$clipid\n";
|
||||
$m3u = "http://{$_SERVER['SERVER_NAME']}".$CC_CONFIG['accessRawAudioUrl']."?sessid={$this->sessid}&id=$clipid\n";
|
||||
} else {
|
||||
$m3u = $this->getMetadataValue($id, UI_MDATA_KEY_URL);
|
||||
}
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
header("Content-type: text/html; charset=utf-8");
|
||||
session_start();
|
||||
|
||||
## LS classes/functions #############################################
|
||||
// CC classes/functions #############################################
|
||||
require_once(dirname(__FILE__).'/ui_conf.php');
|
||||
require_once(dirname(__FILE__).'/ui_browser.class.php');
|
||||
|
||||
|
||||
## well known classes ###############################################
|
||||
// often used classes ###############################################
|
||||
require_once(dirname(__FILE__).'/Smarty/libs/Smarty.class.php');
|
||||
require_once('HTML/QuickForm/Renderer/ArraySmarty.php');
|
||||
|
||||
## initialize objects ###############################################
|
||||
// initialize objects ###############################################
|
||||
$Smarty = new Smarty;
|
||||
$uiBrowser = new uiBrowser($config);
|
||||
$uiBrowser = new uiBrowser($CC_CONFIG);
|
||||
$uiBrowser->init();
|
||||
|
||||
$uiBase =& $uiBrowser;
|
||||
|
@ -21,27 +21,27 @@ $jscom = new jscom(array("jscom_wrapper"));
|
|||
$jscom->handler();
|
||||
|
||||
|
||||
## load Smarty+filters ##############################################
|
||||
// load Smarty+filters ##############################################
|
||||
require_once(dirname(__FILE__).'/ui_smartyExtensions.inc.php');
|
||||
#$Smarty->load_filter('output', 'trimwhitespace');
|
||||
#$Smarty->load_filter('post', 'template_marker');
|
||||
//$Smarty->load_filter('output', 'trimwhitespace');
|
||||
//$Smarty->load_filter('post', 'template_marker');
|
||||
$Smarty->load_filter('output', 'localizer');
|
||||
|
||||
|
||||
## some basic things ################################################
|
||||
// some basic things ################################################
|
||||
foreach (get_defined_constants() as $k=>$v) {
|
||||
$Smarty->assign($k, $v);
|
||||
}
|
||||
|
||||
$Smarty->assign('ACT', isset($_REQUEST['act'])?$_REQUEST['act']:null);
|
||||
$Smarty->assign('CONFIG', $config);
|
||||
$Smarty->assign('START', array(
|
||||
$Smarty->assign('ACT', isset($_REQUEST['act'])?$_REQUEST['act']:null);
|
||||
$Smarty->assign('CONFIG', $CC_CONFIG);
|
||||
$Smarty->assign('START', array(
|
||||
'id' => &$uiBrowser->id,
|
||||
'pid' => &$uiBrowser->pid,
|
||||
'fid' => &$uiBrowser->fid,
|
||||
'sessid' => &$uiBrowser->sessid)
|
||||
);
|
||||
$Smarty->assign('USER', array(
|
||||
$Smarty->assign('USER', array(
|
||||
'sessid' => &$uiBrowser->sessid,
|
||||
'userid' => &$uiBrowser->userid,
|
||||
'login' => &$uiBrowser->login)
|
||||
|
@ -50,7 +50,7 @@ $uiBrowser->loadStationPrefs($ui_fmask['stationPrefs']);
|
|||
$Smarty->assign('STATIONPREFS', $uiBrowser->STATIONPREFS);
|
||||
$Smarty->assign_by_ref('_REQUEST', &$_REQUEST);
|
||||
|
||||
## retransfer incomplete formdata from SESSION to POST-data #########
|
||||
// retransfer incomplete formdata from SESSION to POST-data #########
|
||||
if (isset($_SESSION['retransferFormData']) && is_array($_SESSION['retransferFormData'])) {
|
||||
foreach($_SESSION['retransferFormData'] as $k=>$v){
|
||||
$_POST[$k] = $v;
|
||||
|
|
|
@ -2,124 +2,125 @@
|
|||
ini_set('memory_limit', '64M');
|
||||
|
||||
// Warning/Error level
|
||||
define('UI_DEBUG', FALSE);
|
||||
define('UI_VERBOSE', FALSE);
|
||||
define('UI_WARNING', TRUE);
|
||||
define('UI_ERROR', TRUE);
|
||||
define('UI_DEBUG', TRUE);
|
||||
define('UI_VERBOSE', FALSE);
|
||||
define('UI_WARNING', TRUE);
|
||||
define('UI_ERROR', TRUE);
|
||||
|
||||
if (UI_DEBUG) {
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
|
||||
define('UI_VERSION', 'Campcaster 1.1.1');
|
||||
define('UI_VERSION_FULLNAME', 'Campcaster 1.1.1');
|
||||
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
|
||||
define('UI_VERSION', 'Campcaster 1.1.1');
|
||||
define('UI_VERSION_FULLNAME', 'Campcaster 1.1.1');
|
||||
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
|
||||
|
||||
// Local settings
|
||||
define('UI_DEFAULT_LANGID', 'en_GB');
|
||||
//define('UI_UPLOAD_LANGID', $_SESSION['langid']);
|
||||
define('UI_UPLOAD_LANGID', UI_DEFAULT_LANGID);
|
||||
define('UI_TIMEZONEOFFSET', date('Z'));
|
||||
define('UI_DEFAULT_LANGID', 'en_GB');
|
||||
//define('UI_UPLOAD_LANGID', $_SESSION['langid']);
|
||||
define('UI_UPLOAD_LANGID', UI_DEFAULT_LANGID);
|
||||
define('UI_TIMEZONEOFFSET', date('Z'));
|
||||
|
||||
// Basic scripts
|
||||
define('UI_HANDLER', 'ui_handler.php');
|
||||
define('UI_BROWSER', 'ui_browser.php');
|
||||
define('UI_HANDLER', 'ui_handler.php');
|
||||
define('UI_BROWSER', 'ui_browser.php');
|
||||
|
||||
// HTML Form stuff
|
||||
define('UI_STANDARD_FORM_METHOD', 'POST');
|
||||
define('UI_INPUT_STANDARD_SIZE', 50);
|
||||
define('UI_INPUT_STANDARD_MAXLENGTH', 255);
|
||||
define('UI_TEXTAREA_STANDART_ROWS', 5);
|
||||
define('UI_TEXTAREA_STANDART_COLS', 32);
|
||||
define('UI_BUTTON_STYLE', 'button');
|
||||
define('UI_QFORM_REQUIRED', '../templates/sub/form_required.tpl');
|
||||
define('UI_QFORM_REQUIREDNOTE', '../templates/sub/form_requirednote.tpl');
|
||||
define('UI_QFORM_ERROR', '../templates/sub/form_error.tpl');
|
||||
define('UI_REGEX_URL', '/^(ht|f)tps?:\/\/[^ ]+$/');
|
||||
define('UI_STANDARD_FORM_METHOD', 'POST');
|
||||
define('UI_INPUT_STANDARD_SIZE', 50);
|
||||
define('UI_INPUT_STANDARD_MAXLENGTH', 255);
|
||||
define('UI_TEXTAREA_STANDART_ROWS', 5);
|
||||
define('UI_TEXTAREA_STANDART_COLS', 32);
|
||||
define('UI_BUTTON_STYLE', 'button');
|
||||
define('UI_QFORM_REQUIRED', '../templates/sub/form_required.tpl');
|
||||
define('UI_QFORM_REQUIREDNOTE', '../templates/sub/form_requirednote.tpl');
|
||||
define('UI_QFORM_ERROR', '../templates/sub/form_error.tpl');
|
||||
define('UI_REGEX_URL', '/^(ht|f)tps?:\/\/[^ ]+$/');
|
||||
|
||||
// DB ls_pref keys
|
||||
define('UI_PL_ACCESSTOKEN_KEY', 'playlistToken');
|
||||
define('UI_SCRATCHPAD_KEY', 'scratchpadContents');
|
||||
define('UI_SCRATCHPAD_MAXLENGTH_KEY', 'scratchpadMaxlength');
|
||||
define('UI_PL_ACCESSTOKEN_KEY', 'playlistToken');
|
||||
define('UI_SCRATCHPAD_KEY', 'scratchpadContents');
|
||||
define('UI_SCRATCHPAD_MAXLENGTH_KEY', 'scratchpadMaxlength');
|
||||
//define('UI_SCRATCHPAD_REGEX', '/^[0-9a-f]{16}:[0-9]{4}-[0-9]{2}-[0-9]{2}$/');
|
||||
|
||||
// Session Keys
|
||||
define('UI_SCRATCHPAD_SESSNAME', 'SCRATCHPAD');
|
||||
define('UI_STATIONINFO_SESSNAME', 'STATIONINFO');
|
||||
define('UI_BROWSE_SESSNAME', 'L_BROWSE');
|
||||
define('UI_SEARCH_SESSNAME', 'L_SEARCH');
|
||||
define('UI_HUBBROWSE_SESSNAME', 'L_HUBBROWSE');
|
||||
define('UI_HUBSEARCH_SESSNAME', 'L_HUBSEARCH');
|
||||
define('UI_TRANSFER_SESSNAME', 'L_TRANSFER');
|
||||
define('UI_PLAYLIST_SESSNAME', 'PLAYLIST');
|
||||
define('UI_LOCALIZER_SESSNAME', 'LOCALIZER');
|
||||
define('UI_CALENDAR_SESSNAME', 'CALENDAR');
|
||||
define('UI_SCRATCHPAD_SESSNAME', 'SCRATCHPAD');
|
||||
define('UI_STATIONINFO_SESSNAME', 'STATIONINFO');
|
||||
define('UI_BROWSE_SESSNAME', 'L_BROWSE');
|
||||
define('UI_SEARCH_SESSNAME', 'L_SEARCH');
|
||||
define('UI_HUBBROWSE_SESSNAME', 'L_HUBBROWSE');
|
||||
define('UI_HUBSEARCH_SESSNAME', 'L_HUBSEARCH');
|
||||
define('UI_TRANSFER_SESSNAME', 'L_TRANSFER');
|
||||
define('UI_PLAYLIST_SESSNAME', 'PLAYLIST');
|
||||
define('UI_LOCALIZER_SESSNAME', 'LOCALIZER');
|
||||
define('UI_CALENDAR_SESSNAME', 'CALENDAR');
|
||||
|
||||
// Metadata Keys
|
||||
define('UI_MDATA_KEY_TITLE', 'dc:title');
|
||||
define('UI_MDATA_KEY_CREATOR', 'dc:creator');
|
||||
define('UI_MDATA_KEY_DURATION', 'dcterms:extent');
|
||||
define('UI_MDATA_KEY_URL', 'ls:url');
|
||||
define('UI_MDATA_KEY_FORMAT', 'dc:format');
|
||||
define('UI_MDATA_KEY_DESCRIPTION', 'dc:description');
|
||||
define('UI_MDATA_KEY_CHANNELS', 'ls:channels');
|
||||
define('UI_MDATA_KEY_SAMPLERATE', 'ls:samplerate');
|
||||
define('UI_MDATA_KEY_BITRATE', 'ls:bitrate');
|
||||
define('UI_MDATA_KEY_ENCODER', 'ls:encoder');
|
||||
define('UI_MDATA_VALUE_FORMAT_FILE', 'File');
|
||||
define('UI_MDATA_VALUE_FORMAT_STREAM', 'live stream');
|
||||
define('UI_MDATA_KEY_TITLE', 'dc:title');
|
||||
define('UI_MDATA_KEY_CREATOR', 'dc:creator');
|
||||
define('UI_MDATA_KEY_DURATION', 'dcterms:extent');
|
||||
define('UI_MDATA_KEY_URL', 'ls:url');
|
||||
define('UI_MDATA_KEY_FORMAT', 'dc:format');
|
||||
define('UI_MDATA_KEY_DESCRIPTION', 'dc:description');
|
||||
define('UI_MDATA_KEY_CHANNELS', 'ls:channels');
|
||||
define('UI_MDATA_KEY_SAMPLERATE', 'ls:samplerate');
|
||||
define('UI_MDATA_KEY_BITRATE', 'ls:bitrate');
|
||||
define('UI_MDATA_KEY_ENCODER', 'ls:encoder');
|
||||
define('UI_MDATA_VALUE_FORMAT_FILE', 'File');
|
||||
define('UI_MDATA_VALUE_FORMAT_STREAM', 'live stream');
|
||||
|
||||
// Search/Browse preferences
|
||||
define('UI_SIMPLESEARCH_FILETYPE', 'File');
|
||||
define('UI_SIMPLESEARCH_OPERATOR', 'OR');
|
||||
define('UI_SIMPLESEARCH_LIMIT', 10);
|
||||
define('UI_SIMPLESEARCH_ROWS', 3);
|
||||
define('UI_SIMPLESEARCH_CAT1', 'dc:title');
|
||||
define('UI_SIMPLESEARCH_OP1', 'partial');
|
||||
define('UI_SIMPLESEARCH_CAT2', 'dc:creator');
|
||||
define('UI_SIMPLESEARCH_OP2', 'partial');
|
||||
define('UI_SIMPLESEARCH_CAT3', 'dc:source');
|
||||
define('UI_SIMPLESEARCH_OP3', 'partial');
|
||||
define('UI_SIMPLESEARCH_FILETYPE', 'File');
|
||||
define('UI_SIMPLESEARCH_OPERATOR', 'OR');
|
||||
define('UI_SIMPLESEARCH_LIMIT', 10);
|
||||
define('UI_SIMPLESEARCH_ROWS', 3);
|
||||
define('UI_SIMPLESEARCH_CAT1', 'dc:title');
|
||||
define('UI_SIMPLESEARCH_OP1', 'partial');
|
||||
define('UI_SIMPLESEARCH_CAT2', 'dc:creator');
|
||||
define('UI_SIMPLESEARCH_OP2', 'partial');
|
||||
define('UI_SIMPLESEARCH_CAT3', 'dc:source');
|
||||
define('UI_SIMPLESEARCH_OP3', 'partial');
|
||||
|
||||
define('UI_SEARCH_MAX_ROWS', 8);
|
||||
define('UI_SEARCH_DEFAULT_LIMIT', 10);
|
||||
define('UI_SEARCHRESULTS_DELTA', 4);
|
||||
define('UI_SEARCH_MAX_ROWS', 8);
|
||||
define('UI_SEARCH_DEFAULT_LIMIT', 10);
|
||||
define('UI_SEARCHRESULTS_DELTA', 4);
|
||||
|
||||
define('UI_BROWSERESULTS_DELTA', 4);
|
||||
define('UI_BROWSE_DEFAULT_KEY_1', 'dc:type');
|
||||
define('UI_BROWSE_DEFAULT_KEY_2', 'dc:creator');
|
||||
define('UI_BROWSE_DEFAULT_KEY_3', 'dc:source');
|
||||
define('UI_BROWSE_DEFAULT_LIMIT', 10);
|
||||
define('UI_BROWSERESULTS_DELTA', 4);
|
||||
define('UI_BROWSE_DEFAULT_KEY_1', 'dc:type');
|
||||
define('UI_BROWSE_DEFAULT_KEY_2', 'dc:creator');
|
||||
define('UI_BROWSE_DEFAULT_KEY_3', 'dc:source');
|
||||
define('UI_BROWSE_DEFAULT_LIMIT', 10);
|
||||
|
||||
define('UI_HUB_POLLING_FREQUENCY', 3);
|
||||
define('UI_HUB_POLLING_FREQUENCY', 3);
|
||||
|
||||
// Scheduler / Calendar
|
||||
define('UI_SCHEDULER_FIRSTWEEKDAY', 1);
|
||||
define('UI_SCHEDULER_DEFAULT_VIEW', 'day');
|
||||
define('UI_SCHEDULER_PAUSE_PL2PL', '0 seconds');
|
||||
define('UI_SCHEDULER_IMPORTTOKEN_KEY', 'schedulerImportToken');
|
||||
define('UI_SCHEDULER_EXPORTTOKEN_KEY', 'schedulerExportToken');
|
||||
define('UI_SCHEDULER_FIRSTWEEKDAY', 1);
|
||||
define('UI_SCHEDULER_DEFAULT_VIEW', 'day');
|
||||
define('UI_SCHEDULER_PAUSE_PL2PL', '0 seconds');
|
||||
define('UI_SCHEDULER_IMPORTTOKEN_KEY', 'schedulerImportToken');
|
||||
define('UI_SCHEDULER_EXPORTTOKEN_KEY', 'schedulerExportToken');
|
||||
|
||||
// File types
|
||||
define('UI_FILETYPE_ANY', 'all');
|
||||
define('UI_FILETYPE_PLAYLIST', 'playlist');
|
||||
define('UI_FILETYPE_AUDIOCLIP', 'audioClip');
|
||||
define('UI_FILETYPE_WEBSTREAM', 'webstream');
|
||||
define('UI_FILETYPE_ANY', 'all');
|
||||
define('UI_FILETYPE_PLAYLIST', 'playlist');
|
||||
define('UI_FILETYPE_AUDIOCLIP', 'audioClip');
|
||||
define('UI_FILETYPE_WEBSTREAM', 'webstream');
|
||||
|
||||
// Playlist elements
|
||||
define('UI_PL_ELEM_PLAYLIST', 'playlistElement');
|
||||
define('UI_PL_ELEM_FADEINFO', 'fadeInfo');
|
||||
define('UI_PL_ELEM_FADEIN', 'fadeIn');
|
||||
define('UI_PL_ELEM_FADEOUT', 'fadeOut');
|
||||
define('UI_PL_ELEM_PLAYLIST', 'playlistElement');
|
||||
define('UI_PL_ELEM_FADEINFO', 'fadeInfo');
|
||||
define('UI_PL_ELEM_FADEIN', 'fadeIn');
|
||||
define('UI_PL_ELEM_FADEOUT', 'fadeOut');
|
||||
|
||||
// Export/Import
|
||||
define('UI_BACKUPTOKEN_KEY', 'backupToken');
|
||||
define('UI_RESTORETOKEN_KEY', 'restoreToken');
|
||||
define('UI_BACKUPTOKEN_KEY', 'backupToken');
|
||||
define('UI_RESTORETOKEN_KEY', 'restoreToken');
|
||||
|
||||
//require_once('PEAR.php');
|
||||
require_once('../../../storageServer/var/conf.php');
|
||||
|
||||
// extent config
|
||||
$config = array_merge($config,
|
||||
$CC_CONFIG = array_merge($CC_CONFIG,
|
||||
array(
|
||||
'file_types' => array(
|
||||
'.mp3',
|
||||
|
@ -134,17 +135,17 @@ $config = array_merge($config,
|
|||
'audio/x-mpegurl'
|
||||
),
|
||||
'languages' => array(
|
||||
'ar_JO' => 'Arabic(JO)',
|
||||
'am_AM' => 'Armenian(AM)',
|
||||
'en_GB' => 'English (GB)',
|
||||
'en_US' => 'English (US)',
|
||||
'es_CO' => 'Español (CO)',
|
||||
'cz_CZ' => 'Česky (CZ)',
|
||||
'de_DE' => 'Deutsch (DE)',
|
||||
'hu_HU' => 'Magyar (HU)',
|
||||
'nl_NL' => 'Nederlands (NL)',
|
||||
'sr_CS' => 'Srpski (CS)',
|
||||
'ru_RU' => 'Russia(RU)'
|
||||
'ar_JO' => 'Arabic(JO)',
|
||||
'am_AM' => 'Armenian(AM)',
|
||||
'en_GB' => 'English (GB)',
|
||||
'en_US' => 'English (US)',
|
||||
'es_CO' => 'Español (CO)',
|
||||
'cz_CZ' => 'Česky (CZ)',
|
||||
'de_DE' => 'Deutsch (DE)',
|
||||
'hu_HU' => 'Magyar (HU)',
|
||||
'nl_NL' => 'Nederlands (NL)',
|
||||
'sr_CS' => 'Srpski (CS)',
|
||||
'ru_RU' => 'Russia(RU)'
|
||||
),
|
||||
)
|
||||
);
|
||||
|
@ -164,10 +165,16 @@ require_once(dirname(__FILE__).'/ui_subjects.class.php');
|
|||
require_once(dirname(__FILE__).'/ui_jscom.php');
|
||||
require_once(dirname(__FILE__).'/ui_exchange.class.php');
|
||||
|
||||
// well known classes
|
||||
require_once('DB.php');
|
||||
require_once('HTML/QuickForm.php');
|
||||
|
||||
// Connect to the database
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallBack');
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
ini_set('memory_limit', '64M');
|
||||
|
||||
## Warning/Error level
|
||||
// Warning/Error level
|
||||
define('UI_DEBUG', FALSE);
|
||||
define('UI_VERBOSE', FALSE);
|
||||
define('UI_WARNING', TRUE);
|
||||
|
@ -15,21 +15,21 @@ define('UI_VERSION', 'Campcaster 1.1.1');
|
|||
define('UI_VERSION_FULLNAME', 'Campcaster 1.1.1');
|
||||
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
|
||||
|
||||
## Scheduler
|
||||
// Scheduler
|
||||
define('UI_SCHEDULER_DAEMON_CMD', '/etc/init.d/campcaster-station start >/tmp/scheduler.log 2>&1 &'); ## adjust the start-command here
|
||||
define('UI_SCHEDULER_DAEMON_NAME', 'scheduler'); ## this is name of scheduler process to grep in process list for it
|
||||
|
||||
## Local settings
|
||||
// Local settings
|
||||
define('UI_DEFAULT_LANGID', 'en_GB');
|
||||
#define('UI_UPLOAD_LANGID', $_SESSION['langid']);
|
||||
//define('UI_UPLOAD_LANGID', $_SESSION['langid']);
|
||||
define('UI_UPLOAD_LANGID', UI_DEFAULT_LANGID);
|
||||
define('UI_TIMEZONEOFFSET', date('Z'));
|
||||
|
||||
## Basic scripts
|
||||
// Basic scripts
|
||||
define('UI_HANDLER', 'ui_handler.php');
|
||||
define('UI_BROWSER', 'ui_browser.php');
|
||||
|
||||
## HTML Form stuff
|
||||
// HTML Form stuff
|
||||
define('UI_STANDARD_FORM_METHOD', 'POST');
|
||||
define('UI_INPUT_STANDARD_SIZE', 50);
|
||||
define('UI_INPUT_STANDARD_MAXLENGTH', 255);
|
||||
|
@ -41,13 +41,13 @@ define('UI_QFORM_REQUIREDNOTE', '../templates/sub/form_requirednote.tpl'
|
|||
define('UI_QFORM_ERROR', '../templates/sub/form_error.tpl');
|
||||
define('UI_REGEX_URL', '/^(ht|f)tps?:\/\/[^ ]+$/');
|
||||
|
||||
## DB ls_pref keys
|
||||
// DB ls_pref keys
|
||||
define('UI_PL_ACCESSTOKEN_KEY', 'playlistToken');
|
||||
define('UI_SCRATCHPAD_KEY', 'scratchpadContents');
|
||||
define('UI_SCRATCHPAD_MAXLENGTH_KEY', 'scratchpadMaxlength');
|
||||
#define('UI_SCRATCHPAD_REGEX', '/^[0-9a-f]{16}:[0-9]{4}-[0-9]{2}-[0-9]{2}$/');
|
||||
//define('UI_SCRATCHPAD_REGEX', '/^[0-9a-f]{16}:[0-9]{4}-[0-9]{2}-[0-9]{2}$/');
|
||||
|
||||
## Session Keys
|
||||
// Session Keys
|
||||
define('UI_SCRATCHPAD_SESSNAME', 'SCRATCHPAD');
|
||||
define('UI_STATIONINFO_SESSNAME', 'STATIONINFO');
|
||||
define('UI_BROWSE_SESSNAME', 'L_BROWSE');
|
||||
|
@ -59,7 +59,7 @@ define('UI_PLAYLIST_SESSNAME', 'PLAYLIST');
|
|||
define('UI_LOCALIZER_SESSNAME', 'LOCALIZER');
|
||||
define('UI_CALENDAR_SESSNAME', 'CALENDAR');
|
||||
|
||||
## Metadata Keys
|
||||
// Metadata Keys
|
||||
define('UI_MDATA_KEY_TITLE', 'dc:title');
|
||||
define('UI_MDATA_KEY_CREATOR', 'dc:creator');
|
||||
define('UI_MDATA_KEY_DURATION', 'dcterms:extent');
|
||||
|
@ -73,7 +73,7 @@ define('UI_MDATA_KEY_ENCODER', 'ls:encoder');
|
|||
define('UI_MDATA_VALUE_FORMAT_FILE', 'File');
|
||||
define('UI_MDATA_VALUE_FORMAT_STREAM', 'live stream');
|
||||
|
||||
## Search/Browse preferences
|
||||
// Search/Browse preferences
|
||||
define('UI_SIMPLESEARCH_FILETYPE', 'File');
|
||||
define('UI_SIMPLESEARCH_OPERATOR', 'OR');
|
||||
define('UI_SIMPLESEARCH_LIMIT', 10);
|
||||
|
@ -97,33 +97,32 @@ define('UI_BROWSE_DEFAULT_LIMIT', 10);
|
|||
|
||||
define('UI_HUB_POLLING_FREQUENCY', 3);
|
||||
|
||||
## Scheduler / Calendar
|
||||
// Scheduler / Calendar
|
||||
define('UI_SCHEDULER_FIRSTWEEKDAY', 1);
|
||||
define('UI_SCHEDULER_DEFAULT_VIEW', 'day');
|
||||
define('UI_SCHEDULER_PAUSE_PL2PL', '0 seconds');
|
||||
define('UI_SCHEDULER_IMPORTTOKEN_KEY', 'schedulerImportToken');
|
||||
define('UI_SCHEDULER_EXPORTTOKEN_KEY', 'schedulerExportToken');
|
||||
|
||||
## File types
|
||||
// File types
|
||||
define('UI_FILETYPE_ANY', 'all');
|
||||
define('UI_FILETYPE_PLAYLIST', 'playlist');
|
||||
define('UI_FILETYPE_AUDIOCLIP', 'audioClip');
|
||||
define('UI_FILETYPE_WEBSTREAM', 'webstream');
|
||||
|
||||
## Playlist elements
|
||||
// Playlist elements
|
||||
define('UI_PL_ELEM_PLAYLIST', 'playlistElement');
|
||||
define('UI_PL_ELEM_FADEINFO', 'fadeInfo');
|
||||
define('UI_PL_ELEM_FADEIN', 'fadeIn');
|
||||
define('UI_PL_ELEM_FADEOUT', 'fadeOut');
|
||||
|
||||
## Export/Import
|
||||
// Export/Import
|
||||
define('UI_BACKUPTOKEN_KEY', 'backupToken');
|
||||
define('UI_RESTORETOKEN_KEY', 'restoreToken');
|
||||
|
||||
## LS stuff
|
||||
require_once 'storage_server/var/conf.php';
|
||||
## extent config
|
||||
$config = array_merge($config,
|
||||
require_once('storage_server/var/conf.php');
|
||||
// extent config
|
||||
$CC_CONFIG = array_merge($CC_CONFIG,
|
||||
array(
|
||||
'file_types' => array(
|
||||
'.mp3',
|
||||
|
@ -166,12 +165,11 @@ require_once dirname(__FILE__).'/ui_subjects.class.php';
|
|||
require_once dirname(__FILE__).'/ui_jscom.php';
|
||||
require_once dirname(__FILE__).'/ui_exchange.class.php';
|
||||
|
||||
## well known classes
|
||||
require_once 'DB.php';
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once('DB.php');
|
||||
require_once('HTML/QuickForm.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallBack');
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallBack');
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT);
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_PRINT);
|
||||
?>
|
|
@ -24,12 +24,10 @@ class uiHandler extends uiBase {
|
|||
* Initialize a new Browser Class
|
||||
* Call uiBase constructor
|
||||
*
|
||||
* @param array $config
|
||||
* configurartion data
|
||||
*/
|
||||
public function __construct($config)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($config);
|
||||
parent::__construct();
|
||||
} // constructor
|
||||
|
||||
|
||||
|
@ -40,7 +38,8 @@ class uiHandler extends uiBase {
|
|||
*/
|
||||
function login($formdata, $mask)
|
||||
{
|
||||
#$this->_cleanArray($_SESSION);
|
||||
global $CC_CONFIG;
|
||||
//$this->_cleanArray($_SESSION);
|
||||
|
||||
if (!$this->_validateForm($formdata, $mask)) {
|
||||
$_SESSION['retransferFormData']['login'] = $formdata['login'];
|
||||
|
@ -50,7 +49,7 @@ class uiHandler extends uiBase {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
$sessid = $this->gb->login($formdata['login'], $formdata['pass']);
|
||||
$sessid = Alib::Login($formdata['login'], $formdata['pass']);
|
||||
|
||||
if (!$sessid || PEAR::isError($sessid)){
|
||||
$this->_retMsg('Login failed.');
|
||||
|
@ -61,11 +60,11 @@ class uiHandler extends uiBase {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
#setcookie($this->config['authCookieName'], $sessid);
|
||||
echo "<meta http-equiv='set-cookie' content='".$this->config['authCookieName']."=".$sessid.";'>";
|
||||
#setcookie($CC_CONFIG['authCookieName'], $sessid);
|
||||
echo "<meta http-equiv='set-cookie' content='".$CC_CONFIG['authCookieName']."=".$sessid.";'>";
|
||||
ob_flush();
|
||||
|
||||
$id = $this->gb->getObjId($formdata['login'], $this->gb->storId);
|
||||
$id = M2tree::GetObjId($formdata['login'], $this->gb->storId);
|
||||
|
||||
if (PEAR::isError($id)) {
|
||||
$this->_retMsg('Access to home directory failed.');
|
||||
|
@ -90,9 +89,10 @@ class uiHandler extends uiBase {
|
|||
*/
|
||||
function logout($trigger_login = FALSE)
|
||||
{
|
||||
$this->gb->logout($this->sessid);
|
||||
#setcookie($this->config['authCookieName'], '');
|
||||
echo "<meta http-equiv='set-cookie' content='".$this->config['authCookieName']."=;'>";
|
||||
global $CC_CONFIG;
|
||||
Alib::Logout($this->sessid);
|
||||
//setcookie($CC_CONFIG['authCookieName'], '');
|
||||
echo "<meta http-equiv='set-cookie' content='".$CC_CONFIG['authCookieName']."=;'>";
|
||||
ob_clean();
|
||||
session_destroy();
|
||||
|
||||
|
@ -113,6 +113,7 @@ class uiHandler extends uiBase {
|
|||
*/
|
||||
function uploadFile($formdata, $mask, $replace=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if ($this->test4audioType($formdata['mediafile']['name']) === FALSE) {
|
||||
if (UI_ERROR) {
|
||||
$this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']);
|
||||
|
@ -124,7 +125,7 @@ class uiHandler extends uiBase {
|
|||
$id = $formdata['id'];
|
||||
$folderId = $formdata['folderId'];
|
||||
|
||||
if ($this->gb->getFileType($folderId) != 'Folder') {
|
||||
if (Greenbox::getFileType($folderId) != 'Folder') {
|
||||
$this->_retMsg('The target is not a folder.');
|
||||
$this->redirUrl = UI_BROWSER."?act=fileList";
|
||||
return FALSE;
|
||||
|
@ -143,11 +144,11 @@ class uiHandler extends uiBase {
|
|||
}
|
||||
|
||||
$tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.campcaster");
|
||||
$ntmp = $this->gb->bufferDir.'/'.$tmpgunid;
|
||||
$ntmp = $CC_CONFIG['bufferDir'].'/'.$tmpgunid;
|
||||
move_uploaded_file($formdata['mediafile']['tmp_name'], $ntmp);
|
||||
chmod($ntmp, 0664);
|
||||
|
||||
// echo "buffer dir: ".$this->gb->bufferDir."<BR>";
|
||||
// echo "buffer dir: ".$CC_CONFIG['bufferDir']."<BR>";
|
||||
// echo "$ntmp <br>";
|
||||
// print_r($formdata);
|
||||
// exit;
|
||||
|
@ -179,7 +180,8 @@ class uiHandler extends uiBase {
|
|||
|
||||
function test4audioType($filename)
|
||||
{
|
||||
foreach ($this->config['file_types'] as $t) {
|
||||
global $CC_CONFIG;
|
||||
foreach ($CC_CONFIG['file_types'] as $t) {
|
||||
if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -244,7 +246,7 @@ class uiHandler extends uiBase {
|
|||
$id = $formdata['id'];
|
||||
$folderId = $formdata['folderId'];
|
||||
|
||||
if ($this->gb->getFileType($folderId) != 'Folder') {
|
||||
if (Greenbox::getFileType($folderId) != 'Folder') {
|
||||
$this->_retMsg ('The target is not a folder.');
|
||||
$this->redirUrl = UI_BROWSER."?act=fileList";
|
||||
return FALSE;
|
||||
|
@ -430,7 +432,7 @@ class uiHandler extends uiBase {
|
|||
$this->redirUrl = UI_BROWSER."?popup[]=_reload_parent&popup[]=_close";
|
||||
|
||||
/* no folder support yet
|
||||
if (!($delOverride==$id) && (count($this->gb->getObjType($id)=='Folder'?
|
||||
if (!($delOverride==$id) && (count(BasicStor::GetObjType($id)=='Folder'?
|
||||
$this->gb->listFolder($id, $this->sessid):NULL))) {
|
||||
$this->_retMsg("Folder is not empty. You can override this protection by clicking DEL again");
|
||||
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid."&delOverride=$id";
|
||||
|
@ -445,7 +447,7 @@ class uiHandler extends uiBase {
|
|||
}
|
||||
|
||||
foreach ($ids as $id) {
|
||||
if ($this->gb->getFileType($id) == 'playlist') {
|
||||
if (Greenbox::getFileType($id) == 'playlist') {
|
||||
$r = $this->gb->deletePlaylist($id, $this->sessid);
|
||||
} else {
|
||||
$r = $this->gb->deleteFile($id, $this->sessid);
|
||||
|
|
|
@ -7,7 +7,7 @@ require_once(dirname(__FILE__).'/ui_conf.php');
|
|||
require_once(dirname(__FILE__).'/ui_handler.class.php');
|
||||
|
||||
## initialize objects ###############################################
|
||||
$uiHandler = new uiHandler($config);
|
||||
$uiHandler = new uiHandler($CC_CONFIG);
|
||||
$uiHandler->init();
|
||||
$uiBase =& $uiHandler;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class uiHubBrowse extends uiBrowse
|
|||
$this->results['cnt'] = $results['cnt'];
|
||||
foreach ($results['results'] as $rec) {
|
||||
// TODO: maybe this getMetaInfo is not correct for the remote results
|
||||
$this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($rec));
|
||||
$this->results['items'][] = $this->Base->getMetaInfo(BasicStor::IdFromGunid($rec));
|
||||
}
|
||||
$this->pagination($results);
|
||||
return is_array($results);
|
||||
|
|
|
@ -90,7 +90,7 @@ class uiHubSearch extends uiSearch {
|
|||
return FALSE;
|
||||
}
|
||||
foreach ($results['results'] as $rec) {
|
||||
$tmpId = $this->Base->gb->idFromGunid($rec["gunid"]);
|
||||
$tmpId = BasicStor::IdFromGunid($rec["gunid"]);
|
||||
$this->results['items'][] = $this->Base->getMetaInfo($tmpId);
|
||||
}
|
||||
$this->results['cnt'] = $results['cnt'];
|
||||
|
@ -117,7 +117,7 @@ class uiHubSearch extends uiSearch {
|
|||
foreach ($results['results'] as $rec) {
|
||||
// TODO: maybe this getMetaInfo is not correct for the remote results
|
||||
// yes, right :)
|
||||
// $this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($rec));
|
||||
// $this->results['items'][] = $this->Base->getMetaInfo(BasicStor::IdFromGunid($rec));
|
||||
$this->results['items'][] = $rec;
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -99,7 +99,7 @@ class uiPlaylist
|
|||
}
|
||||
if (($userid = $this->Base->gb->playlistIsAvailable($plid, $this->Base->sessid)) !== TRUE) {
|
||||
if (UI_WARNING) {
|
||||
$this->Base->_retMsg('Playlist has been locked by "$1".', $this->Base->gb->getSubjName($userid));
|
||||
$this->Base->_retMsg('Playlist has been locked by "$1".', Subjects::GetSubjName($userid));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ class uiPlaylist
|
|||
return FALSE;
|
||||
}
|
||||
if ($msg && UI_VERBOSE) {
|
||||
$this->Base->_retMsg('Playlist "$1" released.', $this->Base->getMetadataValue($this->Base->gb->idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
|
||||
$this->Base->_retMsg('Playlist "$1" released.', $this->Base->getMetadataValue(BasicStor::IdFromGunid($plgunid), UI_MDATA_KEY_TITLE));
|
||||
}
|
||||
$this->activeId = NULL;
|
||||
$this->token = NULL;
|
||||
|
@ -189,13 +189,13 @@ class uiPlaylist
|
|||
return FALSE;
|
||||
}
|
||||
if (UI_VERBOSE) {
|
||||
$this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->getMetadataValue($this->Base->gb->idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
|
||||
$this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->getMetadataValue(BasicStor::IdFromGunid($plgunid), UI_MDATA_KEY_TITLE));
|
||||
}
|
||||
$this->activeId = NULL;
|
||||
$this->token = NULL;
|
||||
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
|
||||
|
||||
if ($this->activate($this->Base->gb->idFromGunid($plgunid), FALSE) !== TRUE) {
|
||||
if ($this->activate(BasicStor::IdFromGunid($plgunid), FALSE) !== TRUE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ class uiPlaylist
|
|||
if ($sub['elementname']===UI_FILETYPE_AUDIOCLIP || $sub['elementname']===UI_FILETYPE_PLAYLIST) {
|
||||
#$this->flat["$parent.$node"] = $sub['attrs'];
|
||||
#$this->flat["$parent.$node"]['type'] = $sub['elementname'];
|
||||
$this->flat[$parent] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($sub['attrs']['id']));
|
||||
$this->flat[$parent] = $this->Base->getMetaInfo(BasicStor::IdFromGunid($sub['attrs']['id']));
|
||||
$this->flat[$parent]['attrs'] = $attrs;
|
||||
$this->flat[$parent]['playlength'] = $sub['attrs']['playlength'];
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ class uiPlaylist
|
|||
|
||||
public function isAvailable($id)
|
||||
{
|
||||
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
|
||||
if (Greenbox::getFileType($id) !== UI_FILETYPE_PLAYLIST) {
|
||||
return TRUE;
|
||||
}
|
||||
if ($this->Base->gb->playlistIsAvailable($id, $this->Base->sessid) === TRUE) {
|
||||
|
@ -698,11 +698,11 @@ class uiPlaylist
|
|||
|
||||
function isUsedBy($id)
|
||||
{
|
||||
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
|
||||
if (Greenbox::getFileType($id) !== UI_FILETYPE_PLAYLIST) {
|
||||
return FALSE;
|
||||
}
|
||||
if (($userid = $this->Base->gb->playlistIsAvailable($id, $this->Base->sessid)) !== TRUE) {
|
||||
return $this->Base->gb->getSubjName($userid);
|
||||
return Subjects::GetSubjName($userid);
|
||||
}
|
||||
return FALSE;
|
||||
} // fn isUsedBy
|
||||
|
|
|
@ -311,7 +311,7 @@ class uiScheduler extends uiCalendar {
|
|||
|
||||
$items = array();
|
||||
foreach ($arr as $key => $val) {
|
||||
$id = $this->Base->gb->idFromGunid($val['playlistId']);
|
||||
$id = BasicStor::IdFromGunid($val['playlistId']);
|
||||
$startDay = strftime('%d', uiScheduler::datetimeToTimestamp($val['start']));
|
||||
$startHour = number_format(strftime('%H', uiScheduler::datetimeToTimestamp($val['start'])));
|
||||
$items[$startDay][$startHour][]= array (
|
||||
|
@ -357,7 +357,7 @@ class uiScheduler extends uiCalendar {
|
|||
$h = number_format(strftime('%H', $start));
|
||||
$M = number_format(strftime('%i', $start));
|
||||
|
||||
$id = $this->Base->gb->idFromGunid($val['playlistId']);
|
||||
$id = BasicStor::IdFromGunid($val['playlistId']);
|
||||
|
||||
$startHour = (int)strftime('%H', $start);
|
||||
$endHour = (int)strftime('%H', $end);
|
||||
|
@ -404,7 +404,7 @@ class uiScheduler extends uiCalendar {
|
|||
// this section.
|
||||
$skip = false;
|
||||
if (strftime('%Y%m%d', $start) === $thisDay) {
|
||||
// For the edge case of starting at the end of
|
||||
// For the edge case of starting at the end of
|
||||
// today.
|
||||
if ($startHour == 23) {
|
||||
$skip = true;
|
||||
|
@ -451,8 +451,8 @@ class uiScheduler extends uiCalendar {
|
|||
$items[date('H', uiScheduler::datetimeToTimestamp($val['start']))][]= array (
|
||||
'start' => substr($val['start'], strpos($val['start'], 'T')+1),
|
||||
'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
|
||||
'title' => $this->Base->getMetadataValue($this->Base->gb->idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
|
||||
'creator' => $this->Base->getMetadataValue($this->Base->gb->idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
|
||||
'title' => $this->Base->getMetadataValue(BasicStor::IdFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
|
||||
'creator' => $this->Base->getMetadataValue(BasicStor::IdFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
|
||||
);
|
||||
}
|
||||
#print_r($items);
|
||||
|
@ -471,7 +471,7 @@ class uiScheduler extends uiCalendar {
|
|||
}
|
||||
|
||||
foreach ($arr as $key => $val) {
|
||||
$id = $this->Base->gb->idFromGunid($val['playlistId']);
|
||||
$id = BasicStor::IdFromGunid($val['playlistId']);
|
||||
$arr[$key]['title'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE);
|
||||
$arr[$key]['creator'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR);
|
||||
$arr[$key]['pos'] = uiScheduler::datetimeToTimestamp($val['start']);
|
||||
|
@ -551,7 +551,7 @@ class uiScheduler extends uiCalendar {
|
|||
if ($id) {
|
||||
$this->Base->SCRATCHPAD->addItem($id);
|
||||
$this->availablePlaylists[] = array(
|
||||
'gunid' => $this->Base->gb->gunidFromId($id),
|
||||
'gunid' => BasicStor::GunidFromId($id),
|
||||
'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE),
|
||||
'duration' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION),
|
||||
);
|
||||
|
@ -588,7 +588,7 @@ class uiScheduler extends uiCalendar {
|
|||
|
||||
/**
|
||||
* Get the currently playing clip or one that is coming up.
|
||||
*
|
||||
*
|
||||
* Note: just use methods here which work without valid authentification.
|
||||
*
|
||||
* @param int $distance
|
||||
|
@ -905,7 +905,7 @@ class uiScheduler extends uiCalendar {
|
|||
|
||||
if (empty($output)) {
|
||||
$this->scriptError = 'Scheduler startup script does not appear to be valid. Please check the value you have set in "Preferences->System Settings".';
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
$message = "";
|
||||
foreach ($output as $line) {
|
||||
|
@ -933,7 +933,7 @@ class uiScheduler extends uiCalendar {
|
|||
function initXmlRpc()
|
||||
{
|
||||
include_once(dirname(__FILE__).'/ui_schedulerPhpClient.class.php');
|
||||
$this->spc =& SchedulerPhpClient::factory($this->Base->dbc, $mdefs, $this->Base->config, FALSE, FALSE);
|
||||
$this->spc =& SchedulerPhpClient::factory($mdefs, FALSE, FALSE);
|
||||
} // fn initXmlRpc
|
||||
|
||||
|
||||
|
|
|
@ -170,24 +170,12 @@ $mdefs = array(
|
|||
* @link http://www.campware.org
|
||||
*/
|
||||
class SchedulerPhpClient {
|
||||
/**
|
||||
* Databases object reference
|
||||
* @var DB
|
||||
*/
|
||||
private $dbc = NULL;
|
||||
|
||||
/**
|
||||
* Array with methods description
|
||||
* @var array
|
||||
*/
|
||||
private $mdefs = array();
|
||||
|
||||
/**
|
||||
* Confiduration array from ../conf.php
|
||||
* @var array
|
||||
*/
|
||||
private $config = array();
|
||||
|
||||
/**
|
||||
* XMLRPC client object reference
|
||||
* @var XMLRPC_Client
|
||||
|
@ -209,26 +197,22 @@ class SchedulerPhpClient {
|
|||
/**
|
||||
* Constructor - please DON'T CALL IT, use factory method instead
|
||||
*
|
||||
* @param DB $dbc
|
||||
* @param array $mdefs
|
||||
* hash array with methods description
|
||||
* @param array $config
|
||||
* hash array with configuration
|
||||
* @param int $debug
|
||||
* XMLRPC debug flag
|
||||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
*/
|
||||
public function __construct(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
|
||||
public function __construct($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
$this->dbc = $dbc;
|
||||
global $CC_CONFIG;
|
||||
$this->mdefs = $mdefs;
|
||||
$this->config = $config;
|
||||
$this->debug = $debug;
|
||||
$this->verbose = $verbose;
|
||||
$confPrefix = "scheduler";
|
||||
$serverPath = "http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
|
||||
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
|
||||
$serverPath = "http://{$CC_CONFIG["{$confPrefix}UrlHost"]}:{$CC_CONFIG["{$confPrefix}UrlPort"]}".
|
||||
"{$CC_CONFIG["{$confPrefix}UrlPath"]}/{$CC_CONFIG["{$confPrefix}XMLRPC"]}";
|
||||
if ($this->verbose) {
|
||||
echo "serverPath: $serverPath\n";
|
||||
}
|
||||
|
@ -250,19 +234,17 @@ class SchedulerPhpClient {
|
|||
*
|
||||
* @todo Replace this method by using PHP5 __call method instead.
|
||||
*
|
||||
* @param DB $dbc
|
||||
* @param array $mdefs
|
||||
* hash array with methods description
|
||||
* @param array $config
|
||||
* hash array with configuration
|
||||
* @param int $debug
|
||||
* XMLRPC debug flag
|
||||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
* @return object, created object instance
|
||||
*/
|
||||
public function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
|
||||
public function &factory($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$f = '';
|
||||
foreach ($mdefs as $fn => $farr) {
|
||||
$f .=
|
||||
|
@ -276,10 +258,9 @@ class SchedulerPhpClient {
|
|||
"$f\n".
|
||||
"}\n";
|
||||
if (FALSE === eval($e)) {
|
||||
return $dbc->raiseError("Eval failed");
|
||||
return $CC_DBC->raiseError("Eval failed");
|
||||
}
|
||||
$spc = new SchedulerPhpClientCore(
|
||||
$dbc, $mdefs, $config, $debug, $verbose);
|
||||
$spc = new SchedulerPhpClientCore($mdefs, $debug, $verbose);
|
||||
return $spc;
|
||||
} // fn factory
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class uiScratchPad
|
|||
$arr = array_slice($arr, 0, $maxLength);
|
||||
foreach ($arr as $gunid) {
|
||||
if (preg_match('/[0-9]{1,20}/', $gunid)) {
|
||||
$id = $this->Base->gb->idFromGunid($this->Base->toHex($gunid));
|
||||
$id = BasicStor::IdFromGunid($this->Base->toHex($gunid));
|
||||
if ($id != FALSE) {
|
||||
if ($i = $this->Base->getMetaInfo($id)) {
|
||||
$this->items[] = $i;
|
||||
|
|
|
@ -67,17 +67,17 @@ class uiSubjects
|
|||
*/
|
||||
function addSubj($request)
|
||||
{
|
||||
include dirname(__FILE__). '/formmask/subjects.inc.php';
|
||||
include(dirname(__FILE__). '/formmask/subjects.inc.php');
|
||||
$this->setRedir();
|
||||
|
||||
if ($this->Base->_validateForm($request, $mask[$request['passwd'] ? 'addUser' : 'addGroup']) !== TRUE) {
|
||||
return FALSE;
|
||||
}
|
||||
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') !== TRUE) {
|
||||
if (Alib::CheckPerm($this->Base->userid, 'subjects') !== TRUE) {
|
||||
$this->Base->_retMsg('Access denied.');
|
||||
return FALSE;
|
||||
}
|
||||
if ($this->Base->gb->getSubjId($request['login'])) {
|
||||
if (Subjects::GetSubjId($request['login'])) {
|
||||
$this->Base->_retMsg('User or group "$1" already exists.', $request['login']);
|
||||
$this->Base->redirUrl = $_SERVER['HTTP_REFERER'];
|
||||
return FALSE;
|
||||
|
@ -111,7 +111,7 @@ class uiSubjects
|
|||
{
|
||||
$this->setReload();
|
||||
|
||||
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') !== TRUE) {
|
||||
if (Alib::CheckPerm($this->Base->userid, 'subjects') !== TRUE) {
|
||||
$this->Base->_retMsg('Access denied.');
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class uiSubjects
|
|||
include(dirname(__FILE__). '/formmask/subjects.inc.php');
|
||||
|
||||
$form = new HTML_QuickForm('chgPasswd', UI_STANDARD_FORM_METHOD, UI_HANDLER);
|
||||
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') === TRUE) {
|
||||
if (Alib::CheckPerm($this->Base->userid, 'subjects') === TRUE) {
|
||||
$mask['chgPasswd']['cancel']['attributes'] = array('onClick' => 'location.href="'.UI_BROWSER.'?act=SUBJECTS"');
|
||||
unset ($mask['chgPasswd']['oldpasswd']);
|
||||
} else {
|
||||
|
@ -168,7 +168,7 @@ class uiSubjects
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects')) {
|
||||
if (Alib::CheckPerm($this->Base->userid, 'subjects')) {
|
||||
$this->setSuRedir();
|
||||
} else {
|
||||
$this->setRedir();
|
||||
|
@ -177,7 +177,7 @@ class uiSubjects
|
|||
$this->Base->_retMsg('Access denied.');
|
||||
return FALSE;
|
||||
}
|
||||
if ($this->Base->gb->authenticate($request['login'], $request['oldpasswd']) === FALSE) {
|
||||
if (Subjects::Authenticate($request['login'], $request['oldpasswd']) === FALSE) {
|
||||
$this->Base->_retMsg('Old password was incorrect.');
|
||||
$this->Base->redirUrl = $_SERVER['HTTP_REFERER'];
|
||||
return FASLE;
|
||||
|
@ -206,7 +206,7 @@ class uiSubjects
|
|||
*/
|
||||
function getSubjectsWCnt()
|
||||
{
|
||||
return $this->Base->gb->getSubjectsWCnt();
|
||||
return Subjects::GetSubjectsWCnt();
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,7 +220,7 @@ class uiSubjects
|
|||
*/
|
||||
function getGroupMember($id)
|
||||
{
|
||||
return $this->Base->gb->listGroup($id);
|
||||
return Subjects::ListGroup($id);
|
||||
} // fn getGroupMember
|
||||
|
||||
|
||||
|
@ -233,11 +233,11 @@ class uiSubjects
|
|||
*/
|
||||
function getNonGroupMember($id)
|
||||
{
|
||||
foreach ($this->Base->gb->listGroup($id) as $val1) {
|
||||
foreach (Subjects::ListGroup($id) as $val1) {
|
||||
$members[$val1['id']] = TRUE;
|
||||
}
|
||||
|
||||
$all = $this->Base->gb->getSubjectsWCnt();
|
||||
$all = Subjects::GetSubjectsWCnt();
|
||||
foreach ($all as $key2=>$val2) {
|
||||
if ($members[$val2['id']]) {
|
||||
unset($all[$key2]);
|
||||
|
@ -268,17 +268,17 @@ class uiSubjects
|
|||
// loop for multiple action
|
||||
if (is_array($request['id'])) {
|
||||
foreach ($request['id'] as $val) {
|
||||
$req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']);
|
||||
$req = array('login' => Subjects::GetSubjName($val), 'gname' => $request['gname']);
|
||||
$this->addSubj2Gr($req);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') !== TRUE){
|
||||
if (Alib::CheckPerm($this->Base->userid, 'subjects') !== TRUE){
|
||||
$this->Base->_retMsg('Access denied.');
|
||||
return FALSE;
|
||||
}
|
||||
if (PEAR::isError($res = $this->Base->gb->addSubj2Gr($request['login'], $request['gname']))) {
|
||||
if (PEAR::isError($res = Subjects::AddSubjectToGroup($request['login'], $request['gname']))) {
|
||||
$this->Base->_retMsg($res->getMessage());
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -306,17 +306,17 @@ class uiSubjects
|
|||
// loop for multiple action
|
||||
if (is_array($request['id'])) {
|
||||
foreach ($request['id'] as $val) {
|
||||
$req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']);
|
||||
$req = array('login' => Subjects::GetSubjName($val), 'gname' => $request['gname']);
|
||||
$this->removeSubjFromGr($req);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') !== TRUE){
|
||||
if (Alib::CheckPerm($this->Base->userid, 'subjects') !== TRUE){
|
||||
$this->Base->_retMsg('Access denied.');
|
||||
return FALSE;
|
||||
}
|
||||
if (PEAR::isError($res = $this->Base->gb->removeSubjFromGr($request['login'], $request['gname']))) {
|
||||
if (PEAR::isError($res = Subjects::RemoveSubjectFromGroup($request['login'], $request['gname']))) {
|
||||
$this->Base->_retMsg($res->getMessage());
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ class uiSubjects
|
|||
*/
|
||||
function isMemberOf($groupname)
|
||||
{
|
||||
if ($gid = $this->Base->gb->getSubjId($groupname)) {
|
||||
if ($gid = Subjects::GetSubjId($groupname)) {
|
||||
$members = $this->getGroupMember($gid);
|
||||
if (is_array($members)) {
|
||||
foreach($members as $member) {
|
||||
|
|
|
@ -155,8 +155,8 @@ class uiTransfers
|
|||
|
||||
function upload2Hub($id)
|
||||
{
|
||||
$gunid = $this->Base->gb->gunidFromId($id);
|
||||
$type = $this->Base->gb->_getType($gunid);
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$type = BasicStor::GetType($gunid);
|
||||
|
||||
switch ($type) {
|
||||
case 'audioClip':
|
||||
|
|
|
@ -15,9 +15,9 @@ require_once("$storageServerPath/var/BasicStor.php");
|
|||
require_once("$storageServerPath/var/Prefs.php");
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$bs = new BasicStor($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$bs = new BasicStor();
|
||||
|
||||
$stid = $bs->storId;
|
||||
#var_dump($stid); exit;
|
||||
|
@ -25,17 +25,17 @@ $stid = $bs->storId;
|
|||
|
||||
function admDumpFolder(&$bs, $fid, $ind='')
|
||||
{
|
||||
$name = $bs->getObjName($fid);
|
||||
$name = M2tree::GetObjName($fid);
|
||||
if (PEAR::isError($name)) {
|
||||
echo $name->getMessage();
|
||||
exit;
|
||||
}
|
||||
$type = $bs->getObjType($fid);
|
||||
$type = BasicStor::GetObjType($fid);
|
||||
if (PEAR::isError($type)) {
|
||||
echo $type->getMessage();
|
||||
exit;
|
||||
}
|
||||
$gunid = $bs->gunidFromId($fid);
|
||||
$gunid = BasicStor::GunidFromId($fid);
|
||||
if (PEAR::isError($gunid)) {
|
||||
echo $gunid->getMessage();
|
||||
exit;
|
||||
|
@ -100,12 +100,12 @@ function admDumpFolder(&$bs, $fid, $ind='')
|
|||
}
|
||||
function admDumpGroup(&$bs, $gid, $ind='')
|
||||
{
|
||||
$name = $bs->getSubjName($gid);
|
||||
$name = Subjects::GetSubjName($gid);
|
||||
if (PEAR::isError($name)) {
|
||||
echo $name->getMessage();
|
||||
exit;
|
||||
}
|
||||
$isGr = $bs->isGroup($gid);
|
||||
$isGr = Subjects::IsGroup($gid);
|
||||
if (PEAR::isError($isGr)) {
|
||||
echo $isGr->getMessage();
|
||||
exit;
|
||||
|
@ -119,7 +119,7 @@ function admDumpGroup(&$bs, $gid, $ind='')
|
|||
'attributes'=> $pars,
|
||||
));
|
||||
}
|
||||
$garr = $bs->listGroup($gid);
|
||||
$garr = Subjects::ListGroup($gid);
|
||||
if (PEAR::isError($garr)) {
|
||||
echo $garr->getMessage();
|
||||
exit;
|
||||
|
@ -156,7 +156,7 @@ function admDumpGroup(&$bs, $gid, $ind='')
|
|||
function admDumpSubjects(&$bs, $ind='')
|
||||
{
|
||||
$res ='';
|
||||
$subjs = $bs->getSubjects('id, login, pass, type');
|
||||
$subjs = Subjects::GetSubjects('id, login, pass, type');
|
||||
foreach ($subjs as $i => $member) {
|
||||
switch ($member['type']) {
|
||||
case "U":
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?
|
||||
require_once 'conf.php';
|
||||
require_once "$storageServerPath/var/conf.php";
|
||||
header("Conten-type: text/plain");
|
||||
$dbname = $config['dsn']['database'];
|
||||
$dbuser = $config['dsn']['username'];
|
||||
$dbhost = $config['dsn']['hostspec'];
|
||||
$res = `pg_dump -s $dbname -U $dbuser`;
|
||||
echo "$res\n";
|
||||
require_once('conf.php');
|
||||
require_once("$storageServerPath/var/conf.php");
|
||||
header("Conten-type: text/plain");
|
||||
$dbname = $CC_CONFIG['dsn']['database'];
|
||||
$dbuser = $CC_CONFIG['dsn']['username'];
|
||||
$dbhost = $CC_CONFIG['dsn']['hostspec'];
|
||||
$res = `pg_dump -s $dbname -U $dbuser`;
|
||||
echo "$res\n";
|
||||
?>
|
|
@ -4,8 +4,8 @@
|
|||
* @version $Revision$
|
||||
*/
|
||||
header("Content-type: text/plain");
|
||||
require_once 'conf.php';
|
||||
require_once "$storageServerPath/var/conf.php";
|
||||
require_once('conf.php');
|
||||
require_once("$storageServerPath/var/conf.php");
|
||||
|
||||
echo "{$config['storageDir']}\n";
|
||||
echo $CC_CONFIG['storageDir']."\n";
|
||||
?>
|
|
@ -18,13 +18,13 @@ require_once("$storageServerPath/var/GreenBox.php");
|
|||
//PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
//PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n");
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
echo "ERROR: ".$dbc->getMessage()." ".$dbc->getUserInfo()."\n";
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
$testonly = (isset($argv[1]) && $argv[1] == '-t');
|
||||
|
||||
|
@ -51,7 +51,7 @@ function import_err($p_pearErrorObj, $txt='')
|
|||
}
|
||||
|
||||
|
||||
$r = $gb->getObjId('import', $gb->storId);
|
||||
$r = M2tree::GetObjId('import', $gb->storId);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
|
|
|
@ -82,9 +82,9 @@ function ls_restore_restoreObject($obj, $parid, $reallyInsert=TRUE){
|
|||
/* =============================================================== processing */
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$bs = new BasicStor($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$bs = new BasicStor();
|
||||
$pr = new Prefs($bs);
|
||||
|
||||
$dbxml = file_get_contents($argv[1]);
|
||||
|
@ -101,42 +101,42 @@ $xmlTree = $parser->getTree();
|
|||
|
||||
|
||||
/* ----------------------------------------- processing storageServer element */
|
||||
$subjArr = FALSE;
|
||||
$tree = FALSE;
|
||||
foreach($xmlTree->children as $i=>$el){
|
||||
switch($el->name){
|
||||
case"subjects":
|
||||
if($subjArr !== FALSE){
|
||||
echo"ERROR: unexpected subjects element\n";
|
||||
$subjArr = FALSE;
|
||||
$tree = FALSE;
|
||||
foreach ($xmlTree->children as $i => $el) {
|
||||
switch ($el->name) {
|
||||
case "subjects":
|
||||
if ($subjArr !== FALSE) {
|
||||
echo "ERROR: unexpected subjects element\n";
|
||||
}
|
||||
$subjArr=$el->children;
|
||||
break;
|
||||
case"folder":
|
||||
if($tree !== FALSE){
|
||||
echo"ERROR: unexpected folder element\n";
|
||||
$subjArr = $el->children;
|
||||
break;
|
||||
case "folder":
|
||||
if ($tree !== FALSE) {
|
||||
echo "ERROR: unexpected folder element\n";
|
||||
}
|
||||
$tree = ls_restore_processObject($el);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
echo"ERROR: unknown element name {$el->name}\n";
|
||||
echo "ERROR: unknown element name {$el->name}\n";
|
||||
exit;
|
||||
}
|
||||
# echo "{$el->name}\n";
|
||||
// echo "{$el->name}\n";
|
||||
}
|
||||
|
||||
/* ---------------------------------------------- processing subjects element */
|
||||
$subjects = array();
|
||||
$groups = array();
|
||||
foreach($subjArr as $i=>$el){
|
||||
switch($el->name){
|
||||
case"group":
|
||||
$subjects = array();
|
||||
$groups = array();
|
||||
foreach ($subjArr as $i => $el) {
|
||||
switch ($el->name) {
|
||||
case "group":
|
||||
$grname = $el->attrs['name']->val;
|
||||
$groups[$grname] = $el->children;
|
||||
$subjects[$grname] = array(
|
||||
'type' => 'group',
|
||||
);
|
||||
break;
|
||||
case"user":
|
||||
break;
|
||||
case "user":
|
||||
$login = $el->attrs['login']->val;
|
||||
$subjects[$login] = array(
|
||||
'type' => 'user',
|
||||
|
@ -145,21 +145,21 @@ foreach($subjArr as $i=>$el){
|
|||
'realname' => '',
|
||||
'prefs' => (isset($el->children[0]) ? $el->children[0]->children : NULL),
|
||||
);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- processing groups */
|
||||
foreach($groups as $grname=>$group){
|
||||
foreach($group as $i=>$el){
|
||||
switch($el->name){
|
||||
case"member":
|
||||
foreach ($groups as $grname => $group) {
|
||||
foreach ($group as $i => $el) {
|
||||
switch ($el->name) {
|
||||
case "member":
|
||||
$groups[$grname][$i] = $el->attrs['name']->val;
|
||||
break;
|
||||
case"preferences":
|
||||
break;
|
||||
case "preferences":
|
||||
$subjects[$grname]['prefs'] = $el->children;
|
||||
unset($groups[$grname][$i]);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,54 +174,64 @@ foreach($groups as $grname=>$group){
|
|||
|
||||
/* ================================================================ restoring */
|
||||
|
||||
if(VERBOSE) echo " resetting storage ...\n";
|
||||
if (VERBOSE) {
|
||||
echo " resetting storage ...\n";
|
||||
}
|
||||
$bs->resetStorage(FALSE);
|
||||
$storId = $bs->storId;
|
||||
|
||||
/* ------------------------------------------------------- restoring subjects */
|
||||
foreach($subjects as $login=>$subj){
|
||||
$uid0 = $bs->getSubjId($login);
|
||||
foreach ($subjects as $login => $subj) {
|
||||
$uid0 = Subjects::GetSubjId($login);
|
||||
ls_restore_checkErr($uid0);
|
||||
switch($subj['type']){
|
||||
case"user":
|
||||
if($login=='root'){
|
||||
switch ($subj['type']) {
|
||||
case "user":
|
||||
if ($login=='root') {
|
||||
$r = $bs->passwd($login, NULL, $subj['pass'], TRUE);
|
||||
ls_restore_checkErr($r, __LINE__);
|
||||
$uid = $uid0;
|
||||
}else{
|
||||
if(!is_null($uid0)){
|
||||
} else {
|
||||
if (!is_null($uid0)) {
|
||||
$r = $bs->removeSubj($login);
|
||||
ls_restore_checkErr($r, __LINE__);
|
||||
}
|
||||
if(VERBOSE) echo " adding user $login ...\n";
|
||||
if (VERBOSE) {
|
||||
echo " adding user $login ...\n";
|
||||
}
|
||||
$uid = $bs->addSubj($login, $subj['pass'], $subj['realname'], TRUE);
|
||||
ls_restore_checkErr($uid, __LINE__);
|
||||
}
|
||||
break;
|
||||
case"group":
|
||||
if(!is_null($uid0)){
|
||||
break;
|
||||
case "group":
|
||||
if (!is_null($uid0)) {
|
||||
$r = $bs->removeSubj($login);
|
||||
if(PEAR::isError($r)){ $uid = $uid0; break; }
|
||||
if (PEAR::isError($r)) {
|
||||
$uid = $uid0;
|
||||
break;
|
||||
}
|
||||
//ls_restore_checkErr($r, __LINE__);
|
||||
}
|
||||
if(VERBOSE) echo " adding group $login ...\n";
|
||||
if (VERBOSE) {
|
||||
echo " adding group $login ...\n";
|
||||
}
|
||||
$uid = $bs->addSubj($login, NULL);
|
||||
ls_restore_checkErr($uid, __LINE__);
|
||||
# var_export($uid); echo " ";
|
||||
break;
|
||||
}
|
||||
# echo "$login/$uid :\n";
|
||||
if(isset($subj['prefs'])){
|
||||
# var_dump($subj['prefs']); exit;
|
||||
foreach($subj['prefs'] as $i=>$el){
|
||||
switch($el->name){
|
||||
case"pref":
|
||||
// var_export($uid); echo " ";
|
||||
break;
|
||||
} // switch
|
||||
|
||||
// echo "$login/$uid :\n";
|
||||
if (isset($subj['prefs'])) {
|
||||
// var_dump($subj['prefs']); exit;
|
||||
foreach ($subj['prefs'] as $i => $el) {
|
||||
switch ($el->name) {
|
||||
case "pref":
|
||||
$prefkey = $el->attrs['name']->val;
|
||||
$prefval = $el->attrs['val']->val;
|
||||
# echo" PREF($prefkey)=$prefval\n";
|
||||
// echo" PREF($prefkey)=$prefval\n";
|
||||
$res = $pr->insert($uid, $prefkey, $prefval);
|
||||
ls_restore_checkErr($res, __LINE__);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
var_dump($el);
|
||||
}
|
||||
|
@ -231,10 +241,12 @@ foreach($subjects as $login=>$subj){
|
|||
|
||||
/* --------------------------------------------------------- restoring groups */
|
||||
#var_dump($groups);
|
||||
foreach($groups as $grname=>$group){
|
||||
foreach($group as $i=>$login){
|
||||
if(VERBOSE) echo " adding subject $login to group $grname ...\n";
|
||||
$r = $bs->addSubj2Gr($login, $grname);
|
||||
foreach ($groups as $grname => $group) {
|
||||
foreach ($group as $i => $login) {
|
||||
if (VERBOSE) {
|
||||
echo " adding subject $login to group $grname ...\n";
|
||||
}
|
||||
$r = Subjects::AddSubjectToGroup($login, $grname);
|
||||
ls_restore_checkErr($r, __LINE__);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,19 +12,19 @@
|
|||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/../var/conf.php';
|
||||
require_once dirname(__FILE__).'/../var/GreenBox.php';
|
||||
require_once dirname(__FILE__).'/../var/Restore.php';
|
||||
include_once 'DB.php';
|
||||
require_once(dirname(__FILE__).'/../var/conf.php');
|
||||
require_once(dirname(__FILE__).'/../var/GreenBox.php');
|
||||
require_once(dirname(__FILE__).'/../var/Restore.php');
|
||||
include_once('DB.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (DB::isError($dbc)) {
|
||||
die($dbc->getMessage());
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (DB::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$gb = new GreenBox();
|
||||
$rs = new Restore($gb);
|
||||
|
||||
if ($rs->loglevel=='debug') {
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
* @link http://www.campware.org
|
||||
*/
|
||||
class AccessRecur {
|
||||
public $ls;
|
||||
public $sessid;
|
||||
|
||||
public function __construct(&$ls, $sessid)
|
||||
{
|
||||
$this->ls =& $ls;
|
||||
$this->dbc =& $ls->dbc;
|
||||
$this->sessid = $sessid;
|
||||
}
|
||||
|
||||
|
@ -53,20 +54,21 @@ class AccessRecur {
|
|||
|
||||
public static function releasePlaylist(&$ls, $sessid, $token)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ppa = new AccessRecur($ls, $sessid);
|
||||
$r = $ppa->dbc->getAll("
|
||||
$r = $CC_DBC->getAll("
|
||||
SELECT to_hex(token)as token2, to_hex(gunid)as gunid
|
||||
FROM {$ppa->ls->accessTable}
|
||||
FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE parent=x'{$token}'::bigint
|
||||
");
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$arr = $r;
|
||||
foreach ($arr as $i => $item) {
|
||||
extract($item); // token2, gunid
|
||||
$r = $ppa->ls->_getType($gunid);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
$r = BasicStor::GetType($gunid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$ftype = $r;
|
||||
|
@ -74,14 +76,14 @@ class AccessRecur {
|
|||
switch (strtolower($ftype)) {
|
||||
case "audioclip":
|
||||
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
# var_dump($r);
|
||||
break;
|
||||
case "playlist":
|
||||
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
# var_dump($r);
|
||||
|
@ -90,7 +92,7 @@ class AccessRecur {
|
|||
}
|
||||
}
|
||||
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
|
||||
if ($ppa->dbc->isError($r)) {
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
|
|
|
@ -106,9 +106,10 @@ class Backup
|
|||
*/
|
||||
public function __construct(&$gb)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$this->gb =& $gb;
|
||||
$this->token = null;
|
||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||
$this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log';
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||
}
|
||||
|
||||
|
@ -190,6 +191,7 @@ class Backup
|
|||
*/
|
||||
public function checkBackup($token)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -201,13 +203,13 @@ class Backup
|
|||
}
|
||||
switch ($status) {
|
||||
case 'success':
|
||||
$r['url'] = $this->gb->getUrlPart()."access/$token.".BACKUP_EXT;
|
||||
$r['tmpfile'] = $this->gb->accessDir."/$token.".BACKUP_EXT;
|
||||
$r['url'] = BasicStor::GetUrlPart()."access/$token.".BACKUP_EXT;
|
||||
$r['tmpfile'] = $CC_CONFIG['accessDir']."/$token.".BACKUP_EXT;
|
||||
case 'working':
|
||||
case 'fault':
|
||||
$r['status'] = $status;
|
||||
$r['status'] = $status;
|
||||
$r['faultString'] = $faultString;
|
||||
$r['token'] = $token;
|
||||
$r['token'] = $token;
|
||||
break;
|
||||
}
|
||||
return $r;
|
||||
|
@ -254,9 +256,9 @@ class Backup
|
|||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." listBackups - stat:$stat\n");
|
||||
}
|
||||
# open temporary dir
|
||||
$tokens = $this->gb->getTokensByType(ACCESS_TYPE);
|
||||
# echo '<XMP>tokens:'; print_r($tokens); echo '</XMP>';
|
||||
// open temporary dir
|
||||
$tokens = BasicStor::GetTokensByType(ACCESS_TYPE);
|
||||
// echo '<XMP>tokens:'; print_r($tokens); echo '</XMP>';
|
||||
foreach ($tokens as $token) {
|
||||
$st = $this->checkBackup($token);
|
||||
if ($stat=='' || $st['status']==$stat) {
|
||||
|
@ -303,8 +305,8 @@ class Backup
|
|||
if (PEAR::isError($sf)) {
|
||||
return $sf;
|
||||
}
|
||||
$lid = $this->gb->idFromGunid($gunid);
|
||||
if (($res = $this->gb->_authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||
$lid = BasicStor::IdFromGunid($gunid);
|
||||
if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
|
||||
return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
|
||||
}
|
||||
|
@ -388,17 +390,18 @@ class Backup
|
|||
*/
|
||||
private function setEnviroment($createDir=false)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment - createDirs:$createDir\n");
|
||||
}
|
||||
# create a temporary directories
|
||||
// create temporary directories
|
||||
if (is_null($this->token) && $createDir) {
|
||||
$this->tmpName = tempnam($this->gb->bufferDir, ACCESS_TYPE.'_');
|
||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||
$this->tmpDir = $this->tmpName.'.dir';
|
||||
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
||||
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
||||
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
||||
$this->tmpName = tempnam($CC_CONFIG['bufferDir'], ACCESS_TYPE.'_');
|
||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||
$this->tmpDir = $this->tmpName.'.dir';
|
||||
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
|
||||
$this->tmpDirClip = $this->tmpDir. '/audioClip';
|
||||
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
|
||||
touch($this->tmpFile);
|
||||
mkdir($this->tmpDir);
|
||||
mkdir($this->tmpDirPlaylist);
|
||||
|
@ -406,7 +409,7 @@ class Backup
|
|||
mkdir($this->tmpDirMeta);
|
||||
$this->genToken();
|
||||
} else {
|
||||
$symlink = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT;
|
||||
$symlink = $CC_CONFIG['accessDir'].'/'.$this->token.'.'.BACKUP_EXT;
|
||||
if (is_link($symlink) && is_file(readlink($symlink))) {
|
||||
$this->tmpName = str_replace('.tar','',readlink($symlink));
|
||||
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
|
||||
|
@ -419,7 +422,7 @@ class Backup
|
|||
return false;
|
||||
}
|
||||
}
|
||||
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.'.BACKUP_EXT.'.status';
|
||||
$this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.'.BACKUP_EXT.'.status';
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("this->tmpName: $this->tmpName\n");
|
||||
$this->addLogItem("this->tmpFile: $this->tmpFile\n");
|
||||
|
@ -440,7 +443,7 @@ class Backup
|
|||
private function genToken()
|
||||
{
|
||||
$acc = $this->gb->bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
|
||||
if ($this->gb->dbc->isError($acc)) {
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
$this->token = $acc['token'];
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -63,9 +63,6 @@ class DataEngine {
|
|||
public function __construct(&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->mdataTable = $gb->mdataTable;
|
||||
$this->filesTable = $gb->filesTable;
|
||||
$this->filetypes = array(
|
||||
'all'=>NULL,
|
||||
'audioclip'=>'audioclip',
|
||||
|
@ -151,16 +148,17 @@ class DataEngine {
|
|||
private function _makeAndSqlWoIntersect($fldsPart, $whereArr, $fileCond, $browse,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$innerBlocks = array();
|
||||
foreach ($whereArr as $i => $v) {
|
||||
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
||||
$lastTbl = ($i==0 ? "f" : "md".($i-1));
|
||||
$innerBlocks[] = "INNER JOIN {$this->mdataTable} md$i ON md$i.gunid = $lastTbl.gunid\n";
|
||||
$innerBlocks[] = "INNER JOIN ".$CC_CONFIG['mdataTable']." md$i ON md$i.gunid = $lastTbl.gunid\n";
|
||||
}
|
||||
// query construcion:
|
||||
$sql = "SELECT $fldsPart\nFROM {$this->filesTable} f\n".join("", $innerBlocks);
|
||||
$sql = "SELECT $fldsPart FROM ".$CC_CONFIG['filesTable']." f ".join("", $innerBlocks);
|
||||
if ($browse) {
|
||||
$sql .= "INNER JOIN {$this->mdataTable} br".
|
||||
$sql .= "INNER JOIN ".$CC_CONFIG['mdataTable']." br".
|
||||
"\n ON br.gunid = f.gunid AND br.objns='_L'".
|
||||
" AND br.predicate='{$brFld}' AND br.predxml='T'";
|
||||
if (!is_null($brFldNs)) {
|
||||
|
@ -203,6 +201,7 @@ class DataEngine {
|
|||
private function _makeAndSql($fldsPart, $whereArr, $fileCond, $browse,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!USE_INTERSECT) {
|
||||
return $this->_makeAndSqlWoIntersect($fldsPart, $whereArr, $fileCond, $browse, $brFldNs, $brFld);
|
||||
}
|
||||
|
@ -210,20 +209,20 @@ class DataEngine {
|
|||
foreach ($whereArr as $i => $v) {
|
||||
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i", "md$i", "md$i");
|
||||
$isectBlocks[] =
|
||||
" SELECT gunid FROM {$this->mdataTable} md$i\n".
|
||||
" SELECT gunid FROM ".$CC_CONFIG['mdataTable']." md$i\n".
|
||||
" WHERE\n {$whereArr[$i]}";
|
||||
}
|
||||
// query construcion:
|
||||
if (count($isectBlocks)>0) {
|
||||
$isectBlock =
|
||||
"FROM\n(\n".join("INTERSECT\n", $isectBlocks).") sq\n".
|
||||
"INNER JOIN {$this->filesTable} f ON f.gunid = sq.gunid";
|
||||
"INNER JOIN ".$CC_CONFIG['filesTable']." f ON f.gunid = sq.gunid";
|
||||
} else {
|
||||
$isectBlock = "FROM {$this->filesTable} f";
|
||||
$isectBlock = "FROM ".$CC_CONFIG['filesTable']." f";
|
||||
}
|
||||
$sql = "SELECT $fldsPart\n".$isectBlock;
|
||||
if ($browse) {
|
||||
$sql .= "\nINNER JOIN {$this->mdataTable} br ON br.gunid = f.gunid\n".
|
||||
$sql .= "\nINNER JOIN ".$CC_CONFIG['mdataTable']." br ON br.gunid = f.gunid\n".
|
||||
"WHERE br.objns='_L' AND br.predxml='T' AND br.predicate='{$brFld}'";
|
||||
if (!is_null($brFldNs)) {
|
||||
$sql .= " AND br.predns='{$brFldNs}'";
|
||||
|
@ -262,14 +261,15 @@ class DataEngine {
|
|||
private function _makeOrSql($fldsPart, $whereArr, $fileCond, $browse,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//$whereArr[] = " FALSE\n";
|
||||
foreach ($whereArr as $i => $v) {
|
||||
$whereArr[$i] = sprintf($v, "md", "md", "md", "md", "md");
|
||||
}
|
||||
// query construcion:
|
||||
$sql = "SELECT $fldsPart\nFROM {$this->filesTable} f\n";
|
||||
$sql = "SELECT $fldsPart FROM ".$CC_CONFIG['filesTable']." f ";
|
||||
if ($browse) {
|
||||
$sql .= "INNER JOIN {$this->mdataTable} br".
|
||||
$sql .= "INNER JOIN ".$CC_CONFIG['mdataTable']." br".
|
||||
"\n ON br.gunid = f.gunid AND br.objns='_L'".
|
||||
" AND br.predxml='T' AND br.predicate='{$brFld}'";
|
||||
if (!is_null($brFldNs)) {
|
||||
|
@ -278,7 +278,7 @@ class DataEngine {
|
|||
$sql .= "\n";
|
||||
}
|
||||
if (count($whereArr) > 0) {
|
||||
$sql .= "INNER JOIN {$this->mdataTable} md ON md.gunid=f.gunid\n";
|
||||
$sql .= "INNER JOIN ".$CC_CONFIG['mdataTable']." md ON md.gunid=f.gunid\n";
|
||||
$sql .= "WHERE\n(\n".join(" OR\n", $whereArr).")";
|
||||
$glue = " AND";
|
||||
} else {
|
||||
|
@ -347,6 +347,7 @@ class DataEngine {
|
|||
private function _localGenSearch($criteria, $limit=0, $offset=0,
|
||||
$brFldNs=NULL, $brFld=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$filetype = (isset($criteria['filetype']) ? $criteria['filetype'] : 'all');
|
||||
$filetype = strtolower($filetype);
|
||||
if (!array_key_exists($filetype, $this->filetypes)) {
|
||||
|
@ -384,7 +385,7 @@ class DataEngine {
|
|||
$desc = (isset($descA[$j]) ? $descA[$j] : NULL);
|
||||
$retype = ($obLp == 'mtime' ? '::timestamp with time zone' : '' );
|
||||
$orderJoinSql[] =
|
||||
"LEFT JOIN {$this->mdataTable} m$i\n".
|
||||
"LEFT JOIN ".$CC_CONFIG['mdataTable']." m$i\n".
|
||||
" ON m$i.gunid = sq2.gunid AND m$i.predicate='$obLp'".
|
||||
" AND m$i.objns='_L' AND m$i.predxml='T'".
|
||||
(!is_null($obNs)? " AND m$i.predns='$obNs'":'');
|
||||
|
@ -423,7 +424,7 @@ class DataEngine {
|
|||
if (PEAR::isError($cnt)) {
|
||||
return $cnt;
|
||||
}
|
||||
$res = $this->dbc->getAll($sql.$limitPart);
|
||||
$res = $CC_DBC->getAll($sql.$limitPart);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -435,7 +436,7 @@ class DataEngine {
|
|||
//$categoryNames = array('dc:title', 'dc:creator', 'dc:source', 'dcterms:extent');
|
||||
foreach ($res as $it) {
|
||||
if (!$browse) {
|
||||
$gunid = StoredFile::_normalizeGunid($it['gunid']);
|
||||
$gunid = StoredFile::NormalizeGunid($it['gunid']);
|
||||
//$values = $this->gb->bsGetMetadataValue($it['id'], $categoryNames);
|
||||
$values = $this->gb->bsGetMetadataValue($it['id']);
|
||||
$eres[] = array(
|
||||
|
@ -473,6 +474,7 @@ class DataEngine {
|
|||
*/
|
||||
public function browseCategory($category, $limit=0, $offset=0, $criteria=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//$category = strtolower($category);
|
||||
$r = XML_Util::splitQualifiedName($category);
|
||||
$catNs = $r['namespace'];
|
||||
|
@ -487,14 +489,14 @@ class DataEngine {
|
|||
$limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
|
||||
($offset != 0 ? " OFFSET $offset" : '' );
|
||||
$sql =
|
||||
"SELECT DISTINCT m.object FROM {$this->mdataTable} m\n".
|
||||
"SELECT DISTINCT m.object FROM ".$CC_CONFIG['mdataTable']." m\n".
|
||||
"WHERE $sqlCond";
|
||||
// echo "\n---\n$sql\n---\n";
|
||||
$cnt = $this->_getNumRows($sql);
|
||||
if (PEAR::isError($cnt)) {
|
||||
return $cnt;
|
||||
}
|
||||
$res = $this->dbc->getCol($sql.$limitPart);
|
||||
$res = $CC_DBC->getCol($sql.$limitPart);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -515,7 +517,8 @@ class DataEngine {
|
|||
*/
|
||||
private function _getNumRows($query)
|
||||
{
|
||||
$rh = $this->dbc->query($query);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$rh = $CC_DBC->query($query);
|
||||
if (PEAR::isError($rh)) {
|
||||
return $rh;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function createFolder($parid, $folderName, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsCreateFolder($parid, $folderName);
|
||||
|
@ -66,7 +66,7 @@ class GreenBox extends BasicStor {
|
|||
$mediaFileLP, $mdataFileLP, $sessid='',
|
||||
$gunid=NULL, $ftype='audioclip')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsPutFile(
|
||||
|
@ -96,7 +96,7 @@ class GreenBox extends BasicStor {
|
|||
public function storeWebstream($parid, $fileName, $mdataFileLP, $sessid='',
|
||||
$gunid=NULL, $url)
|
||||
{
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
if (!file_exists($mdataFileLP)) {
|
||||
|
@ -128,10 +128,10 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
// function accessFile($id, $sessid='')
|
||||
// {
|
||||
// if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// $gunid = $this->gunidFromId($id);
|
||||
// $gunid = BasicStor::GunidFromId($id);
|
||||
// $r = $this->bsAccess(NULL, '', $gunid, 'access');
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
|
@ -171,7 +171,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function analyzeFile($id, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsAnalyzeFile($id);
|
||||
|
@ -190,8 +190,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function renameFile($id, $newName, $sessid='')
|
||||
{
|
||||
$parid = $this->getParent($id);
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($id);
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsRenameFile($id, $newName);
|
||||
|
@ -211,7 +211,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function moveFile($id, $did, $sessid='')
|
||||
{
|
||||
$res = $this->_authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
$res = BasicStor::Authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
if ($res !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function copyFile($id, $did, $sessid='')
|
||||
{
|
||||
$res = $this->_authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
$res = BasicStor::Authorize(array('read', 'write'), array($id, $did), $sessid);
|
||||
if($res !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsReplaceFile($id, $mediaFileLP, $mdataFileLP);
|
||||
|
@ -274,8 +274,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function deleteFile($id, $sessid='', $forced=FALSE)
|
||||
{
|
||||
$parid = $this->getParent($id);
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($id);
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsDeleteFile($id, $forced);
|
||||
|
@ -299,7 +299,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function replaceMetadata($id, $mdata, $mdataLoc='file', $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsReplaceMetadata($id, $mdata, $mdataLoc);
|
||||
|
@ -318,7 +318,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function getMdata($id, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsGetMetadata($id);
|
||||
|
@ -341,7 +341,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function getMdataArray($id, $sessid)
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$ac = StoredFile::recall($this, $id);
|
||||
|
@ -399,7 +399,7 @@ class GreenBox extends BasicStor {
|
|||
public function getMetadataValue($id, $category, $sessid='',
|
||||
$lang=NULL, $deflang=NULL)
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsGetMetadataValue($id, $category);
|
||||
|
@ -425,7 +425,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function setMetadataValue($id, $category, $sessid, $value, $lang=NULL, $mid=NULL)
|
||||
{
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsSetMetadataValue($id, $category, $value, $lang, $mid);
|
||||
|
@ -535,14 +535,15 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function createPlaylist($parid, $fname, $sessid='')
|
||||
{
|
||||
$gunid = StoredFile::_createGunid();
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = StoredFile::CreateGunid();
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
$gunid2 = $lc->createPlaylist($sessid, $gunid, $fname);
|
||||
if (PEAR::isError($gunid2)) {
|
||||
return $gunid2;
|
||||
}
|
||||
// get local id:
|
||||
$id = $this->idFromGunid($gunid2);
|
||||
$id = BasicStor::IdFromGunid($gunid2);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -589,7 +590,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function getPlaylistArray($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$pl = StoredFile::recall($this, $id);
|
||||
if (PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
|
@ -611,8 +612,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function lockPlaylistForEdit($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
$res = $lc->editPlaylist($sessid, $gunid);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -644,7 +646,7 @@ class GreenBox extends BasicStor {
|
|||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->_setEditFlag($gunid, FALSE, $sessid);
|
||||
$this->setEditFlag($gunid, FALSE, $sessid);
|
||||
return $gunid;
|
||||
} // fn releaseLockedPlaylist
|
||||
|
||||
|
@ -677,7 +679,7 @@ class GreenBox extends BasicStor {
|
|||
if (PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
}
|
||||
$acGunid = $this->gunidFromId($acId);
|
||||
$acGunid = BasicStor::GunidFromId($acId);
|
||||
if ($pl->cyclicRecursion($acGunid)){
|
||||
return PEAR::raiseError(
|
||||
"GreenBox::addAudioClipToPlaylist: cyclic-recursion detected".
|
||||
|
@ -814,7 +816,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function revertEditedPlaylist($token, $sessid='')
|
||||
{
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->revertEditedPlaylist($token, $sessid);
|
||||
} // fn revertEditedPlaylist
|
||||
|
||||
|
@ -830,8 +833,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function deletePlaylist($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->deletePlaylist($sessid, $gunid);
|
||||
} // fn deletePlaylist
|
||||
|
||||
|
@ -872,7 +876,7 @@ class GreenBox extends BasicStor {
|
|||
return $res;
|
||||
}
|
||||
$res['title'] = NULL;
|
||||
$id = $this->idFromGunid($res['gunid']);
|
||||
$id = BasicStor::IdFromGunid($res['gunid']);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -934,8 +938,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function importPlaylistOpen($sessid, $chsum='')
|
||||
{
|
||||
$userid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($userid)) {
|
||||
$userid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($userid)) {
|
||||
return $userid;
|
||||
}
|
||||
$r = $this->bsOpenPut($chsum, NULL, $userid);
|
||||
|
@ -988,8 +992,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function existsPlaylist($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->existsPlaylist($sessid, $gunid);
|
||||
} // fn existsPlaylist
|
||||
|
||||
|
@ -1008,8 +1013,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function playlistIsAvailable($id, $sessid)
|
||||
{
|
||||
$gunid = $this->gunidFromId($id);
|
||||
$lc = new LocStor($this->dbc, $this->config);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$lc = new LocStor($CC_DBC, $CC_CONFIG);
|
||||
return $lc->playlistIsAvailable($sessid, $gunid, TRUE);
|
||||
} // fn playlistIsAvailable
|
||||
|
||||
|
@ -1136,8 +1142,8 @@ class GreenBox extends BasicStor {
|
|||
public function renderPlaylistToStorageOpen($sessid, $plid)
|
||||
{
|
||||
require_once("Renderer.php");
|
||||
$owner = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($owner)) {
|
||||
$owner = GreenBox::getSessUserId($sessid);
|
||||
if (PEAR::isError($owner)) {
|
||||
return $owner;
|
||||
}
|
||||
$r = Renderer::rnRender2FileOpen($this, $plid, $owner);
|
||||
|
@ -1181,7 +1187,7 @@ class GreenBox extends BasicStor {
|
|||
public function renderPlaylistToRSSOpen($sessid, $plid)
|
||||
{
|
||||
$token = '123456789abcdeff';
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
file_put_contents($fakeFile, "fake rendered file");
|
||||
return array('token'=>$token);
|
||||
} // fn renderPlaylistToRSSOpen
|
||||
|
@ -1198,7 +1204,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function renderPlaylistToRSSCheck($token)
|
||||
{
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
if ($token != '123456789abcdeff' || !file_exists($fakeFile)){
|
||||
return PEAR::raiseError(
|
||||
"LocStor::renderPlaylistToRSSCheck: invalid token ($token)"
|
||||
|
@ -1245,7 +1251,7 @@ class GreenBox extends BasicStor {
|
|||
"GreenBox::renderPlaylistToRSSClose: invalid token"
|
||||
);
|
||||
}
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
unlink($fakeFile);
|
||||
return TRUE;
|
||||
} // fn renderPlaylistToRSSClose
|
||||
|
@ -1663,8 +1669,8 @@ class GreenBox extends BasicStor {
|
|||
* transport token
|
||||
*/
|
||||
public function downloadFromHub($sessid, $gunid, $withContent=TRUE){
|
||||
$uid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($uid)) {
|
||||
$uid = GreenBox::getSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
require_once("Transport.php");
|
||||
|
@ -1720,7 +1726,7 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function listFolder($id, $sessid='')
|
||||
{
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$listArr = $this->bsListFolder($id);
|
||||
|
@ -1733,12 +1739,11 @@ class GreenBox extends BasicStor {
|
|||
*
|
||||
* @param int $id
|
||||
* local id
|
||||
* @return string/err
|
||||
* @return string|PEAR_Error
|
||||
*/
|
||||
public function getFileType($id)
|
||||
public static function getFileType($id)
|
||||
{
|
||||
// $id = $this->idFromGunid($gunid);
|
||||
$type = $this->getObjType($id);
|
||||
$type = BasicStor::GetObjType($id);
|
||||
return $type;
|
||||
} // fn getFileType
|
||||
|
||||
|
@ -1756,9 +1761,9 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ex;
|
||||
|
@ -1772,9 +1777,9 @@ class GreenBox extends BasicStor {
|
|||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function getPath($id)
|
||||
public static function GetPath($id)
|
||||
{
|
||||
$pa = parent::getPath($id, 'id, name, type');
|
||||
$pa = M2tree::GetPath($id, 'id, name, type');
|
||||
array_shift($pa);
|
||||
return $pa;
|
||||
} // fn getPath
|
||||
|
@ -1788,11 +1793,11 @@ class GreenBox extends BasicStor {
|
|||
* HtmlUI depends on it.
|
||||
*
|
||||
* @param string $sessid
|
||||
* @return int|PEAR_Error
|
||||
* @return int|null|PEAR_Error
|
||||
*/
|
||||
public function getSessUserId($sessid)
|
||||
public static function GetSessUserId($sessid)
|
||||
{
|
||||
$r = parent::getSessUserId($sessid);
|
||||
$r = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
if ($r->getCode() == ALIBERR_NOTEXISTS) {
|
||||
return NULL;
|
||||
|
@ -1822,14 +1827,14 @@ class GreenBox extends BasicStor {
|
|||
public function passwd($login, $oldpass=null, $pass='', $sessid='')
|
||||
{
|
||||
if (is_null($oldpass) || ($oldpass == '') ) {
|
||||
if (($res = $this->_authorize('subjects', $this->rootId, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('subjects', $this->rootId, $sessid)) !== TRUE) {
|
||||
sleep(2);
|
||||
return $res;
|
||||
} else {
|
||||
$oldpass = null;
|
||||
}
|
||||
} else {
|
||||
if (FALSE === $this->authenticate($login, $oldpass)) {
|
||||
if (FALSE === Subjects::Authenticate($login, $oldpass)) {
|
||||
sleep(2);
|
||||
return PEAR::raiseError(
|
||||
"GreenBox::passwd: access denied (oldpass)", GBERR_DENY);
|
||||
|
@ -1860,8 +1865,8 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function addPerm($sid, $action, $oid, $type='A', $sessid='')
|
||||
{
|
||||
$parid = $this->getParent($oid);
|
||||
if (($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($oid);
|
||||
if (($res = BasicStor::Authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return parent::addPerm($sid, $action, $oid, $type);
|
||||
|
@ -1884,18 +1889,18 @@ class GreenBox extends BasicStor {
|
|||
public function removePerm($permid=NULL, $subj=NULL, $obj=NULL, $sessid='')
|
||||
{
|
||||
if (!is_null($permid)) {
|
||||
$oid = $this->_getPermOid($permid);
|
||||
$oid = Alib::GetPermOid($permid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
if (!is_null($oid)) {
|
||||
$parid = $this->getParent($oid);
|
||||
if (($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
$parid = M2tree::GetParent($oid);
|
||||
if (($res = BasicStor::Authorize('editPerms', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = parent::removePerm($permid, $subj, $obj);
|
||||
$res = Alib::RemovePerm($permid, $subj, $obj);
|
||||
return $res;
|
||||
} // fn removePerm
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class LocStor extends BasicStor {
|
|||
)
|
||||
{
|
||||
// test of gunid format:
|
||||
if (!$this->_checkGunid($gunid)) {
|
||||
if (!BasicStor::CheckGunid($gunid)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::storeAudioClipOpen: Wrong gunid ($gunid)"
|
||||
);
|
||||
|
@ -53,7 +53,7 @@ class LocStor extends BasicStor {
|
|||
if (!PEAR::isError($ac)) {
|
||||
// gunid exists - do replace
|
||||
$oid = $ac->getId();
|
||||
if (($res = $this->_authorize('write', $oid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $oid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
if ($ac->isAccessed()) {
|
||||
|
@ -74,10 +74,10 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$oid = $this->addObj($tmpFname, $ftype, $parid);
|
||||
$oid = BasicStor::AddObj($tmpFname, $ftype, $parid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ac->accessRawMediaData($parent);
|
||||
|
@ -258,14 +258,14 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ex)) {
|
||||
return $ex;
|
||||
}
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id) || !$ex) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
|
||||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsOpenDownload($id);
|
||||
|
@ -301,13 +301,13 @@ class LocStor extends BasicStor {
|
|||
{
|
||||
// $res = $this->existsAudioClip($sessid, $gunid);
|
||||
// if(PEAR::isError($res)) return $res;
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadMetadataOpen: gunid not found ($gunid)"
|
||||
);
|
||||
}
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
|
@ -343,7 +343,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$md = $this->bsGetMetadata($ac->getId());
|
||||
|
@ -411,7 +411,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function searchMetadata($sessid, $criteria)
|
||||
{
|
||||
if (($res = $this->_authorize('read', $this->storId, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $this->storId, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$criteria['resultMode'] = 'xmlrpc';
|
||||
|
@ -498,11 +498,11 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = $this->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
|
@ -528,7 +528,7 @@ class LocStor extends BasicStor {
|
|||
}
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsDeleteFile($ac->getId(), $forced);
|
||||
|
@ -554,7 +554,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ac->replaceMetaData($metadata, 'string');
|
||||
|
@ -590,10 +590,10 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $parid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$oid = $this->addObj($tmpFname , 'playlist', $parid);
|
||||
$oid = BasicStor::AddObj($tmpFname , 'playlist', $parid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
|
@ -656,14 +656,14 @@ class LocStor extends BasicStor {
|
|||
return $ac;
|
||||
}
|
||||
$id = $ac->getId();
|
||||
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$r = $this->_setEditFlag($playlistId, TRUE, $sessid);
|
||||
$r = $this->setEditFlag($playlistId, TRUE, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$r = $this->_setEditFlag($playlistId, FALSE, $sessid);
|
||||
$r = $this->setEditFlag($playlistId, FALSE, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$this->_setEditFlag($gunid, FALSE, $sessid);
|
||||
$this->setEditFlag($gunid, FALSE, $sessid);
|
||||
return $gunid;
|
||||
}
|
||||
|
||||
|
@ -770,7 +770,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
if (($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
if (($res = BasicStor::Authorize('write', $ac->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsDeleteFile($ac->getId(), $forced);
|
||||
|
@ -820,8 +820,8 @@ class LocStor extends BasicStor {
|
|||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
$id = $this->idFromGunid($playlistId);
|
||||
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
|
||||
$id = BasicStor::IdFromGunid($playlistId);
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata', $parent);
|
||||
|
@ -876,10 +876,10 @@ class LocStor extends BasicStor {
|
|||
protected function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE)
|
||||
{
|
||||
$res = $this->bsExportPlaylistOpen($plids, $type, !$standalone);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$url = $this->getUrlPart()."access/".basename($res['fname']);
|
||||
$url = BasicStor::GetUrlPart()."access/".basename($res['fname']);
|
||||
$chsum = md5_file($res['fname']);
|
||||
$size = filesize($res['fname']);
|
||||
return array(
|
||||
|
@ -916,8 +916,8 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function importPlaylistOpen($sessid, $chsum)
|
||||
{
|
||||
$userid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($userid)) {
|
||||
$userid = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($userid)) {
|
||||
return $userid;
|
||||
}
|
||||
$r = $this->bsOpenPut($chsum, NULL, $userid);
|
||||
|
@ -958,7 +958,7 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return $this->gunidFromId($res);
|
||||
return BasicStor::GunidFromId($res);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToFileCheck($token)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
require_once("Renderer.php");
|
||||
$r = Renderer::rnRender2FileCheck($this, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -1063,7 +1063,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToFileClose($token)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
require_once("Renderer.php");
|
||||
$r = Renderer::rnRender2FileClose($this, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -1084,9 +1084,9 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToStorageOpen($sessid, $plid)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
$owner = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($owner)) {
|
||||
require_once("Renderer.php");
|
||||
$owner = Alib::GetSessUserId($sessid);
|
||||
if (PEAR::isError($owner)) {
|
||||
return $owner;
|
||||
}
|
||||
$r = Renderer::rnRender2FileOpen($this, $plid, $owner);
|
||||
|
@ -1108,7 +1108,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToStorageCheck($token)
|
||||
{
|
||||
require_once "Renderer.php";
|
||||
require_once("Renderer.php");
|
||||
$r = Renderer::rnRender2StorageCheck($this, $token);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -1129,8 +1129,9 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToRSSOpen($sessid, $plid)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$token = '123456789abcdeff';
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
file_put_contents($fakeFile, "fake rendered file");
|
||||
return array('token'=>$token);
|
||||
}
|
||||
|
@ -1147,13 +1148,13 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function renderPlaylistToRSSCheck($token)
|
||||
{
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
if ($token != '123456789abcdeff' || !file_exists($fakeFile)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::renderPlaylistToRSSCheck: invalid token ($token)"
|
||||
);
|
||||
}
|
||||
$fakeFUrl = $this->getUrlPart()."access/$token.rss";
|
||||
$fakeFUrl = BasicStor::GetUrlPart()."access/$token.rss";
|
||||
return array(
|
||||
'status'=> 'success',
|
||||
'url' => $fakeFUrl,
|
||||
|
@ -1176,7 +1177,7 @@ class LocStor extends BasicStor {
|
|||
"LocStor::renderPlaylistToRSSClose: invalid token"
|
||||
);
|
||||
}
|
||||
$fakeFile = "{$this->accessDir}/$token.rss";
|
||||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
unlink($fakeFile);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1296,8 +1297,8 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function restoreBackupOpen($sessid, $chsum)
|
||||
{
|
||||
$userid = $this->getSessUserId($sessid);
|
||||
if ($this->dbc->isError($userid)) {
|
||||
$userid = Alib::getSessUserId($sessid);
|
||||
if (PEAR::isError($userid)) {
|
||||
return $userid;
|
||||
}
|
||||
$r = $this->bsOpenPut($chsum, NULL, $userid);
|
||||
|
|
|
@ -101,9 +101,9 @@ class M3uPlaylist {
|
|||
foreach ($arr as $i => $it) {
|
||||
list($md, $uri) = preg_split("|\n|", $it);
|
||||
list($length, $title) = preg_split("|, *|", $md);
|
||||
// $gunid = StoredFile::_createGunid();
|
||||
// $gunid = StoredFile::CreateGunid();
|
||||
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
|
||||
$acId = $gb->idFromGunid($gunid);
|
||||
$acId = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($acId)) {
|
||||
return $acId;
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ class M3uPlaylist {
|
|||
foreach ($arr as $i => $it) {
|
||||
list($md, $uri) = preg_split("|\n|", $it);
|
||||
list($length, $title) = preg_split("|, *|", $md);
|
||||
$gunid = StoredFile::_createGunid();
|
||||
$gunid2 = StoredFile::_createGunid();
|
||||
$gunid = StoredFile::CreateGunid();
|
||||
$gunid2 = StoredFile::CreateGunid();
|
||||
$length = Playlist::secondsToPlaylistTime($length);
|
||||
$offset = '???';
|
||||
$uri_h = preg_replace("|--|", "d;d;", htmlspecialchars("$uri"));
|
||||
|
@ -225,7 +225,7 @@ class M3uPlaylistBodyElement {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$gunid = StoredFile::_createGunid();
|
||||
$gunid = StoredFile::CreateGunid();
|
||||
$playlength = '???'; // ***
|
||||
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
|
||||
"$ind<playlist id=\"$gunid\" playlength=\"$playlength\" title=\"\">\n".
|
||||
|
@ -313,8 +313,8 @@ class M3uPlaylistAudioElement {
|
|||
} else {
|
||||
$fInfo = '';
|
||||
}
|
||||
$plElGunid = StoredFile::_createGunid();
|
||||
$aGunid = StoredFile::_createGunid();
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
$aGunid = StoredFile::CreateGunid();
|
||||
$title = basename($tree->attrs['src']->val);
|
||||
$offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val);
|
||||
$playlength = '???'; # ***
|
||||
|
|
|
@ -23,9 +23,6 @@ require_once "XML/Util.php";
|
|||
*/
|
||||
class MetaData {
|
||||
|
||||
public $config;
|
||||
public $dbc;
|
||||
public $mdataTable;
|
||||
public $gunid;
|
||||
public $resDir;
|
||||
public $fname;
|
||||
|
@ -41,9 +38,6 @@ class MetaData {
|
|||
*/
|
||||
public function __construct(&$gb, $gunid, $resDir)
|
||||
{
|
||||
$this->config =& $gb->config;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->mdataTable = $gb->mdataTable;
|
||||
$this->gunid = $gunid;
|
||||
$this->resDir = $resDir;
|
||||
$this->fname = $this->makeFname();
|
||||
|
@ -139,11 +133,12 @@ class MetaData {
|
|||
*/
|
||||
public function delete()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (file_exists($this->fname)) {
|
||||
@unlink($this->fname);
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->mdataTable}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -177,10 +172,11 @@ class MetaData {
|
|||
*/
|
||||
public function getAllMetadata()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT predns, predicate, object
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint";
|
||||
$rows = $this->dbc->getAll($sql);
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$values = array();
|
||||
foreach ($rows as $row) {
|
||||
$values[$row["predns"].":".$row["predicate"]] = $row["object"];
|
||||
|
@ -202,6 +198,7 @@ class MetaData {
|
|||
*/
|
||||
public function getMetadataEl($category, $parid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// handle predicate namespace shortcut
|
||||
$a = XML_Util::splitQualifiedName($category);
|
||||
if (PEAR::isError($a)) {
|
||||
|
@ -217,10 +214,10 @@ class MetaData {
|
|||
$cond .= " AND subjns='_I' AND subject='$parid'";
|
||||
}
|
||||
$sql = "SELECT id as mid, object as value
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE $cond
|
||||
ORDER BY id";
|
||||
$all = $this->dbc->getAll($sql);
|
||||
$all = $CC_DBC->getAll($sql);
|
||||
foreach ($all as $i => $v) {
|
||||
if (is_null($all[$i]['value'])) {
|
||||
$all[$i]['value'] = '';
|
||||
|
@ -244,11 +241,12 @@ class MetaData {
|
|||
*/
|
||||
public function setMetadataEl($mid, $value=NULL)
|
||||
{
|
||||
$info = $this->dbc->getRow("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$info = $CC_DBC->getRow("
|
||||
SELECT parmd.predns as parns, parmd.predicate as parname,
|
||||
md.predxml, md.predns as chns, md.predicate as chname
|
||||
FROM {$this->mdataTable} parmd
|
||||
INNER JOIN {$this->mdataTable} md
|
||||
FROM ".$CC_CONFIG['mdataTable']." parmd
|
||||
INNER JOIN ".$CC_CONFIG['mdataTable']." md
|
||||
ON parmd.id=md.subject AND md.subjns='_I'
|
||||
WHERE md.id=$mid
|
||||
");
|
||||
|
@ -270,11 +268,11 @@ class MetaData {
|
|||
if (!is_null($value)) {
|
||||
$escapedValue = pg_escape_string($value);
|
||||
$sql = "
|
||||
UPDATE {$this->mdataTable}
|
||||
UPDATE ".$CC_CONFIG['mdataTable']."
|
||||
SET object='$escapedValue', objns='_L'
|
||||
WHERE id={$mid}
|
||||
";
|
||||
$res = $this->dbc->query($sql);
|
||||
$res = $CC_DBC->query($sql);
|
||||
} else {
|
||||
$res = $this->deleteRecord($mid);
|
||||
}
|
||||
|
@ -301,9 +299,10 @@ class MetaData {
|
|||
*/
|
||||
public function insertMetadataEl($parid, $category, $value=NULL, $predxml='T')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//$category = strtolower($category);
|
||||
$parent = $this->dbc->getRow("
|
||||
SELECT predns, predicate, predxml FROM {$this->mdataTable}
|
||||
$parent = $CC_DBC->getRow("
|
||||
SELECT predns, predicate, predxml FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint AND id=$parid
|
||||
");
|
||||
if (PEAR::isError($parent)) {
|
||||
|
@ -526,7 +525,9 @@ class MetaData {
|
|||
$atime = trim(`date +%Y-%m-%dT%H:%M:%S`).$tz;
|
||||
}
|
||||
$r = $this->setMetadataValue('ls:mtime', $atime);
|
||||
if(PEAR::isError($r)) return $r;
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$fn = $this->fname;
|
||||
$xml = $this->genXMLDoc();
|
||||
if (PEAR::isError($xml)) {
|
||||
|
@ -589,9 +590,10 @@ class MetaData {
|
|||
*/
|
||||
private function dbCheck($gunid)
|
||||
{
|
||||
$cnt = $this->dbc->getOne("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$cnt = $CC_DBC->getOne("
|
||||
SELECT count(*)as cnt
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
if (PEAR::isError($cnt)) {
|
||||
|
@ -628,7 +630,8 @@ class MetaData {
|
|||
*/
|
||||
private function validate(&$tree)
|
||||
{
|
||||
if ($this->config['validate'] && !is_null($this->format)) {
|
||||
global $CC_CONFIG;
|
||||
if ($CC_CONFIG['validate'] && !is_null($this->format)) {
|
||||
require_once("Validator.php");
|
||||
$val = new Validator($this->format, $this->gunid);
|
||||
if (PEAR::isError($val)) {
|
||||
|
@ -658,7 +661,8 @@ class MetaData {
|
|||
*/
|
||||
private function validateOneValue($parName, $category, $predxml, $value)
|
||||
{
|
||||
if ($this->config['validate'] && !is_null($this->format)) {
|
||||
global $CC_CONFIG;
|
||||
if ($CC_CONFIG['validate'] && !is_null($this->format)) {
|
||||
require_once("Validator.php");
|
||||
$val = new Validator($this->format, $this->gunid);
|
||||
if (PEAR::isError($val)) {
|
||||
|
@ -682,15 +686,16 @@ class MetaData {
|
|||
*/
|
||||
private function storeDoc(&$tree)
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->storeNode($tree);
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -759,7 +764,7 @@ class MetaData {
|
|||
// {
|
||||
// $object_sql = is_null($object) ? "NULL" : "'".pg_escape_string($object)."'";
|
||||
// $objns_sql = is_null($objns) ? "NULL" : "'".pg_escape_string($objns)."'";
|
||||
// $res = $this->dbc->query("UPDATE {$this->mdataTable}
|
||||
// $res = $CC_DBC->query("UPDATE {$this->mdataTable}
|
||||
// SET objns = $objns_sql, object = $object_sql
|
||||
// WHERE gunid = x'{$this->gunid}'::bigint AND id='$mdid'
|
||||
// ");
|
||||
|
@ -796,6 +801,7 @@ class MetaData {
|
|||
private function storeRecord($subjns, $subject, $predns, $predicate, $predxml='T',
|
||||
$objns=NULL, $object=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//echo "$subjns, $subject, $predns, $predicate, $predxml, $objns, $object\n";
|
||||
//$predns = strtolower($predns);
|
||||
//$predicate = strtolower($predicate);
|
||||
|
@ -805,12 +811,12 @@ class MetaData {
|
|||
$predicate_sql = is_null($predicate) ? "NULL" : "'".pg_escape_string($predicate)."'";
|
||||
$objns_sql = is_null($objns) ? "NULL" : "'".pg_escape_string($objns)."'";
|
||||
$object_sql = is_null($object) ? "NULL" : "'".pg_escape_string($object)."'";
|
||||
$id = $this->dbc->nextId("{$this->mdataTable}_id_seq");
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['mdataTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
INSERT INTO {$this->mdataTable}
|
||||
$res = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['mdataTable']."
|
||||
(id , gunid, subjns, subject,
|
||||
predns, predicate, predxml,
|
||||
objns, object
|
||||
|
@ -837,10 +843,11 @@ class MetaData {
|
|||
*/
|
||||
private function deleteRecord($mid)
|
||||
{
|
||||
$sql = "SELECT id FROM {$this->mdataTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE subjns='_I' AND subject='{$mid}' AND
|
||||
gunid=x'{$this->gunid}'::bigint";
|
||||
$rh = $this->dbc->query($sql);
|
||||
$rh = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($rh)) {
|
||||
return $rh;
|
||||
}
|
||||
|
@ -851,10 +858,10 @@ class MetaData {
|
|||
}
|
||||
}
|
||||
$rh->free();
|
||||
$sql = "DELETE FROM {$this->mdataTable}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE id={$mid} AND
|
||||
gunid=x'{$this->gunid}'::bigint";
|
||||
$res = $this->dbc->query($sql);
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -871,9 +878,10 @@ class MetaData {
|
|||
*/
|
||||
public function genPhpArray()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$res = array();
|
||||
$row = $this->dbc->getRow("
|
||||
SELECT * FROM {$this->mdataTable}
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT * FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
AND subjns='_G' AND subject='{$this->gunid}'
|
||||
");
|
||||
|
@ -899,10 +907,11 @@ class MetaData {
|
|||
*/
|
||||
public function genXMLDoc()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
require_once("XML/Util.php");
|
||||
$res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n";
|
||||
$row = $this->dbc->getRow("
|
||||
SELECT * FROM {$this->mdataTable}
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT * FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
AND subjns='_G' AND subject='{$this->gunid}'
|
||||
");
|
||||
|
@ -939,7 +948,7 @@ class MetaData {
|
|||
private function genXMLNode($row, $genXML=TRUE)
|
||||
{
|
||||
if (DEBUG) {
|
||||
echo"genXMLNode:\n";
|
||||
echo "genXMLNode:\n";
|
||||
}
|
||||
if (DEBUG) {
|
||||
var_dump($row);
|
||||
|
@ -990,13 +999,14 @@ class MetaData {
|
|||
*/
|
||||
private function getSubrows($parid, $genXML=TRUE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (DEBUG) {
|
||||
echo" getSubrows:\n";
|
||||
}
|
||||
$qh = $this->dbc->query($q = "
|
||||
$qh = $CC_DBC->query($q = "
|
||||
SELECT
|
||||
id, predxml, predns, predicate, objns, object
|
||||
FROM {$this->mdataTable}
|
||||
FROM ".$CC_CONFIG['mdataTable']."
|
||||
WHERE
|
||||
subjns='_I' AND subject='$parid' AND
|
||||
gunid=x'{$this->gunid}'::bigint
|
||||
|
|
|
@ -102,7 +102,7 @@ class Playlist extends StoredFile {
|
|||
public function &create(&$gb, $plid, $fname=NULL, $parid=NULL)
|
||||
{
|
||||
$tmpFname = uniqid('');
|
||||
$oid = $gb->addObj($tmpFname , 'playlist', $parid);
|
||||
$oid = BasicStor::AddObj($tmpFname , 'playlist', $parid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class Playlist extends StoredFile {
|
|||
'Playlist::lock: playlist already locked'
|
||||
);
|
||||
}
|
||||
$r = $gb->_setEditFlag($this->gunid, $val, NULL, $subjid);
|
||||
$r = $gb->setEditFlag($this->gunid, $val, NULL, $subjid);
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ class Playlist extends StoredFile {
|
|||
} else {
|
||||
$acTit = $acGunid;
|
||||
}
|
||||
$elType = $this->gb->getObjType($acId);
|
||||
$elType = BasicStor::GetObjType($acId);
|
||||
$trTbl = array('audioclip'=>'audioClip', 'webstream'=>'audioClip',
|
||||
'playlist'=>'playlist');
|
||||
$elType = $trTbl[$elType];
|
||||
|
@ -381,7 +381,7 @@ class Playlist extends StoredFile {
|
|||
$plElId = $r;
|
||||
// create and insert gunid (id attribute)
|
||||
if (is_null($plElGunid)) {
|
||||
$plElGunid = StoredFile::_createGunid();
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
}
|
||||
$r = $this->md->insertMetadataEl($plElId, 'id', $plElGunid, 'A');
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -420,7 +420,7 @@ class Playlist extends StoredFile {
|
|||
return $r;
|
||||
}
|
||||
$fiId = $r;
|
||||
$fiGunid = StoredFile::_createGunid();
|
||||
$fiGunid = StoredFile::CreateGunid();
|
||||
$r = $this->md->insertMetadataEl($fiId, 'id', $fiGunid, 'A');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -687,7 +687,7 @@ class Playlist extends StoredFile {
|
|||
if (PEAR::isError($fiMid)) {
|
||||
return $fiMid;
|
||||
}
|
||||
$fiGunid = StoredFile::_createGunid();
|
||||
$fiGunid = StoredFile::CreateGunid();
|
||||
$r = $this->_getMidOrInsert('id', $fiMid, $fiGunid, 'A');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
|
@ -773,7 +773,7 @@ class Playlist extends StoredFile {
|
|||
);
|
||||
}
|
||||
}
|
||||
$acId = $this->gb->idFromGunid($acGunid);
|
||||
$acId = BasicStor::IdFromGunid($acGunid);
|
||||
if (PEAR::isError($acId)) {
|
||||
return $acId;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
/* ================== Prefs ================== */
|
||||
class Prefs {
|
||||
|
||||
public $gb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -25,8 +27,6 @@ class Prefs {
|
|||
public function __construct(&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->prefTable = $gb->config['tblNamePrefix'].'pref';
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Prefs {
|
|||
*/
|
||||
function loadPref($sessid, $key)
|
||||
{
|
||||
$subjid = $this->gb->getSessUserId($sessid);
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class Prefs {
|
|||
*/
|
||||
function savePref($sessid, $key, $value)
|
||||
{
|
||||
$subjid = $this->gb->getSessUserId($sessid);
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class Prefs {
|
|||
*/
|
||||
function delPref($sessid, $key)
|
||||
{
|
||||
$subjid = $this->gb->getSessUserId($sessid);
|
||||
$subjid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class Prefs {
|
|||
function loadGroupPref($sessid, $group, $key)
|
||||
{
|
||||
// if sessid is would be used here fix Transport::cronCallMethod !
|
||||
$subjid = $this->gb->getSubjId($group);
|
||||
$subjid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($subjid)) {
|
||||
return $subjid;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ class Prefs {
|
|||
*/
|
||||
function saveGroupPref($sessid, $group, $key, $value)
|
||||
{
|
||||
$uid = $this->gb->getSessUserId($sessid);
|
||||
$uid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::saveGroupPref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$gid = $this->gb->getSubjId($group);
|
||||
$gid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::saveGroupPref: invalid group name", GBERR_SESS);
|
||||
}
|
||||
$memb = $this->gb->isMemberOf($uid, $gid);
|
||||
$memb = Subjects::IsMemberOf($uid, $gid);
|
||||
if (PEAR::isError($memb)) {
|
||||
return $memb;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class Prefs {
|
|||
*/
|
||||
function delGroupPref($sessid, $group, $key)
|
||||
{
|
||||
$uid = $this->gb->getSessUserId($sessid);
|
||||
$uid = GreenBox::GetSessUserId($sessid);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::delGroupPref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$gid = $this->gb->getSubjId($group);
|
||||
$gid = Subjects::GetSubjId($group);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class Prefs {
|
|||
return PEAR::raiseError(
|
||||
"Prefs::delGroupPref: invalid group name", GBERR_SESS);
|
||||
}
|
||||
$memb = $this->gb->isMemberOf($uid, $gid);
|
||||
$memb = Subjects::IsMemberOf($uid, $gid);
|
||||
if (PEAR::isError($memb)) {
|
||||
return $memb;
|
||||
}
|
||||
|
@ -280,14 +280,15 @@ class Prefs {
|
|||
* @return int
|
||||
* local user id
|
||||
*/
|
||||
function insert($subjid, $keystr, $valstr='')
|
||||
public static function Insert($subjid, $keystr, $valstr='')
|
||||
{
|
||||
$id = $this->dbc->nextId("{$this->prefTable}_id_seq");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['prefTable']."_id_seq");
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$r = $this->dbc->query("
|
||||
INSERT INTO {$this->prefTable}
|
||||
$r = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['prefTable']."
|
||||
(id, subjid, keystr, valstr)
|
||||
VALUES
|
||||
($id, $subjid, '$keystr', '$valstr')
|
||||
|
@ -311,8 +312,9 @@ class Prefs {
|
|||
*/
|
||||
function readVal($subjid, $keystr)
|
||||
{
|
||||
$val = $this->dbc->getOne("
|
||||
SELECT valstr FROM {$this->prefTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$val = $CC_DBC->getOne("
|
||||
SELECT valstr FROM ".$CC_CONFIG['prefTable']."
|
||||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($val)) {
|
||||
|
@ -335,8 +337,9 @@ class Prefs {
|
|||
*/
|
||||
function readKeys($subjid)
|
||||
{
|
||||
$res = $this->dbc->getAll("
|
||||
SELECT keystr FROM {$this->prefTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$res = $CC_DBC->getAll("
|
||||
SELECT keystr FROM ".$CC_CONFIG['prefTable']."
|
||||
WHERE subjid=$subjid
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -362,15 +365,16 @@ class Prefs {
|
|||
*/
|
||||
function update($subjid, $keystr, $newvalstr='')
|
||||
{
|
||||
$r = $this->dbc->query("
|
||||
UPDATE {$this->prefTable} SET
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['prefTable']." SET
|
||||
valstr='$newvalstr'
|
||||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if ($this->dbc->affectedRows() < 1) {
|
||||
if ($CC_DBC->affectedRows() < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -388,14 +392,15 @@ class Prefs {
|
|||
*/
|
||||
function delete($subjid, $keystr)
|
||||
{
|
||||
$r = $this->dbc->query("
|
||||
DELETE FROM {$this->prefTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$r = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['prefTable']."
|
||||
WHERE subjid=$subjid AND keystr='$keystr'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if ($this->dbc->affectedRows() < 1) {
|
||||
if ($CC_DBC->affectedRows() < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -409,7 +414,8 @@ class Prefs {
|
|||
*/
|
||||
function test()
|
||||
{
|
||||
$sessid = $this->gb->login('root', $this->gb->config['tmpRootPass']);
|
||||
global $CC_CONFIG;
|
||||
$sessid = Alib::Login('root', $CC_CONFIG['tmpRootPass']);
|
||||
$testkey = 'testKey';
|
||||
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
|
||||
$r = savePref($sessid, $testKey, $testVal);
|
||||
|
@ -439,39 +445,40 @@ class Prefs {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function install()
|
||||
{
|
||||
$this->dbc->createSequence("{$this->prefTable}_id_seq");
|
||||
$r = $this->dbc->query("CREATE TABLE {$this->prefTable} (
|
||||
id int not null,
|
||||
subjid int REFERENCES {$this->gb->subjTable} ON DELETE CASCADE,
|
||||
keystr varchar(255),
|
||||
valstr text
|
||||
)");
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
|
||||
ON {$this->prefTable} (id)");
|
||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
|
||||
ON {$this->prefTable} (subjid, keystr)");
|
||||
$this->dbc->query("CREATE INDEX {$this->prefTable}_subjid_idx
|
||||
ON {$this->prefTable} (subjid)");
|
||||
$stPrefGr = $this->gb->getSubjId($this->gb->config['StationPrefsGr']);
|
||||
if (PEAR::isError($stPrefGr)) {
|
||||
echo $stPrefGr->getMessage()."\n";
|
||||
}
|
||||
$r = $this->insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
}
|
||||
$genres = file_get_contents( dirname(__FILE__).'/genres.xml');
|
||||
$r = $this->insert($stPrefGr, 'genres', $genres);
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
// function install()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->createSequence("{$this->prefTable}_id_seq");
|
||||
// $r = $CC_DBC->query("CREATE TABLE {$this->prefTable} (
|
||||
// id int not null,
|
||||
// subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
// keystr varchar(255),
|
||||
// valstr text
|
||||
// )");
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
|
||||
// ON {$this->prefTable} (id)");
|
||||
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
|
||||
// ON {$this->prefTable} (subjid, keystr)");
|
||||
// $CC_DBC->query("CREATE INDEX {$this->prefTable}_subjid_idx
|
||||
// ON {$this->prefTable} (subjid)");
|
||||
// $stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
|
||||
// if (PEAR::isError($stPrefGr)) {
|
||||
// echo $stPrefGr->getMessage()."\n";
|
||||
// }
|
||||
// $r = Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()."\n";
|
||||
// }
|
||||
// $genres = file_get_contents(dirname(__FILE__).'/../genres.xml');
|
||||
// $r = Prefs::Insert($stPrefGr, 'genres', $genres);
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()."\n";
|
||||
// }
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -479,11 +486,12 @@ class Prefs {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->prefTable}");
|
||||
$this->dbc->dropSequence("{$this->prefTable}_id_seq");
|
||||
}
|
||||
// function uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE {$this->prefTable}");
|
||||
// $CC_DBC->dropSequence("{$this->prefTable}_id_seq");
|
||||
// }
|
||||
|
||||
} // class Prefs
|
||||
?>
|
|
@ -35,6 +35,7 @@ class Renderer
|
|||
*/
|
||||
function rnRender2FileOpen(&$gb, $plid, $owner=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
// recall playlist:
|
||||
$pl = LsPlaylist::recallByGunid($gb, $plid);
|
||||
if (PEAR::isError($pl)) {
|
||||
|
@ -46,7 +47,7 @@ class Renderer
|
|||
return $smil;
|
||||
}
|
||||
// temporary file for smil:
|
||||
$tmpn = tempnam($gb->bufferDir, 'plRender_');
|
||||
$tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_');
|
||||
$smilf = "$tmpn.smil";
|
||||
file_put_contents($smilf, $smil);
|
||||
$url = "file://$smilf";
|
||||
|
@ -54,11 +55,11 @@ class Renderer
|
|||
$outf = "$tmpn.".RENDER_EXT;
|
||||
touch($outf);
|
||||
// logging:
|
||||
$logf = "{$gb->bufferDir}/renderer.log";
|
||||
$logf = $CC_CONFIG['bufferDir']."/renderer.log";
|
||||
file_put_contents($logf, "--- ".date("Ymd-H:i:s")."\n", FILE_APPEND);
|
||||
// open access to output file: /*gunid*/ /*parent*/
|
||||
$acc = $gb->bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
|
||||
if ($gb->dbc->isError($acc)) {
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
extract($acc);
|
||||
|
@ -118,8 +119,8 @@ class Renderer
|
|||
* url : string - readable url
|
||||
*/
|
||||
function rnRender2FileList(&$gb,$stat='') {
|
||||
# open temporary dir
|
||||
$tokens = $gb->getTokensByType('render');
|
||||
// open temporary dir
|
||||
$tokens = BasicStor::GetTokensByType('render');
|
||||
foreach ($tokens as $token) {
|
||||
$st = Renderer::rnRender2FileCheck($gb, $token);
|
||||
if ( ($stat=='') || ($st['status']==$stat) ) {
|
||||
|
@ -142,12 +143,13 @@ class Renderer
|
|||
*/
|
||||
function rnRender2FileClose(&$gb, $token)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$r = $gb->bsRelease($token, 'render');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$realOgg = $r['realFname'];
|
||||
$tmpn = "{$gb->bufferDir}/".basename($realOgg, '.'.RENDER_EXT);
|
||||
$tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT);
|
||||
$smilf = "$tmpn.smil";
|
||||
$statf = Renderer::getStatusFile($gb, $token);
|
||||
@unlink($statf);
|
||||
|
@ -219,7 +221,7 @@ class Renderer
|
|||
return $parid;
|
||||
}
|
||||
$fileName = 'rendered_playlist';
|
||||
$id = $gb->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
|
@ -254,8 +256,9 @@ class Renderer
|
|||
*/
|
||||
function getLocalFile(&$gb, $token)
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return "{$gb->accessDir}/$token.".RENDER_EXT;
|
||||
global $CC_CONFIG;
|
||||
$token = StoredFile::NormalizeGunid($token);
|
||||
return $CC_CONFIG['accessDir']."/$token.".RENDER_EXT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,8 +288,8 @@ class Renderer
|
|||
*/
|
||||
function getUrl(&$gb, $token)
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return $gb->getUrlPart()."access/$token.".RENDER_EXT;
|
||||
$token = StoredFile::NormalizeGunid($token);
|
||||
return BasicStor::GetUrlPart()."access/$token.".RENDER_EXT;
|
||||
}
|
||||
|
||||
} // class Renderer
|
||||
|
|
|
@ -56,10 +56,12 @@ class Restore {
|
|||
* @param GreenBox $gb
|
||||
* greenbox object reference
|
||||
*/
|
||||
public function __construct(&$gb) {
|
||||
public function __construct(&$gb)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$this->gb =& $gb;
|
||||
$this->token = null;
|
||||
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
|
||||
$this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log';
|
||||
if ($this->loglevel == 'debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
|
||||
}
|
||||
|
@ -77,14 +79,15 @@ class Restore {
|
|||
* hasharray with field:
|
||||
* token string: backup token
|
||||
*/
|
||||
function openRestore($sessid, $backup_file) {
|
||||
function openRestore($sessid, $backup_file)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I-".date("Ymd-H:i:s")." doRestore - sessid:$sessid\n");
|
||||
}
|
||||
$this->sessid = $sessid;
|
||||
|
||||
//generate token
|
||||
$this->token = StoredFile::_createGunid();
|
||||
$this->token = StoredFile::CreateGunid();
|
||||
|
||||
// status file -> working
|
||||
$this->setEnviroment();
|
||||
|
@ -112,7 +115,8 @@ class Restore {
|
|||
* url : string - access url
|
||||
* tmpfile : string - access filename
|
||||
*/
|
||||
function checkRestore($token) {
|
||||
function checkRestore($token)
|
||||
{
|
||||
if ($this->loglevel == 'debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -145,7 +149,8 @@ class Restore {
|
|||
* hasharray with field:
|
||||
* status : boolean - is susccess
|
||||
*/
|
||||
function closeRestore($token) {
|
||||
function closeRestore($token)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
|
||||
}
|
||||
|
@ -170,7 +175,8 @@ class Restore {
|
|||
* @param string $sessid
|
||||
* session id
|
||||
*/
|
||||
function startRestore($backupfile, $token, $sessid) {
|
||||
function startRestore($backupfile, $token, $sessid)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n");
|
||||
}
|
||||
|
@ -181,8 +187,8 @@ class Restore {
|
|||
// extract tarball
|
||||
$command = 'tar -xf '.$backupfile.' --directory '.$this->tmpDir;
|
||||
$res = system($command);
|
||||
#$this->addLogItem('command: '.$command."\n");
|
||||
#$this->addLogItem('res: '.$res."\n");
|
||||
//$this->addLogItem('command: '.$command."\n");
|
||||
//$this->addLogItem('res: '.$res."\n");
|
||||
|
||||
//simple check of archive format
|
||||
if (is_dir($this->tmpDir.'audioClip/') &&
|
||||
|
@ -221,7 +227,8 @@ class Restore {
|
|||
* type : stirng - audioClip | playlist
|
||||
* id : string - the backuped gunid
|
||||
*/
|
||||
function getMetaFiles() {
|
||||
function getMetaFiles()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." getMetaFiles - tmpDir:{$this->tmpDir}\n");
|
||||
}
|
||||
|
@ -256,7 +263,8 @@ class Restore {
|
|||
* @return mixed
|
||||
* true if success or PEAR_error
|
||||
*/
|
||||
function addFileToStorage($file,$type,$gunid) {
|
||||
function addFileToStorage($file,$type,$gunid)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n");
|
||||
}
|
||||
|
@ -273,7 +281,7 @@ class Restore {
|
|||
}
|
||||
if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
|
||||
//replace it
|
||||
$id = $this->gb->idFromGunid($gunid);
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$replace = $this->gb->replaceFile(
|
||||
$id, # id int, virt.file's local id
|
||||
$mediaFileLP, # mediaFileLP string, local path of media file
|
||||
|
@ -341,12 +349,13 @@ class Restore {
|
|||
* Figure out the environment to the backup.
|
||||
*
|
||||
*/
|
||||
function setEnviroment() {
|
||||
function setEnviroment()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n");
|
||||
}
|
||||
$this->statusFile = $this->gb->accessDir.'/'.$this->token.'.status';
|
||||
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
|
||||
$this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.status';
|
||||
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
|
||||
$this->rMkDir($this->tmpDir);
|
||||
}
|
||||
|
||||
|
@ -357,7 +366,8 @@ class Restore {
|
|||
* @param string $item
|
||||
* the new row of log file
|
||||
*/
|
||||
function addLogItem($item) {
|
||||
function addLogItem($item)
|
||||
{
|
||||
$f = fopen ($this->logFile,'a');
|
||||
flock($f,LOCK_SH);
|
||||
fwrite($f,$item);
|
||||
|
@ -376,7 +386,8 @@ class Restore {
|
|||
* @return boolean
|
||||
* is success
|
||||
*/
|
||||
function rRmDir($dirname) {
|
||||
function rRmDir($dirname)
|
||||
{
|
||||
if (is_dir($dirname)) {
|
||||
$dir_handle = opendir($dirname);
|
||||
}
|
||||
|
@ -407,7 +418,8 @@ class Restore {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function rMkDir($dirname,$mode=0777,$recursive=true) {
|
||||
function rMkDir($dirname, $mode=0777, $recursive=true)
|
||||
{
|
||||
if (is_null($dirname) || $dirname === "" ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -238,14 +238,14 @@ class SmilPlaylistAudioElement {
|
|||
}
|
||||
}
|
||||
if ($fadeIn > 0 || $fadeOut > 0) {
|
||||
$fiGunid = StoredFile::_createGunid();
|
||||
$fiGunid = StoredFile::CreateGunid();
|
||||
$fadeIn = Playlist::secondsToPlaylistTime($fadeIn);
|
||||
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
|
||||
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
|
||||
} else {
|
||||
$fInfo = '';
|
||||
}
|
||||
$plElGunid = StoredFile::_createGunid();
|
||||
$plElGunid = StoredFile::CreateGunid();
|
||||
$acGunid = $gunid;
|
||||
$type = 'audioClip';
|
||||
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
|
||||
|
|
|
@ -40,13 +40,13 @@ class StoredFile {
|
|||
* Name of a database table.
|
||||
* @var string
|
||||
*/
|
||||
public $filesTable;
|
||||
//public $filesTable;
|
||||
|
||||
/**
|
||||
* Name of a database table.
|
||||
* @var string
|
||||
*/
|
||||
public $accessTable;
|
||||
//public $accessTable;
|
||||
|
||||
/**
|
||||
* Unique ID for the file.
|
||||
|
@ -57,7 +57,7 @@ class StoredFile {
|
|||
|
||||
/**
|
||||
* Directory where the file is located.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $resDir;
|
||||
|
@ -65,7 +65,7 @@ class StoredFile {
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessDir;
|
||||
//private $accessDir;
|
||||
|
||||
/**
|
||||
* @var RawMediaData
|
||||
|
@ -87,16 +87,17 @@ class StoredFile {
|
|||
*/
|
||||
public function __construct(&$gb, $gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
global $CC_DBC;
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->filesTable = $gb->filesTable;
|
||||
$this->accessTable= $gb->accessTable;
|
||||
//$this->filesTable = $CC_CONFIG['filesTable'];
|
||||
//$this->accessTable= $CC_CONFIG['accessTable'];
|
||||
$this->gunid = $gunid;
|
||||
if (is_null($this->gunid)) {
|
||||
$this->gunid = $this->_createGunid();
|
||||
$this->gunid = StoredFile::CreateGunid();
|
||||
}
|
||||
$this->resDir = $this->_getResDir($this->gunid);
|
||||
$this->accessDir = $this->gb->accessDir;
|
||||
//$this->accessDir = $this->gb->accessDir;
|
||||
$this->rmd = new RawMediaData($this->gunid, $this->resDir);
|
||||
$this->md = new MetaData($gb, $this->gunid, $this->resDir);
|
||||
}
|
||||
|
@ -129,6 +130,7 @@ class StoredFile {
|
|||
$mediaFileLP='', $metadata='', $mdataLoc='file',
|
||||
$gunid=NULL, $ftype=NULL, $className='StoredFile')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$ac = new $className($gb, ($gunid ? $gunid : NULL));
|
||||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
|
@ -142,16 +144,16 @@ class StoredFile {
|
|||
}
|
||||
$escapedName = pg_escape_string($name);
|
||||
$escapedFtype = pg_escape_string($ftype);
|
||||
$ac->dbc->query("BEGIN");
|
||||
$res = $ac->dbc->query("
|
||||
INSERT INTO {$ac->filesTable}
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['filesTable']."
|
||||
(id, name, gunid, mime, state, ftype, mtime)
|
||||
VALUES
|
||||
('$oid', '{$escapedName}', x'{$ac->gunid}'::bigint,
|
||||
'{$ac->mime}', 'incomplete', '$escapedFtype', now())
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
// --- metadata insert:
|
||||
|
@ -167,7 +169,7 @@ class StoredFile {
|
|||
}
|
||||
$res = $ac->md->insert($metadata, $mdataLoc, $ftype);
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
// --- media file insert:
|
||||
|
@ -178,7 +180,7 @@ class StoredFile {
|
|||
}
|
||||
$res = $ac->rmd->insert($mediaFileLP);
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$mime = $ac->rmd->getMime();
|
||||
|
@ -186,7 +188,7 @@ class StoredFile {
|
|||
if ($mime !== FALSE) {
|
||||
$res = $ac->setMime($mime);
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
@ -195,13 +197,13 @@ class StoredFile {
|
|||
if (!$emptyState) {
|
||||
$res = $ac->setState('ready');
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
$res = $ac->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$ac->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return $ac;
|
||||
|
@ -221,15 +223,17 @@ class StoredFile {
|
|||
* optional classname to recall
|
||||
* @return StoredFile
|
||||
*/
|
||||
public function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||
public static function &recall(&$gb, $oid='', $gunid='', $className='StoredFile')
|
||||
{
|
||||
global $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
$cond = ($oid != ''
|
||||
? "id='".intval($oid)."'"
|
||||
: "gunid=x'$gunid'::bigint"
|
||||
);
|
||||
$row = $gb->dbc->getRow("
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT id, to_hex(gunid)as gunid, mime, name, ftype
|
||||
FROM {$gb->filesTable} WHERE $cond
|
||||
FROM ".$CC_CONFIG['filesTable']." WHERE $cond
|
||||
");
|
||||
if (PEAR::isError($row)) {
|
||||
return $row;
|
||||
|
@ -241,7 +245,7 @@ class StoredFile {
|
|||
);
|
||||
return $r;
|
||||
}
|
||||
$gunid = StoredFile::_normalizeGunid($row['gunid']);
|
||||
$gunid = StoredFile::NormalizeGunid($row['gunid']);
|
||||
$ac = new $className($gb, $gunid);
|
||||
$ac->mime = $row['mime'];
|
||||
$ac->name = $row['name'];
|
||||
|
@ -281,9 +285,10 @@ class StoredFile {
|
|||
*/
|
||||
public static function recallByToken(&$gb, $token, $className='StoredFile')
|
||||
{
|
||||
$gunid = $gb->dbc->getOne("
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$gunid = $CC_DBC->getOne("
|
||||
SELECT to_hex(gunid)as gunid
|
||||
FROM {$gb->accessTable}
|
||||
FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE token=x'$token'::bigint
|
||||
");
|
||||
if (PEAR::isError($gunid)) {
|
||||
|
@ -293,7 +298,7 @@ class StoredFile {
|
|||
return PEAR::raiseError(
|
||||
"StoredFile::recallByToken: invalid token ($token)", GBERR_AOBJNEX);
|
||||
}
|
||||
$gunid = StoredFile::_normalizeGunid($gunid);
|
||||
$gunid = StoredFile::NormalizeGunid($gunid);
|
||||
return StoredFile::recall($gb, '', $gunid, $className);
|
||||
}
|
||||
|
||||
|
@ -307,11 +312,11 @@ class StoredFile {
|
|||
* new local id
|
||||
* @return StoredFile
|
||||
*/
|
||||
public function ©Of(&$src, $nid)
|
||||
public static function &CopyOf(&$src, $nid)
|
||||
{
|
||||
$ac = StoredFile::insert(
|
||||
$src->gb, $nid, $src->name, $src->_getRealRADFname(),
|
||||
'', '', NULL, $src->gb->_getType($src->gunid)
|
||||
'', '', NULL, BasicStor::GetType($src->gunid)
|
||||
);
|
||||
if (PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
|
@ -339,10 +344,11 @@ class StoredFile {
|
|||
public function replace($oid, $name, $mediaFileLP='', $metadata='',
|
||||
$mdataLoc='file')
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->rename($name);
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
if ($mediaFileLP != '') { // media
|
||||
|
@ -351,7 +357,7 @@ class StoredFile {
|
|||
$res = $this->rmd->delete();
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
if ($metadata != '') { // metadata
|
||||
|
@ -360,12 +366,12 @@ class StoredFile {
|
|||
$res = $this->md->delete();
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -454,18 +460,19 @@ class StoredFile {
|
|||
*/
|
||||
public function replaceMetaData($metadata, $mdataLoc='file', $format=NULL)
|
||||
{
|
||||
$this->dbc->query("BEGIN");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->md->replace($metadata, $mdataLoc, $format);
|
||||
if (PEAR::isError($res)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$r = $this->md->regenerateXmlFile();
|
||||
if (PEAR::isError($r)) {
|
||||
$this->dbc->query("ROLLBACK");
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $r;
|
||||
}
|
||||
$res = $this->dbc->query("COMMIT");
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -508,9 +515,10 @@ class StoredFile {
|
|||
*/
|
||||
public function rename($newname)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$escapedName = pg_escape_string($newname);
|
||||
$res = $this->dbc->query("
|
||||
UPDATE {$this->filesTable} SET name='$escapedName', mtime=now()
|
||||
$res = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['filesTable']." SET name='$escapedName', mtime=now()
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -532,10 +540,11 @@ class StoredFile {
|
|||
*/
|
||||
public function setState($state, $editedby=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$escapedState = pg_escape_string($state);
|
||||
$eb = (!is_null($editedby) ? ", editedBy=$editedby" : '');
|
||||
$res = $this->dbc->query("
|
||||
UPDATE {$this->filesTable}
|
||||
$res = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['filesTable']."
|
||||
SET state='$escapedState'$eb, mtime=now()
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
|
@ -555,12 +564,13 @@ class StoredFile {
|
|||
*/
|
||||
public function setMime($mime)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if ( !is_string($mime)){
|
||||
$mime = 'application/octet-stream';
|
||||
}
|
||||
$escapedMime = pg_escape_string($mime);
|
||||
$res = $this->dbc->query("
|
||||
UPDATE {$this->filesTable} SET mime='$escapedMime', mtime=now()
|
||||
$res = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['filesTable']." SET mime='$escapedMime', mtime=now()
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -578,6 +588,7 @@ class StoredFile {
|
|||
*/
|
||||
public function delete()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$res = $this->rmd->delete();
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -586,8 +597,8 @@ class StoredFile {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$tokens = $this->dbc->getAll("
|
||||
SELECT to_hex(token)as token, ext FROM {$this->accessTable}
|
||||
$tokens = $CC_DBC->getAll("
|
||||
SELECT to_hex(token)as token, ext FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (is_array($tokens)) {
|
||||
|
@ -598,15 +609,15 @@ class StoredFile {
|
|||
}
|
||||
}
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->accessTable}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['accessTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->dbc->query("
|
||||
DELETE FROM {$this->filesTable}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -625,11 +636,12 @@ class StoredFile {
|
|||
*/
|
||||
public function isAccessed($gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($gunid)) {
|
||||
$gunid = $this->gunid;
|
||||
}
|
||||
$ca = $this->dbc->getOne("
|
||||
SELECT currentlyAccessing FROM {$this->filesTable}
|
||||
$ca = $CC_DBC->getOne("
|
||||
SELECT currentlyAccessing FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
if (is_null($ca)) {
|
||||
|
@ -672,14 +684,15 @@ class StoredFile {
|
|||
*/
|
||||
public function isEditedBy($playlistId=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($playlistId)) {
|
||||
$playlistId = $this->gunid;
|
||||
}
|
||||
$ca = $this->dbc->getOne("
|
||||
SELECT editedBy FROM {$this->filesTable}
|
||||
$ca = $CC_DBC->getOne("
|
||||
SELECT editedBy FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$playlistId'::bigint
|
||||
");
|
||||
if ($this->dbc->isError($ca)) {
|
||||
if (PEAR::isError($ca)) {
|
||||
return $ca;
|
||||
}
|
||||
if (is_null($ca)) {
|
||||
|
@ -705,8 +718,9 @@ class StoredFile {
|
|||
*/
|
||||
public function exists()
|
||||
{
|
||||
$indb = $this->dbc->getRow("
|
||||
SELECT to_hex(gunid) FROM {$this->filesTable}
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$indb = $CC_DBC->getRow("
|
||||
SELECT to_hex(gunid) FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'{$this->gunid}'::bigint
|
||||
");
|
||||
if (PEAR::isError($indb)) {
|
||||
|
@ -715,7 +729,7 @@ class StoredFile {
|
|||
if (is_null($indb)) {
|
||||
return FALSE;
|
||||
}
|
||||
if ($this->gb->_getType($this->gunid) == 'audioclip') {
|
||||
if (BasicStor::GetType($this->gunid) == 'audioclip') {
|
||||
return $this->rmd->exists();
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -727,7 +741,7 @@ class StoredFile {
|
|||
* Create new global unique id
|
||||
*
|
||||
*/
|
||||
public static function _createGunid()
|
||||
public static function CreateGunid()
|
||||
{
|
||||
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
|
||||
$initString =
|
||||
|
@ -736,15 +750,16 @@ class StoredFile {
|
|||
// non-negative int8
|
||||
$hsd = substr($hash, 0, 1);
|
||||
$res = dechex(hexdec($hsd)>>1).substr($hash, 1, 15);
|
||||
return StoredFile::_normalizeGunid($res);
|
||||
return StoredFile::NormalizeGunid($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create new global unique id
|
||||
* Pad the gunid with zeros if it isnt 16 digits.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function _normalizeGunid($gunid0)
|
||||
public static function NormalizeGunid($gunid0)
|
||||
{
|
||||
return str_pad($gunid0, 16, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
@ -763,7 +778,7 @@ class StoredFile {
|
|||
// if (is_null($gunid)) {
|
||||
// $gunid = $this->$gunid;
|
||||
// }
|
||||
// $id = $this->dbc->getOne("
|
||||
// $id = $CC_DBC->getOne("
|
||||
// SELECT id FROM {$this->filesTable}
|
||||
// WHERE gunid=x'$gunid'::bigint
|
||||
// ");
|
||||
|
@ -827,7 +842,7 @@ class StoredFile {
|
|||
// if (is_null($gunid)) {
|
||||
// $gunid = $this->gunid;
|
||||
// }
|
||||
// return $this->dbc->getOne("
|
||||
// return $CC_DBC->getOne("
|
||||
// SELECT mime FROM {$this->filesTable}
|
||||
// WHERE gunid=x'$gunid'::bigint
|
||||
// ");
|
||||
|
@ -844,11 +859,12 @@ class StoredFile {
|
|||
*/
|
||||
public function _getState($gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($gunid)) {
|
||||
$gunid = $this->gunid;
|
||||
}
|
||||
return $this->dbc->getOne("
|
||||
SELECT state FROM {$this->filesTable}
|
||||
return $CC_DBC->getOne("
|
||||
SELECT state FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
}
|
||||
|
@ -864,11 +880,12 @@ class StoredFile {
|
|||
*/
|
||||
public function _getFileName($gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($gunid)) {
|
||||
$gunid = $this->gunid;
|
||||
}
|
||||
return $this->dbc->getOne("
|
||||
SELECT name FROM {$this->filesTable}
|
||||
return $CC_DBC->getOne("
|
||||
SELECT name FROM ".$CC_CONFIG['filesTable']."
|
||||
WHERE gunid=x'$gunid'::bigint
|
||||
");
|
||||
}
|
||||
|
@ -881,8 +898,9 @@ class StoredFile {
|
|||
*/
|
||||
private function _getResDir()
|
||||
{
|
||||
$resDir="{$this->gb->storageDir}/".substr($this->gunid, 0, 3);
|
||||
#$this->gb->debugLog("$resDir");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3);
|
||||
//$this->gb->debugLog("$resDir");
|
||||
// see Transport::_getResDir too for resDir name create code
|
||||
if (!is_dir($resDir)) {
|
||||
mkdir($resDir, 02775);
|
||||
|
@ -921,8 +939,9 @@ class StoredFile {
|
|||
*/
|
||||
private function _getAccessFname($token, $ext='EXT')
|
||||
{
|
||||
$token = StoredFile::_normalizeGunid($token);
|
||||
return "{$this->accessDir}/$token.$ext";
|
||||
global $CC_CONFIG;
|
||||
$token = StoredFile::NormalizeGunid($token);
|
||||
return $CC_CONFIG['accessDir']."/$token.$ext";
|
||||
}
|
||||
|
||||
} // class StoredFile
|
||||
|
|
|
@ -50,32 +50,11 @@ include_once("TransportRecord.php");
|
|||
*/
|
||||
class Transport
|
||||
{
|
||||
/**
|
||||
* Container for db connection instance
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc;
|
||||
|
||||
/**
|
||||
* @var GreenBox
|
||||
*/
|
||||
public $gb;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $transTable;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $transDir;
|
||||
|
||||
/**
|
||||
* File name
|
||||
* @var string
|
||||
|
@ -145,10 +124,6 @@ class Transport
|
|||
public function __construct(&$gb)
|
||||
{
|
||||
$this->gb =& $gb;
|
||||
$this->dbc =& $gb->dbc;
|
||||
$this->config =& $gb->config;
|
||||
$this->transTable = $gb->config['tblNamePrefix'].'trans';
|
||||
$this->transDir = $gb->config['transDir'];
|
||||
$this->cronJobScript = realpath(
|
||||
dirname(__FILE__).
|
||||
'/../../storageServer/var/cron/transportCronJob.php'
|
||||
|
@ -307,8 +282,9 @@ class Transport
|
|||
*/
|
||||
function upload2Hub($gunid, $withContent=TRUE, $pars=array())
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$this->trLog("upload2Hub start: ".strftime("%H:%M:%S"));
|
||||
switch ($ftype = $this->gb->_getType($gunid)) {
|
||||
switch ($ftype = BasicStor::GetType($gunid)) {
|
||||
case "audioclip":
|
||||
case "webstream":
|
||||
$ac = StoredFile::recallByGunid($this->gb, $gunid);
|
||||
|
@ -345,7 +321,7 @@ class Transport
|
|||
}
|
||||
$this->startCronJobProcess($mdtrec->trtok);
|
||||
break;
|
||||
|
||||
|
||||
case "playlist":
|
||||
$plid = $gunid;
|
||||
require_once("Playlist.php");
|
||||
|
@ -364,7 +340,7 @@ class Transport
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$tmpn = tempnam($this->transDir, 'plExport_');
|
||||
$tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
$plfpath = "$tmpn.lspl";
|
||||
$this->trLog("upload2Hub begin copy: ".strftime("%H:%M:%S"));
|
||||
copy($res['fname'], $plfpath);
|
||||
|
@ -441,6 +417,7 @@ class Transport
|
|||
*/
|
||||
function globalSearch($criteria, $resultMode='php', $pars=array())
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
// testing of hub availability and hub account configuration.
|
||||
// it makes searchjob not async - should be removed for real async
|
||||
$r = $this->loginToArchive();
|
||||
|
@ -455,7 +432,7 @@ class Transport
|
|||
}
|
||||
$this->logoutFromArchive($r);
|
||||
$criteria['resultMode'] = $resultMode;
|
||||
$localfile = tempnam($this->transDir, 'searchjob_');
|
||||
$localfile = tempnam($CC_CONFIG['transDir'], 'searchjob_');
|
||||
@chmod($localfile, 0660);
|
||||
$len = file_put_contents($localfile, serialize($criteria));
|
||||
$trec = $this->_uploadGeneralFileToHub($localfile, 'searchjob', $pars);
|
||||
|
@ -579,7 +556,8 @@ class Transport
|
|||
*/
|
||||
function downloadFileFromHub($url, $chsum=NULL, $size=NULL, $pars=array())
|
||||
{
|
||||
$tmpn = tempnam($this->transDir, 'HITrans_');
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$tmpn = tempnam($CC_CONFIG['transDir'], 'HITrans_');
|
||||
$trec = TransportRecord::create($this, 'file', 'down',
|
||||
array_merge(array(
|
||||
'url' => $url,
|
||||
|
@ -730,10 +708,11 @@ class Transport
|
|||
*/
|
||||
function loginToArchive()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$res = $this->xmlrpcCall('archive.login',
|
||||
array(
|
||||
'login'=>$this->config['archiveAccountLogin'],
|
||||
'pass'=>$this->config['archiveAccountPass']
|
||||
'login' => $CC_CONFIG['archiveAccountLogin'],
|
||||
'pass' => $CC_CONFIG['archiveAccountPass']
|
||||
));
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -770,6 +749,7 @@ class Transport
|
|||
*/
|
||||
function cronMain($direction=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if (is_null($direction)) {
|
||||
$r = $this->cronMain('up');
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -795,7 +775,7 @@ class Transport
|
|||
}
|
||||
// ping to archive server:
|
||||
$r = $this->pingToArchive();
|
||||
chdir($this->config['transDir']);
|
||||
chdir($CC_CONFIG['transDir']);
|
||||
// for all opened transports:
|
||||
foreach ($transports as $i => $row) {
|
||||
$r = $this->startCronJobProcess($row['trtok']);
|
||||
|
@ -814,8 +794,9 @@ class Transport
|
|||
*/
|
||||
function startCronJobProcess($trtok)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (TR_LOG_LEVEL > 2) {
|
||||
$redirect = "{$this->transDir}/debug.log";
|
||||
$redirect = $CC_CONFIG['transDir']."/debug.log";
|
||||
} else {
|
||||
$redirect = "/dev/null";
|
||||
}
|
||||
|
@ -1029,7 +1010,7 @@ class Transport
|
|||
'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
|
||||
'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
|
||||
'fname'=>$ret['filename'],
|
||||
'localfile'=>"{$this->transDir}/$trtok",
|
||||
'localfile'=>$CC_CONFIG['transDir']."/$trtok",
|
||||
)));
|
||||
break;
|
||||
case "audioclip":
|
||||
|
@ -1048,7 +1029,7 @@ class Transport
|
|||
'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
|
||||
'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
|
||||
'fname'=>$ret['filename'], 'title'=>$title,
|
||||
'localfile'=>"{$this->transDir}/$trtok",
|
||||
'localfile'=>$CC_CONFIG['transDir']."/$trtok",
|
||||
)));
|
||||
}
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -1311,7 +1292,7 @@ class Transport
|
|||
$ep = $row['localfile'];
|
||||
@unlink($ep);
|
||||
if (preg_match("|/(plExport_[^\.]+)\.lspl$|", $ep, $va)) {
|
||||
list(,$tmpn) = $va; $tmpn = "{$this->transDir}/$tmpn";
|
||||
list(,$tmpn) = $va; $tmpn = $CC_CONFIG['transDir']."/$tmpn";
|
||||
if (file_exists($tmpn)) {
|
||||
@unlink($tmpn);
|
||||
}
|
||||
|
@ -1366,14 +1347,14 @@ class Transport
|
|||
return TRUE;
|
||||
case 'finished': // metadata finished, close main transport
|
||||
$parid = $this->gb->_getHomeDirId($trec->row['uid']);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
$mdtrec->setLock(FALSE);
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->gb->bsPutFile($parid, $row['fname'],
|
||||
$trec->row['localfile'], $mdtrec->row['localfile'],
|
||||
$row['gunid'], 'audioclip', 'file');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
$mdtrec->setLock(FALSE);
|
||||
return $res;
|
||||
}
|
||||
|
@ -1422,13 +1403,13 @@ class Transport
|
|||
switch ($row['trtype']) {
|
||||
case "playlist":
|
||||
$parid = $this->gb->_getHomeDirId($trec->row['uid']);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->gb->bsPutFile($parid, $row['fname'],
|
||||
'', $trec->row['localfile'],
|
||||
$row['gunid'], 'playlist', 'file');
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
@unlink($row['localfile']);
|
||||
|
@ -1437,11 +1418,11 @@ class Transport
|
|||
$subjid = $trec->row['uid'];
|
||||
$fname = $trec->row['localfile'];
|
||||
$parid = $this->gb->_getHomeDirId($subjid);
|
||||
if ($this->dbc->isError($parid)) {
|
||||
if (PEAR::isError($parid)) {
|
||||
return $parid;
|
||||
}
|
||||
$res = $this->gb->bsImportPlaylist($parid, $fname, $subjid);
|
||||
if ($this->dbc->isError($res)) {
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
@unlink($fname);
|
||||
|
@ -1532,6 +1513,7 @@ class Transport
|
|||
*/
|
||||
function getTransports($direction=NULL, $target=NULL, $trtok=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
switch ($direction) {
|
||||
case 'up':
|
||||
$dirCond = "direction='up' AND";
|
||||
|
@ -1553,13 +1535,13 @@ class Transport
|
|||
} else {
|
||||
$trtokCond = "trtok='$trtok' AND";
|
||||
}
|
||||
$rows = $this->dbc->getAll("
|
||||
$rows = $CC_DBC->getAll("
|
||||
SELECT
|
||||
id, trtok, state, trtype, direction,
|
||||
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
|
||||
fname, localfile, expectedsum, expectedsize, url,
|
||||
uid, target
|
||||
FROM {$this->transTable}
|
||||
FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE $dirCond $targetCond $trtokCond
|
||||
state not in ('closed', 'failed', 'paused')
|
||||
ORDER BY start DESC
|
||||
|
@ -1568,8 +1550,8 @@ class Transport
|
|||
return $rows;
|
||||
}
|
||||
foreach ($rows as $i => $row) {
|
||||
$rows[$i]['pdtoken'] = StoredFile::_normalizeGunid($row['pdtoken']);
|
||||
$rows[$i]['gunid'] = StoredFile::_normalizeGunid($row['gunid']);
|
||||
$rows[$i]['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']);
|
||||
$rows[$i]['gunid'] = StoredFile::NormalizeGunid($row['gunid']);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
@ -1617,11 +1599,11 @@ class Transport
|
|||
*/
|
||||
function xmlrpcCall($method, $pars=array())
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$xrp = XML_RPC_encode($pars);
|
||||
$c = new XML_RPC_Client(
|
||||
"{$this->config['archiveUrlPath']}/".
|
||||
"{$this->config['archiveXMLRPC']}",
|
||||
$this->config['archiveUrlHost'], $this->config['archiveUrlPort']
|
||||
$CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'],
|
||||
$CC_CONFIG['archiveUrlHost'], $CC_CONFIG['archiveUrlPort']
|
||||
);
|
||||
$f = new XML_RPC_Message($method, array($xrp));
|
||||
$r = $c->send($f);
|
||||
|
@ -1688,9 +1670,10 @@ class Transport
|
|||
*/
|
||||
function _cleanUp($interval='1 minute'/*'1 hour'*/, $forced=FALSE)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$cond = ($forced ? '' : " AND state='closed' AND lock = 'N'");
|
||||
$r = $this->dbc->query("
|
||||
DELETE FROM {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE ts < now() - interval '$interval'".$cond
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -1736,7 +1719,7 @@ class Transport
|
|||
*/
|
||||
function trLog($msg)
|
||||
{
|
||||
$logfile = "{$this->transDir}/activity.log";
|
||||
$logfile = $CC_CONFIG['transDir']."/activity.log";
|
||||
if (FALSE === ($fp = fopen($logfile, "a"))) {
|
||||
return PEAR::raiseError(
|
||||
"Transport::trLog: Can't write to log ($logfile)"
|
||||
|
@ -1758,7 +1741,8 @@ class Transport
|
|||
*/
|
||||
function resetData()
|
||||
{
|
||||
return $this->dbc->query("DELETE FROM {$this->transTable}");
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
return $CC_DBC->query("DELETE FROM ".$CC_CONFIG['transTable']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1770,76 +1754,78 @@ class Transport
|
|||
* trtype: audioclip | playlist | playlistPkg | searchjob | metadata | file
|
||||
*
|
||||
*/
|
||||
function install()
|
||||
{
|
||||
$r = $this->dbc->query("CREATE TABLE {$this->transTable} (
|
||||
id int not null, -- primary key
|
||||
trtok char(16) not null, -- transport token
|
||||
direction varchar(128) not null, -- direction: up|down
|
||||
state varchar(128) not null, -- state
|
||||
trtype varchar(128) not null, -- transport type
|
||||
lock char(1) not null default 'N',-- running lock
|
||||
target varchar(255) default NULL, -- target system,
|
||||
-- if NULL => predefined set
|
||||
rtrtok char(16) default NULL, -- remote hub's transport token
|
||||
mdtrtok char(16), -- metadata transport token
|
||||
gunid bigint, -- global unique id
|
||||
pdtoken bigint, -- put/download token from archive
|
||||
url varchar(255), -- url on remote side
|
||||
localfile varchar(255), -- pathname of local part
|
||||
fname varchar(255), -- mnemonic filename
|
||||
title varchar(255), -- dc:title mdata value (or filename ...)
|
||||
expectedsum char(32), -- expected file checksum
|
||||
realsum char(32), -- checksum of transported part
|
||||
expectedsize int, -- expected filesize in bytes
|
||||
realsize int, -- filesize of transported part
|
||||
uid int, -- local user id of transport owner
|
||||
errmsg varchar(255), -- error message string for failed tr.
|
||||
start timestamp, -- starttime
|
||||
ts timestamp -- mtime
|
||||
)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->createSequence("{$this->transTable}_id_seq");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_id_idx
|
||||
ON {$this->transTable} (id)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_trtok_idx
|
||||
ON {$this->transTable} (trtok)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE UNIQUE INDEX {$this->transTable}_token_idx
|
||||
ON {$this->transTable} (pdtoken)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE INDEX {$this->transTable}_gunid_idx
|
||||
ON {$this->transTable} (gunid)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
$r = $this->dbc->query("CREATE INDEX {$this->transTable}_state_idx
|
||||
ON {$this->transTable} (state)");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()." ".$r->getUserInfo();
|
||||
}
|
||||
}
|
||||
// function install()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $r = $CC_DBC->query("CREATE TABLE {$this->transTable} (
|
||||
// id int not null, -- primary key
|
||||
// trtok char(16) not null, -- transport token
|
||||
// direction varchar(128) not null, -- direction: up|down
|
||||
// state varchar(128) not null, -- state
|
||||
// trtype varchar(128) not null, -- transport type
|
||||
// lock char(1) not null default 'N',-- running lock
|
||||
// target varchar(255) default NULL, -- target system,
|
||||
// -- if NULL => predefined set
|
||||
// rtrtok char(16) default NULL, -- remote hub's transport token
|
||||
// mdtrtok char(16), -- metadata transport token
|
||||
// gunid bigint, -- global unique id
|
||||
// pdtoken bigint, -- put/download token from archive
|
||||
// url varchar(255), -- url on remote side
|
||||
// localfile varchar(255), -- pathname of local part
|
||||
// fname varchar(255), -- mnemonic filename
|
||||
// title varchar(255), -- dc:title mdata value (or filename ...)
|
||||
// expectedsum char(32), -- expected file checksum
|
||||
// realsum char(32), -- checksum of transported part
|
||||
// expectedsize int, -- expected filesize in bytes
|
||||
// realsize int, -- filesize of transported part
|
||||
// uid int, -- local user id of transport owner
|
||||
// errmsg varchar(255), -- error message string for failed tr.
|
||||
// start timestamp, -- starttime
|
||||
// ts timestamp -- mtime
|
||||
// )");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->createSequence("{$this->transTable}_id_seq");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE UNIQUE INDEX {$this->transTable}_id_idx
|
||||
// ON {$this->transTable} (id)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE UNIQUE INDEX {$this->transTable}_trtok_idx
|
||||
// ON {$this->transTable} (trtok)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE UNIQUE INDEX {$this->transTable}_token_idx
|
||||
// ON {$this->transTable} (pdtoken)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE INDEX {$this->transTable}_gunid_idx
|
||||
// ON {$this->transTable} (gunid)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// $r = $CC_DBC->query("CREATE INDEX {$this->transTable}_state_idx
|
||||
// ON {$this->transTable} (state)");
|
||||
// if (PEAR::isError($r)) {
|
||||
// echo $r->getMessage()." ".$r->getUserInfo();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Uninstall method
|
||||
*/
|
||||
function uninstall()
|
||||
{
|
||||
$this->dbc->query("DROP TABLE {$this->transTable}");
|
||||
$this->dbc->dropSequence("{$this->transTable}_id_seq");
|
||||
}
|
||||
// function uninstall()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("DROP TABLE {$this->transTable}");
|
||||
// $CC_DBC->dropSequence("{$this->transTable}_id_seq");
|
||||
// }
|
||||
}
|
||||
|
||||
?>
|
|
@ -19,7 +19,7 @@ class TransportRecord
|
|||
/**
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc;
|
||||
//public $dbc;
|
||||
|
||||
/**
|
||||
* @var GreenBox
|
||||
|
@ -29,12 +29,7 @@ class TransportRecord
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $transTable;
|
||||
//private $config;
|
||||
|
||||
/**
|
||||
* @var Transport
|
||||
|
@ -60,9 +55,6 @@ class TransportRecord
|
|||
{
|
||||
$this->tr =& $tr;
|
||||
$this->gb =& $tr->gb;
|
||||
$this->dbc =& $tr->gb->dbc;
|
||||
$this->config = $tr->gb->config;
|
||||
$this->transTable = $tr->gb->config['tblNamePrefix'].'trans';
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,6 +72,7 @@ class TransportRecord
|
|||
*/
|
||||
function create(&$tr, $trtype, $direction='up', $defaults=array())
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$trec = new TransportRecord($tr);
|
||||
$trec->trtok = $trtok = $tr->_createTransportToken();
|
||||
$trec->row = array_merge($defaults,
|
||||
|
@ -91,7 +84,7 @@ class TransportRecord
|
|||
return $defaults['title'];
|
||||
}
|
||||
}
|
||||
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
|
||||
$id = $CC_DBC->nextId($CC_CONFIG['transTable']."_id_seq");
|
||||
$names = "id, trtok, direction, state, trtype, start, ts";
|
||||
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
|
||||
foreach ($defaults as $k => $v) {
|
||||
|
@ -100,12 +93,12 @@ class TransportRecord
|
|||
$values .= ", $sqlVal";
|
||||
}
|
||||
$query = "
|
||||
INSERT INTO {$trec->transTable}
|
||||
INSERT INTO ".$CC_CONFIG['transTable']."
|
||||
($names)
|
||||
VALUES
|
||||
($values)
|
||||
";
|
||||
$res = $trec->dbc->query($query);
|
||||
$res = $CC_DBC->query($query);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -123,16 +116,17 @@ class TransportRecord
|
|||
*/
|
||||
function recall(&$tr, $trtok)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$trec = new TransportRecord($tr);
|
||||
$trec->trtok = $trtok;
|
||||
$row = $trec->dbc->getRow("
|
||||
$row = $CC_DBC->getRow("
|
||||
SELECT
|
||||
id, trtok, state, trtype, direction,
|
||||
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
|
||||
fname, localfile, url, rtrtok, mdtrtok, uid,
|
||||
expectedsize, realsize, expectedsum, realsum,
|
||||
errmsg, title
|
||||
FROM {$trec->transTable}
|
||||
FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE trtok='$trtok'
|
||||
");
|
||||
if (PEAR::isError($row)) {
|
||||
|
@ -143,8 +137,8 @@ class TransportRecord
|
|||
" invalid transport token ($trtok)", TRERR_TOK
|
||||
);
|
||||
}
|
||||
$row['pdtoken'] = StoredFile::_normalizeGunid($row['pdtoken']);
|
||||
$row['gunid'] = StoredFile::_normalizeGunid($row['gunid']);
|
||||
$row['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']);
|
||||
$row['gunid'] = StoredFile::NormalizeGunid($row['gunid']);
|
||||
$trec->row = $row;
|
||||
$trec->recalled = TRUE;
|
||||
return $trec;
|
||||
|
@ -165,6 +159,7 @@ class TransportRecord
|
|||
*/
|
||||
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$set = " state='$newState', ts=now()";
|
||||
if (!is_null($lock)) {
|
||||
$slock = ($lock ? 'Y' : 'N');
|
||||
|
@ -175,8 +170,8 @@ class TransportRecord
|
|||
foreach ($data as $k => $v) {
|
||||
$set .= ", $k=".$this->_getSqlVal($k, $v);
|
||||
}
|
||||
$r = $this->dbc->query("
|
||||
UPDATE {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['transTable']."
|
||||
SET $set
|
||||
WHERE trtok='{$this->trtok}'".
|
||||
(is_null($oldState) ? '' : " AND state='$oldState'").
|
||||
|
@ -186,7 +181,7 @@ class TransportRecord
|
|||
return $r;
|
||||
}
|
||||
// return TRUE;
|
||||
$affRows = $this->dbc->affectedRows();
|
||||
$affRows = $CC_DBC->affectedRows();
|
||||
if (PEAR::isError($affRows)) {
|
||||
return $affRows;
|
||||
}
|
||||
|
@ -221,21 +216,22 @@ class TransportRecord
|
|||
*/
|
||||
function setLock($lock)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if ($this->dropped) {
|
||||
return TRUE;
|
||||
}
|
||||
$slock = ($lock ? 'Y' : 'N');
|
||||
$nlock = (!$lock);
|
||||
$snlock = ($nlock ? 'Y' : 'N');
|
||||
$r = $this->dbc->query("
|
||||
UPDATE {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
UPDATE ".$CC_CONFIG['transTable']."
|
||||
SET lock='$slock', ts=now()
|
||||
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
|
||||
);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$affRows = $this->dbc->affectedRows();
|
||||
$affRows = $CC_DBC->affectedRows();
|
||||
if (PEAR::isError($affRows)) {
|
||||
return $affRows;
|
||||
}
|
||||
|
@ -304,6 +300,7 @@ class TransportRecord
|
|||
*/
|
||||
function close()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!$this->recalled) {
|
||||
return PEAR::raiseError("TransportRecord::close:".
|
||||
" not recalled ({$this->trtok})", TRERR_TOK
|
||||
|
@ -315,8 +312,8 @@ class TransportRecord
|
|||
return $r;
|
||||
}
|
||||
} else {
|
||||
$r = $this->dbc->query("
|
||||
DELETE FROM {$this->transTable}
|
||||
$r = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['transTable']."
|
||||
WHERE trtok='{$this->trtok}'
|
||||
");
|
||||
if (PEAR::isError($r)) {
|
||||
|
|
|
@ -329,17 +329,6 @@ $audioClipFormat = array(
|
|||
'type'=>'Int',
|
||||
// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$',
|
||||
),
|
||||
/*
|
||||
''=>array(
|
||||
'type'=>'',
|
||||
'area'=>'',
|
||||
'attrs'=>array(),
|
||||
),
|
||||
*/
|
||||
);
|
||||
|
||||
/*
|
||||
?
|
||||
ls:filename Text auto
|
||||
*/
|
||||
?>
|
|
@ -18,13 +18,13 @@
|
|||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (DB::isError($dbc)) {
|
||||
die($dbc->getMessage());
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$bs = new BasicStor($dbc, $config);
|
||||
$bs = new BasicStor();
|
||||
|
||||
$pass = $argv[1];
|
||||
$r = $bs->passwd('scheduler', NULL, $pass);
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
/**
|
||||
* StorageServer configuration file
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
/**
|
||||
* configuration structure:
|
||||
*
|
||||
* <dl>
|
||||
|
@ -39,9 +31,12 @@ define('CAMPCASTER_VERSION', '1.1.1');
|
|||
* </dl>
|
||||
*/
|
||||
|
||||
// these are the default values for the config
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
$config = array(
|
||||
// these are the default values for the config
|
||||
global $CC_CONFIG;
|
||||
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'test',
|
||||
|
@ -51,7 +46,6 @@ $config = array(
|
|||
'database' => 'Campcaster-test',
|
||||
),
|
||||
'tblNamePrefix' => 'ls_',
|
||||
|
||||
/* ================================================ storage configuration */
|
||||
'authCookieName'=> 'campcaster_session_id',
|
||||
'AdminsGr' => 'Admins',
|
||||
|
@ -123,11 +117,27 @@ $config = array(
|
|||
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
|
||||
'paramdir' => dirname(__FILE__).'/cron/params',
|
||||
);
|
||||
$config['sysSubjs'] = array(
|
||||
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||
|
||||
// Add database table names
|
||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
|
||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||
$CC_CONFIG['classTable'] = $CC_CONFIG['tblNamePrefix'].'classes';
|
||||
$CC_CONFIG['cmembTable'] = $CC_CONFIG['tblNamePrefix'].'cmemb';
|
||||
$CC_CONFIG['treeTable'] = $CC_CONFIG['tblNamePrefix'].'tree';
|
||||
$CC_CONFIG['structTable'] = $CC_CONFIG['tblNamePrefix'].'struct';
|
||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||
|
||||
$CC_CONFIG['sysSubjs'] = array(
|
||||
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr']
|
||||
);
|
||||
$old_ip = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
|
||||
// see if a ~/.campcaster/storageServer.conf.php exists, and
|
||||
// overwrite the settings from there if any
|
||||
|
@ -145,23 +155,23 @@ if (!is_null($this_file)) {
|
|||
$fileowner_name = $fileowner_array['name'];
|
||||
$home_conf = $fileowner_homedir . '/.campcaster/storageServer.conf.php';
|
||||
if (file_exists($home_conf)) {
|
||||
$default_config = $config;
|
||||
$default_config = $CC_CONFIG;
|
||||
$developer_name = $fileowner_name;
|
||||
include($home_conf);
|
||||
$user_config = $config;
|
||||
$config = $user_config + $default_config;
|
||||
$user_config = $CC_CONFIG;
|
||||
$CC_CONFIG = $user_config + $default_config;
|
||||
}
|
||||
}
|
||||
|
||||
// make dirpaths better (without ../)
|
||||
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
|
||||
$rp = realpath($config[$d]);
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
// workaround for missing dirs
|
||||
if ( $rp === FALSE ) {
|
||||
mkdir( $config[$d] );
|
||||
$rp = realpath($config[$d]);
|
||||
mkdir( $CC_CONFIG[$d] );
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
}
|
||||
$config[$d] = $rp;
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -1,13 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* StorageServer configuration file
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
/**
|
||||
*
|
||||
* configuration structure:
|
||||
*
|
||||
* <dl>
|
||||
|
@ -38,9 +32,11 @@ define('CAMPCASTER_VERSION', '1.1.1');
|
|||
* </dl>
|
||||
*/
|
||||
|
||||
define('CAMPCASTER_VERSION', '1.1.1');
|
||||
|
||||
// these are the default values for the config
|
||||
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'ls_dbuser',
|
||||
|
@ -121,21 +117,37 @@ $config = array(
|
|||
'cronfile' => dirname(__FILE__).'/cron/croncall.php',
|
||||
'paramdir' => dirname(__FILE__).'/cron/params',
|
||||
);
|
||||
$config['sysSubjs'] = array(
|
||||
'root', $config['AdminsGr'], $config['AllGr'], $config['StationPrefsGr']
|
||||
|
||||
// Add database table names
|
||||
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
|
||||
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
|
||||
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
|
||||
$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms';
|
||||
$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess';
|
||||
$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
|
||||
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
|
||||
$CC_CONFIG['classTable'] = $CC_CONFIG['tblNamePrefix'].'classes';
|
||||
$CC_CONFIG['cmembTable'] = $CC_CONFIG['tblNamePrefix'].'cmemb';
|
||||
$CC_CONFIG['treeTable'] = $CC_CONFIG['tblNamePrefix'].'tree';
|
||||
$CC_CONFIG['structTable'] = $CC_CONFIG['tblNamePrefix'].'struct';
|
||||
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
|
||||
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
|
||||
|
||||
$CC_CONFIG['sysSubjs'] = array(
|
||||
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr']
|
||||
);
|
||||
$old_ip = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$config['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip);
|
||||
|
||||
// make dirpaths better (without ../)
|
||||
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
|
||||
$rp = realpath($config[$d]);
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
// workaround for missing dirs
|
||||
if ( $rp === FALSE ) {
|
||||
mkdir( $config[$d] );
|
||||
$rp = realpath($config[$d]);
|
||||
mkdir( $CC_CONFIG[$d] );
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
}
|
||||
$config[$d] = $rp;
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,11 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* StorageServer configuration file
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* configuration structure:
|
||||
*
|
||||
* <dl>
|
||||
|
@ -30,7 +26,7 @@
|
|||
* for login to archive
|
||||
* </dl>
|
||||
*/
|
||||
$config = array(
|
||||
$CC_CONFIG = array(
|
||||
/* ================================================== basic configuration */
|
||||
'dsn' => array(
|
||||
'username' => 'ls_dbuser',
|
||||
|
@ -66,4 +62,4 @@ $config = array(
|
|||
'cronUserName' => $developer_name,
|
||||
|
||||
);
|
||||
?>
|
||||
?>
|
|
@ -9,7 +9,7 @@ require_once (dirname(__FILE__).'/../conf.php');
|
|||
* $access = $cron->openCrontab('write');
|
||||
* if ($access != 'write') {
|
||||
* do {
|
||||
* $access = $this->forceWriteable();
|
||||
* $access = $cron->forceWriteable();
|
||||
* } while ($access != 'write');
|
||||
* }
|
||||
* $cron->addCronJob('*','*','*','*','*',
|
||||
|
@ -46,11 +46,11 @@ class Cron {
|
|||
* Constructor
|
||||
*/
|
||||
function Cron() {
|
||||
global $config;
|
||||
$this->lockfile = $config['lockfile'];
|
||||
$this->cronfile = $config['cronfile'];
|
||||
$this->paramdir = $config['paramdir'];
|
||||
$this->cronUserName = $config['cronUserName'];
|
||||
global $CC_CONFIG;
|
||||
$this->lockfile = $CC_CONFIG['lockfile'];
|
||||
$this->cronfile = $CC_CONFIG['cronfile'];
|
||||
$this->paramdir = $CC_CONFIG['paramdir'];
|
||||
$this->cronUserName = $CC_CONFIG['cronUserName'];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once dirname(__FILE__).'/../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once dirname(__FILE__).'/../LocStor.php';
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/../LocStor.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$gb = new LocStor($dbc, $config);
|
||||
$gb = new LocStor();
|
||||
$tr = new Transport($gb);
|
||||
|
||||
$r = $tr->cronMain();
|
||||
if(!$r) exit(1);
|
||||
if (!$r) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
?>
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once dirname(__FILE__).'/../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once dirname(__FILE__).'/../LocStor.php';
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/../LocStor.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$gb = new LocStor($dbc, $config);
|
||||
$gb = new LocStor();
|
||||
$tr = new Transport($gb);
|
||||
|
||||
list(, $trtok) = $_SERVER['argv'];
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
* This (web-callable) script returns group running httpd
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
$egid = posix_getegid();
|
||||
$info = posix_getgrgid($egid);
|
||||
if($_SERVER["REMOTE_ADDR"] == "127.0.0.1") echo $info['name'];
|
||||
header("Content-type: text/plain");
|
||||
$egid = posix_getegid();
|
||||
$info = posix_getgrgid($egid);
|
||||
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") {
|
||||
echo $info['name'];
|
||||
}
|
||||
?>
|
|
@ -3,6 +3,8 @@
|
|||
* This script returns real dir of php scipts for debugging purposes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
if($_SERVER["REMOTE_ADDR"] == "127.0.0.1") echo `pwd`;
|
||||
header("Content-type: text/plain");
|
||||
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") {
|
||||
echo `pwd`;
|
||||
}
|
||||
?>
|
|
@ -3,8 +3,8 @@
|
|||
* This script returns storage root URL
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require "../conf.php";
|
||||
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}";
|
||||
header("Content-type: text/plain");
|
||||
require("../conf.php");
|
||||
echo "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}";
|
||||
?>
|
|
@ -3,8 +3,8 @@
|
|||
* This script returns storage XMLRPC root URL
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require "../conf.php";
|
||||
echo "http://{$config['storageUrlHost']}:{$config['storageUrlPort']}".
|
||||
"{$config['storageUrlPath']}/{$config['storageXMLRPC']}";
|
||||
header("Content-type: text/plain");
|
||||
require("../conf.php");
|
||||
echo "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}".
|
||||
"{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}";
|
||||
?>
|
|
@ -1,120 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*
|
||||
* Note: This file was broken into two parts: install.php and
|
||||
* installMain.php so that the archive server could use the same
|
||||
* installation script, but with just a different config file.
|
||||
*/
|
||||
|
||||
// no remote execution
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != "") {
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once "../Transport.php";
|
||||
require_once "../Prefs.php";
|
||||
echo "*************************\n";
|
||||
echo "* StorageServer Install *\n";
|
||||
echo "*************************\n";
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if (assert_options(ASSERT_ACTIVE) == 1) {
|
||||
return;
|
||||
}
|
||||
echo "ERROR:\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo().
|
||||
"\nui:\n".$err->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
require_once('../conf.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('installMain.php');
|
||||
require_once('installStorage.php');
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
echo "**********************************\n";
|
||||
echo "* StorageServer Install Complete *\n";
|
||||
echo "**********************************\n";
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if (PEAR::isError($dbc)) {
|
||||
echo $dbc->getMessage()."\n";
|
||||
echo $dbc->getUserInfo()."\n";
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in var/conf.php ".
|
||||
"(in storageServer directory).\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config, TRUE);
|
||||
$tr = new Transport($gb);
|
||||
$pr = new Prefs($gb);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// install
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
echo "#StorageServer install:\n";
|
||||
echo "# Install ...\n";
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n");
|
||||
#$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$r = $gb->install();
|
||||
if(PEAR::isError($r)){ echo $r->getMessage()."\n"; echo $r->getUserInfo()."\n"; exit(1); }
|
||||
#if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit(1); }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Storage directory writability test
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if(!($fp = @fopen($config['storageDir']."/_writeTest", 'w'))){
|
||||
echo "\n<b>make {$config['storageDir']} dir webdaemon-writeable</b>".
|
||||
"\nand run install again\n\n";
|
||||
exit(1);
|
||||
}else{
|
||||
fclose($fp); unlink($config['storageDir']."/_writeTest");
|
||||
echo "#storageServer main: OK\n";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Submodules
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
echo "# Install Transport submodule ...";
|
||||
$r = $tr->install();
|
||||
if(PEAR::isError($r)){ echo $r->getMessage()."\n"; echo $r->getUserInfo()."\n"; exit(1); }
|
||||
echo "\n";
|
||||
|
||||
echo "# Install Prefs submodule ...";
|
||||
$r = $pr->install();
|
||||
if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit(1); }
|
||||
echo "\n";
|
||||
|
||||
echo "# submodules: OK\n";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Cron configuration
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
echo "# Cron configuration ...";
|
||||
require_once dirname(__FILE__).'/../cron/Cron.php';
|
||||
$cron = new Cron();
|
||||
$access = $r = $cron->openCrontab('write');
|
||||
if ($access != 'write') {
|
||||
do {
|
||||
$r = $this->forceWriteable();
|
||||
} while ($r);
|
||||
}
|
||||
$cron->ct->addCron('*/2', '*', '*', '*', '*', realpath("{$config['cronDir']}/transportCron.php"));
|
||||
$r = $cron->closeCrontab();
|
||||
echo "# cron config: OK\n";
|
||||
|
||||
echo "#storageServer: OK\n\n";
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
||||
?>
|
|
@ -0,0 +1,371 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision: 2475 $
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
function camp_db_table_exists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo $CC_DBC->getMessage()."\n";
|
||||
echo $CC_DBC->getUserInfo()."\n";
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in var/conf.php ".
|
||||
"(in storageServer directory).\n";
|
||||
exit(1);
|
||||
} else {
|
||||
echo " * Connected to database\n";
|
||||
}
|
||||
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Install database tables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['treeTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['treeTable']."...";
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['treeTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
name varchar(255) not null default'',
|
||||
-- parid int,
|
||||
type varchar(255) not null default'',
|
||||
param varchar(255))");
|
||||
if (PEAR::isError($r)) {
|
||||
echo $r->getMessage()."\n";
|
||||
}
|
||||
$CC_DBC->createSequence($CC_CONFIG['treeTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['treeTable']."_id_idx
|
||||
ON ".$CC_CONFIG['treeTable']." (id)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['treeTable']."_name_idx
|
||||
ON ".$CC_CONFIG['treeTable']." (name)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['treeTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['structTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['structTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['structTable']." (
|
||||
rid int not null PRIMARY KEY,
|
||||
objid int not null REFERENCES ".$CC_CONFIG['treeTable']." ON DELETE CASCADE,
|
||||
parid int not null REFERENCES ".$CC_CONFIG['treeTable']." ON DELETE CASCADE,
|
||||
level int
|
||||
)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['structTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['structTable']."_rid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (rid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['structTable']."_objid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (objid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['structTable']."_parid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (parid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['structTable']."_level_idx
|
||||
ON ".$CC_CONFIG['structTable']." (level)");
|
||||
$CC_DBC->query("
|
||||
CREATE UNIQUE INDEX ".$CC_CONFIG['structTable']."_objid_level_idx
|
||||
ON ".$CC_CONFIG['structTable']." (objid, level)
|
||||
");
|
||||
$CC_DBC->query("
|
||||
CREATE UNIQUE INDEX ".$CC_CONFIG['structTable']."_objid_parid_idx
|
||||
ON ".$CC_CONFIG['structTable']." (objid, parid)
|
||||
");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['structTable']."\n";
|
||||
}
|
||||
|
||||
//
|
||||
// Insert the RootNode if its not there yet.
|
||||
//
|
||||
$sql = "SELECT * FROM ".$CC_CONFIG['treeTable']
|
||||
." WHERE name='".$CC_CONFIG['RootNode']."'"
|
||||
." AND type='RootNode'";
|
||||
$row = $CC_DBC->GetRow($sql);
|
||||
if (!PEAR::isError($row) && !$row) {
|
||||
echo " * Creating ROOT NODE in ".$CC_CONFIG['treeTable']."...";
|
||||
$oid = $CC_DBC->nextId($CC_CONFIG['treeTable']."_id_seq");
|
||||
if (PEAR::isError($oid)) {
|
||||
echo $oid->getMessage()."\n";
|
||||
//print_r($oid);
|
||||
exit();
|
||||
}
|
||||
$CC_DBC->query("
|
||||
INSERT INTO ".$CC_CONFIG['treeTable']."
|
||||
(id, name, type)
|
||||
VALUES
|
||||
($oid, '".$CC_CONFIG['RootNode']."', 'RootNode')
|
||||
");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: Root node already exists in ".$CC_CONFIG['treeTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['classTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['classTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['classTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
cname varchar(20)
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['classTable']."_id_idx
|
||||
ON ".$CC_CONFIG['classTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['classTable']."_cname_idx
|
||||
ON ".$CC_CONFIG['classTable']." (cname)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['classTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['cmembTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['cmembTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['cmembTable']." (
|
||||
objid int not null,
|
||||
cid int not null
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['cmembTable']."_idx
|
||||
ON ".$CC_CONFIG['cmembTable']." (objid, cid)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['cmembTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['subjTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['subjTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['subjTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
login varchar(255) not null default'',
|
||||
pass varchar(255) not null default'',
|
||||
type char(1) not null default 'U',
|
||||
realname varchar(255) not null default'',
|
||||
lastlogin timestamp,
|
||||
lastfail timestamp
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_id_idx
|
||||
ON ".$CC_CONFIG['subjTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_login_idx
|
||||
ON ".$CC_CONFIG['subjTable']." (login)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['subjTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['subjTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['smembTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['smembTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['smembTable']." (
|
||||
id int not null PRIMARY KEY,
|
||||
uid int not null default 0,
|
||||
gid int not null default 0,
|
||||
level int not null default 0,
|
||||
mid int
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['smembTable']."_id_idx
|
||||
ON ".$CC_CONFIG['smembTable']." (id)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['smembTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['smembTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['permTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['permTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['permTable']." (
|
||||
permid int not null PRIMARY KEY,
|
||||
subj int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
action varchar(20),
|
||||
obj int,
|
||||
type char(1)
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_permid_idx
|
||||
ON ".$CC_CONFIG['permTable']." (permid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['permTable']."_subj_obj_idx
|
||||
ON ".$CC_CONFIG['permTable']." (subj, obj)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_all_idx
|
||||
ON ".$CC_CONFIG['permTable']." (subj, action, obj)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['permTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['permTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['sessTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['sessTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['sessTable']." (
|
||||
sessid char(32) not null PRIMARY KEY,
|
||||
userid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
login varchar(255),
|
||||
ts timestamp
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['sessTable']."_sessid_idx
|
||||
ON ".$CC_CONFIG['sessTable']." (sessid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['sessTable']."_userid_idx
|
||||
ON ".$CC_CONFIG['sessTable']." (userid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['sessTable']."_login_idx
|
||||
ON ".$CC_CONFIG['sessTable']." (login)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['sessTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['filesTable']."...";
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['filesTable']." (
|
||||
id int not null,
|
||||
gunid bigint not null, -- global unique ID
|
||||
name varchar(255) not null default'', -- human file id ;)
|
||||
mime varchar(255) not null default'', -- mime type
|
||||
ftype varchar(128) not null default'', -- file type
|
||||
state varchar(128) not null default'empty', -- file state
|
||||
currentlyaccessing int not null default 0, -- access counter
|
||||
editedby int REFERENCES ".$CC_CONFIG['subjTable'].", -- who edits it
|
||||
mtime timestamp(6) with time zone -- lst modif.time
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_id_idx
|
||||
ON ".$CC_CONFIG['filesTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['filesTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx
|
||||
ON ".$CC_CONFIG['filesTable']." (name)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['mdataTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['mdataTable']."...";
|
||||
$CC_DBC->createSequence($CC_CONFIG['mdataTable']."_id_seq");
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['mdataTable']." (
|
||||
id int not null,
|
||||
gunid bigint,
|
||||
subjns varchar(255), -- subject namespace shortcut/uri
|
||||
subject varchar(255) not null default '',
|
||||
predns varchar(255), -- predicate namespace shortcut/uri
|
||||
predicate varchar(255) not null,
|
||||
predxml char(1) not null default 'T', -- Tag or Attribute
|
||||
objns varchar(255), -- object namespace shortcut/uri
|
||||
object text
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['mdataTable']."_id_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (id)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['mdataTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['mdataTable']."_subj_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (subjns, subject)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['mdataTable']."_pred_idx
|
||||
ON ".$CC_CONFIG['mdataTable']." (predns, predicate)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['mdataTable']."\n";
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['accessTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['accessTable']."...";
|
||||
$r = $CC_DBC->query("CREATE TABLE ".$CC_CONFIG['accessTable']." (
|
||||
gunid bigint, -- global unique id
|
||||
token bigint, -- access token
|
||||
chsum char(32) not null default'', -- md5 checksum
|
||||
ext varchar(128) not null default'', -- extension
|
||||
type varchar(20) not null default'', -- access type
|
||||
parent bigint, -- parent token
|
||||
owner int REFERENCES ".$CC_CONFIG['subjTable'].", -- subject have started it
|
||||
ts timestamp
|
||||
)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['accessTable']."_token_idx
|
||||
ON ".$CC_CONFIG['accessTable']." (token)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['accessTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['accessTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['accessTable']."_parent_idx
|
||||
ON ".$CC_CONFIG['accessTable']." (parent)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['accessTable']."\n";
|
||||
}
|
||||
|
||||
echo " * Inserting starting data into tables...";
|
||||
$gb = new GreenBox();
|
||||
$r = $gb->initData();
|
||||
echo "done.\n";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Submodules
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['transTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['transTable']."...";
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['transTable']." (
|
||||
id int not null, -- primary key
|
||||
trtok char(16) not null, -- transport token
|
||||
direction varchar(128) not null, -- direction: up|down
|
||||
state varchar(128) not null, -- state
|
||||
trtype varchar(128) not null, -- transport type
|
||||
lock char(1) not null default 'N',-- running lock
|
||||
target varchar(255) default NULL, -- target system,
|
||||
-- if NULL => predefined set
|
||||
rtrtok char(16) default NULL, -- remote hub's transport token
|
||||
mdtrtok char(16), -- metadata transport token
|
||||
gunid bigint, -- global unique id
|
||||
pdtoken bigint, -- put/download token from archive
|
||||
url varchar(255), -- url on remote side
|
||||
localfile varchar(255), -- pathname of local part
|
||||
fname varchar(255), -- mnemonic filename
|
||||
title varchar(255), -- dc:title mdata value (or filename ...)
|
||||
expectedsum char(32), -- expected file checksum
|
||||
realsum char(32), -- checksum of transported part
|
||||
expectedsize int, -- expected filesize in bytes
|
||||
realsize int, -- filesize of transported part
|
||||
uid int, -- local user id of transport owner
|
||||
errmsg varchar(255), -- error message string for failed tr.
|
||||
start timestamp, -- starttime
|
||||
ts timestamp -- mtime
|
||||
)");
|
||||
$CC_DBC->createSequence($CC_CONFIG['transTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_id_idx
|
||||
ON ".$CC_CONFIG['transTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_trtok_idx
|
||||
ON ".$CC_CONFIG['transTable']." (trtok)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_token_idx
|
||||
ON ".$CC_CONFIG['transTable']." (pdtoken)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['transTable']."_gunid_idx
|
||||
ON ".$CC_CONFIG['transTable']." (gunid)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['transTable']."_state_idx
|
||||
ON ".$CC_CONFIG['transTable']." (state)");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['transTable']."\n";
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
|
||||
echo " * Creating database table ".$CC_CONFIG['prefTable']."...";
|
||||
$CC_DBC->createSequence($CC_CONFIG['prefTable']."_id_seq");
|
||||
$CC_DBC->query("CREATE TABLE ".$CC_CONFIG['prefTable']." (
|
||||
id int not null,
|
||||
subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
|
||||
keystr varchar(255),
|
||||
valstr text
|
||||
)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_id_idx
|
||||
ON ".$CC_CONFIG['prefTable']." (id)");
|
||||
$CC_DBC->query("CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_subj_key_idx
|
||||
ON ".$CC_CONFIG['prefTable']." (subjid, keystr)");
|
||||
$CC_DBC->query("CREATE INDEX ".$CC_CONFIG['prefTable']."_subjid_idx
|
||||
ON ".$CC_CONFIG['prefTable']." (subjid)");
|
||||
echo "done.\n";
|
||||
|
||||
echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."...";
|
||||
$stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
|
||||
Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1");
|
||||
$genres = file_get_contents( dirname(__FILE__).'/../genres.xml');
|
||||
Prefs::Insert($stPrefGr, 'genres', $genres);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Install storage directories
|
||||
//------------------------------------------------------------------------
|
||||
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
if ( $rp === FALSE ) {
|
||||
echo " * Creating directory ".$CC_CONFIG[$d]."...";
|
||||
mkdir($CC_CONFIG[$d], 02775);
|
||||
echo "done.\n";
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
} else {
|
||||
echo " * Skipping: directory already exists: $rp\n";
|
||||
}
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Storage directory writability test
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
echo " * Testing writability of ".$CC_CONFIG['storageDir']."...";
|
||||
if (!($fp = @fopen($CC_CONFIG['storageDir']."/_writeTest", 'w'))) {
|
||||
echo "\nPlease make directory {$CC_CONFIG['storageDir']} writeable by your webserver".
|
||||
"\nand run install again\n\n";
|
||||
exit(1);
|
||||
} else {
|
||||
fclose($fp);
|
||||
unlink($CC_CONFIG['storageDir']."/_writeTest");
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Install Cron job
|
||||
//------------------------------------------------------------------------
|
||||
require_once(dirname(__FILE__).'/../cron/Cron.php');
|
||||
|
||||
echo " * Adding cron job...";
|
||||
$cron = new Cron();
|
||||
$access = $cron->openCrontab('write');
|
||||
if ($access != 'write') {
|
||||
do {
|
||||
$r = $cron->forceWriteable();
|
||||
} while ($r);
|
||||
}
|
||||
$cron->ct->addCron('*/2', '*', '*', '*', '*', realpath("{$CC_CONFIG['cronDir']}/transportCron.php"));
|
||||
$cron->closeCrontab();
|
||||
echo "done.\n";
|
||||
|
||||
?>
|
|
@ -1,65 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* @author $Author$
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision$
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// no remote execution
|
||||
// Do not allow remote execution.
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if(isset($arr["DOCUMENT_ROOT"]) && $arr["DOCUMENT_ROOT"] != ""){
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once "../Transport.php";
|
||||
require_once "../Prefs.php";
|
||||
|
||||
function errCallback($err)
|
||||
{
|
||||
if(assert_options(ASSERT_ACTIVE)==1) return;
|
||||
echo "ERROR:\n";
|
||||
echo "request: "; print_r($_REQUEST);
|
||||
echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo().
|
||||
"\nui:\n".$err->getUserInfo()."\n</pre>\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "***************************\n";
|
||||
echo "* StorageServer Uninstall *\n";
|
||||
echo "***************************\n";
|
||||
|
||||
require_once('../conf.php');
|
||||
require_once('uninstallMain.php');
|
||||
require_once('uninstallStorage.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
if(PEAR::isError($dbc)){
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '{$config['dsn']['database']}' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "************************************\n";
|
||||
echo "* StorageServer Uninstall Complete *\n";
|
||||
echo "************************************\n";
|
||||
|
||||
echo "#StorageServer uninstall:\n";
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config, TRUE);
|
||||
$tr = new Transport($gb);
|
||||
$pr = new Prefs($gb);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
echo "# Uninstall Prefs submodule";
|
||||
$r = $pr->uninstall();
|
||||
if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit; }
|
||||
echo "\n";
|
||||
|
||||
echo "# Uninstall Transport submodule ...";
|
||||
$r = $tr->uninstall();
|
||||
if(PEAR::isError($r)){ echo $r->getUserInfo()."\n"; exit; }
|
||||
echo "\n";
|
||||
|
||||
echo "# Uninstall StorageServer ...\n";
|
||||
$gb->uninstall();
|
||||
echo "#StorageServer uninstall: OK\n";
|
||||
|
||||
$dbc->disconnect();
|
||||
?>
|
||||
?>
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision: 2458 $
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// Do not allow remote execution.
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
require_once('DB.php');
|
||||
|
||||
|
||||
function camp_db_table_exists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "Database connection problem.\n";
|
||||
echo "Check if database '".$CC_CONFIG['dsn']['database']."' exists".
|
||||
" with corresponding permissions.\n";
|
||||
echo "Database access is defined by 'dsn' values in conf.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['transTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['transTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['mdataTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['mdataTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['mdataTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['mdataTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['filesTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['accessTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['permTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['permTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['sessTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['subjTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['smembTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['classTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['classTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['classTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['classTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['cmembTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['cmembTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['cmembTable']);
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['cmembTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['structTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['structTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['structTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['structTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['structTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['treeTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['treeTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['treeTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['treeTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['treeTable']."\n";
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Tomas Hlava <th@red2head.com>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @version $Revision: 2458 $
|
||||
* @package Campcaster
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
|
||||
// Do not allow remote execution.
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
|
||||
$CC_DBC->query("DROP TABLE ".$CC_CONFIG['prefTable']);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id_seq");
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
|
||||
}
|
||||
|
||||
|
||||
echo " * Removing all media files in ".$CC_CONFIG['storageDir']."...";
|
||||
$d = @dir($CC_CONFIG['storageDir']);
|
||||
while (is_object($d) && (false !== ($entry = $d->read()))){
|
||||
if (filetype($CC_CONFIG['storageDir']."/$entry") == 'dir') {
|
||||
if ( ($entry != 'CVS') && ($entry != 'tmp') && (strlen($entry)==3) ) {
|
||||
$dd = dir($CC_CONFIG['storageDir']."/$entry");
|
||||
while (false !== ($ee = $dd->read())) {
|
||||
if (substr($ee, 0, 1) !== '.') {
|
||||
$filename = $CC_CONFIG['storageDir']."/$entry/$ee";
|
||||
echo " * Removing $filename...";
|
||||
unlink($filename);
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
$dd->close();
|
||||
rmdir($CC_CONFIG['storageDir']."/$entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_object($d)) {
|
||||
$d->close();
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
//echo " * Removing all temporary files in ".$CC_CONFIG['bufferDir']."...";
|
||||
//if (file_exists($CC_CONFIG['bufferDir'])) {
|
||||
// $d = dir($CC_CONFIG['bufferDir']);
|
||||
// while (false !== ($entry = $d->read())) {
|
||||
// if (substr($entry, 0, 1) != '.') {
|
||||
// unlink($CC_CONFIG['bufferDir']."/$entry");
|
||||
// }
|
||||
// }
|
||||
// $d->close();
|
||||
// @rmdir($this->bufferDir);
|
||||
//}
|
||||
//echo "done.\n";
|
||||
|
||||
|
||||
?>
|
|
@ -2,20 +2,20 @@
|
|||
header("Content-type: text/plain");
|
||||
echo "\n# Transport test:\n";
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once '../LocStor.php';
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('../LocStor.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
$tr = new Transport($gb);
|
||||
$ls = new LocStor($dbc, $config);
|
||||
@unlink("{$tr->transDir}/activity.log");
|
||||
@unlink("{$tr->transDir}/debug.log");
|
||||
$ls = new LocStor();
|
||||
@unlink($CC_CONFIG['transDir']."/activity.log");
|
||||
@unlink($CC_CONFIG['transDir']."/debug.log");
|
||||
$tr->_cleanUp();
|
||||
|
||||
$gunid = 'a23456789abcdefb';
|
||||
|
@ -24,25 +24,25 @@ $mdataFile = '../tests/mdata1.xml';
|
|||
|
||||
/* ========== PING ========== */
|
||||
/*
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# Ping: ";
|
||||
$r = $tr->pingToArchive();
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
*/
|
||||
/* ========== STORE ========== */
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# Store: ";
|
||||
$parid = $gb->_getHomeDirIdFromSess($sessid);
|
||||
$oid = $r = $gb->bsPutFile($parid, "xx1.mp3", $mediaFile, $mdataFile, $gunid, 'audioclip');
|
||||
if(PEAR::isError($r)){ if($r->getCode()!=GBERR_GUNID){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }}
|
||||
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
echo "$oid\n";
|
||||
|
||||
/* ========== DELETE FROM HUB ========== */
|
||||
|
@ -76,7 +76,7 @@ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n
|
|||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
/*
|
||||
|
@ -97,14 +97,21 @@ for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++,
|
|||
if($state=='failed') exit(1);
|
||||
|
||||
/* === DELETE LOCAL === */
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "# logout: "; $r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
|
||||
echo `$comm`;
|
||||
/*
|
||||
*/
|
||||
|
||||
|
@ -114,7 +121,7 @@ $comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
|||
|
||||
/* === DOWNLOAD === */
|
||||
echo "# DOWNLOAD test:\n";
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# downloadAudioClipFromHub: ";
|
||||
$r = $gb->downloadFromHub($sessid, $gunid);
|
||||
|
@ -122,7 +129,7 @@ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n
|
|||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
|
||||
|
@ -139,16 +146,16 @@ for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++,
|
|||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
/*
|
||||
*/
|
||||
|
||||
/*
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo"# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
*/
|
||||
|
|
|
@ -2,41 +2,58 @@
|
|||
header("Content-type: text/plain");
|
||||
echo "\n#StorageServer storeWebstream test:\n";
|
||||
|
||||
require_once '../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once '../GreenBox.php';
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
#$gunid = "123456789abcdee0";
|
||||
$gunid = "";
|
||||
#$mdataFileLP = '../tests/mdata1.xml';
|
||||
$mdataFileLP = NULL;
|
||||
|
||||
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
$parid = $gb->_getHomeDirId($sessid);
|
||||
|
||||
echo"# storeWebstream: "; $r = $gb->storeWebstream(
|
||||
echo "# storeWebstream: ";
|
||||
$r = $gb->storeWebstream(
|
||||
$parid, 'test stream', $mdataFileLP, $sessid, $gunid, 'http://localhost/y');
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo ""; var_dump($r);
|
||||
#$id = $gb->idFromGunid($gunid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "";
|
||||
var_dump($r);
|
||||
//$id = BasicStor::IdFromGunid($gunid);
|
||||
$id = $r;
|
||||
|
||||
echo"# getMdata: "; $r = $gb->getMdata($id, $sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "# getMdata: ";
|
||||
$r = $gb->getMdata($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo"# deleteFile: "; $r = $gb->deleteFile($id, $sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "# deleteFile: ";
|
||||
$r = $gb->deleteFile($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo"# logout: "; $r = $gb->logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "# logout: ";
|
||||
$r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
|
||||
echo "#storeWebstream test: OK.\n\n"
|
||||
|
|
|
@ -152,7 +152,7 @@ class XR_LocStor extends LocStor {
|
|||
if (!$ok) {
|
||||
return $r;
|
||||
}
|
||||
$res = $this->login($r['login'], $r['pass']);
|
||||
$res = Alib::Login($r['login'], $r['pass']);
|
||||
if (PEAR::isError($res)) {
|
||||
return new XML_RPC_Response(0, 804,
|
||||
"xr_login: ".$res->getMessage().
|
||||
|
@ -203,7 +203,7 @@ class XR_LocStor extends LocStor {
|
|||
if (!$ok) {
|
||||
return $r;
|
||||
}
|
||||
$res = $this->logout($r['sessid']);
|
||||
$res = Alib::Logout($r['sessid']);
|
||||
if (PEAR::isError($res)) {
|
||||
return new XML_RPC_Response(0, 803,
|
||||
"xr_logout: ".$res->getMessage().
|
||||
|
@ -1191,7 +1191,7 @@ class XR_LocStor extends LocStor {
|
|||
}
|
||||
$res = $this->playlistIsAvailable($r['sessid'], $r['plid'], TRUE);
|
||||
$ownerId = ($res === TRUE ? NULL : $res);
|
||||
$ownerLogin = (is_null($ownerId) ? NULL : $this->getSubjName($ownerId));
|
||||
$ownerLogin = (is_null($ownerId) ? NULL : Subjects::GetSubjName($ownerId));
|
||||
if (PEAR::isError($res)) {
|
||||
return new XML_RPC_Response(0, 805,
|
||||
"xr_playlistIsAvailable: ".$res->getMessage().
|
||||
|
@ -3221,7 +3221,7 @@ class XR_LocStor extends LocStor {
|
|||
}
|
||||
require_once('../Transport.php');
|
||||
$tr = new Transport($this);
|
||||
$uid = $this->getSessUserId($par['sessid']); // ###
|
||||
$uid = Alib::GetSessUserId($par['sessid']);
|
||||
$res = $tr->downloadFromHub($uid, $par['gunid']);
|
||||
if (PEAR::isError($res)) {
|
||||
$ec0 = intval($res->getCode());
|
||||
|
@ -3540,7 +3540,7 @@ class XR_LocStor extends LocStor {
|
|||
}
|
||||
return new XML_RPC_Response(XML_RPC_encode(array(
|
||||
'str'=>strtoupper($r['teststring']),
|
||||
'login'=>$this->getSessLogin($r['sessid']),
|
||||
'login' => Alib::GetSessLogin($r['sessid']),
|
||||
'sessid'=>$r['sessid']
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ require_once 'DB.php';
|
|||
require_once dirname(__FILE__).'/../LocStor.php';
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new LocStor($dbc, $config);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new LocStor();
|
||||
|
||||
function http_error($code, $err) {
|
||||
header("HTTP/1.1 $code");
|
||||
|
@ -61,7 +61,7 @@ if(!$tc){ http_error(403, "put.php: Token not valid ($token)."); }
|
|||
|
||||
header("Content-type: text/plain");
|
||||
|
||||
$destfile = "{$config['accessDir']}/{$token}";
|
||||
$destfile = $CC_CONFIG['accessDir']."/{$token}";
|
||||
|
||||
/* PUT data comes in on the input stream */
|
||||
$putdata = @fopen("php://input", "r") or
|
||||
|
|
|
@ -334,24 +334,12 @@ $mdefs = array(
|
|||
/* ======================================================== class definitions */
|
||||
|
||||
class SchedulerPhpClient {
|
||||
/**
|
||||
* Databases object reference
|
||||
* @var DB
|
||||
*/
|
||||
public $dbc = NULL;
|
||||
|
||||
/**
|
||||
* Array with methods description
|
||||
* @var array
|
||||
*/
|
||||
private $mdefs = array();
|
||||
|
||||
/**
|
||||
* Confiduration array from ../conf.php
|
||||
* @var array
|
||||
*/
|
||||
public $config = array();
|
||||
|
||||
/**
|
||||
* XMLRPC client object reference
|
||||
*/
|
||||
|
@ -380,20 +368,18 @@ class SchedulerPhpClient {
|
|||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
*/
|
||||
public function __construct(
|
||||
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
|
||||
public function __construct($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
$this->dbc = $dbc;
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$this->mdefs = $mdefs;
|
||||
$this->config = $config;
|
||||
$this->debug = $debug;
|
||||
$this->verbose = $verbose;
|
||||
$confPrefix = "scheduler";
|
||||
# $confPrefix = "storage";
|
||||
//$confPrefix = "storage";
|
||||
$serverPath =
|
||||
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
|
||||
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
|
||||
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||
"http://{$CC_CONFIG["{$confPrefix}UrlHost"]}:{$CC_CONFIG["{$confPrefix}UrlPort"]}".
|
||||
"{$CC_CONFIG["{$confPrefix}UrlPath"]}/{$CC_CONFIG["{$confPrefix}XMLRPC"]}";
|
||||
//$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||
if ($this->verbose) {
|
||||
echo "serverPath: $serverPath\n";
|
||||
}
|
||||
|
@ -413,19 +399,17 @@ class SchedulerPhpClient {
|
|||
* array, call wrapper callMethod(methodname, parameters) and return its
|
||||
* result.
|
||||
*
|
||||
* @param DB $dbc
|
||||
* @param array $mdefs
|
||||
* hash array with methods description
|
||||
* @param array $config
|
||||
* hash array with configuration
|
||||
* @param int $debug
|
||||
* XMLRPC debug flag
|
||||
* @param boolean $verbose
|
||||
* verbosity flag
|
||||
* @return SchedulerPhpClientCore
|
||||
*/
|
||||
function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
|
||||
function &factory($mdefs, $debug=0, $verbose=FALSE)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$f = '';
|
||||
foreach ($mdefs as $fn => $farr) {
|
||||
$f .=
|
||||
|
@ -441,10 +425,9 @@ class SchedulerPhpClient {
|
|||
"}\n";
|
||||
# echo $e;
|
||||
if (FALSE === eval($e)) {
|
||||
return $dbc->raiseError("Eval failed");
|
||||
return $CC_DBC->raiseError("Eval failed");
|
||||
}
|
||||
$spc = new SchedulerPhpClientCore(
|
||||
$dbc, $mdefs, $config, $debug, $verbose);
|
||||
$spc = new SchedulerPhpClientCore($mdefs, $debug, $verbose);
|
||||
return $spc;
|
||||
}
|
||||
|
||||
|
@ -506,13 +489,13 @@ class SchedulerPhpClient {
|
|||
|
||||
|
||||
// db object handling:
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
|
||||
// scheduler client instantiation:
|
||||
$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config);
|
||||
#$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE);
|
||||
$spc = SchedulerPhpClient::factory($mdefs);
|
||||
#$spc = SchedulerPhpClient::factory($mdefs, 0, TRUE);
|
||||
if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; }
|
||||
|
||||
// call of chosen function by name according to key values in $mdefs array:
|
||||
|
|
|
@ -27,17 +27,18 @@
|
|||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/../conf.php';
|
||||
require_once 'DB.php';
|
||||
require_once dirname(__FILE__).'/../LocStor.php';
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/../LocStor.php');
|
||||
|
||||
$dbc = DB::connect($config['dsn'], TRUE);
|
||||
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$locStor = new LocStor($dbc, $config);
|
||||
$locStor = new LocStor();
|
||||
|
||||
function http_error($code, $err){
|
||||
function http_error($code, $err)
|
||||
{
|
||||
header("HTTP/1.1 $code");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "$err\r\n";
|
||||
|
@ -45,21 +46,21 @@ function http_error($code, $err){
|
|||
}
|
||||
|
||||
// parameter checking:
|
||||
if(preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])){
|
||||
if (preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])) {
|
||||
$sessid = $_REQUEST['sessid'];
|
||||
}else{
|
||||
} else {
|
||||
http_error(400, "Error on sessid parameter. ({$_REQUEST['sessid']})");
|
||||
}
|
||||
if(preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])){
|
||||
if (preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])) {
|
||||
$gunid = $_REQUEST['id'];
|
||||
}else{
|
||||
} else {
|
||||
http_error(400, "Error on id parameter. ({$_REQUEST['id']})");
|
||||
}
|
||||
|
||||
// stored file recall:
|
||||
$ac = StoredFile::recallByGunid($locStor, $gunid);
|
||||
if($dbc->isError($ac)){
|
||||
switch($ac->getCode()){
|
||||
if (PEAR::isError($ac)) {
|
||||
switch ($ac->getCode()) {
|
||||
case GBERR_DENY:
|
||||
http_error(403, "403 ".$ac->getMessage());
|
||||
case GBERR_FILENEX:
|
||||
|
@ -69,22 +70,26 @@ if($dbc->isError($ac)){
|
|||
http_error(500, "500 ".$ac->getMessage());
|
||||
}
|
||||
}
|
||||
$lid = $locStor->idFromGunid($gunid);
|
||||
if($dbc->isError($lid)){ http_error(500, $lid->getMessage()); }
|
||||
if(($res = $locStor->_authorize('read', $lid, $sessid)) !== TRUE){
|
||||
$lid = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($lid)) {
|
||||
http_error(500, $lid->getMessage());
|
||||
}
|
||||
if (($res = BasicStor::Authorize('read', $lid, $sessid)) !== TRUE) {
|
||||
http_error(403, "403 Access denied");
|
||||
}
|
||||
$ftype = $locStor->getObjType($lid);
|
||||
if($dbc->isError($ftype)){ http_error(500, $ftype->getMessage()); }
|
||||
switch($ftype){
|
||||
case"audioclip":
|
||||
$ftype = BasicStor::GetObjType($lid);
|
||||
if (PEAR::isError($ftype)) {
|
||||
http_error(500, $ftype->getMessage());
|
||||
}
|
||||
switch ($ftype) {
|
||||
case "audioclip":
|
||||
$realFname = $ac->_getRealRADFname();
|
||||
$mime = $ac->rmd->getMime();
|
||||
header("Content-type: $mime");
|
||||
header("Content-length: ".filesize($realFname));
|
||||
header("Content-length: ".filesize($realFname));
|
||||
readfile($realFname);
|
||||
break;
|
||||
case"webstream":
|
||||
case "webstream":
|
||||
$url = $locStor->bsGetMetadataValue($lid, 'ls:url');
|
||||
if (empty($url)) {
|
||||
http_error(500, "Unable to get ls:url value");
|
||||
|
@ -93,7 +98,7 @@ switch($ftype){
|
|||
header($txt);
|
||||
// echo "$txt\n";
|
||||
break;
|
||||
case"playlist";
|
||||
case "playlist";
|
||||
// $md = $locStor->bsGetMetadata($ac->getId(), $sessid);
|
||||
$md = $locStor->getAudioClip($sessid, $gunid);
|
||||
// header("Content-type: text/xml");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue