3 # Output the contents of a blob field
5 if (-r 'mysql-lib.pl') {
6 require './mysql-lib.pl';
9 require './postgresql-lib.pl';
11 require './view-lib.pl';
14 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
15 @str = &table_structure($in{'db'}, $in{'table'});
17 # Get search and limiting SQL
18 ($search, $searchhids, $searchargs) = &get_search_args(\%in);
19 $limitsql = &get_search_limit(\%in);
20 ($sortsql, $sorthids, $sortargs) = &get_search_sort(\%in);
22 $d = &execute_sql($in{'db'},
23 "select * from "."e_table($in{'table'})." $search $limitsql $sortsql");
25 # Work out the MIME type based on the data
26 $data = $d->{'data'}->[$in{'row'}]->[$in{'col'}];
27 if ($data =~ /^\s*(<!doctype|<html|<head|<title)/i) {
30 elsif ($data =~ /^GIF89/) {
33 elsif ($data =~ /^\377\330\377\340/) {
36 elsif ($data =~ /^%PDF/) {
37 $type = "application/pdf";
39 elsif ($data =~ /^[\040-\176\r\n\t]+$/) {
43 $type = "application/octet-stream";
45 print "Content-type: $type\n\n";