*
  • 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: * * */ require_once 'DB.php'; require_once '../conf.php'; require_once '../LocStor.php'; PEAR::setErrorHandling(PEAR_ERROR_RETURN); $dbc = DB::connect($config['dsn'], TRUE); $dbc->setFetchMode(DB_FETCHMODE_ASSOC); $locStor = &new LocStor($dbc, $config); function http_error($code, $err){ header("HTTP/1.1 $code"); header("Content-type: text/plain; charset=UTF-8"); echo "$err\r\n"; exit; } 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']})"); } $ex_ac = $locStor->existsAudioClip($sessid, $gunid); if(PEAR::isError($ex_ac)){ if($ex_ac->getCode() == GBERR_DENY){ http_error(403, $ex_ac->getMessage()); }else{ http_error(500, $ex_ac->getMessage()); } } $ex_pl = $locStor->existsPlaylist($sessid, $gunid); if(PEAR::isError($ex_pl)){ if($ex_pl->getCode() == GBERR_DENY){ http_error(403, $ex_pl->getMessage()); }else{ http_error(500, $ex_pl->getMessage()); } } if(!$ex_ac && !$ex_pl){ http_error(404, "404 File not found"); } $ac =& StoredFile::recallByGunid($locStor, $gunid); if(PEAR::isError($ac)){ http_error(500, $ac->getMessage()); } $ftype = $locStor->getObjType($id = $locStor->_idFromGunid($gunid)); if(PEAR::isError($ftype)){ http_error(500, $ftype->getMessage()); } if($ex_ac){ switch($ftype){ case"audioclip": $realFname = $ac->_getRealRADFname(); $mime = $ac->rmd->getMime(); header("Content-type: $mime"); readfile($realFname); break; case"webstream": $url = $locStor->bsGetMetadataValue($id, 'ls:url'); if(PEAR::isError($url)){ http_error(500, $url->getMessage()); } $url = $url[0]['value']; $txt = "Location: $url"; header($txt); // echo "$txt\n"; break; default: var_dump($ftype); http_error(500, "500 Unknown ftype ($ftype)"); } exit; } if($ex_pl){ // $md = $locStor->bsGetMetadata($ac->getId(), $sessid); $md = $locStor->getAudioClip($sessid, $gunid); // header("Content-type: text/xml"); header("Content-type: application/smil"); echo $md; exit; } ?>