in reply to Re: Alternatives to PerlTransHandler?
in thread Alternatives to PerlTransHandler?
package util::TransHandler; use strict; use Apache::Constants qw(:common); sub handler { my $r = shift; my $uri = $r->uri; my ($host,$port) = split(/:/, $r->headers_in->{'Host'}); lc($host); print STDERR $host,"\n"; # if the hostname has more than one subdomain from the one specifi +ed below, reject it. # bar.slinger.foo.com = OK # bar.baz.slinger.foo.com = NOT OK if ($host =~ m/^([a-z0-9]+\.){2,}\.?slinger\.foo\.com$/) { $r->pnotes('BadHost' => ['1']); return DECLINED; # if its not from the base domain. Process it. Find the files and +return the correct path. } elsif ($host !~ m/^(slinger)?\.?foo.com$/) { $host =~ m/^([a-z0-9]+)\.slinger\.foo.com$/; my $members = MEMBERS->select( { SUBDOMAIN => $1 } ); my $session = SESSIONS->select( { SUBDOMAIN => $1 } ); # if the subdomain exists in the database, process it. # Otherwise let the user know its available to use. if ($members != 0 || $session != 0) { my $thedir = $r->server_root_relative($r->dir_config('User +Dir')); my $result; if (ref($members) eq 'ARRAY') { $result = $members->[0]{DI +RECTORY}; } if (ref($session) eq 'ARRAY') { $result = $session->[0]{DI +RECTORY}; } return DECLINED unless $uri =~ s!^/(.*)$!$thedir/$result/$ +1!; $r->pnotes('DontDo' => ['1']); $r->filename($uri); return OK; } else { # Switch that says the subdomain is available. $r->pnotes('SubDomain' => [$1]); return OK; } } else { return DECLINED; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Alternatives to PerlTransHandler?
by perrin (Chancellor) on Nov 01, 2001 at 20:55 UTC |