| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Apache::StrReplace; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21003
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
205
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$Apache::StrReplace::VERSION = '0.03'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
50
|
33
|
1
|
|
37
|
if ( exists $ENV{'MOD_PERL_API_VERSION'} && $ENV{'MOD_PERL_API_VERSION'} eq 2 ) { |
|
|
|
50
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
0
|
require Apache2::Filter; |
|
13
|
0
|
|
|
|
|
0
|
push @ISA, 'Apache2::Filter'; |
|
14
|
0
|
|
|
|
|
0
|
require Apache2::Response; |
|
15
|
0
|
|
|
|
|
0
|
require Apache2::Const; |
|
16
|
0
|
|
|
|
|
0
|
require Apache2::RequestRec; |
|
17
|
0
|
|
|
|
|
0
|
require Apache2::RequestUtil; |
|
18
|
0
|
|
|
|
|
0
|
Apache2::Const->import(qw(OK DECLINED)); |
|
19
|
|
|
|
|
|
|
} elsif ( exists $ENV{'MOD_PERL'} ) { |
|
20
|
0
|
|
|
|
|
0
|
require Apache::Filter; |
|
21
|
0
|
|
|
|
|
0
|
push @ISA, 'Apache::Filter'; |
|
22
|
0
|
|
|
|
|
0
|
require Apache::Response; |
|
23
|
0
|
|
|
|
|
0
|
require Apache::Const; |
|
24
|
0
|
|
|
|
|
0
|
require Apache::RequestRec; |
|
25
|
0
|
|
|
|
|
0
|
require Apache::RequestUtil; |
|
26
|
0
|
|
|
|
|
0
|
Apache::Const->import(qw(OK DECLINED)); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
82
|
use constant BUFF_LEN => 1024; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
418
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub handler { |
|
33
|
0
|
|
|
0
|
0
|
|
my $f = shift; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $search = $f->r->dir_config('StrReplaceSearch'); |
|
36
|
0
|
|
|
|
|
|
my $replace = $f->r->dir_config('StrReplaceReplace'); |
|
37
|
0
|
|
0
|
|
|
|
my $ctype = $f->r->dir_config('StrReplaceContentType') || 'text/html'; |
|
38
|
0
|
|
0
|
|
|
|
my $option = $f->r->dir_config('StrReplaceOption') || 'g'; |
|
39
|
0
|
0
|
|
|
|
|
$option = 'g' if $option!~/^[egimosx]+$/; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
unless ($f->r->content_type =~/$ctype/) { |
|
42
|
0
|
|
|
|
|
|
return DECLINED(); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
unless ( $f->ctx ) { |
|
46
|
0
|
|
|
|
|
|
$f->ctx( { body => '' } ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
while ($f->read(my $buffer, BUFF_LEN)) { |
|
50
|
0
|
|
|
|
|
|
$f->ctx->{'body'}.= $buffer; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
unless ($f->seen_eos) { |
|
54
|
0
|
|
|
|
|
|
return OK(); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
eval '$f->ctx->{body}=~s/$search/'."$replace/$option;"; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$f->r->set_content_length( length( $f->ctx->{'body'} ) ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$f->print( $f->ctx->{'body'} ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
OK(); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
__END__ |