{
my $access = $dl{'access'} || 'private';
my $allow = ($access eq 'public')?'all':"$localAccess $externalSSLAccess";
my $authtype = $dl{'Authentication'} || 'http';
my $alias = (($dl{'AliasOnPrimary'} || 'enabled') eq 'enabled') ?
    'Alias /dl /usr/share/dl' : '';
my $maxupload = $dl{'MaxUploadSize'} || '1024';
my $maxpost = $maxupload+1;
$maxupload .= 'M';
$maxpost .= 'M';
my $auth = '';
if ($authtype eq 'http'){
    $auth =<<'EOF';
    <FilesMatch "^(admin|rest)\.php">
        SSLRequireSSL on
        AuthName "dl"
        AuthType Basic
        AuthExternal pwauth
        Require valid-user
    </FilesMatch>
EOF
}
if ($dl{'status'} eq 'enabled'){

$OUT .=<<"END"

# dl Configuration
$alias

<Directory  /usr/share/dl>
    AllowOverride Limit
    AddType application/x-httpd-php .php
    php_admin_value open_basedir /usr/share/dl:/etc/dl.php:/var/lib/dl:/var/log/dl.log
    php_admin_flag file_uploads On
    php_admin_flag magic_quotes Off
    php_admin_flag magic_quotes_gpc Off
    php_admin_value upload_max_filesize $maxupload
    php_admin_value post_max_size $maxpost
    php_admin_value memory_limit 100M
    php_admin_flag output_buffering Off
    php_admin_value max_execution_time 0
    php_admin_value upload_tmp_dir /var/lib/dl/tmp
    php_admin_value session.save_path /var/lib/dl/tmp
    php_admin_value session.gc_maxlifetime 86400
    order deny,allow
    deny from all
    allow from $allow
$auth
</Directory>
<Directory /usr/share/dl/include>
    Deny from all
</Directory>
<Directory /usr/share/dl/style/include>
    Deny from all
</Directory>
END
}
else{
    $OUT .= "# dl is disabled\n";
}
}
