create table if not exists xbt_announce_log ( id int not null auto_increment, ipa int unsigned not null, port int not null, event int not null, info_hash blob not null, peer_id blob not null, downloaded bigint not null, left0 bigint not null, uploaded bigint not null, uid int not null, mtime int not null, primary key (id) ); create table if not exists xbt_config ( name varchar(255) not null, value varchar(255) not null ); create table if not exists xbt_deny_from_hosts ( begin int not null, end int not null ); create table if not exists xbt_files ( fid int not null auto_increment, info_hash blob not null, leechers int not null default 0, seeders int not null default 0, completed int not null default 0, flags int not null default 0, mtime int not null, ctime int not null, files_size bigint NOT NULL default '0', attach_id int not null, primary key (fid), unique key (info_hash(20)), key (attach_id) ); create table if not exists xbt_files_users ( fid int not null, uid int not null, active tinyint not null, announced int not null, completed int not null, downloaded bigint not null, `left` bigint not null, uploaded bigint not null, mtime int not null, unique key (fid, uid), key (uid) ); create table if not exists xbt_scrape_log ( id int not null auto_increment, ipa int not null, info_hash blob, uid int not null, mtime int not null, primary key (id) ); create table if not exists xbt_users ( uid int not null auto_increment, name varchar(255) not null, pass blob not null, can_leech tinyint not null default 1, can_create tinyint(4) NOT NULL default '0', can_delete tinyint(4) NOT NULL default '0', wait_time int not null default 0, peers_limit int not null default 0, torrents_limit int not null default 1, torrent_pass char(32) not null, torrent_pass_secret bigint not null, downloaded bigint not null, uploaded bigint not null, primary key (uid) ); drop trigger trigger_ai_ipbf_members; delimiter // CREATE DEFINER = 'root'@'localhost' TRIGGER trigger_ai_ipbf_members AFTER INSERT on ipbf_members FOR EACH ROW BEGIN REPLACE INTO xbt_users SET uid = NEW.id, name = NEW.name, torrent_pass = MD5(CONCAT_WS(':', NEW.name, NEW.member_login_key)), pass = MD5(CONCAT_WS(':', NEW.id, NEW.name,NEW.email,NEW.member_login_key)); END; // delimiter ; drop trigger trigger_ad_ipbf_attachments; delimiter // CREATE DEFINER = 'root'@'localhost' TRIGGER trigger_ad_ipbf_attachments AFTER DELETE on ipbf_attachments FOR EACH ROW BEGIN UPDATE xbt_files SET flags = 1 WHERE attach_id = OLD.attach_id; END; // delimiter ; INSERT IGNORE INTO xbt_users (uid, name, torrent_pass, pass) SELECT id, name, MD5(CONCAT_WS(':',name,member_login_key)), MD5(CONCAT_WS(':', id, name,email,member_login_key)) FROM ipbf_members