function bh_createthumbnail($filepath, $size) { global $bhconfig; # See what thumbnailing method we're using switch ($bhconfig['imageprog']) { case "imagemagick": default: if (empty($bhconfig['syspath_convert'])) { $bhconfig['syspath_convert'] = "convert"; } $execline = $bhconfig['syspath_convert'] . " -size " . $size . "x" . $size . " " . escapeshellarg($bhconfig['fileroot'] . $filepath) . " -thumbnail " . $size . "x" . $size . " " . $bhconfig['bhfilepath'] . "/cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png"; $result = `{$execline}`; break; case "gd": if (!extension_loaded("gd")) { if (!dl("gd.so") && !dl("gd.dll")) { bh_die("error:no_gd"); } } # Read in file $fn = fopen($bhconfig['fileroot'] . $filepath, "rb"); while (!feof($fn)) { $imagestring .= fread($fn, 4096); } fclose($fn); # Create image from string $origimg = imagecreatefromstring($imagestring); $origsizearray = getimagesize($bhconfig['fileroot'] . $filepath); $origwidth = $origsizearray[0]; $origheight = $origsizearray[1]; # Find new width/height if ($origwidth > $origheight) { $ratio = $size / $origwidth; $newwidth = $size; $newheight = $ratio * $origheight; } else { $ratio = $size / $origheight; $newheight = $size; $newwidth = $ratio * $origwidth; } # Create new image $newimg = imagecreatetruecolor($newwidth, $newheight); $white = imagecolorallocate($newimg, 255, 255, 255); imagefill($newimg, 0, 0, $white); # This isn't necessary, but... # Resample image down imagecopyresampled($newimg, $origimg, 0, 0, 0, 0, $newwidth, $newheight, $origwidth, $origheight); # Save the image imagepng($newimg, $bhconfig['bhfilepath'] . "/cache/thumbnail-" . $size . "-" . md5_file($bhconfig['fileroot'] . $filepath) . ".png"); break; } }
* */ #name File Link Module #author Andrew Godwin #description Does the one-time time-expiring links. This only generates them, serving them is done by a separate PHP process (filelink.php) # Test for include status if (IN_BH != 1) { header("Location: ../index.php"); die; } $filepath = $_GET['filepath']; if (empty($filepath)) { $filepath = $_POST['filepath']; } if (empty($filepath)) { bh_die("error:no_filepath"); } $filepath = bh_fpclean($filepath); # See if we have details passed to us in the POST if (!empty($_POST['filemail'])) { # Check to see if we email or not 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 {
require "includes/pear/PEAR.php"; # Inbuilt PEAR file. This is bad, I know, but we need it. require "includes/pear/Archive/tar.inc.php"; # And the Archive_Tar library. Slightly modified. bh_updatemoduledb(); # Add any new modules bh_purge_old(); # Purge old requests for things # Right. See if there is a file code if (empty($_GET['filecode'])) { bh_die("error:no_filecode"); } $filecode = $_GET['filecode']; if (bh_filelink_destination($filecode) == false) { bh_log(str_replace("#FILELINK", $filecode, $bhlang['log:filelink_denied']), "BH_FILELINK_ACCESSED"); bh_die("error:filecode_invalid"); } # Well, it must be valid. $filepath = bh_filelink_destination($filecode); $filename = bh_get_filename($filepath); $fileobj = new bhfile($filepath); $username = bh_filelink_get($filecode, "username"); $userobj = new bhuser($username); $fullname = $userobj->userinfo['fullname']; $emailfrom = $userobj->userinfo['email']; # If it is a download: if ($_GET['download'] == 1) { $replarray1 = array("#FILELINK#", "#FILEPATH#", "#FILENAME#", "#IP#", "#TIME#", "#EMAIL#", "#EXPIRES#"); $replarray2 = array($filecode, $filepath, $filename, $_SERVER['REMOTE_ADDR'], date("l dS F Y g:i A"), bh_filelink_get($filecode, "email"), date("l dS F Y g:i A", bh_filelink_get($filecode, "expires"))); # Log it bh_log(str_replace($replarray1, $replarray2, $bhlang['log:filelink_accessed']), "BH_FILELINK_ACCESSED");