function bh_thumbnail($filepath, $size) { global $bhconfig; # Check if we can handle this filetype switch (strtolower(bh_get_extension($filepath))) { case "jpg": case "jpeg": case "gif": case "png": $dothumbnail = true; break; case "svg": case "xpm": case "xcf": if ($bhconfig['imageprog'] == "imagemagick") { $dothumbnail = true; } else { return false; } break; default: return false; } if ($dothumbnail != true) { return false; } # Check for really big files that would choke md5/imagemagick/gd on slower systems if (filesize($bhconfig['fileroot'] . $filepath) > 5 * 1024 * 1024 && $bhconfig['limitthumbs'] == 1) { return false; } if (file_exists("cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png")) { return "cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png"; } else { bh_createthumbnail($filepath, $size); if (!file_exists("cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png")) { if (!file_exists("cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png.0")) { return false; } else { return "cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png.0"; } } else { return "cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png"; } } }
foreach ($this->content1 as $file) { if ($even == 0) { $str .= "<tr>"; } $file['filepath'] = bh_fpclean($file['filepath']); unset($fileobj); $fileobj = new bhfile($file['filepath']); # Get system's description of file on *nix systems. if (bh_os() == "nix") { $cmdstr = "file -b " . escapeshellarg($fileobj->absfilepath); $systemdesc2 = `{$cmdstr}`; $systemdescarray = explode(",", $systemdesc2); $systemdesc = $systemdescarray[0]; $systemdesc[0] = strtoupper($systemdesc[0]); } else { $systemdesc = strtoupper(bh_get_extension($file['filepath'])) . " file"; } # Get any possible description from metadata if (!empty($fileobj->fileinfo['description'])) { $systemdesc = $fileobj->fileinfo['description']; } 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'])) {
function bh_listmodulesfile($filepath) { global $bhcurrent; $fileobj = new bhfile($filepath); $filetype = $fileobj->fileinfo['mimetype']; $fileext = bh_get_extension($filepath); # Get lists of modules it's allowed $modrows = array_merge(select_bhdb("modulesfiletype", array("filetype" => "*", "status" => "1"), ""), select_bhdb("modulesfiletype", array("filetype" => $fileext, "status" => "1"), ""), select_bhdb("modulesfiletype", array("filetype" => $filetype, "status" => "1"), "")); # Get list of modules it's not allowed $modnorows = array_merge(select_bhdb("modulesfiletype", array("filetype" => "-" . $filetype, "status" => "1"), ""), select_bhdb("modulesfiletype", array("filetype" => "-" . $fileext, "status" => "1"), "")); # Go through and select those the user is allowed to access foreach ($modrows as $modrow) { $displayit = 1; foreach ($modnorows as $modnorow) { if ($modnorow['module'] == $modrow['module']) { $displayit = 0; } } if (bh_checkmodulefilepath($modrow['module'], $filepath, $bhcurrent['userobj']->username) == 1) { $allowedmods[$modrow['module']] = $modrow; } } return $allowedmods; }
if ($_POST['filemail']['linkonly'] == "on") { # Check expiry date $expiresin = $_POST['filemail']['expires']; if (is_numeric($expiresin) && $expiresin > 0) { if ($expiresin > $bhconfig['maxexpires']) { bh_log($bhlang['error:expires_too_much'], "BH_ERROR"); } else { if ($_POST['filemail']['notify'] == "on") { $notify = 1; } else { $notify = 0; } $expires = time() + round($expiresin * 60 * 60 * 24); $filecode = bh_filelink_add($filepath, $expires, $bhsession['username'], "--none--", $notify); $str = "<br>" . str_replace("#EXPIRE#", $expiresin, $bhlang['text:link__expire_in_#EXPIRE#']) . " <a href='" . bh_filelink_uri($filecode) . "'>" . bh_filelink_uri($filecode) . "</a><br><br><br>"; if (bh_get_extension($filepath) == "png" || bh_get_extension($filepath) == "gif" || bh_get_extension($filepath) == "jpg" || bh_get_extension($filepath) == "jpeg" || bh_get_extension($filepath) == "tif" || bh_get_extension($filepath) == "tiff" || bh_get_extension($filepath) == "bmp") { $str .= $bhlang['title:image_tags'] . "<br><br>" . $bhlang['label:html'] . "<br><img src=\"" . bh_filelink_uri($filecode) . "&download=1\" /><br><br>"; $str .= $bhlang['label:bbcode'] . "<br>[img]" . bh_filelink_uri($filecode) . "&download=1[/img]<br>"; } } } else { bh_log($bhlang['error:expires_invalid'], "BH_ERROR"); } } else { # Check for empty subject if (empty($_POST['filemail']['subject'])) { bh_log($bhlang['error:no_emailsubj'], "BH_ERROR"); } else { # Check expiry date $expiresin = $_POST['filemail']['expires']; if (is_numeric($expiresin) && $expiresin > 0) {
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; } } }