--- loncom/metadata_database/Attic/lonsql.pm 2001/02/20 14:17:15 1.2 +++ loncom/metadata_database/Attic/lonsql.pm 2001/02/20 16:48:48 1.4 @@ -10,7 +10,7 @@ use Opcode; use Apache::lonnet; use Apache::Constants qw(:common :http); - +use CGI; # ================================================================ Main handler # @@ -20,10 +20,81 @@ use Apache::Constants qw(:common :http); sub handler { my $r=shift; + + if ($r->header_only) { + $r->content_type('text/html'); + $r->send_http_header; + return OK; + } + +# ------------------------------------------------------------------- Open page + + my $query=new CGI; + + my $searchquery; + my $searchresults; + my @regexps; + my $logic; + my $logic_operator; + + if ($query->{'SUBMIT'}) { + $logic_operator=$query->{'logic'}->[0]; + $searchquery="
Your search was:\n"; + $searchquery.="
$_: " . $query->{$_}->[0] . "\n" for ('title','author','subject','notes','abstract','mime','language','creationdate','lastrevisiondate','owner','copyright'); + for ('title','author','subject','notes','abstract','mime','language','creationdate','lastrevisiondate','owner','copyright') { + push @regexps, ($_ . " regexp '" . $query->{$_}->[0] . "'") if $query->{$_}->[0]; + } + $logic="where " . join(" $logic_operator ",@regexps) if @regexps; + } + my $sqlcommand="SELECT * FROM metadata $logic"; + $searchquery.="

SQL command: $sqlcommand

\n"; + + $r->content_type('text/html'); + $r->header_out('Cache-control','no-cache'); + $r->header_out('Pragma','no-cache'); + $r->send_http_header; my $output=<Test output message for lonsql.pm +

+

MySQL search engine

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
title
author
subject
notes
abstract
mime
language
creationdate
lastrevisiondate
owner
copyright
+ + +

+

+$searchquery +

+

+$searchresults +

END $r->print($output); return OK;