{
my $access = $opensondage{'access'} || 'private';
my $allow = ($access eq 'public')?'all':"$localAccess $externalSSLAccess";
my $auth = $opensondage{'Authentication'} || 'http';
my $alias = (($opensondage{'AliasOnPrimary'} || 'enabled') eq 'enabled') ?
    'Alias /opensondage /usr/share/opensondage' : '';
my $authuser = '';
my $authadmin = '';
if ($auth eq 'http'){
    $authuser =<<'EOF';
    <FilesMatch "^($|(index|adminstubs|infos_sondage)\.php)">
        SSLRequireSSL on
        AuthName "OpenSondage"
        AuthType Basic
        AuthExternal pwauth
        Require valid-user
    </FilesMatch>
EOF
    $authadmin =<<'EOF';
<Directory /usr/share/opensondage/admin>
    SSLRequireSSL on
    AuthName "OpenSondage Admin"
    AuthType Basic
    AuthExternal pwauth
    Require user admin
</Directory>
EOF
}
if ($opensondage{'status'} eq 'enabled'){

$OUT .=<<"END"

# OpenSondage Configuration
$alias

<Directory  /usr/share/opensondage>
    AllowOverride None
    AddType application/x-httpd-php .php
    php_admin_value open_basedir /usr/share/opensondage:/etc/opensondage:/usr/share/php
    php_admin_flag file_uploads Off
    php_admin_flag magic_quotes Off
    php_admin_flag magic_quotes_gpc Off
    php_admin_value max_execution_time 120
    order deny,allow
    deny from all
    allow from $allow
    Satisfy all
    <Files ~ "\.(txt|TXT|sql|SQL)$">
        Deny from all
    </Files>
$authuser
</Directory>
$authadmin
<Directory ~ "/usr/share/opensondage/(errors|adodb|iCalcreator|locale|php2pdf|scripts)">
    Deny from all
</Directory>

END
}
else{
    $OUT .= "# OpenSondage is disabled\n";
}
}
