+
+ my $headers = $r->headers_out;
+ $headers->{'Cache-control'} = 'no-cache';
+ #$r->no_cache(1);
+ $headers->{'Expires'} = '0';
+
+# $r->send_http_header;
+
+ if ( $r->filename =~ /\/rt\// ) { #RT
+
+ FS::Trace->log('handling RT file');
+
+ # We don't need to handle non-text, non-xml items
+ return -1 if defined( $r->content_type )
+ && $r->content_type !~ m!(^text/|\bxml\b)!io;
+
+ local $SIG{__WARN__};
+ local $SIG{__DIE__};
+
+ FS::Trace->log('initializing RT');
+ my_rt_init();
+
+ FS::Trace->log('setting RT interpreter');
+ $ah->interp($rt_interp);
+
+ } else {
+
+ FS::Trace->log('handling Freeside file');
+
+ local $SIG{__WARN__};
+ local $SIG{__DIE__};
+
+ FS::Trace->log('initializing RT');
+ my_rt_init();
+
+ #we don't want the RT error handlers under FS
+ {
+ no warnings 'uninitialized';
+ undef($SIG{__WARN__}) if defined($SIG{__WARN__});
+ undef($SIG{__DIE__}) if defined($SIG{__DIE__} );
+ }
+
+ FS::Trace->log('setting Freeside interpreter');
+ $ah->interp($fs_interp);
+
+ }
+
+ FS::Trace->log('handling request');
+ my %session;
+ my $status;
+ eval { $status = $ah->handle_request($r); };
+#!!
+# if ( $@ ) {
+# $RT::Logger->crit($@);
+# }
+ warn $@ if $@;
+
+ undef %session;
+
+#!!
+# if ($RT::Handle->TransactionDepth) {
+# $RT::Handle->ForceRollback;
+# $RT::Logger->crit(
+#"Transaction not committed. Usually indicates a software fault. Data loss may have occurred"
+# );
+# }
+
+ FS::access_user_log->insert_new_path( $r->filename, time-$start_time );
+
+ FS::Trace->log('done');
+
+ FS::Trace->dumpfile( "%%%FREESIDE_EXPORT%%%/profile/$$.".time,
+ FS::Trace->total. ' '. $r->filename
+ )
+ if FS::Trace->total > 5; #10?
+
+ FS::Trace->reset;
+
+ $status;
+}
+
+sub my_rt_init {
+ return unless $RT::VERSION;
+ RT::ConnectToDatabase();
+ RT::InitSignalHandlers();