pro-rating w/ web interface, tested (closes: Bug#313).
[freeside.git] / htetc / handler.pl
1 #!/usr/bin/perl
2 #
3 # This is a basic, fairly fuctional Mason handler.pl.
4 #
5 # For something a little more involved, check out session_handler.pl
6
7 package HTML::Mason;
8
9 # Bring in main Mason package.
10 use HTML::Mason;
11
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');
17
18 # Uncomment the next line if you plan to use the Mason previewer.
19 #use HTML::Mason::Preview;
20
21 use strict;
22
23 # List of modules that you want to use from components (see Admin
24 # manual for details)
25 #{  package HTML::Mason::Commands;
26 #   use CGI;
27 #}
28
29 # Create Mason objects
30 #
31 my $parser = new HTML::Mason::Parser;
32 my $interp = new HTML::Mason::Interp (parser=>$parser,
33                                       comp_root=>'/var/www/masondocs',
34                                       data_dir=>'/home/ivan/freeside_current/masondata',
35                                       out_mode=>'stream',
36                                      );
37 my $ah = new HTML::Mason::ApacheHandler (interp=>$interp);
38
39 # Activate the following if running httpd as root (the normal case).
40 # Resets ownership of all files created by Mason at startup.
41 #
42 chown (Apache->server->uid, Apache->server->gid, $interp->files_written);
43
44 sub handler
45 {
46     my ($r) = @_;
47
48     # If you plan to intermix images in the same directory as
49     # components, activate the following to prevent Mason from
50     # evaluating image files as components.
51     #
52     #return -1 if $r->content_type && $r->content_type !~ m|^text/|i;
53
54     #rar
55     { package HTML::Mason::Commands;
56       use strict;
57       use vars qw( $cgi $p );
58       use CGI;
59       #use CGI::Carp qw(fatalsToBrowser);
60       use Date::Format;
61       use Date::Parse;
62       use Tie::IxHash;
63       use HTML::Entities;
64       use IO::Handle;
65       use IO::File;
66       use String::Approx qw(amatch);
67       use FS::UID qw(cgisuidsetup dbh getotaker datasrc);
68       use FS::Record qw(qsearch qsearchs fields dbdef);
69       use FS::Conf;
70       use FS::CGI qw(header menubar popurl table itable ntable idiot eidiot
71                      small_custview myexit);
72
73       use FS::agent;
74       use FS::agent_type;
75       use FS::domain_record;
76       use FS::cust_bill;
77       use FS::cust_bill_pay;
78       use FS::cust_credit;
79       use FS::cust_credit_bill;
80       use FS::cust_main;
81       use FS::cust_main_county;
82       use FS::cust_pay;
83       use FS::cust_pkg;
84       use FS::cust_refund;
85       use FS::cust_svc;
86       use FS::nas;
87       use FS::part_bill_event;
88       use FS::part_pkg;
89       use FS::part_referral;
90       use FS::part_svc;
91       use FS::pkg_svc;
92       use FS::port;
93       use FS::queue;
94       use FS::raddb;
95       use FS::session;
96       use FS::svc_acct;
97       use FS::svc_acct_pop qw(popselector);
98       use FS::svc_acct_sm;
99       use FS::svc_domain;
100       use FS::svc_forward;
101       use FS::svc_www;
102       use FS::type_pkgs;
103
104       $cgi = new CGI;
105       &cgisuidsetup($cgi);
106       #&cgisuidsetup($r);
107       $p = popurl(2);
108     }
109     $r->content_type('text/html');
110     #eorar
111
112     my $headers = $r->headers_out;
113     $headers->{'Pragma'} = $headers->{'Cache-control'} = 'no-cache';
114     #$r->no_cache(1);
115     $headers->{'Expires'} = '0';
116     
117     my $status = $ah->handle_request($r);
118     
119     return $status;
120 }
121
122 1;