import rt 3.2.2
[freeside.git] / rt / html / NoAuth / images / autohandler
diff --git a/rt/html/NoAuth/images/autohandler b/rt/html/NoAuth/images/autohandler
new file mode 100644 (file)
index 0000000..86f3b22
--- /dev/null
@@ -0,0 +1,21 @@
+<%init>
+
+# This autohandler will spit out RT's images if the user hasn't 
+# properly configured their webserver to stop RT from passing 
+# images through the mason handler.
+
+my $file = $m->base_comp->source_file;
+my $type = "application/octet-stream";
+
+if ($file =~ /\.(gif|png|jpe?g)$/i) {
+    $type = "image/$1";
+    $type =~ s/jpg/jpeg/gi;
+}
+
+die unless (-f $file && -r $file);
+$r->content_type($type);
+open (FILE, "<$file") || die;
+$m->out($_) while (<FILE>);
+close(FILE);
+$m->abort;
+</%init>