/[mws]/trunk/httpd.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/httpd.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12 by dpavlin, Thu May 6 12:40:11 2004 UTC revision 13 by dpavlin, Thu May 6 16:53:40 2004 UTC
# Line 15  use MWS; Line 15  use MWS;
15  use Data::Dumper;  use Data::Dumper;
16    
17  my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;  my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;
 print "Please contact me at: <URL:", $d->url, ">\n";  
   
18  my $cgi = new CGI::Lite;  my $cgi = new CGI::Lite;
19  my $mws = MWS->new('global.conf');  my $mws = MWS->new('global.conf');
20  my $tt = Template->new({  my $tt = Template->new({
# Line 26  my $tt = Template->new({ Line 24  my $tt = Template->new({
24          },          },
25  });  });
26    
27    print "Web server ready at: ", $d->url, "\n";
28    
29    
30  while ( my $c = $d->accept ) {  while ( my $c = $d->accept ) {
31          while ( my $r = $c->get_request ) {          while ( my $r = $c->get_request ) {
# Line 82  while ( my $c = $d->accept ) { Line 82  while ( my $c = $d->accept ) {
82                          $param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'};                          $param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'};
83                  }                  }
84    
85                    my $tpl_var = {
86                            param   => $param
87                    };
88    
89                  # show search results                  # show search results
90                  # ?search=foo:bar                  # ?search=foo:bar
91                  if ($param->{'search'}) {                  if ($param->{'search'}) {
# Line 91  while ( my $c = $d->accept ) { Line 95  while ( my $c = $d->accept ) {
95                          my $results = $mws->search($param->{'search'});                          my $results = $mws->search($param->{'search'});
96                          my @res = $mws->fetch_all_results();                          my @res = $mws->fetch_all_results();
97    
98                          $tt->process($tpl_file, {                          $tpl_var->{results} = \@res;
99                                  query   => $param->{'search'},  
                                 results => \@res,  
                                 param   => $param,  
                         }, \$html) || die $tt->error();  
100    
101                  #                  #
102                  # ?show_id=XXXXxxxx___message_id___xxxxXXXX                  # ?show_id=XXXXxxxx___message_id___xxxxXXXX
103                  } elsif ($param->{'show_id'}) {                  } elsif ($param->{'show_id'}) {
104                                                    
105                          my $row = $mws->fetch_result_by_id($param->{'show_id'});                          my $row = $mws->fetch_result_by_id($param->{'show_id'});
106                          $tt->process($tpl_file, {                          $tpl_var->{message} = $row;
                                 message => $row,  
                         }, \$html) || die $tt->error();  
107                  }                  }
108    
109                    $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error();
110    
111                  #                  #
112                  # send HTMLto client                  # send HTMLto client
113                  #                  #
114    
115                  my $res = HTTP::Response->new(RC_OK);                  my $res = HTTP::Response->new(RC_OK);
116                  $res->header( 'Content-type' => 'text/html; charset=iso-8859-2' );                  $res->header( 'Content-type' => 'text/html; charset=UTF-8' );
117                  $res->content($html);                  $res->content($html);
118                  $c->send_response($res);                  $c->send_response($res);
119    

Legend:
Removed from v.12  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26