diff options
Diffstat (limited to 'forum/utils/file.php')
-rw-r--r-- | forum/utils/file.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/forum/utils/file.php b/forum/utils/file.php index 50993b5..25cb4c2 100644 --- a/forum/utils/file.php +++ b/forum/utils/file.php @@ -28,4 +28,30 @@ function getFile($fid) readfile($filename); } +function getFilePreview($fid) +{ + global $DATA_DIR, $PERMSTORE, $MIME_TYPES; + $files = new Files($DATA_DIR . "/files.xml"); + $file = $files->getFile($fid); + + $filename = $PERMSTORE . "/" . $file->fid; + + if(strstr($file->mimetype, "image")) { + header('Content-Description: File Transfer'); + header('Content-Type: ' . $file->mimetype); + header('Content-Length: ' . filesize($filename)); + header('Content-Disposition: inline; filename=' . basename($file->name)); + readfile($filename); + } else { + header("Content-type: image/png"); + $im = @imagecreate(8 + strlen($file->name) * 5, 20) + or die("Cannot Initialize new GD image stream"); + $background_color = imagecolorallocate($im, 0, 0, 0); + $text_color = imagecolorallocate($im, 233, 14, 91); + imagestring($im, 1, 5, 5, $file->name, $text_color); + imagepng($im); + imagedestroy($im); + } +} + ?>
\ No newline at end of file |