2007/6/14, Clinton Gormley <[EMAIL PROTECTED]>:
By using a PerlAccessHandler, you are adding a step into the standard
apache process.
So:
- the user goes to: /path/file.xyz
- your access handler performs its checks
- Allowed?
- Y :
- return OK
- file served by standard apache means
- N :
- return DENY
- apache sends a 403 (or whatever) response
mhh,I understood for your meanings.but my real question is how I can
send the file to clients after returning OK.here is my apache config
and modperl script,please give more helps.thanks!
from httpd.conf:
PerlModule DLAuth
<Location /flv>
SetHandler perl-script
PerlHandler DLAuth
</Location>
my handler:
sub handler {
my $r = shift;
my $q = Apache::Request->new($r);
my $uri = $r->uri;
my $file = (split/\//,$uri)[-1];
my $c = $r->connection;
my $ip = $ENV{'HTTP_X_FORWARDED_FOR'} ?
$ENV{'HTTP_X_FORWARDED_FOR'} : $c->remote_ip;
return FORBIDDEN unless $ip;
my $ip_int = unpack('N',inet_aton($ip));
my $str = $q->param('auth') || '';
$str = decode_base64($str);
my ($ip_int2,$time) = split/-/,$str;
$ip_int2 ||= 0;
$time ||= 0;
if ($ip_int != $ip_int2 or time() - $time > EXPIRE * 3600) {
return FORBIDDEN;
}else {
$r->internal_redirect(DLDIR. '/' .$file);
}
return OK;
}
=============
How to send the file (given the name is music.mp3) to clients then?
I tried,but didn't get the way to use default apache handler for the
same location of '/flv'.So I used a internal_redirect to another
directory instead.but this is not good,since users can get the real
directory just by guess.
Thanks!
--jen