*/ #name Delete #author Andrew Godwin #description Deletes a file. #iscore 1 # Note: no layouts here, of course. Unless we get an error. # 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) { if ($_POST['dodelete'] == 1) { $delfileobj = new bhfile($filepath); $delfileobj->smartdeletefile(); unset($delfileobj); bh_log($bhlang['notice:file_deleted'], "BH_FILE_DELETED"); $_GET['filepath'] = bh_get_parent($filepath); require "modules/viewdir.inc.php"; } else { $layoutobj = new bhlayout('deleteform'); $layoutobj->filepath = $filepath; $layoutobj->title = $bhlang['title:deleting_'] . bh_get_filename($filepath); $layoutobj->display(); } } else { bh_log($bhlang['error:file_not_exist'], "BH_NOPAGE"); require "modules/error.inc.php"; }
* Module * $Id: download.inc.php,v 1.5 2005/07/26 21:55:09 andrewgodwin Exp $ * */ #name Download #author Andrew Godwin #description Sends the file to the client. #iscore 1 # Note: no layouts here, of course. Unless we get an error. # 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); }
<?php $str .= "\n<br>\n<table class='toolbar' cellspacing='0' cellpadding='0' width='50%' align='center'>\n\t<tr height='10'>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/tl.png'></td>\n\t\t<td background='" . $this->skinpath . "images/sidebar/tc.png'></td>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/tr.png'></td>\n\t</tr>\n\t<tr height='30'>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/lc.png' width='10' height='30'></td>\n\t\t<td background='" . $this->skinpath . "images/sidebar/titlebg.png' align='center' valign='middle'><b>" . $bhlang['title:deleting_'] . bh_get_filename($this->filepath) . "</b></td>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/rc.png' width='10' height='30'></td>\n\t</tr>\n\t<tr>\n\t\t<td width='10' background='" . $this->skinpath . "images/sidebar/lc.png'> </td>\n\t\t<td valign='middle' align='center'><br><br>\n\t\t\t\n\t\t\t\n\t\t\t<table>\n\t\t\t<tr><td align='center' colspan='2'>" . $bhlang['explain:delete'] . "<br/><br/></td></tr>\n\t\t\t<tr>\n\t\t\t<td align='center'>\n\t\t\t\t<form action='index.php?page=viewfile&filepath=" . $this->filepath . "' method='POST'><input type='submit' value='" . $bhlang['button:cancel'] . "'></form>\n\t\t\t</td>\n\t\t\t<td align='center'>\n\t\t\t\t<form action='index.php?page=delete&filepath=" . $this->filepath . "' method='POST'><input type='hidden' name='dodelete' value='1'><input type='submit' value='" . $bhlang['button:delete_file'] . "'></form>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t\t<td width='10' background='" . $this->skinpath . "images/sidebar/rc.png'> </td>\n\t</tr>\n\t<tr height='10'>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/bl.png'></td>\n\t\t<td background='" . $this->skinpath . "images/sidebar/bc.png'></td>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/br.png'></td>\n\t</tr>\n</table>\n";
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; }
function copyto($newfilepath, $aclonly = 0) { global $bhconfig; # Clean up filepath $newfilepath = bh_fpclean($newfilepath); if ($aclonly == 0) { if ($this->is_dir()) { } else { copy($this->absfilepath, $bhconfig['fileroot'] . $newfilepath); chmod($bhconfig['fileroot'] . $newfilepath, 0777); } } # If directory, do the ACL stuff for all files. if ($this->is_dir()) { $this->loadfile(); if ($aclonly == 0) { @mkdir($bhconfig['fileroot'] . $newfilepath, 0777); } foreach ($this->filecontents as $file2copy) { #echo "(".$file2copy['filepath']." --to-- ".bh_fpclean($newfilepath."/".bh_get_filename($file2copy['filename'])).") "; $file2copyobj = new bhfile($file2copy['filepath']); $file2copyobj->copyto(bh_fpclean($newfilepath . "/" . bh_get_filename($file2copy['filename']))); unset($filetocopyobj); } } # Insert ACL/metadata/filecode entries of old self $acl_u_rows = select_bhdb("aclusers", array("filepath" => $this->filepath), ""); foreach ($acl_u_rows as $acl_u_row) { $acl_u_row['filepath'] = $newfilepath; insert_bhdb("aclusers", $acl_u_row); } $acl_g_rows = select_bhdb("aclgroups", array("filepath" => $this->filepath), ""); foreach ($acl_g_rows as $acl_g_row) { $acl_g_row['filepath'] = $newfilepath; insert_bhdb("aclgroups", $acl_g_row); } $acl_p_rows = select_bhdb("aclpublic", array("filepath" => $this->filepath), ""); foreach ($acl_p_rows as $acl_p_row) { $acl_p_row['filepath'] = $newfilepath; insert_bhdb("aclpublic", $acl_p_row); } $md_rows = select_bhdb("metadata", array("filepath" => $this->filepath), ""); foreach ($md_rows as $md_row) { $md_row['filepath'] = $newfilepath; insert_bhdb("metadata", $md_row); } # Done. }
<?php $str .= "\n<br>\n<table class='toolbar' cellspacing='0' cellpadding='0' width='100%' align='center'>\n\t<tr height='10'>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/tl.png'></td>\n\t\t<td background='" . $this->skinpath . "images/sidebar/tc.png'></td>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/tr.png'></td>\n\t</tr>\n\t<tr height='30'>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/lc.png' width='10' height='30'></td>\n\t\t<td background='" . $this->skinpath . "images/sidebar/titlebg.png' align='center' valign='middle'>\n\t\t\t<table cellpadding='0' cellspacing='0' width='100%'><tr><td width='32' align='center'>\n\t\t\t\t<img src='" . $this->geticon($this->filepath, "16") . "' border='0'>\n\t\t\t</td><td align='center'>\n\t\t\t\t<b>" . bh_get_filename($this->filepath) . "</b>\n\t\t\t</td></tr></table>\n\t\t</td>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/rc.png' width='10' height='30'></td>\n\t</tr>\n\t<tr>\n\t\t<td width='10' background='" . $this->skinpath . "images/sidebar/lc.png'> </td>\n\t\t<td valign='middle' align='center'><br>\n\t\t\t<table width='90%' align='center' cellspacing='6' cellpadding='3'>\n\t\t"; if (is_array($this->content1)) { $even = 1; foreach ($this->content1 as $modulearray) { $even = 1 - $even; if ($even == 0) { $str .= "<tr>"; } $str .= "<td width='50'><a href='index.php?page=" . $modulearray['module'] . "&filepath=" . $this->filepath . "'><img src='" . $this->getmoduleicon($modulearray['module']) . "' border='0'></a></td><td><a href='index.php?page=" . $modulearray['module'] . "&filepath=" . $this->filepath . "' class='filenamelink'>" . bh_moduletitle($modulearray['module']) . "</a><br><font color='gray'>" . bh_moduledescription($modulearray['module']) . "<br></font></td>"; if ($even == 1) { $str .= "</tr>"; } } } if ($even = 0) { $str .= "<td width='50'></td><td></td></tr>"; } $str .= "\t\t</table><br>\n\t\t</td>\n\t\t<td width='10' background='" . $this->skinpath . "images/sidebar/rc.png'> </td>\n\t</tr>\n\t<tr height='10'>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/bl.png'></td>\n\t\t<td background='" . $this->skinpath . "images/sidebar/bc.png'></td>\n\t\t<td width='10'><img src='" . $this->skinpath . "images/sidebar/br.png'></td>\n\t</tr>\n</table>\n";
function bh_trash($absfilepath) { global $bhconfig; if (!bh_file_exists(bh_fpclean("/trash"))) { bh_mkdir(bh_fpclean("/trash")); } rename($absfilepath, $bhconfig['fileroot'] . bh_fpclean("/trash") . "/" . bh_get_filename($absfilepath)); }