# FTP Server
<IfDefine FTP>
        <VirtualHost *:21>
                ServerName %name%:21
                ErrorLog "%host_dir%/%name%/_sys/logs/error_log"
                CustomLog "%host_dir%/%name%/_sys/logs/access_log_ftp" ftp_log

                DocumentRoot "%host_dir%/%name%"
                DirectoryIndex ftp_index_list

                # mysql connection
                DBDriver mysql
                DBDParams "host=%db_server% dbname=%db_name% user=%db_user% pass=%db_pass%"
                DBDPersist On
                DBDMin 1
                DBDKeep 2
                DBDMax 2
                DBDExptime 60                   

                # ftp specific
                FTP On
                FTPOptions VirtualHostByUser StripHostname              

                #FTPUmask             022
                #FTPTimeoutLogin      120
                FTPTimeoutIdle       600
                FTPMaxLoginAttempts    3

                <Directory "%host_dir%/%name%">
                        Options FollowSymLinks
                        AllowOverride none
                        order allow,deny
                        Allow from All

                        # Authentication
                        AuthName "FTP Authentication"
                        AuthType basic
                        AuthBasicProvider dbd
                        AuthDBDUserPWQuery "SELECT password FROM users WHERE (groups = 'ftp' or groups LIKE '%,ftp' or groups LIKE 'ftp,%' or groups LIKE '%,ftp,%') AND host = %id% AND name = %s;"
                        Require valid-user

                        #Remove filter for dynamic content
                        RemoveHandler .pl .cgi .shtm .shtml
                        RemoveHandler .php .phps
                        <Files ~ "^\.ht">
                                Order allow,deny
                                Allow from all
                        </Files>
                </Directory>
                
        </VirtualHost>
</IfDefine>