For more information... RTFM!
NAVIGATION
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

FileControl

Control access to files using rules coded into a custom Perl subroutine.

Synopsis

FileControl  file_path  perl_code

Scope

This directive is available for use globally (in the "interchange.cfg" configuration file), and locally (in the "catalog.cfg" configuration file).

The global configuration affects all websites running under the Interchange instance.  Each individual website's local configuration will not affect or influence other websites in any way. 

Description

This directive allows you to control access to your files with the use of a block of custom Perl code.  Your Perl subroutine can grant or deny access to requested files using whatever criteria you need.

The custom subroutine will be called with three parameters, as follows:

  1. Page filename
  2. Write flag
  3. Perl caller information array

The return value is expected to be a boolean.  A true return value will be taken to mean that access to the requested file should be granted, whereas a false return value will result in the file access request being denied.

Examples

Specifying a FileControl subroutine inline

FileControl  test_dir/test_page <<EOF
sub {
    my ($fn, $write, @caller) = @_;

    # grant write access to pages that have "foo" in the filename
    return $fn =~ /foo/ if $write;

    # grant access to pages that don't have "bar" in the filename
    return $fn !~ /bar/;
}
EOF

Specifying a FileControl subroutine as a Sub or GlobalSub

The FileControl subroutine can be created and installed as a Sub or GlobalSub as follows:

Sub <<EOS
sub file_control {
    my ($fn, $write, @caller) = @_;

    # grant write access to pages that have "foo" in the filename
    return $fn =~ /foo/ if $write;

    # grant access to pages that don't have "bar" in the filename
    return $fn !~ /bar/;
}
EOS

FileControl  test_dir/test_page  file_control

Mapping FileControl to a subroutine in a Perl module

Assuming you have a Perl module called YourModule, and that module contains an appropriately-coded file_control() subroutine, you may make use of the subroutine as follows:

FileControl  test_dir/test_page  YourModule::file_control

Categories:  Global config directives | Local config directives
Last modified by: Kevin Walsh
Modification date: Friday 29 June 2007 at 6:23 PM (BST)
Home  |  Legal nonsense  |  Privacy policy  |  Donations  |  Contact us