diff --git a/application/models/Alib.php b/application/models/Alib.php index 751ab3996..6fd294f67 100644 --- a/application/models/Alib.php +++ b/application/models/Alib.php @@ -19,33 +19,6 @@ class Alib { /* ----------------------------------------------- session/authentication */ /* -------------------------------------------------------- authorization */ - /** - * Insert permission record - * - * @param int $sid - * local user/group id - * @param string $action - * @param int $oid - * local object id - * @param string $type - * 'A'|'D' (allow/deny) - * @return int - * local permission id - */ - public static function AddPerm($sid, $action, $oid, $type='A') - { - global $CC_CONFIG, $CC_DBC; - $permid = $CC_DBC->nextId($CC_CONFIG['permSequence']); - $sql = "INSERT INTO ".$CC_CONFIG['permTable']." (permid, subj, action, obj, type)" - ." VALUES ($permid, $sid, '$action', $oid, '$type')"; - $r = $CC_DBC->query($sql); - if (PEAR::isError($r)) { - return($r); - } - return $permid; - } // fn addPerm - - /** * Remove permission record * diff --git a/application/models/Backup.php b/application/models/Backup.php deleted file mode 100755 index 6b5c33c80..000000000 --- a/application/models/Backup.php +++ /dev/null @@ -1,486 +0,0 @@ -gb =& $gb; - $this->token = null; - $this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log'; - $this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n"); - } - - - /** - * Open a backup - * Create a backup file (tarball) - * - * @param string $sessid - * @param array $criteria - * struct - see search criteria - * @return array - * hasharray with field: - * token string: backup token - */ - public function openBackup($sessid, $criteria='') - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n"); - } - $this->sessid = $sessid; - $this->criteria = $criteria; - - // get ids (and real filenames) which files match with criteria - $srch = $this->gb->localSearch($this->criteria,$this->sessid); - if (PEAR::isError($srch)) { - return $srch; - } - $this->setIDs($srch); - - // get real filenames - if (is_array($this->ids)) { - $this->setFilenames(); - - $this->setEnviroment(true); - - // write a status file - file_put_contents($this->statusFile, 'working'); - - // save the metafile to tmpdir - $hostname = trim(`hostname`); - $ctime = time(); - $ctime_f = date("Ymd-H:i:s"); - file_put_contents("{$this->tmpDirMeta}/storage.xml", - "\n". - "\n" - ); - - // copy all file to tmpdir - $this->copyAllFiles(); - - // do everything - $this->doIt(); - - return array('token'=>$this->token); - } else { - return false; - } - } - - - /** - * Check the status of backup. - * - * @param unknown $token - * @return array - * status : string - susccess | working | fault - * faultString: string - description of fault - * token : stirng - backup token - * url : string - access url - * tmpfile : string - access filename - */ - public function checkBackup($token) - { - global $CC_CONFIG; - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n"); - } - $this->token = $token; - $this->setEnviroment(); - $status = file_get_contents($this->statusFile); - if (strpos($status,'fault')!==false) { - list($status,$faultString) = explode('|',$status); - } - switch ($status) { - case 'success': - $r['url'] = BasicStor::GetUrlPart()."access/$token.".BACKUP_EXT; - $r['tmpfile'] = $CC_CONFIG['accessDir']."/$token.".BACKUP_EXT; - case 'working': - case 'fault': - $r['status'] = $status; - $r['faultString'] = $faultString; - $r['token'] = $token; - break; - } - return $r; - } - - - /** - * Close a backup - * - * @param unknown $token - * @return boolean - */ - public function closeBackup($token) - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." closeBackup - token:$token\n"); - } - # post procedures - $this->token = $token; - $this->setEnviroment(); - BasicStor::bsRelease($token, ACCESS_TYPE); - Backup::rRmDir($this->tmpDir); - unlink($this->statusFile); - unlink($this->tmpFile); - if (is_file($this->tmpName)) { - unlink($this->tmpName); - } - return !is_file($this->tmpFile); - } - - - /** - * list of unclosed backups - * - * @param string $stat - * if this parameter is not set, then return with all unclosed backups - * @return array of hasharray with field: - * status : string - susccess | working | fault - * token : stirng - backup token - * url : string - access url - */ - public function listBackups($stat='') - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." listBackups - stat:$stat\n"); - } - // open temporary dir - $tokens = BasicStor::GetTokensByType(ACCESS_TYPE); - // echo 'tokens:'; print_r($tokens); echo ''; - foreach ($tokens as $token) { - $st = $this->checkBackup($token); - if ($stat=='' || $st['status']==$stat) { - $r[] = $st; - } - } - return $r; - } - - - /** - * Set the ids from searchResult - * - * @param array $searchResult : array of gunids - */ - private function setIDs($searchResult) - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." setIDs\n"); - } - if (is_array($searchResult['results'])) { - $this->ids = $searchResult['results']; - } else { - $this->addLogItem("-E- ".date("Ymd-H:i:s")." setIDs - the parameter is not array!\n"); - return PEAR::raiseError('The IDs variable isn\'t array.'); - } - } - - - /** - * Set the filenames from ids. - * - */ - private function setFilenames() - { - // if ($this->loglevel=='debug') { - // $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n"); - // } - // if (is_array($this->ids)) { - // foreach ($this->ids as $i => $item) { - // $gunid = $item['gunid']; - // // get a stored file object of this gunid - // $sf = StoredFile::RecallByGunid($gunid); - // if (is_null($sf) || PEAR::isError($sf)) { - // return $sf; - // } - // $lid = BasicStor::IdFromGunid($gunid); - // if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) { - // $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n"); - // return PEAR::raiseError('Backup::setFilenames : Authorize ... error.'); - // } - // // if the file is a playlist then it has only a meta file - // if (strtolower($sf->md->format) != 'playlist') { - // $this->filenames[] = array( - // 'filename' => $sf->getRealFileName(), - // 'format' => $sf->md->format - // ); - // } - // $this->filenames[] = array( - // 'filename' => $sf->getRealMetadataFileName(), - // 'format' => $sf->md->format - // ); - // if ($this->loglevel=='debug') { - // $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n"); - // } - // } - // return $this->filenames; - // } else { - // $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n"); - // return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.'); - // } - } - - - /** - * Create the tarball - call the shell script - * - */ - private function doIt() - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n"); - } - $command = dirname(__FILe__)."/../bin/backup.sh" - ." {$this->tmpDir}" - ." {$this->tmpFile}" - ." {$this->statusFile}" - ." >> {$this->logFile} &"; - $res = system("$command"); - sleep(2); - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt - command:$command\n"); - } - } - - - /** - * Copy the real files into the tmp dirs to tar they. - * - */ - private function copyAllFiles() - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." copyAllFiles\n"); - } - //echo 'this->filenames:'; print_r($this->filenames); echo ''; - if (is_array($this->filenames)) { - foreach ($this->filenames as $v) { - # get the filename from full path - $fn = substr($v['filename'],strrpos($v['filename'],'/')); - switch (strtolower($v['format'])) { - case 'playlist': - # if playlist then copy to the playlist dir - copy($v['filename'],$this->tmpDirPlaylist.$fn); - break; - case 'audioclip': - # if audioclip then copy to the audioclip dir - copy($v['filename'],$this->tmpDirClip.$fn); - break; - } - } - } - } - - - /** - * Figure out the enviroment to the 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 temporary directories - if (is_null($this->token) && $createDir) { - $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); - mkdir($this->tmpDirClip); - mkdir($this->tmpDirMeta); - $this->genToken(); - } else { - $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; - $this->tmpDir = $this->tmpName.'.dir'; - $this->tmpDirPlaylist = $this->tmpDir. '/playlist'; - $this->tmpDirClip = $this->tmpDir. '/audioClip'; - $this->tmpDirMeta = $this->tmpDir. '/meta-inf'; - } else { - $this->addLogItem("-E- ".date("Ymd-H:i:s")." setEnviroment - Corrupt symbolic link.\n"); - return false; - } - } - $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"); - $this->addLogItem("this->tmpDir: $this->tmpDir\n"); - $this->addLogItem("this->tmpDirPlaylist: $this->tmpDirPlaylist\n"); - $this->addLogItem("this->tmpDirClip: $this->tmpDirClip\n"); - $this->addLogItem("this->tmpDirMeta: $this->tmpDirMeta\n"); - $this->addLogItem("this->token: $this->token\n"); - $this->addLogItem("this->statusFile: $this->statusFile\n"); - } - } - - - /** - * Generate a new token. - * @return void - */ - private function genToken() - { - $acc = BasicStor::bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE); - if (PEAR::isError($acc)) { - return $acc; - } - $this->token = $acc['token']; - } - - - /** - * Add a line to the logfile. - * - * @param string $item - * the new row of log file - */ - private function addLogItem($item) - { - $f = fopen($this->logFile,'a'); - fwrite($f,$item); - fclose($f); - } - - - /** - * Delete a directory recursive - * - * @param string $dirname - * path of dir. - */ - private static function rRmDir($dirname) - { - if (is_dir($dirname)) { - $dir_handle = opendir($dirname); - } - while ($file = readdir($dir_handle)) { - if ( ($file != ".") && ($file != "..") ) { - if (!is_dir($dirname."/".$file)) { - unlink ($dirname."/".$file); - } else { - Backup::rRmDir($dirname."/".$file); - } - } - } - closedir($dir_handle); - rmdir($dirname); - return true; - } - -} // classs Backup diff --git a/application/models/BasicStor.php b/application/models/BasicStor.php index b26b6ef80..dc31970e1 100644 --- a/application/models/BasicStor.php +++ b/application/models/BasicStor.php @@ -59,52 +59,6 @@ require_once(dirname(__FILE__)."/StoredFile.php"); require_once(dirname(__FILE__)."/Transport.php"); require_once(dirname(__FILE__)."/Playlist.php"); -//$g_metadata_xml_to_db_mapping = array( -// "dc:format" => "format", -// "ls:bitrate" => "bit_rate", -// "ls:samplerate" => "sample_rate", -// "dcterms:extent" => "length", -// "dc:title" => "track_title", -// "dc:description" => "comments", -// "dc:type" => "genre", -// "dc:creator" => "artist_name", -// "dc:source" => "album_title", -// "ls:channels" => "channels", -// "ls:filename" => "name", -// "ls:year" => "year", -// "ls:url" => "url", -// "ls:track_num" => "track_number", -// "ls:mood" => "mood", -// "ls:bpm" => "bpm", -// "ls:disc_num" => "disc_number", -// "ls:rating" => "rating", -// "ls:encoded_by" => "encoded_by", -// "dc:publisher" => "label", -// "ls:composer" => "composer", -// "ls:encoder" => "encoder", -// "ls:crc" => "checksum", -// "ls:lyrics" => "lyrics", -// "ls:orchestra" => "orchestra", -// "ls:conductor" => "conductor", -// "ls:lyricist" => "lyricist", -// "ls:originallyricist" => "original_lyricist", -// "ls:radiostationname" => "radio_station_name", -// "ls:audiofileinfourl" => "info_url", -// "ls:artisturl" => "artist_url", -// "ls:audiosourceurl" => "audio_source_url", -// "ls:radiostationurl" => "radio_station_url", -// "ls:buycdurl" => "buy_this_url", -// "ls:isrcnumber" => "isrc_number", -// "ls:catalognumber" => "catalog_number", -// "ls:originalartist" => "original_artist", -// "dc:rights" => "copyright", -// "dcterms:temporal" => "report_datetime", -// "dcterms:spatial" => "report_location", -// "dcterms:entity" => "report_organization", -// "dc:subject" => "subject", -// "dc:contributor" => "contributor", -// "dc:language" => "language"); - /** * Core of Airtime file storage module * @@ -129,93 +83,6 @@ class BasicStor { } - /** - * Store new file in the storage - * - * @param array $p_values - * See StoredFile::Insert() for details. - * @param boolean $copyMedia - * copy the media file if true, make symlink if false - * @return StoredFile|PEAR_Error - * The StoredFile that was created. - */ - // public function bsPutFile($p_values, $p_copyMedia=TRUE) - // { - // $storedFile = StoredFile::Insert($p_values, $p_copyMedia); - // return $storedFile; - // } - - - /** - * Rename file - * - * @param int $id - * Virtual file's local id - * @param string $newName - * @return boolean|PEAR_Error - */ - // public function bsRenameFile($id, $newName) - // { - // switch (BasicStor::GetObjType($id)) { - // case "audioclip": - // case "playlist": - // case "webstream": - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // // catch nonerror exception: - // //if($storedFile->getCode() != GBERR_FOBJNEX) - // return $storedFile; - // } - // $res = $storedFile->setName($newName); - // if (PEAR::isError($res)) { - // return $res; - // } - // break; - // case "File": - // default: - // } - // return TRUE; - // } - - - /** - * Replace file. Doesn't change filetype! - * - * @param int $id - * Virtual file's local id - * @param string $localFilePath - * Local path of media file - * @param string $metadataFilePath - * Local path of metadata file - * @param string $mdataLoc - * 'file'|'string' - * @return true|PEAR_Error - * @exception PEAR::error - */ - // public function bsReplaceFile($id, $localFilePath, $metadataFilePath, $mdataLoc='file') - // { - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // if (!empty($metadataFilePath) && - // ($mdataLoc!='file' || file_exists($metadataFilePath))) { - // $r = $storedFile->setMetadata($metadataFilePath, $mdataLoc); - // if (PEAR::isError($r)) { - // return $r; - // } - // } - // if (!empty($localFilePath) && file_exists($localFilePath)) { - // $r = $storedFile->setRawMediaData($localFilePath); - // if (PEAR::isError($r)) { - // return $r; - // } - // } - // return TRUE; - // } - - - /* ----------------------------------------------------- put, access etc. */ /** * Check validity of access/put token @@ -391,531 +258,8 @@ class BasicStor { } - /** - * Create and return downloadable URL for file - * - * @param int $id - * Virtual file's local id - * @param string $part - * 'media'|'metadata' - * @param int $parent - * parent token (recursive access/release) - * @return array - * array with strings: - * downloadable URL, download token, chsum, size, filename - */ - // public function bsOpenDownload($id, $part='media') - // { - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // $gunid = $storedFile->gunid; - // switch ($part) { - // case "media": - // $realfile = $storedFile->getRealFileName(); - // $ext = $storedFile->getFileExtension(); - // $filename = $storedFile->getName(); - // break; - // case "metadata": - // $realfile = $storedFile->getRealMetadataFileName(); - // $ext = "xml"; - // $filename = $storedFile->getName(); - // break; - // default: - // return PEAR::raiseError( - // "BasicStor::bsOpenDownload: unknown part ($part)" - // ); - // } - // $acc = BasicStor::bsAccess($realfile, $ext, $gunid, 'download'); - // if (PEAR::isError($acc)) { - // return $acc; - // } - // $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']); - // $chsum = md5_file($realfile); - // $size = filesize($realfile); - // return array( - // 'url'=>$url, 'token'=>$acc['token'], - // 'chsum'=>$chsum, 'size'=>$size, - // 'filename'=>$filename - // ); - // } - - - /** - * Discard downloadable URL - * - * @param string $token - * Download token - * @param string $part - * 'media'|'metadata' - * @return string - * gunid - */ - // public function bsCloseDownload($token, $part='media') - // { - // if (!BasicStor::bsCheckToken($token, 'download')) { - // return PEAR::raiseError( - // "BasicStor::bsCloseDownload: invalid token ($token)" - // ); - // } - // $r = BasicStor::bsRelease($token, 'download'); - // if (PEAR::isError($r)){ - // return $r; - // } - // return (is_null($r['gunid']) ? $r['realFname'] : $r['gunid']); - // } - - - /** - * Create writable URL for HTTP PUT method file insert - * - * @param string $chsum - * md5sum of the file having been put - * @param string $gunid - * global unique id - * (NULL for special files such imported playlists) - * @param int $owner - * local user id - owner of token - * @return array - * array with: - * url string: writable URL - * fname string: writable local filename - * token string: PUT token - */ - // public function bsOpenPut($chsum, $gunid, $owner=NULL) - // { - // global $CC_CONFIG, $CC_DBC; - // if (!is_null($gunid)) { - // $gunid = StoredFile::NormalizeGunid($gunid); - // } - // $escapedChsum = pg_escape_string($chsum); - // $token = StoredFile::CreateGunid(); - // $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable'] - // ." WHERE token=x'$token'::bigint"); - // if (PEAR::isError($res)) { - // return $res; - // } - // $gunidSql = (is_null($gunid) ? "NULL" : "x'{$gunid}'::bigint" ); - // $ownerSql = (is_null($owner) ? "NULL" : "$owner" ); - // $res = $CC_DBC->query(" - // INSERT INTO ".$CC_CONFIG['accessTable']." - // (gunid, token, ext, chsum, type, owner, ts) - // VALUES - // ($gunidSql, x'$token'::bigint, - // '', '$escapedChsum', 'put', $ownerSql, now())"); - // if (PEAR::isError($res)) { - // return $res; - // } - // $fname = $CC_CONFIG['accessDir']."/$token"; - // touch($fname); // is it needed? - // $url = BasicStor::GetUrlPart()."xmlrpc/put.php?token=$token"; - // return array('url'=>$url, 'fname'=>$fname, 'token'=>$token); - // } - - - /** - * Get file from writable URL and return local filename. - * Caller should move or unlink this file. - * - * @param string $token - * PUT token - * @return array - * hash with fields: - * fname string, local path of the file having been put - * owner int, local subject id - owner of token - */ - // public function bsClosePut($token) - // { - // global $CC_CONFIG, $CC_DBC; - // $token = StoredFile::NormalizeGunid($token); - // - // if (!BasicStor::bsCheckToken($token, 'put')) { - // return PEAR::raiseError( - // "BasicStor::bsClosePut: invalid token ($token)", - // GBERR_TOKEN); - // } - // $row = $CC_DBC->getRow( - // "SELECT chsum, owner FROM ".$CC_CONFIG['accessTable'] - // ." WHERE token=x'{$token}'::bigint"); - // if (PEAR::isError($row)) { - // return $row; - // } - // $fname = $CC_CONFIG['accessDir']."/$token"; - // $md5sum = md5_file($fname); - // - // $chsum = $row['chsum']; - // $owner = $row['owner']; - // $error = null; - // if ( (trim($chsum) != '') && ($chsum != $md5sum) ) { - // // Delete the file if the checksums do not match. - // if (file_exists($fname)) { - // @unlink($fname); - // } - // $error = new PEAR_Error( - // "BasicStor::bsClosePut: md5sum does not match (token=$token)". - // " [$chsum/$md5sum]", - // GBERR_PUT); - // } else { - // // Remember the MD5 sum - // $storedFile = StoredFile::RecallByToken($token); - // if (!is_null($storedFile) && !PEAR::isError($storedFile)) { - // $storedFile->setMd5($md5sum); - // } else { - //# $error = $storedFile; - // } - // } - // - // // Delete entry from access table. - // $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable'] - // ." WHERE token=x'$token'::bigint"); - // if (PEAR::isError($error)) { - // return $error; - // } elseif (PEAR::isError($res)) { - // return $res; - // } - // - // return array('fname'=>$fname, 'owner'=>$owner); - // } - - - /** - * Check uploaded file - * - * @param string $token - * "Put" token - * @return array - * hash, ( - * status: boolean, - * size: int - filesize - * expectedsum: string - expected checksum - * realsum: string - checksum of uploaded file - * ) - */ - // public function bsCheckPut($token) - // { - // global $CC_CONFIG, $CC_DBC; - // if (!BasicStor::bsCheckToken($token, 'put')) { - // return PEAR::raiseError( - // "BasicStor::bsCheckPut: invalid token ($token)" - // ); - // } - // $chsum = $CC_DBC->getOne(" - // SELECT chsum FROM ".$CC_CONFIG['accessTable']." - // WHERE token=x'{$token}'::bigint - // "); - // if (PEAR::isError($chsum)) { - // return $chsum; - // } - // $fname = $CC_CONFIG['accessDir']."/$token"; - // $md5sum = md5_file($fname); - // $size = filesize($fname); - // $status = ($chsum == $md5sum); - // return array( - // 'status'=>$status, 'size'=>$size, - // 'expectedsum'=>$chsum, - // 'realsum'=>$md5sum, - // ); - // } - - - /** - * Return starting part of storageServer URL - * - * @return string - * URL - */ - // public static function GetUrlPart() - // { - // global $CC_CONFIG; - // $host = $CC_CONFIG['storageUrlHost']; - // $port = $CC_CONFIG['storageUrlPort']; - // $path = $CC_CONFIG['storageUrlPath']; - // return "http://$host:$port$path/"; - // } - - - /** - * Get tokens by type - * - * @param string $type - * access|put|render etc. - * @return array - * array of tokens - */ - // public static function GetTokensByType($type) - // { - // global $CC_CONFIG, $CC_DBC; - // $res = $CC_DBC->query( - // "SELECT TO_HEX(token) AS token FROM ".$CC_CONFIG['accessTable']." WHERE type=?", - // array($type)); - // while ($row = $res->fetchRow()) { - // $r[] = $row['token']; - // } - // return $r; - // } - - /* ----------------------------------------------------- metadata methods */ - /** - * Replace metadata with new XML file or string - * - * @param int $id - * Virtual file's local id - * @param string $mdata - * Local path of metadata XML file - * @param string $mdataLoc - * 'file'|'string' - * @return boolean|PEAR_Error - */ - // public function bsReplaceMetadata($id, $mdata, $mdataLoc='file') - // { - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // return $storedFile->setMetadata($mdata, $mdataLoc); - // } - - - /** - * Get metadata as XML string - * - * @param int $id - * Virtual file's local id - * @return string|PEAR_Error - */ - // public function bsGetMetadata($id) - // { - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // return $storedFile->getMetadata(); - // } - - - /** - * Get dc:title (if exists) - * - * @param int $id - * Virtual file's local id - * @param string $gunid - * Virtual file's gunid, optional, used only if not - * null, id is then ignored - * @return string|PEAR_Error - */ - // public function bsGetTitle($id, $gunid=NULL) - // { - // if (is_null($gunid)) { - // $storedFile = StoredFile::Recall($id); - // } else { - // $storedFile = StoredFile::RecallByGunid($gunid); - // } - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // $r = $storedFile->md["title"]; - // $title = (empty($r) ? 'unknown' : $r); - // return $title; - // } - - - /** - * Get metadata element value - * - * @param int $id - * Virtual file's local id - * @param string|array|null $category - * metadata element name, or array of metadata element names, - * if null is passed, all metadata values for the given ID will - * be fetched. - * @return string|array - * If a string is passed in for $category, a string is returned, - * if an array is passed, an array is returned. - * @see Metadata::getMetadataValue - */ - // public function bsGetMetadataValue($id, $category = null) - // { - // if (!is_numeric($id)) { - // return null; - // } - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // if (is_null($category)) { - // return $storedFile->md; - // } elseif (is_array($category)) { - // $values = array(); - // foreach ($category as $tmpCat) { - // $values[$tmpCat] = $storedFile->md[$tmpCat]; - // } - // return $values; - // } else { - // return $storedFile->md[$category]; - // } - // } - - - /** - * Convert XML name to database column name. Used for backwards compatibility - * with old code. - * - * @param string $p_category - * @return string|null - */ - // public static function xmlCategoryToDbColumn($p_category) - // { - // global $g_metadata_xml_to_db_mapping; - // if (array_key_exists($p_category, $g_metadata_xml_to_db_mapping)) { - // return $g_metadata_xml_to_db_mapping[$p_category]; - // } - // return null; - // } - - - /** - * Convert database column name to XML name. - * - * @param string $p_dbColumn - * @return string|null - */ - // public static function dbColumnToXmlCatagory($p_dbColumn) - // { - // global $g_metadata_xml_to_db_mapping; - // $str = array_search($p_dbColumn, $g_metadata_xml_to_db_mapping); - // // make return value consistent with xmlCategoryToDbColumn() - // if ($str === FALSE) { - // $str = null; - // } - // return $str; - // } - - /** - * Set metadata element value - * - * @param int|StoredFile $id - * Database ID of file - * @param string $category - * Metadata element identification (e.g. dc:title) - * @param string $value - * value to store, if NULL then delete record - * @return boolean - */ - // public static function bsSetMetadataValue($p_id, $p_category, $p_value) - // { - // global $CC_CONFIG, $CC_DBC; - // if (!is_string($p_category) || is_array($p_value)) { - // return FALSE; - // } - // if (is_a($p_id, "StoredFile")) { - // $p_id = $p_id->getId(); - // } - // if ($p_category == 'dcterms:extent') { - // $p_value = BasicStor::NormalizeExtent($p_value); - // } - // $columnName = BasicStor::xmlCategoryToDbColumn($p_category); // Get column name - // - // if (!is_null($columnName)) { - // $escapedValue = pg_escape_string($p_value); - // $sql = "UPDATE ".$CC_CONFIG["filesTable"] - // ." SET $columnName='$escapedValue'" - // ." WHERE id=$p_id"; - // //var_dump($sql); - // $res = $CC_DBC->query($sql); - // if (PEAR::isError($res)) { - // return $res; - // } - // } - // return TRUE; - // } - - - /** - * Normalize time value to hh:mm:ss:dddddd format - * - * @param mixed $v - * value to normalize - * @return string - */ - // private static function NormalizeExtent($v) - // { - // if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) { - // $s = Playlist::playlistTimeToSeconds($v); - // $t = Playlist::secondsToPlaylistTime($s); - // return $t; - // } - // return $v; - // } - - - /** - * Set metadata values in 'batch' mode - * - * @param int|StoredFile $id - * Database ID of file or StoredFile object - * @param array $values - * array of key/value pairs - * (e.g. 'dc:title'=>'New title') - * @return boolean - */ - // public static function bsSetMetadataBatch($id, $values) - // { - // global $CC_CONFIG, $CC_DBC; - // if (!is_array($values)) { - // $values = array($values); - // } - // if (count($values) == 0) { - // return true; - // } - // if (is_a($id, "StoredFile")) { - // $storedFile =& $id; - // } else { - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // } - // foreach ($values as $category => $oneValue) { - // $columnName = BasicStor::xmlCategoryToDbColumn($category); - // if (!is_null($columnName)) { - // if ($category == 'dcterms:extent') { - // $oneValue = BasicStor::NormalizeExtent($oneValue); - // } - // // Since track_number is an integer, you cannot set - // // it to be the empty string, so we NULL it instead. - // if ($columnName == 'track_number' && empty($oneValue)) { - // $sqlPart = "$columnName = NULL"; - // } elseif (($columnName == 'length') && (strlen($oneValue) > 8)) { - // // Postgres doesnt like it if you try to store really large hour - // // values. TODO: We need to fix the underlying problem of getting the - // // right values. - // $parts = explode(':', $oneValue); - // $hour = intval($parts[0]); - // if ($hour > 24) { - // continue; - // } else { - // $sqlPart = "$columnName = '$oneValue'"; - // } - // } else { - // $escapedValue = pg_escape_string($oneValue); - // $sqlPart = "$columnName = '$escapedValue'"; - // } - // $sqlValues[] = $sqlPart; - // } - // } - // if (count($sqlValues)==0) { - // return TRUE; - // } - // $sql = "UPDATE ".$CC_CONFIG["filesTable"] - // ." SET ".join(",", $sqlValues) - // ." WHERE id=$id"; - // $CC_DBC->query($sql); - // return TRUE; - // } - /** * Method returning array with where-parts of sql queries * @@ -1280,446 +624,6 @@ class BasicStor { /* ---------------------------------------------------- methods4playlists */ - /** - * Create a tarfile with playlist export - playlist and all matching - * sub-playlists and media files (if desired) - * - * @param array $plids - * Array of strings, playlist global unique IDs (one gunid is accepted too) - * @param string $type - * Playlist format, possible values: lspl | smil | m3u - * @param boolean $withContent - * if true, export related files too - * @return array - * hasharray with fields: - * fname string: readable fname, - * token string: access token - */ - // public function bsExportPlaylistOpen($plids, $type='lspl', $withContent=TRUE) - // { - // global $CC_CONFIG; - // if (!is_array($plids)) { - // $plids = array($plids); - // } - // $gunids = array(); - // foreach ($plids as $plid) { - // $pl = StoredFile::RecallByGunid($plid); - // if (is_null($pl) || PEAR::isError($pl)) { - // return $pl; - // } - // if ($withContent) { - // $gunidsX = $pl->export(); - // if (PEAR::isError($gunidsX)) { - // return $gunidsX; - // } - // } else { - // $gunidsX = array(array('gunid'=>$plid, 'type'=>'playlist')); - // } - // $gunids = array_merge($gunids, $gunidsX); - // } - // $plExts = array('lspl'=>"lspl", 'smil'=>"smil", 'm3u'=>"m3u"); - // $plExt = (isset($plExts[$type]) ? $plExts[$type] : "xml" ); - // $res = array(); - // $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plExport_'); - // $tmpf = "$tmpn.tar"; - // $tmpd = "$tmpn.dir"; - // mkdir($tmpd); - // $tmpdp = "$tmpn.dir/playlist"; - // mkdir($tmpdp); - // if ($withContent) { - // $tmpdc = "$tmpn.dir/audioClip"; - // mkdir($tmpdc); - // } - // foreach ($gunids as $i => $it) { - // $storedFile = StoredFile::RecallByGunid($it['gunid']); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - //// $MDfname = $storedFile->md->getFileName(); - // $MDfname = $storedFile->md["name"]; - // if (PEAR::isError($MDfname)) { - // return $MDfname; - // } - // if (file_exists($MDfname)) { - // switch ($it['type']) { - // case "playlist": - // $storedFile = $r = StoredFile::RecallByGunid($it['gunid']); - // switch ($type) { - // case "smil": - // $string = $r = $storedFile->outputToSmil(); - // break; - // case "m3u": - // $string = $r = $storedFile->outputToM3u(); - // break; - // default: - //// $string = $r = $storedFile->md->genXmlDoc(); - // } - // if (PEAR::isError($r)) { - // return $r; - // } - // $r = BasicStor::WriteStringToFile($string, "$tmpdp/{$it['gunid']}.$plExt"); - // if (PEAR::isError($r)) { - // return $r; - // } - // break; - // default: - // copy($MDfname, "$tmpdc/{$it['gunid']}.xml"); break; - // } // switch - // } // if file_exists() - // $RADfname = $storedFile->getRealFileName(); - // if (PEAR::isError($RADfname)) { - // return $RADfname; - // } - // $RADext = $storedFile->getFileExtension(); - // if (PEAR::isError($RADext)) { - // return $RADext; - // } - // if (file_exists($RADfname)) { - // copy($RADfname, "$tmpdc/{$it['gunid']}.$RADext"); - // } - // } - // if (count($plids)==1) { - // copy("$tmpdp/$plid.$plExt", "$tmpd/exportedPlaylist.$plExt"); - // } - // $res = `cd $tmpd; tar cf $tmpf * --remove-files`; - // @rmdir($tmpdc); - // @rmdir($tmpdp); - // @rmdir($tmpd); - // unlink($tmpn); - // $acc = BasicStor::bsAccess($tmpf, 'tar', NULL/*gunid*/, 'access'); - // if (PEAR::isError($acc)) { - // return $acc; - // } - // return $acc; - // } - - - /** - * Close playlist export previously opened by the bsExportPlaylistOpen - * method - * - * @param string $token - * Access token obtained from bsExportPlaylistOpen method call. - * @return true/PEAR_Error - */ - // public function bsExportPlaylistClose($token) - // { - // $r = BasicStor::bsRelease($token, 'access'); - // if (PEAR::isError($r)) { - // return $r; - // } - // $file = $r['realFname']; - // if (file_exists($file)) { - // if(! @unlink($file)){ - // return PEAR::raiseError( - // "BasicStor::bsExportPlaylistClose: unlink failed ($file)", - // GBERR_FILEIO); - // } - // } - // return TRUE; - // } - - - /** - * Import playlist in LS Archive format - * - * @param string $plid - * Playlist gunid - * @param string $aPath - * Absolute path part of imported file (e.g. /home/user/airtime) - * @param string $rPath - * Relative path/filename part of imported file (e.g. playlists/playlist_1.smil) - * @param string $ext - * Playlist extension (determines type of import) - * @param array $gunids - * Hash relation from filenames to gunids - * @param int $subjid - * Local subject (user) id (id of user doing the import) - * @return int - * Result file local id (or error object) - */ - // public function bsImportPlaylistRaw($plid, $aPath, $rPath, $ext, &$gunids, $subjid) - // { - // $id = BasicStor::IdFromGunid($plid); - // if (!is_null($id)) { - // return $id; - // } - // $path = realpath("$aPath/$rPath"); - // if (FALSE === $path) { - // return PEAR::raiseError( - // "BasicStor::bsImportPlaylistRaw: file doesn't exist ($aPath/$rPath)" - // ); - // } - // switch ($ext) { - // case "xml": - // case "lspl": - // $fname = $plid; - // $values = array( - // "filename" => $fname, - // "metadata" => $path, - // "gunid" => $plid, - // "filetype" => "playlist" - // ); - // $storedFile = StoredFile::Insert($values); - // $res = $storedFile->getId(); - // break; - // case "smil": - // require_once("SmilPlaylist.php"); - // $res = SmilPlaylist::import($this, $aPath, $rPath, $gunids, $plid, $subjid); - // if (PEAR::isError($res)) { - // break; - // } - // $res = $res->getId(); - // break; - // case "m3u": - // require_once("M3uPlaylist.php"); - // $res = M3uPlaylist::import($this, $aPath, $rPath, $gunids, $plid, $subjid); - // if (PEAR::isError($res)) { - // break; - // } - // $res = $res->getId(); - // break; - // default: - // $res = PEAR::raiseError( - // "BasicStor::importPlaylistRaw: unknown playlist format". - // " (gunid:$plid, format:$ext)" - // ); - // break; - // } - // if (!PEAR::isError($res)) { - // $gunids[basename($rPath)] = $plid; - // } - // return $res; - // } - - - /** - * Import playlist in LS Archive format - * - * @param string $fpath - * Imported file pathname - * @param int $subjid - * Local subject (user) id (id of user doing the import) - * @return int - * Result file local id (or error object) - */ - // public function bsImportPlaylist($fpath, $subjid) - // { - // global $CC_CONFIG; - // // untar: - // $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plImport_'); - // $tmpd = "$tmpn.dir"; - // $tmpdc = "$tmpd/audioClip"; - // $tmpdp = "$tmpd/playlist"; - // mkdir($tmpd); - // $res = `cd $tmpd; tar xf $fpath`; - // // clips: - // $d = @dir($tmpdc); - // $entries = array(); - // $gunids = array(); - // if ($d !== false) { - // while (false !== ($entry = $d->read())) { - // if (preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)) { - // list(,$gunid, $ext) = $va; - // switch ($ext) { - // case"xml": - // $entries[$gunid]['metadata'] = $entry; - // break; - // default: - // $entries[$gunid]['rawMedia'] = $entry; - // $entries[$gunid]['rawMediaExt'] = $ext; - // $gunids[$entry] = $gunid; - // break; - // } - // } - // } - // $d->close(); - // } - // $res = TRUE; - // foreach ($entries as $gunid => $it) { - // $rawMedia = "$tmpdc/{$it['rawMedia']}"; - // if (!file_exists($rawMedia)) { - // $rawMedia = NULL; - // } - // $metadata = "$tmpdc/{$it['metadata']}"; - // if (!file_exists($metadata)) { - // $metadata = NULL; - // } - // $f = StoredFile::RecallByGunid($gunid); - // if (!PEAR::isError($f)) { - // $exists = $f->existsFile(); - // if ( $exists ) { - // $res = $f->delete(); - // } - // } - // if (!PEAR::isError($res) ) { - // $values = array( - // "filename" => $gunid, - // "filepath" => $rawMedia, - // "metadata" => $metadata, - // "gunid" => $gunid, - // "filetype" => "audioclip" - // ); - // $storedFile = StoredFile::Insert($values); - // $res = $storedFile->getId(); - // } - // @unlink("$tmpdc/{$it['rawMedia']}"); - // @unlink("$tmpdc/{$it['metadata']}"); - // if (PEAR::isError($res)) { - // break; - // } - // } - // // playlists: - // $d = @dir($tmpdp); - // if ($d !== false) { - // while ((!PEAR::isError($res)) && false !== ($entry = $d->read())) { - // if (preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)) { - // list(,$gunid, $ext) = $va; - // $res = $this->bsImportPlaylistRaw($gunid, - // $tmpdp, $entry, $ext, $gunids, $subjid); - // unlink("$tmpdp/$entry"); - // if (PEAR::isError($res)) { - // break; - // } - // } - // } - // $d->close(); - // } - // //@rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd); - // @system("rm -rf $tmpdc"); - // @system("rm -rf $tmpdp"); - // @system("rm -rf $tmpd"); - // @unlink($tmpn); - // return $res; - // } - - - /* --------------------------------------------------------- info methods */ - - /** - * Analyze media file for internal metadata information - * - * @param int $id - * Virtual file's local id - * @return array - */ - // public function bsAnalyzeFile($id) - // { - // $storedFile = StoredFile::Recall($id); - // if (is_null($storedFile) || PEAR::isError($storedFile)) { - // return $storedFile; - // } - // $ia = $storedFile->analyzeFile(); - // return $ia; - // } - - - /** - * Check if file exists in the storage - * - * @param int $id - * Local id - * @param string $ftype - * Internal file type - * @param boolean $byGunid - * select file by gunid (id is then ignored) - * @return boolean - */ - // public function bsExistsFile($id, $ftype=NULL, $byGunid=FALSE) - // { - // if ($byGunid) { - // $storedFile = StoredFile::RecallByGunid($id); - // } else { - // $storedFile = StoredFile::Recall($id); - // } - // if (is_null($storedFile)) { - // return $storedFile; - // } - // if (PEAR::isError($storedFile)) { - // // catch some exceptions - // switch ($storedFile->getCode()) { - // case GBERR_FILENEX: - // case GBERR_FOBJNEX: - // return FALSE; - // break; - // default: - // return $storedFile; - // } - // } - // $realFtype = BasicStor::GetType($storedFile->gunid); - // if (!is_null($ftype) && ( - // (strtolower($realFtype) != strtolower($ftype)) - // // webstreams are subset of audioclips - // && !($realFtype == 'webstream' && $ftype == 'audioclip') - // )) { - // return FALSE; - // } - // return TRUE; - // } - - - /* ---------------------------------------------------- redefined methods */ - /** - * Get object type by id. - * - * @param int $oid - * Local object id - * @return string|PEAR_Error - */ - // public static function GetObjType($p_id) - // { - // $type = "unknown"; - // $f = StoredFile::Recall($p_id); - // return $f->getType(); - - // $gunid = BasicStor::GunidFromId($oid); - // if (PEAR::isError($gunid)) { - // return $gunid; - // } - // $ftype = BasicStor::GetType($gunid); - // if (PEAR::isError($ftype)) { - // return $ftype; - // } - // if (!is_null($ftype)) { - // $type = $ftype; - // } - // return $type; - // } - - - /** - * Add new user - * - * @param string $login - * @param string $pass - * @param string $realname - * @return int|PEAR_Error - */ - public static function addSubj($login, $pass=NULL, $realname='') - { - global $CC_CONFIG; - $uid = Subjects::AddSubj($login, $pass, $realname); - if (PEAR::isError($uid)) { - return $uid; - } - if (Subjects::IsGroup($uid) === FALSE) { - $res = Alib::AddPerm($uid, '_all', '0', 'A'); - if (PEAR::isError($res)) { - return $res; - } - $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']); - if (PEAR::isError($res)) { - return $res; - } - // $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']); - // if (PEAR::isError($res)) { - // return $res; - // } - } - return $uid; - } - - /* ================================================== "protected" methods */ /** * Check authorization - auxiliary method @@ -1758,98 +662,6 @@ class BasicStor { } - /** - * Get local id from global id (in hex). - * - * @param string $p_gunid - * Global id - * @return int - * Local id - */ - // public static function IdFromGunid($p_gunid) - // { - // global $CC_DBC; - // global $CC_CONFIG; - // return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid=x'$p_gunid'::bigint"); - // } - - /** - * Get local id from global id (big int). - * - * @param string $p_gunid - * Global id - * @return int - * Local id - */ - // public static function IdFromGunidBigInt($p_gunid) - // { - // global $CC_DBC; - // global $CC_CONFIG; - // return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid='$p_gunid'"); - // } - - - /** - * Get global id from local id - * - * @param int $p_id - * Local id - * @return string - * Global id - */ - // public static function GunidFromId($p_id) - // { - // global $CC_CONFIG; - // global $CC_DBC; - // if (!is_numeric($p_id)) { - // return NULL; - // } - // $gunid = $CC_DBC->getOne(" - // SELECT to_hex(gunid)as gunid FROM ".$CC_CONFIG['filesTable']." - // WHERE id='$p_id' - // "); - // if (PEAR::isError($gunid)) { - // return $gunid; - // } - // if (is_null($gunid)) { - // return NULL; - // } - // return StoredFile::NormalizeGunid($gunid); - // } - - - /** - * Get storage-internal file type - * - * @param string $p_gunid - * Global unique id of file - * @return string - */ - // public static function GetType($p_gunid) - // { - // global $CC_CONFIG; - // global $CC_DBC; - // $ftype = $CC_DBC->getOne(" - // SELECT ftype FROM ".$CC_CONFIG['filesTable']." - // WHERE gunid=x'$p_gunid'::bigint - // "); - // return $ftype; - // } - - - /** - * Check gunid format - * - * @param string $p_gunid - * Global unique ID - * @return boolean - */ - // protected static function CheckGunid($p_gunid) - // { - // $res = preg_match("|^([0-9a-fA-F]{16})?$|", $p_gunid); - // return $res; - // } - /** * Set playlist edit flag * @@ -1947,25 +759,6 @@ class BasicStor { print_r($va); } - - /** - * deleteFiles - * - * @return void - */ - // private function deleteFiles() - // { - // global $CC_CONFIG, $CC_DBC; - // $ids = $CC_DBC->getAll("SELECT id FROM ".$CC_CONFIG['filesTable']); - // if (is_array($ids)) { - // foreach ($ids as $i => $item) { - // $f = StoredFile::Recall($item['id']); - // $f->delete(); - // } - // } - // } - - /** * Aux logging for debug * diff --git a/application/models/GreenBox.php b/application/models/GreenBox.php index 6aa58a334..0cffb4f89 100644 --- a/application/models/GreenBox.php +++ b/application/models/GreenBox.php @@ -7,10 +7,7 @@ if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) { echo __FILE__.':line '.__LINE__.": Loaded BasicStor
"; } require_once("Playlist.php"); -require_once("Renderer.php"); require_once('Prefs.php'); -require_once("Backup.php"); -require_once('Restore.php'); require_once("Transport.php"); /** @@ -26,353 +23,8 @@ require_once("Transport.php"); class GreenBox extends BasicStor { /* ====================================================== storage methods */ - - /** - * Store new file in the storage - * - * @param string $fileName - * The name for the new file. - * @param string $mediaFileLP - * Local path of the media file - * @param string $mdataFileLP - * Local path of the metadata file - * @param string $sessid - * Session id - * @param string $gunid - * Global unique id - * @param string $ftype - * Internal file type - * @return int - * ID of the StoredFile that was created. - */ - public function putFile($p_values, $p_sessionId='') - { - if (($res = BasicStor::Authorize('write', null, $p_sessionId)) !== TRUE) { - return $res; - } - $storedFile = StoredFile::Insert($p_values); - return $storedFile; - } // fn putFile - - - /** - * Store new webstream - * - * @param string $fileName - * Name for new file - * @param string $mdataFileLP - * Local path of metadata file - * @param string $sessid - * Session id - * @param string $gunid - * Global unique id - * @param string $url - * Webstream url - * @return int - * @exception PEAR::error - */ - public function storeWebstream($fileName, $mdataFileLP, $sessid='', - $gunid=NULL, $url) - { - if (($res = BasicStor::Authorize('write', null, $sessid)) !== TRUE) { - return $res; - } - if (!file_exists($mdataFileLP)) { - $mdataFileLP = dirname(__FILE__).'/emptyWebstream.xml'; - } - $values = array( - "filename" => $fileName, - "metadata" => $mdataFileLP, - "gunid" => $gunid, - "filetype" => "webstream" - ); - $storedFile = StoredFile::Insert($values); - if (PEAR::isError($storedFile)) { - return $storedFile; - } - $r = $storedFile->setMetadataValue('ls:url', $url); - if (PEAR::isError($r)) { - return $r; - } - return $oid; - } // fn storeWebstream - - - /** - * Access stored file - increase access counter - * - * @param int $id - * virt.file's local id - * @param string $sessid - * session id - * @return string access token - */ -// function accessFile($id, $sessid='') -// { -// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { -// return $res; -// } -// $gunid = BasicStor::GunidFromId($id); -// $r = BasicStor::bsAccess(NULL, '', $gunid, 'access'); -// if (PEAR::isError($r)) { -// return $r; -// } -// $token = $r['token']; -// return $token; -// } // fn accessFile - - - /** - * Release stored file - decrease access counter - * - * @param string $token - * access token - * @param string $sessid - * session id - * @return boolean - */ -// function releaseFile($token, $sessid='') -// { -// $r = BasicStor::bsRelease($token, 'access'); -// if (PEAR::isError($r)) { -// return $r; -// } -// return FALSE; -// } // fn releaseFile - - - /** - * Analyze media file for internal metadata information - * - * @param int $id - * Virtual file's local id - * @param string $sessid - * Session id - * @return array - */ -// public function analyzeFile($id, $sessid='') -// { -// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { -// return $res; -// } -// return $this->bsAnalyzeFile($id); -// } - - - /** - * Rename file - * - * @param int $id - * Virtual file's local id - * @param string $newName - * @param string $sessid - * Session id - * @return boolean|PEAR_Error - */ -// public function renameFile($id, $newName, $sessid='') -// { -// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { -// return $res; -// } -// return $this->bsRenameFile($id, $newName); -// } - - - /** - * Replace file. Doesn't change filetype! - * - * @param int $id - * virt.file's local id - * @param string $mediaFileLP - * local path of media file - * @param string $mdataFileLP - * local path of metadata file - * @param string $sessid - * session id - * @return TRUE|PEAR_Error - */ -// public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='') -// { -// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { -// return $res; -// } -// return $this->bsReplaceFile($id, $mediaFileLP, $mdataFileLP); -// } - - - /** - * Delete file - * - * @param int $id - * local id - * @param int $sessid - * @param boolean $forced - * if true don't use trash -- now ignored - * @return true|PEAR_Error - */ - public function deleteFile($id, $sessid='', $forced=FALSE) - { - if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { - return $res; - } - $f = StoredFile::Recall($id); - return $f->delete(true); - } - - /* ------------------------------------------------------------- metadata */ - /** - * Replace metadata with new XML file or string - * - * @param int $id - * Virtual file's local id - * @param string $mdata - * XML string or local path of metadata XML file - * @param string $mdataLoc - * metadata location: 'file'|'string' - * @param string $sessid - * session id - * @return boolean|PEAR_Error - */ -// public function replaceMetadata($id, $mdata, $mdataLoc='file', $sessid='') -// { -// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { -// return $res; -// } -// return $this->bsReplaceMetadata($id, $mdata, $mdataLoc); -// } // fn replaceMetadata - - - /** - * Get metadata XML tree as string - * - * @param int $id - * Virtual file's local id - * @param string $sessid - * session id - * @return string|PEAR_Error - * @todo rename this function to "getMetadata" - */ - public function getMetadata($id, $sessid='') - { - if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { - return $res; - } - $f = StoredFile::Recall($id); - return $f->getMetadata(); - } - - - /** - * Return metadata as hierarchical PHP hash-array - * - * If xml:lang attribute is specified in metadata category, - * array of metadata values indexed by xml:lang values - * is presented instead of one plain metadata value. - * - * @param int $id - * local object id - * @param string $sessid - * session ID - * @return array - */ - public function getMetadataArray($id, $sessid) - { - if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { - return $res; - } - $storedFile = StoredFile::Recall($id); - if (is_null($storedFile) || PEAR::isError($storedFile)) { - return $storedFile; - } - return $storedFile->md; - -// $arr = $storedFile->md->genPhpArray(); - $md = FALSE; - foreach ($arr['children'] as $i=>$a) { - if ($a['elementname'] == 'metadata'){ - $md = $arr['children'][$i]; - break; - } - } - if ($md === FALSE) { - return PEAR::raiseError( - "GreenBox::getMetadataArray: no metadata container found" - ); - } - $res = array(); - foreach ($md['children'] as $el) { - $lang = isset($el['attrs']['xml:lang']) ? $el['attrs']['xml:lang'] : ""; - $category = $el['elementname']; - if ($lang == "") { - $res[$category] = $el['content']; - } else { - $res[$category][$lang] = $el['content']; - } - } - return $res; - } - - - /** - * Get metadata element value - * - * @param int $id - * Virtual file's local id - * @param string $category - * metadata element name - * @param string $sessid - * session id - * @param string $lang - * xml:lang value for select language version - * @param string $deflang - * xml:lang for default language - * @return array of matching records as hash with fields: - * - */ - public function getMetadataValue($id, $category, $sessid='', - $lang=NULL, $deflang=NULL) - { - if (!is_numeric($id)) { - return null; - } - if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { - return $res; - } - $f = StoredFile::Recall($id); - return $f->getMetadataValue($category); - } - - - /** - * Set metadata element value - * - * @param int $id - * Virtual file's local id - * @param string $category - * Metadata element identification (e.g. dc:title) - * @param string $sessid - * Session id - * @param string $value - * The value to store, if NULL then delete record - * @return boolean - */ - public function setMetadataValue($id, $category, $sessid, $value) - { - if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) { - return $res; - } - $f = StoredFile::Recall($id); - return $f->setMetadataValue($category, $value); - } // fn setMetadataValue - - /** * Search in local metadata database. * @@ -434,412 +86,7 @@ class GreenBox extends BasicStor { } // fn localSearch - /** - * Return values of specified metadata category - * - * @param string $category - * metadata category name - * with or without namespace prefix (dc:title, author) - * @param array $criteria - * see localSearch method - * @param string $sessid - * @return array, fields: - * results : array with found values - * cnt : integer - number of matching values - * @see BasicStor::bsBrowseCategory - */ - public function browseCategory($category, $criteria = null, $sessid = '') - { - $limit = 0; - $offset = 0; - if (!is_null($criteria)) { - $limit = intval(isset($criteria['limit']) ? $criteria['limit'] : 0); - $offset = intval(isset($criteria['offset']) ? $criteria['offset'] : 0); - } - $res = $this->bsBrowseCategory($category, $limit, $offset, $criteria); - return $res; - } // fn browseCategory - - /*====================================================== playlist methods */ - /** - * Create a new empty playlist. - * - * @param string $fname - * human readable menmonic file name - * @param string $sessid - * session ID - * @return int - * local id of created playlist - */ - public function createPlaylist($fname, $sessid='') - { - $pl = new Playlist(); - $pl = $pl->create($fname); - - return $pl; - } // fn createPlaylist - - public function setPLMetadataValue($id, $category, $value, $lang=NULL, $mid=NULL) - { - $pl = Playlist::Recall($id); - - if($pl === FALSE) - return FALSE; - - $res = $pl->setPLMetaData($category, $value, $lang); - - return $res; - } - - public function getPLMetadataValue($id, $category, $langId=NULL) - { - $pl = Playlist::Recall($id); - - if($pl === FALSE) - return FALSE; - - $res = $pl->getPLMetaData($category); - - return $res; - } - - /** - * Return playlist as XML string - * - * @param int $id - * local object id - * @param string $sessid - * session ID - * @return string - * XML - */ -// function getPlaylistXml($id, $sessid) -// { -// return $this->getMetadata($id, $sessid); -// } // fn getPlaylistXml - - - /** - * Return playlist as hierarchical PHP hash-array - * - * @param int $id - * local object id - * @param string $sessid - * session ID - * @return array - */ - public function getPlaylistArray($id) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->getContents(); - - if(is_null($res)) - return array(); - - return $res; - } // fn getPlaylistArray - - - /** - * Mark playlist as edited and return edit token - * - * @param int $id - * local object id - * @param string $sessid - * session ID - * @return string - * playlist access token - */ - public function lockPlaylistForEdit($id, $sessid) { - $pl = Playlist::Recall($id); - - if($pl === FALSE) - return; - - $res = $pl->lock($sessid); - - return $res; - } - - - /** - * clear edit flag. - * - * @param string $sessid - * session ID - * @return string gunid - */ - public function releaseLockedPlaylist($id, $sessid) { - $pl = Playlist::Recall($id); - - if($pl === FALSE) - return FALSE; - - $res = $pl->unlock($sessid); - return $res; - } - - - /** - * Add audioclip specified by local id to the playlist - * - * @param string $token - * playlist access token - * @param string $acId - * local ID of added file - * @param string $sessid - * session ID - * @param string $fadeIn - * in time format hh:mm:ss.ssssss - * @param string $fadeOut - * in time format hh:mm:ss.ssssss - * @param string $length - * length in extent format - - * for webstream (or for overrule length of audioclip) - * @param string $clipstart - * optional clipstart time format hh:mm:ss.ssssss - relative to begin - * @param string $clipend - * optional $clipend time format hh:mm:ss.ssssss - relative to begin - * @return boolean, true if added. - */ - public function addAudioClipToPlaylist($id, $acId, $pos=NULL, $fadeIn=NULL, $fadeOut=NULL, $cliplength=NULL, $cueIn=NULL, $cueOut=NULL) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->addAudioClip($acId, $pos, $fadeIn, $fadeOut, $cliplength, $cueIn, $cueOut); - - return $res; - } // fn addAudioClipToPlaylist - - - /** - * Remove audioclip from playlist - * - * @param string $id - * playlist id - * @param int $pos - * position of element in playlist to delete. - * @return boolean, true if deleted. - * @todo rename this function to "deleteAudioClipFromPlaylist" - */ - public function delAudioClipFromPlaylist($id, $pos) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->delAudioClip($pos); - if($res === FALSE) - return FALSE; - - return TRUE; - } - - /** - * Move audioClip to the new position in the playlist. - * - * This method may change id attributes of playlistElements and/or - * fadeInfo. - * - * @param string $id - * playlist id - * @param id $oldPos - * old position in playlist - * @param int $newPos - * new position in playlist - * @return boolean - */ - public function moveAudioClipInPlaylist($id, $oldPos, $newPos) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->moveAudioClip($oldPos, $newPos); - - return $res; - } - - /** - * Change fadeInfo values - * - * @param string $id - * playlist id - * @param string $fadeIn - * in time format hh:mm:ss.ssssss - * @param string $fadeOut - * in time format hh:mm:ss.ssssss - * @return boolean - */ - public function changeFadeInfo($id, $pos, $fadeIn, $fadeOut) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut); - - return $res; - } - - /** - * Change cueIn/cueOut values for playlist element - * - * @param string $id - * playlist id - * @param string $cueIn - * in time format hh:mm:ss.ssssss - * @param string $cueOut - * in time format hh:mm:ss.ssssss - * relative to begin - * @param sessid $string - * session ID - * @return boolean or pear error object - */ - public function changeClipLength($id, $pos, $cueIn, $cueOut) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->changeClipLength($pos, $cueIn, $cueOut); - - return $res; - } - - /** - * Delete a Playlist metafile. - * - * @param int $id - * local id - * @param string $sessid - * session ID - * @return boolean - */ - public function deletePlaylist($id) - { - return Playlist::Delete($id); - - } - - /** - * Find info about clip at specified offset in playlist. - * - * @param string $sessid - * session id - * @param string $plid - * playlist global unique id - * @param string $offset - * current playtime (hh:mm:ss.ssssss) - * @param int $distance - * 0=current clip; 1=next clip ... - * @return array of matching clip info: - * - */ - public function displayPlaylistClipAtOffset($sessid, $plid, $offset, $distance=0) - { - $pl = Playlist::Recall($plid); - if (is_null($pl) || PEAR::isError($pl)) { - return $pl; - } - $res = $pl->displayPlaylistClipAtOffset($offset, $distance); - if (PEAR::isError($res)) { - return $res; - } - $res['title'] = NULL; - $f = StoredFile::RecallByGunid($res['gunid']); - if (PEAR::isError($f)) { - return $f; - } - $res['title'] = $f->getMetadataValue("dc:title"); - $res['playlist_title'] = NULL; - $pl = Playlist::Recall($plid); - $res['playlist'] = $pl->getName(); - - return $res; - } - - - /** - * Create a tarfile with playlist export - playlist and all matching - * sub-playlists and media files (if desired) - * - * @param string $sessid - * string, session ID - * @param array $plids - * array of strings, playlist global unique IDs - * (one gunid is accepted too) - * @param string $type - * playlist format, values: lspl | smil | m3u - * @param boolean $standalone - * if only playlist should be exported or - * with all related files - * @return hasharray with fields: - * fname string: readable fname, - * token string: access token - */ - public function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE) - { - return $this->bsExportPlaylistOpen($plids, $type, !$standalone); - } // fn exportPlaylistOpen - - - /** - * Close playlist export previously opened by the exportPlaylistOpen method - * - * @param string $token - * access token obtained from exportPlaylistOpen - * method call - * @return TRUE|PEAR_Error - */ - public function exportPlaylistClose($token) - { - return $this->bsExportPlaylistClose($token); - } // fn exportPlaylistClose - - - /** - * Open writable handle for import playlist in LS Archive format - * - * @param string $sessid - * session id - * @param string $chsum - * md5 checksum of imported file - * @return hasharray with: - * fname string: writable local filename - * token string: put token - */ - public function importPlaylistOpen($sessid, $chsum='') - { - $userid = GreenBox::GetSessUserId($sessid); - if (PEAR::isError($userid)) { - return $userid; - } - $r = $this->bsOpenPut($chsum, NULL, $userid); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } // fn importPlaylistOpen - - /** * Close import-handle and import playlist * @@ -864,770 +111,8 @@ class GreenBox extends BasicStor { } // fn importPlaylistClose - /** - * Check whether a Playlist metafile with the given playlist ID exists. - * - * @param int $id - * local id - * @param string $sessid - * session ID - * @return boolean - */ - public function existsPlaylist($id) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - return TRUE; - } // fn existsPlaylist - - - /** - * Check whether a Playlist metafile with the given playlist ID - * is available for editing, i.e., exists and is not marked as - * beeing edited. - * - * @param int $id - * local id - * @param string $sessid - * session ID - * @return TRUE|int - * id of user editing it - */ - public function playlistIsAvailable($id, $sessid) - { - $pl = Playlist::Recall($id); - if ($pl === FALSE) { - return FALSE; - } - - $res = $pl->isEdited(); - - if($res !== FALSE) - return $res; - - return TRUE; - } // fn playlistIsAvailable - - - /* ---------------------------------------------- time conversion methods */ - /** - * Convert playlist time value to float seconds - * - * @param string $plt - * playlist time value (HH:mm:ss.dddddd) - * @return int - * seconds - */ - public function playlistTimeToSeconds($plt) - { - return Playlist::playlistTimeToSeconds($plt); - } - - - /** - * Convert float seconds value to playlist time format - * - * @param int $s0 - * seconds - * @return string - * time in playlist time format (HH:mm:ss.dddddd) - */ - public static function secondsToPlaylistTime($s0) - { - return Playlist::secondsToPlaylistTime($s0); - } // fn secondsToPlaylistTime - - - /* ------------------------------------------------------- render methods */ - /** - * Render playlist to ogg file (open handle) - * - * @param string $sessid - * session id - * @param string $plid - * playlist gunid - * @return string $token - * render token - */ - public function renderPlaylistToFileOpen($sessid, $plid) - { - $r = Renderer::rnRender2FileOpen($this, $plid); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } // fn renderPlaylistToFileOpen - - - /** - * Render playlist to ogg file (check results) - * - * @param string $token - * render token - * @return hasharray: - * status : string - susccess | working | fault - * tmpfile : string - filepath to result temporary file - */ - public function renderPlaylistToFileCheck($token) - { - $r = Renderer::rnRender2FileCheck($this, $token); - if (PEAR::isError($r)) { - return $r; - } - return array('status'=>$r['status'], 'tmpfile'=>$r['tmpfile']); - } // fn renderPlaylistToFileCheck - - - /** - * Render playlist to ogg file (list results) - * - * @param string $status - * success | working | fault - * if this parameter is not set, then return with all unclosed - * @return array of hasharray: - * status : string - susccess | working | fault - * tmpfile : string - filepath to result temporary file - */ - public function renderPlaylistToFileList($status='') - { - return Renderer::rnRender2FileList($this, $status); - } // fn renderPlaylistToFileList - - - /** - * Render playlist to ogg file (close handle) - * - * @param string $token - * render token - * @return boolean - * status - */ - public function renderPlaylistToFileClose($token) - { - $r = Renderer::rnRender2FileClose($this, $token); - if (PEAR::isError($r)) { - return $r; - } - return array(TRUE); - } // fn renderPlaylistToFileClose - - - /** - * Render playlist to storage media clip (open handle) - * - * @param string $sessid - * session id - * @param string $plid - * playlist gunid - * @return string - * render token - */ - public function renderPlaylistToStorageOpen($sessid, $plid) - { - $owner = GreenBox::getSessUserId($sessid); - if (PEAR::isError($owner)) { - return $owner; - } - $r = Renderer::rnRender2FileOpen($this, $plid, $owner); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } // fn renderPlaylistToStorageOpen - - - /** - * Render playlist to storage media clip (check results) - * - * @param string $token - * render token - * @return hasharray: - * status : string - susccess | working | fault - * gunid : string - gunid of result file - */ - public function renderPlaylistToStorageCheck($token) - { - $r = Renderer::rnRender2StorageCheck($this, $token); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } // fn renderPlaylistToStorageCheck - - - /** - * Render playlist to RSS file (open handle) - * - * @param string $sessid - * session id - * @param string $plid - * playlist gunid - * @return string - * render token - */ - public function renderPlaylistToRSSOpen($sessid, $plid) - { - $token = '123456789abcdeff'; - $fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; - file_put_contents($fakeFile, "fake rendered file"); - return array('token'=>$token); - } // fn renderPlaylistToRSSOpen - - - /** - * Render playlist to RSS file (check results) - * - * @param string $token - * render token - * @return hasharray: - * status : string - susccess | working | fault - * tmpfile : string - filepath to result temporary file - */ - public function renderPlaylistToRSSCheck($token) - { - $fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; - if ($token != '123456789abcdeff' || !file_exists($fakeFile)){ - return PEAR::raiseError( - "renderPlaylistToRSSCheck: invalid token ($token)" - ); - } - return array( - 'status'=> 'success', - 'tmpfile' => $fakeFile, - ); - } // fn renderPlaylistToRSSCheck - - - /** - * Render playlist to RSS file (list results) - * - * @param string $status - * success | working | fault - * @return array of hasharray: - * status : string - susccess | working | fault - * tmpfile : string - filepath to result temporary file - */ -// function renderPlaylistToRSSList($status='') -// { -// $dummytokens = array ('123456789abcdeff'); -// foreach ($dummytokens as $token) { -// $r[] = $this->renderPlaylistToRSSCheck($token); -// } -// return $r; -// } // fn renderPlaylistToRSSList - - - /** - * Render playlist to RSS file (close handle) - * - * @param string $token - * render token - * @return boolean - * status - */ - public function renderPlaylistToRSSClose($token) - { - if ($token != '123456789abcdeff'){ - return PEAR::raiseError( - "GreenBox::renderPlaylistToRSSClose: invalid token" - ); - } - $fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; - unlink($fakeFile); - return TRUE; - } // fn renderPlaylistToRSSClose - - - /*================================================= storage admin methods */ - /* ------------------------------------------------------- backup methods */ - /** - * Create backup of storage (open handle) - * - * @param string $sessid - * session id - * @param struct $criteria - * see search criteria - * @return array - * token : string - backup token - */ - public function createBackupOpen($sessid, $criteria='') - { - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->openBackup($sessid,$criteria); - } // fn createBackupOpen - - - /** - * Create backup of storage (check results) - * - * @param string $token - * backup token - * @return hasharray with field: - * status : string - susccess | working | fault - * faultString: string - description of fault - * token : stirng - backup token - * url : string - access url - */ - public function createBackupCheck($token) - { - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->checkBackup($token); - } // fn createBackupCheck - - - /** - * Create backup of storage (list results) - * - * @param string $sessid - * session id - * @param string $stat - * if this parameter is not set, then return with all unclosed backups - * @return array of hasharray with field: - * status : string - susccess | working | fault - * token : stirng - backup token - * url : string - access url - */ - public function createBackupList($sessid, $stat='') - { - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->listBackups($stat); - } // fn createBackupList - - - /** - * Create backup of storage (close handle) - * - * @param string $token - * backup token - * @return boolean - * status - */ - public function createBackupClose($token) - { - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->closeBackup($token); - } // fn createBackupClose - - - /* ===================================================== restore funcitons*/ - /** - * Restore a backup file - * - * @param string $sessid - * session id - * @param string $filename - * backup file path - * @return string - * restore token - */ - public function backupRestoreOpen($sessid, $filename) - { - $rs = new Restore($this); - if (PEAR::isError($rs)) { - return $rs; - } - return $rs->openRestore($sessid,$filename); - } // fn backupRestoreOpen - - - /** - * Check status of backup restore - * - * @param string $token - * restore token - * @return hasharray - * fields: - * token: string - restore token - * status: string - working | fault | success - * faultString: string - description of fault - */ - public function backupRestoreCheck($token) - { - $rs = new Restore($this); - if (PEAR::isError($rs)) { - return $rs; - } - return $rs->checkRestore($token); - } // fn backupRestoreCheck - - - /** - * Close a restore procedure - * - * @param string $token - * restore token - * @return boolean - * is success - */ - public function backupRestoreClose($token) { - $rs = new Restore($this); - if (PEAR::isError($rs)) { - return $rs; - } - return $rs->closeRestore($token); - } // fn backupRestoreClose - - /* ============================================== methods for preferences */ - - /** - * Read preference record by session id - * - * @param string $sessid - * session id - * @param string $key - * preference key - * @return string - * preference value - */ - public function loadPref($sessid, $key) - { - $pr = new Prefs($this); - $res = $pr->loadPref($sessid, $key); - return $res; - } // fn loadPref - - - /** - * Save preference record by session id - * - * @param string $sessid - * session id - * @param string $key - * preference key - * @param string $value - * preference value - * @return boolean - */ - public function savePref($sessid, $key, $value) - { - $pr = new Prefs($this); - $res = $pr->savePref($sessid, $key, $value); - return $res; - } // fn savePref - - - /** - * Delete preference record by session id - * - * @param string $sessid - * session id - * @param string $key - * preference key - * @return boolean - */ - public function delPref($sessid, $key) - { - $pr = new Prefs($this); - $res = $pr->delPref($sessid, $key); - return $res; - } // fn delPref - - - /** - * Read group preference record - * - * @param string $sessid - * session id - * @param string $group - * group name - * @param string $key - * preference key - * @return string - * preference value - */ - public function loadGroupPref($group, $key) - { - $pr = new Prefs($this); - $res = $pr->loadGroupPref($group, $key); - return $res; - } // fn loadGroupPref - - - /** - * Save group preference record - * - * @param string $sessid - * session id - * @param string $group - * group name - * @param string $key - * preference key - * @param string $value - * preference value - * @return boolean - */ - public function saveGroupPref($sessid, $group, $key, $value) - { - $pr = new Prefs($this); - $res = $pr->saveGroupPref($sessid, $group, $key, $value); - return $res; - } // fn saveGroupPref - - - /** - * Delete group preference record - * - * @param string $sessid - * session id - * @param string $group - * group name - * @param string $key - * preference key - * @return boolean - */ - public function delGroupPref($sessid, $group, $key) - { - $pr = new Prefs($this); - $res = $pr->delGroupPref($sessid, $group, $key); - return $res; - } // fn delGroupPref - - - /* =================================================== networking methods */ - /* ------------------------------------------------------- common methods */ - /** - * Common "check" method for transports - * - * @param string $trtok - * transport token - * @return array with fields: - * trtype: string - audioclip | playlist | search | file - * state: string - transport state - * direction: string - up | down - * expectedsize: int - file size in bytes - * realsize: int - currently transported bytes - * expectedchsum: string - orginal file checksum - * realchsum: string - transported file checksum - * ... ? - */ - public function getTransportInfo($trtok) - { - $tr = new Transport($this); - return $tr->getTransportInfo($trtok); - } // fn getTransportInfo - - - /** - * Turn transports on/off, optionaly return current state. - * - * @param string $sessid - * session id - * @param boolean $onOff - * optional (if not used, current state is returned) - * @return boolean - * previous state - */ - public function turnOnOffTransports($sessid, $onOff=NULL) - { - $tr = new Transport($this); - return $tr->turnOnOffTransports($sessid, $onOff); - } // fn turnOnOffTransports - - - /** - * Pause, resume or cancel transport - * - * @param string $trtok - * transport token - * @param string $action - * pause | resume | cancel - * @return string - * resulting transport state - */ - public function doTransportAction($trtok, $action) - { - $tr = new Transport($this); - $res = $tr->doTransportAction($trtok, $action); - return $res; - } // fn doTransportAction - - - /* ------------------------ methods for ls-archive-format file transports */ - /** - * Open async file transfer from local storageServer to network hub, - * file should be ls-archive-format file. - * - * @param string $filePath - * local path to uploaded file - * @return string - * transport token - */ - public function uploadFile2Hub($filePath) - { - $tr = new Transport($this); - return $tr->uploadFile2Hub($filePath); - } // fn uploadFile2Hub - - - /** - * Get list of prepared transfers initiated by hub - * - * @return array of structs/hasharrays with fields: - * trtok: string transport token - * ... ? - */ - public function getHubInitiatedTransfers() - { - $tr = new Transport($this); - return $tr->getHubInitiatedTransfers(); - } // fn getHubInitiatedTransfers - - - /** - * Start of download initiated by hub - * - * @param string $trtok - * transport token obtained from - * the getHubInitiatedTransfers method - * @return string - * transport token - */ - public function startHubInitiatedTransfer($trtok) - { - $tr = new Transport($this); - return $tr->startHubInitiatedTransfer($trtok); - } // fn startHubInitiatedTransfer - - - /* ------------- special methods for audioClip/webstream object transport */ - - /** - * Start upload of audioClip/webstream/playlist from local storageServer - * to hub - * - * @param string $gunid - * global unique id of object being transported - * @param boolean $withContent - * if true, transport playlist content too - * @return string - * transport token - * @todo rename this function "uploadToHub" - */ - public function upload2Hub($gunid, $withContent=FALSE) - { - $tr = new Transport($this); - return $tr->upload2Hub($gunid, $withContent); - } // fn upload2Hub - - - /** - * Start download of audioClip/webstream/playlist from hub to local - * storageServer - * - * @param string $sessid - * session id - * @param string $gunid - * global unique id of playlist being transported - * @param boolean $withContent - * if true, transport playlist content too - * @return string - * transport token - */ - public function downloadFromHub($sessid, $gunid, $withContent=TRUE){ - $uid = GreenBox::getSessUserId($sessid); - if (PEAR::isError($uid)) { - return $uid; - } - $tr = new Transport($this); - return $tr->downloadFromHub($uid, $gunid, $withContent); - } // fn downloadFromHub - - - /* ------------------------------------------------ global-search methods */ - /** - * Start search job on network hub - * - * @param array $criteria - * criteria format (see localSearch) - * @return string - * transport token - */ - public function globalSearch($criteria) - { - $tr = new Transport($this); - //return $tr->globalSearch($criteria); - return $tr->remoteSearch($criteria); - } - - - /** - * Get results from search job on network hub - * - * @param string $trtok - * transport token - * @param boolean $andClose - * if TRUE, close transport token - * @return array - * search result format (see localSearch) - */ -// public function getSearchResults($trtok, $andClose=TRUE) -// { -// $tr = new Transport($this); -// return $tr->getSearchResults($trtok, $andClose); -// } // fn getSearchResults - - /* ========================================================= info methods */ - /** - * Check if file gunid exists in the storage and - * user have permission to read it - * - * @param string $sessid - * session id - * @param string $gunid - * @param string $ftype - * internal file type - * @return string|PEAR_Error - */ - public function existsFile($sessid, $gunid, $ftype=NULL) - { - if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { - return $res; - } - $f = StoredFile::RecallByGunid($gunid); - return $f->existsFile(); - } // fn existsFile - - /* ==================================================== redefined methods */ - /** - * Get user id from session id - * - * This redefinition only simulate old (bad) behaviour - returns NULL - * for wrong sessid (code ALIBERR_NOTEXISTS). - * HtmlUI depends on it. - * - * @param string $sessid - * @return int|null|PEAR_Error - */ - public static function GetSessUserId($sessid) - { - $r = Alib::GetSessUserId($sessid); - if (PEAR::isError($r)) { - if ($r->getCode() == ALIBERR_NOTEXISTS) { - return NULL; - } else { - return $r; - } - } - return $r; - } // fn getSessUserId - /** * Change user password. @@ -1668,28 +153,4 @@ class GreenBox extends BasicStor { } // fn passwd - /** - * Insert permission record - * - * @param int $sid - * local user/group id - * @param string $action - * @param int $oid - * local object id - * @param char $type - * 'A'|'D' (allow/deny) - * @param string $sessid - * session id - * @return int - * local permission id - */ - public function addPerm($sid, $action, $oid, $type='A', $sessid='') - { - if (($res = BasicStor::Authorize('editPerms', $oid, $sessid)) !== TRUE) { - return $res; - } - return Alib::AddPerm($sid, $action, $oid, $type); - } // fn addPerm - - } // class GreenBox diff --git a/application/models/LocStor.php b/application/models/LocStor.php index 4a5f5cf5b..6bdd4d02c 100644 --- a/application/models/LocStor.php +++ b/application/models/LocStor.php @@ -996,370 +996,6 @@ class LocStor extends BasicStor { } - /* ------------------------------------------------------- render methods */ - /** - * Render playlist to ogg file (open handle) - * - * @param string $sessid - * session id - * @param string $plid - * playlist gunid - * @return hasharray - * token: string - render token - */ - protected function renderPlaylistToFileOpen($sessid, $plid) - { - require_once("Renderer.php"); - $r = Renderer::rnRender2FileOpen($this, $plid); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } - - - /** - * Render playlist to ogg file (check results) - * - * @param string $token - * render token - * @return hasharray: - * status : string - success | working | fault - * url : string - readable url - */ - protected function renderPlaylistToFileCheck($token) - { - require_once("Renderer.php"); - $r = Renderer::rnRender2FileCheck($this, $token); - if (PEAR::isError($r)) { - return $r; - } - return array('status'=>$r['status'], 'url'=>$r['url']); - } - - - /** - * Render playlist to ogg file (close handle) - * - * @param string $token - * render token - * @return boolean status - */ - protected function renderPlaylistToFileClose($token) - { - require_once("Renderer.php"); - $r = Renderer::rnRender2FileClose($this, $token); - if (PEAR::isError($r)) { - return $r; - } - return array(TRUE); - } - - - /** - * Render playlist to storage media clip (open handle) - * - * @param string $sessid - * session id - * @param string $plid - * playlist gunid - * @return string - * render token - */ - protected function renderPlaylistToStorageOpen($sessid, $plid) - { - require_once("Renderer.php"); - $owner = Alib::GetSessUserId($sessid); - if (PEAR::isError($owner)) { - return $owner; - } - $r = Renderer::rnRender2FileOpen($this, $plid, $owner); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } - - - /** - * Render playlist to storage media clip (check results) - * - * @param string $token - * render token - * @return hasharray: - * status : string - success | working | fault - * gunid : string - gunid of result file - */ - protected function renderPlaylistToStorageCheck($token) - { - require_once("Renderer.php"); - $r = Renderer::rnRender2StorageCheck($this, $token); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } - - - /** - * Render playlist to RSS file (open handle) - * - * @param string $sessid - * session id - * @param string $plid - * playlist gunid - * @return string - * render token - */ - protected function renderPlaylistToRSSOpen($sessid, $plid) - { - global $CC_CONFIG; - $token = '123456789abcdeff'; - $fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; - file_put_contents($fakeFile, "fake rendered file"); - return array('token'=>$token); - } - - - /** - * Render playlist to RSS file (check results) - * - * @param string $token - * render token - * @return hasharray : - * status : string - success | working | fault - * url : string - readable url - */ - protected function renderPlaylistToRSSCheck($token) - { - $fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; - if ($token != '123456789abcdeff' || !file_exists($fakeFile)) { - return PEAR::raiseError( - "LocStor::renderPlaylistToRSSCheck: invalid token ($token)" - ); - } - $fakeFUrl = BasicStor::GetUrlPart()."access/$token.rss"; - return array( - 'status'=> 'success', - 'url' => $fakeFUrl, - ); - } - - - /** - * Render playlist to RSS file (close handle) - * - * @param string $token - * render token - * @return boolean - * status - */ - protected function renderPlaylistToRSSClose($token) - { - if ($token != '123456789abcdeff') { - return PEAR::raiseError( - "LocStor::renderPlaylistToRSSClose: invalid token" - ); - } - $fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; - unlink($fakeFile); - return TRUE; - } - - - /*================================================= storage admin methods */ - - /* ------------------------------------------------------- backup methods */ - - /** - * Create backup of storage (open handle) - * - * @param string $sessid - * session id - * @param array $criteria - * see search criteria - * @return array - * token : string - backup token - */ - protected function createBackupOpen($sessid, $criteria='') - { - require_once("Backup.php"); - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - $r = $bu->openBackup($sessid,$criteria); - if ($r === FALSE) { - return PEAR::raiseError( - "LocStor::createBackupOpen: false returned from Backup" - ); - } - return $r; - } - - - /** - * Create backup of storage (check results) - * - * @param string $token - * backup token - * @return hasharray - * with field: - * status : string - susccess | working | fault - * faultString: string - description of fault - * token : stirng - backup token - * url : string - access url - */ - protected function createBackupCheck($token) - { - require_once("Backup.php"); - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->checkBackup($token); - } - - - /** - * Create backup of storage (list results) - * - * @param string $sessid - * session id - * @param status $stat - * if this parameter is not set, then return with all unclosed backups - * @return array - * array of hasharray with field: - * status : string - susccess | working | fault - * token : stirng - backup token - * url : string - access url - */ - protected function createBackupList($sessid, $stat='') - { - require_once("Backup.php"); - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->listBackups($stat); - } - - - /** - * Create backup of storage (close handle) - * - * @param string $token - * backup token - * @return boolean - * status - */ - protected function createBackupClose($token) - { - require_once("Backup.php"); - $bu = new Backup($this); - if (PEAR::isError($bu)) { - return $bu; - } - return $bu->closeBackup($token); - } - - - /* ------------------------------------------------------ restore methods */ - - /** - * Restore a backup file (open handle) - * - * @param string $sessid - * session id - * @param string $chsum - * md5 checksum of imported file - * @return array - * array with: - * url string: writable URL - * fname string: writable local filename - * token string: PUT token - */ - protected function restoreBackupOpen($sessid, $chsum) - { - $userid = Alib::getSessUserId($sessid); - if (PEAR::isError($userid)) { - return $userid; - } - $r = $this->bsOpenPut($chsum, NULL, $userid); - if (PEAR::isError($r)) { - return $r; - } - return $r; - } - - - /** - * Restore a backup file (close put handle) - * - * @param string $sessid - * session id - * @param string $token - * "put" token - * @return string $token - * restore token - */ - protected function restoreBackupClosePut($sessid, $token) { - $arr = $this->bsClosePut($token); - if (PEAR::isError($arr)) { - return $arr; - } - $fname = $arr['fname']; - require_once('Restore.php'); - $rs = new Restore($this); - if (PEAR::isError($rs)) { - return $rs; - } - return $rs->openRestore($sessid, $fname); - } - - - /** - * Restore a backup file (check state) - * - * @param string $token - * restore token - * @return array - * status - fields: - * token: string - restore token - * status: string - working | fault | success - * faultString: string - description of fault - */ - protected function restoreBackupCheck($token) - { - require_once('Restore.php'); - $rs = new Restore($this); - if (PEAR::isError($rs)) { - return $rs; - } - return $rs->checkRestore($token); - } - - - /** - * Restore a backup file (close handle) - * - * @param string $token - * restore token - * @return array - * status - fields: - * token: string - restore token - * status: string - working | fault | success - */ - protected function restoreBackupClose($token) { - require_once('Restore.php'); - $rs = new Restore($this); - if (PEAR::isError($rs)) { - return $rs; - } - return $rs->closeRestore($token); - } - - /*===================================================== auxiliary methods */ /** * Dummy method - only returns Airtime version diff --git a/application/models/M3uPlaylist.php b/application/models/M3uPlaylist.php deleted file mode 100644 index 8504ac9e3..000000000 --- a/application/models/M3uPlaylist.php +++ /dev/null @@ -1,351 +0,0 @@ -lock($gb, $subjid); -// if (PEAR::isError($r)) { -// return $r; -// } -// foreach ($arr as $i => $it) { -// list($md, $uri) = preg_split("|\n|", $it); -// list($length, $title) = preg_split("|, *|", $md); -// // $gunid = StoredFile::CreateGunid(); -// $gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL); -// $acId = BasicStor::IdFromGunid($gunid); -// if (PEAR::isError($acId)) { -// return $acId; -// } -// $length = Playlist::secondsToPlaylistTime($length); -// $offset = '???'; -// if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) { -// switch (strtolower($ext = $va[1])) { -// case "lspl": -// case "xml": -// case "smil": -// case "m3u": -// $acId = $gb->bsImportPlaylistRaw($gunid, -// $aPath, $uri, $ext, $gunids, $subjid); -// if (PEAR::isError($acId)) { -// break; -// } -// //no break! -// default: -// if (is_null($gunid)) { -// return PEAR::raiseError( -// "M3uPlaylist::import: no gunid"); -// } -// $r = $pl->addAudioClip($acId); -// if (PEAR::isError($r)) { -// return $r; -// } -// } -// } -// } -// $r = $pl->unlock($gb); -// if (PEAR::isError($r)) { -// return $r; -// } -// return $pl; - } - - /** - * Import M3U file to storage - * - * @param GreenBox $gb - * @param string $data - * local path to M3U file - * @return string - * XML playlist in Airtime playlist format - */ - function convert2lspl(&$gb, $data) - { - $arr = M3uPlaylist::parse($data); - if (PEAR::isError($arr)) { - return $arr; - } - $ind = ''; - $ind2 = $ind.INDCH; - $ind3 = $ind2.INDCH; - $res = ''; - foreach ($arr as $i => $it) { - list($md, $uri) = preg_split("|\n|", $it); - list($length, $title) = preg_split("|, *|", $md); - $gunid = StoredFile::CreateGunid(); - $gunid2 = StoredFile::CreateGunid(); - $length = Playlist::secondsToPlaylistTime($length); - $offset = '???'; - $clipStart = '???'; - $clipEnd = '???'; - $clipLength = '???'; - $uri_h = preg_replace("|--|", "d;d;", htmlspecialchars("$uri")); - if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) { - switch (strtolower($ext = $va[1])) { - case "lspl": - case "xml": - case "smil": - case "m3u": - $acOrPl = "$ind3 ". - "\n"; - break; - default: - $acOrPl = "$ind3 ". - "\n"; - break; - } - } - $res .= "$ind2\n". - $acOrPl. - "$ind2\n"; - } - $res = "$ind\n". - "$ind\n". - "$ind2\n". - "$res". - "$ind\n"; - return $res; - } -} // class M3uPlaylist - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class M3uPlaylistBodyElement { - function convert2lspl(&$tree, $ind='') - { - $ind2 = $ind.INDCH; - if ($tree->name != 'body') { - return PEAR::raiseError("M3uPlaylist::parse: body tag expected"); - } - if (isset($tree->children[1])) { - return PEAR::raiseError(sprintf( - "M3uPlaylist::parse: unexpected tag %s in tag body", - $tree->children[1]->name - )); - } - $res = M3uPlaylistParElement::convert2lspl($tree->children[0], $ind2); - if (PEAR::isError($res)) { - return $res; - } - $gunid = StoredFile::CreateGunid(); - $playlength = '???'; // *** - $res = "$ind\n". - "$ind\n". - "$ind2\n". - "$res". - "$ind\n"; - return $res; - } -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class M3uPlaylistParElement { - function convert2lspl(&$tree, $ind='') - { - if ($tree->name != 'par') { - return PEAR::raiseError("M3uPlaylist::parse: par tag expected"); - } - $res = ''; - foreach ($tree->children as $i => $ch) { - $ch =& $tree->children[$i]; - $r = M3uPlaylistAudioElement::convert2lspl($ch, $ind.INDCH); - if (PEAR::isError($r)) { - return $r; - } - $res .= $r; - } - return $res; - } -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class M3uPlaylistAudioElement { - function convert2lspl(&$tree, $ind='') - { - $ind2 = $ind.INDCH; - if ($tree->name != 'audio') { - return PEAR::raiseError("M3uPlaylist::parse: audio tag expected"); - } - if (isset($tree->children[2])) { - return PEAR::raiseError(sprintf( - "M3uPlaylist::parse: unexpected tag %s in tag audio", - $tree->children[2]->name - )); - } - $res = ''; $fadeIn = 0; $fadeOut = 0; - foreach ($tree->children as $i => $ch) { - $ch =& $tree->children[$i]; - $r = M3uPlaylistAnimateElement::convert2lspl($ch, $ind2); - if (PEAR::isError($r)) { - return $r; - } - switch ($r['type']) { - case "fadeIn": - $fadeIn = $r['val']; - break; - case "fadeOut": - $fadeOut = $r['val']; - break; - } - } - if ($fadeIn > 0 || $fadeOut > 0) { - $fadeIn = Playlist::secondsToPlaylistTime($fadeIn); - $fadeOut = Playlist::secondsToPlaylistTime($fadeOut); - $fInfo = "$ind2\n"; - } else { - $fInfo = ''; - } - $plElGunid = StoredFile::CreateGunid(); - $aGunid = StoredFile::CreateGunid(); - $title = basename($tree->attrs['src']->val); - $offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val); - $playlength = '???'; # *** - $res = "$ind\n". - "$ind2\n". - $fInfo. - "$ind\n"; - return $res; - } -} // class M3uPlaylistAudioElement - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class M3uPlaylistAnimateElement { - function convert2lspl(&$tree, $ind='') { - if ($tree->name != 'animate') { - return PEAR::raiseError("M3uPlaylist::parse: animate tag expected"); - } - if ($tree->attrs['attributeName']->val == 'soundLevel' && - $tree->attrs['from']->val == '0%' && - $tree->attrs['to']->val == '100%' && - $tree->attrs['calcMode']->val == 'linear' && - $tree->attrs['fill']->val == 'freeze' && - $tree->attrs['begin']->val == '0s' && - preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va) - ) { - return array('type'=>'fadeIn', 'val'=>$va[1]); - } - if ($tree->attrs['attributeName']->val == 'soundLevel' && - $tree->attrs['from']->val == '100%' && - $tree->attrs['to']->val == '0%' && - $tree->attrs['calcMode']->val == 'linear' && - $tree->attrs['fill']->val == 'freeze' && - preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) && - preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd) - ) { - return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1])); - } - return PEAR::raiseError( - "M3uPlaylistAnimateElement::convert2lspl: animate parameters too general" - ); - } -} - diff --git a/application/models/Prefs.php b/application/models/Prefs.php index 53b5e82e5..9082174da 100644 --- a/application/models/Prefs.php +++ b/application/models/Prefs.php @@ -42,7 +42,7 @@ class Prefs { */ function loadPref($sessid, $key) { - $subjid = GreenBox::GetSessUserId($sessid); + $subjid = Alib::GetSessUserId($sessid); if (PEAR::isError($subjid)) { return $subjid; } @@ -75,7 +75,7 @@ class Prefs { */ function savePref($sessid, $key, $value) { - $subjid = GreenBox::GetSessUserId($sessid); + $subjid = Alib::GetSessUserId($sessid); if (PEAR::isError($subjid)) { return $subjid; } @@ -107,7 +107,7 @@ class Prefs { */ function delPref($sessid, $key) { - $subjid = GreenBox::GetSessUserId($sessid); + $subjid = Alib::GetSessUserId($sessid); if (PEAR::isError($subjid)) { return $subjid; } @@ -180,7 +180,7 @@ class Prefs { */ function saveGroupPref($sessid, $group, $key, $value) { - $uid = GreenBox::GetSessUserId($sessid); + $uid = Alib::GetSessUserId($sessid); if (PEAR::isError($uid)) { return $uid; } @@ -230,7 +230,7 @@ class Prefs { */ function delGroupPref($sessid, $group, $key) { - $uid = GreenBox::GetSessUserId($sessid); + $uid = Alib::GetSessUserId($sessid); if (PEAR::isError($uid)) { return $uid; } diff --git a/application/models/Renderer.php b/application/models/Renderer.php deleted file mode 100644 index 4ee908a50..000000000 --- a/application/models/Renderer.php +++ /dev/null @@ -1,289 +0,0 @@ -outputToSmil(); - if (PEAR::isError($smil)) { - return $smil; - } - // temporary file for smil: - $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_'); - $smilf = "$tmpn.smil"; - file_put_contents($smilf, $smil); - $url = "file://$smilf"; - // output file: - $outf = "$tmpn.".RENDER_EXT; - touch($outf); - // logging: - $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 = BasicStor::bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner); - if (PEAR::isError($acc)) { - return $acc; - } - extract($acc); - $statf = Renderer::getStatusFile($gb, $token); - file_put_contents($statf, "working"); - // command: - $stServDir = dirname(__FILE__)."/.."; - $renderExe = "$stServDir/bin/renderer.sh"; - $command = "$renderExe -p $url -o $outf -s $statf >> $logf &"; - file_put_contents($logf, "$command\n", FILE_APPEND); - $res = system($command); - if ($res === FALSE) { - return PEAR::raiseError( - 'Renderer::rnRender2File: Error running renderer' - ); - } - return array('token'=>$token); - } - - - /** - * Render playlist to ogg file (check results) - * - * @param GreenBox $gb - * GreenBox object reference - * @param string $token - * render token - * @return array - * status : string - success | working | fault - * url : string - readable url - */ - function rnRender2FileCheck(&$gb, $token) - { - $statf = Renderer::getStatusFile($gb, $token); - if (!file_exists($statf)) { - return PEAR::raiseError( - 'Renderer::rnRender2FileCheck: Invalid token' - ); - } - $status = trim(file_get_contents($statf)); - $url = Renderer::getUrl($gb, $token); - $tmpfile= Renderer::getLocalFile($gb, $token); - return array('status'=>$status, 'url'=>$url, 'tmpfile'=>$tmpfile); - } - - - /** - * Render playlist to ogg file (list results) - * - * @param GreenBox $gb - * greenbox object reference - * @param string $stat - * status (optional) if this parameter is not set, then return with all unclosed backups - * @return array - * array of hasharray: - * status : string - success | working | fault - * url : string - readable url - */ - function rnRender2FileList(&$gb,$stat='') { - // open temporary dir - $tokens = BasicStor::GetTokensByType('render'); - foreach ($tokens as $token) { - $st = Renderer::rnRender2FileCheck($gb, $token); - if ( ($stat=='') || ($st['status']==$stat) ) { - $r[] = $st; - } - } - return $r; - } - - - /** - * Render playlist to ogg file (close handle) - * - * @param GreenBox $gb - * greenbox object reference - * @param string $token - * render token - * @return mixed - * TRUE or PEAR_Error - */ - function rnRender2FileClose(&$gb, $token) - { - global $CC_CONFIG; - $r = BasicStor::bsRelease($token, 'render'); - if (PEAR::isError($r)) { - return $r; - } - $realOgg = $r['realFname']; - $tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT); - $smilf = "$tmpn.smil"; - $statf = Renderer::getStatusFile($gb, $token); - @unlink($statf); - @unlink($realOgg); - @unlink($smilf); - @unlink($tmpn); - return TRUE; - } - - - /** - * Render playlist to storage as audioClip (check results) - * - * @param GreenBox $gb - * greenbox object reference - * @param string $token - * render token - * @return array - * status : string - success | working | fault - * gunid: string - global unique id of result file - */ - function rnRender2StorageCheck(&$gb, $token) - { - $r = Renderer::rnRender2FileCheck($gb, $token); - if (PEAR::isError($r)) { - return $r; - } - $status = $r['status']; - $res = array('status' => $status, 'gunid'=>'NULL'); - switch ($status) { - case "fault": - $res['faultString'] = "Error runing renderer"; - break; - case "success": - $r = Renderer::rnRender2StorageCore($gb, $token); - if (PEAR::isError($r)) { - return $r; - } - $res['gunid'] = $r['gunid']; - break; - default: - break; - } - return $res; - } - - - /** - * Render playlist to storage as audioClip (core method) - * - * @param GreenBox $gb - * greenbox object reference - * @param string $token - * render token - * @return array: - * gunid: string - global unique id of result file - */ - function rnRender2StorageCore(&$gb, $token) - { - // $r = BasicStor::bsRelease($token, 'render'); - // if (PEAR::isError($r)) { - // return $r; - // } - // $realOgg = $r['realFname']; - // $owner = $r['owner']; - // $gunid = $r['gunid']; - // $fileName = 'rendered_playlist'; - // $id = BasicStor::IdFromGunid($gunid); - // if (PEAR::isError($id)) { - // return $id; - // } - // $mdata = ''; - // foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) { - // $val = $gb->bsGetMetadataValue($id, $item); - // $mdata .= " <$item>$val\n"; - // } - // $mdata = "\n \n$mdata \n\n"; - // //$mdata = "\n \n$mdata0\n\n\n"; - // $values = array( - // "filename" => $fileName, - // "filepath" => $realOgg, - // "metadata" => $mdata, - // "filetype" => "audioclip" - // ); - // $storedFile = $gb->bsPutFile($values); - // if (PEAR::isError($storedFile)) { - // return $storedFile; - // } - // return array('gunid' => $storedFile->getGunid()); - } - - - /** - * Return local filepath of rendered file - * - * @param Greenbox $gb - * greenbox object reference - * @param string $token - * render token - * @return array - */ - function getLocalFile(&$gb, $token) - { - global $CC_CONFIG; - $token = StoredFile::NormalizeGunid($token); - return $CC_CONFIG['accessDir']."/$token.".RENDER_EXT; - } - - - /** - * Return filepath of render status file - * - * @param GreenBox $gb - * greenbox object reference - * @param string $token - * render token - * @return array - */ - function getStatusFile(&$gb, $token) - { - return Renderer::getLocalFile($gb, $token).".status"; - } - - - /** - * Return remote accessible URL for rendered file - * - * @param GreenBox $gb - * greenbox object reference - * @param string $token - * render token - * @return array - */ - function getUrl(&$gb, $token) - { - $token = StoredFile::NormalizeGunid($token); - return BasicStor::GetUrlPart()."access/$token.".RENDER_EXT; - } - -} // class Renderer - diff --git a/application/models/Restore.php b/application/models/Restore.php deleted file mode 100644 index 7c03fe5de..000000000 --- a/application/models/Restore.php +++ /dev/null @@ -1,436 +0,0 @@ -gb =& $gb; - $this->token = null; - $this->logFile = $CC_CONFIG['bufferDir'].'/'.$this->ACCESS_TYPE.'.log'; - if ($this->loglevel == 'debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n"); - } - } - - - /** - * Call asyncronously the restore procedure. Restore from backup. - * - * @param string $sessid - * session id - * @param string $backup_file - * path of the backup file - * @return array - * hasharray with field: - * token string: backup token - */ - 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(); - - // status file -> working - $this->setEnviroment(); - file_put_contents($this->statusFile, 'working'); - - //call the restore script in background - $command = dirname(__FILE__).'/../bin/restore.php'; - $runLog = "/dev/null"; - $params = "{$backup_file} {$this->statusFile} {$this->token} {$sessid}>> $runLog &"; - $ret = system("$command $params", $st); - if ($this->loglevel=='debug') { - $this->addLogItem("-I-".date("Ymd-H:i:s")." restore.php call: $st/$ret\n"); - } - - return array('token'=>$this->token); - } - - - /** - * Check the status of restore - * - * @param string $token - * @return array - * hasharray with field: - * status : string - susccess | working | fault - * faultString : string - description of fault - * token : stirng - backup token - * url : string - access url - * tmpfile : string - access filename - */ - function checkRestore($token) - { - if ($this->loglevel == 'debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n"); - } - $this->token = $token; - $this->setEnviroment(); - if (is_file($this->statusFile)) { - $r = array(); - $stat = file_get_contents($this->statusFile); - if (strpos($stat,'fault|') !== false) { - list($stat,$message) = explode('|',$stat); - } - $r['status'] = $stat; - if ($stat=='fault') { - $r['faultString'] = $message; - } else { - $r['faultString'] = ''; - } - return $r; - } else { - return PEAR::raiseError('Restore::checkRestore: invalid token!'); - } - } - - - /** - * Check the status of restore. - * - * @param string $token - * @return array - * hasharray with field: - * status : boolean - is success - */ - function closeRestore($token) - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n"); - } - $this->token = $token; - $this->setEnviroment(); - $this->rRmDir($this->tmpDir); - unlink($this->statusFile); - return array("status" => !is_file($this->statusFile)); - } - - - /** - * Do restore in background - * - * this function is called from the asyncron commandline script - * ../bin/restore.php - * - * @param string $backupfile - * path of backupfile - * @param string $token - * restore token - * @param string $sessid - * session id - */ - function startRestore($backupfile, $token, $sessid) - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n"); - } - $this->token = $token; - $this->sessid = $sessid; - $this->setEnviroment(); - - // extract tarball - $command = 'tar -xf '.$backupfile .' --directory '.$this->tmpDir; - $res = system($command); - //$this->addLogItem('command: '.$command."\n"); - //$this->addLogItem('res: '.$res."\n"); - - //simple check of archive format - if (is_dir($this->tmpDir.'audioClip/') && - is_dir($this->tmpDir.'meta-inf/') && - is_dir($this->tmpDir.'playlist/')) { - //search metafiles - $this->metafiles = $this->getMetaFiles(); - #$this->addLogItem('metafiles:'.print_r($this->metafiles,true)); - //add to storage server - foreach ($this->metafiles as $info) { - $r = $this->addFileToStorage($info['file'],$info['type'],$info['id']); - if (PEAR::isError($r)) { - $this->addLogItem("-E- ".date("Ymd-H:i:s"). - " startRestore - addFileToStorage \n". - "(".$put->getMessage()."/".$put->getUserInfo().")\n" - ); - file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo()); - return; - } - } - } else { - $this->addLogItem("-E- ".date("Ymd-H:i:s")." startRestore - invalid archive format\n"); - file_put_contents($this->statusFile, 'fault|invalid archive format'); - return; - } - file_put_contents($this->statusFile, 'success'); - // unlink($backupfile); - } - - - /** - * Get the metafiles. - * - * @return array - * array of hasharray with field: - * file : string - metafile path - * type : stirng - audioClip | playlist - * id : string - the backuped gunid - */ - function getMetaFiles() - { - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." getMetaFiles - tmpDir:{$this->tmpDir}\n"); - } - $audioclips = scandir($this->tmpDir.'audioClip/'); - $playlists = scandir($this->tmpDir.'playlist/'); - for ($i = 0; $i < count($audioclips); $i++) { - if (strpos($audioclips[$i],'xml')!==false) - $r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i], - 'type' => 'audioClip', - 'id' => str_replace('.xml','',$audioclips[$i])); - } - for ($i = 0; $i < count($playlists); $i++) { - if (strpos($playlists[$i],'xml') !== false) - $r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i], - 'type' => 'playlist', - 'id' => str_replace('.xml','',$playlists[$i])); - } - return $r; - } - - - /** - * Add the file to the storage server. - * - * @param string $file - * path of metafile - * @param string $type - * restore token - * @param string $sessid - * session id - * - * @return mixed - * true if success or PEAR_error - */ - // function addFileToStorage($file,$type,$gunid) - // { - // if ($this->loglevel=='debug') { - // $this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n"); - // } - // require_once("XmlParser.php"); - // $tree = XmlParser::parse($file); - // $mediaFileLP = str_replace('.xml','',$file); - // $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:''; - // $ex = $this->gb->existsFile($this->sessid,$gunid); - // if (PEAR::isError($ex)) { - // $this->addLogItem("-E- ".date("Ymd-H:i:s"). - // " addFileToStorage - existsFile($gunid) ". - // "(".$ex->getMessage()."/".$ex->getUserInfo().")\n" - // ); - // } - // if (!PEAR::isError($ex) && $ex) { // file is exists in storage server - // //replace it - // $id = BasicStor::IdFromGunid($gunid); - // $replace = $this->gb->replaceFile( - // $id, # id int, virt.file's local id - // $mediaFileLP, # mediaFileLP string, local path of media file - // $file, # mdataFileLP string, local path of metadata file - // $this->sessid); # sessid string, session id - // if (PEAR::isError($replace)) { - // $this->addLogItem("-E- ".date("Ymd-H:i:s"). - // " addFileToStorage - replaceFile Error ". - // "(".$replace->getMessage()."/".$replace->getUserInfo().")\n" - // ); - // file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo()); - // return $replace; - // } - // #$this->addLogItem("replace it \n"); - // } else { - // // add as new - // $name = $tree->children[0]->children[0]->content; - // if (empty($name)) { - // $name = $tree->attrs['title']->val; - // } - // if (empty($name)) { - // $name = '???'; - // } - // if ($this->loglevel=='debug') { - // $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n". - // "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n" - // ); - // } - // $values = array( - // "filename" => $name, - // "filepath" => $mediaFileLP, - // "metadata" => $file, - // "gunid" => $gunid, - // "filetype" => $type - // ); - // $put = $this->gb->putFile($values, $this->sessid); - // //$this->addLogItem("add as new \n"); - // if (PEAR::isError($put)) { - // $this->addLogItem("-E- ".date("Ymd-H:i:s"). - // " addFileToStorage - putFile Error ". - // "(".$put->getMessage()."/".$put->getUserInfo().")\n" - // ."\n---\n".file_get_contents($file)."\n---\n" - // ); - // file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo()); - // //$this->addLogItem("Error Object: ".print_r($put,true)."\n"); - // return $put; - // } - // } - // $ac = StoredFile::RecallByGunid($gunid); - // if (is_null($ac) || PEAR::isError($ac)) { - // return $ac; - // } - // $res = $ac->setState('ready'); - // if (PEAR::isError($res)) { - // return $res; - // } - // return true; - // } - - - /** - * Figure out the environment to the backup. - * - */ - function setEnviroment() - { - global $CC_CONFIG; - if ($this->loglevel=='debug') { - $this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n"); - } - $this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.status'; - $this->tmpDir = '/tmp/ls_restore/'.$this->token.'/'; - $this->rMkDir($this->tmpDir); - } - - - /** - * Add a line to the logfile. - * - * @param string $item - * the new row of log file - */ - function addLogItem($item) - { - $f = fopen ($this->logFile,'a'); - flock($f,LOCK_SH); - fwrite($f,$item); - flock($f,LOCK_UN); - fclose($f); - //echo file_get_contents($this->logFile)."

\n\n"; - } - - - /** - * Delete a directory recursive - * - * @param string $dirname - * path of dir - * - * @return boolean - * is success - */ - function rRmDir($dirname) - { - if (is_dir($dirname)) { - $dir_handle = opendir($dirname); - } - while ($file = readdir($dir_handle)) { - if ($file!="." && $file!="..") { - if (!is_dir($dirname."/".$file)) { - unlink ($dirname."/".$file); - } else { - Restore::rRmDir($dirname."/".$file); - } - } - } - closedir($dir_handle); - rmdir($dirname); - return true; - } - - - /** - * Create a directory recursive - * - * @param string $dirname - * path of dir. - * @param int $mode - * octal - rights of dir. - * @param boolean $recursive - * do it recursive. - * - * @return boolean - */ - function rMkDir($dirname, $mode=0777, $recursive=true) - { - if (is_null($dirname) || $dirname === "" ) { - return false; - } - if (is_dir($dirname) || $dirname === "/" ) { - return true; - } - if ($this->rMkDir(dirname($dirname), $mode, $recursive)) { - return mkdir($dirname, $mode); - } - return false; - } - -} // class Restore - diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php index 8b8407f79..72e96dbea 100644 --- a/application/models/StoredFile.php +++ b/application/models/StoredFile.php @@ -1271,14 +1271,14 @@ class StoredFile { if (!file_exists($this->filepath) || @unlink($this->filepath)) { $this->exists = FALSE; return TRUE; - } + } else { return PEAR::raiseError( "StoredFile::deleteFile: unlink failed ({$this->filepath})", GBERR_FILEIO ); } - } + } else { $this->exists = FALSE; return TRUE; @@ -1304,7 +1304,7 @@ class StoredFile { Playlist::DeleteFileFromAllPlaylists($this->id); } - + $sql = "DELETE FROM ".$CC_CONFIG['filesTable'] ." WHERE gunid='{$this->gunid}'"; $res = $CC_DBC->query($sql); @@ -1717,7 +1717,7 @@ class StoredFile { foreach($searchCols as $col) { $escapedTerm = pg_escape_string($term); - $innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'"; + $innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'"; } $outerCond[] = "(".join(" OR ", $innerCond).")"; } diff --git a/application/models/Subjects.php b/application/models/Subjects.php index 8f29c6706..3484484f9 100644 --- a/application/models/Subjects.php +++ b/application/models/Subjects.php @@ -13,48 +13,11 @@ define('ALIBERR_BADSMEMB', 21); * @subpackage Alib * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt - * @see ObjClasses - * @see Alib */ class Subjects { /* ======================================================= public methods */ - /** - * Add new subject (a.k.a. "user") - * - * @param string $p_login - * @param string $p_pass - * @param string $p_realname - * @param boolean $p_passenc - * password already encrypted if true - * @return int|PEAR_Error - */ - public static function AddSubj($p_login, $p_pass=NULL, $p_realname='', $p_passenc=FALSE) - { - global $CC_CONFIG, $CC_DBC; - if (!$p_login) { - return $CC_DBC->raiseError("Subjects::AddSubj: empty login"); - } - $id = $CC_DBC->nextId($CC_CONFIG['subjSequence']); - if (PEAR::isError($id)) { - return $id; - } - if (!is_null($p_pass) && !$p_passenc) { - $p_pass = md5($p_pass); - } - $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; - } - return $id; - } - - /** * Check login and password * @@ -77,28 +40,6 @@ class Subjects { } // fn authenticate - /** - * Set lastlogin or lastfail timestamp - * - * @param string $login - * @param boolean $failed - * true=> set lastfail, false=> set lastlogin - * @return boolean|int|PEAR_Error - */ - public static function SetTimeStamp($login, $failed=FALSE) - { - global $CC_CONFIG, $CC_DBC; - $fld = ($failed ? 'lastfail' : 'lastlogin'); - $sql = "UPDATE ".$CC_CONFIG['subjTable']." SET $fld=now()" - ." WHERE login='$login'"; - $r = $CC_DBC->query($sql); - if (PEAR::isError($r)) { - return $r; - } - return TRUE; - } // fn setTimeStamp - - /** * Change user password * @@ -137,52 +78,6 @@ class Subjects { /* --------------------------------------------------------------- groups */ - /** - * Add {login} and direct/indirect members to {gname} and to groups, - * where {gname} is [in]direct member - * - * @param string $login - * @param string $gname - * @return int|PEAR_Error - */ - public static function AddSubjectToGroup($login, $gname) - { - $uid = Subjects::GetSubjId($login); - if (PEAR::isError($uid)) { - return $uid; - } - $gid = Subjects::GetSubjId($gname); - if (PEAR::isError($gid)) { - return $gid; - } - $isgr = Subjects::IsGroup($gid); - if (PEAR::isError($isgr)) { - return $isgr; - } - if (!$isgr) { - return PEAR::raiseError("Subjects::addSubj2Gr: Not a group ($gname)", ALIBERR_NOTGR); - } - // add subject and all [in]direct members to group $gname: - $mid = Subjects::_plainAddSubjectToGroup($uid, $gid); - if (PEAR::isError($mid)) { - return $mid; - } - // add it to all groups where $gname is [in]direct member: - $marr = Subjects::_listRMemb($gid); - if (PEAR::isError($marr)) { - return $marr; - } - foreach ($marr as $k => $v) { - $r = Subjects::_plainAddSubjectToGroup( - $uid, $v['gid'], intval($v['level'])+1, $v['id']); - if (PEAR::isError($r)) { - return $r; - } - } - return $mid; - } // fn addSubj2Gr - - /* --------------------------------------------------------- info methods */ /** @@ -201,114 +96,6 @@ class Subjects { } // fn getSubjId - /** - * Get subject name (login) from id - * - * @param int $id - * @param string $fld - * @return string|PEAR_Error - */ - public static function GetSubjName($id, $fld='login') - { - global $CC_CONFIG; - global $CC_DBC; - $sql = "SELECT $fld FROM ".$CC_CONFIG['subjTable'] - ." WHERE id='$id'"; - return $CC_DBC->getOne($sql); - } // fn getSubjName - - - /** - * Get one subject from the table. - * - * @param string $p_fieldValue - * @param string $p_fieldName - * @return array - */ - public static function GetSubject($p_fieldValue, $p_fieldName='login') - { - global $CC_CONFIG, $CC_DBC; - if (!in_array($p_fieldName, array("login", "id"))) { - return null; - } - $escapedValue = pg_escape_string($p_fieldValue); - $sql = "SELECT * FROM ".$CC_CONFIG['subjTable'] - ." WHERE $p_fieldName='$escapedValue'"; - $row = $CC_DBC->GetRow($sql); - return $row; - } - - - /** - * Get all subjects - * - * @param string $flds - * @return array|PEAR_Error - */ - public static function GetSubjects($flds='id, login') - { - 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|PEAR_Error - */ - public static function GetSubjectsWCnt() - { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT count(m.uid)as cnt, s.id, s.login, s.type" - ." 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 $CC_DBC->getAll($sql); - } // fn getSubjectsWCnt - - - /** - * Return true if subject is a group - * - * @param int $gid - * @return boolean|PEAR_Error - */ - public static function IsGroup($gid) - { - global $CC_CONFIG, $CC_DBC; - if (empty($gid)) { - return FALSE; - } - $sql = "SELECT type FROM ".$CC_CONFIG['subjTable'] - ." WHERE id='$gid'"; - $r = $CC_DBC->getOne($sql); - if (PEAR::isError($r)) { - return $r; - } - return ($r === 'G'); - } // fn isGroup - - - /** - * List direct members of group - * - * @param int $gid - * @return array|PEAR_Error - */ - public static function ListGroup($gid) - { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT s.id, s.login, s.type" - ." FROM ".$CC_CONFIG['smembTable']." m, ".$CC_CONFIG['subjTable']." s" - ." WHERE m.uid=s.id AND m.mid is null AND m.gid='$gid'"; - return $CC_DBC->getAll($sql); - } // fn listGroup - - /** * Return true if uid is [id]direct member of gid * @@ -332,180 +119,5 @@ class Subjects { } // fn isMemberOf - /* ==================================================== "private" methods */ - - /** - * Create membership record - * - * @param int $uid - * @param int $gid - * @param int $level - * @param int $mid - * @return int|PEAR_Error - */ - private static function _addMemb($uid, $gid, $level=0, $mid='null') - { - global $CC_CONFIG, $CC_DBC; - if ($uid == $gid) { - return PEAR::raiseError("Subjects::_addMemb: uid==gid ($uid)", ALIBERR_BADSMEMB); - } - $sql = "SELECT id, level, mid FROM ".$CC_CONFIG['smembTable'] - ." WHERE uid='$uid' AND gid='$gid' ORDER BY level ASC"; - $a = $CC_DBC->getAll($sql); - if (PEAR::isError($a)) { - return $a; - } - if (count($a) > 0) { - $a0 = $a[0]; - $id = $a0['id']; - if ($level < intval($a0['level'])){ - $sql2 = "UPDATE ".$CC_CONFIG['smembTable'] - ." SET level='$level', mid=$mid WHERE id='{$a0['id']}'"; - $r = $CC_DBC->query($sql2); - if (PEAR::isError($r)) { - return $r; - } - } - } else { - $id = $CC_DBC->nextId($CC_CONFIG['smembSequence']); - if (PEAR::isError($id)) { - return $id; - } - $sql3 = "INSERT INTO ".$CC_CONFIG['smembTable']." (id, uid, gid, level, mid)" - ." VALUES ($id, $uid, $gid, $level, $mid)"; - $r = $CC_DBC->query($sql3); - if (PEAR::isError($r)) { - return $r; - } - } - return $id; - } // fn _addMemb - - - /** - * Remove membership record - * - * @param int $mid - * @return null|PEAR_Error - */ - private static function _removeMemb($mid) - { - global $CC_CONFIG, $CC_DBC; - $sql = "DELETE FROM ".$CC_CONFIG['smembTable'] - ." WHERE id='$mid'"; - return $CC_DBC->query($sql); - } // fn _removeMemb - - - /** - * List [in]direct members of group - * - * @param int $gid - * @param int $uid - * @return array|PEAR_Error - */ - private static function _listMemb($gid, $uid=NULL) - { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT id, uid, level FROM ".$CC_CONFIG['smembTable'] - ." WHERE gid='$gid'".(is_null($uid) ? '' : " AND uid='$uid'"); - return $CC_DBC->getAll($sql); - } // fn _listMemb - - - /** - * List groups where uid is [in]direct member - * - * @param int $gid - * @param int $uid - * @return array|PEAR_Error - */ - private static function _listRMemb($uid, $gid=NULL) - { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT id, gid, level FROM ".$CC_CONFIG['smembTable'] - ." WHERE uid='$uid'".(is_null($gid) ? '' : " AND gid='$gid'"); - return $CC_DBC->getAll($sql); - } // fn listRMemb - - - /** - * Add uid and its [in]direct members to gid - * - * @param int $uid - * @param int $gid - * @param int $level - * @param int $rmid - * @return int|PEAR_Error - */ - private static function _plainAddSubjectToGroup($uid, $gid, $level=0, $rmid='null') - { - $mid = Subjects::_addMemb($uid, $gid, $level, $rmid); - if (PEAR::isError($mid)) { - return $mid; - } - $marr = Subjects::_listMemb($uid); - if (PEAR::isError($marr)) { - return $marr; - } - foreach ($marr as $k => $v) { - $r = Subjects::_addMemb( - $v['uid'], $gid, intval($v['level'])+$level+1, $mid - ); - if (PEAR::isError($r)) { - return $r; - } - } - return $mid; - } - - - /** - * Rebuild indirect membership records
- * it's probably more complicated to do removing without rebuild ... - * - * @return true|PEAR_Error - */ - private static function _rebuildRels() - { - global $CC_CONFIG, $CC_DBC; - $CC_DBC->query("BEGIN"); - $r = $CC_DBC->query("LOCK TABLE ".$CC_CONFIG['smembTable']); - if (PEAR::isError($r)) { - return $r; - } - $sql = "DELETE FROM ".$CC_CONFIG['smembTable'] - ." WHERE mid is not null"; - $r = $CC_DBC->query($sql); - if (PEAR::isError($r)) { - return $r; - } - $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 = Subjects::_listRMemb($it['gid']); - if (PEAR::isError($marr)) { - return $marr; - } - foreach ($marr as $k => $v) { - $r = Subjects::_plainAddSubjectToGroup( - $it['uid'], $v['gid'], intval($v['level'])+1, $v['id'] - ); - if (PEAR::isError($r)) { - return $r; - } - } - } - $r = $CC_DBC->query("COMMIT"); - if (PEAR::isError($r)) { - return $r; - } - return TRUE; - } // fn _rebuildRels - - } // class Subjects diff --git a/application/models/Validator.php b/application/models/Validator.php deleted file mode 100644 index 077f0aba6..000000000 --- a/application/models/Validator.php +++ /dev/null @@ -1,385 +0,0 @@ - - *
  • audioClipFormat.php
  • - *
  • webstreamFormat.php
  • - *
  • playlistFormat.php
  • - * - * It probably should be replaced by XML schema validation in the future. - * - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class Validator { - /** - * Format type of validated document - * @var string - */ - private $format = NULL; - - /** - * Preloaded format tree structure - * @var array - */ - private $formTree = NULL; - - /** - * Gunid of validated file for identification in mass input - * @var string - */ - private $gunid = NULL; - - - /** - * Constructor - * - * @param string $format - * format type of validated document - * @param string $gunid - * gunid of validated file for identification in mass input - */ - public function __construct($format, $gunid) - { - $format = strtolower($format); - $this->format = $format; - $this->gunid = $gunid; - $formats = array( - 'audioclip' => "audioClipFormat", - 'playlist' => "playlistFormat", - 'webstream' => "webstreamFormat", - ); - if (!isset($formats[$format])) { - return $this->_err(VAL_FORMAT); - } - $formatName = $formats[$format]; - $formatFile = dirname(__FILE__)."/$formatName.php"; - if (!file_exists($formatFile)) { - return $this->_err(VAL_FORMAT); - } - require($formatFile); - $this->formTree = $$formatName; - } - - - /** - * Validate document - only wrapper for validateNode method - * - * @param object $data - * validated object tree - * @return mixed - * TRUE or PEAR::error - */ - function validate(&$data) - { - $r = $this->validateNode($data, $this->formTree['_root']); - return $r; - } - - - /** - * Validate one metadata value (on insert/update) - * - * @param string $fname - * parent element name - * @param string $category - * qualif.category name - * @param string $predxml - * 'A' | 'T' (attr or tag) - * @param string $value - * validated element value - * @return TRUE|PEAR_Error - */ - function validateOneValue($fname, $category, $predxml, $value) - { - $formTree =& $this->formTree; - switch ($predxml) { - case 'T': - if (!$this->isChildInFormat($fname, $category)) { - return $this->_err(VAL_UNKNOWNE, "$category in $fname"); - } - break; - case 'A': - if (!$this->isAttrInFormat($fname, $category)) { - return $this->_err(VAL_UNKNOWNA, "$category in $fname"); - } - break; - case 'N': - return TRUE; - break; - default: - return $this->_err(VAL_PREDXML, $predxml); - } - if (isset($formTree[$category]['regexp'])) { - // echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n"; - if (!preg_match("|{$formTree[$category]['regexp']}|", $value)) { - return $this->_err(VAL_CONTENT, "$category/$value"); - } - } - } - - - /** - * Validation of one element node from object tree - * - * @param object $node - * validated node - * @param string $fname - * actual name in format structure - * @return mixed - * TRUE or PEAR::error - */ - function validateNode(&$node, $fname) - { - $dname = (($node->ns? $node->ns.":" : '').$node->name); - $formTree =& $this->formTree; - if (DEBUG) { - echo"\nVAL::validateNode: 1 $dname/$fname\n"; - } - // check root node name: - if ($dname != $fname) { - return $this->_err(VAL_ROOT, $fname); - } - // check if this element is defined in format: - if (!isset($formTree[$fname])) { - return $this->_err(VAL_NOTDEF, $fname); - } - // check element content - if (isset($formTree[$fname]['regexp'])) { - // echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n"; - if (!preg_match("|{$formTree[$fname]['regexp']}|", $node->content)) { - return $this->_err(VAL_CONTENT, "$fname/{$node->content}"); - } - } - // validate attributes: - $ra = $this->validateAttributes($node, $fname); - if (PEAR::isError($ra)) { - return $ra; - } - // validate children: - $r = $this->validateChildren($node, $fname); - if (PEAR::isError($r)) { - return $r; - } - return TRUE; - } - - - /** - * Validation of attributes - * - * @param object $node - * validated node - * @param string $fname - * actual name in format structure - * @return mixed - * TRUE or PEAR::error - */ - function validateAttributes(&$node, $fname) - { - $formTree =& $this->formTree; - $attrs = array(); - // check if all attrs are permitted here: - foreach ($node->attrs as $i => $attr) { - $aname = (($attr->ns? $attr->ns.":" : '').$attr->name); - $attrs[$aname] =& $node->attrs[$i]; - if (!$this->isAttrInFormat($fname, $aname)) { - return $this->_err(VAL_UNKNOWNA, $aname); - } - // check attribute format - // echo "XXA $aname\n"; - if (isset($formTree[$aname]['regexp'])) { - // echo "XAR {$formTree[$fname]['regexp']} / ".$node->content."\n"; - if (!preg_match("|{$formTree[$aname]['regexp']}|", $attr->val)) { - return $this->_err(VAL_ATTRIB, "$aname [".var_export($attr->val,TRUE)."]"); - } - } - } - // check if all required attrs are here: - if (isset($formTree[$fname]['attrs'])) { - $fattrs =& $formTree[$fname]['attrs']; - if (isset($fattrs['required'])) { - foreach ($fattrs['required'] as $i => $attr) { - if (!isset($attrs[$attr])) { - return $this->_err(VAL_NOREQA, $attr); - } - } - } - } - return TRUE; - } - - - /** - * Validation children nodes - * - * @param object $node - * validated node - * @param string $fname - * actual name in format structure - * @return mixed - * TRUE or PEAR::error - */ - function validateChildren(&$node, $fname) - { - $formTree =& $this->formTree; - $childs = array(); - // check if all children are permitted here: - foreach ($node->children as $i => $ch) { - $chname = (($ch->ns? $ch->ns.":" : '').$ch->name); - // echo "XXE $chname\n"; - if (!$this->isChildInFormat($fname, $chname)) { - return $this->_err(VAL_UNKNOWNE, $chname); - } - // call children recursive: - $r = $this->validateNode($node->children[$i], $chname); - if (PEAR::isError($r)) { - return $r; - } - $childs[$chname] = TRUE; - } - // check if all required children are here: - if (isset($formTree[$fname]['childs'])) { - $fchilds =& $formTree[$fname]['childs']; - if (isset($fchilds['required'])) { - foreach ($fchilds['required'] as $i => $ch) { - if (!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch); - } - } - // required one from set - if (isset($fchilds['oneof'])) { - $one = FALSE; - foreach ($fchilds['oneof'] as $i => $ch) { - if (isset($childs[$ch])) { - if ($one) { - return $this->_err(VAL_UNEXPONEOF, "$ch in $fname"); - } - $one = TRUE; - } - } - if (!$one) { - return $this->_err(VAL_NOONEOF); - } - } - } - return TRUE; - } - - - /** - * Test if child is presented in format structure - * - * @param string $fname - * node name in format structure - * @param string $chname - * child node name - * @return boolean - */ - function isChildInFormat($fname, $chname) - { - $listo = $this->isInFormatAs($fname, $chname, 'childs', 'optional'); - $listr = $this->isInFormatAs($fname, $chname, 'childs', 'required'); - $list1 = $this->isInFormatAs($fname, $chname, 'childs', 'oneof'); - return ($listo!==FALSE || $listr!==FALSE || $list1!==FALSE); - } - - - /** - * Test if attribute is presented in format structure - * - * @param string $fname - * node name in format structure - * @param string $aname - * attribute name - * @return boolean - */ - function isAttrInFormat($fname, $aname) - { - $listr = $this->isInFormatAs($fname, $aname, 'attrs', 'required'); - $listi = $this->isInFormatAs($fname, $aname, 'attrs', 'implied'); - $listn = $this->isInFormatAs($fname, $aname, 'attrs', 'normal'); - return ($listr!==FALSE || $listi!==FALSE || $listn!==FALSE); - } - - - /** - * Check if node/attribute is presented in format structure - * - * @param string $fname - * node name in format structure - * @param string $chname - * node/attribute name - * @param string $nType - * 'childs' | 'attrs' - * @param string $reqType - *
      - *
    • for elements: 'required' | 'optional' | 'oneof'
    • - *
    • for attributes: 'required' | 'implied' | 'normal'
    • - *
    - * @return mixed - * boolean/int (index int format array returned if found) - */ - function isInFormatAs($fname, $chname, $nType='childs', $reqType='required') - { - $formTree =& $this->formTree; - $listed = ( - isset($formTree[$fname][$nType][$reqType]) ? - array_search($chname, $formTree[$fname][$nType][$reqType]) : - FALSE - ); - return $listed; - } - - - /** - * Error exception generator - * - * @param int $errno - * erron code - * @param string $par - * optional string for more descriptive error messages - * @return PEAR_Error - */ - function _err($errno, $par='') - { - $msg = array( - VAL_ROOT => 'Wrong root element', - VAL_NOREQE => 'Required element missing', - VAL_NOONEOF => 'One-of element missing', - VAL_UNKNOWNE => 'Unknown element', - VAL_UNKNOWNA => 'Unknown attribute', - VAL_NOTDEF => 'Not defined', - VAL_UNEXPONEOF => 'Unexpected second object from one-of set', - VAL_FORMAT => 'Unknown format', - VAL_CONTENT => 'Invalid content', - VAL_NOREQA => 'Required attribute missing', - VAL_ATTRIB => 'Invalid attribute format', - VAL_PREDXML => 'Invalid predicate type', - ); - return PEAR::raiseError( - "Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})", - $errno - ); - } - - -} // class Validator - - diff --git a/application/models/audioClipFormat.php b/application/models/audioClipFormat.php deleted file mode 100644 index d8460ccfa..000000000 --- a/application/models/audioClipFormat.php +++ /dev/null @@ -1,326 +0,0 @@ -'audioClip', - 'audioClip'=>array( - 'childs'=>array( - 'required'=>array('metadata'), - ), - ), - 'metadata'=>array( - 'childs'=>array( - 'required'=>array( - 'dc:title', 'dcterms:extent' - ), - 'optional'=>array( - 'dc:identifier', - 'dc:creator', 'dc:source', 'ls:genre', - 'ls:year', 'dc:type', 'dc:description', 'dc:format', - 'ls:bpm', 'ls:rating', 'ls:encoded_by', 'ls:track_num', - 'ls:disc_num', 'ls:disc_num', 'dc:publisher', 'ls:composer', - 'ls:bitrate', 'ls:channels', 'ls:samplerate', 'ls:encoder', - 'ls:crc', 'ls:lyrics', 'ls:orchestra', 'ls:conductor', - 'ls:lyricist', 'ls:originallyricist', 'ls:radiostationname', - 'ls:audiofileinfourl', 'ls:artisturl', 'ls:audiosourceurl', - 'ls:radiostationurl', 'ls:buycdurl', 'ls:isrcnumber', - 'ls:catalognumber', 'ls:originalartist', 'dc:rights', - 'ls:license', 'dc:title', 'dcterms:temporal', - 'dcterms:spatial', 'dcterms:entity', 'dc:description', - 'dc:creator', 'dc:subject', 'dc:type', 'dc:format', - 'dc:contributor', 'dc:language', 'dc:rights', - 'dcterms:isPartOf', 'dc:date', - 'dc:publisher', - // extra - 'dcterms:alternative', 'ls:filename', 'ls:mtime', - // added lately by sebastian - 'ls:mood', - ), - ), - 'namespaces'=>array( - 'dc'=>"http://purl.org/dc/elements/1.1/", - 'dcterms'=>"http://purl.org/dc/terms/", - 'xbmf'=>"http://www.streamonthefly.org/xbmf", - 'xsi'=>"http://www.w3.org/2001/XMLSchema-instance", - 'xml'=>"http://www.w3.org/XML/1998/namespace", - ), - ), - 'dc:identifier'=>array( - 'type'=>'Text', - 'auto'=>TRUE, - ), - 'dc:title'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:alternative'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:extent'=>array( - 'type'=>'Time', -// 'regexp'=>'^\d{2}:\d{2}:\d{2}.\d{6}$', - 'regexp'=>'^((\d{1,2}:)?\d{1,2}:)?\d{1,20}(.\d{1,6})?$', - ), - 'dc:creator'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:source'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:genre'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:year'=>array( - 'type'=>'Menu', - 'area'=>'Music', - ), - 'dc:type'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:description'=>array( - 'type'=>'Longtext', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:format'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:bpm'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:rating'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:encoded_by'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:track_num'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:disc_num'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:disc_num'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:publisher'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:composer'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:bitrate'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:channels'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:samplerate'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:encoder'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:crc'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:lyrics'=>array( - 'type'=>'Longtext', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:orchestra'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:conductor'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:lyricist'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:originallyricist'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:radiostationname'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:audiofileinfourl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:artisturl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:audiosourceurl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:radiostationurl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:buycdurl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:isrcnumber'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:catalognumber'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:originalartist'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:rights'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:license'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:title'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:temporal'=>array( - 'type'=>'Time/Date', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:spatial'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:entity'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:description'=>array( - 'type'=>'Longtext', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:creator'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:subject'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:type'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:format'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:contributor'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:language'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:rights'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:isPartOf'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:date'=>array( - 'type'=>'Date', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:publisher'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - - 'ls:filename'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:mtime'=>array( - 'type'=>'Int', -// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$', - ), -); diff --git a/application/models/playlistFormat.php b/application/models/playlistFormat.php deleted file mode 100644 index 36342163e..000000000 --- a/application/models/playlistFormat.php +++ /dev/null @@ -1,112 +0,0 @@ -'playlist', - 'playlist'=>array( - 'childs'=>array( - // 'repeatable'=>array('playlistElement'), - 'optional'=>array('metadata', 'playlistElement'), - ), - 'attrs'=>array( - 'required'=>array('id'), - 'implied'=>array('title', 'playlength'), - ), - ), - 'playlistElement'=>array( - 'childs'=>array( - 'oneof'=>array('audioClip', 'playlist'), - 'optional'=>array('fadeInfo'), - ), - 'attrs'=>array( - 'required'=>array('id', 'relativeOffset', 'clipStart', 'clipEnd', 'clipLength'), - ), - ), - 'audioClip'=>array( - 'childs'=>array( - 'optional'=>array('metadata'), - ), - 'attrs'=>array( - 'implied'=>array('id', 'title', 'playlength', 'uri'), - ), - ), - 'fadeInfo'=>array( - 'attrs'=>array( - 'required'=>array('id', 'fadeIn', 'fadeOut'), - ), - ), - 'metadata'=>array( - 'childs'=>array( - 'optional'=>array( - 'dc:title', 'dcterms:extent', 'dc:creator', 'dc:description', - 'dcterms:alternative', 'ls:filename', 'ls:mtime', - ), - ), - 'namespaces'=>array( - 'dc'=>"http://purl.org/dc/elements/1.1/", - 'dcterms'=>"http://purl.org/dc/terms/", - 'xbmf'=>"http://www.streamonthefly.org/xbmf", - 'xsi'=>"http://www.w3.org/2001/XMLSchema-instance", - 'xml'=>"http://www.w3.org/XML/1998/namespace", - ), - ), - 'dc:title'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:alternative'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:extent'=>array( - 'type'=>'Time', - 'regexp'=>'^\d{2}:\d{2}:\d{2}.\d{6}$', - ), - 'dc:creator'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:description'=>array( - 'type'=>'Longtext', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'playlength'=>array( - 'type'=>'Time', - 'regexp'=>'^((\d{2}:)?\d{2}:)?\d{1,2}(.\d{6})?$', - ), - 'id'=>array( - 'type'=>'Attribute', - 'regexp'=>'^[0-9a-f]{16}$', - ), - 'fadeIn'=>array( - 'type'=>'Attribute', - 'regexp'=>'^((\d{2}:)?\d{2}:)?\d{1,2}(.\d{6})?$', - ), - 'fadeOut'=>array( - 'type'=>'Attribute', - 'regexp'=>'^((\d{2}:)?\d{2}:)?\d{1,2}(.\d{6})?$', - ), - 'ls:filename'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:mtime'=>array( - 'type'=>'Int', -// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$', - ), -/* - ''=>array( - 'childs'=>array(''), - 'attrs'=>array('implied'=>array()), - ), -*/ -); - diff --git a/application/models/tests/PlaylistTests.php b/application/models/tests/PlaylistTests.php index 834efb506..08b63974f 100644 --- a/application/models/tests/PlaylistTests.php +++ b/application/models/tests/PlaylistTests.php @@ -118,64 +118,6 @@ class PlaylistTests extends PHPUnit_TestCase { } } - function testAddAudioClip() { - - $pl = new Playlist(); - $pl_id = $pl->create("Playlist Unit Test ". date("g:i a")); - $res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId()); - if($res !== TRUE) { - $this->fail("problems adding audioclip to playlist."); - return; - } - - $res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId()); - if($res !== TRUE) { - $this->fail("problems adding audioclip 2 to playlist."); - return; - } - } - - function testMoveAudioClip() { - $pl = new Playlist(); - $pl_id = $pl->create("Playlist Unit Test: Move ". date("g:i a")); - - $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId()); - $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId()); - - $res = $this->greenbox->moveAudioClipInPlaylist($pl_id, 0, 1); - - if($res !== TRUE) { - $this->fail("problems moving audioclip in playlist."); - return; - } - } - - function testDeleteAudioClip() { - $pl = new Playlist(); - $pl_id = $pl->create("Playlist UnitTest: Delete ".date("g:i a")); - - $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId()); - $res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0); - - if($res !== TRUE) { - $this->fail("problems deleting audioclip from playlist."); - return; - } - } - - function testFadeInfo() { - $pl = new Playlist(); - $pl_id = $pl->create("Playlist Unit Test: Fade Info " . date("g:i a")); - - $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId()); - - $res = $this->greenbox->changeFadeInfo($pl_id, 0, '00:00:01.14', null); - - if(!is_array($res) && count($res) !== 2) { - $this->fail("problems setting fade in playlist."); - return; - } - } } diff --git a/application/models/webstreamFormat.php b/application/models/webstreamFormat.php deleted file mode 100644 index 48d6354fa..000000000 --- a/application/models/webstreamFormat.php +++ /dev/null @@ -1,340 +0,0 @@ -'audioClip', - 'audioClip'=>array( - 'childs'=>array( - 'required'=>array('metadata'), - ), - ), - 'metadata'=>array( - 'childs'=>array( - 'required'=>array( - 'dc:title', 'dcterms:extent', 'ls:url' - ), - 'optional'=>array( - 'dc:identifier', - 'dc:creator', 'dc:source', 'ls:genre', - 'ls:year', 'dc:type', 'dc:description', 'dc:format', - 'ls:bpm', 'ls:rating', 'ls:encoded_by', 'ls:track_num', - 'ls:disc_num', 'ls:disc_num', 'dc:publisher', 'ls:composer', - 'ls:bitrate', 'ls:channels', 'ls:samplerate', 'ls:encoder', - 'ls:crc', 'ls:lyrics', 'ls:orchestra', 'ls:conductor', - 'ls:lyricist', 'ls:originallyricist', 'ls:radiostationname', - 'ls:audiofileinfourl', 'ls:artisturl', 'ls:audiosourceurl', - 'ls:radiostationurl', 'ls:buycdurl', 'ls:isrcnumber', - 'ls:catalognumber', 'ls:originalartist', 'dc:rights', - 'ls:license', 'dc:title', 'dcterms:temporal', - 'dcterms:spatial', 'dcterms:entity', 'dc:description', - 'dc:creator', 'dc:subject', 'dc:type', 'dc:format', - 'dc:contributor', 'dc:language', 'dc:rights', - 'dcterms:isPartOf', 'dc:date', - 'dc:publisher', - // extra - 'dcterms:alternative', 'ls:filename', 'ls:mtime', - // added lately by sebastian - 'ls:mood', - ), - ), - 'namespaces'=>array( - 'dc'=>"http://purl.org/dc/elements/1.1/", - 'dcterms'=>"http://purl.org/dc/terms/", - 'xbmf'=>"http://www.streamonthefly.org/xbmf", - 'xsi'=>"http://www.w3.org/2001/XMLSchema-instance", - 'xml'=>"http://www.w3.org/XML/1998/namespace", - ), - ), - 'ls:url'=>array( - 'type'=>'URL', - ), - 'dc:identifier'=>array( - 'type'=>'Text', - 'auto'=>TRUE, - ), - 'dc:title'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:alternative'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:extent'=>array( - 'type'=>'Time', - 'regexp'=>'^\d{2}:\d{2}:\d{2}.\d{6}$', - ), - 'dc:creator'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:source'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:genre'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:year'=>array( - 'type'=>'Menu', - 'area'=>'Music', - ), - 'dc:type'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:description'=>array( - 'type'=>'Longtext', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:format'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:bpm'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:rating'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:encoded_by'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:track_num'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:disc_num'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:disc_num'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:publisher'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:composer'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:bitrate'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:channels'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:samplerate'=>array( - 'type'=>'Menu', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:encoder'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:crc'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:lyrics'=>array( - 'type'=>'Longtext', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:orchestra'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:conductor'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:lyricist'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:originallyricist'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:radiostationname'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:audiofileinfourl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:artisturl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:audiosourceurl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:radiostationurl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:buycdurl'=>array( - 'type'=>'URL', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:isrcnumber'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:catalognumber'=>array( - 'type'=>'Number', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:originalartist'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:rights'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:license'=>array( - 'type'=>'Text', - 'area'=>'Music', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:title'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:temporal'=>array( - 'type'=>'Time/Date', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:spatial'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:entity'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:description'=>array( - 'type'=>'Longtext', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:creator'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:subject'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:type'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:format'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:contributor'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:language'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:rights'=>array( - 'type'=>'Menu', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dcterms:isPartOf'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:date'=>array( - 'type'=>'Date', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'dc:publisher'=>array( - 'type'=>'Text', - 'area'=>'Talk', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:filename'=>array( - 'type'=>'Text', - 'attrs'=>array('implied'=>array('xml:lang')), - ), - 'ls:mtime'=>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(), - ), -*/ -); - diff --git a/application/models/xmlrpc/XR_LocStor.php b/application/models/xmlrpc/XR_LocStor.php deleted file mode 100644 index 2208f07d5..000000000 --- a/application/models/xmlrpc/XR_LocStor.php +++ /dev/null @@ -1,3833 +0,0 @@ - - *
  • version : string
  • - * - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_getVersion: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Subjects::getVersion - */ -// public function xr_getVersion($input) -// { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } -// $res = $this->getVersion(); -// if (PEAR::isError($res)) { -// return new XML_RPC_Response(0, 805, -// "xr_getVersion: ".$res->getMessage(). -// " ".$res->getUserInfo() -// ); -// } -// return new XML_RPC_Response( -// XML_RPC_encode(array('version'=>$res)) -// ); -// } - public function xr_getVersion() - { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } - $res = $this->getVersion(); -// if (PEAR::isError($res)) { -// return new XML_RPC_Response(0, 805, -// "xr_getVersion: ".$res->getMessage(). -// " ".$res->getUserInfo() -// ); -// } - return new XML_RPC_Response( - XML_RPC_encode(array('version'=>$res)) - ); - } - - - /* ------------------------------------------------------- authentication */ - /** - * Checks the login name and password of the user and return - * true if login data are correct, othervise return false. - * - * The XML-RPC name of this method is "locstor.authenticate". - * - * Input parameters: XML-RPC struct with the following fields: - *
      - *
    • login : string - login name
    • - *
    • pass : string - password
    • - *
    - * On success, returns a XML-RPC struct with single field: - *
      - *
    • authenticate : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 804 - xr_authenticate: database error
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Subjects::authenticate - */ - public function xr_authenticate($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->authenticate($r['login'], $r['pass']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 804, - "xr_authenticate: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - $retval = ($res !== FALSE); - return new XML_RPC_Response( - XML_RPC_encode(array('authenticate'=>$retval)) - ); - } - - - /** - * Checks the login name and password of the user. If the login is - * correct, a new session ID string is generated, to be used in all - * subsequent XML-RPC calls as the "sessid" field of the - * parameters. - * - * The XML-RPC name of this method is "locstor.login". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • login : string - login name
    • - *
    • pass : string - password
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • sessid : string - the newly generated session ID
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 802 - xr_login: login failed - - * incorrect username or password.
    • - *
    • 804 - xr_login:: database error
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Alib::login - */ - public function xr_login($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = Alib::Login($r['login'], $r['pass']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 804, - "xr_login: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - if ($res === FALSE) { - return new XML_RPC_Response(0, 802, - "xr_login: login failed - incorrect username or password." - ); - } else { - return new XML_RPC_Response(XML_RPC_encode(array('sessid'=>$res))); - } - } - - /** - * Logout, destroy session and return status. - * If session is not valid error message is returned. - * - * The XML-RPC name of this method is "locstor.logout". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean - TRUE
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 803 - xr_logout: logout failed - not logged.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - public function xr_logout($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = Alib::Logout($r['sessid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 803, - "xr_logout: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /* ---------------------------------------------------------------- store */ - /** - * Open writable URL for store new AudioClip or replace existing one. - * Writing to returned URL is possible using HTTP PUT method - * (as e.g. curl -T <filename> command does) - * - * The XML-RPC name of this method is "locstor.storeAudioClipOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioCLip, - * if gunid is empty string, new one is generated - * (returned by subsequent storeAudioClipClose call) - *
    • - *
    • metadata : string - metadata XML string - * (as defined in Airtime::Core::AudioClip Class Reference, - * examples are in storageServer/var/tests/*.xml) - *
    • - *
    • fname : string - human readable mnemonic file name - * with extension corresponding to filetype
    • - *
    • chsum : string - md5 checksum of media file
    • - *
    - * - * On success, returns a XML-RPC struct: - *
      - *
    • url : string - writable URL for HTTP PUT
    • - *
    • token : string - access token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_storeAudioClipOpen: - * <message from lower layer>
    • - *
    • 888 - If the file being uploaded is a duplicate of - * a file already in the system.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::storeAudioClipOpen - */ - public function xr_storeAudioClipOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->storeAudioClipOpen($r['sessid'], $r['gunid'], - $r['metadata'], $r['fname'], $r['chsum']); - if (PEAR::isError($res)) { - $code = 805; - if ($res->getCode() == 888) { - $code = 888; - } - return new XML_RPC_Response(0, $code, - "xr_storeAudioClipOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Close writable URL for store new AudioClip or replace existing one. - * - * The XML-RPC name of this method is "locstor.storeAudioClipClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • token : string - access token
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • gunid : string - gunid of stored file
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_storeAudioClipClose: - * <message from lower layer>
    • - *
    • 850 - wrong 1st parameter, struct expected.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::storeAudioClipClose - */ - public function xr_storeAudioClipClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->storeAudioClipClose($r['sessid'], $r['token']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_TOKEN ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_storeAudioClipClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /** - * Store audio stream identified by URL - no raw audio data - * - * The XML-RPC name of this method is "locstor.storeWebstream". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioCLip
    • - *
    • metadata : string - metadata XML string
    • - *
    • fname : string - human readable mnemonic file name - * with extension corresponding to filetype
    • - *
    • url : string - URL of the webstrea,
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • gunid : string - gunid of stored file
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_storeWebstream: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::storeWebstream - */ - public function xr_storeWebstream($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->storeWebstream( - $r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['url'] - ); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_storeWebstream: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /* ------------------------------------------------ access raw audio data */ - /** - * Make access to audio clip. - * - * The XML-RPC name of this method is "locstor.accessRawAudioData". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioClip
    • - *
    - * - * On success, returns a XML-RPC struct: - *
      - *
    • url : string - local access url
    • - *
    • token : string - access token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_accessRawAudioData: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::accessRawAudioData - */ - public function xr_accessRawAudioData($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->accessRawAudioData($r['sessid'], $r['gunid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_accessRawAudioData: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Release access to audio clip - * - * The XML-RPC name of this method is "locstor.releaseRawAudioData". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - access token - * returned by locstor.accessRawAudioData
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_releaseRawAudioData: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::releaseRawAudioData - */ - public function xr_releaseRawAudioData($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->releaseRawAudioData(NULL, $r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_releaseRawAudioData: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /* ---------------------------------------------- download raw audio data */ - /** - * Create downlodable URL for stored file - * - * The XML-RPC name of this method is "locstor.downloadRawAudioDataOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioClip
    • - *
    - * - * On success, returns a XML-RPC struct: - *
      - *
    • url : string - downloadable url
    • - *
    • token : string - download token
    • - *
    • chsum : string - md5 checksum
    • - *
    • size : int - file size
    • - *
    • filename : string - human readable mnemonic file name
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_accessRawAudioDataOpen: - * <message from lower layer>
    • - *
    • 847 - invalid gunid.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::downloadRawAudioDataOpen - */ - public function xr_downloadRawAudioDataOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_NOTF ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_downloadRawAudioDataOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Delete downlodable URL with media file. - * - * The XML-RPC name of this method is "locstor.downloadRawAudioDataClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • token : string - download token - * returned by locstor.downloadRawAudioDataOpen
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • gunid : string - global unique ID
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_releaseRawAudioDataClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::downloadRawAudioDataClose - */ - public function xr_downloadRawAudioDataClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->downloadRawAudioDataClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_downloadRawAudioDataClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /* ---------------------------------------------------- download metadata */ - /** - * Create downlodable URL for metadata part of stored file - * - * The XML-RPC name of this method is "locstor.downloadMetadataOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioClip
    • - *
    - * - * On success, returns a XML-RPC struct: - *
      - *
    • url : string - downloadable url
    • - *
    • token : string - download token
    • - *
    • chsum : string - md5 checksum
    • - *
    • filename : string - mnemonic filename
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_downloadMetadataOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::downloadRawAudioDataOpen - */ - public function xr_downloadMetadataOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - #$this->debugLog("{$r['sessid']}, {$r['gunid']}"); - $res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_downloadMetadataOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Delete downlodable URL with metadata. - * - * The XML-RPC name of this method is "locstor.downloadMetadataClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • token : string - download token - * returned by locstor.downloadRawAudioDataOpen
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • gunid : string - global unique ID
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_downloadMetadataClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::downloadRawAudioDataClose - */ - public function xr_downloadMetadataClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->downloadMetadataClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_downloadMetadataClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); - } - - /* --------------------------------------------------------------- delete */ - /** - * Delete existing audio clip - DISABLED now! - * - * The XML-RPC name of this method is "locstor.deleteAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioCLip
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean - TRUE
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_deleteAudioClip: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::deleteAudioClip - */ - public function xr_deleteAudioClip($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - if (!isset($r['forced'])) { - $r['forced']=FALSE; - } - $res = $this->deleteAudioClip($r['sessid'], $r['gunid'], $r['forced']); - if (!$r['forced']) { - return new XML_RPC_Response(0, 805, "xr_deleteAudioClip: method disabled"); - } - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_deleteAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /*====================================================== playlist methods */ - /** - * Create a new Playlist metafile. - * - * The XML-RPC name of this method is "locstor.createPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - global unique id of Playlist
    • - *
    • fname : string - human readable menmonic file name
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • plid : string
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_createPlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::createPlaylist - */ - public function xr_createPlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->createPlaylist($r['sessid'], $r['plid'], $r['fname']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_createPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); - } - - /** - * Open a Playlist metafile for editing. - * Open readable URL and mark file as beeing edited. - * - * The XML-RPC name of this method is "locstor.editPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - global unique id of Playlist
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • url : string - readable url
    • - *
    • token : string - playlist token
    • - *
    • chsum : string - md5 checksum
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_editPlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::editPlaylist - */ - public function xr_editPlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->editPlaylist($r['sessid'], $r['plid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_editPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Store a new Playlist metafile in place of the old one. - * - * The XML-RPC name of this method is "locstor.savePlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • token : string - playlist token - * returned by locstor.editPlaylist
    • - *
    • newPlaylist : string - new Playlist in XML string
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • plid : string - playlistId
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_savePlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::savePlaylist - */ - public function xr_savePlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->savePlaylist($r['sessid'], $r['token'], $r['newPlaylist']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_savePlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); - } - - /** - * RollBack playlist changes to the locked state - * - * The XML-RPC name of this method is "locstor.revertEditedPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • token : string - playlist token - * returned by locstor.editPlaylist
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • plid : string - playlistId
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_revertEditedPlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::revertEditedPlaylist - */ - public function xr_revertEditedPlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->revertEditedPlaylist($r['token'], $r['sessid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_revertEditedPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); - } - - /* ------------------------------------------------------- delete playlist*/ - /** - * Delete a Playlist metafile - DISABLED now! - * - * The XML-RPC name of this method is "locstor.deletePlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - global unique id of Playlist
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean - TRUE
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_deletePlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::deletePlaylist - */ - public function xr_deletePlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - if (!isset($r['forced'])) { - $r['forced']=FALSE; - } - $res = $this->deletePlaylist($r['sessid'], $r['plid'], $r['forced']); - if (! $r['forced']) { - return new XML_RPC_Response(0, 805,"xr_deletePlaylist: method disabled"); - } - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_FILENEX ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_deletePlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /* ------------------------------------------------------- access playlist*/ - /** - * Access (read) a Playlist metafile. - * - * The XML-RPC name of this method is "locstor.accessPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - global unique id of Playlist
    • - *
    • recursive : boolean - flag for recursive access content - * inside playlist (default: false)
    • - *
    - * - * On success, returns an XML-RPC struct with the following fields: - *
      - *
    • url : string - readable url of accessed playlist in - * XML format
    • - *
    • token : string - playlist token
    • - *
    • chsum : string - md5 checksum
    • - *
    • content: array of structs - recursive access (optional)
    • - *
    - * - * The content field contains a struct for each playlist - * element contained in the playlist. For audio clips, this struct is - * of type {url, token}; for sub-playlists, it is of type - * {url, token, chsum, content}. - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_accessPlaylist: - * <message from lower layer>
    • - *
    • 847 - invalid plid.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::accessPlaylist - */ - public function xr_accessPlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - if (!isset($r['recursive']) || is_null($r['recursive'])) { - $r['recursive']=FALSE; - } - $res = $this->accessPlaylist($r['sessid'], $r['plid'], (boolean)$r['recursive']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_NOTF ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_accessPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Release the resources obtained earlier by accessPlaylist(). - * - * The XML-RPC name of this method is "locstor.releasePlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - playlist token - * returned by locstor.accessPlaylist
    • - *
    • recursive : boolean - flag for recursive release content - * accessed by recursive accessPlaylist - * (ignored now - true forced)
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • plid : string - playlist ID
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_releasePlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::releasePlaylist - */ - public function xr_releasePlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - //if (!isset($r['recursive']) || is_null($r['recursive'])) $r['recursive']=FALSE; - $res = $this->releasePlaylist(NULL, $r['token'], TRUE); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_releasePlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); - } - - /* -------------------------------------------------------- playlist info */ - /** - * Check whether a Playlist metafile with the given playlist ID exists. - * - * The XML-RPC name of this method is "locstor.existsPlaylist". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - global unique id of Playlist
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • exists : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_existsPlaylist: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::existsPlaylist - */ - public function xr_existsPlaylist($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->existsPlaylist($r['sessid'], $r['plid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_existsPlaylist: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); - } - - /** - * Check whether a Playlist metafile with the given playlist ID - * is available for editing, i.e., exists and is not marked as - * beeing edited. - * - * The XML-RPC name of this method is "locstor.playlistIsAvailable". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - global unique id of Playlist
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • available : boolean
    • - *
    • ownerid : int - local user id
    • - *
    • ownerlogin : string - local username
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_playlistIsAvailable: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::playlistIsAvailable - */ - public function xr_playlistIsAvailable($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->playlistIsAvailable($r['sessid'], $r['plid'], TRUE); - $ownerId = ($res === TRUE ? NULL : $res); - $ownerLogin = (is_null($ownerId) ? NULL : Subjects::GetSubjName($ownerId)); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_playlistIsAvailable: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'available' => ($res === TRUE), - 'ownerid' => $ownerId, - 'ownerlogin' => $ownerLogin, - ))); - } - - /* ------------------------------------------------------ export playlist */ - /** - * Create a tarfile with playlist export - playlist and all matching - * sub-playlists and media files (if desired) - * - * The XML-RPC name of this method is "locstor.exportPlaylistOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plids : array of strings - global unique IDs of Playlists
    • - *
    • type : string - playlist format, values: lspl | smil
    • - *
    • standalone : boolean - if only playlist should be exported or - * with all related files
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • url : string - readable url
    • - *
    • token : string - access token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_exportPlaylistOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::exportPlaylistOpen - */ - public function xr_exportPlaylistOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - if (!isset($r['standalone']) || empty($r['standalone'])) { - $r['standalone']=FALSE; - } - $res = $this->exportPlaylistOpen( - $r['sessid'], $r['plids'], $r['type'], $r['standalone'] - ); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_exportPlaylistOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'url' => $res['url'], - 'token' => $res['token'], - ))); - } - - /** - * Close playlist export previously opened by the exportPlaylistOpen method - * - * The XML-RPC name of this method is "locstor.exportPlaylistClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - access token
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean - status/li> - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_exportPlaylistClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::exportPlaylistClose - */ - public function xr_exportPlaylistClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->exportPlaylistClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_exportPlaylistClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>TRUE))); - } - - /* ------------------------------------------------------ import playlist */ - /** - * Open writable URL for import playlist in LS Archive format - * - * The XML-RPC name of this method is "locstor.importPlaylistOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • chsum : string - md5 checksum of imported file
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • url : string - writable url
    • - *
    • token : string - PUT token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_importPlaylistOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::importPlaylistOpen - */ - public function xr_importPlaylistOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->importPlaylistOpen($r['sessid'], $r['chsum']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_importPlaylistOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'url'=>$res['url'], - 'token'=>$res['token'], - ))); - } - - /** - * Open writable URL for import playlist in LS Archive format - * - * The XML-RPC name of this method is "locstor.importPlaylistClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - access token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • gunid : string - global id
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_importPlaylistClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::importPlaylistClose - */ - public function xr_importPlaylistClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->importPlaylistClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_importPlaylistClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'gunid'=>$res, - ))); - } - - /* ---------------------------------------------- render playlist to file */ - /** - * Render playlist to ogg file (open handle) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToFileOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - playlist gunid
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToFileOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToFileOpen - */ - public function xr_renderPlaylistToFileOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToFileOpen($r['sessid'], $r['plid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToFileOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'token'=>$res['token'], - ))); - } - - /** - * Render playlist to ogg file (check results) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToFileCheck". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : string - success | working | fault
    • - *
    • url : string - readable url
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToFileCheck: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToFileCheck - */ - public function xr_renderPlaylistToFileCheck($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToFileCheck($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToFileCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'url'=>$res['url'], - 'status'=>$res['status'], - ))); - } - - /** - * Render playlist to ogg file (close handle) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToFileClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToFileClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToFileClose - */ - public function xr_renderPlaylistToFileClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToFileClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToFileClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'status'=>$res['status'], - ))); - } - - /* ------------------------------------------- render playlist to storage */ - /** - * Render playlist to storage media clip (open handle) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToStorageOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - playlist gunid
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToStorageOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToStorageOpen - */ - public function xr_renderPlaylistToStorageOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToStorageOpen($r['sessid'], $r['plid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToStorageOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'token'=>$res['token'], - ))); - } - - /** - * Render playlist to storage media clip (check results) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToStorageCheck". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : string - success | working | fault
    • - *
    • gunid : string - gunid of result file
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToStorageCheck: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToStorageCheck - */ - public function xr_renderPlaylistToStorageCheck($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToStorageCheck($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToStorageCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'status'=>$res['status'], - 'gunid'=>$res['gunid'], - ))); - } - - /* ----------------------------------------------- render playlist to RSS */ - /** - * Render playlist to RSS file (open handle) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToRSSOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • plid : string - playlist gunid
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToRSSOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToRSSOpen - */ - public function xr_renderPlaylistToRSSOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToRSSOpen($r['sessid'], $r['plid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToRSSOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'token'=>$res['token'], - ))); - } - - /** - * Render playlist to RSS file (check results) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToRSSCheck". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : string - success | working | fault
    • - *
    • url : string - readable url
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToRSSCheck: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToRSSCheck - */ - public function xr_renderPlaylistToRSSCheck($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToRSSCheck($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToRSSCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'url'=>$res['url'], - 'status'=>$res['status'], - ))); - } - - /** - * Render playlist to RSS file (close handle) - * - * The XML-RPC name of this method is "locstor.renderPlaylistToRSSClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - render token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_renderPlaylistToRSSClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::renderPlaylistToRSSClose - */ - public function xr_renderPlaylistToRSSClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->renderPlaylistToRSSClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_renderPlaylistToRSSClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'status'=>$res['status'], - ))); - } - - /*==================================================storage admin methods */ - /* ------------------------------------------------------- backup methods */ - /** - * Create backup of storage (open handle) - * - * The XML-RPC name of this method is "locstor.createBackupOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • criteria : struct - see search criteria
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • token : string - backup token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_createBackupOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::createBackupOpen - */ - public function xr_createBackupOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - -# return new XML_RPC_Response(XML_RPC_encode(var_export($this, TRUE))); - - $res = $this->createBackupOpen($r['sessid'], $r['criteria']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_createBackupOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'token'=>$res['token'], - ))); - } - - /** - * Create backup of storage (check results) - * - * The XML-RPC name of this method is "locstor.createBackupCheck". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - backup token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : string - success | working | fault
    • - *
    • url : string - readable url
    • - *
    • metafile : string - archive metafile in XML format
    • - *
    • faultString : string - error message - * (use only if status==fault)
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_createBackupCheck: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::createBackupCheck - */ - //
  • 854 - backup process fault
  • - public function xr_createBackupCheck($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->createBackupCheck($r['token']); - - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_BGERR ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_createBackupCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Create backup of storage (list results) - * - * The XML-RPC name of this method is "locstor.createBackupList". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • stat : string - backup status
    • - *
    - * - * On success, returns a XML-RPC array of struct with following fields: - *
      - *
    • status : string - success | working | fault
    • - *
    • url : string - readable url
    • - *
    • metafile : string - archive metafile in XML format
    • - *
    • faultString : string - error message - * (use only if status==fault)
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_createBackupCheck: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::createBackupCheck - */ - //
  • 854 - backup process fault
  • - public function xr_createBackupList($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - if (!isset($r['stat']) || is_null($r['stat'])) { - $r['stat']=''; - } - $res = $this->createBackupList($r['stat']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_BGERR ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_createBackupCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Create backup of storage (close handle) - * - * The XML-RPC name of this method is "locstor.createBackupClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - backup token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_createBackupClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::createBackupClose - */ - public function xr_createBackupClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->createBackupClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_createBackupClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'status'=>$res['status'], - ))); - } - /* ------------------------------------------------------ restore methods */ - /** - * Open restore a backup file - * - * The XML-RPC name of this method is "locstor.restoreBackupOpen". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • chsum : string - md5 checksum of restore file
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • url : string - writable URL for HTTP PUT
    • - *
    • token : string - PUT token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_restoreBackupOpen: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::restoreBackupOpen - */ - public function xr_restoreBackupOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->restoreBackupOpen($r['sessid'], $r['chsum']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_restoreBackupOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - unset($res['fname']); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Close writable URL for restore a backup file and start the restore - * process - * - * The XML-RPC name of this method is "locstor.restoreBackupClosePut". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • token : string - PUT token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • token : string - restore token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_restoreBackupClosePut: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::restoreBackupClosePut - */ - public function xr_restoreBackupClosePut($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->restoreBackupClosePut($r['sessid'], $r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_restoreBackupClosePut: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Check the state of restore procedure - * - * The XML-RPC name of this method is "locstor.restoreBackupCheck". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - restore token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : string - success | working | fault
    • - *
    • faultString: string - description of fault
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_restoreBackupCheck: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::restoreBackupCheck - */ - public function xr_restoreBackupCheck($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->restoreBackupCheck($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_restoreBackupCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } -# return new XML_RPC_Response(XML_RPC_encode(array( -# 'status'=>$res, -# ))); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Close the restore process - * - * The XML-RPC name of this method is "locstor.restoreBackupClose". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • token : string - restore token
    • - *
    - * - * On success, returns a XML-RPC struct with following fields: - *
      - *
    • status : string - status
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_restoreBackupClose: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::restoreBackupClose - */ - public function xr_restoreBackupClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->restoreBackupClose($r['token']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_restoreBackupClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } -# return new XML_RPC_Response(XML_RPC_encode(array( -# 'gunid'=>$res, -# ))); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /*========================================================== info methods */ - /** - * Check if audio clip exists and return TRUE/FALSE - * - * The XML-RPC name of this method is "locstor.existsAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioCLip
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • exists : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_existsAudioClip: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::existsAudioClip - */ - public function xr_existsAudioClip($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - #$this->debugLog(join(', ', $r)); - $res = $this->existsAudioClip($r['sessid'], $r['gunid']); - #$this->debugLog($res); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 805, - "xr_existsAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); - } - - /*====================================================== metadata methods */ - /** - * Return all file's metadata as XML string - * - * The XML-RPC name of this method is "locstor.getAudioClip". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioCLip
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • metadata : string - metadata as XML
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_getAudioClip: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::getAudioClip - */ - public function xr_getAudioClip($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->getAudioClip($r['sessid'], $r['gunid']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('metadata'=>$res))); - } - - /** - * Update existing audio clip metadata - * - * The XML-RPC name of this method is "locstor.updateAudioClipMetadata". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id of AudioCLip
    • - *
    • metadata : metadata XML string
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean - TRUE
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_updateAudioClipMetadata: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::updateAudioClipMetadata - */ - public function xr_updateAudioClipMetadata($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->updateAudioClipMetadata( - $r['sessid'], $r['gunid'], $r['metadata'] - ); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_updateAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /** - * Search in local metadata database - * - * The XML-RPC name of this method is "locstor.searchMetadata". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • criteria : struct, with following fields:
      - *
        - *
      • filetype : string - type of searched files, - * meaningful values: 'audioclip', 'webstream', 'playlist', 'all'
      • - *
      • operator : string - type of conditions join - * (any condition matches / all conditions match), - * meaningful values: 'and', 'or', '' - * (may be empty or ommited only with less then 2 items in - * "conditions" field) - *
      • - *
      • limit : int - limit for result arrays (0 means unlimited)
      • - *
      • offset : int - starting point (0 means without offset)
      • - *
      • orderby : string - metadata category for sorting (optional) - * or array of strings for multicolumn orderby - * [default: dc:creator, dc:source, dc:title] - *
      • - *
      • desc : boolean - flag for descending order (optional) - * or array of boolean for multicolumn orderby - * (it corresponds to elements of orderby field) - * [default: all ascending] - *
      • - *
      • conditions : array of struct with fields: - *
          - *
        • cat : string - metadata category name
        • - *
        • op : string - operator, meaningful values: - * 'full', 'partial', 'prefix', '=', '<', '<=', - * '>', '>='
        • - *
        • val : string - search value
        • - *
        - *
      • - *
      - *
    • - *
    - * - * On success, returns a XML-RPC array of structs with fields: - *
      - *
    • cnt : integer - number of matching gunids - * of files have been found
    • - *
    • results : array of hashes: - *
        - *
      • gunid: string
      • - *
      • type: string - audioclip | playlist | webstream
      • - *
      • title: string - dc:title from metadata
      • - *
      • creator: string - dc:creator from metadata
      • - *
      • source: string - dc:source from metadata
      • - *
      • length: string - dcterms:extent in extent format
      • - *
      - *
    • - *
    - * (cnt value may be greater than size of result array - see limit param) - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_searchMetadata: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::searchMetadata - * @see BasicStor::localSearch - */ - public function xr_searchMetadata($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->searchMetadata($r['sessid'], $r['criteria']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_searchAudioClip: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } -# return new XML_RPC_Response(XML_RPC_encode($res)); - $xv = new XML_RPC_Value; - $xv->addStruct(array( - 'cnt' => XML_RPC_encode($res['cnt']), - 'results' => - (count($res['results'])==0 - ? new XML_RPC_Value(array(), 'array') - : XML_RPC_encode($res['results']) - ), - )); - return new XML_RPC_Response($xv); - } - - /** - * Return values of specified metadata category - * - * The XML-RPC name of this method is "locstor.browseCategory". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • category : string - metadata category name - * with or without namespace prefix (dc:title, author)
    • - *
    • criteria : hash - see searchMetadata method
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • results : array with found values
    • - *
    • cnt : integer - number of matching values
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_browseCategory: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::browseCategory - */ - public function xr_browseCategory($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->browseCategory( - $r['category'], $r['criteria'], $r['sessid'] - ); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - - ); - } - $xv = new XML_RPC_Value; - $xv->addStruct(array( - 'cnt' => XML_RPC_encode($res['cnt']), - 'results' => - (count($res['results'])==0 - ? new XML_RPC_Value(array(), 'array') - : XML_RPC_encode($res['results']) - ), - )); - return new XML_RPC_Response($xv); - } - - /* ============================================== methods for preferences */ - /** - * Load user preference value - * - * The XML-RPC name of this method is "locstor.loadPref". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • key : string - preference key
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • value : string - preference value
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_loadPref: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 849 - invalid preference key.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Pref::loadPref - */ - public function xr_loadPref($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once(dirname(__FILE__).'/../Prefs.php'); - $pr = new Prefs($this); - $res = $pr->loadPref($r['sessid'], $r['key']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res))); - } - - /** - * Save user preference value - * - * The XML-RPC name of this method is "locstor.savePref". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • key : string - preference key
    • - *
    • value : string - preference value
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_savePref: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Pref::savePref - */ - public function xr_savePref($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once(dirname(__FILE__).'/../Prefs.php'); - $pr = new Prefs($this); - $res = $pr->savePref($r['sessid'], $r['key'], $r['value']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /** - * Delete user preference record - * - * The XML-RPC name of this method is "locstor.delPref". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • key : string - preference key
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_delPref: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 849 - invalid preference key.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Pref::delPref - */ - public function xr_delPref($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once(dirname(__FILE__).'/../Prefs.php'); - $pr = new Prefs($this); - $res = $pr->delPref($r['sessid'], $r['key']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /** - * Read group preference record - * - * The XML-RPC name of this method is "locstor.loadGroupPref". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • group : string - group name
    • - *
    • key : string - preference key
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • value : string - preference value
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_loadGroupPref: - * <message from lower layer>
    • - *
    • 820 - invalid group name.
    • - *
    • 848 - invalid session id.
    • - *
    • 849 - invalid preference key.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Pref::loadGroupPref - */ - public function xr_loadGroupPref($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once(dirname(__FILE__).'/../Prefs.php'); - $pr = new Prefs($this); - $res = $pr->loadGroupPref($r['group'], $r['key']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ( - $ec0 == GBERR_SESS || $ec0 == GBERR_PREF || $ec0==ALIBERR_NOTGR - ? 800+$ec0 : 805 - ); - return new XML_RPC_Response(0, $ec, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res))); - } - - /** - * Save group preference record - * - * The XML-RPC name of this method is "locstor.saveGroupPref". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • group : string - group name
    • - *
    • key : string - preference key
    • - *
    • value : string - preference value
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • status : boolean
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_saveGroupPref: - * <message from lower layer>
    • - *
    • 820 - invalid group name.
    • - *
    • 848 - invalid session id.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Pref::saveGroupPref - */ - public function xr_saveGroupPref($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once(dirname(__FILE__).'/../Prefs.php'); - $pr = new Prefs($this); - $res = $pr->saveGroupPref($r['sessid'], $r['group'], $r['key'], $r['value']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0==GBERR_SESS || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); - } - - /* =============================== remote repository (networking) methods */ - /* ------------------------------------------------------- common methods */ - /** - * Common "check" method for transports - * - * The XML-RPC name of this method is "locstor.getTransportInfo". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • trtype: string - audioclip | playlist | search | file
    • - *
    • direction: string - up | down
    • - *
    • state: string - transport state
    • - *
    • expectedsize: int - expected size
    • - *
    • realsize: int - size of transported file
    • - *
    • expectedchsum: string - expected checksum
    • - *
    • realchsum: string - checksum of transported file
    • - *
    • title: string - file title
    • - *
    • errmsg: string - error message from failed transports
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_getTransportInfo: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::getTransportInfo - */ - public function xr_getTransportInfo($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->getTransportInfo($r['trtok']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_getTransportInfo: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Turn transports on/off, optionaly return current state. - * - * The XML-RPC name of this method is "locstor.turnOnOffTransports". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • onOff: boolean optional - * (if not used, current state is returned)
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • state : boolean - previous state
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_turnOnOffTransports: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::turnOnOffTransports - */ - public function xr_turnOnOffTransports($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->turnOnOffTransports($r['onOff']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_turnOnOffTransports: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res))); - } - - /** - * Pause, resume or cancel transport - * - * The XML-RPC name of this method is "locstor.doTransportAction". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • trtok : string - transport token
    • - *
    • action: string - pause | resume | cancel - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • state : string - resulting transport state
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_doTransportAction: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::doTransportAction - */ - public function xr_doTransportAction($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->doTransportAction($r['trtok'], $r['action']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_doTransportAction: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res))); - } - - /* ------------------------ methods for ls-archive-format file transports */ - /** - * Open async file transfer from local storageServer to network hub, - * file should be ls-archive-format file. - * - * The XML-RPC name of this method is "locstor.uploadFile2Hub". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • filePath string - local path to uploaded file
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_uploadFile2Hub: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::uploadFile2Hub - */ - public function xr_uploadFile2Hub($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->uploadFile2Hub($r['filePath']); // local files on XML-RPC :( - // there should be something as uploadFile2storageServer - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_uploadFile2Hub: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); - } - - /** - * Get list of prepared transfers initiated by hub - * - * The XML-RPC name of this method is "locstor.getHubInitiatedTransfers". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • results : array of structs with fields: - *
        - *
      • trtok : string - transport token
      • - *
      • ... ?
      • - *
      - *
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_getHubInitiatedTransfers: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::getHubInitiatedTransfers - */ - public function xr_getHubInitiatedTransfers($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->getHubInitiatedTransfers(); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_getHubInitiatedTransfers: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /** - * Start of download initiated by hub - * - * The XML-RPC name of this method is "locstor.startHubInitiatedTransfer". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • trtok : string - transport token obtained from - * the getHubInitiatedTransfers method
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_startHubInitiatedTransfer: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::startHubInitiatedTransfer - */ - public function xr_startHubInitiatedTransfer($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->startHubInitiatedTransfer($r['trtok']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_startHubInitiatedTransfer: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); - } - - /* ------------- special methods for audioClip/webstream object transport */ - - /** - * Start upload of audioclip or playlist from local storageServer to hub - * - * The XML-RPC name of this method is "locstor.upload2Hub". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid: string - global unique id of object being transported - *
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_upload2Hub: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::upload2Hub - */ - public function xr_upload2Hub($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $res = $tr->upload2Hub($r['gunid']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_upload2Hub: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); - } - - /** - * Start download of audioclip or playlist from hub to local storageServer - * - * The XML-RPC name of this method is "locstor.downloadFromHub". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid: string - global unique id of object being transported - *
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_downloadFromHub: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::downloadFromHub - */ - public function xr_downloadFromHub($input) - { - list($ok, $par) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $par; - } - require_once('../Transport.php'); - $tr = new Transport($this); - $uid = Alib::GetSessUserId($par['sessid']); - $res = $tr->downloadFromHub($uid, $par['gunid']); - if (PEAR::isError($res)) { - $ec0 = intval($res->getCode()); - $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); - return new XML_RPC_Response(0, $ec, - "xr_downloadFromHub: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); - } - - /* ------------------------------------------------ global-search methods */ - /** - * Start search job on network hub - * - * The XML-RPC name of this method is "locstor.globalSearch". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • criteria : hash, LS criteria format - see searchMetadata method - *
    • - *
    - * - * On success, returns a XML-RPC struct with the following fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_globalSearch: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 874 - invalid hub connection configuration.
    • - *
    • 872 - invalid tranport token.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::globalSearch - */ -// public function xr_globalSearch($input) -// { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } -// require_once('../Transport.php'); -// $tr = new Transport($this); -// $res = $tr->globalSearch($r['criteria']); -// if (PEAR::isError($res)) { -// $ec0 = intval($res->getCode()); -// $ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 ); -// return new XML_RPC_Response(0, $ec, -// "xr_globalSearch: ".$res->getMessage()." ".$res->getUserInfo() -// ); -// } -// return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); -// } - - /** - * Get results from search job on network hub. - * (returns error if not finished) - * - * The XML-RPC name of this method is "locstor.getSearchResults". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On success, returns a XML-RPC array of structs with fields: - *
      - *
    • cnt : integer - number of matching gunids - * of files have been found
    • - *
    • results : array of hashes: - *
        - *
      • gunid: string
      • - *
      • type: string - audioclip | playlist | webstream
      • - *
      • title: string - dc:title from metadata
      • - *
      • creator: string - dc:creator from metadata
      • - *
      • source: string - dc:source from metadata
      • - *
      • length: string - dcterms:extent in extent format
      • - *
      - *
    • - *
    - * (cnt value may be greater than size of result array - see limit param) - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_getSearchResults: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    • 872 - invalid tranport token.
    • - *
    • 873 - not finished.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::getSearchResults - */ -// public function xr_getSearchResults($input) -// { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } -// require_once('../Transport.php'); -// $tr = new Transport($this); -// $res = $tr->getSearchResults($r['trtok']); -// if (PEAR::isError($res)) { -// $ec0 = intval($res->getCode()); -// $ec = ( -// $ec0 == GBERR_SESS || $ec0 == TRERR_TOK || $ec0 == TRERR_NOTFIN -// ? 800+$ec0 : 805 ); -// return new XML_RPC_Response(0, $ec, -// "xr_getSearchResults: ".$res->getMessage()." ".$res->getUserInfo() -// ); -// } -// return new XML_RPC_Response(XML_RPC_encode($res)); -// } - - /** - * OBSOLETE - * Starts upload audioclip to remote archive - * - * The XML-RPC name of this method is "locstor.uploadToArchive". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_uploadToArchive: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::uploadToArchive - */ -// public function xr_uploadToArchive($input) -// { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } -// require_once(dirname(__FILE__).'/../Transport.php'); -// $tr = new Transport($this); -// $res = $tr->uploadToArchive($r['gunid'], $r['sessid']); -// if (PEAR::isError($res)) { -// $ec0 = intval($res->getCode()); -// $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); -// return new XML_RPC_Response(0, $ec, -// "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() -// ); -// } -// return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); -// } - - /** - * OBSOLETE - * Starts download audioclip from remote archive - * - * The XML-RPC name of this method is "locstor.downloadFromArchive". - * - * The input parameters are an XML-RPC struct with the following - * fields: - *
      - *
    • sessid : string - session id
    • - *
    • gunid : string - global unique id
    • - *
    - * - * On success, returns a XML-RPC struct with single field: - *
      - *
    • trtok : string - transport token
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_downloadFromArchive: - * <message from lower layer>
    • - *
    • 848 - invalid session id.
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see Transport::downloadFromArchive - */ -// public function xr_downloadFromArchive($input) -// { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } -// require_once(dirname(__FILE__).'/../Transport.php'); -// $tr = new Transport($this); -// $res = $tr->downloadFromArchive($r['gunid'], $r['sessid']); -// if (PEAR::isError($res)) { -// $ec0 = intval($res->getCode()); -// $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); -// return new XML_RPC_Response(0, $ec, -// "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() -// ); -// } -// return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); -// } - - /* ================================================ methods for debugging */ - /** - * Reset storageServer for debugging. - * - * The XML-RPC name of this method is "locstor.resetStorage". - * - * The input parameters are an empty XML-RPC struct, - * or struct with the following optional fields: - *
      - *
    • loadSampleData : boolean - load sample data? (default: true) - *
    • - *
    • invalidateSessionIds : boolean - invalidate active session IDs? - * (default: false) - *
    • - *
    - * - * On success, returns the same result as searchMetadata with filetype - * 'all' and no conditions, ordered by filetype and dc:title - * i.e. XML-RPC array of structs with fields: - *
      - *
    • cnt : integer - number of inserted files
    • - *
    • results : array of hashes: - *
        - *
      • gunid: string
      • - *
      • type: string - audioclip | playlist | webstream
      • - *
      • title: string - dc:title from metadata
      • - *
      • creator: string - dc:creator from metadata
      • - *
      • source: string - dc:source from metadata
      • - *
      • length: string - dcterms:extent in extent format
      • - *
      - *
    • - *
    - * - * On errors, returns an XML-RPC error response. - * The possible error codes and error message are: - *
      - *
    • 3 - Incorrect parameters passed to method: - * Wanted ... , got ... at param
    • - *
    • 801 - wrong 1st parameter, struct expected.
    • - *
    • 805 - xr_resetStorage: - * <message from lower layer>
    • - *
    - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - * @see LocStor::getAudioClip - */ -// public function xr_resetStorage($input) -// { -// list($ok, $r) = XR_LocStor::xr_getParams($input); -// if (!$ok) { -// return $r; -// } -// $res = $this->resetStorage( -// isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE, -// !(isset($r['invalidateSessionIds']) ? $r['invalidateSessionIds'] : FALSE) -// ); -// if (PEAR::isError($res)) { -// return new XML_RPC_Response(0, 805, -// "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() -// ); -// } -// return new XML_RPC_Response(XML_RPC_encode($res)); -// } - - /** - * Test XMLRPC - strupper and return given string, - * also return loginname of logged user - * - debug method only - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - public function xr_test($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'str'=>strtoupper($r['teststring']), - 'login' => Alib::GetSessLogin($r['sessid']), - 'sessid'=>$r['sessid'] - ))); - } - - /** - * Open writable URL for put method - debug method only - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - public function xr_openPut($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->bsOpenPut(); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * Close writable URL - debug method only - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - public function xr_closePut($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->bsClosePut($r['token'], $r['chsum']); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode(array( - 'fname'=>$res['fname'], - 'owner'=>$res['owner'], - ))); - } - - /** - * Simple ping method - return string - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_ping($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = date("Ymd-H:i:s")." -- reply from remote node: {$r['par']}"; - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_uploadOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->uploadOpen($r['sessid'], $r['chsum']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_uploadOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * Check state of file upload - * - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_uploadCheck($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->uploadCheck($r['token']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_uploadCheck: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_uploadClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->uploadClose($r['token'], $r['trtype'], $r['pars']); - if (PEAR::isError($res)) { - $code = 803; - // Special case for duplicate file - give back - // different error code so we can display nice user message. - if ($res->getCode() == GBERR_GUNID) { - $code = 888; - } - return new XML_RPC_Response(0, $code, - "xr_uploadClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_downloadOpen($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->downloadOpen($r['sessid'], $r['trtype'], $r['pars']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_downloadOpen: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_downloadClose($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->downloadClose($r['token'], $r['trtype']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_downloadClose: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_prepareHubInitiatedTransfer($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - foreach (array('trtype'=>NULL, 'direction'=>'up', 'pars'=>array()) as $k => $dv) { - if (!isset($r[$k])) { - $r[$k] = $dv; - } - } - $res = $this->prepareHubInitiatedTransfer( - $r['target'], $r['trtype'], $r['direction'], $r['pars']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_prepareHubInitiatedTransfer: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_listHubInitiatedTransfers($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - foreach (array('target'=>NULL, 'direction'=>NULL, 'trtok'=>NULL) as $k=>$dv) { - if (!isset($r[$k])) { - $r[$k] = $dv; - } - } - $res = $this->listHubInitiatedTransfers( - $r['target'], $r['direction'], $r['trtok']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_listHubInitiatedTransfers: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - - /** - * @param XML_RPC_Message $input - * @return XML_RPC_Response - */ - function xr_setHubInitiatedTransfer($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->setHubInitiatedTransfer( - $r['target'], $r['trtok'], $r['state']); - if (PEAR::isError($res)) - return new XML_RPC_Response(0, 803, - "xr_setHubInitiatedTransfer: ".$res->getMessage(). - " ".$res->getUserInfo() - ); - return new XML_RPC_Response(XML_RPC_encode($res)); - } - - /* ==================================================== "private" methods */ - /** - * Check and convert struct of parameters - * - * @param XML_RPC_Message $input - * @return array - * Array of two items: first item is boolean, indicating - * successful decode. - * On success, the second param is an array of values. - * On failure, the second param is an XML_RPC_Response object. - */ - protected static function xr_getParams($input) - { - $p = $input->getParam(0); - if (isset($p) && ($p->scalartyp()=="struct")) { - $r = XML_RPC_decode($p); - return array(TRUE, $r); - } else { - return array(FALSE, new XML_RPC_Response(0, 801, "wrong 1st parameter, struct expected." )); - } - } - -} // class XR_LocStor - - diff --git a/application/models/xmlrpc/index.php b/application/models/xmlrpc/index.php deleted file mode 100644 index 07176fc80..000000000 --- a/application/models/xmlrpc/index.php +++ /dev/null @@ -1,3 +0,0 @@ - - *
  • token : string, put token returned by appropriate - * XMLRPC call
  • - * - * - * On success, returns HTTP return code 200. - * - * On errors, returns HTTP return code >200 - * The possible error codes are: - *
      - *
    • 400 - Incorrect parameters passed to method
    • - *
    • 403 - Access denied
    • - *
    • 500 - Application error
    • - *
    - * - * @see XR_LocStor - * @package Airtime - * @subpackage storageServer - */ - -define('USE_FLOCK', TRUE); - -require_once(dirname(__FILE__).'/../../conf.php'); -require_once('DB.php'); -require_once(dirname(__FILE__).'/../LocStor.php'); - -PEAR::setErrorHandling(PEAR_ERROR_RETURN); -$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE); -$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); -$gb = new LocStor(); - -function http_error($code, $err) -{ - header("HTTP/1.1 $code"); - header("Content-type: text/plain; charset=UTF-8"); - echo "$err\r\n"; - flush(); - exit; -} - -if (preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['token'])) { - $token = $_REQUEST['token']; -} else { - http_error(400, "Error on token parameter. ({$_REQUEST['token']})"); -} - -$tc = BasicStor::bsCheckToken($token, 'put'); -if (PEAR::isError($tc)) { - http_error(500, $ex->getMessage()); -} -if (!$tc) { - http_error(403, "put.php: Token not valid ($token)."); -} - -header("Content-type: text/plain"); - -$destfile = $CC_CONFIG['accessDir']."/{$token}"; - -/* PUT data comes in on the input stream */ -$putdata = @fopen("php://input", "r") or - http_error(500, "put.php: Can't read input"); - -/* Open a file for writing */ -$fp = @fopen($destfile, "ab") or - http_error(500, "put.php: Can't write to destination file (token=$token)"); - -if ( USE_FLOCK ) { - // lock the file - $lockres = flock($fp,LOCK_EX+LOCK_NB); - if ($lockres !== TRUE) { - http_error(409, "put.php: file locked (token=$token)"); - } -} - -/* Read the data 1 KB at a time and write to the file */ -while ($data = fread($putdata, 1024)){ - fwrite($fp, $data); -} - -if ( USE_FLOCK ) { - // unlock the file - flock($fp,LOCK_UN); -} - -/* Close the streams */ -fclose($fp); -fclose($putdata); - -header("HTTP/1.1 200"); - diff --git a/application/models/xmlrpc/schedulerPhpClient.php b/application/models/xmlrpc/schedulerPhpClient.php deleted file mode 100644 index c591f5bbd..000000000 --- a/application/models/xmlrpc/schedulerPhpClient.php +++ /dev/null @@ -1,510 +0,0 @@ - - *
  • m
  • full method name (include optional prefix) - *
  • p
  • array of input parameter names - *
  • t
  • array of input parameter types - *
  • r
  • array of result element names (not used there at present) - *
  • e
  • array of error codes/messages (not used there at present) - * - */ -$mdefs = array( - "listMethods" => array('m'=>"system.listMethods", 'p'=>NULL, 't'=>NULL), - "AddAudioClipToPlaylistMethod" => array( - 'm'=>'addAudioClipToPlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'audioClipId'/*string*/, 'relativeOffset'/*int*/, 'clipStart'/*int*/, 'clipEnd'/*int*/, 'clipLength'/*int*/), - 't'=>array('string', 'string', 'string', 'int', 'int', 'int', 'int'), - 'r'=>array('playlistElementId'/*string*/), - 'e'=>array( - '301'=>'invalid argument format', - '302'=>'missing playlist ID argument', - '303'=>'missing audio clip ID argument', - '304'=>'missing relative offset argument', - '305'=>'playlist not found', - '306'=>'playlist has not been opened for editing', - '307'=>'audio clip does not exist', - '308'=>'two audio clips at the same relative offset', - '320'=>'missing session ID argument', - ) - ), - "CreatePlaylistMethod" => array( - 'm'=>'createPlaylist', - 'p'=>array('sessionId'/*string*/), - 't'=>array('string'), - 'r'=>array('playlist'/*string*/), - 'e'=>array( - '201'=>'invalid argument format', - '202'=>'could not create playlist', - '220'=>'missing session ID argument', - ) - ), - "DeletePlaylistMethod" => array( - 'm'=>'deletePlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array(), - 'e'=>array( - '901'=>'invalid argument format', - '902'=>'missing playlist ID argument', - '903'=>'playlist not found', - '904'=>'playlist is locked', - '905'=>'playlist could not be deleted', - '920'=>'missing session ID argument', - ) - ), - "DisplayAudioClipMethod" => array( - 'm'=>'displayAudioClip', - 'p'=>array('sessionId'/*string*/, 'audioClipId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array('audioClip'/*string*/), - 'e'=>array( - '601'=>'invalid argument format', - '602'=>'argument is not an audio clip ID', - '603'=>'audio clip not found', - '620'=>'missing session ID argument', - ) - ), - "DisplayAudioClipsMethod" => array( - 'm'=>'displayAudioClips', - 'p'=>array('sessionId'/*string*/), - 't'=>array('string'), - 'r'=>array(array('audioClip'/*string*/)), - 'e'=>array( - '1801'=>'invalid argument format', - '1802'=>'XML-RPC error', - '1820'=>'missing session ID argument', - ) - ), - "DisplayPlaylistMethod" => array( - 'm'=>'displayPlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array('playlist'/*string*/), - 'e'=>array( - '1001'=>'invalid argument format', - '1002'=>'argument is not a playlist ID', - '1003'=>'playlist not found', - '1020'=>'missing session ID argument', - ) - ), - "DisplayPlaylistsMethod" => array( - 'm'=>'displayPlaylists', - 'p'=>array('sessionId'/*string*/), - 't'=>array('string'), - 'r'=>array(array('playlist'/*string*/)), - 'e'=>array( - '1701'=>'invalid argument format', - '1702'=>'XML-RPC error', - '1720'=>'missing session ID argument', - ) - ), - "DisplayScheduleMethod" => array( - 'm'=>'displaySchedule', - 'p'=>array('sessionId'/*string*/, 'from'/*datetime*/, 'to'/*datetime*/), - 't'=>array('string', 'dateTime.iso8601', 'dateTime.iso8601'), - 'r'=>array(array('id'/*int*/, 'playlistId'/*string*/, 'start'/*datetime*/, 'end'/*datetime*/)), - 'e'=>array( - '1101'=>'invalid argument format', - '1102'=>"missing or invalid 'from' argument", - '1103'=>"missing or invalid 'to' argument", - '1120'=>'missing session ID argument', - ) - ), - "GeneratePlayReportMethod" => array( - 'm'=>'generatePlayReport', - 'p'=>array('sessionId'/*string*/, 'from'/*datetime*/, 'to'/*datetime*/), - 't'=>array('string', 'dateTime.iso8601', 'dateTime.iso8601'), - 'r'=>array(array('audioClipId'/*string*/, 'timestamp'/*datetime*/)), - 'e'=>array( - '1501'=>'invalid argument format', - '1502'=>"missing or invalid 'from' argument", - '1503'=>"missing or invalid 'to' argument", - '1520'=>'missing session ID argument', - ) - ), - "GetSchedulerTimeMethod" => array( - 'm'=>'getSchedulerTime', - 'p'=>array(), - 't'=>array(), - 'r'=>array('schedulerTime'/*datetime*/), - 'e'=>array( -) - ), - "GetVersionMethod" => array( - 'm'=>'getVersion', - 'p'=>array(), - 't'=>array(), - 'r'=>array('version'/*string*/), - 'e'=>array() - ), - "LoginMethod" => array( - 'm'=>'login', - 'p'=>array('login'/*string*/, 'password'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array('sessionId'/*string*/), - 'e'=>array( - '2001'=>'invalid argument format', - '2002'=>'missing login argument', - '2003'=>'missing password argument', - '2004'=>'the authentication server reported an error', - ) - ), - "LogoutMethod" => array( - 'm'=>'logout', - 'p'=>array('sessionId'/*string*/), - 't'=>array('string'), - 'r'=>array(), - 'e'=>array( - '2101'=>'invalid argument format', - '2120'=>'missing session ID argument', - '2104'=>'the authentication server reported an error', - ) - ), - "OpenPlaylistForEditingMethod" => array( - 'm'=>'openPlaylistForEditing', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array('playlist'/*string*/), - 'e'=>array( - '101'=>'invalid argument format', - '102'=>'argument is not a playlist ID', - '104'=>'could not open playlist for editing', - '120'=>'missing session ID argument', - ) - ), - "RemoveAudioClipFromPlaylistMethod" => array( - 'm'=>'removeAudioClipFromPlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playlistElementId'/*string*/), - 't'=>array('string', 'string', 'string'), - 'r'=>array(), - 'e'=>array( - '401'=>'invalid argument format', - '402'=>'missing playlist ID argument', - '403'=>'missing relative offset argument', - '404'=>'playlist does not exist', - '405'=>'playlist has not been opened for editing', - '406'=>'no audio clip at the specified relative offset', - '420'=>'missing session ID argument', - ) - ), - "RemoveFromScheduleMethod" => array( - 'm'=>'removeFromSchedule', - 'p'=>array('sessionId'/*string*/, 'scheduleEntryId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array(), - 'e'=>array( - '1201'=>'invalid argument format', - '1202'=>'missing schedule entry ID argument', - '1203'=>'schedule entry not found', - '1220'=>'missing session ID argument', - ) - ), - "RescheduleMethod" => array( - 'm'=>'reschedule', - 'p'=>array('sessionId'/*string*/, 'scheduleEntryId'/*string*/, 'playtime'/*datetime*/), - 't'=>array('string', 'string', 'dateTime.iso8601'), - 'r'=>array(), - 'e'=>array( - '1301'=>'invalid argument format', - '1302'=>'missing schedule entry ID argument', - '1303'=>'missing playtime argument', - '1304'=>'schedule entry not found', - '1305'=>'could not reschedule entry', - '1320'=>'missing session ID argument', - ) - ), -// "ResetStorageMethod" => array( -// 'm'=>'resetStorage', -// 'p'=>array(), -// 't'=>array(), -// 'r'=>array(), -// 'e'=>array('3001'=>'storage client reported an error'), -// ), - "RevertEditedPlaylistMethod" => array( - 'm'=>'revertEditedPlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array(), - 'e'=>array( - '801'=>'invalid argument format', - '802'=>'argument is not a playlist ID', - '803'=>'playlist not found', - '804'=>'could not revert playlist', - '820'=>'missing session ID argument', - ) - ), - "SavePlaylistMethod" => array( - 'm'=>'savePlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array(), - 'e'=>array( - '701'=>'invalid argument format', - '702'=>'argument is not a playlist ID', - '703'=>'playlist not found', - '705'=>'could not save playlist', - '720'=>'missing session ID argument', - ) - ), - "UpdateFadeInFadeOutMethod" => array( - 'm'=>'updateFadeInFadeOut', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playlistElementId'/*string*/, 'fadeIn'/*int*/, 'fadeOut'/*int*/), - 't'=>array('string', 'string', 'string', 'int', 'int'), - 'r'=>array(), - 'e'=>array( - '1601'=>'invalid argument format', - '1602'=>'missing playlist ID argument', - '1603'=>'missing playlist element ID argument', - '1604'=>'missing fade in argument', - '1605'=>'missing fade out argument', - '1606'=>'playlist does not exist', - '1607'=>'playlist has not been opened for editing', - '1608'=>'error executing setFadeInfo() method', - '1620'=>'missing session ID argument', - ) - ), - "UploadPlaylistMethod" => array( - 'm'=>'uploadPlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playtime'/*datetime*/), - 't'=>array('string', 'string', 'dateTime.iso8601'), - 'r'=>array('scheduleEntryId'/*string*/), - 'e'=>array( - '1401'=>'invalid argument format', - '1402'=>'missing playlist ID argument', - '1403'=>'missing playtime argument', - '1404'=>'playlist not found', - '1405'=>'timeframe not available', - '1406'=>'could not schedule playlist', - '1420'=>'missing session ID argument', - ) - ), - "ValidatePlaylistMethod" => array( - 'm'=>'validatePlaylist', - 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array('valid'/*bool*/), - 'e'=>array( - '501'=>'invalid argument format', - '502'=>'missing playlist ID argument', - '503'=>'playlist does not exist', - '504'=>'playlist has not been opened for editing', - '520'=>'missing session ID argument', - ) - ), - "LoginGB" => array( - 'm'=>'locstor.login', - 'p'=>array('login'/*string*/, 'pass'/*string*/), - 't'=>array('string', 'string'), - 'r'=>array('sessid'/*string*/), - 'e'=>array( - '2001'=>'invalid argument format', - '2002'=>'missing login argument', - '2003'=>'missing password argument', - '2004'=>'the authentication server reported an error', - ) - ), - "LogoutGB" => array( - 'm'=>'locstor.logout', - 'p'=>array('sessid'/*string*/), - 't'=>array('string'), - 'r'=>array('status'/*boolean*/), - 'e'=>array( - '2001'=>'invalid argument format', - '2002'=>'missing login argument', - '2003'=>'missing password argument', - '2004'=>'the authentication server reported an error', - ) - ), -); - -/* ======================================================== class definitions */ - -class SchedulerPhpClient { - /** - * Array with methods description - * @var array - */ - private $mdefs = array(); - - /** - * XMLRPC client object reference - */ - private $client = NULL; - - /** - * Verbosity flag - */ - private $verbose = FALSE; - - /** - * XMLRPC debug flag - */ - private $debug = 0; - - /** - * 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($mdefs, $debug=0, $verbose=FALSE) - { - global $CC_DBC, $CC_CONFIG; - $this->mdefs = $mdefs; - $this->debug = $debug; - $this->verbose = $verbose; - $confPrefix = "scheduler"; - //$confPrefix = "storage"; - $serverPath = - "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"; - } - $url = parse_url($serverPath); - $this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']); - } - - - /** - * Factory, create object instance - * - * In fact it doesn't create instance of SchedulerPhpClient, but - * dynamically extend this class with set of methods based on $mdefs array - * (using eval function) and instantiate resulting class - * SchedulerPhpClientCore instead. - * Each new method in this subclass accepts parameters according to $mdefs - * array, call wrapper callMethod(methodname, parameters) and return its - * result. - * - * @param array $mdefs - * hash array with methods description - * @param int $debug - * XMLRPC debug flag - * @param boolean $verbose - * verbosity flag - * @return SchedulerPhpClientCore - */ - function &factory($mdefs, $debug=0, $verbose=FALSE) - { - global $CC_DBC, $CC_CONFIG; - $f = ''; - foreach ($mdefs as $fn => $farr) { - $f .= - ' function '.$fn.'(){'."\n". - ' $pars = func_get_args();'."\n". - ' $r = $this->callMethod("'.$fn.'", $pars);'."\n". - ' return $r;'."\n". - ' }'."\n"; - } - $e = - "class SchedulerPhpClientCore extends SchedulerPhpClient{\n". - "$f\n". - "}\n"; -# echo $e; - if (FALSE === eval($e)) { - return $CC_DBC->raiseError("Eval failed"); - } - $spc = new SchedulerPhpClientCore($mdefs, $debug, $verbose); - return $spc; - } - - - /** - * XMLRPC methods wrapper - * Encode XMLRPC request message, send it, receive and decode response. - * - * @param string $method - * method name - * @param array $gettedPars - * returned by func_get_args() in called method - * @return array - * PHP hash with response - */ - function callMethod($method, $gettedPars) - { - $parr = array(); - $XML_RPC_val = new XML_RPC_Value; - foreach ($this->mdefs[$method]['p'] as $i => $p) { - $parr[$p] = new XML_RPC_Value; - $parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]); - } - $XML_RPC_val->addStruct($parr); - $fullmethod = $this->mdefs[$method]['m']; - $msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val)); - if ($this->verbose) { - echo "parr:\n"; - var_dump($parr); - echo "message:\n"; - echo $msg->serialize()."\n"; - } - $this->client->setDebug($this->debug); - $res = $this->client->send($msg); - if ($res->faultCode() > 0) { - return PEAR::raiseError( - "SchedulerPhpClient::$method:".$res->faultString()." ". - $res->faultCode()."\n", $res->faultCode(), - PEAR_ERROR_RETURN - ); - } - if ($this->verbose) { - echo "result:\n"; - echo $res->serialize(); - } - $val = $res->value(); - $resp = XML_RPC_decode($res->value()); - return $resp; - } - -} // class SchedulerPhpClient - -/* ======================================================== class definitions */ - -/** - * Example of use: - * - * / - - -// db object handling: -$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($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: -// (for testing on storageServer XMLRPC I've changes confPrefix in -// SchedulerPhpClient constructor from 'scheduler' to 'storage' value) -#$r = $spc->LoginGB('root', 'q'); var_dump($r); -#$r = $spc->LogoutGB(''); var_dump($r); - -#$r = $spc->DisplayScheduleMethod($this->Base->sessid, '2005-01-01 00:00:00.000000', '2005-02-01 00:00:00.000000'); var_dump($r); -#$r = $spc->DisplayScheduleMethod('dummySessionId2-1681692777', '2005-01-01 00:00:00.000000', '2005-02-01 00:00:00.000000'); var_dump($r); -$r = $spc->DisplayScheduleMethod($this->Base->sessid, '20040101T00:00:00', '20050401T00:00:00'); var_dump($r); -#$r = $spc->LoginMethod('root', 'q'); var_dump($r); -#$r = $spc->LogoutMethod('dummySessionId3-1714636915'); var_dump($r); -#$r = $spc->listMethods(); var_dump($r); -#$r = $spc->GetSchedulerTimeMethod(); var_dump($r); -================= */ - diff --git a/application/models/xmlrpc/simpleGet.php b/application/models/xmlrpc/simpleGet.php deleted file mode 100644 index 19b723605..000000000 --- a/application/models/xmlrpc/simpleGet.php +++ /dev/null @@ -1,127 +0,0 @@ - - *
  • sessid : string, session ID
  • - *
  • id : string, global unique ID of requested file
  • - * - * - * On success, returns HTTP return code 200 and requested file. - * - * On errors, returns HTTP return code >200 - * The possible error codes are: - *
      - *
    • 400 - Incorrect parameters passed to method
    • - *
    • 403 - Access denied
    • - *
    • 404 - File not found
    • - *
    • 500 - Application error
    • - *
    - * - */ - -require_once(dirname(__FILE__).'/../../conf.php'); -require_once('DB.php'); -require_once(dirname(__FILE__).'/../LocStor.php'); -require_once(dirname(__FILE__).'/../MetaData.php'); - -$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE); -$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN); -$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); - -$locStor = new LocStor(); - -function http_error($code, $err) -{ - header("HTTP/1.1 $code"); - header("Content-type: text/plain; charset=UTF-8"); - echo "$err\r\n"; - exit; -} - -/** - * This function encodes an filename to - * be transferred via HTTP header. - * - * @param string $p_string utf8 filename - * @return string HTTP header encoded filename - */ -function sg_2hexstring($p_string) -{ - for ($x=0; $x < strlen($p_string); $x++) { - $return .= '%' . bin2hex($p_string[$x]); - } - return $return; -} - -// parameter checking: -if (preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])) { - $sessid = $_REQUEST['sessid']; -} else { - http_error(400, "Error on sessid parameter. ({$_REQUEST['sessid']})"); -} -if (preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])) { - $gunid = $_REQUEST['id']; -} else { - http_error(400, "Error on id parameter. ({$_REQUEST['id']})"); -} - -// stored file recall: -$ac = StoredFile::RecallByGunid($gunid); -if (PEAR::isError($ac)) { - switch ($ac->getCode()) { - case GBERR_DENY: - http_error(403, "403 ".$ac->getMessage()); - case GBERR_FILENEX: - case GBERR_FOBJNEX: - http_error(404, "404 File not found"); - default: - http_error(500, "500 ".$ac->getMessage()); - } -} -$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 = BasicStor::GetObjType($lid); -if (PEAR::isError($ftype)) { - http_error(500, $ftype->getMessage()); -} -switch ($ftype) { - case "audioclip": - $realFname = $ac->getRealFileName(); - $mime = $ac->getMime(); - $md = new MetaData($ac->getGunId(), null); - $fileName = $md->getMetadataValue('dc:title').'.'.$ac->getFileExtension(); - header("Content-type: $mime"); - header("Content-length: ".filesize($realFname)); - header("Content-Disposition: attachment; filename*=".sg_2hexstring($fileName).";"); - readfile($realFname); - break; - case "webstream": - $url = $locStor->bsGetMetadataValue($lid, 'ls:url'); - if (empty($url)) { - http_error(500, "Unable to get ls:url value"); - } - $txt = "Location: $url"; - header($txt); - // echo "$txt\n"; - break; - case "playlist"; - // $md = $locStor->bsGetMetadata($ac->getId(), $sessid); - $md = $locStor->getAudioClip($sessid, $gunid); - // header("Content-type: text/xml"); - header("Content-type: application/smil"); - echo $md; - break; - default: - // var_dump($ftype); - http_error(500, "500 Unknown ftype ($ftype)"); -} diff --git a/application/models/xmlrpc/urldecode b/application/models/xmlrpc/urldecode deleted file mode 100755 index 172c8f73c..000000000 --- a/application/models/xmlrpc/urldecode +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/php -q - \ No newline at end of file diff --git a/application/models/xmlrpc/xrLocStor.php b/application/models/xmlrpc/xrLocStor.php deleted file mode 100644 index 5f5b55040..000000000 --- a/application/models/xmlrpc/xrLocStor.php +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - -faultCode -804 - - -faultString -"); -ini_set("error_append_string", " - - - - -"); -header("Content-type: text/xml"); - -/* ================================================================= includes */ -require_once(dirname(__FILE__).'/../../conf.php'); -require_once('DB.php'); -require_once("XML/RPC/Server.php"); -require_once('XR_LocStor.php'); - -/* ============================================ setting default error handler */ -function errHndl($errno, $errmsg, $filename, $linenum, $vars) -{ - switch ($errno) { - case E_WARNING: - case E_NOTICE: - case E_USER_WARNING: - case E_USER_NOTICE: - return; - break; - default: - $xr = new XML_RPC_Response(0, 805, - htmlspecialchars("ERROR:xrLocStor: $errno $errmsg ($filename:$linenum)")); - header("Content-type: text/xml"); - echo $xr->serialize(); - exit($errno); - } -} -$old_error_handler = set_error_handler("errHndl", E_ALL); - -/* ============================================================= runable code */ -$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); -} -$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN); -$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); - -$locStor = new XR_LocStor(); - -$methods = array( - 'test' => 'Tests toupper and checks sessid, params: '. - 'teststring, sessid.', - 'getVersion' => 'Get version of Airtime.', -// 'authenticate' => 'Checks authentication.', - 'login' => 'Login to storage.', - 'logout' => 'Logout from storage.', - 'existsAudioClip' => 'Checks if an audio clip with the specified '. - 'id is stored in local storage.', - 'storeAudioClipOpen' => 'Open channel to store a new audio clip '. - 'or replace an existing one.', - 'storeAudioClipClose' => 'Close channel to store a new audio clip'. - ' or replace an existing one.', - 'downloadRawAudioDataOpen'=> 'Create and return downloadable URL'. - 'for audio file', - 'downloadRawAudioDataClose'=>'Discard downloadable URL for audio file', - 'downloadMetadataOpen' => 'Create and return downloadable URL'. - 'for metadata', - 'downloadMetadataClose' => 'Discard downloadable URL for metadata', - 'openPut' => 'openPut', - 'closePut' => 'closePut', - 'deleteAudioClip' => 'Delete an existing Audio clip.', - 'updateAudioClipMetadata' => 'Update the metadata of an Audio clip '. - 'stored in Local storage.', - 'searchMetadata' => 'Search through the metadata of stored '. - 'files, return all matching clip ids.', - 'browseCategory' =>'Return values of specified metadata category.', - 'accessRawAudioData' => 'Get access to raw audio data.', - 'releaseRawAudioData' => 'Release access to raw audio data.', - 'getAudioClip' => 'Return the contents of an Audio clip.', -// 'resetStorage' => 'Reset storageServer for debugging.', - 'storeWebstream' => 'Store audio stream identified by URL', - - 'createPlaylist' => 'Create a new Playlist metafile.', - 'editPlaylist' => 'Open a Playlist metafile for editing.', - 'savePlaylist' => 'Save a Playlist metafile.', - 'revertEditedPlaylist' => 'RollBack playlist changes to the locked state.', - 'deletePlaylist' => 'Delete a Playlist metafile.', - 'accessPlaylist' => 'Open readable URL to a Playlist metafile.', - 'releasePlaylist' => 'Release readable URL from accessPlaylist.', - 'existsPlaylist' => 'Check whether a Playlist exists.', - 'playlistIsAvailable' => 'Check whether a Playlist is available '. - 'for editing.', - 'exportPlaylistOpen' => 'Create a tarfile with playlist export.', - 'exportPlaylistClose' => 'Close playlist export.', - 'importPlaylistOpen' => 'Open writable handle for playlist import.', - 'importPlaylistClose' => 'Close import-handle and import playlist.', - - 'renderPlaylistToFileOpen' => 'Render playlist to ogg file (open handle)', - 'renderPlaylistToFileCheck' => 'Render playlist to ogg file (check results)', - 'renderPlaylistToFileClose' => 'Render playlist to ogg file (close handle)', - - 'renderPlaylistToStorageOpen' => 'Render playlist to storage media clip (open handle)', - 'renderPlaylistToStorageCheck' => 'Render playlist to storage media clip (check results)', - - 'renderPlaylistToRSSOpen' => 'Render playlist to RSS file (open handle)', - 'renderPlaylistToRSSCheck' => 'Render playlist to RSS file (check results)', - 'renderPlaylistToRSSClose' => 'Render playlist to RSS file (close handle)', - - 'createBackupOpen' => 'Create backup of storage (open handle)', - 'createBackupCheck' => 'Create backup of storage (check results)', - 'createBackupClose' => 'Create backup of storage (close handle)', - - 'restoreBackupOpen' => 'Restore a backup file (open handle)', - 'restoreBackupClosePut' => 'Restore a backup file (close PUT handle)', - 'restoreBackupCheck' => 'Restore a backup file (check results)', - 'restoreBackupClose' => 'Restore a backup file (close handle)', - - 'loadPref' => 'Load user preference value.', - 'savePref' => 'Save user preference value.', - 'delPref' => 'Delete user preference record.', - 'loadGroupPref' => 'Read group preference record.', - 'saveGroupPref' => 'Delete user preference record.', - - 'getTransportInfo' => 'Common "check" method and info getter for transports', - 'turnOnOffTransports' => 'Turn transports on/off, optionaly return current state', - 'doTransportAction' => 'Pause, resume or cancel transport', - 'uploadFile2Hub' => 'Open async file transfer from local storageServer to network hub', - 'getHubInitiatedTransfers' => 'Get list of prepared transfers initiated by hub', - 'startHubInitiatedTransfer' => 'Start of download initiated by hub', - 'upload2Hub' => 'Start upload of audioclip or playlist from local storageServer to hub', - 'downloadFromHub' => 'Start download of audioclip or playlist from hub to local storageServer', -// 'globalSearch' => 'Start search job on network hub', -// 'getSearchResults' => 'Get results from search job on network hub', - - 'uploadOpen' => 'Open file-layer upload', - 'uploadCheck' => 'Check the checksum of uploaded file', - 'uploadClose' => 'Close file-layer upload', - 'downloadOpen' => 'Open file-layer download', -// 'downloadCheck' => 'Check the checksum of downloaded file', - 'downloadClose' => 'Close file-layer download', - 'prepareHubInitiatedTransfer' => 'Prepare hub initiated transfer', - 'listHubInitiatedTransfers' => 'List hub initiated transfers', - 'setHubInitiatedTransfer' => 'Set state of hub initiated transfers', - 'ping' => 'Echo request', -); - -$defs = array(); -foreach ($methods as $method => $description) { - $defs["locstor.$method"] = array( - "function" => array(&$locStor, "xr_$method"), - // NOTE: the way this signature is set up, every function must take at least one parameter! - "signature" => array( - array($GLOBALS['XML_RPC_Struct'], $GLOBALS['XML_RPC_Struct']) - ), - "docstring" => $description - ); -} - -$s = new XML_RPC_Server($defs); - - diff --git a/application/models/xmlrpc/xr_cli_test.php b/application/models/xmlrpc/xr_cli_test.php deleted file mode 100644 index 47f890ba5..000000000 --- a/application/models/xmlrpc/xr_cli_test.php +++ /dev/null @@ -1,367 +0,0 @@ -debug = 1; - echo "ServerPath: $serverPath\n"; - echo "Host: {$url['host']}, path: {$url['path']}\n"; - echo "Method: $method\n"; - echo "Parameters:\n"; - //var_dump($pars); -} - -$infos = array( - "listMethods" => array('m'=>"system.listMethods", 'p'=>NULL), - "methodHelp" => array('m'=>"system.methodHelp", 'p'=>0), - "methodSignature" => array('m'=>"system.methodSignature", 'p'=>0), - "test" => array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')), - "ping" => array('m'=>"locstor.ping", 'p'=>array("par")), - "getVersion" => array('m'=>"locstor.getVersion", 'p'=>array("str"), 'r'=>'version'), - "authenticate" => array('m'=>"locstor.authenticate", 'p'=>array('login', 'pass'), 'r'=>'authenticate'), - "login" => array('m'=>"locstor.login", 'p'=>array('login', 'pass'), 'r'=>'sessid'), - "logout" => array('m'=>"locstor.logout", 'p'=>array('sessid'), 'r'=>'status'), - "storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen", - 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'), - 'r'=>array('url', 'token') - ), - "storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose", - 'p'=>array('sessid', 'token'), 'r'=>'gunid'), - "accessRawAudioData" => array('m'=>"locstor.accessRawAudioData", - 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), - "releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData", - 'p'=>array('token'), 'r'=>'status'), - "downloadRawAudioDataOpen" => - array('m'=>"locstor.downloadRawAudioDataOpen", - 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), - "downloadRawAudioDataClose" => - array('m'=>"locstor.downloadRawAudioDataClose", - 'p'=>array('sessid', 'token'), 'r'=>'gunid'), - "downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen", - 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), - "downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose", - 'p'=>array('sessid', 'token'), 'r'=>'gunid'), - - "deleteAudioClip" => - array('m'=>"locstor.deleteAudioClip", - 'p'=>array('sessid', 'gunid', 'forced'), 'r'=>'status'), - "existsAudioClip" => array('m'=>"locstor.existsAudioClip", - 'p'=>array('sessid', 'gunid'), 'r'=>'exists'), - "getAudioClip" => array('m'=>"locstor.getAudioClip", - 'p'=>array('sessid', 'gunid'), 'r'=>'metadata'), - "updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata", - 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), - "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), - "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL), -// "resetStorage" => array('m'=>"locstor.resetStorage", -// 'p'=>array()), -# 'p'=>array('loadSampleData', 'invalidateSessionIds')), - "storeWebstream" => array('m'=>"locstor.storeWebstream", - 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'), - 'r'=>array('gunid') - ), - - "createPlaylist" => array('m'=>"locstor.createPlaylist", - 'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'), - "editPlaylist" => array('m'=>"locstor.editPlaylist", - 'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')), - "savePlaylist" => array('m'=>"locstor.savePlaylist", - 'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'), - "revertEditedPlaylist" => array('m'=>"locstor.revertEditedPlaylist", - 'p'=>array('sessid', 'token'), 'r'=>'plid'), - "deletePlaylist" => array('m'=>"locstor.deletePlaylist", - 'p'=>array('sessid', 'plid', 'forced'), 'r'=>'status'), - "accessPlaylist" => array('m'=>"locstor.accessPlaylist", - 'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')), - "releasePlaylist" => array('m'=>"locstor.releasePlaylist", - 'p'=>array('token'), 'r'=>'plid'), - "existsPlaylist" => array('m'=>"locstor.existsPlaylist", - 'p'=>array('sessid', 'plid'), 'r'=>'exists'), - "playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable", - 'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')), - - "exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen", - 'p'=>array('sessid', 'plids', 'type', 'standalone'), - 'r'=>array('url', 'token')), - "exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose", - 'p'=>array('token'), 'r'=>array('status')), - "importPlaylistOpen" => array('m'=>"locstor.importPlaylistOpen", - 'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')), - "importPlaylistClose" => array('m'=>"locstor.importPlaylistClose", - 'p'=>array('token'), 'r'=>array('gunid')), - - "renderPlaylistToFileOpen" => array('m'=>"locstor.renderPlaylistToFileOpen", - 'p'=>array('sessid', 'plid'), - 'r'=>array('token')), - "renderPlaylistToFileCheck" => array('m'=>"locstor.renderPlaylistToFileCheck", - 'p'=>array('token'), 'r'=>array('status', 'url')), - "renderPlaylistToFileClose" => array('m'=>"locstor.renderPlaylistToFileClose", - 'p'=>array('token'), 'r'=>array('status')), - "renderPlaylistToStorageOpen" => array('m'=>"locstor.renderPlaylistToStorageOpen", - 'p'=>array('sessid', 'plid'), - 'r'=>array('token')), - "renderPlaylistToStorageCheck" => array('m'=>"locstor.renderPlaylistToStorageCheck", - 'p'=>array('token'), 'r'=>array('status', 'gunid')), - "renderPlaylistToRSSOpen" => array('m'=>"locstor.renderPlaylistToRSSOpen", - 'p'=>array('sessid', 'plid'), - 'r'=>array('token')), - "renderPlaylistToRSSCheck" => array('m'=>"locstor.renderPlaylistToRSSCheck", - 'p'=>array('token'), 'r'=>array('status', 'url')), - "renderPlaylistToRSSClose" => array('m'=>"locstor.renderPlaylistToRSSClose", - 'p'=>array('token'), 'r'=>array('status')), - - "loadPref" => array('m'=>"locstor.loadPref", - 'p'=>array('sessid', 'key'), 'r'=>'value'), - "savePref" => array('m'=>"locstor.savePref", - 'p'=>array('sessid', 'key', 'value'), 'r'=>'status'), - "delPref" => array('m'=>"locstor.delPref", - 'p'=>array('sessid', 'key'), 'r'=>'status'), - "loadGroupPref" => array('m'=>"locstor.loadGroupPref", - 'p'=>array('sessid', 'group', 'key'), 'r'=>'value'), - "saveGroupPref" => array('m'=>"locstor.saveGroupPref", - 'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'), - - "getTransportInfo" => array('m'=>"locstor.getTransportInfo", - 'p'=>array('trtok'), - 'r'=>array('state', 'realsize', 'expectedsize', 'realsum', 'expectedsum')), - "turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports", - 'p'=>array('sessid', 'onOff'), 'r'=>array('state')), - "doTransportAction" => array('m'=>"locstor.doTransportAction", - 'p'=>array('sessid', 'trtok', 'action'), 'r'=>array('state')), - "uploadFile2Hub" => array('m'=>"locstor.uploadFile2Hub", - 'p'=>array('sessid', 'filePath'), 'r'=>array('trtok')), - "getHubInitiatedTransfers" => array('m'=>"locstor.getHubInitiatedTransfers", - 'p'=>array('sessid'), 'r'=>array()), - "startHubInitiatedTransfer" => array('m'=>"locstor.startHubInitiatedTransfer", - 'p'=>array('trtok'), 'r'=>array()), - "upload2Hub" => array('m'=>"locstor.upload2Hub", - 'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')), - "downloadFromHub" => array('m'=>"locstor.downloadFromHub", - 'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')), -// "globalSearch" => array('m'=>"locstor.globalSearch", -// 'p'=>array('sessid', 'criteria'), 'r'=>array('trtok')), -// "getSearchResults" => array('m'=>"locstor.getSearchResults", -// 'p'=>array('trtok')), - - "createBackupOpen" => array('m'=>"locstor.createBackupOpen", - 'p'=>array('sessid', 'criteria'), 'r'=>array('token')), - "createBackupCheck" => array('m'=>"locstor.createBackupCheck", -# 'p'=>array('token'), 'r'=>array('status', 'url', 'metafile', 'faultString')), - 'p'=>array('token'), 'r'=>array('status', 'url', 'tmpfile')), - "createBackupClose" => array('m'=>"locstor.createBackupClose", - 'p'=>array('token'), 'r'=>array('status')), - "restoreBackupOpen" => array('m'=>"locstor.restoreBackupOpen", - 'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')), - "restoreBackupClosePut" => array('m'=>"locstor.restoreBackupClosePut", - 'p'=>array('sessid', 'token'), 'r'=>array('token')), - "restoreBackupCheck" => array('m'=>"locstor.restoreBackupCheck", - 'p'=>array('token'), 'r'=>array('status', 'faultString')), - "restoreBackupClose" => array('m'=>"locstor.restoreBackupClose", - 'p'=>array('token'), 'r'=>array('status')), - -/* - "uploadToArchive" => array('m'=>"locstor.uploadToArchive", - 'p'=>array('sessid', 'gunid'), 'r'=>'trtok'), - "downloadFromArchive" => array('m'=>"locstor.downloadFromArchive", - 'p'=>array('sessid', 'gunid'), 'r'=>'trtok'), -*/ - - "openPut" => array('m'=>"locstor.openPut", 'p'=>array()), - "closePut" => array('m'=>"locstor.closePut", 'p'=>array()), -); - - -switch ($method) { - case "searchMetadata": -// case "globalSearch": - case "createBackupOpen": - $parr = array( - 'sessid'=>$pars[0], - 'criteria'=>array( - 'filetype'=>'audioclip', - 'operator'=>'and', - 'limit'=> 0, - 'offset'=> 0, - 'conditions'=>array( - array('cat'=>$pars[1], 'op'=>'partial', 'val'=>$pars[2]) - ) - ), - ); - break; - case "browseCategory": - $parr = array( - 'sessid'=>$pars[0], - 'category'=>$pars[1], - 'criteria'=>array( - 'filetype'=>'audioclip', - 'operator'=>'and', - 'limit'=> 0, - 'offset'=> 0, - 'conditions'=>array( - array('cat'=>$pars[2], 'op'=>'partial', 'val'=>$pars[3]) - ) - ), - ); - break; -// case "resetStorage": -// $parr = array( -// 'loadSampleData'=>(boolean)$pars[0], -// 'invalidateSessionIds'=>(boolean)$pars[1], -// ); -// break; - default: - $pinfo = $infos[$method]['p']; - if (is_null($pinfo)) { - $parr = NULL; - } elseif(!is_array($pinfo)) { - $parr = $pars[0]; - #echo "pinfo not null and not array.\n"; exit; - } elseif(count($pinfo) == 0) { - $parr = (object)array(); - } else { - $parr = array(); $i=0; - foreach($pinfo as $it){ - if(isset($pars[$i])) $parr[$it] = $pars[$i]; - $i++; - } - } -} // switch - -$fullmethod = $infos[$method]['m']; -if (is_array($options)) { - $msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($options))); -} else { - $msg = new XML_RPC_Message($fullmethod); -} -//$msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($parr))); - -if ($verbose) { - echo "parr:\n"; - var_dump($parr); - echo "message:\n"; - echo $msg->serialize()."\n"; -} - -#$client->setDebug(1); -$res = $client->send($msg); -if ($res->faultCode() > 0) { - echo "xr_cli_test.php: ".$res->faultString()." ".$res->faultCode()."\n"; -# echo var_export($res); - exit(1); -} - -if ($verbose) { - echo "result:\n"; - echo $res->serialize(); -} - -$resp = XML_RPC_decode($res->value()); -if (isset($infos[$method]['r'])) { - $pom = $infos[$method]['r']; - if (is_array($pom)) { - foreach ($pom as $k => $it) { - $pom[$k] = $resp[$it]; - } - echo join(' ', $pom)."\n"; - } else { - switch ($pom) { - case "status": - case "exists": - echo ($resp[$pom]=='1' ? "TRUE" : "FALSE" )."\n"; - break; - default: - echo "{$resp[$pom]}\n"; - } - } -} else { - switch ($method) { - case "searchMetadata": -// case "getSearchResults": - $acCnt = 0; - $acGunids = array(); - $plCnt = 0; - $plGunids = array(); - $fld = (isset($options['category']) ? $options['category'] : 'gunid' ); - foreach ($resp['results'] as $k => $v) { - if ($v['type']=='audioclip') { - $acCnt++; - $acGunids[] = $v[$fld]; - } - if ($v['type']=='playlist') { - $plCnt++; - $plGunids[] = $v[$fld]; - } - } - echo "AC({$acCnt}): ". - join(", ", $acGunids). - " | PL({$plCnt}): ". - join(", ", $plGunids). - "\n"; - break; - case "browseCategory": - echo "RES({$resp['cnt']}): ". - join(", ", $resp['results']). - "\n"; - break; - default: - print_r($resp); - echo "\n"; - } -} - diff --git a/application/models/xmlrpc/xr_web_test.php b/application/models/xmlrpc/xr_web_test.php deleted file mode 100644 index 34537170c..000000000 --- a/application/models/xmlrpc/xr_web_test.php +++ /dev/null @@ -1,373 +0,0 @@ -'.htmlspecialchars($p_printValue)."\n"; - echo $str; - return $selected; -} // fn camp_html_select_option - - -$serverPath = - "http://{$CC_CONFIG['storageUrlHost']}:{$CC_CONFIG['storageUrlPort']}". - "{$CC_CONFIG['storageUrlPath']}/{$CC_CONFIG['storageXMLRPC']}"; -$serverPath = camp_session_get("storageserver_xmlrpc_path", $serverPath); -$f_selectedMethod = camp_session_get("f_selectedMethod", "listMethods"); -$url = parse_url($serverPath); -$client = new XML_RPC_Client($url['path'], $url['host']); - -$methodDefs = array( - "listMethods" => array('m'=>"system.listMethods", 'p'=>NULL), - "methodHelp" => array('m'=>"system.methodHelp", 'p'=>0), - "methodSignature" => array('m'=>"system.methodSignature", 'p'=>0), - "test" => array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')), - "getVersion" => array('m'=>"locstor.getVersion", 'p'=>array(), 'r'=>'version'), - "authenticate" => array('m'=>"locstor.authenticate", 'p'=>array('login', 'pass'), 'r'=>'authenticate'), - "login" => array('m'=>"locstor.login", 'p'=>array('login', 'pass'), 'r'=>'sessid'), - "logout" => array('m'=>"locstor.logout", 'p'=>array('sessid'), 'r'=>'status'), - "storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen", - 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'), - 'r'=>array('url', 'token') - ), - "storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose", - 'p'=>array('sessid', 'token'), 'r'=>'gunid'), - "accessRawAudioData" => array('m'=>"locstor.accessRawAudioData", - 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), - "releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData", - 'p'=>array('token'), 'r'=>'status'), - "downloadRawAudioDataOpen" => - array('m'=>"locstor.downloadRawAudioDataOpen", - 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), - "downloadRawAudioDataClose" => - array('m'=>"locstor.downloadRawAudioDataClose", - 'p'=>array('sessid', 'token'), 'r'=>'gunid'), - "downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen", - 'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')), - "downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose", - 'p'=>array('sessid', 'token'), 'r'=>'gunid'), - - "deleteAudioClip" => - array('m'=>"locstor.deleteAudioClip", - 'p'=>array('sessid', 'gunid', 'forced'), 'r'=>'status'), - "existsAudioClip" => array('m'=>"locstor.existsAudioClip", - 'p'=>array('sessid', 'gunid'), 'r'=>'exists'), - "getAudioClip" => array('m'=>"locstor.getAudioClip", - 'p'=>array('sessid', 'gunid'), 'r'=>'metadata'), - "updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata", - 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), - "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), - "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL), -// "resetStorage" => array('m'=>"locstor.resetStorage", -// 'p'=>array()), - "storeWebstream" => array('m'=>"locstor.storeWebstream", - 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'), - 'r'=>array('gunid') - ), - - "createPlaylist" => array('m'=>"locstor.createPlaylist", - 'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'), - "editPlaylist" => array('m'=>"locstor.editPlaylist", - 'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')), - "savePlaylist" => array('m'=>"locstor.savePlaylist", - 'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'), - "revertEditedPlaylist" => array('m'=>"locstor.revertEditedPlaylist", - 'p'=>array('sessid', 'token'), 'r'=>'plid'), - "deletePlaylist" => array('m'=>"locstor.deletePlaylist", - 'p'=>array('sessid', 'plid', 'forced'), 'r'=>'status'), - "accessPlaylist" => array('m'=>"locstor.accessPlaylist", - 'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')), - "releasePlaylist" => array('m'=>"locstor.releasePlaylist", - 'p'=>array('token'), 'r'=>'plid'), - "existsPlaylist" => array('m'=>"locstor.existsPlaylist", - 'p'=>array('sessid', 'plid'), 'r'=>'exists'), - "playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable", - 'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')), - - "exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen", - 'p'=>array('sessid', 'plids', 'type', 'standalone'), - 'r'=>array('url', 'token')), - "exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose", - 'p'=>array('token'), 'r'=>array('status')), - "importPlaylistOpen" => array('m'=>"locstor.importPlaylistOpen", - 'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')), - "importPlaylistClose" => array('m'=>"locstor.importPlaylistClose", - 'p'=>array('token'), 'r'=>array('gunid')), - - "renderPlaylistToFileOpen" => array('m'=>"locstor.renderPlaylistToFileOpen", - 'p'=>array('sessid', 'plid'), - 'r'=>array('token')), - "renderPlaylistToFileCheck" => array('m'=>"locstor.renderPlaylistToFileCheck", - 'p'=>array('token'), 'r'=>array('status', 'url')), - "renderPlaylistToFileClose" => array('m'=>"locstor.renderPlaylistToFileClose", - 'p'=>array('token'), 'r'=>array('status')), - "renderPlaylistToStorageOpen" => array('m'=>"locstor.renderPlaylistToStorageOpen", - 'p'=>array('sessid', 'plid'), - 'r'=>array('token')), - "renderPlaylistToStorageCheck" => array('m'=>"locstor.renderPlaylistToStorageCheck", - 'p'=>array('token'), 'r'=>array('status', 'gunid')), - "renderPlaylistToRSSOpen" => array('m'=>"locstor.renderPlaylistToRSSOpen", - 'p'=>array('sessid', 'plid'), - 'r'=>array('token')), - "renderPlaylistToRSSCheck" => array('m'=>"locstor.renderPlaylistToRSSCheck", - 'p'=>array('token'), 'r'=>array('status', 'url')), - "renderPlaylistToRSSClose" => array('m'=>"locstor.renderPlaylistToRSSClose", - 'p'=>array('token'), 'r'=>array('status')), - - "loadPref" => array('m'=>"locstor.loadPref", - 'p'=>array('sessid', 'key'), 'r'=>'value'), - "savePref" => array('m'=>"locstor.savePref", - 'p'=>array('sessid', 'key', 'value'), 'r'=>'status'), - "delPref" => array('m'=>"locstor.delPref", - 'p'=>array('sessid', 'key'), 'r'=>'status'), - "loadGroupPref" => array('m'=>"locstor.loadGroupPref", - 'p'=>array('sessid', 'group', 'key'), 'r'=>'value'), - "saveGroupPref" => array('m'=>"locstor.saveGroupPref", - 'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'), - - "getTransportInfo" => array('m'=>"locstor.getTransportInfo", - 'p'=>array('trtok'), - 'r'=>array('state', 'realsize', 'expectedsize', 'realsum', 'expectedsum')), - "turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports", - 'p'=>array('sessid', 'onOff'), 'r'=>array('state')), - "doTransportAction" => array('m'=>"locstor.doTransportAction", - 'p'=>array('sessid', 'trtok', 'action'), 'r'=>array('state')), - "uploadFile2Hub" => array('m'=>"locstor.uploadFile2Hub", - 'p'=>array('sessid', 'filePath'), 'r'=>array('trtok')), - "getHubInitiatedTransfers" => array('m'=>"locstor.getHubInitiatedTransfers", - 'p'=>array('sessid'), 'r'=>array()), - "startHubInitiatedTransfer" => array('m'=>"locstor.startHubInitiatedTransfer", - 'p'=>array('trtok'), 'r'=>array()), - "upload2Hub" => array('m'=>"locstor.upload2Hub", - 'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')), - "downloadFromHub" => array('m'=>"locstor.downloadFromHub", - 'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')), -// "globalSearch" => array('m'=>"locstor.globalSearch", -// 'p'=>array('sessid', 'criteria'), 'r'=>array('trtok')), -// "getSearchResults" => array('m'=>"locstor.getSearchResults", -// 'p'=>array('trtok')), - - "createBackupOpen" => array('m'=>"locstor.createBackupOpen", - 'p'=>array('sessid', 'criteria'), 'r'=>array('token')), - "createBackupCheck" => array('m'=>"locstor.createBackupCheck", -# 'p'=>array('token'), 'r'=>array('status', 'url', 'metafile', 'faultString')), - 'p'=>array('token'), 'r'=>array('status', 'url', 'tmpfile')), - "createBackupClose" => array('m'=>"locstor.createBackupClose", - 'p'=>array('token'), 'r'=>array('status')), - "restoreBackupOpen" => array('m'=>"locstor.restoreBackupOpen", - 'p'=>array('sessid', 'chsum'), 'r'=>array('url', 'token')), - "restoreBackupClosePut" => array('m'=>"locstor.restoreBackupClosePut", - 'p'=>array('sessid', 'token'), 'r'=>array('token')), - "restoreBackupCheck" => array('m'=>"locstor.restoreBackupCheck", - 'p'=>array('token'), 'r'=>array('status', 'faultString')), - "restoreBackupClose" => array('m'=>"locstor.restoreBackupClose", - 'p'=>array('token'), 'r'=>array('status')), - "openPut" => array('m'=>"locstor.openPut", 'p'=>array()), - "closePut" => array('m'=>"locstor.closePut", 'p'=>array()), -); - -if (isset($_REQUEST['go_button'])) { - // Get the parameters - $methodParams = $methodDefs[$f_selectedMethod]['p']; - foreach ($methodParams as $methodParamName) { - $inputParamName = "param_".$methodParamName; - $xmlParameters[$methodParamName] = $_REQUEST[$inputParamName]; - $_SESSION[$inputParamName] = $_REQUEST[$inputParamName]; - } - - // Create the XML-RPC message - $actualMethod = $methodDefs[$f_selectedMethod]['m']; - $msg = new XML_RPC_Message($actualMethod, array(XML_RPC_encode($xmlParameters))); - $sentMessage = $msg->serialize(); - - // Send it - $sendResult = $client->send($msg); - if ($sendResult->faultCode() > 0) { - $errorMsg = "xr_cli_test.php: ".$sendResult->faultString()." ".$sendResult->faultCode()."\n"; - } else { - // If successful - $xmlResponse = XML_RPC_decode($sendResult->value()); - - // Special case state handling - switch ($f_selectedMethod) { - case "login": - // Remember the login session ID so we can use it to call - // other methods. - $loggedIn = true; - $_SESSION['xmlrpc_session_id'] = $xmlResponse['sessid']; - break; - case "logout": - unset($_SESSION['xmlrpc_session_id']); - break; - case "storeAudioClipOpen": - $_SESSION['xmlrpc_token'] = $xmlResponse['token']; - $_SESSION['xmlrpc_put_url'] = $xmlResponse['url']; - break; - } - - if (isset($methodDefs[$method]['r'])) { - $expectedResult = $methodDefs[$method]['r']; - if (is_array($expectedResult)) { - foreach ($expectedResult as $resultName) { - $actualResults[$resultName] = $xmlResponse[$resultName]; - } - echo join(' ', $actualResults)."\n"; - } else { - switch ($expectedResult) { - case "status": - case "exists": - echo ($xmlResponse[$expectedResult]=='1' ? "TRUE" : "FALSE" )."\n"; - break; - default: - echo "{$xmlResponse[$expectedResult]}\n"; - } - } - } else { - switch ($method) { - case "searchMetadata": -// case "getSearchResults": - $acCnt = 0; - $acGunids = array(); - $plCnt = 0; - $plGunids = array(); - $fld = (isset($options['category']) ? $options['category'] : 'gunid' ); - foreach ($xmlResponse['results'] as $k => $v) { - if ($v['type']=='audioclip') { - $acCnt++; - $acGunids[] = $v[$fld]; - } - if ($v['type']=='playlist') { - $plCnt++; - $plGunids[] = $v[$fld]; - } - } - echo "AC({$acCnt}): ". - join(", ", $acGunids). - " | PL({$plCnt}): ". - join(", ", $plGunids). - "\n"; - break; - case "browseCategory": - echo "RES({$xmlResponse['cnt']}): ". - join(", ", $xmlResponse['results']). - "\n"; - break; - default: - //print_r($xmlResponse); - } - } - } -} -?> - - -
    -StorageServer path :
    -Method: - -
    -Parameters: -"; -} else { - echo ""; - foreach ($methodParams as $methodParamName) { - $value = ""; - if ($methodParamName == "sessid" && isset($_SESSION['xmlrpc_session_id'])) { - $value = $_SESSION['xmlrpc_session_id']; - } elseif ($methodParamName == "token" && isset($_SESSION['xmlrpc_token'])) { - $value = $_SESSION['xmlrpc_token']; - } elseif (isset($_SESSION["param_".$methodParamName])) { - $value = $_SESSION["param_".$methodParamName]; - } - echo ""; - echo ""; ?> - "; -} -?> -
    - - - - -
    "; -} -if (isset($sentMessage)) { - ?> - Sent message:
    - -
    - - Error:
    - -
    - - Response:
    - -
    - - - diff --git a/utils/airtime-backup b/utils/airtime-backup deleted file mode 100755 index 6a225c5e9..000000000 --- a/utils/airtime-backup +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Airtime project. -# http://airtime.sourcefabric.org/ -# -# Airtime is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# Airtime is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Airtime; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- -#------------------------------------------------------------------------------- -# This script creates a tgz archive of the Airtime storage. -# -# To get usage help, try the -h option -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Determine directories, files -#------------------------------------------------------------------------------- - -reldir=`dirname $0` -phpdir=$reldir -mkdir -p $reldir/tmp -tmpmaindir=`cd $reldir/tmp; pwd` -dbxml="db.xml" -datestr=`date '+%Y%m%d%H%M%S'` -xmltar="xmls.tar" -destfile="storage$datestr.tar" - -#------------------------------------------------------------------------------- -# Print the usage information for this script. -#------------------------------------------------------------------------------- -printUsage() -{ - echo "This script creates a tgz archive of the Airtime storage."; - echo "parameters:"; - echo ""; - echo " -d, --destination Destination directory [default:$tmpmaindir]."; - echo " -h, --help Print this message and exit."; - echo ""; -} - -#------------------------------------------------------------------------------- -# Process command line parameters -#------------------------------------------------------------------------------- -CMD=${0##*/} - -opts=$(getopt -o hd: -l help,destinantion: -n $CMD -- "$@") || exit 1 -eval set -- "$opts" -while true; do - case "$1" in - -h|--help) - printUsage; - exit 0;; - -d|--destinantion) - destdir=$2 - shift; shift;; - --) - shift; - break;; - *) - echo "Unrecognized option $1."; - printUsage; - exit 1; - esac -done - -if [ "x$destdir" == "x" ]; then - destdir=$tmpmaindir -fi -destdir=`cd $destdir; pwd` - -#------------------------------------------------------------------------------- -# Do backup -#------------------------------------------------------------------------------- - -tmpdir=`mktemp -d $tmpmaindir/tmp.XXXXXX` - -echo "Backuping to $destdir/$destfile :" -echo "Dumping database ..." -cd $phpdir -php -q airtime_backup.php > $tmpdir/$dbxml -echo "Packaging stored files ..." -cd $phpdir -storpath=`php -q getStorPath.php` -cd $storpath/.. -find stor -name "*.xml" -print | tar cf $tmpdir/$xmltar -T - -find stor ! -name "*.xml" -a -type f -print | tar cf $tmpdir/$destfile -T - -cd $tmpdir -tar rf $xmltar $dbxml --remove-files -echo "Compressing XML part ..." -bzip2 $xmltar -tar rf $destfile $xmltar.bz2 --remove-files -mv $destfile "$destdir" -rmdir $tmpdir - -#------------------------------------------------------------------------------- -# Say goodbye -#------------------------------------------------------------------------------- -echo "done" diff --git a/utils/airtime-backup.php b/utils/airtime-backup.php deleted file mode 100644 index 7a544d3eb..000000000 --- a/utils/airtime-backup.php +++ /dev/null @@ -1,194 +0,0 @@ -setFetchMode(DB_FETCHMODE_ASSOC); -$bs = new BasicStor(); - -$stid = $bs->storId; -#var_dump($stid); exit; -#$farr = $bs->bsListFolder($stid); var_dump($farr); exit; - -function admDumpFolder(&$bs, $fid, $ind='') -{ - // NOTE: need to fix this, removed due to tree removal - // $name = M2tree::GetObjName($fid); - // if (PEAR::isError($name)) { - // echo $name->getMessage(); - // exit; - // } - $media = StoredFile::Recall($fid); - $type = $media->getType(); - $gunid = $media->getGunid(); - $pars = array(); - if ($gunid) { - $pars['id']="$gunid"; - } - $pars['name'] = "$name"; - switch ($type) { - case "audioclip": - return XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'audioClip', - 'attributes'=> $pars, - )); - break; - case "webstream": - return XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'webstream', - 'attributes'=> $pars, - )); - break; - case "playlist": - return XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'playlist', - 'attributes'=> $pars, - )); - break; - default: - return ""; - } -} - -function admDumpGroup(&$bs, $gid, $ind='') -{ - $name = Subjects::GetSubjName($gid); - if (PEAR::isError($name)) { - echo $name->getMessage(); - exit; - } - $isGr = Subjects::IsGroup($gid); - if (PEAR::isError($isGr)) { - echo $isGr->getMessage(); - exit; - } - $pars = array('name'=>"$name"); - $pars['id'] = $gid; - if (!$isGr) { - return XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'member', - 'attributes'=> $pars, - )); - } - $garr = Subjects::ListGroup($gid); - if (PEAR::isError($garr)) { - echo $garr->getMessage(); - exit; - } - $res = ''; - foreach ($garr as $i => $member) { - $fid2 = $member['id']; - $res .= admDumpGroup($bs, $fid2, "$ind "); - } - $tagarr = array( - 'namespace' => NSPACE, - 'localPart' => 'group', - 'attributes'=> $pars, - ); - $prefs = admDumpPrefs($bs, $gid); - if (!is_null($prefs)) { - $res .= $prefs; - } - if ($res) { - $tagarr['content'] = $res; - } - return XML_Util::createTagFromArray($tagarr, $res === ''); - // if (!$res) { - // } else { - // return XML_Util::createTagFromArray(array( - // 'namespace' => NSPACE, - // 'localPart' => 'group', - // 'attributes'=> $pars, - // 'content' => $res, - // ), FALSE); - // } - - } - function admDumpSubjects(&$bs, $ind='') - { - $res =''; - $subjs = Subjects::GetSubjects('id, login, pass, type'); - foreach ($subjs as $i => $member) { - switch ($member['type']) { - case "U": - $prefs = admDumpPrefs($bs, $member['id']); - $pars = array('login'=>"{$member['login']}", 'pass'=>"{$member['pass']}"); - $pars['id'] = $member['id']; - $tagarr = array( - 'namespace' => NSPACE, - 'localPart' => 'user', - 'attributes'=> $pars, - ); - if (!is_null($prefs)) { - $tagarr['content'] = $prefs; - } - $res .= XML_Util::createTagFromArray($tagarr , FALSE); - break; - case "G": - $res .= admDumpGroup($bs, $member['id'], "$ind "); - break; - } - } - # return "$ind\n$res$ind\n"; - return XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'subjects', - 'content'=> $res, - ), FALSE); - } - - function admDumpPrefs(&$bs, $subjid) - { - $res =''; - $pr = new Prefs($bs); - $prefkeys = $pr->readKeys($subjid); - # var_dump($subjid); var_dump($prefkeys); #exit; - foreach ($prefkeys as $i => $prefk) { - $keystr = $prefk['keystr']; - $prefval = $pr->readVal($subjid, $keystr); - $pars = array('name'=>"$keystr", 'val'=>"$prefval"); - $res .= XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'pref', - 'attributes'=> $pars, - )); - } - if (!$res) { - return NULL; - } - return XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'preferences', - 'content'=> $res, - ), FALSE); - } - - $subjects = admDumpSubjects($bs, ' '); - $tree = admDumpFolder($bs, $stid, ' '); - - $res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n"; - $node = XML_Util::createTagFromArray(array( - 'namespace' => NSPACE, - 'localPart' => 'storageServer', - 'content' => "$subjects$tree", - ), FALSE); - $res .= $node; - - $fmt = new XML_Beautifier(); - $res = $fmt->formatString($res); - - #var_export($res); - #var_dump($res); - echo "$res"; diff --git a/utils/airtime-restore b/utils/airtime-restore deleted file mode 100755 index 04e23f1a7..000000000 --- a/utils/airtime-restore +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Airtime project. -# http://airtime.sourcefabric.org/ -# -# Airtime is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# Airtime is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Airtime; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- -#------------------------------------------------------------------------------- -# This script restores the data which was backed up with airtime-backup. -# -# To get usage help, try the -h option -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Determine directories, files -#------------------------------------------------------------------------------- - -reldir=`dirname $0` -phpdir=$reldir -mkdir -p $reldir/tmp -tmpmaindir=`cd $reldir/tmp; pwd` -dbxml="db.xml" -tarfile0="xmls.tar" - -#------------------------------------------------------------------------------- -# Print the usage information for this script. -#------------------------------------------------------------------------------- -printUsage() -{ - echo "This script restores the data which was backed up with airtime-backup." - echo "parameters:"; - echo ""; - echo " -f, --file File with the backed up data, required."; - echo " -h, --help Print this message and exit."; - echo ""; -} - -#------------------------------------------------------------------------------- -# Process command line parameters -#------------------------------------------------------------------------------- -CMD=${0##*/} - -opts=$(getopt -o hf: -l help,file -n $CMD -- "$@") || exit 1 -eval set -- "$opts" -while true; do - case "$1" in - -h|--help) - printUsage; - exit 0;; - -f|--file) - tarfile=$2 - shift; shift;; - --) - shift; - break;; - *) - echo "Unrecognized option $1."; - printUsage; - exit 1; - esac -done - -if [ "x$tarfile" == "x" ]; then - echo "Required parameter file not specified."; - printUsage; - exit 1; -fi - -tfdir=`dirname $tarfile` -tfdir=`cd $tfdir; pwd` -tfbname=`basename $tarfile` -tarfile="$tfdir/$tfbname" - -#------------------------------------------------------------------------------- -# Do restore -#------------------------------------------------------------------------------- - -tmpdir=`mktemp -d $tmpmaindir/tmp.XXXXXX` - -echo "Restoring database from $tarfile ..." -cd $tmpdir -tar xf $tarfile -tar xjf $tarfile0.bz2 -rm -f $tarfile0.bz2 -cd $phpdir -php -q restore.php $tmpdir/$dbxml $tmpdir -rm -rf "$tmpdir/stor" -rm -f $tmpdir/* -rmdir "$tmpdir" - - -#------------------------------------------------------------------------------- -# Say goodbye -#------------------------------------------------------------------------------- -echo "done" diff --git a/utils/restore.php b/utils/restore.php deleted file mode 100644 index 1daf99498..000000000 --- a/utils/restore.php +++ /dev/null @@ -1,257 +0,0 @@ - $el->attrs['name']->val, - 'type' => $el->name, - ); - switch ($res['type']) { - case 'folder': - foreach ($el->children as $i => $o) { - $res['children'][] = ls_restore_processObject($o); - } - break; - default: - $res['gunid'] = $el->attrs['id']->val; - break; - } - return $res; -} - -function ls_restore_checkErr($r, $ln='') -{ - if (PEAR::isError($r)) { - echo "ERROR $ln: ".$r->getMessage()." ".$r->getUserInfo()."\n"; - exit; - } -} - -function ls_restore_restoreObject($obj, /*$parid,*/ $reallyInsert=TRUE){ - global $tmpdir, $bs; - switch ($obj['type']) { - case "audioClip"; - case "webstream"; - case "playlist"; - $gunid = $obj['gunid']; - if (is_null($gunid)) { - break; - } - $gunid3 = substr($gunid, 0, 3); - $mediaFile = "$tmpdir/stor/$gunid3/$gunid"; -# echo "X1 $gunid, $gunid3, $mediaFile\n"; - if (!file_exists($mediaFile)) { - $mediaFile = NULL; - } - $mdataFile = "$tmpdir/stor/$gunid3/$gunid.xml"; - if (!file_exists($mdataFile)) { - $mdataFile = NULL; - } - if ($reallyInsert) { - if (VERBOSE) { - echo " creating file {$obj['name']} ...\n"; - } - $values = array( - "filename" => $obj['name'], - "filepath" => $mediaFile, - "metadata" => $mdataFile, - "gunid" => $obj['gunid'], - "filetype" => strtolower($obj['type']) - ); - $r = StoredFile::Insert($values); - ls_restore_checkErr($r, __LINE__); - } - break; - } -} - -/* =============================================================== processing */ - -PEAR::setErrorHandling(PEAR_ERROR_RETURN); -$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]); -$tmpdir = $argv[2]; - -require_once("$STORAGE_SERVER_PATH/var/XmlParser.php"); -$parser = new XmlParser($dbxml); -if ($parser->isError()) { - return PEAR::raiseError( - "MetaData::parse: ".$parser->getError() - ); -} -$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 = $el->children; - break; -// case "folder": -// if ($tree !== FALSE) { -// echo "ERROR: unexpected folder element\n"; -// } -// $tree = ls_restore_processObject($el); -// break; - default: - echo "ERROR: unknown element name {$el->name}\n"; - exit; - } -// echo "{$el->name}\n"; -} - -/* ---------------------------------------------- processing subjects element */ -$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": - $login = $el->attrs['login']->val; - $subjects[$login] = array( - 'type' => 'user', - 'pass' => $el->attrs['pass']->val, -# 'realname' => $el->attrs['realname']->val, - 'realname' => '', - 'prefs' => (isset($el->children[0]) ? $el->children[0]->children : NULL), - ); - break; - } -} - -/* -------------------------------------------------------- processing groups */ -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": - $subjects[$grname]['prefs'] = $el->children; - unset($groups[$grname][$i]); - break; - } - } -} - -#var_dump($xmlTree); -#var_dump($subjArr); -#var_dump($groups); -#var_dump($subjects); -#var_dump($tree); - -#exit; - -/* ================================================================ restoring */ - -if (VERBOSE) { - echo " resetting storage ...\n"; -} -$bs->resetStorage(FALSE); -$storId = $bs->storId; - -/* ------------------------------------------------------- restoring subjects */ -foreach ($subjects as $login => $subj) { - $uid0 = Subjects::GetSubjId($login); - ls_restore_checkErr($uid0); - 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)) { - $r = $bs->removeSubj($login); - ls_restore_checkErr($r, __LINE__); - } - if (VERBOSE) { - echo " adding user $login ...\n"; - } - $uid = BasicStor::addSubj($login, $subj['pass'], $subj['realname'], TRUE); - ls_restore_checkErr($uid, __LINE__); - } - break; - case "group": - if (!is_null($uid0)) { - $r = $bs->removeSubj($login); - if (PEAR::isError($r)) { - $uid = $uid0; - break; - } - //ls_restore_checkErr($r, __LINE__); - } - if (VERBOSE) { - echo " adding group $login ...\n"; - } - $uid = BasicStor::addSubj($login, NULL); - ls_restore_checkErr($uid, __LINE__); -// 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"; - $res = $pr->insert($uid, $prefkey, $prefval); - ls_restore_checkErr($res, __LINE__); - break; - default: - var_dump($el); - } - } - } -} - -/* --------------------------------------------------------- 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 = Subjects::AddSubjectToGroup($login, $grname); - ls_restore_checkErr($r, __LINE__); - } -} - -/* -------------------------------------------------------- restoring objects */ -ls_restore_restoreObject($tree, /*$storId,*/ FALSE); - diff --git a/utils/restore2.php b/utils/restore2.php deleted file mode 100755 index 026a6fe18..000000000 --- a/utils/restore2.php +++ /dev/null @@ -1,36 +0,0 @@ -getMessage()); -} -$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); - -$gb = new GreenBox(); -$rs = new Restore($gb); - -if ($rs->loglevel=='debug') { - $rs->addLogItem('argv:'.print_r($argv,true)); -} - -$backupfile = $argv[1]; -$token = $argv[3]; -$sessid = $argv[4]; -$rs->startRestore($backupfile,$token,$sessid); -
    $methodParamName