line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Nes by Skriptke |
5
|
|
|
|
|
|
|
# Copyright 2009 - 2010 Enrique F. Castañón Barbero |
6
|
|
|
|
|
|
|
# Licensed under the GNU GPL. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# CPAN: |
9
|
|
|
|
|
|
|
# http://search.cpan.org/dist/Nes/ |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Sample: |
12
|
|
|
|
|
|
|
# http://nes.sourceforge.net/ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Repository: |
15
|
|
|
|
|
|
|
# http://github.com/Skriptke/nes |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# Version 1.04 |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# Nes.pm |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Nes; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
3
|
|
88852
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
124
|
|
26
|
|
|
|
|
|
|
#use warnings; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# cgi environment no defined in command line |
29
|
3
|
|
|
3
|
|
16
|
no warnings 'uninitialized'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
548
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '1.03.4_1'; |
32
|
|
|
|
|
|
|
our $CRLF = "\015\012"; |
33
|
|
|
|
|
|
|
our $MAX_INTERACTIONS = 900; |
34
|
|
|
|
|
|
|
our $MAX_SCRIPTS = 900; |
35
|
|
|
|
|
|
|
our $MOD_PERL = $ENV{'MOD_PERL'} || 0; |
36
|
|
|
|
|
|
|
our $MOD_PERL1 = $MOD_PERL =~ /mod_perl\/1/ || 0; |
37
|
|
|
|
|
|
|
our $MOD_PERL2 = $MOD_PERL =~ /mod_perl\/2/ || 0; |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
3
|
|
1741
|
use Nes::Tags; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
83
|
|
40
|
3
|
|
|
3
|
|
1823
|
use Nes::Setting; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
96
|
|
41
|
3
|
|
|
3
|
|
1646
|
use Nes::Singleton; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
2017
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %instance; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
10
|
|
|
10
|
0
|
17
|
my $class = shift; |
47
|
10
|
|
|
|
|
25
|
my $self = bless {}, $class; |
48
|
10
|
|
|
|
|
43
|
$self->{'previous'} = $class->get_obj(); |
49
|
10
|
|
|
|
|
103
|
$instance{$class} = $self; |
50
|
|
|
|
|
|
|
|
51
|
10
|
|
|
|
|
20
|
$self->{'tag_start'} = $Nes::Tags::start; |
52
|
10
|
|
|
|
|
19
|
$self->{'tag_end'} = $Nes::Tags::end; |
53
|
10
|
|
|
|
|
17
|
$self->{'pre_start'} = $Nes::Tags::pre_start; |
54
|
10
|
|
|
|
|
17
|
$self->{'pre_end'} = $Nes::Tags::pre_end; |
55
|
|
|
|
|
|
|
|
56
|
10
|
|
|
|
|
19
|
$self->{'tag_nes'} = $Nes::Tags::nes; |
57
|
|
|
|
|
|
|
|
58
|
10
|
|
|
|
|
16
|
$self->{'tag_var'} = $Nes::Tags::var; |
59
|
10
|
|
|
|
|
23
|
$self->{'tag_env'} = $Nes::Tags::env ; |
60
|
10
|
|
|
|
|
22
|
$self->{'tag_expre'} = $Nes::Tags::expre; |
61
|
10
|
|
|
|
|
18
|
$self->{'tag_tpl'} = $Nes::Tags::tpl; |
62
|
10
|
|
|
|
|
16
|
$self->{'tag_sql'} = $Nes::Tags::sql; |
63
|
10
|
|
|
|
|
19
|
$self->{'tag_hash'} = $Nes::Tags::hash; |
64
|
10
|
|
|
|
|
18
|
$self->{'tag_field'} = $Nes::Tags::field; |
65
|
10
|
|
|
|
|
17
|
$self->{'tag_include'} = $Nes::Tags::include; |
66
|
10
|
|
|
|
|
16
|
$self->{'tag_comment'} = $Nes::Tags::comment; |
67
|
10
|
|
|
|
|
26
|
$self->{'tag_plugin'} = $Nes::Tags::plugin; |
68
|
|
|
|
|
|
|
|
69
|
10
|
|
|
|
|
16
|
$self->{'pre_subs_start'} = $Nes::Tags::pre_subs_start; |
70
|
10
|
|
|
|
|
17
|
$self->{'pre_subs_end'} = $Nes::Tags::pre_subs_end; |
71
|
|
|
|
|
|
|
|
72
|
10
|
|
|
|
|
41
|
$self->{'top_container'} = nes_top_container->get_obj(); |
73
|
10
|
|
|
|
|
47
|
$self->{'CFG'} = Nes::Setting->get_obj(); |
74
|
10
|
|
|
|
|
43
|
$self->{'cookies'} = nes_cookie->get_obj(); |
75
|
10
|
|
|
|
|
42
|
$self->{'session'} = nes_session->get_obj(); |
76
|
10
|
|
|
|
|
38
|
$self->{'query'} = nes_query->get_obj(); |
77
|
10
|
|
|
|
|
36
|
$self->{'container'} = nes_container->get_obj(); |
78
|
10
|
|
|
|
|
44
|
$self->{'register'} = nes_register->get_obj(); |
79
|
10
|
|
66
|
|
|
30
|
$self->{'nes'} = $instance{'nes_top_container'} || $self; |
80
|
10
|
|
|
|
|
47
|
$self->{'MAX_INTERACTIONS'} = $MAX_INTERACTIONS; |
81
|
10
|
|
|
|
|
17
|
$self->{'MAX_SCRIPTS'} = $MAX_SCRIPTS; |
82
|
|
|
|
|
|
|
|
83
|
10
|
|
|
|
|
21
|
return $self; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub VERSION { |
87
|
1
|
|
|
1
|
0
|
4
|
return $VERSION; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub get_obj { |
91
|
74
|
|
|
74
|
0
|
101
|
my $self = shift; |
92
|
74
|
|
|
|
|
229
|
my $class = ref($self); |
93
|
|
|
|
|
|
|
|
94
|
74
|
50
|
|
|
|
171
|
$self = $instance{$self} if !$class; |
95
|
|
|
|
|
|
|
|
96
|
74
|
|
|
|
|
348
|
return $self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub forget { |
100
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
101
|
0
|
|
|
|
|
0
|
my $class = ref($self); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
$instance{$class} = $self->{'previous'}; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
return $instance{$class}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_key { |
109
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
110
|
0
|
|
|
|
|
0
|
my ($max) = @_; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
0
|
my @kletters = @{ $self->{'CFG'}{'kletters'} }; |
|
0
|
|
|
|
|
0
|
|
113
|
0
|
|
|
|
|
0
|
my @kletnum = @{ $self->{'CFG'}{'kletnum'} }; |
|
0
|
|
|
|
|
0
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# siempre comienza por letra por si se usa como nombre de variable o campo |
116
|
0
|
|
|
|
|
0
|
my $key = $kletters[ int( rand( $#kletters + 1 ) ) ]; |
117
|
0
|
|
|
|
|
0
|
for ( 1 .. ( $max - 1 ) ) { |
118
|
0
|
|
|
|
|
0
|
$key .= $kletnum[ int( rand( $#kletnum + 1 ) ) ]; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
0
|
return $key; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub cleanup { |
125
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
126
|
|
|
|
|
|
|
|
127
|
1
|
50
|
|
|
|
4
|
utl::cleanup(\%instance) if $ENV{'MOD_PERL'}; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
{ |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
package nes_tmp; |
135
|
3
|
|
|
3
|
|
26
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2896
|
|
136
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub new { |
139
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
140
|
0
|
|
|
|
|
0
|
my ($suffix,$name,$id) = @_; |
141
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new(); |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
0
|
$self->{'suffix'} = $suffix; |
144
|
0
|
|
|
|
|
0
|
$self->{'tmp_suffix'} = $self->{'CFG'}{'tmp_suffix'}; |
145
|
0
|
|
|
|
|
0
|
$self->{'name'} = $self->get_name($name,$id); |
146
|
0
|
|
|
|
|
0
|
$self->{'tmp_dir'} = $self->{'CFG'}{'tmp_dir'}; |
147
|
0
|
|
|
|
|
0
|
$self->{'file'} = $self->{'tmp_dir'}.'/'.$self->{'name'}; |
148
|
0
|
|
|
|
|
0
|
$self->{'expired'} = utl::expires_time($self->{'CFG'}{'tmp_clear'}); |
149
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
0
|
$self->clear_expired if $self->{'CFG'}{'tmp_clear'}; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
0
|
return $self; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub clear_expired { |
156
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# borra de vez en cuando los temporales ( 1 de cada rand x veces ) |
159
|
|
|
|
|
|
|
# si hay muchos puede ser lento, sólo será lento una de cada rand x veces |
160
|
0
|
0
|
|
|
|
0
|
return if 1 < (rand 100); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# -------------------------------------------------------------------------- |
163
|
|
|
|
|
|
|
# si por error en el archivo de configuración se hace: tmp_dir = '/' |
164
|
|
|
|
|
|
|
# podía ser desastroso... de ahí tantas comprobaciones antes de borrar |
165
|
|
|
|
|
|
|
# Indicar 0 en tmp_clear del archivo de configuración para no borrar nunca. |
166
|
|
|
|
|
|
|
# -------------------------------------------------------------------------- |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# nos aseguramos que tmp_dir tiene valor |
169
|
|
|
|
|
|
|
# la ruta más corta es /tmp |
170
|
0
|
0
|
|
|
|
0
|
return if length $self->{'tmp_dir'} < 4; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# nos aseguramos que tmp_suffix tiene valor |
173
|
0
|
0
|
|
|
|
0
|
return if length $self->{'tmp_suffix'} < 4; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
opendir(DIR,$self->{'tmp_dir'}); |
176
|
0
|
|
|
|
|
0
|
foreach my $file (readdir(DIR)) { |
177
|
0
|
0
|
|
|
|
0
|
if ( $file =~ /$self->{'tmp_suffix'}$/ ) { |
178
|
|
|
|
|
|
|
# nos aseguramos que sea un archivo temporal |
179
|
0
|
0
|
|
|
|
0
|
next if $file !~ /tmp/; |
180
|
0
|
|
|
|
|
0
|
my $last_mod = (stat ($self->{'tmp_dir'}.'/'.$file))[10]; |
181
|
0
|
0
|
|
|
|
0
|
unlink($self->{'tmp_dir'}.'/'.$file) if ( (time - $last_mod) > $self->{'expired'} ); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} |
185
|
0
|
|
|
|
|
0
|
closedir DIR; |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
0
|
return; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub save { |
191
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
192
|
0
|
|
|
|
|
0
|
my ($data) = @_; |
193
|
|
|
|
|
|
|
|
194
|
0
|
0
|
|
|
|
0
|
if ( ! -d $self->{'tmp_dir'} ) { |
195
|
0
|
|
|
|
|
0
|
my @level = split('/',$self->{'tmp_dir'}); |
196
|
0
|
|
|
|
|
0
|
my $dir; |
197
|
0
|
|
|
|
|
0
|
foreach my $this_level ( @level ) { |
198
|
0
|
|
|
|
|
0
|
$dir .= '/'.$this_level; |
199
|
0
|
0
|
|
|
|
0
|
mkdir $dir if ! -d $dir; |
200
|
0
|
0
|
|
|
|
0
|
if ( ! -d $dir ) { |
201
|
0
|
|
|
|
|
0
|
warn "Can't create tmp dir : $dir"; |
202
|
0
|
|
|
|
|
0
|
return; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
0
|
open(my $fh,'>>',$self->{'file'}) or warn "Can't write tmp file : $self->{'file'}"; |
208
|
0
|
|
|
|
|
0
|
print $fh $data,"\n"; |
209
|
0
|
|
|
|
|
0
|
close $fh; |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
0
|
return; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub load { |
215
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
216
|
|
|
|
|
|
|
|
217
|
0
|
0
|
|
|
|
0
|
return if ! -e $self->{'file'}; |
218
|
|
|
|
|
|
|
|
219
|
0
|
0
|
|
|
|
0
|
open(my $fh, '<', $self->{'file'}) or warn "Can't read tmp file : $self->{'file'}"; |
220
|
0
|
|
|
|
|
0
|
my @data = <$fh>; |
221
|
0
|
|
|
|
|
0
|
chomp @data; |
222
|
0
|
|
|
|
|
0
|
close $fh; |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
0
|
return @data; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub clear { |
228
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
229
|
0
|
|
|
|
|
0
|
my ($data) = @_; |
230
|
|
|
|
|
|
|
|
231
|
0
|
0
|
|
|
|
0
|
return if ! -e $self->{'file'}; |
232
|
|
|
|
|
|
|
|
233
|
0
|
0
|
|
|
|
0
|
open(my $fh,'>',$self->{'file'}) or warn "Can't write tmp file : $self->{'file'} $!"; |
234
|
0
|
0
|
|
|
|
0
|
print $fh $data."\n" if $data; |
235
|
0
|
|
|
|
|
0
|
close $fh; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
0
|
return; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub get_name { |
241
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
242
|
0
|
|
|
|
|
0
|
my ($name,$id) = @_; |
243
|
|
|
|
|
|
|
|
244
|
0
|
0
|
|
|
|
0
|
if ( !$id ) { |
245
|
0
|
|
|
|
|
0
|
$id = $ENV{'REMOTE_ADDR'}; |
246
|
0
|
0
|
0
|
|
|
0
|
$id = $ENV{'HTTP_X_REMOTE_ADDR'} if $ENV{'HTTP_X_REMOTE_ADDR'} && ( !$id || $id =~ /^(127|192)\./); |
|
|
|
0
|
|
|
|
|
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
0
|
|
|
|
|
0
|
$name .= '.id.'.$id.$self->{'suffix'}.$self->{'tmp_suffix'}; |
250
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
0
|
return $name; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
{ |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
package nes_register; |
259
|
3
|
|
|
3
|
|
18
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
3283
|
|
260
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub new { |
263
|
1
|
|
|
1
|
|
3
|
my $class = shift; |
264
|
1
|
|
|
|
|
7
|
my $self = $class->SUPER::new(); |
265
|
|
|
|
|
|
|
|
266
|
1
|
|
|
|
|
3
|
return $self; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub set_data { |
270
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
271
|
0
|
|
|
|
|
0
|
my ($class, $name, $type, $data) = @_; |
272
|
|
|
|
|
|
|
|
273
|
0
|
|
|
|
|
0
|
$self->{'data'}{$class}{$name}{$type} = $data; |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
0
|
return; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub get_data { |
279
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
280
|
0
|
|
|
|
|
0
|
my ($class, $name, $type) = @_; |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
0
|
return $self->{'data'}{$class}{$name}{$type}; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub tag { |
286
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
287
|
0
|
|
|
|
|
0
|
my ($class, $tag, $handler) = @_; |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
0
|
$self->{'tag'}{$tag}{'handler'} = $handler; |
290
|
0
|
|
|
|
|
0
|
$self->{'obj'}{$class}{'tag'}{$tag} = $handler; |
291
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
0
|
return; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub handler { |
296
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
297
|
0
|
|
|
|
|
0
|
my ($class, $name_handler, $handler) = @_; |
298
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
0
|
$self->{'obj'}{'handler'}{$class}{$name_handler} = $handler; |
300
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
0
|
return; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub add_obj { |
305
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
306
|
0
|
|
|
|
|
0
|
my ($class, $name, $obj, $cfg_file) = @_; |
307
|
|
|
|
|
|
|
|
308
|
0
|
|
0
|
|
|
0
|
$cfg_file ||= $self->{'CFG'}{'plugin_top_dir'}.'/.'.$class.'.nes.cfg'; |
309
|
0
|
|
|
|
|
0
|
Nes::Setting->load_cfg($cfg_file); |
310
|
|
|
|
|
|
|
|
311
|
0
|
|
|
|
|
0
|
$self->{'obj'}{$class}{$name} = $obj; |
312
|
|
|
|
|
|
|
|
313
|
0
|
|
|
|
|
0
|
return $self; |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
sub set_obj { |
317
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
318
|
0
|
|
|
|
|
0
|
my ($class, $name, $obj) = @_; |
319
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
0
|
$self->{'obj'}{$class}{$name} = $obj; |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
0
|
return $self; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub get { |
326
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
327
|
0
|
|
|
|
|
0
|
my ($class, $name) = @_; |
328
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
0
|
return $self->{'obj'}{$class}{$name}; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
sub get_tags { |
333
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
334
|
|
|
|
|
|
|
|
335
|
0
|
|
|
|
|
0
|
return keys %{ $self->{'tag'} }; |
|
0
|
|
|
|
|
0
|
|
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub get_plugins { |
339
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
340
|
|
|
|
|
|
|
|
341
|
0
|
|
|
|
|
0
|
return keys %{ $self->{'obj'} }; |
|
0
|
|
|
|
|
0
|
|
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
sub get_names { |
345
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
346
|
0
|
|
|
|
|
0
|
my ($class) = @_; |
347
|
|
|
|
|
|
|
|
348
|
0
|
|
|
|
|
0
|
return keys %{ $self->{'obj'}{$class} }; |
|
0
|
|
|
|
|
0
|
|
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub get_tag_class { |
352
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
353
|
0
|
|
|
|
|
0
|
my ($tag) = @_; |
354
|
|
|
|
|
|
|
|
355
|
0
|
|
|
|
|
0
|
return $self->{'tag'}{$tag}{'class'}; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub get_tag_handler { |
359
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
360
|
0
|
|
|
|
|
0
|
my ($tag) = @_; |
361
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
0
|
return \&{$self->{'tag'}{$tag}{'handler'}}; |
|
0
|
|
|
|
|
0
|
|
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
sub get_handler { |
366
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
367
|
0
|
|
|
|
|
0
|
my ($class, $name_handler) = @_; |
368
|
|
|
|
|
|
|
|
369
|
0
|
|
|
|
|
0
|
return \&{$self->{'obj'}{'handler'}{$class}{$name_handler}}; |
|
0
|
|
|
|
|
0
|
|
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub add_last_error { |
373
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
374
|
0
|
|
|
|
|
0
|
my ($class, $name, $error) = @_; |
375
|
|
|
|
|
|
|
|
376
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_error_last', $error ); |
377
|
|
|
|
|
|
|
|
378
|
0
|
|
|
|
|
0
|
return; |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub add_fatal_error { |
382
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
383
|
0
|
|
|
|
|
0
|
my ($class, $name, $ok) = @_; |
384
|
|
|
|
|
|
|
|
385
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_error_fatal', $ok ); |
386
|
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
0
|
return; |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
sub add_error { |
391
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
392
|
0
|
|
|
|
|
0
|
my ($class, $name, $type, $error) = @_; |
393
|
|
|
|
|
|
|
|
394
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_error_'.$type, $error ); |
395
|
|
|
|
|
|
|
|
396
|
0
|
|
|
|
|
0
|
return; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub add_env { |
400
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
401
|
0
|
|
|
|
|
0
|
my ($class, $name, $type, $value) = @_; |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_'.$type, $value ); |
404
|
|
|
|
|
|
|
|
405
|
0
|
|
|
|
|
0
|
return; |
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
{ |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
# obsoleto, se mantiene por compatibilidad |
414
|
|
|
|
|
|
|
package nes_plugin; |
415
|
3
|
|
|
3
|
|
17
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
3341
|
|
416
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
my %instance = (); |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
sub new { |
421
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
422
|
0
|
|
|
|
|
0
|
my ( $obj_class, $name, $obj ) = @_; |
423
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new(); |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
# utl::cleanup(\%instance) if $ENV{'MOD_PERL'}; |
426
|
|
|
|
|
|
|
|
427
|
0
|
|
|
|
|
0
|
$self->{'plugin'} = $obj_class; |
428
|
0
|
|
|
|
|
0
|
$self->{'obj'}{$name} = $obj; |
429
|
|
|
|
|
|
|
|
430
|
0
|
|
|
|
|
0
|
my $cfg_file = $self->{'CFG'}{'plugin_top_dir'} . '/.' . $name . '.nes.cfg'; |
431
|
0
|
|
|
|
|
0
|
Nes::Setting->load_cfg($cfg_file); |
432
|
|
|
|
|
|
|
|
433
|
0
|
|
|
|
|
0
|
$instance{$obj_class} = $self; |
434
|
|
|
|
|
|
|
|
435
|
0
|
|
|
|
|
0
|
return $self; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
# add object for this class |
439
|
|
|
|
|
|
|
sub add_obj { |
440
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
441
|
0
|
|
|
|
|
0
|
my ($name, $obj) = @_; |
442
|
|
|
|
|
|
|
|
443
|
0
|
|
|
|
|
0
|
$self->{'obj'}{$name} = $obj; |
444
|
|
|
|
|
|
|
|
445
|
0
|
|
|
|
|
0
|
return $obj; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub add_last_error { |
449
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
450
|
0
|
|
|
|
|
0
|
my ($class, $name, $error) = @_; |
451
|
|
|
|
|
|
|
|
452
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_error_last', $error ); |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
0
|
return; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
sub add_fatal_error { |
458
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
459
|
0
|
|
|
|
|
0
|
my ($class, $name, $ok) = @_; |
460
|
|
|
|
|
|
|
|
461
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_error_fatal', $ok ); |
462
|
|
|
|
|
|
|
|
463
|
0
|
|
|
|
|
0
|
return; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
sub add_error { |
467
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
468
|
0
|
|
|
|
|
0
|
my ($class, $name, $type, $error) = @_; |
469
|
|
|
|
|
|
|
|
470
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_error_'.$type, $error ); |
471
|
|
|
|
|
|
|
|
472
|
0
|
|
|
|
|
0
|
return; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
sub add_env { |
476
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
477
|
0
|
|
|
|
|
0
|
my ($class, $name, $type, $value) = @_; |
478
|
|
|
|
|
|
|
|
479
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_'.$class.'_'.$name.'_'.$type, $value ); |
480
|
|
|
|
|
|
|
|
481
|
0
|
|
|
|
|
0
|
return; |
482
|
|
|
|
|
|
|
} |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
sub get { |
485
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
486
|
0
|
|
|
|
|
0
|
my ($class, $name) = @_; |
487
|
|
|
|
|
|
|
|
488
|
0
|
0
|
|
|
|
0
|
return $instance{$class}->{'obj'}{$name} if $name; |
489
|
0
|
|
|
|
|
0
|
return $instance{$class}->{'obj'}{$class}; |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
sub get_obj { |
494
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
495
|
0
|
|
|
|
|
0
|
my ($class) = @_; |
496
|
|
|
|
|
|
|
|
497
|
0
|
0
|
|
|
|
0
|
return $instance{$class} if $class; |
498
|
0
|
|
|
|
|
0
|
return $self->SUPER::get_obj(); |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
{ |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
package nes_cookie; |
508
|
3
|
|
|
3
|
|
124
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
3463
|
|
509
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
sub new { |
512
|
2
|
|
|
2
|
|
4
|
my $class = shift; |
513
|
2
|
|
|
|
|
8
|
my $self = $class->SUPER::new(); |
514
|
|
|
|
|
|
|
|
515
|
2
|
|
|
|
|
25
|
$self->get_user_cookies(); |
516
|
|
|
|
|
|
|
|
517
|
2
|
|
|
|
|
5
|
return $self; |
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
sub get_cookies { |
521
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
522
|
|
|
|
|
|
|
|
523
|
0
|
|
|
|
|
0
|
my @cookies; |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
# primero las que borran, para no machacar las que valen |
526
|
0
|
|
|
|
|
0
|
foreach my $cookie ( keys %{ $self->{'c_set'} } ) { |
|
0
|
|
|
|
|
0
|
|
527
|
0
|
0
|
|
|
|
0
|
push( @cookies, $cookie ) if $cookie =~ /_delete$/; |
528
|
|
|
|
|
|
|
} |
529
|
0
|
|
|
|
|
0
|
foreach my $cookie ( keys %{ $self->{'c_set'} } ) { |
|
0
|
|
|
|
|
0
|
|
530
|
0
|
0
|
|
|
|
0
|
push( @cookies, $cookie ) if $cookie !~ /_delete$/; |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
|
533
|
0
|
|
|
|
|
0
|
return @cookies; |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
sub get { |
537
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
538
|
1
|
|
|
|
|
2
|
my ( $name, $pass ) = @_; |
539
|
|
|
|
|
|
|
|
540
|
1
|
50
|
|
|
|
9
|
return if !$self->{'c_get'}{$name}; |
541
|
0
|
0
|
|
|
|
0
|
$pass = '' if !$pass; |
542
|
|
|
|
|
|
|
|
543
|
0
|
|
|
|
|
0
|
my $key = $self->{'CFG'}{'private_key'} . $pass; |
544
|
0
|
|
|
|
|
0
|
require Crypt::CBC; |
545
|
0
|
|
|
|
|
0
|
my $cipher = Crypt::CBC->new( |
546
|
|
|
|
|
|
|
-key => $key, |
547
|
|
|
|
|
|
|
-cipher => 'Blowfish' |
548
|
|
|
|
|
|
|
); |
549
|
0
|
|
|
|
|
0
|
my $text = ''; |
550
|
0
|
|
|
|
|
0
|
eval { $text = $cipher->decrypt_hex( $self->{'c_get'}{$name} ); }; |
|
0
|
|
|
|
|
0
|
|
551
|
|
|
|
|
|
|
|
552
|
0
|
|
|
|
|
0
|
return $text; |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
sub create { |
556
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
557
|
0
|
|
|
|
|
0
|
my ( $name, $value, $expiration, $path, $domain, $pass ) = @_; |
558
|
0
|
0
|
|
|
|
0
|
$pass = '' if !$pass; |
559
|
|
|
|
|
|
|
|
560
|
0
|
|
|
|
|
0
|
my $expires = &utl::expires($expiration); |
561
|
0
|
|
|
|
|
0
|
my $key = $self->{'CFG'}{'private_key'} . $pass; |
562
|
|
|
|
|
|
|
|
563
|
0
|
|
|
|
|
0
|
require Crypt::CBC; |
564
|
0
|
|
|
|
|
0
|
my $cipher = Crypt::CBC->new( |
565
|
|
|
|
|
|
|
-key => $key, |
566
|
|
|
|
|
|
|
-cipher => 'Blowfish' |
567
|
|
|
|
|
|
|
); |
568
|
|
|
|
|
|
|
|
569
|
0
|
|
|
|
|
0
|
$value = $cipher->encrypt_hex($value); |
570
|
0
|
0
|
|
|
|
0
|
$path = '/' if !$path; |
571
|
|
|
|
|
|
|
|
572
|
0
|
|
|
|
|
0
|
$self->{'c_set'}{$name} = "Set-Cookie: $name=$value; expires=$expires; path=$path; "; |
573
|
0
|
0
|
|
|
|
0
|
$self->{'c_set'}{$name} .= "domain=$domain; " if $domain; |
574
|
|
|
|
|
|
|
|
575
|
0
|
|
|
|
|
0
|
return; |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
sub del { |
579
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
580
|
0
|
|
|
|
|
0
|
my ($name,$path) = @_; |
581
|
0
|
0
|
|
|
|
0
|
$path = '/' if !$path; |
582
|
|
|
|
|
|
|
|
583
|
0
|
|
|
|
|
0
|
my $expires = &utl::expires('1s'); |
584
|
0
|
|
|
|
|
0
|
my $value = 'deleted'; |
585
|
|
|
|
|
|
|
|
586
|
0
|
|
|
|
|
0
|
$self->{'c_set'}{ $name . '_delete' } = "Set-Cookie: $name=$value; expires=$expires; path=$path; "; |
587
|
|
|
|
|
|
|
|
588
|
0
|
|
|
|
|
0
|
return; |
589
|
|
|
|
|
|
|
} |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
sub get_user_cookies { |
592
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
593
|
|
|
|
|
|
|
|
594
|
2
|
50
|
|
|
|
7
|
return if !$ENV{'HTTP_COOKIE'}; |
595
|
|
|
|
|
|
|
|
596
|
0
|
|
|
|
|
0
|
my @cookies = split( /[;,]\s*/, $ENV{'HTTP_COOKIE'} ); |
597
|
0
|
|
|
|
|
0
|
foreach my $cookie (@cookies) { |
598
|
0
|
|
|
|
|
0
|
my ( $key, $value ) = split( /=/, $cookie ); |
599
|
0
|
0
|
|
|
|
0
|
$value = '' if !$value; |
600
|
0
|
0
|
|
|
|
0
|
next if $value eq 'deleted'; |
601
|
0
|
|
|
|
|
0
|
$self->{'c_get'}{$key} = $value; |
602
|
|
|
|
|
|
|
} |
603
|
|
|
|
|
|
|
} |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
sub out { |
606
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
607
|
|
|
|
|
|
|
|
608
|
0
|
|
|
|
|
0
|
my $cookies = ''; |
609
|
0
|
|
|
|
|
0
|
foreach my $cookie ( $self->get_cookies() ) { |
610
|
0
|
|
|
|
|
0
|
$cookies .= $self->{'c_set'}{$cookie}."\n"; |
611
|
|
|
|
|
|
|
} |
612
|
|
|
|
|
|
|
|
613
|
0
|
|
|
|
|
0
|
return $cookies; |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
sub get_c_get { |
617
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
618
|
|
|
|
|
|
|
|
619
|
0
|
|
|
|
|
0
|
my @cookies; |
620
|
|
|
|
|
|
|
|
621
|
0
|
|
|
|
|
0
|
foreach my $cookie ( keys %{ $self->{'c_get'} } ) { |
|
0
|
|
|
|
|
0
|
|
622
|
0
|
|
|
|
|
0
|
push( @cookies, $cookie ); |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
0
|
return @cookies; |
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
{ |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
package nes_session; |
634
|
3
|
|
|
3
|
|
132
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
57
|
|
|
3
|
|
|
|
|
2124
|
|
635
|
|
|
|
|
|
|
@ISA = qw( nes_cookie ); |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
sub new { |
638
|
1
|
|
|
1
|
|
3
|
my $class = shift; |
639
|
1
|
|
|
|
|
6
|
my $self = $class->SUPER::new(); |
640
|
1
|
|
|
|
|
2
|
my ($session_prefix) = @_; |
641
|
|
|
|
|
|
|
|
642
|
1
|
|
33
|
|
|
14
|
$self->{'session_prefix'} = $session_prefix || $self->{'CFG'}{'session_prefix'}; |
643
|
1
|
|
|
|
|
2
|
$self->{'session_ok'} = 0; |
644
|
1
|
|
|
|
|
3
|
$self->{'user'} = ''; |
645
|
1
|
|
|
|
|
9
|
$self->get; |
646
|
|
|
|
|
|
|
|
647
|
1
|
|
|
|
|
2
|
return $self; |
648
|
|
|
|
|
|
|
} |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
sub get { |
651
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
652
|
1
|
|
50
|
|
|
15
|
my ($pass) = @_ || ''; |
653
|
|
|
|
|
|
|
|
654
|
1
|
|
|
|
|
3
|
my $key = $self->{'CFG'}{'private_key'} . $pass; |
655
|
1
|
|
|
|
|
8
|
$self->{'sess'} = $self->SUPER::get( $self->{'session_prefix'}, $key ); |
656
|
1
|
50
|
|
|
|
5
|
return if !$self->{'sess'}; |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
0
|
my ( $session_name, $expire, $user, $refuse ) = split( /::/, $self->{'sess'} ); |
659
|
|
|
|
|
|
|
|
660
|
0
|
0
|
|
|
|
0
|
return if time > $expire; |
661
|
0
|
0
|
|
|
|
0
|
return if $session_name ne $self->{'session_prefix'}; |
662
|
|
|
|
|
|
|
|
663
|
0
|
|
|
|
|
0
|
$self->{'session_ok'} = 1; |
664
|
0
|
|
|
|
|
0
|
$self->{'user'} = $user; |
665
|
|
|
|
|
|
|
|
666
|
0
|
|
|
|
|
0
|
return $user; |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
sub create { |
670
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
671
|
0
|
|
|
|
|
0
|
my ( $user, $expiration, $pass ) = @_; |
672
|
0
|
0
|
|
|
|
0
|
$pass = '' if !$pass; |
673
|
|
|
|
|
|
|
|
674
|
0
|
|
|
|
|
0
|
my $key = $self->{'CFG'}{'private_key'} . $pass; |
675
|
0
|
|
|
|
|
0
|
my $expire = time + utl::expires_time( $expiration ); |
676
|
0
|
|
|
|
|
0
|
my $refuse = $self->get_key( 10 + int rand 10 ); |
677
|
0
|
|
|
|
|
0
|
my $value = $self->{'session_prefix'} . '::' . $expire . '::' . $user . '::' . $refuse; |
678
|
0
|
|
|
|
|
0
|
my $path = '/'; |
679
|
|
|
|
|
|
|
|
680
|
0
|
|
|
|
|
0
|
$self->{'cookies'}->create( $self->{'session_prefix'}, $value, $expiration, $path,'',$key ); |
681
|
|
|
|
|
|
|
|
682
|
0
|
|
|
|
|
0
|
return; |
683
|
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
sub del { |
686
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
687
|
|
|
|
|
|
|
|
688
|
0
|
0
|
|
|
|
0
|
return if !$self->{'user'}; |
689
|
0
|
|
|
|
|
0
|
$self->{'cookies'}->del( $self->{'session_prefix'} ); |
690
|
|
|
|
|
|
|
|
691
|
0
|
|
|
|
|
0
|
return; |
692
|
|
|
|
|
|
|
} |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
} |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
{ # todo, add "" support |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
package nes_query; |
700
|
3
|
|
|
3
|
|
19
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
820
|
|
701
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
sub new { |
704
|
1
|
|
|
1
|
|
16
|
my $class = shift; |
705
|
1
|
|
|
|
|
6
|
my $self = $class->SUPER::new(); |
706
|
|
|
|
|
|
|
|
707
|
1
|
|
|
|
|
3
|
$self->{'q'} = {}; |
708
|
1
|
|
50
|
|
|
9
|
my $clength = $ENV{'CONTENT_LENGTH'} || 0; |
709
|
1
|
|
|
|
|
3
|
$self->{'save_buffer'} = 0; |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
# return $self if !$clength && !$ENV{'QUERY_STRING'}; |
712
|
|
|
|
|
|
|
|
713
|
3
|
|
|
3
|
|
2529
|
use Nes::Minimal; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
20
|
|
714
|
1
|
0
|
33
|
|
|
6
|
$self->{'save_buffer'} = 1 if $self->{'top_container'}->{'php_wrapper'} && |
|
|
|
33
|
|
|
|
|
715
|
|
|
|
|
|
|
$clength > ($self->{'CFG'}{'tmp_upload'}*1024) && |
716
|
|
|
|
|
|
|
$self->{'CFG'}{'tmp_upload'}; |
717
|
1
|
|
|
|
|
6
|
Nes::Minimal::allow_hybrid_post_get(1); |
718
|
1
|
|
|
|
|
6
|
Nes::Minimal::max_read_size( $self->{'CFG'}{'max_post'}*1024 ); |
719
|
1
|
|
|
|
|
6
|
Nes::Minimal::use_tmp( $self->{'CFG'}{'tmp_upload'}*1024 ); |
720
|
1
|
|
|
|
|
5
|
Nes::Minimal::max_upload( $self->{'CFG'}{'max_upload'}*1024 ); |
721
|
1
|
50
|
|
|
|
5
|
Nes::Minimal::save_buffer(1) if $self->{'save_buffer'}; |
722
|
1
|
50
|
|
|
|
12
|
Nes::Minimal::sub_filter( \&utl::no_nes_remove ) if $self->{'top_container'}->{'php_wrapper'}; |
723
|
1
|
|
|
|
|
8
|
$self->{'CGI'} = Nes::Minimal->new; |
724
|
1
|
|
|
|
|
5
|
$self->set_query(); |
725
|
|
|
|
|
|
|
|
726
|
1
|
|
|
|
|
3
|
return $self; |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
sub set_query { |
730
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
731
|
|
|
|
|
|
|
|
732
|
1
|
|
|
|
|
6
|
foreach my $param ( $self->{'CGI'}->param() ) { |
733
|
0
|
|
|
|
|
0
|
$self->{'q'}{$param} = $self->{'CGI'}->param($param); |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
|
736
|
1
|
|
|
|
|
2
|
return; |
737
|
|
|
|
|
|
|
} |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
sub param { |
740
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
741
|
0
|
|
|
|
|
0
|
my ($param) = @_; |
742
|
|
|
|
|
|
|
|
743
|
0
|
0
|
|
|
|
0
|
return if !$self->{'CGI'}; |
744
|
|
|
|
|
|
|
|
745
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->param($param); |
746
|
|
|
|
|
|
|
} |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
sub by_CGI { |
749
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
# no upload inplemented |
752
|
0
|
|
|
|
|
0
|
require CGI; |
753
|
0
|
|
|
|
|
0
|
$self->{'q_CGI'} = CGI->new( $self->{'q'} ); |
754
|
|
|
|
|
|
|
|
755
|
0
|
|
|
|
|
0
|
return $self->{'q_CGI'}; |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
sub header { |
759
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
760
|
|
|
|
|
|
|
|
761
|
0
|
0
|
|
|
|
0
|
return if !$self->{'q_CGI'}; |
762
|
|
|
|
|
|
|
|
763
|
0
|
|
|
|
|
0
|
return $self->{'q_CGI'}->header(@_); |
764
|
|
|
|
|
|
|
} |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
# sub get_upload { |
767
|
|
|
|
|
|
|
# my $self = shift; |
768
|
|
|
|
|
|
|
# my ($param,$buffer) = @_; |
769
|
|
|
|
|
|
|
# |
770
|
|
|
|
|
|
|
# my $fh = $self->{'CGI'}->upload($param); |
771
|
|
|
|
|
|
|
# return if !$fh; |
772
|
|
|
|
|
|
|
# |
773
|
|
|
|
|
|
|
# return read($fh, $$buffer, 8192); |
774
|
|
|
|
|
|
|
# } |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
sub get_upload_buffer { |
777
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
778
|
0
|
|
|
|
|
0
|
my ($param,$buffer) = @_; |
779
|
|
|
|
|
|
|
|
780
|
0
|
|
|
|
|
0
|
my $fh = $self->{'CGI'}->upload($param); |
781
|
0
|
0
|
|
|
|
0
|
return if !$fh; |
782
|
|
|
|
|
|
|
|
783
|
0
|
|
|
|
|
0
|
return read($fh, $$buffer, 8192); |
784
|
|
|
|
|
|
|
} |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
sub get_upload_name { |
787
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
788
|
0
|
|
|
|
|
0
|
my ($param) = @_; |
789
|
|
|
|
|
|
|
|
790
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->param_filename($param); |
791
|
|
|
|
|
|
|
} |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
sub get_upload_fh { |
794
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
795
|
0
|
|
|
|
|
0
|
my ($param) = @_; |
796
|
|
|
|
|
|
|
|
797
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->upload($param); |
798
|
|
|
|
|
|
|
} |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
sub upload_is_tmp { |
801
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
802
|
0
|
|
|
|
|
0
|
my ($param) = @_; |
803
|
|
|
|
|
|
|
|
804
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->upload_is_tmp($param); |
805
|
|
|
|
|
|
|
} |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
sub upload_max_size { |
808
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
809
|
|
|
|
|
|
|
|
810
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->upload_max_size(); |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
sub post_max_size { |
814
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
815
|
|
|
|
|
|
|
|
816
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->post_max_size(); |
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
sub url_encode { |
820
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
821
|
0
|
|
|
|
|
0
|
my ($value) = @_; |
822
|
|
|
|
|
|
|
|
823
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->url_encode($value); |
824
|
|
|
|
|
|
|
} |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
sub url_decode { |
827
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
828
|
0
|
|
|
|
|
0
|
my ($value) = @_; |
829
|
|
|
|
|
|
|
|
830
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->url_decode($value); |
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
sub get_buffer { |
834
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
835
|
0
|
|
|
|
|
0
|
my $buffer; |
836
|
|
|
|
|
|
|
|
837
|
0
|
0
|
|
|
|
0
|
return if !$self->{'CGI'}; |
838
|
|
|
|
|
|
|
|
839
|
0
|
0
|
|
|
|
0
|
if ( $ENV{'REQUEST_METHOD'} ne 'GET' ) { |
840
|
0
|
0
|
|
|
|
0
|
return $buffer if $self->{'CGI'}->raw_saved(\$buffer, 8192); |
841
|
|
|
|
|
|
|
} |
842
|
0
|
|
|
|
|
0
|
return; |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
} |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
sub get_buffer_raw { |
847
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
848
|
|
|
|
|
|
|
|
849
|
0
|
0
|
|
|
|
0
|
return if !$self->{'CGI'}; |
850
|
|
|
|
|
|
|
|
851
|
0
|
0
|
|
|
|
0
|
if ( $ENV{'REQUEST_METHOD'} ne 'GET' ) { |
852
|
0
|
|
|
|
|
0
|
return $self->{'CGI'}->raw; |
853
|
|
|
|
|
|
|
} |
854
|
0
|
|
|
|
|
0
|
return; |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
} |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
sub get { |
859
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
860
|
0
|
|
|
|
|
0
|
my ($key) = @_; |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
# return $self->{'CGI'}->param($key); |
863
|
0
|
|
|
|
|
0
|
return $self->{'q'}{$key}; |
864
|
|
|
|
|
|
|
} |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
sub set { |
867
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
868
|
0
|
|
|
|
|
0
|
my ( $name, $value ) = @_; |
869
|
|
|
|
|
|
|
|
870
|
0
|
|
|
|
|
0
|
$self->{'q'}{$name} = $value; |
871
|
|
|
|
|
|
|
|
872
|
0
|
|
|
|
|
0
|
return; |
873
|
|
|
|
|
|
|
} |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
sub del { |
876
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
877
|
0
|
|
|
|
|
0
|
my ( $name ) = @_; |
878
|
|
|
|
|
|
|
|
879
|
0
|
|
|
|
|
0
|
undef $self->{'q'}{$name}; |
880
|
|
|
|
|
|
|
|
881
|
0
|
|
|
|
|
0
|
return; |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
} |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
{ |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
package nes_top_container; |
890
|
3
|
|
|
3
|
|
27
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
11419
|
|
891
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
sub new { |
894
|
1
|
|
|
1
|
|
25
|
my $class = shift; |
895
|
1
|
|
|
|
|
12
|
my $self = $class->SUPER::new(); |
896
|
1
|
|
|
|
|
3
|
my ($file,$dir) = @_; |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
# maximo de interactiones, para evitar un bucle infinito. |
899
|
1
|
|
|
|
|
4
|
$self->{'max_inter'} = $MAX_INTERACTIONS; |
900
|
1
|
|
|
|
|
3
|
$self->{'max_scripts'} = $MAX_SCRIPTS; |
901
|
1
|
|
|
|
|
4
|
$self->{'nes'}->{'debug_info'}{'is_load'} = 0; |
902
|
1
|
|
|
|
|
3
|
$self->{'nes'}->{'debug_info'}{'obj'} = undef; |
903
|
1
|
|
|
|
|
13
|
$self->{'nes'}->{'print_out'} = 1; |
904
|
|
|
|
|
|
|
|
905
|
1
|
50
|
|
|
|
14
|
$self->init($file,$dir) if $file; |
906
|
|
|
|
|
|
|
|
907
|
1
|
|
|
|
|
5
|
return $self; |
908
|
|
|
|
|
|
|
} |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
sub init { |
911
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
912
|
1
|
|
|
|
|
3
|
my ($file,$dir) = @_; |
913
|
|
|
|
|
|
|
|
914
|
1
|
|
|
|
|
7
|
$self->cleanup; |
915
|
|
|
|
|
|
|
|
916
|
1
|
|
|
|
|
2
|
$self->{'url'} = ''; |
917
|
1
|
|
|
|
|
3
|
$self->{'dir'} = $dir; |
918
|
1
|
|
|
|
|
2
|
$self->{'file'} = $file; |
919
|
|
|
|
|
|
|
|
920
|
1
|
|
|
|
|
6
|
$self->set_parent_dir( $self->{'dir'} ); |
921
|
|
|
|
|
|
|
|
922
|
1
|
|
|
|
|
4
|
$self->{'file'} =~ s/(.*[\\\/])/\//; |
923
|
1
|
|
|
|
|
4
|
$self->{'file'} = $self->{'dir'} . $self->{'file'}; |
924
|
|
|
|
|
|
|
|
925
|
1
|
50
|
|
|
|
6
|
$self->{'php_wrapper'} = 1 if $self->{'file'} =~ /php$/i; |
926
|
|
|
|
|
|
|
|
927
|
1
|
|
|
|
|
5
|
$self->{'register'} = nes_register->new(); |
928
|
1
|
|
|
|
|
5
|
$self->{'query'} = nes_query->new(); |
929
|
1
|
|
|
|
|
5
|
$self->{'cookies'} = nes_cookie->new(); |
930
|
1
|
|
|
|
|
5
|
$self->{'session'} = nes_session->new(); |
931
|
|
|
|
|
|
|
|
932
|
1
|
|
|
|
|
6
|
$self->init_nes_env(); |
933
|
1
|
|
|
|
|
4
|
$self->init_cgi_env(); |
934
|
|
|
|
|
|
|
|
935
|
1
|
|
|
|
|
6
|
$self->{'container'} = nes_container->new( $self->{'file'} ); |
936
|
|
|
|
|
|
|
|
937
|
1
|
|
|
|
|
3
|
return; |
938
|
|
|
|
|
|
|
} |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
sub get_out { |
941
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
942
|
|
|
|
|
|
|
|
943
|
0
|
|
|
|
|
0
|
return $self->{'out'}; |
944
|
|
|
|
|
|
|
} |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
sub get_session { |
947
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
948
|
|
|
|
|
|
|
|
949
|
0
|
|
|
|
|
0
|
return $self->{'session'}; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
sub get_query { |
953
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
954
|
|
|
|
|
|
|
|
955
|
0
|
|
|
|
|
0
|
return $self->{'query'}; |
956
|
|
|
|
|
|
|
} |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
sub get_file_path { |
959
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
960
|
1
|
|
|
|
|
2
|
my ( $file ) = @_; |
961
|
|
|
|
|
|
|
|
962
|
1
|
|
|
|
|
3
|
my $parent_dir = $self->get_parent_dir(); |
963
|
1
|
|
|
|
|
5
|
$parent_dir =~ s/\/$//; |
964
|
1
|
|
|
|
|
2
|
my $this_dir = $file; |
965
|
1
|
|
|
|
|
13
|
$this_dir =~ s/[^\/]*$//; |
966
|
1
|
|
|
|
|
2
|
$this_dir =~ s/^\.\///; |
967
|
1
|
|
|
|
|
2
|
my $this_file = $file; |
968
|
1
|
|
|
|
|
6
|
$this_file =~ s/(.*)(\\|\/)//; |
969
|
|
|
|
|
|
|
|
970
|
1
|
|
|
|
|
2
|
my $file_path; |
971
|
|
|
|
|
|
|
|
972
|
1
|
50
|
|
|
|
5
|
if ( $this_dir =~ /^\// ) { |
973
|
1
|
|
|
|
|
3
|
$self->{'this_dir'} = $this_dir; |
974
|
1
|
|
|
|
|
2
|
$file_path = $file; |
975
|
|
|
|
|
|
|
} else { |
976
|
0
|
|
|
|
|
0
|
while ( $this_dir =~ s/^\.\.\/// ) { |
977
|
0
|
|
|
|
|
0
|
$parent_dir =~ s/\/[^\/]*$//; |
978
|
|
|
|
|
|
|
} |
979
|
0
|
|
|
|
|
0
|
$self->{'this_dir'} = $parent_dir.'/'.$this_dir; |
980
|
0
|
|
|
|
|
0
|
$file_path = $parent_dir.'/'.$this_dir.$this_file; |
981
|
|
|
|
|
|
|
} |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
# Insecure dependency in require while running with -T switch at |
984
|
1
|
50
|
|
|
|
6
|
if ($file_path =~ /^([-\@\w.\\\/]+)$/) { |
985
|
1
|
|
|
|
|
4
|
$file_path = $1; |
986
|
|
|
|
|
|
|
} |
987
|
|
|
|
|
|
|
|
988
|
1
|
|
|
|
|
3
|
return $file_path; |
989
|
|
|
|
|
|
|
} |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
sub get_dir { |
992
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
993
|
0
|
|
|
|
|
0
|
my ($file) = @_; |
994
|
|
|
|
|
|
|
|
995
|
0
|
|
|
|
|
0
|
my $dir = $file; |
996
|
0
|
|
|
|
|
0
|
$dir =~ s/(.*)(\\|\/).*/$1/; |
997
|
|
|
|
|
|
|
|
998
|
0
|
|
|
|
|
0
|
return $dir; |
999
|
|
|
|
|
|
|
} |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
sub set_parent_dir { |
1002
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
1003
|
2
|
|
|
|
|
3
|
my ($dir) = @_; |
1004
|
|
|
|
|
|
|
|
1005
|
2
|
|
|
|
|
3
|
$self->{'parent_dir'} = $dir; |
1006
|
|
|
|
|
|
|
|
1007
|
2
|
|
|
|
|
4
|
return $dir; |
1008
|
|
|
|
|
|
|
} |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
sub get_parent_dir { |
1011
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
1012
|
|
|
|
|
|
|
|
1013
|
2
|
|
|
|
|
6
|
return $self->{'parent_dir'}; |
1014
|
|
|
|
|
|
|
} |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
sub init_nes_env { |
1017
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1018
|
1
|
|
|
|
|
77
|
my ( $var, $value ) = @_; |
1019
|
|
|
|
|
|
|
|
1020
|
1
|
|
|
|
|
3
|
foreach my $key ( keys %{ $self->{'query'}->{'q'} } ) { |
|
1
|
|
|
|
|
5
|
|
1021
|
0
|
|
|
|
|
0
|
my $name_env = 'q_' . $key; |
1022
|
0
|
|
|
|
|
0
|
my $value = $self->{'query'}->{'q'}{$key}; |
1023
|
0
|
|
|
|
|
0
|
$self->{'nes_env'}{$name_env} = $value; |
1024
|
|
|
|
|
|
|
} |
1025
|
|
|
|
|
|
|
|
1026
|
1
|
|
|
|
|
2
|
foreach my $key ( keys %{ $self->{'CFG'} } ) { |
|
1
|
|
|
|
|
9
|
|
1027
|
39
|
|
|
|
|
52
|
my $name_env = 'cfg_' . $key; |
1028
|
39
|
|
|
|
|
189
|
my $value = $self->{'CFG'}->{$key}; |
1029
|
|
|
|
|
|
|
# $value = "@{$self->{'CFG'}->{$key}}" if ref $self->{'CFG'}->{$key} eq 'ARRAY'; |
1030
|
|
|
|
|
|
|
# $value = keys %{$self->{'CFG'}->{$key}} if ref $self->{'CFG'}->{$key} eq 'HASH'; |
1031
|
39
|
|
|
|
|
93
|
$self->{'nes_env'}{$name_env} = $value; |
1032
|
|
|
|
|
|
|
} |
1033
|
|
|
|
|
|
|
|
1034
|
1
|
|
|
|
|
8
|
( $self->{'nes_env'}{'nes_accept_language'} ) = split(/,/, $ENV{'HTTP_ACCEPT_LANGUAGE'}, 2); |
1035
|
1
|
|
|
|
|
3
|
$self->{'nes_env'}{'nes_dir_self'} = $self->{'dir'}; |
1036
|
1
|
|
|
|
|
3
|
$self->{'nes_env'}{'nes_this_dir'} = $self->{'dir'}; |
1037
|
1
|
|
|
|
|
4
|
$self->{'nes_env'}{'nes_this_file'} = $self->{'file'}; |
1038
|
1
|
|
|
|
|
8
|
$self->{'nes_env'}{'nes_ver'} = $self->VERSION; |
1039
|
1
|
|
|
|
|
4
|
$self->{'nes_env'}{'nes_perl_ver'} = $]; |
1040
|
1
|
|
|
|
|
3
|
$self->{'nes_env'}{'nes_remote_ip'} = $ENV{'REMOTE_ADDR'}; |
1041
|
1
|
0
|
0
|
|
|
4
|
$self->{'nes_env'}{'nes_remote_ip'} = $ENV{'HTTP_X_REMOTE_ADDR'} |
|
|
|
33
|
|
|
|
|
1042
|
|
|
|
|
|
|
if $ENV{'HTTP_X_REMOTE_ADDR'} && ( !$ENV{'REMOTE_ADDR'} || $ENV{'REMOTE_ADDR'} =~ /^(127|192|169|10)\./); |
1043
|
|
|
|
|
|
|
|
1044
|
1
|
|
|
|
|
4
|
$self->{'nes_env'}{'nes_session_ok'} = $self->{'session'}->{'session_ok'}; |
1045
|
1
|
|
|
|
|
3
|
$self->{'nes_env'}{'nes_session_user'} = $self->{'session'}->{'user'}; |
1046
|
|
|
|
|
|
|
|
1047
|
1
|
|
|
|
|
10
|
return; |
1048
|
|
|
|
|
|
|
} |
1049
|
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
sub init_cgi_env { |
1051
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1052
|
1
|
|
|
|
|
2
|
my ( $var, $value ) = @_; |
1053
|
|
|
|
|
|
|
|
1054
|
1
|
|
|
|
|
8
|
foreach my $key ( keys %ENV ) { |
1055
|
22
|
|
|
|
|
27
|
my $name_env = 'env_' . $key; |
1056
|
22
|
|
|
|
|
35
|
my $value = $ENV{$key}; |
1057
|
22
|
|
|
|
|
103
|
$self->{'nes_env'}{$name_env} = $value; |
1058
|
|
|
|
|
|
|
} |
1059
|
|
|
|
|
|
|
|
1060
|
1
|
|
|
|
|
3
|
return; |
1061
|
|
|
|
|
|
|
} |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
sub set_nes_env { |
1064
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1065
|
0
|
|
|
|
|
0
|
my ( $var, $value ) = @_; |
1066
|
|
|
|
|
|
|
|
1067
|
0
|
|
|
|
|
0
|
$self->{'nes_env'}{$var} = $value; |
1068
|
|
|
|
|
|
|
|
1069
|
0
|
|
|
|
|
0
|
return; |
1070
|
|
|
|
|
|
|
} |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
sub del_nes_env { |
1073
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1074
|
0
|
|
|
|
|
0
|
my ( $var ) = @_; |
1075
|
|
|
|
|
|
|
|
1076
|
0
|
|
|
|
|
0
|
undef $self->{'nes_env'}{$var}; |
1077
|
|
|
|
|
|
|
|
1078
|
0
|
|
|
|
|
0
|
return; |
1079
|
|
|
|
|
|
|
} |
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
sub get_nes_env { |
1082
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1083
|
0
|
|
|
|
|
0
|
my ($var) = @_; |
1084
|
|
|
|
|
|
|
|
1085
|
0
|
|
|
|
|
0
|
return $self->{'nes_env'}{$var}; |
1086
|
|
|
|
|
|
|
|
1087
|
0
|
|
|
|
|
0
|
return; |
1088
|
|
|
|
|
|
|
} |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
sub get_nes_env_keys { |
1091
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1092
|
0
|
|
|
|
|
0
|
my ($par) = @_; |
1093
|
|
|
|
|
|
|
|
1094
|
0
|
0
|
|
|
|
0
|
return keys %{$self->{'nes_env'}} if !$par; |
|
0
|
|
|
|
|
0
|
|
1095
|
|
|
|
|
|
|
|
1096
|
0
|
|
|
|
|
0
|
my @keys; |
1097
|
0
|
|
|
|
|
0
|
foreach my $key ( keys %{$self->{'nes_env'}} ) { |
|
0
|
|
|
|
|
0
|
|
1098
|
0
|
0
|
|
|
|
0
|
push(@keys, $key) if $key =~ /^$par/; |
1099
|
|
|
|
|
|
|
} |
1100
|
|
|
|
|
|
|
|
1101
|
0
|
|
|
|
|
0
|
return @keys; |
1102
|
|
|
|
|
|
|
} |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
} |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
{ |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
package nes_container; |
1109
|
3
|
|
|
3
|
|
27
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
4855
|
|
1110
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
sub new { |
1113
|
1
|
|
|
1
|
|
3
|
my $class = shift; |
1114
|
1
|
|
|
|
|
6
|
my $self = $class->SUPER::new(); |
1115
|
1
|
|
|
|
|
2
|
my ( $file ) = @_; |
1116
|
|
|
|
|
|
|
|
1117
|
1
|
|
|
|
|
4
|
$self->{'error_not_exist'} = 0; |
1118
|
1
|
|
|
|
|
5
|
$self->{'file_dir'} = $self->{'top_container'}->get_parent_dir(); |
1119
|
1
|
|
|
|
|
6
|
$self->{'file_name'} = $self->{'top_container'}->get_file_path($file); |
1120
|
|
|
|
|
|
|
|
1121
|
1
|
|
|
|
|
5
|
$self->{'top_container'}->set_parent_dir($self->{'top_container'}->{'this_dir'}); |
1122
|
|
|
|
|
|
|
|
1123
|
1
|
50
|
|
|
|
4
|
$self->{'top_container'}->{'max_inter'}-- || die "Possible infinite loop"; |
1124
|
1
|
|
|
|
|
5
|
$self->{'this_inter'} = $MAX_INTERACTIONS - $self->{'top_container'}->{'max_inter'}; |
1125
|
1
|
|
33
|
|
|
21
|
$self->{'parent'} = $self->{'previous'}->{'container'} || $self->{'top_container'}; |
1126
|
1
|
|
|
|
|
4
|
$self->{'parent_file_name'} = $self->{'previous'}->{'file_name'}; |
1127
|
|
|
|
|
|
|
|
1128
|
1
|
|
|
|
|
4
|
$self->{'souce_types'}{'unknown'} = 'unknown'; |
1129
|
1
|
|
|
|
|
2
|
$self->{'souce_types'}{'html'} = 'html,htm,nhtm,nhtml'; |
1130
|
1
|
|
|
|
|
3
|
$self->{'souce_types'}{'nsql'} = 'nsql'; |
1131
|
1
|
|
|
|
|
2
|
$self->{'souce_types'}{'php'} = 'php'; |
1132
|
1
|
|
|
|
|
2
|
$self->{'souce_types'}{'perl'} = 'pl'; |
1133
|
1
|
|
|
|
|
3
|
$self->{'souce_types'}{'txt'} = 'txt'; |
1134
|
1
|
|
|
|
|
2
|
$self->{'souce_types'}{'bash'} = 'sh'; |
1135
|
1
|
|
|
|
|
3
|
$self->{'souce_types'}{'python'} = 'py'; |
1136
|
1
|
|
|
|
|
2
|
$self->{'souce_types'}{'js'} = 'njs,js'; |
1137
|
|
|
|
|
|
|
#$self->{'souce_types'}{'mail'} = 'eml'; |
1138
|
|
|
|
|
|
|
# ... |
1139
|
|
|
|
|
|
|
|
1140
|
1
|
|
|
|
|
5
|
$self->get_source(); # set @{$self->{'file_souce'}} |
1141
|
1
|
|
|
|
|
6
|
$self->set_out(); # set $self->{'file_script'}, $self->{'out'} |
1142
|
1
|
|
|
|
|
12
|
$self->get_type(); # set $self->{'type'}, $self->{'content_obj'} |
1143
|
1
|
|
|
|
|
5
|
$self->add_parent_tags(); # hereda los tags |
1144
|
|
|
|
|
|
|
|
1145
|
1
|
|
|
|
|
2
|
return $self; |
1146
|
|
|
|
|
|
|
} |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
sub get_type { |
1149
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1150
|
|
|
|
|
|
|
|
1151
|
1
|
|
|
|
|
3
|
my $extension = $self->{'file_name'}; |
1152
|
1
|
|
|
|
|
7
|
$extension =~ s/(.*)\.([^\.]*)$/$2/; |
1153
|
|
|
|
|
|
|
|
1154
|
1
|
|
|
|
|
8
|
$self->{'type'} = 'unknown'; |
1155
|
1
|
|
|
|
|
2
|
foreach my $type ( keys %{ $self->{'souce_types'} } ) { |
|
1
|
|
|
|
|
6
|
|
1156
|
9
|
100
|
|
|
|
89
|
$self->{'type'} = $type if $self->{'souce_types'}{$type} =~ /[\,\s]?$extension[\,\s]?/i; |
1157
|
|
|
|
|
|
|
} |
1158
|
|
|
|
|
|
|
|
1159
|
1
|
50
|
|
|
|
5
|
if ( $self->{'type'} eq 'html' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1160
|
1
|
|
|
|
|
7
|
$self->{'content_obj'} = nes_html->new( $self ); |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'nsql' ) { |
1163
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_nsql->new( $self ); |
1164
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'php' ) { |
1166
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_php->new( $self ); |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'perl' ) { |
1169
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_perl->new( $self ); |
1170
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'txt' ) { |
1172
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_txt->new( $self ); |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'bash' ) { |
1175
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_shell->new( $self ); |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'python' ) { |
1178
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_python->new( $self ); |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
} elsif ( $self->{'type'} eq 'js' ) { |
1181
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_js->new( $self ); |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
} else { |
1184
|
0
|
|
|
|
|
0
|
$self->{'content_obj'} = nes_unknown->new( $self ); |
1185
|
|
|
|
|
|
|
} |
1186
|
|
|
|
|
|
|
|
1187
|
1
|
|
|
|
|
2
|
return; |
1188
|
|
|
|
|
|
|
} |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
sub get_source { |
1191
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
1192
|
|
|
|
|
|
|
|
1193
|
1
|
50
|
|
|
|
64
|
if ( open my $fh, '<', "$self->{'file_name'}" ) { |
1194
|
1
|
|
|
|
|
29
|
@{ $self->{'file_souce'} } = <$fh>; |
|
1
|
|
|
|
|
5
|
|
1195
|
1
|
|
|
|
|
9
|
chomp $self->{'file_souce'}[$#{$self->{'file_souce'}}] if |
|
1
|
|
|
|
|
4
|
|
1196
|
1
|
50
|
|
|
|
4
|
$self->{'file_souce'}[$#{$self->{'file_souce'}}]; |
1197
|
1
|
|
|
|
|
12
|
close $fh; |
1198
|
|
|
|
|
|
|
} else { |
1199
|
0
|
|
|
|
|
0
|
warn "Couldn't open $self->{'file_name'}\n"; |
1200
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'nes_error_file_not_exist', $self->{'file_name'} ); |
1201
|
0
|
|
|
|
|
0
|
$self->{'error_not_exist'} = 1; |
1202
|
|
|
|
|
|
|
} |
1203
|
|
|
|
|
|
|
|
1204
|
1
|
|
|
|
|
4
|
return; |
1205
|
|
|
|
|
|
|
} |
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
sub add_tags { |
1208
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1209
|
0
|
|
|
|
|
0
|
my (%tags) = @_; |
1210
|
|
|
|
|
|
|
|
1211
|
0
|
|
|
|
|
0
|
$self->{'content_obj'}->add_tags(%tags); |
1212
|
|
|
|
|
|
|
|
1213
|
0
|
|
|
|
|
0
|
return; |
1214
|
|
|
|
|
|
|
} |
1215
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
sub add_parent_tags { |
1217
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1218
|
|
|
|
|
|
|
|
1219
|
1
|
|
|
|
|
2
|
foreach my $tag ( keys %{ $self->{'previous'}->{'content_obj'}->{'tags'} } ) { |
|
1
|
|
|
|
|
6
|
|
1220
|
0
|
|
|
|
|
0
|
$self->{'content_obj'}->{'tags'}{$tag} = $self->{'previous'}->{'content_obj'}->{'tags'}{$tag}; |
1221
|
|
|
|
|
|
|
} |
1222
|
|
|
|
|
|
|
|
1223
|
1
|
|
|
|
|
3
|
return; |
1224
|
|
|
|
|
|
|
} |
1225
|
|
|
|
|
|
|
|
1226
|
|
|
|
|
|
|
sub set_out_content { |
1227
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1228
|
0
|
|
|
|
|
0
|
my ($out) = @_; |
1229
|
|
|
|
|
|
|
|
1230
|
0
|
|
|
|
|
0
|
$self->{'content_obj'}->set_out($out); |
1231
|
|
|
|
|
|
|
|
1232
|
0
|
|
|
|
|
0
|
return; |
1233
|
|
|
|
|
|
|
} |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
sub get_out_content { |
1236
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1237
|
|
|
|
|
|
|
|
1238
|
0
|
|
|
|
|
0
|
return $self->{'content_obj'}->{'out'}; |
1239
|
|
|
|
|
|
|
} |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
sub set_tags { |
1242
|
1
|
|
|
1
|
|
352
|
my $self = shift; |
1243
|
1
|
|
|
|
|
4
|
my (%tags) = @_; |
1244
|
|
|
|
|
|
|
|
1245
|
1
|
|
|
|
|
18
|
$self->{'content_obj'}->set_tags(%tags); |
1246
|
|
|
|
|
|
|
|
1247
|
1
|
|
|
|
|
3
|
return; |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
sub get_tag { |
1251
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1252
|
0
|
|
|
|
|
0
|
my ($tag) = @_; |
1253
|
|
|
|
|
|
|
|
1254
|
0
|
|
|
|
|
0
|
return $self->{'content_obj'}->{'tags'}{$tag}; |
1255
|
|
|
|
|
|
|
} |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
sub set_out { |
1258
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1259
|
|
|
|
|
|
|
|
1260
|
1
|
50
|
50
|
|
|
41
|
$self->{'file_nes_line'} = $self->{'file_souce'}[0] |
1261
|
|
|
|
|
|
|
if $self->{'file_souce'}[0] =~ /$Nes::Tags::start\s*$Nes::Tags::nes/i || ''; |
1262
|
|
|
|
|
|
|
|
1263
|
1
|
|
|
|
|
8
|
my $interpret = nes_interpret->new(); |
1264
|
1
|
|
|
|
|
7
|
my @param = $interpret->replace_NES( $self->{'file_nes_line'} ); |
1265
|
1
|
|
|
|
|
3
|
chomp $self->{'file_nes_line'}; |
1266
|
|
|
|
|
|
|
|
1267
|
1
|
50
|
|
|
|
4
|
if ( $param[0] ) { |
1268
|
1
|
|
|
|
|
2
|
shift @{ $self->{'file_souce'} }; # eliminamos la primera linea |
|
1
|
|
|
|
|
3
|
|
1269
|
1
|
|
|
|
|
3
|
$self->{'script_ver'} = shift @param; |
1270
|
1
|
|
|
|
|
2
|
@{ $self->{'file_script'} } = @param; |
|
1
|
|
|
|
|
3
|
|
1271
|
|
|
|
|
|
|
} |
1272
|
|
|
|
|
|
|
|
1273
|
1
|
|
|
|
|
3
|
$self->{'out'} = ''; |
1274
|
1
|
|
|
|
|
2
|
foreach my $line (@{$self->{'file_souce'}}) { |
|
1
|
|
|
|
|
2
|
|
1275
|
11
|
|
|
|
|
17
|
$self->{'out'} .= $line; |
1276
|
|
|
|
|
|
|
} |
1277
|
|
|
|
|
|
|
|
1278
|
1
|
|
|
|
|
8
|
foreach my $script ( @{ $self->{'file_script'} } ) { |
|
1
|
|
|
|
|
2
|
|
1279
|
1
|
50
|
|
|
|
4
|
$script = 'none' if !$script; |
1280
|
1
|
50
|
|
|
|
4
|
next if $script eq 'none'; |
1281
|
|
|
|
|
|
|
} |
1282
|
|
|
|
|
|
|
|
1283
|
1
|
|
|
|
|
3
|
return; |
1284
|
|
|
|
|
|
|
} |
1285
|
|
|
|
|
|
|
|
1286
|
|
|
|
|
|
|
sub go { |
1287
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1288
|
|
|
|
|
|
|
|
1289
|
0
|
|
|
|
|
0
|
$self->{'content_obj'}->go(); |
1290
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_parent_dir($self->{'file_dir'}); |
1291
|
|
|
|
|
|
|
|
1292
|
0
|
|
|
|
|
0
|
return; |
1293
|
|
|
|
|
|
|
} |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
sub interpret { |
1296
|
1
|
|
|
1
|
|
5
|
my $self = shift; |
1297
|
|
|
|
|
|
|
|
1298
|
1
|
|
|
|
|
9
|
$self->{'content_obj'}->interpret(); |
1299
|
|
|
|
|
|
|
|
1300
|
1
|
|
|
|
|
3
|
return; |
1301
|
|
|
|
|
|
|
} |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
sub get_out { |
1304
|
2
|
|
|
2
|
|
1753
|
my $self = shift; |
1305
|
|
|
|
|
|
|
|
1306
|
2
|
|
|
|
|
15
|
return $self->{'content_obj'}->get_out(); |
1307
|
|
|
|
|
|
|
} |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
sub out { |
1310
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1311
|
|
|
|
|
|
|
|
1312
|
0
|
0
|
|
|
|
0
|
if ( !$self->{'nes'}->{'debug_info'}{'is_load'} ) { |
1313
|
0
|
0
|
|
|
|
0
|
if ( ! $self->{'content_obj'}->{'is_binary'} ) { |
1314
|
0
|
|
|
|
|
0
|
while ( $self->{'content_obj'}->{'out'} =~ s/$Nes::Tags::start(\s*($Nes::Tags::all_or).+?)$Nes::Tags::end//gsio ) |
1315
|
|
|
|
|
|
|
{ |
1316
|
|
|
|
|
|
|
# impedir que los tags con error o no reemplazados aparezcan en la salida |
1317
|
|
|
|
|
|
|
} |
1318
|
|
|
|
|
|
|
} |
1319
|
|
|
|
|
|
|
} |
1320
|
|
|
|
|
|
|
|
1321
|
0
|
0
|
|
|
|
0
|
$self->{'content_obj'}->out() if $self->{'nes'}->{'print_out'}; |
1322
|
|
|
|
|
|
|
|
1323
|
0
|
|
|
|
|
0
|
return; |
1324
|
|
|
|
|
|
|
} |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
} |
1327
|
|
|
|
|
|
|
|
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
{ |
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
package nes_content; |
1332
|
3
|
|
|
3
|
|
20
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
9704
|
|
1333
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
sub new { |
1336
|
1
|
|
|
1
|
|
2
|
my $class = shift; |
1337
|
1
|
|
|
|
|
7
|
my $self = $class->SUPER::new(); |
1338
|
1
|
|
|
|
|
3
|
my ($container) = @_; |
1339
|
|
|
|
|
|
|
|
1340
|
1
|
|
|
|
|
2
|
$self->{'container'} = $container; |
1341
|
1
|
|
|
|
|
3
|
$self->{'file_script'} = $self->{'container'}->{'file_script'}; |
1342
|
1
|
|
|
|
|
4
|
$self->{'out'} = $self->{'container'}->{'out'}; |
1343
|
1
|
|
|
|
|
2
|
$self->{'exec'} = 0; |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
# default content type |
1346
|
1
|
|
|
|
|
4
|
$self->{'Content-type'} = "Content-type: text/html"; |
1347
|
1
|
|
|
|
|
3
|
$self->{'HTTP-status'} = "200 Ok"; |
1348
|
1
|
|
|
|
|
3
|
$self->{'X-Powered-By'} = "Nes/$VERSION"; |
1349
|
1
|
|
|
|
|
2
|
$self->{'TAG_HTTP-headers'} = ''; |
1350
|
|
|
|
|
|
|
|
1351
|
1
|
|
|
|
|
3
|
return $self; |
1352
|
|
|
|
|
|
|
} |
1353
|
|
|
|
|
|
|
|
1354
|
|
|
|
|
|
|
sub add_tags { |
1355
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1356
|
0
|
|
|
|
|
0
|
my %tags; |
1357
|
0
|
|
|
|
|
0
|
(%tags) = @_; |
1358
|
|
|
|
|
|
|
|
1359
|
0
|
|
|
|
|
0
|
foreach my $tag ( keys %tags ) { |
1360
|
0
|
|
|
|
|
0
|
$self->{'tags'}{$tag} = $tags{$tag}; |
1361
|
|
|
|
|
|
|
} |
1362
|
|
|
|
|
|
|
|
1363
|
0
|
|
|
|
|
0
|
$self->{'TAG_HTTP-headers'} = $self->{'tags'}{'HTTP-headers'}; |
1364
|
0
|
|
|
|
|
0
|
$self->{'tags'}{'HTTP-headers'} = ''; |
1365
|
|
|
|
|
|
|
|
1366
|
0
|
|
|
|
|
0
|
return; |
1367
|
|
|
|
|
|
|
} |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
sub set_tags { |
1370
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1371
|
1
|
|
|
|
|
2
|
my %tags; |
1372
|
1
|
|
|
|
|
3
|
(%tags) = @_; |
1373
|
|
|
|
|
|
|
|
1374
|
1
|
|
|
|
|
4
|
foreach my $tag ( keys %tags ) { |
1375
|
1
|
|
|
|
|
5
|
$self->{'tags'}{$tag} = $tags{$tag}; |
1376
|
|
|
|
|
|
|
} |
1377
|
|
|
|
|
|
|
|
1378
|
1
|
|
|
|
|
5
|
$self->{'TAG_HTTP-headers'} = $self->{'tags'}{'HTTP-headers'}; |
1379
|
1
|
50
|
|
|
|
5
|
$self->{'tags'}{'_HTTP_headers_'} = $self->{'tags'}{'HTTP-headers'} if $self->{'tags'}{'HTTP-headers'}; |
1380
|
1
|
|
|
|
|
3
|
delete $self->{'tags'}{'HTTP-headers'}; |
1381
|
|
|
|
|
|
|
|
1382
|
1
|
|
|
|
|
3
|
return; |
1383
|
|
|
|
|
|
|
} |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
sub interpret { |
1386
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
1387
|
1
|
|
|
|
|
2
|
my %tags; |
1388
|
|
|
|
|
|
|
|
1389
|
1
|
|
|
|
|
7
|
$self->{'interpret'} = nes_interpret->new( $self->{'out'} ); |
1390
|
1
|
|
|
|
|
3
|
$self->{'out'} = $self->{'interpret'}->go( %{ $self->{'tags'} } ); |
|
1
|
|
|
|
|
7
|
|
1391
|
|
|
|
|
|
|
|
1392
|
1
|
|
|
|
|
2
|
return; |
1393
|
|
|
|
|
|
|
} |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
sub get_out { |
1396
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
1397
|
|
|
|
|
|
|
|
1398
|
2
|
|
|
|
|
8
|
return $self->{'out'}; |
1399
|
|
|
|
|
|
|
} |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
sub set_out { |
1402
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1403
|
0
|
|
|
|
|
0
|
my ($out) = @_; |
1404
|
|
|
|
|
|
|
|
1405
|
0
|
|
|
|
|
0
|
$self->{'out'} = $out; |
1406
|
|
|
|
|
|
|
|
1407
|
0
|
|
|
|
|
0
|
return; |
1408
|
|
|
|
|
|
|
} |
1409
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
sub go_plugin_first { |
1411
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1412
|
|
|
|
|
|
|
|
1413
|
0
|
|
|
|
|
0
|
my $self_file = $self->{'container'}->{'file_name'}; |
1414
|
0
|
|
|
|
|
0
|
my $top_file = $self->{'top_container'}->{'file'}; |
1415
|
|
|
|
|
|
|
|
1416
|
0
|
0
|
|
|
|
0
|
if ( $self_file eq $top_file ) { |
1417
|
0
|
|
|
|
|
0
|
foreach my $plugin ( @{$self->{'CFG'}{'auto_load_plugin_top_first'}} ) { |
|
0
|
|
|
|
|
0
|
|
1418
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $plugin ); |
1419
|
0
|
|
|
|
|
0
|
$plugin = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
1420
|
0
|
|
|
|
|
0
|
$self->do_script( $plugin ); |
1421
|
|
|
|
|
|
|
} |
1422
|
|
|
|
|
|
|
} |
1423
|
|
|
|
|
|
|
|
1424
|
0
|
|
|
|
|
0
|
foreach my $plugin ( @{$self->{'CFG'}{'auto_load_plugin_all_first'}} ) { |
|
0
|
|
|
|
|
0
|
|
1425
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $plugin ); |
1426
|
0
|
|
|
|
|
0
|
$plugin = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
1427
|
0
|
|
|
|
|
0
|
$self->do_script( $plugin ); |
1428
|
|
|
|
|
|
|
} |
1429
|
|
|
|
|
|
|
|
1430
|
0
|
|
|
|
|
0
|
return; |
1431
|
|
|
|
|
|
|
} |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
sub go_plugin_last { |
1434
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1435
|
|
|
|
|
|
|
|
1436
|
0
|
|
|
|
|
0
|
$self->{'exec'} = 1; |
1437
|
|
|
|
|
|
|
|
1438
|
0
|
|
|
|
|
0
|
my $self_file = $self->{'container'}->{'file_name'}; |
1439
|
0
|
|
|
|
|
0
|
my $top_file = $self->{'top_container'}->{'file'}; |
1440
|
|
|
|
|
|
|
|
1441
|
0
|
0
|
|
|
|
0
|
if ( $self_file eq $top_file ) { |
1442
|
0
|
|
|
|
|
0
|
foreach my $plugin ( @{$self->{'CFG'}{'auto_load_plugin_top_last'}} ) { |
|
0
|
|
|
|
|
0
|
|
1443
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $plugin ); |
1444
|
0
|
|
|
|
|
0
|
$plugin = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
1445
|
0
|
|
|
|
|
0
|
$self->do_script( $plugin ); |
1446
|
|
|
|
|
|
|
} |
1447
|
|
|
|
|
|
|
} |
1448
|
|
|
|
|
|
|
|
1449
|
0
|
|
|
|
|
0
|
foreach my $plugin ( @{$self->{'CFG'}{'auto_load_plugin_all_last'}} ) { |
|
0
|
|
|
|
|
0
|
|
1450
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $plugin ); |
1451
|
0
|
|
|
|
|
0
|
$plugin = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
1452
|
0
|
|
|
|
|
0
|
$self->do_script( $plugin ); |
1453
|
|
|
|
|
|
|
} |
1454
|
|
|
|
|
|
|
|
1455
|
0
|
|
|
|
|
0
|
return; |
1456
|
|
|
|
|
|
|
} |
1457
|
|
|
|
|
|
|
|
1458
|
|
|
|
|
|
|
sub go { |
1459
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1460
|
|
|
|
|
|
|
|
1461
|
0
|
|
|
|
|
0
|
$self->go_plugin_first(); |
1462
|
|
|
|
|
|
|
|
1463
|
0
|
|
|
|
|
0
|
$self->exec_scripts(); |
1464
|
|
|
|
|
|
|
|
1465
|
0
|
|
|
|
|
0
|
$self->go_plugin_last(); |
1466
|
|
|
|
|
|
|
|
1467
|
0
|
|
|
|
|
0
|
return; |
1468
|
|
|
|
|
|
|
} |
1469
|
|
|
|
|
|
|
|
1470
|
|
|
|
|
|
|
sub exec_scripts { |
1471
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1472
|
|
|
|
|
|
|
|
1473
|
0
|
|
|
|
|
0
|
foreach my $script ( @{ $self->{'file_script'} } ) { |
|
0
|
|
|
|
|
0
|
|
1474
|
0
|
0
|
|
|
|
0
|
if ( $script eq 'none' ) { |
1475
|
0
|
0
|
|
|
|
0
|
$self->{'top_container'}->{'max_scripts'}-- || die "Possible infinite loop in MAX_SCRIPTS"; |
1476
|
0
|
|
|
|
|
0
|
do { |
1477
|
0
|
|
|
|
|
0
|
my $nes_obj = Nes::Singleton->new(); |
1478
|
0
|
|
|
|
|
0
|
$nes_obj->out(); |
1479
|
|
|
|
|
|
|
}; |
1480
|
0
|
|
|
|
|
0
|
next; |
1481
|
|
|
|
|
|
|
} |
1482
|
0
|
0
|
|
|
|
0
|
if ( $script ) { |
1483
|
0
|
|
|
|
|
0
|
$self->do_script( $script ); |
1484
|
|
|
|
|
|
|
} |
1485
|
|
|
|
|
|
|
} |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
} |
1488
|
|
|
|
|
|
|
|
1489
|
|
|
|
|
|
|
sub do_script { |
1490
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1491
|
0
|
|
|
|
|
0
|
my ($script) = @_; |
1492
|
|
|
|
|
|
|
|
1493
|
0
|
0
|
|
|
|
0
|
$self->{'top_container'}->{'max_scripts'}-- || die "Possible infinite loop in MAX_SCRIPTS"; |
1494
|
|
|
|
|
|
|
|
1495
|
0
|
|
|
|
|
0
|
$script = $self->{'top_container'}->get_file_path( $script ); |
1496
|
|
|
|
|
|
|
|
1497
|
0
|
|
|
|
|
0
|
my $script_dir = $script; |
1498
|
0
|
|
|
|
|
0
|
$script_dir =~ s/(.*)(\\|\/).*/$1/; |
1499
|
0
|
0
|
|
|
|
0
|
push( @INC, $script_dir ) if !$self->{'top_container'}->{'in_inc'}->{$script_dir}; |
1500
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->{'in_inc'}->{$script_dir} = 1; |
1501
|
|
|
|
|
|
|
|
1502
|
0
|
|
|
|
|
0
|
my $return = do $script; |
1503
|
0
|
0
|
|
|
|
0
|
unless ($return) { |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
# mod_perl muestra un error cuando se usa exit |
1506
|
0
|
0
|
|
|
|
0
|
return if $@ =~ /ModPerl::Util::exit/; |
1507
|
|
|
|
|
|
|
|
1508
|
0
|
0
|
|
|
|
0
|
warn "couldn't parse $script: $@" if $@; |
1509
|
0
|
0
|
|
|
|
0
|
warn "couldn't do $script: $!" unless defined $return; |
1510
|
0
|
0
|
|
|
|
0
|
warn "couldn't run $script" unless $return; |
1511
|
|
|
|
|
|
|
} |
1512
|
|
|
|
|
|
|
|
1513
|
0
|
|
|
|
|
0
|
return; |
1514
|
|
|
|
|
|
|
} |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
sub out { |
1517
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1518
|
|
|
|
|
|
|
|
1519
|
0
|
0
|
|
|
|
0
|
if ( $self->{'nes'}->{'debug_info'}{'obj'}{'location'} ) { |
1520
|
0
|
|
|
|
|
0
|
print $self->{'out'}; |
1521
|
0
|
|
|
|
|
0
|
return; |
1522
|
|
|
|
|
|
|
} |
1523
|
|
|
|
|
|
|
|
1524
|
0
|
|
|
|
|
0
|
print $self->{'cookies'}->out; |
1525
|
0
|
|
|
|
|
0
|
print "X-Powered-By: $self->{'X-Powered-By'}\n"; |
1526
|
|
|
|
|
|
|
# print "Status: $self->{'HTTP-status'}\n" if !$self->{'tags'}{'HTTP-headers'}; |
1527
|
0
|
|
0
|
|
|
0
|
print $self->{'TAG_HTTP-headers'} || $self->{'Content-type'}."\n\n"; |
1528
|
0
|
|
|
|
|
0
|
print $self->{'out'}; |
1529
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
} |
1531
|
|
|
|
|
|
|
|
1532
|
|
|
|
|
|
|
sub location { |
1533
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1534
|
0
|
|
|
|
|
0
|
my ($location, $status) = @_; |
1535
|
0
|
0
|
|
|
|
0
|
$status = "302 Found" if !$status; |
1536
|
|
|
|
|
|
|
|
1537
|
0
|
|
|
|
|
0
|
print $self->{'cookies'}->out; |
1538
|
0
|
|
|
|
|
0
|
print "X-Powered-By: $self->{'X-Powered-By'}\n"; |
1539
|
0
|
0
|
|
|
|
0
|
if ( $self->{'nes'}->{'debug_info'}{'is_load'} ) { |
1540
|
0
|
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}{'location'} = 1; |
1541
|
0
|
|
|
|
|
0
|
print "Content-type: text/html\n\n"; |
1542
|
0
|
|
|
|
|
0
|
print "Location"; |
1543
|
0
|
|
|
|
|
0
|
print ""; |
1544
|
0
|
|
|
|
|
0
|
print "* Automatic location deactivated by debug_info, to enable display the debug information "; |
1545
|
0
|
|
|
|
|
0
|
warn "Warning: this calls to HTTP Location ( *** ignores subsequent errors *** )\n"; |
1546
|
|
|
|
|
|
|
} else { |
1547
|
0
|
|
|
|
|
0
|
print "Status: $status\n"; |
1548
|
0
|
|
|
|
|
0
|
print "Location: $location\n\n"; |
1549
|
0
|
|
|
|
|
0
|
exit; |
1550
|
|
|
|
|
|
|
} |
1551
|
|
|
|
|
|
|
|
1552
|
|
|
|
|
|
|
} |
1553
|
|
|
|
|
|
|
|
1554
|
|
|
|
|
|
|
} |
1555
|
|
|
|
|
|
|
|
1556
|
|
|
|
|
|
|
{ |
1557
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
package nes_html; |
1559
|
3
|
|
|
3
|
|
55
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
375
|
|
1560
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1561
|
|
|
|
|
|
|
|
1562
|
|
|
|
|
|
|
sub new { |
1563
|
1
|
|
|
1
|
|
3
|
my $class = shift; |
1564
|
1
|
|
|
|
|
2
|
my ( $container ) = @_; |
1565
|
1
|
|
|
|
|
9
|
my $self = $class->SUPER::new($container); |
1566
|
|
|
|
|
|
|
|
1567
|
1
|
|
|
|
|
2
|
$self->{'Content-type'} = "Content-type: text/html"; |
1568
|
|
|
|
|
|
|
|
1569
|
1
|
|
|
|
|
3
|
return $self; |
1570
|
|
|
|
|
|
|
} |
1571
|
|
|
|
|
|
|
|
1572
|
|
|
|
|
|
|
} |
1573
|
|
|
|
|
|
|
|
1574
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
{ |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
package nes_nsql; |
1578
|
3
|
|
|
3
|
|
23
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
445
|
|
1579
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1580
|
|
|
|
|
|
|
|
1581
|
|
|
|
|
|
|
sub new { |
1582
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1583
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1584
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1585
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
# @{ $self->{'file_script'} } = @scripts; |
1587
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/html"; |
1588
|
|
|
|
|
|
|
|
1589
|
0
|
|
|
|
|
0
|
return $self; |
1590
|
|
|
|
|
|
|
} |
1591
|
|
|
|
|
|
|
|
1592
|
|
|
|
|
|
|
} |
1593
|
|
|
|
|
|
|
|
1594
|
|
|
|
|
|
|
|
1595
|
|
|
|
|
|
|
{ |
1596
|
|
|
|
|
|
|
|
1597
|
|
|
|
|
|
|
package nes_txt; |
1598
|
3
|
|
|
3
|
|
16
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
446
|
|
1599
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1600
|
|
|
|
|
|
|
|
1601
|
|
|
|
|
|
|
sub new { |
1602
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1603
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1604
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1605
|
|
|
|
|
|
|
|
1606
|
|
|
|
|
|
|
# @{ $self->{'file_script'} } = @scripts; |
1607
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/plain"; |
1608
|
|
|
|
|
|
|
|
1609
|
0
|
|
|
|
|
0
|
return $self; |
1610
|
|
|
|
|
|
|
} |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
} |
1613
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
|
1615
|
|
|
|
|
|
|
{ |
1616
|
|
|
|
|
|
|
|
1617
|
|
|
|
|
|
|
package nes_perl; |
1618
|
3
|
|
|
3
|
|
15
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
724
|
|
1619
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1620
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
sub new { |
1622
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1623
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1624
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1625
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
# @{ $self->{'file_script'} } = @scripts; |
1627
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/html"; |
1628
|
|
|
|
|
|
|
|
1629
|
0
|
|
|
|
|
0
|
return $self; |
1630
|
|
|
|
|
|
|
} |
1631
|
|
|
|
|
|
|
|
1632
|
|
|
|
|
|
|
sub go { |
1633
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1634
|
|
|
|
|
|
|
|
1635
|
0
|
|
|
|
|
0
|
$self->go_plugin_first(); |
1636
|
0
|
0
|
|
|
|
0
|
$self->exec_scripts() if @{ $self->{'file_script'} }; |
|
0
|
|
|
|
|
0
|
|
1637
|
|
|
|
|
|
|
|
1638
|
0
|
|
|
|
|
0
|
require IO::String; |
1639
|
0
|
|
|
|
|
0
|
my $out; |
1640
|
0
|
|
|
|
|
0
|
my $str_fh = IO::String->new($out); |
1641
|
0
|
|
|
|
|
0
|
my $old_fh = select($str_fh); |
1642
|
|
|
|
|
|
|
|
1643
|
0
|
|
|
|
|
0
|
eval $self->{'out'}; |
1644
|
|
|
|
|
|
|
|
1645
|
0
|
0
|
|
|
|
0
|
select($old_fh) if defined $old_fh; |
1646
|
|
|
|
|
|
|
|
1647
|
0
|
|
|
|
|
0
|
$self->{'out'} = $out; |
1648
|
|
|
|
|
|
|
|
1649
|
0
|
|
|
|
|
0
|
$self->go_plugin_last(); |
1650
|
|
|
|
|
|
|
|
1651
|
0
|
|
|
|
|
0
|
return; |
1652
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
} |
1654
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
} |
1656
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
{ |
1659
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
package nes_shell; |
1661
|
3
|
|
|
3
|
|
16
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1891
|
|
1662
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1663
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
sub new { |
1665
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1666
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1667
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1668
|
|
|
|
|
|
|
|
1669
|
|
|
|
|
|
|
# @{ $self->{'file_script'} } = @scripts; |
1670
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/html"; |
1671
|
|
|
|
|
|
|
|
1672
|
0
|
|
|
|
|
0
|
return ($self); |
1673
|
|
|
|
|
|
|
} |
1674
|
|
|
|
|
|
|
|
1675
|
|
|
|
|
|
|
sub go { |
1676
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1677
|
|
|
|
|
|
|
|
1678
|
0
|
|
|
|
|
0
|
$self->go_plugin_first(); |
1679
|
0
|
0
|
|
|
|
0
|
$self->exec_scripts() if @{ $self->{'file_script'} }; |
|
0
|
|
|
|
|
0
|
|
1680
|
|
|
|
|
|
|
|
1681
|
0
|
0
|
|
|
|
0
|
warn "Not Found: ".$self->{'CFG'}{'shell_cline'} if !-e $self->{'CFG'}{'shell_cline'}; |
1682
|
|
|
|
|
|
|
|
1683
|
0
|
0
|
|
|
|
0
|
if ( $MOD_PERL ) { |
1684
|
|
|
|
|
|
|
|
1685
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->unredirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1686
|
|
|
|
|
|
|
|
1687
|
0
|
|
|
|
|
0
|
require IPC::Run; |
1688
|
|
|
|
|
|
|
# IPC::Open2/Open3 no funcionan con mod_perl |
1689
|
|
|
|
|
|
|
|
1690
|
0
|
|
|
|
|
0
|
local $| = 1; |
1691
|
0
|
|
|
|
|
0
|
my @command = ( $self->{'CFG'}{'shell_cline'} ); |
1692
|
0
|
|
|
|
|
0
|
my ( $writer, $reader, $error ); |
1693
|
0
|
|
|
|
|
0
|
my $h = IPC::Run::start (\@command, \$writer, \$reader, \$error, IPC::Run::timeout( 10 )); |
1694
|
0
|
|
0
|
|
|
0
|
$writer = $self->{'out'} || "\n"; |
1695
|
0
|
|
|
|
|
0
|
IPC::Run::pump $h; |
1696
|
0
|
|
|
|
|
0
|
IPC::Run::finish $h; |
1697
|
0
|
|
|
|
|
0
|
$self->{'out'} = $reader; |
1698
|
|
|
|
|
|
|
|
1699
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->redirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1700
|
0
|
0
|
|
|
|
0
|
warn $error if $error; |
1701
|
|
|
|
|
|
|
|
1702
|
|
|
|
|
|
|
} else { |
1703
|
|
|
|
|
|
|
|
1704
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->unredirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1705
|
|
|
|
|
|
|
|
1706
|
0
|
|
|
|
|
0
|
require IPC::Open3; |
1707
|
0
|
|
|
|
|
0
|
my ( $writer, $reader, $error ); |
1708
|
0
|
|
|
|
|
0
|
my $pid = IPC::Open3::open3( $writer, $reader, $error, "$self->{'CFG'}{'shell_cline'}" ); |
1709
|
0
|
|
|
|
|
0
|
print $writer $self->{'out'}; |
1710
|
0
|
|
|
|
|
0
|
close $writer; |
1711
|
0
|
|
|
|
|
0
|
$self->{'out'} = ''; |
1712
|
0
|
|
|
|
|
0
|
while (<$reader>) { |
1713
|
0
|
|
|
|
|
0
|
$self->{'out'} .= $_; |
1714
|
|
|
|
|
|
|
} |
1715
|
0
|
|
|
|
|
0
|
close $reader; |
1716
|
0
|
|
|
|
|
0
|
waitpid( $pid, 0 ); |
1717
|
|
|
|
|
|
|
|
1718
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->redirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1719
|
0
|
0
|
|
|
|
0
|
warn $error if $error; |
1720
|
|
|
|
|
|
|
|
1721
|
|
|
|
|
|
|
} |
1722
|
|
|
|
|
|
|
|
1723
|
0
|
|
|
|
|
0
|
$self->go_plugin_last(); |
1724
|
|
|
|
|
|
|
|
1725
|
0
|
|
|
|
|
0
|
return; |
1726
|
|
|
|
|
|
|
} |
1727
|
|
|
|
|
|
|
|
1728
|
|
|
|
|
|
|
} |
1729
|
|
|
|
|
|
|
|
1730
|
|
|
|
|
|
|
|
1731
|
|
|
|
|
|
|
{ |
1732
|
|
|
|
|
|
|
|
1733
|
|
|
|
|
|
|
package nes_php; |
1734
|
3
|
|
|
3
|
|
17
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
3198
|
|
1735
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1736
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
sub new { |
1738
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1739
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1740
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1741
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
# @{ $self->{'file_script'} } = @scripts; |
1743
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/html"; |
1744
|
0
|
|
|
|
|
0
|
$self->{'is_binary'} = 0; |
1745
|
0
|
|
|
|
|
0
|
$self->{'file_name'} = $self->{'container'}->{'file_name'}; |
1746
|
|
|
|
|
|
|
|
1747
|
0
|
|
|
|
|
0
|
$self->{'php_wrapper'} = 0; |
1748
|
0
|
0
|
|
|
|
0
|
$self->{'php_wrapper'} = 1 if $self->{'file_name'} eq $self->{'top_container'}->{'file'}; |
1749
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
# damos soporte a include PHP al método GET |
1751
|
0
|
|
|
|
|
0
|
$self->{'start_script'} = ''."\n"; |
1752
|
|
|
|
|
|
|
|
1753
|
0
|
|
|
|
|
0
|
return ($self); |
1754
|
|
|
|
|
|
|
} |
1755
|
|
|
|
|
|
|
|
1756
|
|
|
|
|
|
|
sub go { |
1757
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1758
|
|
|
|
|
|
|
|
1759
|
|
|
|
|
|
|
|
1760
|
0
|
|
|
|
|
0
|
$self->go_plugin_first(); |
1761
|
0
|
0
|
|
|
|
0
|
$self->exec_scripts() if !$self->{'php_wrapper'}; |
1762
|
|
|
|
|
|
|
|
1763
|
0
|
|
|
|
|
0
|
my $cline = $self->{'CFG'}{'php_cline'}; |
1764
|
0
|
0
|
|
|
|
0
|
$cline = $self->{'CFG'}{'php_cgi_cline'} if $self->{'php_wrapper'}; |
1765
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
# warn "Not Found: ".$cline if !-e $cline; |
1767
|
|
|
|
|
|
|
|
1768
|
0
|
0
|
0
|
|
|
0
|
if ( $self->{'php_wrapper'} || $MOD_PERL ) { |
1769
|
|
|
|
|
|
|
# por seguridad |
1770
|
0
|
|
|
|
|
0
|
require Env::C; |
1771
|
0
|
|
|
|
|
0
|
foreach (keys %ENV) { |
1772
|
0
|
|
|
|
|
0
|
my $var = $ENV{$_}; |
1773
|
0
|
|
|
|
|
0
|
utl::no_nes_remove(\$var); |
1774
|
0
|
|
|
|
|
0
|
Env::C::setenv( $_, $var ); |
1775
|
|
|
|
|
|
|
} |
1776
|
|
|
|
|
|
|
} |
1777
|
|
|
|
|
|
|
|
1778
|
0
|
0
|
|
|
|
0
|
if ( $MOD_PERL ) { |
1779
|
|
|
|
|
|
|
|
1780
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->unredirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1781
|
|
|
|
|
|
|
|
1782
|
0
|
|
|
|
|
0
|
local $| = 1; |
1783
|
0
|
|
|
|
|
0
|
require IPC::Run; |
1784
|
|
|
|
|
|
|
|
1785
|
0
|
|
|
|
|
0
|
my @command = split(' ', $cline ); |
1786
|
0
|
|
|
|
|
0
|
my ( $writer, $reader, $error ); |
1787
|
0
|
|
|
|
|
0
|
my $h = IPC::Run::start (\@command, \$writer, \$reader, \$error, IPC::Run::timeout( 30 )); |
1788
|
|
|
|
|
|
|
|
1789
|
0
|
0
|
|
|
|
0
|
if ( $self->{'php_wrapper'} ) { |
1790
|
0
|
0
|
|
|
|
0
|
if ( $ENV{'REQUEST_METHOD'} ne 'GET' ) { |
1791
|
0
|
0
|
|
|
|
0
|
if ( $self->{'query'}->{'save_buffer'} ) { |
1792
|
|
|
|
|
|
|
# todo: es posible que esto consuma mucha memoria en POST grandes |
1793
|
|
|
|
|
|
|
# $writer .= $buffer; sin IPC::Run::pump, pero haciendo pump da |
1794
|
|
|
|
|
|
|
# errores en mod_perl, comprobar |
1795
|
0
|
|
|
|
|
0
|
while ( my $buffer = $self->{'query'}->get_buffer ) { |
1796
|
0
|
|
|
|
|
0
|
$writer .= $buffer; |
1797
|
|
|
|
|
|
|
} |
1798
|
|
|
|
|
|
|
} else { |
1799
|
0
|
|
|
|
|
0
|
$writer = $self->{'query'}->get_buffer_raw; |
1800
|
|
|
|
|
|
|
} |
1801
|
|
|
|
|
|
|
} |
1802
|
|
|
|
|
|
|
} else { |
1803
|
|
|
|
|
|
|
# include PHP no soporta el metodo POST, de momento |
1804
|
0
|
|
|
|
|
0
|
$writer = $self->{'start_script'}.$self->{'out'}; |
1805
|
|
|
|
|
|
|
} |
1806
|
|
|
|
|
|
|
|
1807
|
0
|
|
|
|
|
0
|
IPC::Run::pump $h; |
1808
|
0
|
|
|
|
|
0
|
IPC::Run::finish $h; |
1809
|
0
|
|
|
|
|
0
|
$self->{'out'} = $reader; |
1810
|
|
|
|
|
|
|
|
1811
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->redirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1812
|
0
|
0
|
|
|
|
0
|
warn $error if $error; |
1813
|
|
|
|
|
|
|
|
1814
|
|
|
|
|
|
|
} else { |
1815
|
|
|
|
|
|
|
|
1816
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->unredirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1817
|
|
|
|
|
|
|
|
1818
|
0
|
|
|
|
|
0
|
require IPC::Open3; |
1819
|
0
|
|
|
|
|
0
|
my ( $writer, $reader, $error, $out_error ); |
1820
|
0
|
|
|
|
|
0
|
my $pid = IPC::Open3::open3( $writer, $reader, $error, $cline ); |
1821
|
|
|
|
|
|
|
|
1822
|
0
|
|
|
|
|
0
|
binmode $writer; |
1823
|
0
|
|
|
|
|
0
|
binmode $reader; |
1824
|
|
|
|
|
|
|
|
1825
|
0
|
0
|
|
|
|
0
|
if ( $self->{'php_wrapper'} ) { |
1826
|
0
|
0
|
|
|
|
0
|
if ( $ENV{'REQUEST_METHOD'} ne 'GET' ) { |
1827
|
0
|
0
|
|
|
|
0
|
if ( $self->{'query'}->{'save_buffer'} ) { |
1828
|
0
|
|
|
|
|
0
|
while ( my $buffer = $self->{'query'}->get_buffer ) { |
1829
|
0
|
|
|
|
|
0
|
print $writer $buffer; |
1830
|
|
|
|
|
|
|
} |
1831
|
|
|
|
|
|
|
} else { |
1832
|
0
|
|
|
|
|
0
|
print $writer $self->{'query'}->get_buffer_raw; |
1833
|
|
|
|
|
|
|
} |
1834
|
|
|
|
|
|
|
} |
1835
|
|
|
|
|
|
|
} else { |
1836
|
|
|
|
|
|
|
# include PHP no soporta el metodo POST |
1837
|
0
|
|
|
|
|
0
|
print $writer $self->{'start_script'}.$self->{'out'}; |
1838
|
|
|
|
|
|
|
} |
1839
|
0
|
|
|
|
|
0
|
close $writer; |
1840
|
|
|
|
|
|
|
|
1841
|
0
|
|
|
|
|
0
|
my $buffer; |
1842
|
0
|
|
|
|
|
0
|
$self->{'out'} = ''; |
1843
|
0
|
|
|
|
|
0
|
while ( read($reader, $buffer, 8190) ) { |
1844
|
0
|
|
|
|
|
0
|
$self->{'out'} .= $buffer; |
1845
|
|
|
|
|
|
|
} |
1846
|
0
|
|
|
|
|
0
|
close $reader; |
1847
|
0
|
|
|
|
|
0
|
waitpid( $pid, 0 ); |
1848
|
|
|
|
|
|
|
|
1849
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->redirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1850
|
0
|
0
|
|
|
|
0
|
warn $error if $error; |
1851
|
|
|
|
|
|
|
|
1852
|
|
|
|
|
|
|
} |
1853
|
|
|
|
|
|
|
|
1854
|
0
|
0
|
|
|
|
0
|
if ( $self->{'php_wrapper'} ) { |
1855
|
0
|
|
|
|
|
0
|
( $self->{'HTTP-headers'}, $self->{'out'} ) = split(/$CRLF$CRLF/, $self->{'out'},2); |
1856
|
0
|
|
|
|
|
0
|
$self->{'is_binary'} = $self->{'HTTP-headers'} !~ /Content-Type: text/is; |
1857
|
0
|
0
|
|
|
|
0
|
$self->exec_scripts() if !$self->{'is_binary'}; |
1858
|
|
|
|
|
|
|
} |
1859
|
|
|
|
|
|
|
|
1860
|
0
|
|
|
|
|
0
|
$self->go_plugin_last(); |
1861
|
|
|
|
|
|
|
|
1862
|
0
|
|
|
|
|
0
|
return; |
1863
|
|
|
|
|
|
|
} |
1864
|
|
|
|
|
|
|
|
1865
|
|
|
|
|
|
|
sub out { |
1866
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1867
|
|
|
|
|
|
|
|
1868
|
0
|
0
|
|
|
|
0
|
if ( $self->{'nes'}->{'debug_info'}{'obj'}{'location'} ) { |
1869
|
0
|
|
|
|
|
0
|
print $self->{'out'}; |
1870
|
0
|
|
|
|
|
0
|
return; |
1871
|
|
|
|
|
|
|
} |
1872
|
|
|
|
|
|
|
|
1873
|
0
|
|
|
|
|
0
|
binmode STDOUT; |
1874
|
0
|
|
|
|
|
0
|
print $self->{'cookies'}->out; |
1875
|
0
|
|
|
|
|
0
|
print "X-Powered-By: $self->{'X-Powered-By'}\n"; |
1876
|
|
|
|
|
|
|
# print "Status: $self->{'HTTP-status'}\n" if !$self->{'tags'}{'HTTP-headers'}; |
1877
|
|
|
|
|
|
|
# print $self->{'TAG_HTTP-headers'} || $self->{'Content-type'}."\n\n"; |
1878
|
0
|
0
|
|
|
|
0
|
print $self->{'HTTP-headers'}."\n\n" if !$self->{'TAG_HTTP-headers'}; |
1879
|
0
|
|
|
|
|
0
|
print $self->{'out'}; |
1880
|
|
|
|
|
|
|
|
1881
|
|
|
|
|
|
|
} |
1882
|
|
|
|
|
|
|
|
1883
|
|
|
|
|
|
|
} |
1884
|
|
|
|
|
|
|
|
1885
|
|
|
|
|
|
|
|
1886
|
|
|
|
|
|
|
{ |
1887
|
|
|
|
|
|
|
|
1888
|
|
|
|
|
|
|
package nes_python; |
1889
|
3
|
|
|
3
|
|
46
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1546
|
|
1890
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1891
|
|
|
|
|
|
|
|
1892
|
|
|
|
|
|
|
sub new { |
1893
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1894
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1895
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1896
|
|
|
|
|
|
|
|
1897
|
|
|
|
|
|
|
# @{ $self->{'file_script'} } = @scripts; |
1898
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/html"; |
1899
|
0
|
|
|
|
|
0
|
$self->{'file_name'} = $self->{'container'}->{'file_name'}; |
1900
|
|
|
|
|
|
|
# $self->{'file_name'} = $file_name; |
1901
|
|
|
|
|
|
|
|
1902
|
0
|
|
|
|
|
0
|
return ($self); |
1903
|
|
|
|
|
|
|
} |
1904
|
|
|
|
|
|
|
|
1905
|
|
|
|
|
|
|
sub go { |
1906
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1907
|
|
|
|
|
|
|
|
1908
|
0
|
|
|
|
|
0
|
$self->go_plugin_first(); |
1909
|
0
|
0
|
|
|
|
0
|
$self->exec_scripts() if @{ $self->{'file_script'} };; |
|
0
|
|
|
|
|
0
|
|
1910
|
|
|
|
|
|
|
|
1911
|
0
|
|
|
|
|
0
|
my $cline = $self->{'CFG'}{'python_cline'}; |
1912
|
0
|
|
|
|
|
0
|
my @command = ( $cline ); |
1913
|
|
|
|
|
|
|
|
1914
|
|
|
|
|
|
|
# warn "Not Found: ".$cline if !-e $cline; |
1915
|
|
|
|
|
|
|
|
1916
|
0
|
0
|
|
|
|
0
|
if ( $MOD_PERL ) { |
1917
|
|
|
|
|
|
|
|
1918
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->unredirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1919
|
|
|
|
|
|
|
|
1920
|
0
|
|
|
|
|
0
|
require IPC::Run; |
1921
|
|
|
|
|
|
|
# IPC::Open2/Open3 no funcionan con mod_perl |
1922
|
|
|
|
|
|
|
# *** php_cgi no funciona con IPC::Run |
1923
|
|
|
|
|
|
|
|
1924
|
0
|
|
|
|
|
0
|
local $| = 1; |
1925
|
0
|
|
|
|
|
0
|
my ( $writer, $reader, $error ); |
1926
|
0
|
|
|
|
|
0
|
my $h = IPC::Run::start (\@command, \$writer, \$reader, \$error, IPC::Run::timeout( 10 )); |
1927
|
0
|
|
0
|
|
|
0
|
$writer = $self->{'out'} || "\n"; |
1928
|
0
|
|
|
|
|
0
|
IPC::Run::pump $h; |
1929
|
0
|
|
|
|
|
0
|
IPC::Run::finish $h; |
1930
|
0
|
|
|
|
|
0
|
$self->{'out'} = $reader; |
1931
|
|
|
|
|
|
|
|
1932
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->redirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1933
|
|
|
|
|
|
|
|
1934
|
|
|
|
|
|
|
} else { |
1935
|
|
|
|
|
|
|
|
1936
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->unredirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1937
|
|
|
|
|
|
|
|
1938
|
0
|
|
|
|
|
0
|
require IPC::Open2; |
1939
|
0
|
|
|
|
|
0
|
my ( $reader, $writer ); |
1940
|
0
|
|
|
|
|
0
|
my $pid = IPC::Open2::open2( $reader, $writer, "@command" ); |
1941
|
0
|
|
|
|
|
0
|
print $writer $self->{'out'}; |
1942
|
0
|
|
|
|
|
0
|
close $writer; |
1943
|
0
|
|
|
|
|
0
|
$self->{'out'} = ''; |
1944
|
0
|
|
|
|
|
0
|
while (<$reader>) { |
1945
|
0
|
|
|
|
|
0
|
$self->{'out'} .= $_; |
1946
|
|
|
|
|
|
|
} |
1947
|
0
|
|
|
|
|
0
|
close $reader; |
1948
|
0
|
|
|
|
|
0
|
waitpid( $pid, 0 ); |
1949
|
|
|
|
|
|
|
|
1950
|
0
|
0
|
|
|
|
0
|
$self->{'nes'}->{'debug_info'}{'obj'}->redirect_err if $self->{'nes'}->{'debug_info'}{'is_load'}; |
1951
|
|
|
|
|
|
|
|
1952
|
|
|
|
|
|
|
} |
1953
|
|
|
|
|
|
|
|
1954
|
0
|
|
|
|
|
0
|
$self->go_plugin_last(); |
1955
|
|
|
|
|
|
|
|
1956
|
0
|
|
|
|
|
0
|
return; |
1957
|
|
|
|
|
|
|
} |
1958
|
|
|
|
|
|
|
|
1959
|
|
|
|
|
|
|
} |
1960
|
|
|
|
|
|
|
|
1961
|
|
|
|
|
|
|
{ |
1962
|
|
|
|
|
|
|
|
1963
|
|
|
|
|
|
|
package nes_js; |
1964
|
3
|
|
|
3
|
|
14
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
321
|
|
1965
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1966
|
|
|
|
|
|
|
|
1967
|
|
|
|
|
|
|
sub new { |
1968
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1969
|
0
|
|
|
|
|
0
|
my ( $container ) = @_; |
1970
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1971
|
|
|
|
|
|
|
|
1972
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/javascript"; |
1973
|
|
|
|
|
|
|
|
1974
|
0
|
|
|
|
|
0
|
return $self; |
1975
|
|
|
|
|
|
|
} |
1976
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
} |
1978
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
# lo intenta como si fuese un archivo de texto plano |
1980
|
|
|
|
|
|
|
{ |
1981
|
|
|
|
|
|
|
|
1982
|
|
|
|
|
|
|
package nes_unknown; |
1983
|
3
|
|
|
3
|
|
20
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
311
|
|
1984
|
|
|
|
|
|
|
@ISA = qw( nes_content ); |
1985
|
|
|
|
|
|
|
|
1986
|
|
|
|
|
|
|
sub new { |
1987
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1988
|
0
|
|
|
|
|
0
|
my ($container) = @_; |
1989
|
0
|
|
|
|
|
0
|
my $self = $class->SUPER::new($container); |
1990
|
|
|
|
|
|
|
|
1991
|
0
|
|
|
|
|
0
|
$self->{'Content-type'} = "Content-type: text/plain"; |
1992
|
|
|
|
|
|
|
|
1993
|
0
|
|
|
|
|
0
|
return ($self); |
1994
|
|
|
|
|
|
|
} |
1995
|
|
|
|
|
|
|
|
1996
|
|
|
|
|
|
|
} |
1997
|
|
|
|
|
|
|
|
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
{ |
2000
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
package nes_interpret; |
2002
|
3
|
|
|
3
|
|
13
|
use vars qw(@ISA); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
556
|
|
2003
|
|
|
|
|
|
|
@ISA = qw( Nes ); |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
sub new { |
2006
|
3
|
|
|
3
|
|
18
|
my $class = shift; |
2007
|
3
|
|
|
|
|
6
|
my ($out) = @_; |
2008
|
3
|
|
|
|
|
22
|
my $self = $class->SUPER::new(); |
2009
|
|
|
|
|
|
|
|
2010
|
3
|
|
|
|
|
8
|
$self->{'out'} = $out; |
2011
|
3
|
100
|
|
|
|
17
|
$self->preformat() if $out; |
2012
|
|
|
|
|
|
|
|
2013
|
|
|
|
|
|
|
# banderas para eliminar de las variables código malicioso |
2014
|
3
|
|
|
|
|
11
|
$self->{'security_options'}{'no_sql'} = 0; |
2015
|
3
|
|
|
|
|
9
|
$self->{'security_options'}{'no_html'} = 1; |
2016
|
3
|
|
|
|
|
8
|
$self->{'security_options'}{'no_br'} = 0; |
2017
|
3
|
|
|
|
|
6
|
$self->{'security_options'}{'no_nes'} = 1; |
2018
|
|
|
|
|
|
|
|
2019
|
3
|
|
|
|
|
30
|
return $self; |
2020
|
|
|
|
|
|
|
} |
2021
|
|
|
|
|
|
|
|
2022
|
|
|
|
|
|
|
sub preformat { |
2023
|
2
|
|
|
2
|
|
48
|
my $self = shift; |
2024
|
|
|
|
|
|
|
|
2025
|
2
|
|
|
|
|
6
|
my $reg_block; |
2026
|
|
|
|
|
|
|
my $reg_param; |
2027
|
0
|
|
|
|
|
0
|
my $reg_tag; |
2028
|
0
|
|
|
|
|
0
|
my $all_tag; |
2029
|
0
|
|
|
|
|
0
|
my $reg_tag_plugin; |
2030
|
0
|
|
|
|
|
0
|
my $param_bracket; |
2031
|
0
|
|
|
|
|
0
|
my $comment; |
2032
|
|
|
|
|
|
|
|
2033
|
3
|
|
|
3
|
|
17
|
no warnings; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
129
|
|
2034
|
3
|
|
|
3
|
|
16
|
use re 'eval'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
15139
|
|
2035
|
|
|
|
|
|
|
$reg_block = qr/ |
2036
|
|
|
|
|
|
|
( |
2037
|
2
|
|
|
|
|
15
|
$self->{'pre_start'} |
2038
|
|
|
|
|
|
|
(?> |
2039
|
|
|
|
|
|
|
(?> [^$self->{'pre_start'}$self->{'pre_end'}]+ ) |
2040
|
|
|
|
|
|
|
| |
2041
|
|
|
|
|
|
|
(??{$reg_block}) |
2042
|
|
|
|
|
|
|
)* |
2043
|
|
|
|
|
|
|
$self->{'pre_end'} |
2044
|
|
|
|
|
|
|
) |
2045
|
|
|
|
|
|
|
( ?) |
2046
|
2
|
|
|
|
|
146
|
/ix; |
2047
|
|
|
|
|
|
|
|
2048
|
|
|
|
|
|
|
$param_bracket = qr/ |
2049
|
|
|
|
|
|
|
( |
2050
|
|
|
|
|
|
|
\( # parametros con paréntesis |
2051
|
|
|
|
|
|
|
(?> |
2052
|
|
|
|
|
|
|
(?> [^\(\)]+ ) |
2053
|
|
|
|
|
|
|
| |
2054
|
|
|
|
|
|
|
(??{$param_bracket}) |
2055
|
|
|
|
|
|
|
)* |
2056
|
|
|
|
|
|
|
\) |
2057
|
|
|
|
|
|
|
| |
2058
|
|
|
|
|
|
|
[^\(\)]\S* # o sin paréntesis |
2059
|
|
|
|
|
|
|
) |
2060
|
2
|
|
|
|
|
19
|
/ix; |
2061
|
|
|
|
|
|
|
|
2062
|
2
|
|
|
|
|
241
|
$reg_tag = qr/ |
2063
|
|
|
|
|
|
|
^\s*$self->{'pre_start'}\s* |
2064
|
|
|
|
|
|
|
( |
2065
|
|
|
|
|
|
|
$self->{'tag_var'} | |
2066
|
|
|
|
|
|
|
$self->{'tag_env'} | |
2067
|
|
|
|
|
|
|
$self->{'tag_expre'} | |
2068
|
|
|
|
|
|
|
$self->{'tag_tpl'} | |
2069
|
|
|
|
|
|
|
$self->{'tag_sql'} | |
2070
|
|
|
|
|
|
|
$self->{'tag_field'} | |
2071
|
|
|
|
|
|
|
$self->{'tag_hash'} | |
2072
|
|
|
|
|
|
|
$self->{'tag_plugin'} | |
2073
|
|
|
|
|
|
|
$self->{'tag_include'} |
2074
|
|
|
|
|
|
|
)\s* |
2075
|
|
|
|
|
|
|
$param_bracket |
2076
|
|
|
|
|
|
|
(.*) |
2077
|
|
|
|
|
|
|
\s*$self->{'pre_end'}\s*$ |
2078
|
|
|
|
|
|
|
/isx; |
2079
|
|
|
|
|
|
|
|
2080
|
2
|
|
|
|
|
142
|
$reg_tag_plugin = qr{(?six) |
2081
|
|
|
|
|
|
|
^\s*$self->{'pre_start'}\s* |
2082
|
|
|
|
|
|
|
$self->{'tag_plugin'} |
2083
|
|
|
|
|
|
|
\s* |
2084
|
|
|
|
|
|
|
(\S+) # tag del plugin |
2085
|
|
|
|
|
|
|
\s* |
2086
|
|
|
|
|
|
|
$param_bracket # parametros |
2087
|
|
|
|
|
|
|
(.*) # code |
2088
|
|
|
|
|
|
|
$self->{'pre_end'}\s*$ |
2089
|
|
|
|
|
|
|
}; |
2090
|
|
|
|
|
|
|
|
2091
|
|
|
|
|
|
|
$comment = qr/ |
2092
|
|
|
|
|
|
|
( |
2093
|
1
|
|
|
|
|
9
|
$self->{'pre_start'}\s*$self->{'tag_comment'} |
2094
|
|
|
|
|
|
|
(?> |
2095
|
|
|
|
|
|
|
(?> [^$self->{'pre_start'}$self->{'pre_end'}]+ ) |
2096
|
|
|
|
|
|
|
| |
2097
|
|
|
|
|
|
|
(??{$reg_block}) |
2098
|
|
|
|
|
|
|
)* |
2099
|
|
|
|
|
|
|
$self->{'pre_end'} |
2100
|
|
|
|
|
|
|
) |
2101
|
|
|
|
|
|
|
( ?)(\s*) |
2102
|
2
|
|
|
|
|
118
|
/ix; |
2103
|
|
|
|
|
|
|
|
2104
|
2
|
|
|
|
|
12
|
$self->{'blocks'} = $reg_block; |
2105
|
2
|
|
|
|
|
6
|
$self->{'block_tag'} = $reg_tag; |
2106
|
2
|
|
|
|
|
9
|
$self->{'block_plugin'} = $reg_tag_plugin; |
2107
|
2
|
|
|
|
|
4
|
$self->{'param_bracket'} = $param_bracket; |
2108
|
2
|
|
|
|
|
6
|
$self->{'block_comment'} = $comment; |
2109
|
|
|
|
|
|
|
|
2110
|
2
|
|
|
|
|
23
|
$self->{'out'} =~ s/$self->{'pre_start'}/$self->{'pre_subs_start'}/g; |
2111
|
2
|
|
|
|
|
31
|
$self->{'out'} =~ s/$self->{'pre_end'}/$self->{'pre_subs_end'}/g; |
2112
|
|
|
|
|
|
|
|
2113
|
2
|
|
|
|
|
27
|
$self->{'out'} =~ s/$self->{'tag_start'}/$self->{'pre_start'}/g; |
2114
|
2
|
|
|
|
|
34
|
$self->{'out'} =~ s/$self->{'tag_end'}/$self->{'pre_end'}/g; |
2115
|
|
|
|
|
|
|
|
2116
|
|
|
|
|
|
|
# elimina los comentarios, eliminándolos aquí ahorramos CPU |
2117
|
2
|
|
|
|
|
18
|
$self->{'out'} =~ s/$self->{'block_comment'}//g; |
2118
|
|
|
|
|
|
|
|
2119
|
2
|
|
|
|
|
7
|
return; |
2120
|
|
|
|
|
|
|
} |
2121
|
|
|
|
|
|
|
|
2122
|
|
|
|
|
|
|
sub clear_tags { |
2123
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2124
|
|
|
|
|
|
|
|
2125
|
0
|
|
|
|
|
0
|
$self->{'out'} =~ s/$self->{'blocks'}//g; |
2126
|
|
|
|
|
|
|
|
2127
|
|
|
|
|
|
|
# $self->{'out'} =~ s/$self->{'pre_start'}/$self->{'tag_start'}/g; |
2128
|
|
|
|
|
|
|
# $self->{'out'} =~ s/$self->{'pre_end'}/$self->{'tag_end'}/g; |
2129
|
|
|
|
|
|
|
# |
2130
|
|
|
|
|
|
|
# $self->{'out'} =~ s/$self->{'pre_subs_start'}/$self->{'pre_start'}/g; |
2131
|
|
|
|
|
|
|
# $self->{'out'} =~ s/$self->{'pre_subs_end'}/$self->{'pre_end'}/g; |
2132
|
|
|
|
|
|
|
|
2133
|
0
|
|
|
|
|
0
|
return; |
2134
|
|
|
|
|
|
|
} |
2135
|
|
|
|
|
|
|
|
2136
|
|
|
|
|
|
|
sub postformat { |
2137
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2138
|
0
|
|
|
|
|
0
|
my ($out) = @_; |
2139
|
|
|
|
|
|
|
|
2140
|
0
|
|
|
|
|
0
|
$out =~ s/$self->{'pre_start'}/$self->{'tag_start'}/g; |
2141
|
0
|
|
|
|
|
0
|
$out =~ s/$self->{'pre_end'}/$self->{'tag_end'}/g; |
2142
|
|
|
|
|
|
|
|
2143
|
0
|
|
|
|
|
0
|
$out =~ s/$self->{'pre_subs_start'}/$self->{'pre_start'}/g; |
2144
|
0
|
|
|
|
|
0
|
$out =~ s/$self->{'pre_subs_end'}/$self->{'pre_end'}/g; |
2145
|
|
|
|
|
|
|
|
2146
|
0
|
|
|
|
|
0
|
return $out; |
2147
|
|
|
|
|
|
|
} |
2148
|
|
|
|
|
|
|
|
2149
|
|
|
|
|
|
|
sub postformat2 { |
2150
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
2151
|
|
|
|
|
|
|
|
2152
|
2
|
|
|
|
|
63
|
$self->{'out'} =~ s/$self->{'pre_start'}/$self->{'tag_start'}/g; |
2153
|
2
|
|
|
|
|
20
|
$self->{'out'} =~ s/$self->{'pre_end'}/$self->{'tag_end'}/g; |
2154
|
|
|
|
|
|
|
|
2155
|
2
|
|
|
|
|
19
|
$self->{'out'} =~ s/$self->{'pre_subs_start'}/$self->{'pre_start'}/g; |
2156
|
2
|
|
|
|
|
17
|
$self->{'out'} =~ s/$self->{'pre_subs_end'}/$self->{'pre_end'}/g; |
2157
|
|
|
|
|
|
|
|
2158
|
2
|
|
|
|
|
6
|
return; |
2159
|
|
|
|
|
|
|
} |
2160
|
|
|
|
|
|
|
|
2161
|
|
|
|
|
|
|
sub go { |
2162
|
2
|
|
|
2
|
|
15
|
my $self = shift; |
2163
|
2
|
|
|
|
|
7
|
my (%tags) = @_; |
2164
|
|
|
|
|
|
|
|
2165
|
2
|
|
|
|
|
8
|
foreach my $tag ( keys %tags ) { |
2166
|
2
|
|
|
|
|
10
|
$self->{'tags'}{$tag} = $tags{$tag}; |
2167
|
|
|
|
|
|
|
} |
2168
|
|
|
|
|
|
|
|
2169
|
2
|
|
50
|
|
|
18
|
while ( $self->{'out'} =~ s/$self->{'blocks'}/$self->replace_block($1,($2 || ''),($3 || ''))/e ) { |
|
2
|
|
50
|
|
|
36
|
|
2170
|
|
|
|
|
|
|
|
2171
|
|
|
|
|
|
|
# con los "$space" se "intenta" dejar el HTML como estaba sin huecos |
2172
|
|
|
|
|
|
|
# $self->replace_block($1).$2.$3.$4 No funciona, $1... pierden su valor |
2173
|
|
|
|
|
|
|
# cuando vuelven de la función |
2174
|
|
|
|
|
|
|
# $2.$3.$4$self->replace_block($1) Sí funcionaría, curiosamente? |
2175
|
|
|
|
|
|
|
} |
2176
|
|
|
|
|
|
|
|
2177
|
2
|
|
|
|
|
11
|
$self->postformat2; |
2178
|
2
|
|
|
|
|
10
|
return $self->{'out'}; |
2179
|
|
|
|
|
|
|
} |
2180
|
|
|
|
|
|
|
|
2181
|
|
|
|
|
|
|
sub param_block { |
2182
|
3
|
|
|
3
|
|
4
|
my $self = shift; |
2183
|
3
|
|
|
|
|
8
|
my ($params,$skip_inclusion) = @_; |
2184
|
|
|
|
|
|
|
|
2185
|
3
|
50
|
|
|
|
9
|
return if !$params; |
2186
|
|
|
|
|
|
|
|
2187
|
|
|
|
|
|
|
# los parámetros pueden tener estos formatos: |
2188
|
|
|
|
|
|
|
# parámetro: |
2189
|
|
|
|
|
|
|
# sin paréntesis, sin comomillas, sin espacios, un sólo parámetro |
2190
|
|
|
|
|
|
|
# (parámetro,parámetro): |
2191
|
|
|
|
|
|
|
# con paréntesis, sin espacios, con o sin comillas, uno o más parámetros |
2192
|
|
|
|
|
|
|
# separados por comas |
2193
|
|
|
|
|
|
|
# ('parámetro uno','parámetro,dos'): |
2194
|
|
|
|
|
|
|
# comillas necesarias cuando hay espacios o comas en los parámetros. |
2195
|
|
|
|
|
|
|
# ('parámetro \'uno'): |
2196
|
|
|
|
|
|
|
# las comillas requieren barra invertida |
2197
|
|
|
|
|
|
|
# las comillas dobles no se utilizan, se reservan para su uso en futuras |
2198
|
|
|
|
|
|
|
# versiones, requieren barra invertida. |
2199
|
|
|
|
|
|
|
|
2200
|
|
|
|
|
|
|
# 1.02.2 soporte para dobles comillas en parámetros: |
2201
|
|
|
|
|
|
|
# ("parámetro \"uno\"", "parámetro 'dos'"): |
2202
|
|
|
|
|
|
|
|
2203
|
3
|
|
|
|
|
7
|
$params =~ s/^\s*\(//; |
2204
|
3
|
|
|
|
|
6
|
$params =~ s/\)\s*$//; |
2205
|
3
|
|
|
|
|
4
|
my @param; |
2206
|
3
|
|
|
|
|
7
|
my $this = ''; |
2207
|
3
|
|
|
|
|
27
|
while ( $params =~ s/\s*"([^\"\\]*(?:\\.[^\"\\]*)*)"\s*,?|\s*'([^\'\\]*(?:\\.[^\'\\]*)*)'\s*,?|\s*([^,\s]+)\s*,?|\s*,// ) { |
2208
|
3
|
|
|
|
|
19
|
$this = $+; |
2209
|
3
|
50
|
|
|
|
21
|
$this =~ s/\\'/'/g if $this; |
2210
|
3
|
50
|
|
|
|
13
|
$this =~ s/\\"/"/g if $this; |
2211
|
|
|
|
|
|
|
|
2212
|
3
|
50
|
|
|
|
7
|
if ( !$skip_inclusion ) { # Permite la inclusión en los parámetros |
2213
|
3
|
50
|
|
|
|
33
|
if ($this =~ /$self->{'pre_start'}/) { |
2214
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $self->postformat($this) ); |
2215
|
0
|
|
|
|
|
0
|
$this = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
2216
|
|
|
|
|
|
|
} |
2217
|
3
|
50
|
|
|
|
26
|
if ($this =~ /$self->{'tag_start'}/) { |
2218
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $this ); |
2219
|
0
|
|
|
|
|
0
|
$this = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
2220
|
|
|
|
|
|
|
} |
2221
|
|
|
|
|
|
|
} |
2222
|
|
|
|
|
|
|
|
2223
|
3
|
|
|
|
|
18
|
push @param, $this; |
2224
|
|
|
|
|
|
|
} |
2225
|
|
|
|
|
|
|
|
2226
|
3
|
|
|
|
|
17
|
return @param; |
2227
|
|
|
|
|
|
|
} |
2228
|
|
|
|
|
|
|
|
2229
|
|
|
|
|
|
|
sub replace_block { |
2230
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
2231
|
2
|
|
|
|
|
7
|
my ( $block, $space1, $space2 ) = @_; |
2232
|
2
|
|
|
|
|
23
|
my ( $tag, $params, $code ) = $block =~ /$self->{'block_tag'}/; |
2233
|
2
|
|
|
|
|
4
|
my $out; |
2234
|
|
|
|
|
|
|
|
2235
|
2
|
50
|
|
|
|
136
|
if ( $tag =~ /^$self->{'tag_expre'}$/ ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2236
|
|
|
|
|
|
|
|
2237
|
0
|
|
|
|
|
0
|
$out = $self->replace_expre( $code, $params ); |
2238
|
|
|
|
|
|
|
|
2239
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_tpl'}$/ ) { |
2240
|
|
|
|
|
|
|
|
2241
|
0
|
|
|
|
|
0
|
$out = $self->replace_tpl( $code, $self->param_block($params) ); |
2242
|
|
|
|
|
|
|
|
2243
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_sql'}$/ ) { |
2244
|
|
|
|
|
|
|
|
2245
|
0
|
|
|
|
|
0
|
$out = $self->replace_nsql( $code, $self->param_block($params,1) ); |
2246
|
|
|
|
|
|
|
|
2247
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_hash'}$/ ) { |
2248
|
|
|
|
|
|
|
|
2249
|
0
|
|
|
|
|
0
|
$out = $self->replace_hash( $code, $self->param_block($params) ); |
2250
|
|
|
|
|
|
|
|
2251
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_include'}$/ ) { |
2252
|
|
|
|
|
|
|
|
2253
|
0
|
|
|
|
|
0
|
$out = $self->replace_ind( $self->param_block($params) ); |
2254
|
|
|
|
|
|
|
|
2255
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_var'}$/ ) { |
2256
|
|
|
|
|
|
|
|
2257
|
2
|
|
|
|
|
8
|
$out = $self->replace_var( $self->param_block($params) ); |
2258
|
|
|
|
|
|
|
|
2259
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_env'}$/ ) { |
2260
|
|
|
|
|
|
|
|
2261
|
0
|
|
|
|
|
0
|
$out = $self->replace_env( $self->param_block($params) ); |
2262
|
|
|
|
|
|
|
|
2263
|
|
|
|
|
|
|
} elsif ( $tag =~ /^$self->{'tag_plugin'}$/ ) { |
2264
|
|
|
|
|
|
|
|
2265
|
0
|
|
|
|
|
0
|
$out = $self->replace_plugin( $block, $space1, $space2 ); |
2266
|
|
|
|
|
|
|
|
2267
|
|
|
|
|
|
|
} else { |
2268
|
|
|
|
|
|
|
|
2269
|
|
|
|
|
|
|
# si no conoce el tag lo deja como estaba |
2270
|
0
|
|
|
|
|
0
|
$block =~ s/(^\s*)($self->{'pre_start'})/$1$self->{'tag_start'}/g; |
2271
|
0
|
|
|
|
|
0
|
$block =~ s/($self->{'pre_end'})(\s*$)/$self->{'tag_end'}$2/g; |
2272
|
|
|
|
|
|
|
|
2273
|
0
|
|
|
|
|
0
|
return $block; |
2274
|
|
|
|
|
|
|
} |
2275
|
|
|
|
|
|
|
|
2276
|
2
|
|
|
|
|
83
|
$out .= $space1; |
2277
|
2
|
|
|
|
|
29
|
return $out; |
2278
|
|
|
|
|
|
|
} |
2279
|
|
|
|
|
|
|
|
2280
|
|
|
|
|
|
|
sub security { |
2281
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
2282
|
2
|
|
|
|
|
5
|
my ($value, @security_options) = @_; |
2283
|
|
|
|
|
|
|
|
2284
|
2
|
50
|
|
|
|
10
|
return $value if $value =~ /^\d*$/; |
2285
|
|
|
|
|
|
|
|
2286
|
2
|
|
|
|
|
7
|
my $tmp_no_html = $self->{'security_options'}{'no_html'}; |
2287
|
2
|
|
|
|
|
5
|
my $tmp_no_nes = $self->{'security_options'}{'no_nes'}; |
2288
|
2
|
|
|
|
|
5
|
my $tmp_no_br = $self->{'security_options'}{'no_br'}; |
2289
|
2
|
|
|
|
|
4
|
my $tmp_no_sql = $self->{'security_options'}{'no_sql'}; |
2290
|
|
|
|
|
|
|
|
2291
|
2
|
|
|
|
|
3
|
my @yes_tag; |
2292
|
2
|
|
|
|
|
6
|
foreach my $key ( @security_options ) { |
2293
|
0
|
|
|
|
|
0
|
my $val = 1; |
2294
|
0
|
0
|
|
|
|
0
|
if ($key =~ /^yes_tag_(.*)/) { |
2295
|
0
|
|
|
|
|
0
|
push(@yes_tag, $1); |
2296
|
|
|
|
|
|
|
} else { |
2297
|
0
|
0
|
|
|
|
0
|
$val = 0 if $key =~ /^yes_/i; |
2298
|
0
|
|
|
|
|
0
|
$key =~ s/^yes_/no_/; |
2299
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{$key} = $val; |
2300
|
|
|
|
|
|
|
} |
2301
|
|
|
|
|
|
|
} |
2302
|
2
|
50
|
|
|
|
82
|
push(@yes_tag, 'br') if !$self->{'security_options'}{'no_br'}; |
2303
|
|
|
|
|
|
|
|
2304
|
2
|
50
|
|
|
|
10
|
$value = utl::quote($value) if $self->{'security_options'}{'no_sql'}; |
2305
|
2
|
50
|
|
|
|
13
|
$value = utl::no_nes($value) if $self->{'security_options'}{'no_nes'}; |
2306
|
2
|
50
|
|
|
|
19
|
$value = utl::no_html( $value, @yes_tag ) if $self->{'security_options'}{'no_html'}; |
2307
|
|
|
|
|
|
|
|
2308
|
2
|
|
|
|
|
6
|
$self->{'security_options'}{'no_html'} = $tmp_no_html; |
2309
|
2
|
|
|
|
|
4
|
$self->{'security_options'}{'no_nes'} = $tmp_no_nes; |
2310
|
2
|
|
|
|
|
4
|
$self->{'security_options'}{'no_br'} = $tmp_no_br; |
2311
|
2
|
|
|
|
|
4
|
$self->{'security_options'}{'no_sql'} = $tmp_no_sql; |
2312
|
|
|
|
|
|
|
|
2313
|
2
|
|
|
|
|
6
|
return $value; |
2314
|
|
|
|
|
|
|
} |
2315
|
|
|
|
|
|
|
|
2316
|
|
|
|
|
|
|
sub replace_NES { |
2317
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
2318
|
1
|
|
|
|
|
2
|
my ($block) = @_; |
2319
|
|
|
|
|
|
|
|
2320
|
1
|
50
|
|
|
|
17
|
return if !$block =~ /$self->{'tag_start'}\s*$self->{'tag_nes'}/; |
2321
|
|
|
|
|
|
|
|
2322
|
1
|
|
|
|
|
35
|
my $tagnes = qr{(?ix) |
2323
|
|
|
|
|
|
|
$self->{'tag_start'}\s*$self->{'tag_nes'} |
2324
|
|
|
|
|
|
|
\s*([^\s]*)\s* # vesión |
2325
|
|
|
|
|
|
|
(.*) # parametros |
2326
|
|
|
|
|
|
|
\s* |
2327
|
|
|
|
|
|
|
$self->{'tag_end'} |
2328
|
|
|
|
|
|
|
}; |
2329
|
|
|
|
|
|
|
|
2330
|
1
|
|
|
|
|
10
|
my ( $version, $params ) = $block =~ /$tagnes/; |
2331
|
1
|
|
|
|
|
5
|
my @param = $self->param_block($params); |
2332
|
|
|
|
|
|
|
|
2333
|
1
|
|
|
|
|
3
|
unshift( @param, $version ); |
2334
|
|
|
|
|
|
|
|
2335
|
1
|
|
|
|
|
7
|
return @param; |
2336
|
|
|
|
|
|
|
} |
2337
|
|
|
|
|
|
|
|
2338
|
|
|
|
|
|
|
sub replace_var { |
2339
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
2340
|
2
|
|
|
|
|
11
|
my ($var, @security_options) = @_; |
2341
|
|
|
|
|
|
|
|
2342
|
2
|
100
|
|
|
|
23
|
if ( $self->{'nes'}->{'debug_info'} ) { |
2343
|
1
|
50
|
|
|
|
5
|
warn "Warning uninitialized: $Nes::Tags::start_html $Nes::Tags::l_var $var ...\n" if !exists $self->{'tags'}{$var}; |
2344
|
|
|
|
|
|
|
} |
2345
|
|
|
|
|
|
|
|
2346
|
2
|
|
|
|
|
16
|
return $self->security( $self->{'tags'}{$var}, @security_options ); |
2347
|
|
|
|
|
|
|
} |
2348
|
|
|
|
|
|
|
|
2349
|
|
|
|
|
|
|
sub replace_expre { |
2350
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2351
|
0
|
|
|
|
|
0
|
my ( $code, $expre ) = @_; |
2352
|
|
|
|
|
|
|
|
2353
|
0
|
0
|
|
|
|
0
|
if ($expre =~ /$self->{'pre_start'}/) { |
2354
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $self->postformat($expre) ); |
2355
|
0
|
|
|
|
|
0
|
$expre = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
2356
|
|
|
|
|
|
|
} |
2357
|
|
|
|
|
|
|
|
2358
|
0
|
|
|
|
|
0
|
$expre =~ s/$Nes::Tags::var/:-:var:-:/g; |
2359
|
0
|
|
|
|
|
0
|
$expre =~ s/$Nes::Tags::env/:-:env:-:/g; |
2360
|
|
|
|
|
|
|
|
2361
|
0
|
|
|
|
|
0
|
my $nodef = undef; |
2362
|
0
|
|
|
|
|
0
|
my %vars; |
2363
|
0
|
|
|
|
|
0
|
my $reg = qr{(?x) ((:-:var:-:|:-:env:-:)\s*(\w*)) }; |
2364
|
|
|
|
|
|
|
|
2365
|
0
|
|
|
|
|
0
|
while ( $expre =~ /$reg/ ) { |
2366
|
0
|
|
|
|
|
0
|
my $tvar = $1; |
2367
|
0
|
|
|
|
|
0
|
my $tag = $2; |
2368
|
0
|
|
|
|
|
0
|
my $var = $3; |
2369
|
0
|
0
|
|
|
|
0
|
if ( $tag =~ /^:-:var:-:$/ ) { |
2370
|
|
|
|
|
|
|
|
2371
|
0
|
0
|
|
|
|
0
|
if ( defined $self->{'tags'}{$var} ) { |
2372
|
0
|
|
|
|
|
0
|
$vars{$var} = $self->{'tags'}{$var}; |
2373
|
0
|
|
|
|
|
0
|
$expre =~ s/$reg/\$vars\{\'$var\'\}/; |
2374
|
0
|
|
|
|
|
0
|
next; |
2375
|
|
|
|
|
|
|
} else { |
2376
|
0
|
|
|
|
|
0
|
$expre =~ s/$reg/\$nodef/; |
2377
|
0
|
|
|
|
|
0
|
next; |
2378
|
|
|
|
|
|
|
} |
2379
|
|
|
|
|
|
|
|
2380
|
|
|
|
|
|
|
} |
2381
|
0
|
0
|
|
|
|
0
|
if ( $tag =~ /^:-:env:-:$/ ) { |
2382
|
|
|
|
|
|
|
|
2383
|
0
|
0
|
|
|
|
0
|
if ( defined $self->{'top_container'}->{'nes_env'}{$var} ) { |
2384
|
0
|
|
|
|
|
0
|
$vars{$var} = $self->{'top_container'}->{'nes_env'}{$var}; |
2385
|
0
|
|
|
|
|
0
|
$expre =~ s/$reg/\$vars\{\'$var\'\}/; |
2386
|
0
|
|
|
|
|
0
|
next; |
2387
|
|
|
|
|
|
|
} else { |
2388
|
0
|
|
|
|
|
0
|
$expre =~ s/$reg/\$nodef/; |
2389
|
0
|
|
|
|
|
0
|
next; |
2390
|
|
|
|
|
|
|
} |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
} |
2393
|
|
|
|
|
|
|
} |
2394
|
|
|
|
|
|
|
|
2395
|
0
|
0
|
|
|
|
0
|
return $code if ( eval $expre ); |
2396
|
0
|
|
|
|
|
0
|
return ''; |
2397
|
|
|
|
|
|
|
} |
2398
|
|
|
|
|
|
|
|
2399
|
|
|
|
|
|
|
sub replace_ind { |
2400
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2401
|
0
|
|
|
|
|
0
|
my (@param) = @_; |
2402
|
|
|
|
|
|
|
|
2403
|
0
|
|
|
|
|
0
|
my $file = shift @param; |
2404
|
|
|
|
|
|
|
|
2405
|
0
|
|
|
|
|
0
|
my $obj_name = $file; |
2406
|
0
|
|
|
|
|
0
|
$obj_name =~ s/.*\///; |
2407
|
0
|
|
|
|
|
0
|
$obj_name =~ s/\.[^\.]*$//; |
2408
|
|
|
|
|
|
|
|
2409
|
0
|
0
|
|
|
|
0
|
unless ( $file ) { |
2410
|
0
|
|
|
|
|
0
|
warn "Void include in $self->{'container'}->{'file_name'}"; |
2411
|
0
|
|
|
|
|
0
|
return ''; |
2412
|
|
|
|
|
|
|
} |
2413
|
|
|
|
|
|
|
|
2414
|
0
|
|
|
|
|
0
|
my $count = 0; |
2415
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'q_obj_param_' . $count, $obj_name ); |
2416
|
0
|
|
|
|
|
0
|
$self->{'query'}->set( 'obj_param_' . $count, $obj_name ); |
2417
|
0
|
|
|
|
|
0
|
foreach my $this (@param) { |
2418
|
0
|
|
|
|
|
0
|
$count++; |
2419
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'q_' . $obj_name . '_param_' . $count, $this ); |
2420
|
0
|
|
|
|
|
0
|
$self->{'query'}->set( $obj_name . '_param_' . $count, $this ); |
2421
|
|
|
|
|
|
|
} |
2422
|
|
|
|
|
|
|
|
2423
|
0
|
|
|
|
|
0
|
my $container = nes_container->new($file); |
2424
|
0
|
|
|
|
|
0
|
$container->go(); |
2425
|
|
|
|
|
|
|
|
2426
|
0
|
|
|
|
|
0
|
$count = 0; |
2427
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->del_nes_env( 'q_obj_param_' . $count ); |
2428
|
0
|
|
|
|
|
0
|
$self->{'query'}->del( 'obj_param_' . $count ); |
2429
|
0
|
|
|
|
|
0
|
foreach my $this (@param) { |
2430
|
0
|
|
|
|
|
0
|
$count++; |
2431
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->del_nes_env( 'q_' . $obj_name . '_param_' . $count ); |
2432
|
0
|
|
|
|
|
0
|
$self->{'query'}->del( $obj_name . '_param_' . $count ); |
2433
|
|
|
|
|
|
|
} |
2434
|
|
|
|
|
|
|
|
2435
|
0
|
|
|
|
|
0
|
my $out = $container->get_out(); |
2436
|
0
|
|
|
|
|
0
|
$container->forget(); |
2437
|
|
|
|
|
|
|
|
2438
|
0
|
|
|
|
|
0
|
return $out; |
2439
|
|
|
|
|
|
|
} |
2440
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
sub replace_hash { |
2442
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2443
|
0
|
|
|
|
|
0
|
my ( $code, $name_hash ) = @_; |
2444
|
0
|
|
|
|
|
0
|
$name_hash =~ s/\s*//g; |
2445
|
|
|
|
|
|
|
|
2446
|
0
|
0
|
|
|
|
0
|
if ( !exists $self->{'tags'}{$name_hash} ) { |
2447
|
0
|
|
|
|
|
0
|
warn "Not exists: $Nes::Tags::start_html $Nes::Tags::l_hash $name_hash in $self->{'container'}->{'file_name'}\n"; |
2448
|
0
|
|
|
|
|
0
|
return; |
2449
|
|
|
|
|
|
|
} |
2450
|
|
|
|
|
|
|
|
2451
|
0
|
0
|
|
|
|
0
|
if ( $name_hash =~ /$self->{'tag_field'}/ ) { |
2452
|
0
|
|
|
|
|
0
|
$code =~ s/\s*(.+?)\.(\S*)\s*/$self->security($self->{'tags'}{$1}{$2})/egi; |
|
0
|
|
|
|
|
0
|
|
2453
|
0
|
|
|
|
|
0
|
return $code; |
2454
|
|
|
|
|
|
|
} |
2455
|
|
|
|
|
|
|
|
2456
|
0
|
|
|
|
|
0
|
my %hash = %{ $self->{'tags'}{$name_hash} }; |
|
0
|
|
|
|
|
0
|
|
2457
|
|
|
|
|
|
|
|
2458
|
0
|
|
|
|
|
0
|
my $out_code; |
2459
|
0
|
|
|
|
|
0
|
foreach my $key ( keys %hash ) { |
2460
|
0
|
|
|
|
|
0
|
my $tmp_code = $code; |
2461
|
0
|
|
|
|
|
0
|
$tmp_code =~ s/$self->{'pre_start'}\s*$self->{'tag_field'}\s*($name_hash\._name)\s*$self->{'pre_end'}/$self->security($key)/egi; |
|
0
|
|
|
|
|
0
|
|
2462
|
0
|
|
|
|
|
0
|
$tmp_code =~ s/$self->{'pre_start'}\s*$self->{'tag_field'}\s*($name_hash\._value)\s*$self->{'pre_end'}/$self->security($hash{$key})/egi; |
|
0
|
|
|
|
|
0
|
|
2463
|
0
|
|
|
|
|
0
|
$out_code .= $tmp_code; |
2464
|
|
|
|
|
|
|
} |
2465
|
|
|
|
|
|
|
|
2466
|
0
|
|
|
|
|
0
|
return $out_code; |
2467
|
|
|
|
|
|
|
} |
2468
|
|
|
|
|
|
|
|
2469
|
|
|
|
|
|
|
sub replace_nsql { |
2470
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2471
|
0
|
|
|
|
|
0
|
my ( $code, $sql ) = @_; |
2472
|
|
|
|
|
|
|
|
2473
|
0
|
0
|
|
|
|
0
|
return if $sql !~ /^SELECT/; |
2474
|
|
|
|
|
|
|
|
2475
|
0
|
|
|
|
|
0
|
my $tmp_no_html = $self->{'security_options'}{'no_html'}; |
2476
|
0
|
|
|
|
|
0
|
my $tmp_no_nes = $self->{'security_options'}{'no_nes'}; |
2477
|
0
|
|
|
|
|
0
|
my $tmp_no_br = $self->{'security_options'}{'no_br'}; |
2478
|
0
|
|
|
|
|
0
|
my $tmp_no_sql = $self->{'security_options'}{'no_sql'}; |
2479
|
|
|
|
|
|
|
|
2480
|
0
|
0
|
|
|
|
0
|
if ( $sql =~ /$self->{'pre_start'}/ ) { |
2481
|
0
|
|
|
|
|
0
|
my $interpret = nes_interpret->new( $self->postformat($sql) ); |
2482
|
0
|
|
|
|
|
0
|
$interpret->{'security_options'}{'no_sql'} = 1; |
2483
|
0
|
|
|
|
|
0
|
$sql = $interpret->go( %{ $self->{'tags'} } ); |
|
0
|
|
|
|
|
0
|
|
2484
|
|
|
|
|
|
|
} |
2485
|
|
|
|
|
|
|
|
2486
|
0
|
|
|
|
|
0
|
my $name = $self->{'CFG'}{'DB_base'}; |
2487
|
0
|
|
|
|
|
0
|
my $user = $self->{'CFG'}{'DB_user'}; |
2488
|
0
|
|
|
|
|
0
|
my $pass = $self->{'CFG'}{'DB_pass'}; |
2489
|
0
|
|
|
|
|
0
|
my $driver = $self->{'CFG'}{'DB_driver'}; |
2490
|
0
|
|
|
|
|
0
|
my $host = $self->{'CFG'}{'DB_host'}; |
2491
|
0
|
|
|
|
|
0
|
my $port = $self->{'CFG'}{'DB_port'}; |
2492
|
|
|
|
|
|
|
|
2493
|
0
|
|
|
|
|
0
|
require Nes::DB; |
2494
|
0
|
|
|
|
|
0
|
my $obj_name = $self->{'query'}->{'q'}{'obj_param_0'}; |
2495
|
0
|
0
|
|
|
|
0
|
if ( $self->{'container'}->{'type'} eq 'nsql' ) { |
2496
|
0
|
|
0
|
|
|
0
|
$name = $self->{'query'}->{'q'}{ $obj_name . '_param_1' } || $self->{'CFG'}{'DB_base'}; |
2497
|
0
|
|
0
|
|
|
0
|
$user = $self->{'query'}->{'q'}{ $obj_name . '_param_2' } || $self->{'CFG'}{'DB_user'}; |
2498
|
0
|
|
0
|
|
|
0
|
$pass = $self->{'query'}->{'q'}{ $obj_name . '_param_3' } || $self->{'CFG'}{'DB_pass'}; |
2499
|
0
|
|
0
|
|
|
0
|
$driver = $self->{'query'}->{'q'}{ $obj_name . '_param_4' } || $self->{'CFG'}{'DB_driver'}; |
2500
|
0
|
|
0
|
|
|
0
|
$host = $self->{'query'}->{'q'}{ $obj_name . '_param_5' } || $self->{'CFG'}{'DB_host'}; |
2501
|
0
|
|
0
|
|
|
0
|
$port = $self->{'query'}->{'q'}{ $obj_name . '_param_6' } || $self->{'CFG'}{'DB_port'}; |
2502
|
|
|
|
|
|
|
} |
2503
|
|
|
|
|
|
|
|
2504
|
0
|
|
|
|
|
0
|
my $base = Nes::DB->new( $name, $user, $pass, $driver, $host, $port ); |
2505
|
0
|
|
|
|
|
0
|
my @result = $base->sen_select($sql); |
2506
|
|
|
|
|
|
|
|
2507
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'DBnes_error_last_error', $base->{'errstr'} ); |
2508
|
0
|
|
|
|
|
0
|
$self->{'top_container'}->set_nes_env( 'DBnes_rows', $base->{'rows'} ); |
2509
|
|
|
|
|
|
|
|
2510
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_nes'} = 1; |
2511
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_html'} = 1; |
2512
|
|
|
|
|
|
|
|
2513
|
0
|
0
|
|
|
|
0
|
if ( $self->{'nes'}->{'debug_info'} ) { |
2514
|
0
|
|
|
|
|
0
|
$self->{'debug_info_count'}++; |
2515
|
0
|
|
|
|
|
0
|
$self->{'container'}->{'content_obj'}->{'tags'}{'generated_by_debug_info_sql_'.$self->{'debug_info_count'}} = \@result; |
2516
|
|
|
|
|
|
|
} |
2517
|
|
|
|
|
|
|
|
2518
|
0
|
|
|
|
|
0
|
my $out_code; |
2519
|
0
|
|
|
|
|
0
|
foreach my $reg (@result) { |
2520
|
0
|
|
|
|
|
0
|
my $tmp_code = $code; |
2521
|
0
|
|
|
|
|
0
|
$tmp_code =~ s/$self->{'pre_start'}\s*$self->{'tag_field'}\s*($self->{'param_bracket'})\s*$self->{'pre_end'}/$self->replace_field($reg,'\S*',$1)/egi; |
|
0
|
|
|
|
|
0
|
|
2522
|
0
|
|
|
|
|
0
|
$out_code .= $tmp_code; |
2523
|
|
|
|
|
|
|
} |
2524
|
|
|
|
|
|
|
|
2525
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_html'} = $tmp_no_html; |
2526
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_nes'} = $tmp_no_nes; |
2527
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_br'} = $tmp_no_br; |
2528
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_sql'} = $tmp_no_sql; |
2529
|
|
|
|
|
|
|
|
2530
|
0
|
|
|
|
|
0
|
return $out_code; |
2531
|
|
|
|
|
|
|
} |
2532
|
|
|
|
|
|
|
|
2533
|
|
|
|
|
|
|
sub replace_tpl { |
2534
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2535
|
0
|
|
|
|
|
0
|
my ( $code, $name ) = @_; |
2536
|
|
|
|
|
|
|
|
2537
|
0
|
0
|
|
|
|
0
|
if ( $self->{'nes'}->{'debug_info'} ) { |
2538
|
0
|
0
|
|
|
|
0
|
warn "Warning uninitialized: $Nes::Tags::start_html $Nes::Tags::l_tpl $name ...\n" if !exists $self->{'tags'}{$name}; |
2539
|
|
|
|
|
|
|
} |
2540
|
|
|
|
|
|
|
|
2541
|
0
|
|
|
|
|
0
|
my $out_code; |
2542
|
0
|
|
|
|
|
0
|
foreach my $reg ( @{ $self->{'tags'}{$name} } ) { |
|
0
|
|
|
|
|
0
|
|
2543
|
0
|
|
|
|
|
0
|
my $tmp_code = $code; |
2544
|
0
|
|
|
|
|
0
|
$tmp_code =~ s/$self->{'pre_start'}\s*$self->{'tag_field'}\s*($self->{'param_bracket'})\s*$self->{'pre_end'}/$self->replace_field($reg,$name,$1)/egi; |
|
0
|
|
|
|
|
0
|
|
2545
|
0
|
|
|
|
|
0
|
$out_code .= $tmp_code; |
2546
|
|
|
|
|
|
|
} |
2547
|
|
|
|
|
|
|
|
2548
|
0
|
|
|
|
|
0
|
return $out_code; |
2549
|
|
|
|
|
|
|
} |
2550
|
|
|
|
|
|
|
|
2551
|
|
|
|
|
|
|
sub replace_field { |
2552
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2553
|
0
|
|
|
|
|
0
|
my ( $reg, $name, $params ) = @_; |
2554
|
0
|
|
|
|
|
0
|
my @param = $self->param_block($params); |
2555
|
|
|
|
|
|
|
|
2556
|
0
|
|
|
|
|
0
|
my $var = shift @param; |
2557
|
0
|
|
|
|
|
0
|
$var =~ s/$name\.//; |
2558
|
|
|
|
|
|
|
|
2559
|
0
|
|
|
|
|
0
|
return $self->security($reg->{$var},@param); |
2560
|
|
|
|
|
|
|
} |
2561
|
|
|
|
|
|
|
|
2562
|
|
|
|
|
|
|
sub replace_env { |
2563
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2564
|
0
|
|
|
|
|
0
|
my ($var, @security_options) = @_; |
2565
|
|
|
|
|
|
|
|
2566
|
0
|
|
|
|
|
0
|
my $tmp_no_html = $self->{'security_options'}{'no_html'}; |
2567
|
0
|
|
|
|
|
0
|
my $tmp_no_nes = $self->{'security_options'}{'no_nes'}; |
2568
|
|
|
|
|
|
|
|
2569
|
|
|
|
|
|
|
# comportamiento por defecto: |
2570
|
0
|
0
|
|
|
|
0
|
$self->{'security_options'}{'no_html'} = 1 if $var =~ /^q_/; |
2571
|
0
|
0
|
|
|
|
0
|
$self->{'security_options'}{'no_nes'} = 1 if $var =~ /^q_/; |
2572
|
|
|
|
|
|
|
|
2573
|
0
|
|
|
|
|
0
|
$var = $self->{'top_container'}->get_nes_env($var); |
2574
|
0
|
0
|
|
|
|
0
|
$var = "@{$var}" if ref $var eq 'ARRAY'; |
|
0
|
|
|
|
|
0
|
|
2575
|
0
|
0
|
|
|
|
0
|
$var = keys %{$var} if ref $var eq 'HASH'; |
|
0
|
|
|
|
|
0
|
|
2576
|
0
|
|
|
|
|
0
|
$var = $self->security( $var, @security_options ); |
2577
|
|
|
|
|
|
|
|
2578
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_html'} = $tmp_no_html; |
2579
|
0
|
|
|
|
|
0
|
$self->{'security_options'}{'no_nes'} = $tmp_no_nes; |
2580
|
|
|
|
|
|
|
|
2581
|
0
|
|
|
|
|
0
|
return $var; |
2582
|
|
|
|
|
|
|
} |
2583
|
|
|
|
|
|
|
|
2584
|
|
|
|
|
|
|
sub replace_plugin { |
2585
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2586
|
0
|
|
|
|
|
0
|
my ( $block, $space1, $space2 ) = @_; |
2587
|
0
|
|
|
|
|
0
|
my ( $tag, $params, $code ) = $block =~ /$self->{'block_plugin'}/; |
2588
|
0
|
|
|
|
|
0
|
my $out; |
2589
|
0
|
|
|
|
|
0
|
my ( @register_tags ) = $self->{'register'}->get_tags(); |
2590
|
|
|
|
|
|
|
|
2591
|
0
|
|
|
|
|
0
|
foreach my $tag_plugin ( @register_tags ) { |
2592
|
0
|
0
|
|
|
|
0
|
if ( $tag =~ /^$tag_plugin$/i ) { |
2593
|
0
|
|
|
|
|
0
|
my $handler = $self->{'register'}->get_tag_handler($tag_plugin); |
2594
|
0
|
0
|
|
|
|
0
|
if ( !$handler ) { |
2595
|
0
|
|
|
|
|
0
|
warn "No handler for plugin Tag: $tag_plugin "; |
2596
|
0
|
|
|
|
|
0
|
next; |
2597
|
|
|
|
|
|
|
} |
2598
|
0
|
|
|
|
|
0
|
$out = $handler->( $code,$self->param_block($params) ); |
2599
|
0
|
|
|
|
|
0
|
return $out; |
2600
|
|
|
|
|
|
|
} |
2601
|
|
|
|
|
|
|
} |
2602
|
|
|
|
|
|
|
|
2603
|
0
|
|
|
|
|
0
|
warn "Not replaced: $Nes::Tags::start_html $Nes::Tags::l_plugin $tag in $self->{'container'}->{'file_name'}\n"; |
2604
|
|
|
|
|
|
|
|
2605
|
0
|
|
|
|
|
0
|
return ''; |
2606
|
|
|
|
|
|
|
} |
2607
|
|
|
|
|
|
|
|
2608
|
|
|
|
|
|
|
} |
2609
|
|
|
|
|
|
|
|
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
{ |
2612
|
|
|
|
|
|
|
|
2613
|
|
|
|
|
|
|
package utl; |
2614
|
|
|
|
|
|
|
|
2615
|
|
|
|
|
|
|
sub get_file_path { |
2616
|
|
|
|
|
|
|
|
2617
|
3
|
|
|
3
|
|
3375
|
use FindBin qw($Bin $Script); |
|
3
|
|
|
|
|
3790
|
|
|
3
|
|
|
|
|
630
|
|
2618
|
0
|
|
0
|
0
|
|
0
|
my $file = $ENV{'PATH_TRANSLATED'} || $ENV{'SCRIPT_FILENAME'} || "$Bin\\$Script"; |
2619
|
|
|
|
|
|
|
|
2620
|
0
|
|
|
|
|
0
|
return $file; |
2621
|
|
|
|
|
|
|
} |
2622
|
|
|
|
|
|
|
|
2623
|
|
|
|
|
|
|
sub get_file_dir { |
2624
|
|
|
|
|
|
|
|
2625
|
3
|
|
|
3
|
|
20
|
use FindBin qw($Bin $Script); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
494
|
|
2626
|
2
|
|
33
|
2
|
|
29
|
my $dir = $ENV{'PATH_TRANSLATED'} || $ENV{'SCRIPT_FILENAME'} || "$Bin\\$Script"; |
2627
|
2
|
|
|
|
|
21
|
$dir =~ s/(.*)(\\|\/).*/$1/; |
2628
|
|
|
|
|
|
|
|
2629
|
2
|
|
|
|
|
6
|
return $dir; |
2630
|
|
|
|
|
|
|
} |
2631
|
|
|
|
|
|
|
|
2632
|
|
|
|
|
|
|
sub get_root_dir { |
2633
|
|
|
|
|
|
|
|
2634
|
3
|
|
|
3
|
|
15
|
use FindBin '$Bin'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2032
|
|
2635
|
2
|
|
|
2
|
|
35
|
my ($root_dir) = split( "$ENV{'PATH_INFO'}", $ENV{'PATH_TRANSLATED'} ); |
2636
|
2
|
|
33
|
|
|
12
|
my $dir = $root_dir || $Bin; # en entornos no cgi da el directorio en el que se ejecuta el script o directorio de trabajo |
2637
|
2
|
|
|
|
|
8
|
$dir =~ s/[\/\\]$//; |
2638
|
|
|
|
|
|
|
|
2639
|
2
|
|
|
|
|
8
|
return $dir; |
2640
|
|
|
|
|
|
|
} |
2641
|
|
|
|
|
|
|
|
2642
|
|
|
|
|
|
|
sub expires { |
2643
|
0
|
|
|
0
|
|
0
|
my ($expire) = @_; |
2644
|
|
|
|
|
|
|
|
2645
|
0
|
|
|
|
|
0
|
my (@MON) = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; |
2646
|
0
|
|
|
|
|
0
|
my (@WDAY) = qw/Sun Mon Tue Wed Thu Fri Sat/; |
2647
|
0
|
|
|
|
|
0
|
my (%formt) = ( |
2648
|
|
|
|
|
|
|
's' => 1, |
2649
|
|
|
|
|
|
|
'm' => 60, |
2650
|
|
|
|
|
|
|
'h' => 60 * 60, |
2651
|
|
|
|
|
|
|
'd' => 60 * 60 * 24, |
2652
|
|
|
|
|
|
|
'M' => 60 * 60 * 24 * 30, |
2653
|
|
|
|
|
|
|
'y' => 60 * 60 * 24 * 365 |
2654
|
|
|
|
|
|
|
); |
2655
|
|
|
|
|
|
|
|
2656
|
0
|
|
|
|
|
0
|
$expire =~ /(\-?\d*)(.)/; |
2657
|
0
|
|
|
|
|
0
|
my $second = $1; |
2658
|
0
|
|
|
|
|
0
|
my $factor = $2; |
2659
|
0
|
|
|
|
|
0
|
my $time = time + ( $second * $formt{$factor} ); |
2660
|
0
|
|
|
|
|
0
|
my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime($time); |
2661
|
0
|
|
|
|
|
0
|
$year += 1900; |
2662
|
|
|
|
|
|
|
|
2663
|
0
|
|
|
|
|
0
|
return sprintf( "%s, %02d-%s-%04d %02d:%02d:%02d GMT", $WDAY[$wday], $mday, $MON[$mon], $year, $hour, $min, $sec ); |
2664
|
|
|
|
|
|
|
} |
2665
|
|
|
|
|
|
|
|
2666
|
|
|
|
|
|
|
sub expires_time { |
2667
|
0
|
|
|
0
|
|
0
|
my ($expire) = @_; |
2668
|
|
|
|
|
|
|
|
2669
|
0
|
|
|
|
|
0
|
my (%formt) = ( |
2670
|
|
|
|
|
|
|
's' => 1, |
2671
|
|
|
|
|
|
|
'm' => 60, |
2672
|
|
|
|
|
|
|
'h' => 60 * 60, |
2673
|
|
|
|
|
|
|
'd' => 60 * 60 * 24, |
2674
|
|
|
|
|
|
|
'M' => 60 * 60 * 24 * 30, |
2675
|
|
|
|
|
|
|
'y' => 60 * 60 * 24 * 365 |
2676
|
|
|
|
|
|
|
); |
2677
|
|
|
|
|
|
|
|
2678
|
0
|
|
|
|
|
0
|
$expire =~ /(\-?\d*)(.)/; |
2679
|
0
|
|
0
|
|
|
0
|
my $second = $1 || 0; |
2680
|
0
|
|
0
|
|
|
0
|
my $factor = $2 || 's'; |
2681
|
0
|
|
|
|
|
0
|
my $time = $second * $formt{$factor}; |
2682
|
|
|
|
|
|
|
|
2683
|
0
|
|
|
|
|
0
|
return $time; |
2684
|
|
|
|
|
|
|
} |
2685
|
|
|
|
|
|
|
|
2686
|
|
|
|
|
|
|
sub escape { |
2687
|
0
|
|
|
0
|
|
0
|
my $string = shift; |
2688
|
|
|
|
|
|
|
|
2689
|
0
|
|
|
|
|
0
|
$string =~ s/(.)/'%'.sprintf("%X", ord($1))/ge; |
|
0
|
|
|
|
|
0
|
|
2690
|
|
|
|
|
|
|
|
2691
|
0
|
|
|
|
|
0
|
return $string; |
2692
|
|
|
|
|
|
|
} |
2693
|
|
|
|
|
|
|
|
2694
|
|
|
|
|
|
|
sub js_escape { |
2695
|
0
|
|
|
0
|
|
0
|
my $string = shift; |
2696
|
|
|
|
|
|
|
|
2697
|
3
|
|
|
3
|
|
3219
|
use Encode qw(encode FB_PERLQQ); |
|
3
|
|
|
|
|
38558
|
|
|
3
|
|
|
|
|
3720
|
|
2698
|
0
|
|
|
|
|
0
|
$string =~ s{([\x00-\x29\x2C\x3A-\x40\x5B-\x5E\x60\x7B-\x7F])} |
2699
|
0
|
|
|
|
|
0
|
{'%' . uc(unpack('H2', $1))}eg; # XXX JavaScript compatible |
2700
|
0
|
|
|
0
|
|
0
|
$string = encode( 'ascii', $string, sub { sprintf '%%u%04X', $_[0] } ); |
|
0
|
|
|
|
|
0
|
|
2701
|
|
|
|
|
|
|
|
2702
|
0
|
|
|
|
|
0
|
return $string; |
2703
|
|
|
|
|
|
|
} |
2704
|
|
|
|
|
|
|
|
2705
|
|
|
|
|
|
|
sub js_unescape { |
2706
|
0
|
|
|
0
|
|
0
|
my $escaped = shift; |
2707
|
|
|
|
|
|
|
|
2708
|
0
|
|
|
|
|
0
|
$escaped =~ s/%u([0-9a-f]+)/chr(hex($1))/eig; |
|
0
|
|
|
|
|
0
|
|
2709
|
0
|
|
|
|
|
0
|
$escaped =~ s/%([0-9a-f]{2})/chr(hex($1))/eig; |
|
0
|
|
|
|
|
0
|
|
2710
|
|
|
|
|
|
|
|
2711
|
0
|
|
|
|
|
0
|
return $escaped; |
2712
|
|
|
|
|
|
|
} |
2713
|
|
|
|
|
|
|
|
2714
|
|
|
|
|
|
|
sub quote { |
2715
|
0
|
|
|
0
|
|
0
|
my ($value) = @_; |
2716
|
|
|
|
|
|
|
|
2717
|
0
|
|
|
|
|
0
|
require DBI; |
2718
|
|
|
|
|
|
|
|
2719
|
0
|
|
|
|
|
0
|
return DBD::_::db->quote($value); |
2720
|
|
|
|
|
|
|
} |
2721
|
|
|
|
|
|
|
|
2722
|
|
|
|
|
|
|
sub no_html { |
2723
|
2
|
|
|
2
|
|
6
|
my ( $value, @yes_tag ) = @_; |
2724
|
|
|
|
|
|
|
|
2725
|
2
|
50
|
|
|
|
10
|
return if !$value; |
2726
|
|
|
|
|
|
|
|
2727
|
2
|
|
|
|
|
6
|
my $tags = ''; |
2728
|
2
|
|
|
|
|
5
|
foreach my $tag (@yes_tag) { |
2729
|
2
|
|
|
|
|
10
|
$tags .= '\/?'.$tag.'\W|'; |
2730
|
|
|
|
|
|
|
} |
2731
|
2
|
|
|
|
|
12
|
$tags =~ s/\|$//; |
2732
|
|
|
|
|
|
|
|
2733
|
2
|
50
|
|
|
|
11
|
if (!$tags) { |
2734
|
0
|
|
|
|
|
0
|
$value =~ s/\</sg; |
2735
|
0
|
|
|
|
|
0
|
$value =~ s/\>/>/sg; |
2736
|
|
|
|
|
|
|
} else { |
2737
|
2
|
|
|
|
|
82
|
while ( $value =~ s/\<((?!$tags)[^\>\<]*)\>/<$1>/sig ) {} |
2738
|
|
|
|
|
|
|
} |
2739
|
|
|
|
|
|
|
|
2740
|
2
|
|
|
|
|
8
|
return $value; |
2741
|
|
|
|
|
|
|
} |
2742
|
|
|
|
|
|
|
|
2743
|
|
|
|
|
|
|
sub no_nes { |
2744
|
2
|
|
|
2
|
|
6
|
my ($value) = @_; |
2745
|
|
|
|
|
|
|
|
2746
|
2
|
50
|
|
|
|
7
|
return if !$value; |
2747
|
|
|
|
|
|
|
|
2748
|
2
|
|
|
|
|
107
|
my $tags = qr/ |
2749
|
|
|
|
|
|
|
$Nes::Tags::start |
2750
|
|
|
|
|
|
|
( |
2751
|
|
|
|
|
|
|
\s* |
2752
|
|
|
|
|
|
|
($Nes::Tags::all_or) |
2753
|
|
|
|
|
|
|
(.+?) |
2754
|
|
|
|
|
|
|
) |
2755
|
|
|
|
|
|
|
$Nes::Tags::end |
2756
|
|
|
|
|
|
|
/six; |
2757
|
|
|
|
|
|
|
|
2758
|
2
|
|
|
|
|
105
|
my $tags_pre = qr/ |
2759
|
|
|
|
|
|
|
$Nes::Tags::pre_start |
2760
|
|
|
|
|
|
|
( |
2761
|
|
|
|
|
|
|
\s* |
2762
|
|
|
|
|
|
|
($Nes::Tags::all_or) |
2763
|
|
|
|
|
|
|
(.+?) |
2764
|
|
|
|
|
|
|
) |
2765
|
|
|
|
|
|
|
$Nes::Tags::pre_end |
2766
|
|
|
|
|
|
|
/six; |
2767
|
|
|
|
|
|
|
|
2768
|
2
|
|
|
|
|
14
|
while ( $value =~ s/$tags/$Nes::Tags::start_html$1$Nes::Tags::end_html/go ) {} |
2769
|
2
|
|
|
|
|
11
|
while ( $value =~ s/$tags_pre/$Nes::Tags::pre_start_html$1$Nes::Tags::pre_end_html/go ) {} |
2770
|
|
|
|
|
|
|
|
2771
|
2
|
|
|
|
|
11
|
return $value; |
2772
|
|
|
|
|
|
|
} |
2773
|
|
|
|
|
|
|
|
2774
|
|
|
|
|
|
|
sub no_nes_pre { |
2775
|
0
|
|
|
0
|
|
|
my ($value) = @_; |
2776
|
|
|
|
|
|
|
|
2777
|
0
|
0
|
|
|
|
|
return if !$value; |
2778
|
|
|
|
|
|
|
|
2779
|
0
|
|
|
|
|
|
my $tags = qr/ |
2780
|
|
|
|
|
|
|
$Nes::Tags::pre_start |
2781
|
|
|
|
|
|
|
( |
2782
|
|
|
|
|
|
|
\s* |
2783
|
|
|
|
|
|
|
($Nes::Tags::all_or) |
2784
|
|
|
|
|
|
|
(.+?) |
2785
|
|
|
|
|
|
|
) |
2786
|
|
|
|
|
|
|
$Nes::Tags::pre_end |
2787
|
|
|
|
|
|
|
/six; |
2788
|
|
|
|
|
|
|
|
2789
|
0
|
|
|
|
|
|
while ( $value =~ s/$tags/$Nes::Tags::pre_start_html$1$Nes::Tags::pre_end_html/go ) {} |
2790
|
|
|
|
|
|
|
|
2791
|
0
|
|
|
|
|
|
return $value; |
2792
|
|
|
|
|
|
|
} |
2793
|
|
|
|
|
|
|
|
2794
|
|
|
|
|
|
|
sub no_nes_remove { |
2795
|
0
|
|
|
0
|
|
|
my ($data) = @_; |
2796
|
|
|
|
|
|
|
|
2797
|
0
|
|
|
|
|
|
my $start = '(\{|\%7B)(\:|\%3A)'; |
2798
|
0
|
|
|
|
|
|
my $end = '(?:\:|\%3A)(?:\%7D|\})'; |
2799
|
|
|
|
|
|
|
|
2800
|
0
|
|
|
|
|
|
$$data =~ s/$start/{_/gis; |
2801
|
0
|
|
|
|
|
|
$$data =~ s/$end/_}/gis; |
2802
|
|
|
|
|
|
|
|
2803
|
0
|
|
|
|
|
|
return; |
2804
|
|
|
|
|
|
|
} |
2805
|
|
|
|
|
|
|
|
2806
|
|
|
|
|
|
|
sub clear { |
2807
|
0
|
|
|
0
|
|
|
my (@vars) = @_; |
2808
|
|
|
|
|
|
|
|
2809
|
0
|
0
|
|
|
|
|
if ( $MOD_PERL2 ) { |
2810
|
0
|
|
|
|
|
|
require Apache2::RequestUtil; |
2811
|
0
|
|
|
|
|
|
require Apache2::RequestIO; |
2812
|
0
|
|
|
|
|
|
require APR::Pool; |
2813
|
0
|
|
|
|
|
|
Apache2::RequestUtil->request->pool->clear(); |
2814
|
|
|
|
|
|
|
} |
2815
|
|
|
|
|
|
|
|
2816
|
0
|
|
|
|
|
|
return 1; |
2817
|
|
|
|
|
|
|
} |
2818
|
|
|
|
|
|
|
|
2819
|
|
|
|
|
|
|
sub destroy { |
2820
|
0
|
|
|
0
|
|
|
my (@vars) = @_; |
2821
|
|
|
|
|
|
|
|
2822
|
0
|
0
|
|
|
|
|
if ( $MOD_PERL2 ) { |
2823
|
0
|
|
|
|
|
|
require Apache2::RequestUtil; |
2824
|
0
|
|
|
|
|
|
require Apache2::RequestIO; |
2825
|
0
|
|
|
|
|
|
require APR::Pool; |
2826
|
0
|
|
|
|
|
|
Apache2::RequestUtil->request->pool->destroy(); |
2827
|
|
|
|
|
|
|
} |
2828
|
|
|
|
|
|
|
|
2829
|
0
|
|
|
|
|
|
return 1; |
2830
|
|
|
|
|
|
|
} |
2831
|
|
|
|
|
|
|
|
2832
|
|
|
|
|
|
|
sub cleanup { |
2833
|
0
|
|
|
0
|
|
|
my (@vars) = @_; |
2834
|
|
|
|
|
|
|
|
2835
|
0
|
0
|
|
|
|
|
if ( $MOD_PERL2 ) { |
2836
|
0
|
|
|
|
|
|
require Apache2::RequestUtil; |
2837
|
0
|
|
|
|
|
|
require Apache2::RequestIO; |
2838
|
0
|
|
|
|
|
|
require APR::Pool; |
2839
|
0
|
|
|
|
|
|
Apache2::RequestUtil->request->pool->cleanup_register(\&utl::cleanup_callback, @vars); |
2840
|
|
|
|
|
|
|
} |
2841
|
|
|
|
|
|
|
|
2842
|
0
|
0
|
|
|
|
|
if ( $MOD_PERL1 ) { |
2843
|
0
|
|
|
|
|
|
require Apache; |
2844
|
0
|
|
|
|
|
|
Apache->request->register_cleanup(\&utl::cleanup_callback, @vars); |
2845
|
|
|
|
|
|
|
} |
2846
|
|
|
|
|
|
|
|
2847
|
0
|
|
|
|
|
|
return 1; |
2848
|
|
|
|
|
|
|
} |
2849
|
|
|
|
|
|
|
|
2850
|
|
|
|
|
|
|
sub cleanup_callback { |
2851
|
0
|
|
|
0
|
|
|
my (@vars) = @_; |
2852
|
|
|
|
|
|
|
|
2853
|
0
|
|
|
|
|
|
foreach my $var (@vars) { |
2854
|
0
|
|
|
|
|
|
my $ref = ref $var; |
2855
|
0
|
0
|
0
|
|
|
|
undef $$var if $ref eq 'SCALAR' || $ref eq 'REF' ; |
2856
|
0
|
0
|
|
|
|
|
undef %$var if $ref eq 'HASH'; |
2857
|
0
|
0
|
|
|
|
|
undef @$var if $ref eq 'ARRAY'; |
2858
|
|
|
|
|
|
|
} |
2859
|
|
|
|
|
|
|
|
2860
|
0
|
|
|
|
|
|
return 1; |
2861
|
|
|
|
|
|
|
} |
2862
|
|
|
|
|
|
|
|
2863
|
|
|
|
|
|
|
} |
2864
|
|
|
|
|
|
|
|
2865
|
|
|
|
|
|
|
|
2866
|
|
|
|
|
|
|
|
2867
|
|
|
|
|
|
|
|
2868
|
|
|
|
|
|
|
1; |