summaryrefslogtreecommitdiff
path: root/forum/utils/file.php
diff options
context:
space:
mode:
authordeva <deva>2008-10-12 16:02:03 +0000
committerdeva <deva>2008-10-12 16:02:03 +0000
commit28856d6f9b7d726b1681df9384f3ef000dbf6f4c (patch)
tree4297943b1d5656ee2b0c01d3aabac5ddb414d45d /forum/utils/file.php
parented97119bc3a7203b11d92cf170869a12bd2da953 (diff)
Made file preview (original image or png with filename as text). Added error image as png with error text.
Diffstat (limited to 'forum/utils/file.php')
-rw-r--r--forum/utils/file.php26
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