} elseif (!empty($fileobj->fileinfo['desc'])) { $systemdesc = $fileobj->fileinfo['desc']; } # Stop JS/HTML insertion $systemdesc = strip_tags($systemdesc); # Get thumbnail $thumbpath = bh_thumbnail($file['filepath'], 128); if ($thumbpath == false) { $thumbpath = $this->geticon($file['filepath'], 128); } if (empty($bhconfig['defaultfilemodule'])) { $defaultfilemodule = "viewfile"; } else { $defaultfilemodule = $bhconfig['defaultfilemodule']; } if ($fileobj->is_dir() == true) { $str .= "<td align='center'>\n\t\t\t<table><tr height='128'><td style='border: 1px solid gray;' width='128' valign='middle' align='center'><a href='index.php?page=viewdir&filepath=" . $file['filepath'] . "'><img src='" . $thumbpath . "' border='0'></a></td></tr>\n\t\t\t<tr><td align='center' width='128'><a href='index.php?page=viewdir&filepath=" . $file['filepath'] . "' class='filenamelink'>" . $file['filename'] . "</a><br><font color='gray'>" . $systemdesc . "<br>" . $fileobj->numberfiles() . $bhlang['label:_files'] . "<br></font></td></tr></table></td>"; } else { $str .= "<td align='center'>\n\t\t\t<table><tr height='128'><td style='border: 1px solid gray;' width='128' valign='middle' align='center'><a href='index.php?page={$defaultfilemodule}&filepath=" . $file['filepath'] . "'><img src='" . $thumbpath . "' border='0'></a></td></tr>\n\t\t\t<tr><td align='center' width='128'><a href='index.php?page={$defaultfilemodule}&filepath=" . $file['filepath'] . "' class='filenamelink'>" . $file['filename'] . "</a><br><font color='gray'>" . $systemdesc . "<br>" . bh_humanfilesize($file['filesize']) . "<br></font></td></tr></table></td>"; } if ($even == 2) { $str .= "</tr>"; $even = -1; } $even++; } } 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";
# Send the file listing to the layout, along with directory name $layoutobj->title = $bhlang['title:main']; $layoutobj->content1 = $bhtexts['main_loggedout']; $layoutobj->display(); } else { # Send the file listing to the layout, along with directory name # Open layout object $layoutobj = new bhlayout("filelist"); # Grab the directory we're looking in $filepath = bh_fpclean($bhcurrent['userobj']->homedir); # Open the file object for the directory if (empty($filepath)) { $filepath = "/"; } $directoryobj = new bhfile($filepath); if ($directoryobj->is_dir() == FALSE) { bh_error($bhlang['error:not_a_dir'], "BH_INVALID_PATH"); } $modulestouse = bh_listmodulesdirectory($filepath); # Get listing mode for this directory $view = bh_view($bhcurrent['userobj']->username, $filepath); # Grab a listing of the files $files = $directoryobj->loadfile(); # Send the file listing to the layout, along with directory name $layoutobj->title = $bhlang['title:viewing_directory'] . " " . $filepath; $layoutobj->subtitle1 = $filepath; $layoutobj->content1 = $files; $layoutobj->content2 = $modulestouse; $layoutobj->filepath = $filepath; $layoutobj->view = $view; $layoutobj->display();
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 geticon($filepath, $size = 48) { # Open file object and see if it is a folder $fileobj = new bhfile($filepath); if ($fileobj->is_dir() == TRUE) { if (file_exists($this->skinpath . "images/filetypes/" . $size . "x" . $size . "/folder.png")) { return $this->skinpath . "images/filetypes/" . $size . "x" . $size . "/folder.png"; } else { return $this->skinpath . "images/filetypes/48x48/folder.png"; } } # Get extension of file $filepatharray = explode(".", $filepath); $extension = $filepatharray[count($filepatharray) - 1]; # Find icon name switch ($extension) { case "png": case "jpg": case "jpeg": case "gif": case "mng": case "tif": case "tiff": case "bmp": case "xpm": $icon = "image.png"; break; case "svg": case "psd": case "xcf": case "ps": $icon = "vectorgfx.png"; break; case "htm": case "html": case "tpl": $icon = "html.png"; break; case "doc": case "oot": case "ott": case "sxw": case "rtf": $icon = "document.png"; break; case "xls": case "oos": case "ots": case "sxc": $icon = "spreadsheet.png"; break; case "mov": case "wmv": case "mpg": case "mpeg": case "ogv": $icon = "video.png"; break; case "ogg": case "mp3": case "wma": case "wav": case "flac": $icon = "sound.png"; break; case "chm": $icon = "help.png"; break; case "exe": case "dll": $icon = "winexe.png"; break; case "py": $icon = "source_python.png"; break; case "php": case "php3": case "php4": case "php5": case "phpx": case "phtml": $icon = "source_php.png"; break; case "zip": case "bz2": case "gz": case "tgz": case "tbz2": case "rar": case "7z": case "cab": case "sit": case "sitx": $icon = "compressed.png"; break; case "eml": $icon = "email.png"; break; case "txt": $icon = "txt.png"; break; case "mid": case "midi": $icon = "midi.png"; break; case "iso": case "cue": $icon = "cdimage.png"; break; case "bin": $icon = "binary.png"; break; case "pdf": $icon = "pdf.png"; break; case "deb": $icon = "deb.png"; break; case "rpm": $icon = "rpm.png"; break; case "log": $icon = "log.png"; break; default: $icon = "generic.png"; break; } if (file_exists($this->skinpath . "images/filetypes/" . $size . "x" . $size . "/" . $icon) == true) { return $this->skinpath . "images/filetypes/" . $size . "x" . $size . "/" . $icon; } else { if (file_exists($this->skinpath . "images/filetypes/" . $size . "x" . $size . "/generic.png")) { return $this->skinpath . "images/filetypes/" . $size . "x" . $size . "/generic.png"; } else { return $this->skinpath . "images/filetypes/48x48/" . $icon; } } }
#iscore 1 # Test for include status if (IN_BH != 1) { header("Location: ../index.php"); die; } if (bh_file_exists($filepath) == true) { # Open layout object $layoutobj = new bhlayout("filepane"); # Grab the file we're looking at $filepath = bh_fpclean($_GET['filepath']); if (empty($filepath)) { bh_log($bhlang['error:no_file_specified'], "BH_INVALID_PATH"); } $fileobj = new bhfile($filepath); if ($fileobj->is_dir() == TRUE) { bh_error($bhlang['error:not_a_file'], "BH_INVALID_PATH"); } # Get the modules it's allowed $modulestouse = bh_listmodulesfile($filepath); # Send the stuff to the layout. # Note: # content1 - the list of modules it is allowed # subtitle1 - the filename # subtitle2 - the description $layoutobj->title = $bhlang['title:viewing_file'] . " " . $filepath; $layoutobj->subtitle1 = $filepath; $layoutobj->content1 = $modulestouse; $layoutobj->filepath = $filepath; $layoutobj->display(); } else {
function bh_mimetype($filepath) { global $bhconfig; $fileobj = new bhfile($filepath); if ($fileobj->is_dir()) { return "bytehoard/directory"; } else { # If we can use unix file, then YES! YES! YES! if (bh_os() == "nix") { # Get what file says $cmdstr = "file -bi " . escapeshellarg($bhconfig['fileroot'] . $filepath); $fileoutput = `{$cmdstr}`; # Trim off any charset or language stuff $array1 = explode(",", $fileoutput); $fileoutput = $array1[0]; $array1 = explode(";", $fileoutput); $fileoutput = $array1[0]; $fileoutput = trim($fileoutput); $fileoutput = str_replace("\n", "", $fileoutput); return $fileoutput; } $extension = bh_get_extension($filepath); switch ($extension) { case "txt": return "text/plain"; break; case "html": case "htm": case "txt": return "text/html"; break; case "png": return "image/png"; break; case "jpg": case "jpeg": case "jpe": return "image/jpeg"; break; case "gif": return "image/gif"; break; case "mp3": return "audio/x-mp3"; break; case "ogg": return "audio/x-vorbis"; break; case "wav": return "audio/wav"; break; case "doc": return "application/msword"; break; case "xls": return "application/vnd.ms-excel"; break; case "ppt": case "pps": return "application/vnd.ms-powerpoint"; break; default: return "application/octet-stream"; break; } } }