Leser: 1
![]() |
|< 1 2 3 4 5 6 >| | ![]() |
52 Einträge, 6 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sub parse_form {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
QuoteObtain permission before redistributing this software over the Internet or in any other medium. In all cases copyright and header must remain intact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use HTML::Template::Compiled;
use File::Find;
use HTML::Parser;
my $cgi = CGI->new();
print $cgi->header(type => 'text/plain');
my %params = $cgi->Vars();
my $basedir = '/home/netzgrafik/www.lottermoser.at/test/';
my @files = ();
find(\&find_files,$basedir);
my %includes = search($params{terms},\@files);
print_found($params{terms},\%includes);
sub find_files{
push(@files,$File::Find::name) if(-f $File::Find::name && $_ =~ /\.htm$/);
}
sub print_found{
my ($terms,$hashref) = @_;
print $terms," found in:\n";
foreach my $key(keys(%$hashref)){
print $key."\n" if($hashref->{$key} eq 'yes');
}
}
sub search{
my ($termsstring,$files) = @_;
my @terms = split(/\s+/,$termsstring);
my $parser = HTML::Parser->new(
api_version => 3,
start_h => [\&start,"self,tagname,attr"],
text_h => [\&text,"self,dtext"],
end_h => [\&end,"self,tagname"]);
$parser->{divs} = 0;
my $string = '';
my %include;
for my $html_file(@$files){
$string = '';
$parser->parse_file($html_file);
foreach $term (@terms) {
$term = umlauts($term);
if ($string =~ /$term/) {
$include{$html_file} = 'yes';
last;
}
else {
$include{$html_file} = 'no';
}
}
}
return %include;
}
sub start{
my ($self,$tag,$attr) = @_;
if($tag eq 'div' && $attr->{class} eq 'scroll'){
$self->{search} = 1;
}
if($tag eq 'div' and $self->{search}){
$self->{divs}++;
}
}
sub text{
my ($self,$dtext) = @_;
$string .= $dtext if($self->{search});
}
sub end{
my ($self,$tag) = @_;
if($tag eq 'div' and $self->{search}){
$self->{divs}--;
}
if($self->{divs} == 0){
$self->{search} = 0;
}
}
sub umlauts{
my ($term) = @_;
$term=~ s/&â/ä\;/g;
$term=~ s/¾/Ã\;/g;
$term=~ s/&â/ö\;/g;
$term=~ s/÷/Ã\;/g;
$term=~ s/&¸/ü\;/g;
$term=~ s/Ã/Ã\;/g;
$term=~ s/þ/Ã\;/g;
return $term;
}
![]() |
|< 1 2 3 4 5 6 >| | ![]() |
52 Einträge, 6 Seiten |