line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Utils.pm,v 1.2 2003/05/17 14:30:40 devel Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package NTS::Utils; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#use 5.008; |
6
|
1
|
|
|
1
|
|
23002
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
457
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2.0'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Recupega Post com multiples values |
12
|
|
|
|
|
|
|
sub getForm { |
13
|
0
|
|
|
0
|
1
|
|
my($i,@j,$k,%r,$c,%concat); |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $r = Apache->request; |
16
|
0
|
|
|
|
|
|
$c = shift; |
17
|
0
|
|
|
|
|
|
$i = $c; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
return () unless defined $i; |
20
|
0
|
|
|
|
|
|
while ($i =~ s/^\&?([a-zA-Z0-9-_\%\.\,\+]+)=([a-zA-Z0-9-_\*\@\%\.\,\+\/]+)?&?//sx) { |
21
|
0
|
|
|
|
|
|
$j[0] = $1; |
22
|
0
|
|
|
|
|
|
$j[1] = $2; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Trasnforma os chars especiais em normais |
25
|
0
|
|
|
|
|
|
$j[0] =~ tr/+/ /; |
26
|
0
|
|
|
|
|
|
$j[0] =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if (defined $j[1]) { |
29
|
0
|
|
|
|
|
|
$j[1] =~ tr/+/ /; |
30
|
0
|
|
|
|
|
|
$j[1] =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Verifica quantas vezes se repete |
34
|
0
|
|
|
|
|
|
$k = $c =~ s/(^|&)($j[0]=)/$1$2/gi; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Verifica se joga em array ou hash |
37
|
0
|
0
|
|
|
|
|
if ($k > 1) { push (@{$r{$j[0]}},$j[1]); } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
else { $r{$j[0]} = $j[1] } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Verifica se deve fazer concat |
41
|
0
|
0
|
|
|
|
|
$concat{$1}->{$2} = $j[1] if ($j[0] =~ /^concat\.(.*)\.([0-9]+)$/); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$k = 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Retorna dados do concat corretos |
47
|
0
|
|
|
|
|
|
foreach $i (keys %concat) { |
48
|
0
|
|
|
|
|
|
undef $r{$i}; |
49
|
0
|
|
|
|
|
|
foreach (sort keys %{$concat{$i}}) { |
|
0
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
$r{$i} .= $concat{$i}->{$_} if $concat{$i}->{$_}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
return %r if %r; |
55
|
0
|
|
|
|
|
|
return (); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
#__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
NTS::Utils - Utilitarios Web |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 Description |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Funcoes simples e rapidas utilizadas em paginas CGI ou modperl |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SYNOPSIS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use NTS::Utils; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my %form = NTS::Utils::getForm(eval {my $i = $r->args || $r->content; return $i}); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$r->print($form{field}); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 TO DO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
no comment |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DIRECTIVE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 getForm() |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
%form = NTS::Utils::getForm(eval {my $i = $r->args || $r->content; return $i}); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 Authors |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Udlei Nattis Eunattis (at) nattis.comE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|