| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (C) 2000 by Robert Jenks |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
4
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
5
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
6
|
|
|
|
|
|
|
# (at your option) any later version. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
9
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11
|
|
|
|
|
|
|
# GNU Library General Public License for more details. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
14
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
15
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Apache::AddHostPath; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
2461
|
use Apache::Constants qw(:common); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Apache::Log (); |
|
21
|
|
|
|
|
|
|
use vars qw($VERSION); |
|
22
|
|
|
|
|
|
|
$VERSION = '0.02'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub handler { |
|
25
|
|
|
|
|
|
|
my $r = shift; |
|
26
|
|
|
|
|
|
|
my $uri = $r->uri(); |
|
27
|
|
|
|
|
|
|
$uri =~ s{^/}{}; |
|
28
|
|
|
|
|
|
|
my @path_items = split '/', $uri; |
|
29
|
|
|
|
|
|
|
my ($hostname, $port) = split ':', $r->headers_in->{'Host'}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my @path_info = (); |
|
32
|
|
|
|
|
|
|
my $filename = ''; |
|
33
|
|
|
|
|
|
|
PATH_ITEMS: while (1) { |
|
34
|
|
|
|
|
|
|
my @host_items = reverse split '\.', $hostname; |
|
35
|
|
|
|
|
|
|
push @host_items, $port; |
|
36
|
|
|
|
|
|
|
HOST_ITEMS: while (1) { |
|
37
|
|
|
|
|
|
|
$uri = '/' . join '/', @host_items, @path_items; |
|
38
|
|
|
|
|
|
|
$filename = $r->document_root() . $uri; |
|
39
|
|
|
|
|
|
|
$r->log->debug("Checking for: '$filename'"); |
|
40
|
|
|
|
|
|
|
last PATH_ITEMS if -d $filename or -f $filename; |
|
41
|
|
|
|
|
|
|
last HOST_ITEMS unless pop @host_items; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
return DECLINED unless @path_items; |
|
44
|
|
|
|
|
|
|
unshift @path_info, pop @path_items; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
$filename .= '/' if -d $filename; |
|
47
|
|
|
|
|
|
|
$r->log->debug("Found match at: '$filename'"); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Set $r->filename() |
|
50
|
|
|
|
|
|
|
#$filename = join '/', $filename, @path_info; |
|
51
|
|
|
|
|
|
|
#$r->log->debug("Filename set to: '$filename'"); |
|
52
|
|
|
|
|
|
|
#$r->filename($filename); |
|
53
|
|
|
|
|
|
|
#return OK; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Set $r->uri() |
|
56
|
|
|
|
|
|
|
$uri = join '/', $uri, @path_info; |
|
57
|
|
|
|
|
|
|
$uri .= '/' if ! @path_info && -d $filename; |
|
58
|
|
|
|
|
|
|
$r->log->debug("URI set to: '$uri'"); |
|
59
|
|
|
|
|
|
|
$r->uri($uri); |
|
60
|
|
|
|
|
|
|
return DECLINED; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |