line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Voodoo::Application::ConfigParser; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "3.0200"; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1781
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
6
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
71
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
14
|
use Apache::Voodoo::Constants; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
61
|
|
9
|
3
|
|
|
3
|
|
3764
|
use Config::General; |
|
3
|
|
|
|
|
93759
|
|
|
3
|
|
|
|
|
215
|
|
10
|
3
|
|
|
3
|
|
33
|
use File::Spec; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
61
|
|
11
|
3
|
|
|
3
|
|
4189
|
use Exception::Class::DBI; |
|
3
|
|
|
|
|
35024
|
|
|
3
|
|
|
|
|
3756
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
0
|
23654
|
my $class = shift; |
15
|
8
|
|
|
|
|
20
|
my $self = {}; |
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
|
|
18
|
bless $self, $class; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
|
|
31
|
$self->{'id'} = shift; |
20
|
8
|
|
66
|
|
|
58
|
$self->{'constants'} = shift || Apache::Voodoo::Constants->new(); |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
20
|
$self->{'conf_mtime'} = 0; |
23
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
34
|
$self->{'config'} = {}; |
25
|
8
|
|
|
|
|
19
|
$self->{'models'} = {}; |
26
|
8
|
|
|
|
|
19
|
$self->{'views'} = {}; |
27
|
8
|
|
|
|
|
15
|
$self->{'controllers'} = {}; |
28
|
8
|
|
|
|
|
22
|
$self->{'includes'} = {}; |
29
|
8
|
|
|
|
|
19
|
$self->{'template_conf'} = {}; |
30
|
|
|
|
|
|
|
|
31
|
8
|
100
|
|
|
|
23
|
if (defined($self->{'id'})) { |
32
|
7
|
|
|
|
|
36
|
$self->{'conf_file'} = File::Spec->catfile( |
33
|
|
|
|
|
|
|
$self->{constants}->install_path(), |
34
|
|
|
|
|
|
|
$self->{'id'}, |
35
|
|
|
|
|
|
|
$self->{constants}->conf_file() |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
1
|
|
|
|
|
15
|
die "ID is a required parameter."; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
7
|
|
|
|
|
32
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub changed { |
46
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
return $self->{'conf_mtime'} != (stat($self->{'conf_file'}))[9]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
6
|
0
|
36
|
sub old_ns { return $_[0]->{'old_ns'} }; |
52
|
27
|
|
|
27
|
0
|
170
|
sub config { return $_[0]->{'config'} }; |
53
|
6
|
|
|
6
|
0
|
31
|
sub models { return $_[0]->{'models'} }; |
54
|
6
|
|
|
6
|
0
|
26
|
sub views { return $_[0]->{'views'} }; |
55
|
6
|
|
|
6
|
0
|
27
|
sub controllers { return $_[0]->{'controllers'} }; |
56
|
6
|
|
|
6
|
0
|
22
|
sub includes { return $_[0]->{'includes'} }; |
57
|
0
|
|
|
0
|
0
|
0
|
sub template_conf { return $_[0]->{'template_conf'} }; |
58
|
0
|
|
|
0
|
0
|
0
|
sub databases { return $_[0]->{'dbs'} }; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub parse { |
61
|
6
|
|
|
6
|
0
|
401
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
|
|
69
|
my $conf = Config::General->new( |
64
|
|
|
|
|
|
|
'-ConfigFile' => $self->{'conf_file'}, |
65
|
|
|
|
|
|
|
'-IncludeRelative' => 1, |
66
|
|
|
|
|
|
|
'-UseApacheInclude' => 1, |
67
|
|
|
|
|
|
|
'-IncludeAgain' => 1 |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
6
|
|
|
|
|
11207
|
my %conf = $conf->getall(); |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
84
|
$conf{'id'} = $self->{'id'}; |
73
|
|
|
|
|
|
|
|
74
|
6
|
|
66
|
|
|
38
|
$conf{'base_package'} ||= $self->{'id'}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# PCI says that sessions should expire after 15 minutes, this should be a sane default |
77
|
6
|
100
|
66
|
|
|
40
|
$conf{'session_timeout'} = (defined($conf{'session_timeout'}) && $conf{'session_timeout'} =~ /^\d+$/)?$conf{'session_timeout'}:900; |
78
|
|
|
|
|
|
|
|
79
|
6
|
100
|
66
|
|
|
36
|
$conf{'upload_size_max'} = (defined($conf{'upload_size_max'}) && $conf{'upload_size_max'} =~ /^\d+$/)?$conf{'upload_size_max'}:5242880; |
80
|
|
|
|
|
|
|
|
81
|
6
|
|
66
|
|
|
35
|
$conf{'cookie_name'} ||= uc($self->{'id'}). "_SID"; |
82
|
|
|
|
|
|
|
|
83
|
6
|
100
|
|
|
|
21
|
$conf{'https_cookies'} = ($conf{'https_cookies'})?1:0; |
84
|
|
|
|
|
|
|
|
85
|
6
|
|
50
|
|
|
31
|
$conf{'template_opts'} ||= {}; |
86
|
|
|
|
|
|
|
|
87
|
6
|
|
|
|
|
27
|
$conf{'template_dir'} = File::Spec->catfile( |
88
|
|
|
|
|
|
|
$self->{'constants'}->install_path(), |
89
|
|
|
|
|
|
|
$self->{'id'}, |
90
|
|
|
|
|
|
|
$self->{'constants'}->tmpl_path() |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
6
|
|
100
|
|
|
33
|
$conf{'logout_target'} ||= "/index"; |
94
|
|
|
|
|
|
|
|
95
|
6
|
100
|
|
|
|
15
|
if (defined($conf{'devel_mode'})) { |
96
|
2
|
50
|
|
|
|
8
|
if ($conf{'devel_mode'}) { |
97
|
2
|
|
|
|
|
5
|
$conf{'devel_mode'} = 1; |
98
|
2
|
|
|
|
|
9
|
$conf{'dynamic_loading'} = 1; |
99
|
2
|
|
|
|
|
5
|
$conf{'halt_on_errors'} = 0; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
0
|
|
|
|
|
0
|
$conf{'devel_mode'} = 0; |
103
|
0
|
|
|
|
|
0
|
$conf{'dynamic_loading'} = 0; |
104
|
0
|
|
|
|
|
0
|
$conf{'halt_on_errors'} = 1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
else { |
108
|
4
|
|
|
|
|
10
|
$conf{'devel_mode'} = 0; |
109
|
4
|
|
100
|
|
|
19
|
$conf{'dynamic_loading'} = $conf{'dynamic_loading'} || 0; |
110
|
4
|
100
|
|
|
|
15
|
$conf{'halt_on_errors'} = defined($conf{'halt_on_errors'})?$conf{'halt_on_errors'}:1; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
6
|
100
|
|
|
|
16
|
if ($conf{'dynamic_loading'}) { |
114
|
4
|
|
|
|
|
122
|
$self->{'conf_mtime'} = (stat($self->{'conf_file'}))[9]; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
6
|
100
|
|
|
|
38
|
if (defined($conf{'database'})) { |
118
|
4
|
|
|
|
|
7
|
my $db; |
119
|
4
|
100
|
|
|
|
15
|
if (ref($conf{'database'}) eq "ARRAY") { |
120
|
2
|
|
|
|
|
5
|
$db = $conf{'database'}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else { |
123
|
2
|
|
|
|
|
8
|
$db = [ $conf{'database'} ]; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# make the connect string a perl array ref |
127
|
|
|
|
|
|
|
$self->{'dbs'} = [ |
128
|
|
|
|
|
|
|
map { |
129
|
6
|
100
|
|
|
|
22
|
unless (ref ($_->{'extra'}) eq "HASH") { |
|
4
|
|
|
|
|
9
|
|
130
|
4
|
|
|
|
|
9
|
$_->{'extra'} = {}; |
131
|
|
|
|
|
|
|
} |
132
|
6
|
|
|
|
|
14
|
$_->{'extra'}->{PrintError} = 0; |
133
|
6
|
|
|
|
|
22
|
$_->{'extra'}->{RaiseError} = 0; |
134
|
6
|
|
|
|
|
52
|
$_->{'extra'}->{HandleError} = Exception::Class::DBI->handler; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
[ |
137
|
6
|
|
|
|
|
300
|
$_->{'connect'}, |
138
|
|
|
|
|
|
|
$_->{'username'}, |
139
|
|
|
|
|
|
|
$_->{'password'}, |
140
|
|
|
|
|
|
|
$_->{'extra'} |
141
|
|
|
|
|
|
|
] |
142
|
4
|
|
|
|
|
9
|
} @{$db} |
143
|
|
|
|
|
|
|
]; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else { |
146
|
2
|
|
|
|
|
5
|
$self->{'dbs'} = []; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
6
|
|
100
|
|
|
35
|
$self->{'models'} = $conf{'models'} || {}; |
150
|
6
|
|
100
|
|
|
32
|
$self->{'views'} = $conf{'views'} || {}; |
151
|
6
|
|
100
|
|
|
30
|
$self->{'includes'} = $conf{'includes'} || {}; |
152
|
|
|
|
|
|
|
|
153
|
6
|
|
|
|
|
14
|
$self->{'old_ns'} = 0; |
154
|
6
|
100
|
|
|
|
21
|
if ($conf{'controllers'}) { |
|
|
100
|
|
|
|
|
|
155
|
2
|
|
|
|
|
5
|
$self->{'controllers'} = $conf{'controllers'}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
elsif ($conf{'modules'}) { |
158
|
2
|
|
|
|
|
6
|
$self->{'controllers'} = $conf{'modules'}; |
159
|
2
|
|
|
|
|
4
|
$self->{'old_ns'} = 1; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
else { |
162
|
2
|
|
|
|
|
5
|
$self->{'controllers'} = {}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
6
|
|
|
|
|
14
|
delete $conf{'models'}; |
166
|
6
|
|
|
|
|
11
|
delete $conf{'views'}; |
167
|
6
|
|
|
|
|
10
|
delete $conf{'controllers'}; |
168
|
6
|
|
|
|
|
10
|
delete $conf{'modules'}; |
169
|
6
|
|
|
|
|
8
|
delete $conf{'includes'}; |
170
|
|
|
|
|
|
|
|
171
|
6
|
|
100
|
|
|
35
|
$self->{'template_conf'} = $conf{'template_conf'} || {}; |
172
|
6
|
|
|
|
|
14
|
delete $conf{'template_conf'}; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# make a dummy entry for default if it doesn't exists, |
175
|
|
|
|
|
|
|
# this saves an if(defined blah blah) on every page request. |
176
|
6
|
100
|
|
|
|
24
|
unless (defined($self->{'template_conf'}->{'default'})) { |
177
|
4
|
|
|
|
|
12
|
$self->{'template_conf'}->{'default'} = {}; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# merge in the default block to each of the others now so that we don't have to |
181
|
|
|
|
|
|
|
# do it at page request time. |
182
|
6
|
|
|
|
|
10
|
foreach my $key (grep {$_ ne 'default'} keys %{$self->{'template_conf'}}) { |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
21
|
|
183
|
0
|
|
|
|
|
0
|
$self->{'template_conf'}->{$key} = { |
184
|
0
|
|
|
|
|
0
|
%{$self->{'template_conf'}->{'default'}}, |
185
|
0
|
|
|
|
|
0
|
%{$self->{'template_conf'}->{$key}} |
186
|
|
|
|
|
|
|
}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# |
190
|
|
|
|
|
|
|
# Theme support |
191
|
|
|
|
|
|
|
# |
192
|
6
|
50
|
66
|
|
|
42
|
if (defined($conf{'themes'}) && $conf{'themes'}->{'use_themes'} == 1) { |
193
|
0
|
0
|
|
|
|
0
|
unless (scalar(@{$conf{'themes'}->{'theme'}})) { |
|
0
|
|
|
|
|
0
|
|
194
|
0
|
|
|
|
|
0
|
$self->{'errors'}++; |
195
|
0
|
|
|
|
|
0
|
warn "You must define at least one theme block\n"; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
6
|
|
|
|
|
110
|
$self->{config} = \%conf; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
################################################################################ |
206
|
|
|
|
|
|
|
# Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). |
207
|
|
|
|
|
|
|
# All rights reserved. |
208
|
|
|
|
|
|
|
# |
209
|
|
|
|
|
|
|
# You may use and distribute Apache::Voodoo under the terms described in the |
210
|
|
|
|
|
|
|
# LICENSE file include in this package. The summary is it's a legalese version |
211
|
|
|
|
|
|
|
# of the Artistic License :) |
212
|
|
|
|
|
|
|
# |
213
|
|
|
|
|
|
|
################################################################################ |