Baza. Cisto onako nabacana polja
[code]CREATE TABLE IF NOT EXISTS access_log
(
id
bigint(20) NOT NULL auto_increment,
userid
varchar(15) NOT NULL,
access_time
datetime NOT NULL,
remote_ip
varchar(15) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS access_log_err
(
id
bigint(20) NOT NULL auto_increment,
userid
varchar(15) NOT NULL,
access_time
datetime NOT NULL,
remote_ip
varchar(15) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS transfer_log
(
transfer_id
int(11) NOT NULL auto_increment,
userid
varchar(30) NOT NULL default ‘’,
filename
varchar(255) NOT NULL default ‘’,
bytes
bigint(20) NOT NULL default ‘0’,
remote_host
varchar(255) NOT NULL default ‘’,
remote_ip
varchar(15) NOT NULL default ‘’,
command
varchar(4) NOT NULL default ‘’,
time_req
bigint(20) NOT NULL default ‘0’,
request_time
datetime NOT NULL default ‘0000-00-00 00:00:00’,
PRIMARY KEY (transfer_id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS transfer_log_err
(
transfer_id
int(11) NOT NULL auto_increment,
userid
varchar(30) NOT NULL default ‘’,
filename
varchar(255) NOT NULL default ‘’,
bytes
bigint(20) NOT NULL default ‘0’,
remote_host
varchar(255) NOT NULL default ‘’,
remote_ip
varchar(15) NOT NULL default ‘’,
command
varchar(4) NOT NULL default ‘’,
time_req
bigint(20) NOT NULL default ‘0’,
request_time
datetime NOT NULL default ‘0000-00-00 00:00:00’,
PRIMARY KEY (transfer_id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS users
(
userid
varchar(30) NOT NULL,
passwd
varchar(80) NOT NULL,
uid
int(11) default NULL,
gid
int(11) default NULL,
homedir
varchar(255) default NULL,
shell
varchar(255) default NULL,
login_allowed
tinyint(1) NOT NULL default ‘1’,
login_count
int(6) NOT NULL,
last_login
datetime default NULL,
last_login_ip
varchar(15) default NULL,
last_failed_login
datetime default NULL,
UNIQUE KEY userid
(userid
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;[/code]
Konfiguracija proftpd-a ( samo dio relevantan za mod_sql ):
[code]DefaultRoot ~
SQLEngine on
SQLAuthTypes OpenSSL
SQLAuthenticate users
SQLConnectInfo ftp@localhost ftp ftp
SQLDefaultGID 100
SQLDefaultUID 65534
SQLMinUserGID 100
SQLMinUserUID 1000
SQLUserInfo users userid passwd uid gid homedir shell
SQLUserWhereClause “login_allowed = 1”
NO Home Dir Creation
CreateHome on 755 dirmode 755
for debugging only
SQLLogFile /var/log/proftpd.sql.log
SQLShowInfo PASS “230” "User %u. Last login %{lasttime}. You have been logged on %{getcount} times on this server. Last see
n IP %{lastip}"
SQLNamedQuery getcount SELECT "login_count, userid from users WHERE userid=’%u’"
SQLNamedQuery lasttime SELECT "last_login, userid from users WHERE userid=’%u’"
SQLNamedQuery lastip SELECT “last_login_ip, userid from users WHERE userid=’%u’”
Update user table on success and failure
SQLLog PASS user_auth_success
SQLNamedQuery user_auth_success UPDATE “last_login=now(), login_count=login_count+1, last_login_ip=’%a’ WHERE userid=’%u’” users
SQLLog ERR_PASS user_auth_failed
SQLNamedQuery user_auth_failed UPDATE “last_failed_login=now() WHERE userid=’%U’” users
Track the logons on the FTP server
SQLLog PASS access_success
SQLNamedQuery access_success INSERT “’’,’%u’,now(),’%a’” access_log
SQLLog ERR_PASS access_failed
SQLNamedQuery access_failed INSERT “’’,’%U’,now(),’%a’” access_log_err
Transfer Log MySQL
SQLLog RETR,STOR transfer_log
SQLNamedQuery transfer_log INSERT “’’,’%u’, ‘%f’, ‘%b’, ‘%h’, ‘%a’, ‘%m’, ‘%T’,now()” transfer_log
SQLLog ERR_RETR,ERR_STOR transfer_log_err
SQLNamedQuery transfer_log_err INSERT “’’,’%u’, ‘%f’, ‘%b’, ‘%h’, ‘%a’, ‘%m’, ‘%T’,now()” transfer_log_err[/code]
To bi bilo to. U pocetku podesis odakle da cita informacije o korisnicima i na koji nacin da tretira sifre, mozes deaktivirati korisnika putem atributa login_allowed u tabeli users. Posto moj sistem na drugi nacin kreira home direktorije, navedeni dio konfiguracije je tu ( kome zatreba ).
Ice