Controlling access to a questionnaire by IP address

Problem

You want to allow access to a questionnaire only to workstations at a certain IP address.

Solution

Use the "Deny access if" pound instruction as in:

    # Deny access if = {$contexte{ip}!~/^55\.54\.53/}

Discussion

The "Deny access if" pound instruction contains a logical condition which denies access to the questionnaire if it is true. This condition is tested every time callweb.cgi receives a request. In the example above, access is denied if the IP address of the computer accessing the questionnaire does not begin with 55.54.53. Other $contexte information can also be used to control access.

In the example above, the logical expression must use Perl syntax in order to make use of the $contexte data — hence the use of the braces around the condition. The Perl "!~" operator means "does not contain" while the circumflex accent at the beginning of the pattern anchors the comparison to the beginning of the IP address.

The "Deny access if" pound instruction is the strongest barrier to entry since it is tested with every call to callweb.cgi. Alternative methods (using questionnaire logic) can only be implemented at specific places in the script.

This instruction displays system message 28 which is fully customizable, like any other system message.

Controlling access to a questionnaire by IP address

Problem

You want to allow access to a questionnaire only to workstations at a certain IP address.

Solution

Use the "Deny access if" pound instruction as in:

    # Deny access if = {$contexte{ip}!~/^55\.54\.53/}

Discussion

The "Deny access if" pound instruction contains a logical condition which denies access to the questionnaire if it is true. This condition is tested every time callweb.cgi receives a request. In the example above, access is denied if the IP address of the computer accessing the questionnaire does not begin with 55.54.53. Other $contexte information can also be used to control access.

In the example above, the logical expression must use Perl syntax in order to make use of the $contexte data — hence the use of the braces around the condition. The Perl "!~" operator means "does not contain" while the circumflex accent at the beginning of the pattern anchors the comparison to the beginning of the IP address.

The "Deny access if" pound instruction is the strongest barrier to entry since it is tested with every call to callweb.cgi. Alternative methods (using questionnaire logic) can only be implemented at specific places in the script.

This instruction displays system message 28 which is fully customizable, like any other system message.