# Server settings
ServerName                      "<SERVERNAME> FTP Server"
ServerType                      standalone
DefaultServer                   on
Port                            21
UseIPv6                         off
Umask                           022
SyslogLevel			emerg
SystemLog                       /var/log/xferlog
LogFormat                       auth    "%v [%P] %h %t \"%r\" %s"
ExtendedLog                     /var/log/xferlog        AUTH auth

# General settings
DeferWelcome                    off
MultilineRFC2228                on
ShowSymlinks                    on
TimeoutNoTransfer               600
TimeoutStalled                  600
TimeoutIdle                     1200
DisplayLogin                    welcome.msg
DisplayChdir                    .message
ListOptions                     "-l"
DenyFilter                      \*.*/
MaxInstances                    30
CommandBufferSize		512
User				nobody
Group				nogroup
AllowOverwrite			on

# Allow up- and downloads to be continued
AllowRetrieveRestart	On
AllowStoreRestart		On

<IfModule mod_quotatab.c>
    QuotaEngine on
    QuotaShowQuotas on
    QuotaDisplayUnits Mb
    QuotaLock /var/lock/ftpd.quotatab.lock
</IfModule>

<IfModule mod_ratio.c>
    Ratios off
</IfModule>

<IfModule mod_delay.c>
    DelayEngine off
</IfModule>

<IfModule mod_sql.c>
    DefaultRoot ~
    RequireValidShell off
    AuthOrder mod_sql.c
    SQLBackend mysql
    SQLEngine on
    SQLAuthenticate on
    SQLAuthTypes Crypt
    SQLAuthenticate users* groups*
    SQLConnectInfo <SQL_DB>@<SQL_HOST> <SQL_UNPRIVILEGED_USER> <SQL_UNPRIVILEGED_PASSWORD>
    SQLUserInfo ftp_users username password uid gid homedir shell
    SQLGroupInfo ftp_groups groupname gid members
    SQLUserWhereClause "login_enabled = 'y'"

    SQLLog PASS login
    SQLNamedQuery login UPDATE "last_login=now(), login_count=login_count+1 WHERE username='%u'" ftp_users

    SQLLog RETR download
    SQLNamedQuery download UPDATE "down_count=down_count+1, down_bytes=down_bytes+%b WHERE username='%u'" ftp_users

    SQLLog STOR upload
    SQLNamedQuery upload UPDATE "up_count=up_count+1, up_bytes=up_bytes+%b WHERE username='%u'" ftp_users

    QuotaLimitTable sql:/get-quota-limit
    QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
    SQLNamedQuery get-quota-limit SELECT "ftp_users.username AS name, ftp_quotalimits.quota_type, ftp_quotalimits.per_session, ftp_quotalimits.limit_type, panel_customers.diskspace*1024 AS bytes_in_avail, ftp_quotalimits.bytes_out_avail, ftp_quotalimits.bytes_xfer_avail, ftp_quotalimits.files_in_avail, ftp_quotalimits.files_out_avail, ftp_quotalimits.files_xfer_avail FROM ftp_users, ftp_quotalimits, panel_customers WHERE ftp_users.username = '%{0}' AND panel_customers.loginname = SUBSTRING_INDEX('%{0}', 'ftp', 1) AND quota_type ='%{1}'"
    SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used,bytes_out_used, bytes_xfer_used, files_in_used, files_out_used,files_xfer_used FROM ftp_quotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"
    SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used= files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name= '%{6}' AND quota_type = '%{7}'" ftp_quotatallies
    SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4},%{5}, %{6}, %{7}" ftp_quotatallies
</IfModule>


#<IfModule mod_tls.c>
#    TLSEngine on
#    TLSLog /var/log/xferlog
#    TLSProtocol SSLv23
#    TLSRequired off
#    TLSRSACertificateFile /etc/ssl/cert.pem
#    TLSRSACertificateKeyFile /etc/ssl/key.pem
#    TLSVerifyClient off
#    TLSRenegotiate required off
#</IfModule>
