Cleaned up conf.php to make it more obvious what a user should change and what they shouldnt.
Removed old code that isnt used anymore. Changed the login screen to use config variables for AIRTIME_VERSION.
This commit is contained in:
parent
c9c47c7d5f
commit
7b58f3563f
13 changed files with 37 additions and 1131 deletions
|
@ -1,41 +1,56 @@
|
|||
<?php
|
||||
define('CAMPCASTER_VERSION', '1.6.1-GA');
|
||||
define('CAMPCASTER_COPYRIGHT_DATE', '2010');
|
||||
define('AIRTIME_VERSION', '1.7.0 alpha');
|
||||
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
|
||||
|
||||
// These are the default values for the config.
|
||||
global $CC_CONFIG;
|
||||
|
||||
$values = load_airtime_config();
|
||||
|
||||
// **********************************
|
||||
// ***** START CUSTOMIZING HERE *****
|
||||
// **********************************
|
||||
|
||||
// Set the location where you want to store all of your audio files.
|
||||
//
|
||||
// For example:
|
||||
// $baseFilesDir = '/home/john/radio-files';
|
||||
$baseFilesDir = __DIR__.'/../../files';
|
||||
|
||||
$CC_CONFIG = array(
|
||||
// Database config
|
||||
'dsn' => $values['database'],
|
||||
|
||||
// Set the URL of your installation
|
||||
'storageUrlHost' => 'localhost',
|
||||
'storageUrlPort' => 80,
|
||||
|
||||
// Name of the web server user
|
||||
'webServerUser' => 'www-data',
|
||||
|
||||
// ***********************************************************************
|
||||
// STOP CUSTOMIZING HERE
|
||||
//
|
||||
// You don't need to touch anything below this point.
|
||||
// ***********************************************************************
|
||||
|
||||
'baseFilesDir' => $baseFilesDir,
|
||||
// main directory for storing binary media files
|
||||
'storageDir' => "$baseFilesDir/stor",
|
||||
|
||||
// Database config
|
||||
'dsn' => $values['database'],
|
||||
|
||||
// prefix for table names in the database
|
||||
'tblNamePrefix' => 'cc_',
|
||||
|
||||
/* ================================================ storage configuration */
|
||||
|
||||
'apiKey' => $values['api_key'],
|
||||
|
||||
'apiPath' => '/api/',
|
||||
|
||||
'baseFilesDir' => $baseFilesDir,
|
||||
// main directory for storing binary media files
|
||||
'storageDir' => "$baseFilesDir/stor",
|
||||
|
||||
"rootDir" => __DIR__."/../..",
|
||||
'pearPath' => dirname(__FILE__).'/../../library/pear',
|
||||
'zendPath' => dirname(__FILE__).'/../../library/Zend',
|
||||
'phingPath' => dirname(__FILE__).'/../../library/phing',
|
||||
|
||||
// secret token cookie name
|
||||
'authCookieName'=> 'campcaster_session_id',
|
||||
|
||||
// name of admin group
|
||||
//'AdminsGr' => 'Admins',
|
||||
|
||||
|
@ -44,47 +59,6 @@ $CC_CONFIG = array(
|
|||
|
||||
// name of 'all users' group
|
||||
//'AllGr' => 'All',
|
||||
'TrashName' => 'trash_',
|
||||
|
||||
// enable/disable validator
|
||||
'validate' => TRUE,
|
||||
|
||||
// enable/disable safe delete (move to trash)
|
||||
'useTrash' => FALSE,
|
||||
|
||||
/* ==================================================== URL configuration */
|
||||
// path-URL-part of storageServer base dir
|
||||
'storageUrlPath' => '/campcaster/backend',
|
||||
|
||||
// XMLRPC server script address relative to storageUrlPath
|
||||
'storageXMLRPC' => 'xmlrpc/xrLocStor.php',
|
||||
|
||||
// host and port of storageServer
|
||||
'storageUrlHost' => 'localhost',
|
||||
'storageUrlPort' => 80,
|
||||
|
||||
/* ================================================ remote link configuration */
|
||||
// path-URL-part of remote server base dir
|
||||
'archiveUrlPath' => '/campcaster/backend',
|
||||
|
||||
// XMLRPC server script address relative to archiveUrlPath
|
||||
'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
|
||||
|
||||
// host and port of archiveServer
|
||||
'archiveUrlHost' => 'localhost',
|
||||
// 'archiveUrlHost' => '192.168.30.166',
|
||||
'archiveUrlPort' => 80,
|
||||
|
||||
// account info for login to archive
|
||||
'archiveAccountLogin' => 'root',
|
||||
'archiveAccountPass' => 'q',
|
||||
|
||||
/* ============================================== scheduler configuration */
|
||||
'schedulerUrlPath' => '',
|
||||
'schedulerXMLRPC' => 'RC2',
|
||||
'schedulerUrlHost' => 'localhost',
|
||||
'schedulerUrlPort' => 3344,
|
||||
'schedulerPass' => 'change_me',
|
||||
|
||||
/* ==================================== application-specific configuration */
|
||||
'objtypes' => array(
|
||||
|
@ -92,22 +66,16 @@ $CC_CONFIG = array(
|
|||
'File' => array(),
|
||||
'audioclip' => array(),
|
||||
'playlist' => array(),
|
||||
// 'Replica' => array(),
|
||||
),
|
||||
'allowedActions'=> array(
|
||||
'File' => array('editPrivs', 'write', 'read'),
|
||||
'audioclip' => array('editPrivs', 'write', 'read'),
|
||||
'playlist' => array('editPrivs', 'write', 'read'),
|
||||
// 'Replica' => array('editPrivs', 'write', 'read'),
|
||||
// '_class' => array('editPrivs', 'write', 'read'),
|
||||
),
|
||||
'allActions' => array(
|
||||
'editPrivs', 'write', 'read', /*'classes',*/ 'subjects'
|
||||
'editPrivs', 'write', 'read', 'subjects'
|
||||
),
|
||||
|
||||
/* ============================================== auxiliary configuration */
|
||||
'tmpRootPass' => 'q',
|
||||
|
||||
/* =================================================== cron configuration */
|
||||
'cronUserName' => 'www-data',
|
||||
# 'lockfile' => dirname(__FILE__).'/cron/cron.lock',
|
||||
|
|
|
@ -31,7 +31,7 @@ class ApiController extends Zend_Controller_Action
|
|||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
$jsonStr = json_encode(array("version"=>CAMPCASTER_VERSION));
|
||||
$jsonStr = json_encode(array("version"=>AIRTIME_VERSION));
|
||||
echo $jsonStr;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ class LoginController extends Zend_Controller_Action
|
|||
|
||||
$this->view->message = $message;
|
||||
$this->view->form = $form;
|
||||
|
||||
$this->view->airtimeVersion = AIRTIME_VERSION;
|
||||
$this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE;
|
||||
}
|
||||
|
||||
public function logoutAction()
|
||||
|
|
|
@ -18,99 +18,6 @@ class Alib {
|
|||
|
||||
/* ----------------------------------------------- session/authentication */
|
||||
|
||||
/**
|
||||
* Authenticate and create session
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @return boolean|sessionId|PEAR_Error
|
||||
*/
|
||||
public static function Login($login, $pass)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (FALSE === Subjects::Authenticate($login, $pass)) {
|
||||
Subjects::SetTimeStamp($login, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
$sessid = Alib::_createSessid();
|
||||
if (PEAR::isError($sessid)) {
|
||||
return $sessid;
|
||||
}
|
||||
$userid = Subjects::GetSubjId($login);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['sessTable']." (sessid, userid, login, ts)"
|
||||
." VALUES('$sessid', '$userid', '$login', now())";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
Subjects::SetTimeStamp($login, FALSE);
|
||||
return $sessid;
|
||||
} // fn login
|
||||
|
||||
|
||||
/**
|
||||
* Logout and destroy session
|
||||
*
|
||||
* @param string $sessid
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
public static function Logout($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 ".$CC_CONFIG['sessTable']
|
||||
." WHERE sessid='$sessid'";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
} // fn logout
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the token is valid
|
||||
*
|
||||
* @param string $sessid
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
private static function CheckAuthToken($sessid)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable']
|
||||
." WHERE sessid='$sessid'";
|
||||
$c = $CC_DBC->getOne($sql);
|
||||
return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE ));
|
||||
} //fn checkAuthToken
|
||||
|
||||
|
||||
/**
|
||||
* Set valid token in alib object
|
||||
*
|
||||
* @param string $sessid
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
// public function setAuthToken($sessid)
|
||||
// {
|
||||
// $r = $this->checkAuthToken($sessid);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// if (!$r) {
|
||||
// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
|
||||
// }
|
||||
// //$this->sessid = $sessid;
|
||||
// return TRUE;
|
||||
// } // fn setAuthToken
|
||||
|
||||
|
||||
/* -------------------------------------------------------- authorization */
|
||||
/**
|
||||
* Insert permission record
|
||||
|
@ -172,170 +79,10 @@ class Alib {
|
|||
} // fn removePerm
|
||||
|
||||
|
||||
/**
|
||||
* Return object related with permission record
|
||||
*
|
||||
* @param int $permid
|
||||
* local permission id
|
||||
* @return int
|
||||
* local object id
|
||||
*/
|
||||
public static function GetPermOid($permid)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT obj FROM ".$CC_CONFIG['permTable']." WHERE permid=$permid";
|
||||
$res = $CC_DBC->getOne($sql);
|
||||
return $res;
|
||||
} // fn GetPermOid
|
||||
|
||||
|
||||
/**
|
||||
* Check if specified subject have permission to specified action
|
||||
* on specified object
|
||||
*
|
||||
* Look for sequence of corresponding permissions and order it by
|
||||
* relevence, then test the most relevant for result.
|
||||
* High relevence have direct permission (directly for specified subject
|
||||
* and object. Relevance order is done by level distance in the object
|
||||
* tree, level distance in subjects (user/group system).
|
||||
* Similar way is used for permissions related to object classes.
|
||||
* But class-related permissions have lower priority then
|
||||
* object-tree-related.
|
||||
* Support for object classes can be disabled by USE_ALIB_CLASSES const.
|
||||
*
|
||||
* @param int $sid
|
||||
* subject id (user or group id)
|
||||
* @param string $action
|
||||
* from set defined in config
|
||||
* @param int $oid
|
||||
* object id (default: root node)
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function CheckPerm($sid, $action, $oid=NULL)
|
||||
{
|
||||
return TRUE;
|
||||
// global $CC_DBC;
|
||||
// global $CC_CONFIG;
|
||||
// if (!is_numeric($sid)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
//// if (is_null($oid) or $oid=='') {
|
||||
//// $oid = M2tree::GetRootNode();
|
||||
//// }
|
||||
//// if (PEAR::isError($oid)) {
|
||||
//// return $oid;
|
||||
//// }
|
||||
// if (!is_numeric($oid)) {
|
||||
// return FALSE;
|
||||
// }
|
||||
// // query construction
|
||||
// // shortcuts:
|
||||
// // p: permTable,
|
||||
// // s: subjTable, m smembTable,
|
||||
// // t: treeTable ts: structTable,
|
||||
// // c: classTable, cm: cmembTable
|
||||
// // main query elements:
|
||||
// $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
|
||||
// $q_from = $CC_CONFIG['permTable']." p ";
|
||||
// // joins for solving users/groups:
|
||||
// $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj ";
|
||||
// $q_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
|
||||
// $q_cond = "p.action in('_all', '$action') AND
|
||||
// (s.id=$sid OR m.uid=$sid) ";
|
||||
// // coalesce -1 for higher priority of nongroup rows:
|
||||
// // action DESC order for lower priority of '_all':
|
||||
// $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
|
||||
// $q_flds0 = $q_flds;
|
||||
// $q_from0 = $q_from;
|
||||
// $q_join0 = $q_join;
|
||||
// $q_cond0 = $q_cond;
|
||||
// $q_ordb0 = $q_ordb;
|
||||
// // joins for solving object tree:
|
||||
// $q_flds .= ", t.name, ts.level as tlevel";
|
||||
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['treeTable']." t ON t.id=p.obj ";
|
||||
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=p.obj ";
|
||||
// //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
|
||||
// // action DESC order is hack for lower priority of '_all':
|
||||
// $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
|
||||
// // query by tree:
|
||||
// $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
|
||||
// $r1 = $CC_DBC->getAll($query1);
|
||||
// if (PEAR::isError($r1)) {
|
||||
// return($r1);
|
||||
// }
|
||||
// // if there is row with type='A' on the top => permit
|
||||
// //$AllowedByTree =
|
||||
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
|
||||
// //$DeniedByTree =
|
||||
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
|
||||
//
|
||||
// if (!USE_ALIB_CLASSES) {
|
||||
// return $AllowedbyTree;
|
||||
// }
|
||||
//
|
||||
// // joins for solving object classes:
|
||||
// $q_flds = $q_flds0.", c.cname ";
|
||||
// $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj ";
|
||||
// $q_join .= "LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON cm.cid=p.obj ";
|
||||
// $q_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
|
||||
// $q_ordb = $q_ordb0;
|
||||
// // query by class:
|
||||
// $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
|
||||
// $r2 = $CC_DBC->getAll($query2);
|
||||
// if (PEAR::isError($r2)) {
|
||||
// return $r2;
|
||||
// }
|
||||
// $AllowedByClass =
|
||||
// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
|
||||
// // not used now:
|
||||
// // $DeniedByClass =
|
||||
// // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
|
||||
// $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
|
||||
// return $res;
|
||||
} // fn CheckPerm
|
||||
|
||||
|
||||
/* ---------------------------------------------------------- object tree */
|
||||
|
||||
/**
|
||||
* Remove all permissions on object and then remove object itself
|
||||
*
|
||||
* @param int $id
|
||||
* @return void|PEAR_Error
|
||||
*/
|
||||
public static function RemoveObj($id)
|
||||
{
|
||||
$r = Alib::RemovePerm(NULL, NULL, $id);
|
||||
return $r;
|
||||
} // fn removeObj
|
||||
|
||||
/* --------------------------------------------------------- users/groups */
|
||||
|
||||
/**
|
||||
* Remove all permissions of subject and then remove subject itself
|
||||
*
|
||||
* @param string $login
|
||||
* @return void|PEAR_Error
|
||||
*/
|
||||
public static function RemoveSubj($login)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
if (is_null($uid)){
|
||||
return $CC_DBC->raiseError("Alib::removeSubj: Subj not found ($login)",
|
||||
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
|
||||
}
|
||||
$r = Alib::RemovePerm(NULL, $uid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return Subjects::RemoveSubj($login, $uid);
|
||||
} // fn RemoveSubj
|
||||
|
||||
|
||||
/* ------------------------------------------------------------- sessions */
|
||||
/**
|
||||
* Get login from session id (token)
|
||||
|
@ -411,9 +158,6 @@ class Alib {
|
|||
$sql = "SELECT *"
|
||||
." FROM ".$CC_CONFIG['permTable']
|
||||
." WHERE p.subj=$sid";
|
||||
// $sql = "SELECT t.name, t.type as otype , p.*"
|
||||
// ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
|
||||
// ." WHERE t.id=p.obj AND p.subj=$sid";
|
||||
$a1 = $CC_DBC->getAll($sql);
|
||||
return $a1;
|
||||
} // fn GetSubjPerms
|
||||
|
@ -425,31 +169,6 @@ class Alib {
|
|||
* (only very simple structure definition - in $CC_CONFIG - supported now)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get all actions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function GetAllActions()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
return $CC_CONFIG['allActions'];
|
||||
} // fn GetAllActions
|
||||
|
||||
|
||||
/**
|
||||
* Get all allowed actions on specified object type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public static function GetAllowedActions($type)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
return $CC_CONFIG['allowedActions'][$type];
|
||||
} // fn GetAllowedActions
|
||||
|
||||
|
||||
/* ====================================================== private methods */
|
||||
|
||||
/**
|
||||
|
@ -473,149 +192,4 @@ class Alib {
|
|||
} // fn _createSessid
|
||||
|
||||
|
||||
/* =============================================== test and debug methods */
|
||||
|
||||
/**
|
||||
* Dump all permissions for debug
|
||||
*
|
||||
* @param string $indstr
|
||||
* indentation string
|
||||
* @param string $ind
|
||||
* actual indentation
|
||||
* @return string
|
||||
*/
|
||||
public static function DumpPerms($indstr=' ', $ind='')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT s.login, p.action, p.type"
|
||||
." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
|
||||
." WHERE s.id=p.subj"
|
||||
." ORDER BY p.permid";
|
||||
$arr = $CC_DBC->getAll($sql);
|
||||
if (PEAR::isError($arr)) {
|
||||
return $arr;
|
||||
}
|
||||
$r = $ind.join(', ', array_map(create_function('$v',
|
||||
'return "{$v[\'login\']}/{$v[\'action\']}/{$v[\'type\']}";'
|
||||
),
|
||||
$arr
|
||||
))."\n";
|
||||
return $r;
|
||||
} // fn dumpPerms
|
||||
|
||||
|
||||
/**
|
||||
* Delete everything form the permission table and session table.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function 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
|
||||
|
||||
|
||||
/**
|
||||
* Insert test permissions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function TestData()
|
||||
{
|
||||
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'),
|
||||
array($s['test1'], 'read', $t['s2b'], 'D'),
|
||||
array($s['test2'], 'addChilds', $t['pa'], 'D'),
|
||||
array($s['test2'], 'read', $t['i2'], 'A'),
|
||||
array($s['test2'], 'edit', $t['s1a'], 'A'),
|
||||
array($s['test1'], 'addChilds', $t['s2a'], 'D'),
|
||||
array($s['test1'], 'addChilds', $t['s2c'], 'D'),
|
||||
array($s['gr2'], 'addChilds', $t['i2'], 'A'),
|
||||
array($s['test3'], '_all', $t['t1'], 'D'),
|
||||
);
|
||||
if (USE_ALIB_CLASSES){
|
||||
$perms[] = array($s['test3'], 'read', $c['cl_sa'], 'D');
|
||||
$perms[] = array($s['test4'], 'editPerms', $c['cl2'], 'A');
|
||||
}
|
||||
foreach ($perms as $p){
|
||||
$o[] = $r = Alib::AddPerm($p[0], $p[1], $p[2], $p[3]);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
$tdata['perms'] = $o;
|
||||
return $tdata;
|
||||
} // fn testData
|
||||
|
||||
|
||||
/**
|
||||
* Make basic test
|
||||
*
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function Test()
|
||||
{
|
||||
$p = Subjects::test();
|
||||
if (PEAR::isError($p)) {
|
||||
return $p;
|
||||
}
|
||||
Alib::DeleteData();
|
||||
$tdata = Alib::TestData();
|
||||
if (PEAR::isError($tdata)) {
|
||||
return $tdata;
|
||||
}
|
||||
$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){
|
||||
$test_correct .= ", test3/read/D, test4/editPerms/A";
|
||||
}
|
||||
$test_correct .= "\nno, yes\n";
|
||||
$r = Alib::DumpPerms();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$test_dump = $r.
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'read',
|
||||
$tdata['tree']['t1']
|
||||
)? 'yes':'no').", ".
|
||||
(Alib::CheckPerm(
|
||||
$tdata['subjects']['test1'], 'addChilds',
|
||||
$tdata['tree']['i2']
|
||||
)? 'yes':'no')."\n"
|
||||
;
|
||||
Alib::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) {
|
||||
$test_correct .= ", test3/read/D, test4/editPerms/A";
|
||||
}
|
||||
$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{$test_correct}\n".
|
||||
"dump:\n{$test_dump}\n</pre>\n");
|
||||
}
|
||||
} // fn test
|
||||
|
||||
} // class Alib
|
||||
|
|
|
@ -215,74 +215,6 @@ class BasicStor {
|
|||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param int $id
|
||||
* Virtual file's local id
|
||||
* @param boolean $forced
|
||||
* If true don't use trash
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
// public function bsDeleteFile($id, $forced=FALSE)
|
||||
// {
|
||||
// global $CC_CONFIG;
|
||||
// // full delete:
|
||||
// if (!$CC_CONFIG['useTrash'] || $forced) {
|
||||
// $res = BasicStor::RemoveObj($id, $forced);
|
||||
// return $res;
|
||||
// }
|
||||
//
|
||||
// $storedFile = StoredFile::Recall($id);
|
||||
//
|
||||
// if (is_null($storedFile) || PEAR::isError($storedFile)) {
|
||||
// return $storedFile;
|
||||
// }
|
||||
// if ($storedFile->isAccessed()) {
|
||||
// return PEAR::raiseError(
|
||||
// 'Cannot delete an object that is currently accessed.'
|
||||
// );
|
||||
// }
|
||||
// // move to trash:
|
||||
// switch (BasicStor::GetObjType($id)) {
|
||||
//
|
||||
// case "audioclip":
|
||||
// $playLists = $storedFile->getPlaylists();
|
||||
// $item_gunid = $storedFile->getGunid();
|
||||
// if( $playLists != NULL) {
|
||||
//
|
||||
// foreach($playLists as $key=>$val) {
|
||||
// $playList_id = BasicStor::IdFromGunidBigInt($val["gunid"]);
|
||||
// $playList_titles[] = BasicStor::bsGetMetadataValue($playList_id, "dc:title");
|
||||
// }
|
||||
// return PEAR::raiseError(
|
||||
// 'Please remove this song from all playlists: ' . join(",", $playList_titles)
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case "playlist":
|
||||
// if($storedFile->isScheduled()) {
|
||||
// return PEAR::raiseError(
|
||||
// 'Cannot delete an object that is scheduled to play.'
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case "webstream":
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
//
|
||||
// $res = $storedFile->setState('deleted');
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
//
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
|
||||
/* ----------------------------------------------------- put, access etc. */
|
||||
/**
|
||||
|
@ -1788,51 +1720,6 @@ class BasicStor {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove user by login
|
||||
*
|
||||
* @param string $login
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function removeSubj($login)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (FALSE !== array_search($login, $CC_CONFIG['sysSubjs'])) {
|
||||
return $CC_DBC->raiseError(
|
||||
"BasicStor::removeSubj: cannot remove system user/group");
|
||||
}
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
$res = $CC_DBC->query("
|
||||
DELETE FROM ".$CC_CONFIG['accessTable']." WHERE owner=$uid
|
||||
");
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = Alib::RemoveSubj($login);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Authenticate and create session
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $pass
|
||||
* @return boolean|sessionId|PEAR_Error
|
||||
*/
|
||||
function login($login, $pass)
|
||||
{
|
||||
$r = Alib::Login($login, $pass);
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================== "protected" methods */
|
||||
/**
|
||||
* Check authorization - auxiliary method
|
||||
|
@ -1862,13 +1749,6 @@ class BasicStor {
|
|||
$acts = array($acts);
|
||||
}
|
||||
$perm = true;
|
||||
// foreach ($acts as $i => $action) {
|
||||
// $res = Alib::CheckPerm($userid, $action, $pars[$i]);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $perm = $perm && $res;
|
||||
// }
|
||||
if ($perm) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2031,89 +1911,6 @@ class BasicStor {
|
|||
|
||||
|
||||
/* ---------------------------------------- redefined "protected" methods */
|
||||
/**
|
||||
* Copy virtual file.
|
||||
* Redefined from parent class.
|
||||
*
|
||||
* @return int
|
||||
* New object local id
|
||||
*/
|
||||
// protected static function CopyObj($id, $newParid, $after=NULL)
|
||||
// {
|
||||
// switch (BasicStor::GetObjType($id)) {
|
||||
// case "audioclip":
|
||||
// case "playlist":
|
||||
// case "webstream":
|
||||
// $storedFile = StoredFile::Recall($id);
|
||||
// if (is_null($storedFile) || PEAR::isError($storedFile)) {
|
||||
// return $storedFile;
|
||||
// }
|
||||
// $ac2 = StoredFile::CopyOf($storedFile, $nid);
|
||||
// //$ac2->setName(M2tree::GetObjName($nid));
|
||||
// break;
|
||||
// case "File":
|
||||
// default:
|
||||
// }
|
||||
// return $nid;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Remove virtual file.<br>
|
||||
* Redefined from parent class.
|
||||
*
|
||||
* @param int $id
|
||||
* Local id of removed object
|
||||
* @param boolean $forced
|
||||
* Unconditional delete
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
// public static function RemoveObj($id, $forced=FALSE)
|
||||
// {
|
||||
// $ot = BasicStor::GetObjType($id);
|
||||
// if (PEAR::isError($ot)) {
|
||||
// return $ot;
|
||||
// }
|
||||
// switch ($ot) {
|
||||
// case "audioclip":
|
||||
// case "playlist":
|
||||
// case "webstream":
|
||||
// $storedFile = StoredFile::Recall($id);
|
||||
// if (is_null($storedFile)) {
|
||||
// return TRUE;
|
||||
// }
|
||||
// if (PEAR::isError($storedFile)) {
|
||||
// return $storedFile;
|
||||
// }
|
||||
// if ($storedFile->isEdited() && !$forced) {
|
||||
// return PEAR::raiseError(
|
||||
// 'BasicStor::RemoveObj(): is edited'
|
||||
// );
|
||||
// }
|
||||
// if ($storedFile->isAccessed() && !$forced) {
|
||||
// return PEAR::raiseError(
|
||||
// 'BasicStor::RemoveObj(): is accessed'
|
||||
// );
|
||||
// }
|
||||
// $storedFile->delete();
|
||||
// break;
|
||||
// case "File":
|
||||
//// case "Folder":
|
||||
//// case "Replica":
|
||||
// break;
|
||||
// default:
|
||||
// return PEAR::raiseError(
|
||||
// "BasicStor::bsDeleteFile: unknown obj type ($ot)"
|
||||
// );
|
||||
// }
|
||||
// $res = Alib::RemoveObj($id);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
|
||||
/* ========================================================= misc methods */
|
||||
/**
|
||||
* Write string to file
|
||||
|
|
|
@ -1692,34 +1692,4 @@ class GreenBox extends BasicStor {
|
|||
} // fn addPerm
|
||||
|
||||
|
||||
/**
|
||||
* Remove permission record
|
||||
*
|
||||
* @param int $permid
|
||||
* local permission id
|
||||
* @param int $subj
|
||||
* local user/group id
|
||||
* @param int $obj
|
||||
* local object id
|
||||
* @param string $sessid
|
||||
* session id
|
||||
* @return boolean/error
|
||||
*/
|
||||
public function removePerm($permid=NULL, $subj=NULL, $obj=NULL, $sessid='')
|
||||
{
|
||||
if (!is_null($permid)) {
|
||||
$oid = Alib::GetPermOid($permid);
|
||||
if (PEAR::isError($oid)) {
|
||||
return $oid;
|
||||
}
|
||||
if (!is_null($oid)) {
|
||||
if (($res = BasicStor::Authorize('editPerms', $oid, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = Alib::RemovePerm($permid, $subj, $obj);
|
||||
return $res;
|
||||
} // fn removePerm
|
||||
|
||||
} // class GreenBox
|
||||
|
|
|
@ -1368,7 +1368,7 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
public static function getVersion()
|
||||
{
|
||||
return CAMPCASTER_VERSION;
|
||||
return AIRTIME_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -406,37 +406,5 @@ class Prefs {
|
|||
}
|
||||
|
||||
|
||||
/* ==================================================== auxiliary methods */
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
*/
|
||||
function test()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$sessid = Alib::Login('root', $CC_CONFIG['tmpRootPass']);
|
||||
$testkey = 'testKey';
|
||||
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
|
||||
$r = savePref($sessid, $testKey, $testVal);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$val = loadPref($sessid, $testKey);
|
||||
if ($val != $testVal) {
|
||||
echo "ERROR: preference storage test failed.\n ($testVal / $val)\n";
|
||||
return FALSE;
|
||||
}
|
||||
$r = savePref($sessid, $testKey, '');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$val = loadPref($sessid, $testKey);
|
||||
if ($val != $testVal) {
|
||||
echo "ERROR: preference storage test failed.\n ('' / '$val')\n";
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
} // class Prefs
|
||||
|
||||
|
|
|
@ -55,38 +55,6 @@ class Subjects {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove subject by uid or by login
|
||||
*
|
||||
* @param string $login
|
||||
* @param int $uid
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function RemoveSubj($login, $uid=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (is_null($uid)) {
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
}
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['smembTable']
|
||||
." WHERE (uid='$uid' OR gid='$uid') AND mid is null";
|
||||
$r = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$sql2 = "DELETE FROM ".$CC_CONFIG['subjTable']
|
||||
." WHERE login='$login'";
|
||||
$r = $CC_DBC->query($sql2);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return Subjects::_rebuildRels();
|
||||
} // fn removeSubj
|
||||
|
||||
|
||||
/**
|
||||
* Check login and password
|
||||
*
|
||||
|
@ -215,47 +183,6 @@ class Subjects {
|
|||
} // fn addSubj2Gr
|
||||
|
||||
|
||||
/**
|
||||
* Remove subject from group
|
||||
*
|
||||
* @param string $login
|
||||
* @param string $gname
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function RemoveSubjectFromGroup($login, $gname)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$uid = Subjects::GetSubjId($login);
|
||||
if (PEAR::isError($uid)) {
|
||||
return $uid;
|
||||
}
|
||||
$gid = Subjects::GetSubjId($gname);
|
||||
if (PEAR::isError($gid)) {
|
||||
return $gid;
|
||||
}
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG['smembTable']
|
||||
." WHERE uid='$uid' AND gid='$gid' AND mid is null";
|
||||
$mid = $CC_DBC->getOne($sql);
|
||||
if (is_null($mid)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (PEAR::isError($mid)) {
|
||||
return $mid;
|
||||
}
|
||||
// remove it:
|
||||
$r = Subjects::_removeMemb($mid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
// and rebuild indirect memberships:
|
||||
$r = Subjects::_rebuildRels();
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return TRUE;
|
||||
} // fn removeSubjFromGr
|
||||
|
||||
|
||||
/* --------------------------------------------------------- info methods */
|
||||
|
||||
/**
|
||||
|
@ -580,104 +507,5 @@ class Subjects {
|
|||
} // fn _rebuildRels
|
||||
|
||||
|
||||
/* =============================================== test and debug methods */
|
||||
|
||||
/**
|
||||
* Dump subjects for debug
|
||||
*
|
||||
* @param string $indstr
|
||||
* indentation string
|
||||
* @param string $ind
|
||||
* actual indentation
|
||||
* @return string
|
||||
*/
|
||||
public static function DumpSubjects($indstr=' ', $ind='')
|
||||
{
|
||||
$r = $ind.join(', ', array_map(
|
||||
create_function('$v', 'return "{$v[\'login\']}({$v[\'cnt\']})";'),
|
||||
Subjects::GetSubjectsWCnt()
|
||||
))."\n";
|
||||
return $r;
|
||||
} // fn dumpSubjects
|
||||
|
||||
|
||||
/**
|
||||
* Delete all subjects and membership records
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function 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
|
||||
|
||||
|
||||
/**
|
||||
* Insert test data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function 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 static function Test()
|
||||
{
|
||||
// $p = ObjClasses::Test();
|
||||
// if (PEAR::isError($p)) {
|
||||
// return $p;
|
||||
// }
|
||||
// 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";
|
||||
// $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";
|
||||
// $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{$test_correct}\n".
|
||||
// "dump:\n{$test_dump}\n</pre>\n");
|
||||
// }
|
||||
} // fn test
|
||||
|
||||
} // class Subjects
|
||||
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('../LocStor.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
$tr = new Transport($gb);
|
||||
$ls = new LocStor();
|
||||
@unlink($CC_CONFIG['transDir']."/activity.log");
|
||||
@unlink($CC_CONFIG['transDir']."/debug.log");
|
||||
$tr->_cleanUp();
|
||||
|
||||
$gunid = 'a23456789abcdefb';
|
||||
$mediaFile = '../tests/ex1.mp3';
|
||||
$mdataFile = '../tests/mdata1.xml';
|
||||
|
||||
// Test remote search
|
||||
$result = $tr->remoteSearch("");
|
||||
if (PEAR::isError($result)) {
|
||||
echo $result->message."\n";
|
||||
} else {
|
||||
var_dump($result);
|
||||
}
|
||||
|
||||
// ========== STORE ==========
|
||||
|
||||
echo"# Store: ";
|
||||
//$parid = $gb->_getHomeDirIdFromSess($sessid);
|
||||
$values = array(
|
||||
"filename" => "xx1.mp3",
|
||||
"filepath" => $mediaFile,
|
||||
"metadata" => $mdataFile,
|
||||
"gunid" => $gunid,
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
if ($storedFile->getCode()!=GBERR_GUNID) {
|
||||
echo "ERROR: ".$storedFile->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$oid = $storedFile->getId();
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
echo "$oid\n";
|
||||
|
||||
// ========== DELETE FROM HUB ==========
|
||||
echo"# loginToArchive: ";
|
||||
$r = $tr->loginToArchive();
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "{$r['sessid']}\n";
|
||||
$asessid = $r['sessid'];
|
||||
echo"# deleteAudioClip on Hub: ";
|
||||
$r = $tr->xmlrpcCall(
|
||||
'archive.deleteAudioClip',
|
||||
array(
|
||||
'sessid' => $asessid,
|
||||
'gunid' => $gunid,
|
||||
'forced' => TRUE,
|
||||
)
|
||||
);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; if($r->getCode()!=800+GBERR_FILENEX) exit(1); }
|
||||
else{ echo " {$r['status']}\n"; }
|
||||
echo"# logoutFromArchive: ";
|
||||
$r = $tr->logoutFromArchive($asessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
|
||||
|
||||
// ========== UPLOAD ==========
|
||||
echo "# UPLOAD test:\n";
|
||||
echo"# uploadAudioClip2Hub: ";
|
||||
$r = $gb->upload2Hub($gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
#$trtok='280a6f1c18389620';
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
// === DELETE LOCAL ===
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
echo "# logout: "; $r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
|
||||
echo `$comm`;
|
||||
|
||||
// === DOWNLOAD ===
|
||||
echo "# DOWNLOAD test:\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# downloadAudioClipFromHub: ";
|
||||
$r = $gb->downloadFromHub($sessid, $gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
|
||||
if(file_exists("../trans/log")) echo `tail -n 25 ../trans/log`;
|
||||
echo "#Transport test: OK.\n\n";
|
||||
*/
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
echo "\n#StorageServer storeWebstream test:\n";
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
#$gunid = "123456789abcdee0";
|
||||
$gunid = "";
|
||||
#$mdataFileLP = '../tests/mdata1.xml';
|
||||
$mdataFileLP = NULL;
|
||||
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
$parid = $gb->_getHomeDirId($sessid);
|
||||
|
||||
echo "# storeWebstream: ";
|
||||
$r = $gb->storeWebstream(
|
||||
$parid, 'test stream', $mdataFileLP, $sessid, $gunid, 'http://localhost/y');
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "";
|
||||
var_dump($r);
|
||||
//$id = BasicStor::IdFromGunid($gunid);
|
||||
$id = $r;
|
||||
|
||||
echo "# getMdata: ";
|
||||
$r = $gb->getMetadata($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo "# deleteFile: ";
|
||||
$r = $gb->deleteFile($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo "# logout: ";
|
||||
$r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
|
||||
echo "#storeWebstream test: OK.\n\n"
|
||||
*/
|
|
@ -7,5 +7,5 @@
|
|||
<?php echo $this->form; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer"> Airtime 1.7.0-alpha Copyright © Sourcefabric o.p.s 2011. All rights reserved.<br/>
|
||||
<div class="footer"> Airtime <?php echo $this->airtimeVersion ?> Copyright © Sourcefabric o.p.s <?php echo $this->airtimeCopyright ?>. All rights reserved.<br/>
|
||||
Maintained and distributed under GNU GPL v.3 by <a href="http://www.sourcefabric.org"> Sourcefabric o.p.s </a> </div>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
echo "This file is currently not working. Try again in the next version. :) \n";
|
||||
exit;
|
||||
|
||||
define('NSPACE', 'lse');
|
||||
define('VERBOSE', FALSE);
|
||||
#define('VERBOSE', TRUE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue