| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CGI::Portal; |
|
2
|
|
|
|
|
|
|
# Copyright (c) 2008 Alexander David P. All rights reserved. |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Create, run requested object and print |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
26656
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5852
|
use CGI; |
|
|
1
|
|
|
|
|
29354
|
|
|
|
1
|
|
|
|
|
8
|
|
|
9
|
1
|
|
|
1
|
|
629
|
use CGI::Portal::RDB; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
33
|
|
|
10
|
1
|
|
|
1
|
|
759
|
use CGI::Portal::Scripts::Header; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
26
|
|
|
11
|
1
|
|
|
1
|
|
564
|
use CGI::Portal::Scripts::Footer; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
12
|
1
|
|
|
1
|
|
5264
|
use HTML::Template; |
|
|
1
|
|
|
|
|
17460
|
|
|
|
1
|
|
|
|
|
46
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
13
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
545
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = "0.12"; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
1; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Create, run requested object and print |
|
21
|
|
|
|
|
|
|
sub activate { |
|
22
|
0
|
|
|
0
|
1
|
|
my $conf = shift; |
|
23
|
0
|
|
|
|
|
|
my $e; |
|
24
|
|
|
|
|
|
|
my $cl; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $cgi = new CGI(); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Get parameters |
|
29
|
0
|
|
|
|
|
|
my @v = $cgi->param; |
|
30
|
0
|
|
|
|
|
|
my %in; |
|
31
|
0
|
|
|
|
|
|
foreach my $f (@v){ |
|
32
|
0
|
|
|
|
|
|
my $v = $cgi->param($f); |
|
33
|
0
|
|
|
|
|
|
$v =~ s/<.*\r*\n*.*>//g; |
|
34
|
0
|
|
|
|
|
|
$in{$f} = $v; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Get a database handle |
|
38
|
0
|
|
|
|
|
|
my $rdb = CGI::Portal::RDB->new("DBI:$conf->{'database_type'}:database=$conf->{'database_name'};host=$conf->{'database_host'};", $conf->{'database_user'}, $conf->{'database_passw'}); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Reference to parameters, database handle, config |
|
41
|
0
|
|
|
|
|
|
my $i = {'in', \%in, |
|
42
|
|
|
|
|
|
|
'rdb', $rdb, |
|
43
|
|
|
|
|
|
|
'conf', $conf}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Get requested action or default |
|
46
|
0
|
|
|
|
|
|
my $c = $conf->{'actions'}[0]; |
|
47
|
0
|
|
|
|
|
|
foreach my $a (@{$conf->{'actions'}}) { |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ($in{'action'} eq $a) { |
|
49
|
0
|
|
|
|
|
|
$c = $a; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Use a control |
|
54
|
0
|
0
|
0
|
|
|
|
if ($in{'submit'} || $in{'Submit'}) { |
|
55
|
0
|
|
|
|
|
|
$cl = "CGI::Portal::Controls::$c"; |
|
56
|
0
|
|
|
|
|
|
eval "use $cl;"; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
# Use a script |
|
59
|
0
|
0
|
0
|
|
|
|
if ($@ || ! ($in{'submit'} || $in{'Submit'})) { |
|
|
|
|
0
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$cl = "CGI::Portal::Scripts::$c"; |
|
61
|
0
|
|
|
|
|
|
eval "use $cl;"; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Use default |
|
65
|
0
|
0
|
|
|
|
|
if ($@) { |
|
66
|
0
|
|
|
|
|
|
$cl = "CGI::Portal::Scripts::$conf->{'actions'}[0]"; |
|
67
|
0
|
|
|
|
|
|
eval "use $cl;"; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
# Create an object and run launch |
|
70
|
0
|
0
|
|
|
|
|
if (! $@) { |
|
71
|
0
|
|
|
|
|
|
$e = $cl->new($i); |
|
72
|
0
|
|
|
|
|
|
$e->launch; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Create header object and run launch |
|
76
|
0
|
|
|
|
|
|
my $header = CGI::Portal::Scripts::Header->new({ |
|
77
|
|
|
|
|
|
|
'in', \%in, |
|
78
|
|
|
|
|
|
|
'rdb', $rdb, |
|
79
|
|
|
|
|
|
|
'conf', $conf}); |
|
80
|
0
|
|
|
|
|
|
$header->launch($e); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Create footer object and run launch |
|
83
|
0
|
|
|
|
|
|
my $footer = CGI::Portal::Scripts::Footer->new({ |
|
84
|
|
|
|
|
|
|
'in', \%in, |
|
85
|
|
|
|
|
|
|
'rdb', $rdb, |
|
86
|
|
|
|
|
|
|
'conf', $conf}); |
|
87
|
0
|
|
|
|
|
|
$footer->launch($e); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Print |
|
90
|
0
|
|
|
|
|
|
print $e->{'cookies'}; |
|
91
|
0
|
|
|
|
|
|
print $cgi->header; |
|
92
|
0
|
|
|
|
|
|
print $header->{'out'}; |
|
93
|
0
|
|
|
|
|
|
print $e->{'out'}; |
|
94
|
0
|
|
|
|
|
|
print $footer->{'out'}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
CGI::Portal - MVC Framework for Multiuser Applications |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use CGI::Portal; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
CGI::Portal::activate({'database_type' => "mysql", |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
'database_name' => "some_name", |
|
108
|
|
|
|
|
|
|
'database_host' => "localhost", |
|
109
|
|
|
|
|
|
|
'database_user' => "some_user", |
|
110
|
|
|
|
|
|
|
'database_passw' => "some_password", |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
'user_table' => "users", |
|
113
|
|
|
|
|
|
|
'user_index_field' => "id", |
|
114
|
|
|
|
|
|
|
'user_user_field' => "user", |
|
115
|
|
|
|
|
|
|
'user_passw_field' => "passw", |
|
116
|
|
|
|
|
|
|
'user_additional' => ["email","first_name","middle_initial","last_name","city","state","country"], |
|
117
|
|
|
|
|
|
|
# at least: ["email"], |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
'session_table' => "sessions", |
|
120
|
|
|
|
|
|
|
'session_index_field' => "id", |
|
121
|
|
|
|
|
|
|
'session_sid_field' => "sid", |
|
122
|
|
|
|
|
|
|
'session_user_field' => "user", |
|
123
|
|
|
|
|
|
|
'session_start_field' => "session_start", |
|
124
|
|
|
|
|
|
|
'session_additional' => "", |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Accessible classes, the first is the default action |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
'actions' => ["logon", "logoff", "register", "profile", "changepw", "emailpw"], |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
'session_length' => 7200, |
|
132
|
|
|
|
|
|
|
'admin_email' => "some_user\@some_host.com", |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
'template_dir' => "templates/", # include trailing slash |
|
135
|
|
|
|
|
|
|
'header_html' => "header.html", |
|
136
|
|
|
|
|
|
|
'footer_html' => "footer.html", |
|
137
|
|
|
|
|
|
|
'logon_success_html' => "logon.html"}); |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
CGI::Portal is a MVC framework for the design of extensible, |
|
142
|
|
|
|
|
|
|
plug-configure-and-play multiuser web applications based on preferred object |
|
143
|
|
|
|
|
|
|
oriented coding standards. It provides authentication, session management, internal |
|
144
|
|
|
|
|
|
|
redirects and a modular architecture to build complex applications. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
It requires a database including a user and a sessions table, a collection of HTML::Template |
|
147
|
|
|
|
|
|
|
style templates and a properly configured startup script. To start with CGI::Portal you |
|
148
|
|
|
|
|
|
|
may want to install the provided templates at http://cgi-portal.sourceforge.net/ |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
All requests access through the startup script, and are handled by the class in |
|
151
|
|
|
|
|
|
|
the CGI::Portal::Scripts and CGI::Portal::Controls namespace that corresponds to the desired action. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
portal.cgi?action=foo calls CGI::Portal::Scripts::foo::launch() |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
portal.cgi?action=foo&Submit=1 calls CGI::Portal::Controls::foo::launch() |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 activate |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
CGI::Portal::activate($conf) takes a reference to the configuration hash, collects |
|
162
|
|
|
|
|
|
|
input parameters, creates a database object, and passes those on to your class |
|
163
|
|
|
|
|
|
|
for creating an object instance. It then runs your classes "launch" method and |
|
164
|
|
|
|
|
|
|
concludes by doing the printing for you. This function is called once from your |
|
165
|
|
|
|
|
|
|
startup script. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 BUILDING APPLICATIONS |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
See CGI::Portal::Scripts on Building Applications |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 INSTALLATION |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
perl Makefile.PL |
|
174
|
|
|
|
|
|
|
make |
|
175
|
|
|
|
|
|
|
make test |
|
176
|
|
|
|
|
|
|
make install |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Alexander David P |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |