diff --git a/livesupport/src/modules/archiveServer/var/Archive.php b/livesupport/src/modules/archiveServer/var/Archive.php index 33db1d3b4..b7b03628e 100644 --- a/livesupport/src/modules/archiveServer/var/Archive.php +++ b/livesupport/src/modules/archiveServer/var/Archive.php @@ -1,134 +1,150 @@ getSessUserId($sessid); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $res = $r = $this->bsOpenPut($chsum, NULL, $owner); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } return array('url'=>$res['url'], 'token'=>$res['token']); } + /** - * Check uploaded file + * Check uploaded file * - * @param token: string - transport token - * @return array(md5h string, size int, url string) + * @param string $token + * transport token + * @return array + * (md5h string, size int, url string) */ function uploadCheck($token) { return $this->bsCheckPut($token); } + /** - * Close upload transport + * Close upload transport * - * @param token: string - transport token - * @param trtype: string - transport type - * @param pars: array - transport parameters - * @return mixed + * @param string $token + * transport token + * @param string $trtype + * transport type + * @param array $pars + * transport parameters + * @return mixed */ function uploadClose($token, $trtype, $pars=array()) { $res = $r = $this->bsClosePut($token); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } extract($res); // fname, owner - switch($trtype){ - case"audioclip": + switch ($trtype) { + case "audioclip": $mdtoken = $pars['mdpdtoken']; $res = $r = $this->bsClosePut($mdtoken); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $mdfname = $res['fname']; - if($gunid=='') $gunid=NULL; + if ($gunid == '') { + $gunid=NULL; + } $parid = $r = $this->_getHomeDirId($owner); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $res = $r = $this->bsPutFile($parid, $pars['name'], $fname, $mdfname, $pars['gunid'], 'audioclip', 'file'); - if($this->dbc->isError($r)) return $r; - @unlink($fname); @unlink($mdfname); + if ($this->dbc->isError($r)) { + return $r; + } + @unlink($fname); + @unlink($mdfname); break; - case"playlist": - if($gunid=='') $gunid=NULL; + case "playlist": + if ($gunid == '') { + $gunid = NULL; + } $parid = $r = $this->_getHomeDirId($owner); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $res = $r = $this->bsPutFile($parid, $pars['name'], '', $fname, $pars['gunid'], 'playlist', 'file'); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } @unlink($fname); break; - case"playlistPkg": + case "playlistPkg": $chsum = md5_file($fname); // importPlaylistOpen: $res = $r = $this->bsOpenPut($chsum, NULL, $owner); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $dest = $res['fname']; $token = $res['token']; copy($fname, $dest); $r = $this->importPlaylistClose($token); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } @unlink($fname); return $r; break; - case"searchjob": + case "searchjob": $crits = file_get_contents($fname); $criteria = unserialize($crits); @unlink($fname); $results = $r =$this->localSearch($criteria); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $realfile = tempnam($this->accessDir, 'searchjob_'); @chmod($realfile, 0660); $len = $r = file_put_contents($realfile, serialize($results)); $acc = $r = $this->bsAccess($realfile, '', NULL, 'download'); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $url = $this->getUrlPart()."access/".basename($acc['fname']); $chsum = md5_file($realfile); - $size = filesize($realfile); + $size = filesize($realfile); $res = array( 'url'=>$url, 'token'=>$acc['token'], 'chsum'=>$chsum, 'size'=>$size, @@ -136,67 +152,77 @@ class Archive extends XR_LocStor{ ); return $res; break; - case"metadata": + case "metadata": break; default: } return $res; } + /** - * Open download transport + * Open download transport * - * @param sessid: string - session id - * @param trtype: string - transport type - * @param pars: array - transport parameters - * @return hasharray with: + * @param string $sessid - session id + * @param string $trtype - transport type + * @param array $pars - transport parameters + * @return hasharray with: * url string: writable URL * token string: PUT token */ function downloadOpen($sessid, $trtype, $pars=array()) { - switch($trtype){ - case"unknown": - case"audioclip": - case"metadata": - case"playlist": - case"playlistPkg": - if(!isset($pars['gunid'])) + switch ($trtype) { + case "unknown": + case "audioclip": + case "metadata": + case "playlist": + case "playlistPkg": + if (!isset($pars['gunid'])) { return PEAR::raiseError("Archive::downloadOpen: gunid not set"); + } break; } $gunid = $pars['gunid']; // resolve trtype by object type: - if($trtype == 'unknown' || $trtype == 'playlistPkg'){ + if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) { $trtype2 = $r = $this->_getType($gunid); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } // required with content: $trtype = ($trtype2 == 'playlist' && $trtype == 'playlistPkg'? 'playlistPkg' : $trtype2); # return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid"); } - switch($trtype){ - case"audioclip": + switch ($trtype) { + case "audioclip": $res = $r = $this->downloadRawAudioDataOpen($sessid, $gunid); break; - case"metadata": + case "metadata": $res = $r = $this->downloadMetadataOpen($sessid, $gunid); break; - case"playlist": + case "playlist": $res = $r = $this->accessPlaylist($sessid, $gunid); break; - case"playlistPkg": + case "playlistPkg": $res = $r = $this->bsExportPlaylistOpen($gunid); - if($this->dbc->isError($r)) return $r; + if ($this->dbc->isError($r)) { + return $r; + } $tmpn = tempnam($this->transDir, 'plExport_'); $plfpath = "$tmpn.lspl"; copy($res['fname'], $plfpath); $res = $r = $this->bsExportPlaylistClose($res['token']); - if(PEAR::isError($r)) return $r; + if (PEAR::isError($r)) { + return $r; + } $fname = "transported_playlist.lspl"; $id = $this->_idFromGunid($gunid); $acc = $this->bsAccess($plfpath, 'lspl', NULL, 'download'); - if($this->dbc->isError($acc)){ return $acc; } + if ($this->dbc->isError($acc)) { + return $acc; + } $url = $this->getUrlPart()."access/".basename($acc['fname']); $chsum = md5_file($plfpath); $size = filesize($plfpath); @@ -206,25 +232,27 @@ class Archive extends XR_LocStor{ 'filename'=>$fname ); break; - case"searchjob": + case "searchjob": $res = $pars; break; - case"file": + case "file": $res = $r = array(); break; default: return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)"); } - if($this->dbc->isError($r)) return $r; - switch($trtype){ - case"audioclip": - case"metadata": - case"playlist": - case"playlistPkg": + if ($this->dbc->isError($r)) { + return $r; + } + switch ($trtype) { + case "audioclip": + case "metadata": + case "playlist": + case "playlistPkg": $title = $r = $this->bsGetTitle(NULL, $gunid); break; - case"searchjob": $title = 'searchjob'; break; - case"file": $title = 'regular file'; break; + case "searchjob": $title = 'searchjob'; break; + case "file": $title = 'regular file'; break; default: } $res['title'] = $title; @@ -232,50 +260,67 @@ class Archive extends XR_LocStor{ return $res; } + /** - * Close download transport + * Close download transport * - * @param token: string - transport token - * @param trtype: string - transport type - * @return hasharray with: + * @param string $token + * transport token + * @param string $trtype + * transport type + * @return array + * hasharray with: * url string: writable URL * token string: PUT token */ function downloadClose($token, $trtype) { - switch($trtype){ - case"audioclip": + switch ($trtype) { + case "audioclip": $res = $r = $this->downloadRawAudioDataClose($token); - if($this->dbc->isError($r)) return $r; - return $res; - break; - case"metadata": - $res = $r = $this->downloadMetadataClose($token); - if($this->dbc->isError($r)) return $r; - return $res; - break; - case"playlist": - $res = $r = $this->releasePlaylist(NULL/*$sessid*/, $token); - if($this->dbc->isError($r)) return $r; - return $res; - break; - case"playlistPkg": - $res = $r = $this->bsRelease($token, 'download'); - if($this->dbc->isError($r)) return $r; - $realFname = $r['realFname']; - @unlink($realFname); - if(preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)){ - list(,$tmpn) = $va; $tmpn = "{$this->transDir}/$tmpn"; - if(file_exists($tmpn)) @unlink($tmpn); + if ($this->dbc->isError($r)) { + return $r; } return $res; break; - case"searchjob": - $res = $r = $this->bsRelease($token, 'download'); - if($this->dbc->isError($r)) return $r; + case "metadata": + $res = $r = $this->downloadMetadataClose($token); + if ($this->dbc->isError($r)) { + return $r; + } return $res; break; - case"file": + case "playlist": + $res = $r = $this->releasePlaylist(NULL/*$sessid*/, $token); + if ($this->dbc->isError($r)) { + return $r; + } + return $res; + break; + case "playlistPkg": + $res = $r = $this->bsRelease($token, 'download'); + if ($this->dbc->isError($r)) { + return $r; + } + $realFname = $r['realFname']; + @unlink($realFname); + if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) { + list(,$tmpn) = $va; + $tmpn = "{$this->transDir}/$tmpn"; + if (file_exists($tmpn)) { + @unlink($tmpn); + } + } + return $res; + break; + case "searchjob": + $res = $r = $this->bsRelease($token, 'download'); + if ($this->dbc->isError($r)) { + return $r; + } + return $res; + break; + case "file": return array(); break; default: @@ -283,14 +328,19 @@ class Archive extends XR_LocStor{ } } + /** - * Prepare hub initiated transport + * Prepare hub initiated transport * - * @param target: string - hostname of transport target - * @param trtype: string - transport type - * @param direction: string - 'up' | 'down' - * @param pars: array - transport parameters - * @return + * @param string $target + * hostname of transport target + * @param string $trtype + * transport type + * @param string $direction + * 'up' | 'down' + * @param array $pars + * transport parameters + * @return mixed */ function prepareHubInitiatedTransfer( $target, $trtype='file', $direction='up',$pars=array()) @@ -299,46 +349,62 @@ class Archive extends XR_LocStor{ $trec = $r = TransportRecord::create($tr, $trtype, $direction, array_merge($pars, array('target'=>$target)) ); - if(PEAR::isError($r)){ return $r; } + if (PEAR::isError($r)) { + return $r; + } return TRUE; } + /** - * List hub initiated transports + * List hub initiated transports * - * @param target: string - hostname of transport target - * @param direction: string - 'up' | 'down' - * @param trtok: string - transport token - * @return + * @param string $target + * hostname of transport target + * @param string $direction + * 'up' | 'down' + * @param string $trtok + * transport token + * @return mixed */ function listHubInitiatedTransfers( $target=NULL, $direction=NULL, $trtok=NULL) { $tr =& new Transport($this); $res = $r = $tr->getTransports($direction, $target, $trtok); - if(PEAR::isError($r)){ return $r; } + if (PEAR::isError($r)) { + return $r; + } return $res; } + /** - * Set state of hub initiated transport + * Set state of hub initiated transport * - * @param target: string - hostname of transport target - * @param trtok: string - transport token - * @param state: string - transport state - * @return + * @param string $target + * hostname of transport target + * @param string $trtok + * transport token + * @param string $state + * transport state + * @return */ function setHubInitiatedTransfer($target, $trtok, $state) { $tr =& new Transport($this); $trec = $r = TransportRecord::recall($tr, $trtok); - if(PEAR::isError($r)){ return $r; } + if (PEAR::isError($r)) { + return $r; + } $r = $trec->setState($state); - if(PEAR::isError($r)){ return $r; } + if (PEAR::isError($r)) { + return $r; + } return $res; } /* ==================================================== auxiliary methods */ -} +} // class Archive ?> \ No newline at end of file diff --git a/livesupport/src/modules/archiveServer/var/conf.php b/livesupport/src/modules/archiveServer/var/conf.php index a9fd7e03b..37989b04b 100644 --- a/livesupport/src/modules/archiveServer/var/conf.php +++ b/livesupport/src/modules/archiveServer/var/conf.php @@ -1,36 +1,11 @@ +?> \ No newline at end of file diff --git a/livesupport/src/modules/archiveServer/var/install/install.php b/livesupport/src/modules/archiveServer/var/install/install.php index 095698091..22606e70e 100644 --- a/livesupport/src/modules/archiveServer/var/install/install.php +++ b/livesupport/src/modules/archiveServer/var/install/install.php @@ -1,35 +1,12 @@ getMessage()."\ndi:\n".$err->getDebugInfo(). @@ -50,14 +29,14 @@ function errCallback($err) exit(1); } -if(!function_exists('pg_connect')){ +if (!function_exists('pg_connect')) { trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR); exit(2); } PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s