| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Nes by Skriptke |
|
6
|
|
|
|
|
|
|
# Copyright 2009 - 2010 Enrique F. Castañón Barbero |
|
7
|
|
|
|
|
|
|
# Licensed under the GNU GPL. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# CPAN: |
|
10
|
|
|
|
|
|
|
# http://search.cpan.org/dist/Nes/ |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Sample: |
|
13
|
|
|
|
|
|
|
# http://nes.sourceforge.net/ |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# Repository: |
|
16
|
|
|
|
|
|
|
# http://github.com/Skriptke/nes |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# Version 1.03 |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# Setting.pm |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Nes::Setting; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $instance; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
|
31
|
2
|
|
|
2
|
0
|
6
|
my $class = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
2
|
50
|
|
|
|
10
|
utl::cleanup(\$instance) if $ENV{'MOD_PERL'}; |
|
34
|
2
|
50
|
|
|
|
7
|
return $instance if $instance; |
|
35
|
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
10
|
my $level = utl::get_file_dir(); |
|
37
|
2
|
|
|
|
|
5
|
my $file_name = '.nes.cfg'; |
|
38
|
2
|
|
50
|
|
|
13
|
my $nes_dir = $ENV{'SCRIPT_NAME'} || '/cgi-bin/nes'; # default: /cgi-bin/nes |
|
39
|
2
|
|
50
|
|
|
12
|
my $nes_top_dir = $ENV{'SCRIPT_FILENAME'} || ''; |
|
40
|
2
|
|
|
|
|
15
|
$nes_dir =~ s/\/[^\/]*\.cgi|pl$//; |
|
41
|
2
|
|
|
|
|
3
|
$nes_top_dir =~ s/\/[^\/]*\.cgi|pl$//; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# en entornos no cgi da el directorio en el que se ejecuta el script |
|
44
|
2
|
|
|
|
|
7
|
my $top_dir = utl::get_root_dir(); |
|
45
|
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
106
|
my $self = { |
|
47
|
|
|
|
|
|
|
tmp_dir => '/tmp/nes', |
|
48
|
|
|
|
|
|
|
tmp_suffix => '.nes_file_temp', |
|
49
|
|
|
|
|
|
|
tmp_clear => 0, # borrar los archivos temporales de más del tiempo indicado, si es 0 no borra |
|
50
|
|
|
|
|
|
|
top_dir => $top_dir, # document root |
|
51
|
|
|
|
|
|
|
nes_top_dir => $nes_top_dir, # nes dir install |
|
52
|
|
|
|
|
|
|
nes_dir => $nes_dir, # default: /cgi-bin/nes |
|
53
|
|
|
|
|
|
|
plugin_dir => $nes_dir . '/plugin', |
|
54
|
|
|
|
|
|
|
obj_dir => $nes_dir . '/obj', |
|
55
|
|
|
|
|
|
|
plugin_top_dir => $nes_top_dir . '/plugin', |
|
56
|
|
|
|
|
|
|
obj_top_dir => $nes_top_dir . '/obj', |
|
57
|
|
|
|
|
|
|
obj_form => $nes_top_dir . '/obj/Nes/form', |
|
58
|
|
|
|
|
|
|
img_dir => $nes_dir . '/images', |
|
59
|
|
|
|
|
|
|
time_zone => 'Europe/Madrid', # * sin implementar * |
|
60
|
|
|
|
|
|
|
locale => '', # es_ES.utf8 |
|
61
|
|
|
|
|
|
|
session_prefix => 'NESSESSION', |
|
62
|
|
|
|
|
|
|
private_key => 'ChangeIt', # Change private key |
|
63
|
|
|
|
|
|
|
DB_base => '', # Change in you .nes.cfg |
|
64
|
|
|
|
|
|
|
DB_user => '', # Change in you .nes.cfg |
|
65
|
|
|
|
|
|
|
DB_pass => '', # Change in you .nes.cfg |
|
66
|
|
|
|
|
|
|
DB_driver => 'mysql', # Change in you .nes.cfg |
|
67
|
|
|
|
|
|
|
DB_host => 'localhost', # Change in you .nes.cfg |
|
68
|
|
|
|
|
|
|
DB_port => '3306', # Change in you .nes.cfg |
|
69
|
|
|
|
|
|
|
php_cline => '/usr/bin/php', |
|
70
|
|
|
|
|
|
|
php_cgi_cline => '/usr/bin/php-cgi', |
|
71
|
|
|
|
|
|
|
perl_cline => '/usr/bin/perl', |
|
72
|
|
|
|
|
|
|
python_cline => '/usr/bin/python', |
|
73
|
|
|
|
|
|
|
shell_cline => '/bin/bash', |
|
74
|
|
|
|
|
|
|
max_post => 512, # max kB. for POST |
|
75
|
|
|
|
|
|
|
max_upload => 2048, # max kB. for upload, 0 none |
|
76
|
|
|
|
|
|
|
tmp_upload => 512, # a partir de que kB. se usa un archivo temporal en los upload |
|
77
|
|
|
|
|
|
|
auto_load_plugin_top_first => [ ], # Cargar Plugins al inicio, sólo para la URL |
|
78
|
|
|
|
|
|
|
auto_load_plugin_all_first => [ ], # Cargar Plugins al inicio, para todos los archivos incluidos |
|
79
|
|
|
|
|
|
|
auto_load_plugin_top_last => [ ], # Cargar Plugins al final, sólo para la URL |
|
80
|
|
|
|
|
|
|
auto_load_plugin_all_last => [ ], # Cargar Plugins al final, para todos los archivos incluidos |
|
81
|
|
|
|
|
|
|
kletters => [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ], |
|
82
|
|
|
|
|
|
|
knumbers => [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ], |
|
83
|
|
|
|
|
|
|
kletnum => [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ], |
|
84
|
|
|
|
|
|
|
}; |
|
85
|
2
|
|
|
|
|
7
|
bless $self, $class; |
|
86
|
2
|
|
|
|
|
3
|
$instance = $self; |
|
87
|
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
5
|
while (1) { |
|
89
|
2
|
|
|
|
|
5
|
my $file = $level . '/' . $file_name; |
|
90
|
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
8
|
$self->load_cfg($file); |
|
92
|
2
|
|
|
|
|
10
|
$level =~ s/[\/\\][^\/\\]*$//; |
|
93
|
2
|
50
|
|
|
|
36
|
last if $level !~ /$self->{'top_dir'}/; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
2
|
50
|
|
|
|
9
|
warn "Change the private_key in $file_name" if $self->{'private_key'} =~ /ChangeIt/i; |
|
97
|
|
|
|
|
|
|
|
|
98
|
2
|
|
|
|
|
5
|
return $self; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub load_cfg { |
|
102
|
2
|
|
|
2
|
0
|
5
|
my $class = shift; |
|
103
|
2
|
|
|
|
|
47
|
my $self = Nes::Setting::get_obj(); |
|
104
|
2
|
|
|
|
|
4
|
my ($file) = @_; |
|
105
|
|
|
|
|
|
|
|
|
106
|
2
|
50
|
|
|
|
67
|
if ( -e $file ) { |
|
107
|
2
|
50
|
|
|
|
90
|
open( my $fh, "$file" ) || warn "couldn't open $file"; |
|
108
|
2
|
|
|
|
|
52
|
while (<$fh>) { |
|
109
|
6
|
|
|
|
|
9
|
chomp; |
|
110
|
6
|
|
|
|
|
10
|
my $line = $_; |
|
111
|
6
|
100
|
|
|
|
22
|
next if $line =~ /^#/; |
|
112
|
4
|
100
|
|
|
|
25
|
next if $line =~ /^$/; |
|
113
|
2
|
|
|
|
|
12
|
my ( $key, $value ) = split( /=\s*/, $line, 2 ); |
|
114
|
2
|
|
|
|
|
17
|
$key =~ s/\s*(\@|\%|\$)?$//; |
|
115
|
2
|
|
50
|
|
|
11
|
my $eval = $1 || 0; |
|
116
|
2
|
|
|
|
|
45
|
$value =~ s/\s*$//; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# impide que se reescriba 'set'; |
|
119
|
2
|
50
|
|
|
|
15
|
next if $key eq 'set'; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# sólo sobreescribe los valores que cambian, los valores de éste |
|
122
|
|
|
|
|
|
|
# directorio priman sobre el nivel superior, se empieza a leer en el |
|
123
|
|
|
|
|
|
|
# nivel del script ya que por ejemplo $self->{'top_dir'} tiene que |
|
124
|
|
|
|
|
|
|
# estar fijado para conocer cual es el nivel superior. |
|
125
|
2
|
50
|
|
|
|
15
|
unless ( $self->{'set'}{$key} ) { |
|
126
|
2
|
50
|
|
|
|
41
|
if ( $eval ) { |
|
|
|
50
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
0
|
$eval = '@' if ref( $self->{$key} ) eq 'ARRAY'; |
|
128
|
0
|
0
|
|
|
|
0
|
$eval = '%' if ref( $self->{$key} ) eq 'HASH'; |
|
129
|
0
|
0
|
|
|
|
0
|
$eval = '$' if ref( $self->{$key} ) eq 'SCALAR'; |
|
130
|
0
|
0
|
|
|
|
0
|
@{ $self->{$key} } = eval { $value } if $eval eq '@'; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
131
|
0
|
0
|
|
|
|
0
|
%{ $self->{$key} } = eval { $value } if $eval eq '%'; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
132
|
0
|
0
|
|
|
|
0
|
$self->{$key} = eval "$value" if $eval eq '$'; |
|
133
|
|
|
|
|
|
|
} elsif ( ref( $self->{$key} ) eq 'ARRAY' ) { |
|
134
|
0
|
|
|
|
|
0
|
@{ $self->{$key} } = split( /,/, $value ); |
|
|
0
|
|
|
|
|
0
|
|
|
135
|
|
|
|
|
|
|
} else { |
|
136
|
2
|
|
|
|
|
4
|
$self->{$key} = $value; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
2
|
|
|
|
|
10
|
$self->{'set'}{$key} = 1; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} |
|
141
|
2
|
|
|
|
|
22
|
close $fh; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# si por error se deja la ultima barra del directorio |
|
145
|
2
|
|
|
|
|
6
|
$self->{'top_dir'} =~ s/[\/\\]$//; |
|
146
|
2
|
|
|
|
|
7
|
$self->{'tmp_dir'} =~ s/[\/\\]$//; |
|
147
|
2
|
|
|
|
|
5
|
$self->{'nes_dir'} =~ s/[\/\\]$//; |
|
148
|
2
|
|
|
|
|
5
|
$self->{'plugin_dir'} =~ s/[\/\\]$//; |
|
149
|
2
|
|
|
|
|
5
|
$self->{'obj_dir'} =~ s/[\/\\]$//; |
|
150
|
2
|
|
|
|
|
5
|
$self->{'plugin_top_dir'} =~ s/[\/\\]$//; |
|
151
|
2
|
|
|
|
|
6
|
$self->{'obj_top_dir'} =~ s/[\/\\]$//; |
|
152
|
2
|
|
|
|
|
5
|
$self->{'obj_form'} =~ s/[\/\\]$//; |
|
153
|
|
|
|
|
|
|
|
|
154
|
2
|
|
|
|
|
7
|
push( @INC, ( $self->{'plugin_top_dir'}, $self->{'obj_top_dir'}, $self->{'obj_form'} ) ); |
|
155
|
|
|
|
|
|
|
|
|
156
|
2
|
|
|
|
|
5
|
return; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub get_obj { |
|
160
|
12
|
|
66
|
12
|
0
|
49
|
my $self = $instance || Nes::Setting->new(); |
|
161
|
|
|
|
|
|
|
|
|
162
|
12
|
|
|
|
|
32
|
return $self; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |
|
168
|
|
|
|
|
|
|
|