Apache-Roaming
view release on metacpan or search on metacpan
lib/Apache/Roaming.pm view on Meta::CPAN
=head1 NETSCAPE COMMUNICATOR CONFIGURATION
Assuming your document root directory is /home/httpd/html and you
want your profile files being located under http://your.host/roaming,
do the following:
=over 8
=item 1.)
Create a directory /home/httpd/html/roaming. Make it writable by the
web server and noone else, for example by doing a
mkdir /home/httpd/html/roaming
chown nobody /home/httpd/html/roaming
# Insert your web servers UID here
chmod 700 /home/httpd/html/roaming
=item 2.)
Start your communicator and open Preferences/Roaming User. Click the
"Enable Roaming Access for this profile" checkbox.
=item 3.)
Open Preferences/Roaming User/Server Information. Click the "HTTP Server"
checkbox and enter the Base URL "http://your.host/roaming/$USERID".
=back
That's all. Now hit the Ok button. A directory with the name of your
user id should automatically be generated under /roaming and files
should be stored there.
=head1 METHOD INTERFACE
As already said, the Apache::Roaming module is subclassable. You can
well use it by itself, but IMO the most important possibility is
overwriting the GET method for complete control over the users
settings.
=head2 handler
$result = Apache::Roaming->handler($r);
(Class Method) The I<handler> method is called by the Apache server
for any request. It receives an Apache request B<$r>. The methods
main task is creating an instance of Apache::Roaming by calling the
I<new> method and then passing control to the I<Authenticate>,
I<CheckDir> and I<GET>, I<PUT>, I<DELETE> or I<MOVE>, respectively,
methods.
=cut
sub handler ($$) {
my($class, $r) = @_;
my $file = File::Spec->canonpath(URI::Escape::uri_unescape($r->filename()));
if ($file=~/IMAP$/) {
my $addon=$r->the_request();
$addon=~s/IMAP\s(.*)\s.*$/$1/;
$file="$file%20$addon";
}
if (my $pi = $r->path_info()) {
my @dirs = grep { length $_ } split(/\//, $pi);
my $f = pop @dirs;
$file = File::Spec->catfile($file, @dirs, $f) if $f;
}
my $self = eval {
$class->new('file' => $file,
'basedir' => $r->dir_config('BaseDir'),
'user' => $r->connection()->user(),
'method' => $r->method(),
'status' => Apache::Constants::SERVER_ERROR(),
'request' => $r)
};
if ($@) {
$r->log_reason($@, $file);
return Apache::Constants::SERVER_ERROR();
}
eval {
$self->Authenticate();
$self->CheckDir();
if ($self->{'method'} !~ /(?:GET|PUT|DELETE|MOVE)/) {
$self->{'status'} = Apache::Constants::HTTP_METHOD_NOT_ALLOWED();
die "Unknown method: $self->{'method'}";
}
my $method = $self->{'method'};
my $f = File::Basename::basename($file);
$f =~ s/\W//g;
my $m = "$method\_$f";
UNIVERSAL::can($self, $m) ? $self->$m() : $self->$method();
};
if ($@) {
$r->log_reason($@, $file);
return Apache::Constants::SERVER_ERROR();
}
return Apache::Constants::OK();
}
=pod
=head2 handler_type
$status = Apache::Roaming->handler_type($r)
(Class Method) This method is required only, because the Apache server
would refuse other methods than GET otherwise. It checks whether the
requested method is GET, PUT, HEAD, DELETE or MOVE, in which case it
returns the value OK. Otherwise the value DECLINED is returned.
( run in 2.399 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )