# Test for include status if (IN_BH != 1) { header("Location: ../index.php"); die; } $filepath = bh_fpclean($_GET['filepath']); $filename = bh_get_filename($filepath); if (bh_file_exists($filepath) == true) { $fileobj = new bhfile($filepath); #if ($fileobj->fileinfo['size'] == 0) { # bh_log($bhlang['error:file_not_exist'], "BH_NOPAGE"); # require "modules/error.inc.php"; #} else { # Log bandwidth usage. New feature, for those who like Absolute Control(tm). This comment shamelessly copied from upload.inc.php. bh_bandwidth($bhsession['username'], "down", $fileobj->fileinfo['filesize']); header("Content-type: " . $fileobj->mimetype()); # If there's a Secret Message from the view image script not to include download headers, don't. if ($_GET['nodownheaders'] == 1) { header("Content-Disposition: filename=" . $filename); } else { header("Content-Disposition: attachment; filename=" . $filename); } header("Content-length: " . $fileobj->fileinfo['filesize']); # IE SSL fix header("Pragma: "); header("Cache-Control: "); $fileobj->readfile(); #} } else { bh_log($bhlang['error:file_not_exist'], "BH_NOPAGE"); require "modules/error.inc.php";
function fileinfo($filepath) { $return = array(); $filepath = bh_fpclean($filepath); $fileobj = new bhfile($filepath); $filename = bh_get_filename($filepath); $return['path'] = utf8_encode($filepath); $return['props'][] = $this->mkprop("getdisplayname", $filepath); $return['props'][] = $this->mkprop("displayname", $filepath); $return['props'][] = $this->mkprop("creationdate", $fileobj->fileinfo['createdate']); if (!empty($fileobj->fileinfo['moddate'])) { $return['props'][] = $this->mkprop("getlastmodified", $fileobj->fileinfo['moddate']); } else { $return['props'][] = $this->mkprop("getlastmodified", $fileobj->fileinfo['createdate']); } $return['props'][] = $this->mkprop("getcontentlength", $fileobj->fileinfo['filesize']); if ($fileobj->is_dir() == 1) { $return['props'][] = $this->mkprop('getcontenttype', "directory"); #$return['props'][] = $this->mkprop('contenttype', "directory"); $return['props'][] = $this->mkprop('resourcetype', 'collection'); } else { $return['props'][] = $this->mkprop('getcontenttype', $fileobj->mimetype()); #$return['props'][] = $this->mkprop('contenttype', $fileobj->mimetype()); $return['props'][] = $this->mkprop('resourcetype', ''); } return $return; }