-
- if($result && ref($result) && $result->{'format'} && $result->{'content'}
- && $result->{'format'} eq 'csv') {
- print $cgi->header('-expires' => 'now',
- '-Content-Type' => 'text/csv',
- '-Content-Disposition' => "attachment;filename=output.csv",
- ),
- $result->{'content'};
- }
- elsif($result && ref($result) && $result->{'format'} && $result->{'content'}
- && $result->{'format'} eq 'xls') {
- print $cgi->header('-expires' => 'now',
- '-Content-Type' => 'application/vnd.ms-excel',
- '-Content-Disposition' => "attachment;filename=output.xls",
- '-Content-Length' => length($result->{'content'}),
- ),
- $result->{'content'};
- }
- elsif($result && ref($result) && $result->{'format'} && $result->{'content'}
- && $result->{'format'} eq 'png') {
- print $cgi->header('-expires' => 'now',
- '-Content-Type' => 'image/png',
- ),
- $result->{'content'};
- }
- else {
- my $source = "$template_dir/$name.html";
- my $template = new Text::Template( TYPE => 'FILE',
- SOURCE => $source,
- DELIMITERS => [ '<%=', '%>' ],
- UNTAINT => 1,
- )
- or die $Text::Template::ERROR;
-
- my $data = $template->fill_in(
- PACKAGE => 'FS::SelfService::_selfservicecgi',
- HASH => $fill_in,
- ) || "Error processing template $source"; # at least print _something_
- print $cgi->header( '-expires' => 'now' );
- print $data;
+ # update the user's authentication
+ my $timeout = $access_info->{'timeout'} || '60';
+ my $cookie = CGI::Cookie->new('-name' => 'session',
+ '-value' => $session_id,
+ '-expires' => '+'.$timeout,
+ #'-secure' => 1, # would be a good idea...
+ );
+ if ( $name eq 'logout' ) {
+ $cookie->expires(0);
+ }
+
+ if ( $fill_in->{'format'} ) {
+ # then override content-type, and return $fill_in->{'content'} instead
+ # of filling in a template
+ if ( $fill_in->{'format'} eq 'csv') {
+ print $cgi->header('-expires' => 'now',
+ '-Content-Type' => 'text/csv',
+ '-Content-Disposition' => "attachment;filename=output.csv",
+ );
+ } elsif ( $fill_in->{'format'} eq 'xls' ) {
+ print $cgi->header('-expires' => 'now',
+ '-Content-Type' => 'application/vnd.ms-excel',
+ '-Content-Disposition' => "attachment;filename=output.xls",
+ '-Content-Length' => length($fill_in->{'content'}),
+ );
+ } elsif ( $fill_in->{'format'} eq 'png' ) {
+ print $cgi->header('-expires' => 'now',
+ '-Content-Type' => 'image/png',
+ );