<?PHP
class BSGDownload
{
var $bsgar;
var $webappcfg;
function BSGDownload()
{
global $webappcfg;
$this->webappcfg = $webappcfg;
$this->bsgar = new BSGAuthRight();
}
function downloadFile($_filename, $_ownerid, $_keypass, $_vartype=FILENAME)
{
if ($this->bsgar->checkFileRead($_filename, NSession::getuid(),
$_ownerid, $_keypass, $_vartype))
{
$filedirdb = $this->bsgar->getfiledirdb();
//echo("<PRE>");
//print_r($filedirdb);
if ($filedirdb!=null)
{
$twfile = $filedirdb->getobj();
$tfile = fopen($this->webappcfg['filestorage']."/".$twfile->getlocation(), "r");
$filesize = filesize($this->webappcfg['filestorage']."/".$twfile->getlocation());
$filecontent = fread($tfile, $filesize);
fclose($tfile);
return array("filedirdb"=>$filedirdb, "filecontent"=>$filecontent, "filesize"=>$filesize);
}
else
return null;
}
else
{
// Return Error : Access Denied
echo "BSD: Access Denied";
return null;
}
}
}
?>