{

use esmith::AccountsDB;

if (($pydio{'status'} || 'disabled') eq 'enabled'){
    my $alias = (($pydio{'AliasOnPrimary'} || 'enabled') eq 'enabled' ) ? "Alias /ajaxplorer /usr/share/pydio\nAlias /pydio /usr/share/pydio":'';
    my $allow = (($pydio{'access'} || 'private') eq 'public') ? 'all':"$localAccess $externalSSLAccess";
    my $auth = (($pydio{'Authentication'} || 'http') eq 'http') ? "AuthName \"Pydio\"\n" .
                    "    AuthType Basic\n" .
                    "    AuthExternal pwauth\n" .
                    "    Require valid-user\n" : '';
    my $maxsize = $pydio{'MaxUploadSize'} || '200M';
    my $homedir = $pydio{'HomeDir'} || 'none';
    $homedir = (($homedir eq 'enabled') || ($homedir eq 'users')) ? ":/home/e-smith/files/users":"";

    my $shares = '';

    my $public = $pydio{'PublicShares'} || 'enabled';
    $OUT .=<<"EOF" if ($public eq 'enabled');

Alias /ajxppub /var/lib/pydio/public
<Directory /var/lib/pydio/public>
    Options None
    AddType application/x-httpd-php .php
    php_admin_value open_basedir /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/home/e-smith/files/shares$homedir
    Order deny,allow
    Allow from all
    <Files ".ajxp_*">
        deny from all
    </Files>
    <IfModule mod_xsendfile.c>
        XSendFile on
        XSendFilePath /home/e-smith/files/shares
        XSendFilePath /var/lib/pydio
        XSendFilePath /home/e-smith/files/users
    </IfModule>
</Directory>

EOF

    $OUT .=<<"EOF";

$alias

<Directory /usr/share/pydio>
    AddType application/x-httpd-php .php
    php_admin_value open_basedir /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/home/e-smith/files/shares$homedir
    php_admin_value memory_limit 100M
    php_admin_value upload_max_filesize $maxsize
    php_admin_value post_max_size $maxsize
    php_admin_value max_execution_time 900
    php_admin_value upload_tmp_dir /var/lib/pydio/tmp
    php_admin_value session.save_path /var/lib/pydio/tmp
    php_admin_flag output_buffering off
    SSLRequireSSL on
    Order deny,allow
    Deny from all
    Allow from $allow
    $auth
    <IfModule mod_xsendfile.c>
        XSendFile on
        XSendFilePath /home/e-smith/files/shares
        XSendFilePath /var/lib/pydio
        XSendFilePath /home/e-smith/files/users
    </IfModule>
</Directory>

EOF

}
else {
    $OUT .=<<'EOF';

# Pydio is disabled
# You can enable it with
# db configuration setprop pydio status enabled
# signal-event webapps-update

EOF
}

}
