3 # This is a basic, fairly fuctional Mason handler.pl.
5 # For something a little more involved, check out session_handler.pl
9 # Bring in main Mason package.
12 # Bring in ApacheHandler, necessary for mod_perl integration.
13 # Uncomment the second line (and comment the first) to use
14 # Apache::Request instead of CGI.pm to parse arguments.
15 use HTML::Mason::ApacheHandler;
16 # use HTML::Mason::ApacheHandler (args_method=>'mod_perl');
18 # Uncomment the next line if you plan to use the Mason previewer.
19 #use HTML::Mason::Preview;
23 # List of modules that you want to use from components (see Admin
25 #{ package HTML::Mason::Commands;
29 # Create Mason objects
32 #my $parser = new HTML::Mason::Parser;
33 #my $interp = new HTML::Mason::Interp (parser=>$parser,
34 # comp_root=>'/var/www/masondocs',
35 # data_dir=>'/usr/local/etc/freeside/masondata',
38 my $ah = new HTML::Mason::ApacheHandler (
40 #auto_send_headers => 0,
41 comp_root=>'/var/www/freeside',
42 data_dir=>'/usr/local/etc/freeside/masondata',
46 # Activate the following if running httpd as root (the normal case).
47 # Resets ownership of all files created by Mason at startup.
49 #chown (Apache->server->uid, Apache->server->gid, $interp->files_written);
55 # If you plan to intermix images in the same directory as
56 # components, activate the following to prevent Mason from
57 # evaluating image files as components.
59 #return -1 if $r->content_type && $r->content_type !~ m|^text/|i;
62 { package HTML::Mason::Commands;
64 use vars qw( $cgi $p );
66 #use CGI::Carp qw(fatalsToBrowser);
74 use String::Approx qw(amatch);
75 use Chart::LinesPoints;
76 use HTML::Widgets::SelectLayers 0.02;
77 use FS::UID qw(cgisuidsetup dbh getotaker datasrc driver_name);
78 use FS::Record qw(qsearch qsearchs fields dbdef);
80 use FS::CGI qw(header menubar popurl table itable ntable idiot eidiot
81 small_custview myexit http_header);
82 use FS::Msgcat qw(gettext geterror);
86 use FS::domain_record;
88 use FS::cust_bill_pay;
90 use FS::cust_credit_bill;
92 use FS::cust_main_county;
98 use FS::part_bill_event;
100 use FS::part_referral;
102 use FS::part_svc_router;
103 use FS::part_virtual_field;
106 use FS::queue qw(joblisting);
110 use FS::svc_acct_pop qw(popselector);
116 use FS::svc_broadband;
117 use FS::svc_external;
120 use FS::part_export_option;
124 *CGI::redirect = sub {
125 my( $self, $location ) = @_;
128 if ( defined(@DBIx::Profile::ISA) ) { #profiling redirect
131 qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!.
133 ( UNIVERSAL::can(dbh, 'sprintProfile')
134 ? encode_entities(dbh->sprintProfile())
135 : 'DBIx::Profile missing sprintProfile method;'.
136 'unpatched or too old?' ).
137 #"\n\n". &sprintAutoProfile(). '</PRE>'.
140 dbh->{'private_profile'} = {};
143 } else { #normal redirect
145 $m->redirect($location);
163 my( $location ) = @_;
166 #false laziness w/above
167 if ( defined(@DBIx::Profile::ISA) ) { #profiling redirect
170 qq!<HTML><BODY>Redirect to <A HREF="$location">$location</A>!.
172 ( UNIVERSAL::can(dbh, 'sprintProfile')
173 ? encode_entities(dbh->sprintProfile())
174 : 'DBIx::Profile missing sprintProfile method;'.
175 'unpatched or too old?' ).
176 #"\n\n". &sprintAutoProfile(). '</PRE>'.
180 dbh->{'private_profile'} = {};
184 } else { #normal redirect
186 $m->redirect($location);
192 } # end package HTML::Mason::Commands;
194 $r->content_type('text/html');
197 my $headers = $r->headers_out;
198 $headers->{'Pragma'} = $headers->{'Cache-control'} = 'no-cache';
200 $headers->{'Expires'} = '0';
202 # $r->send_http_header;
204 my $status = $ah->handle_request($r);