- web interface for hourly account charges!
[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 FS::UID qw(cgisuidsetup);
65       use FS::Record qw(qsearch qsearchs fields);
66       use FS::part_svc;
67       use FS::part_pkg;
68       use FS::pkg_svc;
69       use FS::cust_pkg;
70       use FS::cust_svc;
71       use FS::part_bill_event;
72       use FS::CGI qw(header menubar popurl table itable ntable);
73
74       $cgi = new CGI;
75       &cgisuidsetup($cgi);
76       #&cgisuidsetup($r);
77       $p = popurl(2);
78     }
79     $r->content_type('text/html');
80     #eorar
81
82     # @FS::CGI::headers or some other way to set no-cache headers!!!
83     
84     my $status = $ah->handle_request($r);
85     
86     return $status;
87 }
88
89 1;