Apache-Roaming

 view release on metacpan or  search on metacpan

lib/Apache/Roaming.pm  view on Meta::CPAN

Compared to Apache::Roaming, this script doesn't need mod_perl. On
the other hand it doesn't support the MOVE method, thus you need
to set the li.prefs.http.useSimplePut attribute in your Netscape
preferences. Due to the missing MOVE method, it may be even slower
than Apache::Roaming and perhaps a little bit less stable.


The modules features are:

=over 8

=item *

GET, HEAD, PUT, DELETE and MOVE are handled by the module. In particular
the Non-standard MOVE method is implemented, although Apache doesn't know
it by default. Thus you need no set the li.prefs.http.useSimplePut
attribute to true.

=item *

Directories are created automatically.

=item *

The module is subclassable, so that you can create profiles on the fly
or parse and modify the user preferences. See L<Apache::Roaming::LiPrefs(3)>
for an example subclass.

=back


=head1 INSTALLATION

First of all you need an Apache Web server with mod_perl support. The
TypeHandler must be enabled, so you need to set PERL_TYPE=1 when
running Makefile.PL. For example, I use the following statements to
build Apache:

    cd mod_perl-1.16
    perl Makefile.PL APACHE_SRC=../apache_1.3.X/src DO_HTTPD=1 \
        USE_APACI=1 PERL_METHOD_HANDLERS=1 PERL_AUTHEN=1 \
        PERL_CLEANUP=1 PREP_HTTPD=1 PERL_STACKED_HANDLERS=1 \
	PERL_FILE_API=1
    cd ../apache-1.3.3
    ./configure --activate-module=src/modules/perl/libperl.a
    make
    make install
    cd ../mod_perl-1.16
    make
    make install

See the mod_perl docs for details.

Once the web server is installed, you need to create a directory for
roaming profiles, I assume /home/httpd/html/roaming in what follows,
with /home/httpd/html being the servers root directory. Be sure, that
this directory is writable for the web server, better for the web
server only. For example I do

    mkdir /home/httpd/html/roaming
    chown nobody /home/httpd/html/roaming
    chgrp nobody /home/httpd/html/roaming
    chmod 700 /home/httpd/html/roaming

with I<nobody> being the web server user.

Access to the roaming directory must be restricted and enabled via
password only. Finally tell the web server, that Apache::Roaming is
handling requests to this directory by adding something like this
to your srm.conf or access.conf:

    PerlModule Apache::Roaming
    <Location /roaming>
      PerlHandler Apache::Roaming->handler
      PerlTypeHandler Apache::Roaming->handler_type
      AuthType Basic
      AuthName "Roaming User"
      AuthUserFile /home/httpd/.htusers
      require valid-user
      PerlSetVar BaseDir /home/httpd/html/roaming
    </Location>

That's it!


=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,



( run in 0.515 second using v1.01-cache-2.11-cpan-71847e10f99 )