# Server settings
ServerName				"<SERVERNAME> FTP Server"
ServerType				standalone
ServerIdent				off
DefaultServer			on
Port					21
MaxInstances			50

# General settings
DeferWelcome			on
MultilineRFC2228		on
ShowSymlinks			on
AllowOverwrite			on
AllowStoreRestart		on
AllowRetrieveRestart		on
UseReverseDNS			off
ListOptions				"-al"
DisplayChdir			.message
UseIPv6				off

# Modules settings
#DelayEngine				off

# Timeout settings
TimeoutLogin			120
TimeoutNoTransfer		600
TimeoutStalled			600
TimeoutIdle				600

# Security settings
RootLogin				off
RequireValidShell		off
User					froxlorftpd
Group					froxlorftpd
Umask					133 022
DefaultRoot				~
DenyFilter				\*.*/

# Per-Directory settings
<Directory /*>
Umask					133 022
AllowOverwrite			on
</Directory>

# SQL settings
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

# Quota settings
QuotaEngine on
QuotaShowQuotas on
QuotaDisplayUnits Mb
QuotaLock /var/lock/ftpd.quotatab.lock
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

# TLS settings
#<IfModule mod_tls.c>
#TLSEngine					on
#TLSLog						/var/log/proftpd-tls.log
#TLSProtocol					SSLv23
#TLSTimeoutHandshake				120
# Really important for WinClients
#TLSOptions					NoCertRequest
#TLSRSACertificateFile		/etc/ssl/server/<SERVERNAME>.crt
#TLSRSACertificateKeyFile	/etc/ssl/server/<SERVERNAME>.key
# Authenticate client that want to use FTP over TLS?
#TLSVerifyClient			off
# Uncomment the following line to force tls login
#TLSRequired				off
#</IfModule>

# LOG settings
# Logging Formats
LogFormat default "%h %1 %u %t \"%r\" %s %b"
LogFormat auth "%v [%P] %h %t \"%r\" %s"
LogFormat write "%h %l %u %t \"%r\" %s %b"
# Activate Logging
# all logins
ExtendedLog /var/log/proftpd-auth.log AUTH auth
# file/dir access
ExtendedLog /var/log/proftpd-access.log WRITE,READ write
# everything (be careful, generates_ very_ big logfiles)
#ExtendedLog /var/log/proftpd-all.log ALL default

# make proftpd faster / do not perform ident and reverse dns lookup
UseReverseDNS off
