line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Portal::Scripts; |
2
|
|
|
|
|
|
|
# Copyright (c) 2008 Alexander David P. All rights reserved. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Extend this class to add useful attributes and functions |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
525
|
use CGI::Portal::Sessions; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
94
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = "0.12"; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@ISA = qw(CGI::Portal::Sessions); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
1; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
CGI::Portal::Scripts - Building Applications |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package CGI::Portal::Scripts::some_name; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use CGI::Portal::Scripts; |
27
|
|
|
|
|
|
|
use vars qw(@ISA); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
@ISA = qw(CGI::Portal::Scripts); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub launch { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
.... |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Internal Redirects |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
package CGI::Portal::Scripts::some_name; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use CGI::Portal::Scripts; |
43
|
|
|
|
|
|
|
use CGI::Portal::Scripts::other_name; |
44
|
|
|
|
|
|
|
use vars qw(@ISA); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
@ISA = qw(CGI::Portal::Scripts); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub launch { |
51
|
|
|
|
|
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
.... |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$self->CGI::Portal::Scripts::other_name::launch; |
55
|
|
|
|
|
|
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
CGI::Portal applications are build by creating classes that reside in the |
61
|
|
|
|
|
|
|
CGI::Portal::Scripts and CGI::Portal::Controls namespaces and extend CGI::Portal::Scripts. These classes |
62
|
|
|
|
|
|
|
must provide a subroutine launch() that CGI::Portal calls as an object method to |
63
|
|
|
|
|
|
|
run your code. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Classes in the CGI::Portal::Scripts handle the assembly of pages, classes in the CGI::Portal::Controls |
66
|
|
|
|
|
|
|
namespace handle form submissions. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
CGI::Portal::Controls are called by providing input parameter "Submit" or "submit" |
69
|
|
|
|
|
|
|
and should provide internal redirects to call a CGI::Portal::Scripts class. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
In your classes, do not print() or exit(). Instead of "print"ing append to $self->{'out'} |
72
|
|
|
|
|
|
|
or $self->{'cookies'} and instead of "exit"ing, "return" from launch(). |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Extending CGI::Portal::Scripts, gives you access to an object with the following attributes. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 conf |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$self->{'conf'} references a hash containing all values as set in the startup script. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 in |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->{'in'} references a hash containing all input parameters, stripped off any HTML tags. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 user |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->{'user'} is set by $self->authenticate_user() if logon succeeds. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 rdb |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->{'rdb'} is a CGI::Portal::RDB database object holding a database handle. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 out |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$self->{'out'} supposed to collect all output. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 cookies |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$self->{'cookies'} collects cookie headers you might want to set. It is also used for |
101
|
|
|
|
|
|
|
Sessions, so you might want to append to it. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 FUNCTIONS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 authenticate_user |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$self->authenticate_user() takes no arguments and does not return anything. It sets |
108
|
|
|
|
|
|
|
$self->{'user'} and starts a session if user logon succeeds. If user logon fails |
109
|
|
|
|
|
|
|
it writes the HTML for a logon form to $self->{'out'}. It also maintains the sessions |
110
|
|
|
|
|
|
|
during subsequent calls. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$self->authenticate_user(); |
113
|
|
|
|
|
|
|
return unless $self->{'user'}; |
114
|
|
|
|
|
|
|
.... |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 logoff |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$self->logoff() takes no arguments and does not return anything. It removes the current |
119
|
|
|
|
|
|
|
users session id from the database and unsets the session cookie. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 RDB->exec |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$self->{'rdb'}->exec($sql) is an object method for the database object. It takes a SQL |
124
|
|
|
|
|
|
|
statement as argument and returns a DBI statement handle. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The database handle can be directly retrieved from $self->{'rdb'}{'dbh'}. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 RDB->escape |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$self->{'rdb'}->escape(@values) takes an array of SQL values. It uses DBI's quote() on those |
131
|
|
|
|
|
|
|
values and returns them as a string seperated by commas. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Alexander David P |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |