
##########
CREATE TABLE `hb_admin_details` (
  `id` int(10) NOT NULL,
  `firstname` text NOT NULL,
  `lastname` text NOT NULL,
  `email` text NOT NULL,
  `signature` text NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `email` (`email`(64)),
  KEY `firstname_lastname` (`firstname`(32),`lastname`(32))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
INSERT INTO `hb_admin_details` (`id`, `firstname`, `lastname`, `email`, `signature`) VALUES
(1, 'Default', 'User', 'change@me.com', '--my signature--');
##########
CREATE TABLE `hb_admin_failed_login` (
  `id` int(10) NOT NULL auto_increment,
  `date` datetime NOT NULL,
  `login` varchar(255) NOT NULL,
  `ip` varbinary(16) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_admin_fields` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(127) NOT NULL,
  `variable` varchar(127) NOT NULL,
  `type` varchar(127) NOT NULL,
  `default` text NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `variable` (`variable`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_admin_fields_values` (
  `field_id` int(11) NOT NULL,
  `admin_id` int(11) NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY  (`field_id`,`admin_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_api_log` (
  `id` int(11) NOT NULL auto_increment,
  `api_id` varchar(20) NOT NULL,
  `date` datetime NOT NULL,
  `ip` varchar(32) NOT NULL,
  `action` text NOT NULL,
  `result` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_banned_emails` (
  `id` int(1) NOT NULL auto_increment,
  `domain` varchar(128) NOT NULL,
  `reason` text NOT NULL,
  `expires` datetime NOT NULL,
  `count` int(1) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_banned_ip` (
  `id` int(1) NOT NULL auto_increment,
  `ip` varchar(64) NOT NULL,
  `reason` text NOT NULL,
  `expires` datetime NOT NULL,
  `count` int(1) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_configuration` (
  `setting` varchar(128) NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY  (`setting`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_cron_tasks` (
  `task` varchar(40) NOT NULL default '',
  `name` varchar(255) NOT NULL,
  `lastrun` datetime NOT NULL,
  `status` tinyint(1) NOT NULL,
  `count` tinyint(4) NOT NULL default '0',
  `metadata` text NOT NULL,
  `output` text NOT NULL,
  `run_every` enum('Run','Time','Week','Month','Hour') NOT NULL,
  `run_every_time` varchar(5) NOT NULL,
  PRIMARY KEY  (`task`),
  KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
INSERT INTO `hb_cron_tasks` (`task`, `name`, `lastrun`, `status`, `count`, `metadata`, `output`, `run_every`, `run_every_time`) VALUES
('custom:2:call_Daily', 'Module - AutoUpgrade, daily cron call', '0000-00-00 00:00:00', 1, 0, '', '', 'Time', '1200'),
('customModules', 'customModules', '0000-00-00 00:00:00', 1, 0, '', '', 'Run', '1200'),
('sendCronResults', 'Send daily Cron-Runs results email', '0000-00-00 00:00:00', 1, 0, '', '', 'Time', '1200');
##########
CREATE TABLE `hb_email_templates` (
  `id` int(11) NOT NULL auto_increment,
  `tplname` varchar(128) NOT NULL,
  `group` enum('Domain','Product','Invoice','General','Support','Custom','Mobile') default NULL,
  `for` enum('Client','Admin') NOT NULL default 'Client',
  `language_id` int(11) NOT NULL default '1',
  `subject` text NOT NULL,
  `message` text NOT NULL,
  `send` tinyint(1) default '1',
  `plain` tinyint(1) default '0',
  `system` tinyint(1) default '1',
  `hidden` tinyint(1) default '0',
  PRIMARY KEY  (`id`,`language_id`),
  KEY `tplname` (`tplname`(32)),
  KEY `group` (`group`),
  KEY `for` (`for`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_email_templates_lang` (
  `id` int(5) NOT NULL auto_increment,
  `language` varchar(32) NOT NULL,
  PRIMARY KEY  (`id`,`language`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
##########
INSERT INTO `hb_email_templates_lang` (`id`, `language`) VALUES
(1, 'english');
##########
CREATE TABLE `hb_error_log` (
  `id` int(11) NOT NULL auto_increment,
  `date` datetime NOT NULL,
  `entry` text NOT NULL,
  `type` enum('Exception','PHP Error','Other') NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_language` (
  `id` int(11) NOT NULL auto_increment,
  `parent_id` int(11) NOT NULL,
  `target` enum('admin','user') NOT NULL default 'admin',
  `name` varchar(30) NOT NULL,
  `status` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `parent_id` (`parent_id`),
  KEY `target` (`target`),
  KEY `status` (`status`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
##########
INSERT INTO `hb_language` (`id`, `parent_id`, `target`, `name`, `status`) VALUES
(1, 0, 'admin', 'english', 1),
(2, 0, 'user', 'english', 1),
(3, 1, 'admin', 'portuguese-br', 0),
(4, 2, 'user', 'portuguese-br', 0),
(5, 2, 'user', 'german', 0);
##########
CREATE TABLE `hb_language_locales` (
  `language_id` int(11) NOT NULL,
  `section` varchar(20) character set utf8 collate utf8_bin NOT NULL,
  `keyword` varchar(40) character set utf8 collate utf8_bin NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY  (`language_id`,`section`,`keyword`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_modules_configuration` (
  `id` int(11) NOT NULL auto_increment,
  `module` varchar(128) NOT NULL,
  `type` enum('Hosting','Payment','Domain','Fraud','Other','Notification') NOT NULL,
  `config` text NOT NULL,
  `filename` varchar(128) NOT NULL,
  `version` varchar(32) NOT NULL,
  `active` tinyint(1) default '1',
  `modname` varchar(100) NOT NULL,
  `subtype` tinyint(1) NOT NULL default '0',
  `sort_order` int(11) NOT NULL default '0',
  `settings` text NOT NULL,
  `access` varchar(128) NOT NULL,
  `remote` varchar(63) default NULL,
  PRIMARY KEY  (`id`),
  KEY `type_active` (`type`,`active`),
  KEY `filename` (`filename`(32))
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
##########
INSERT INTO `hb_modules_configuration` (`id`, `module`, `type`, `config`, `filename`, `version`, `active`, `modname`, `subtype`, `sort_order`, `settings`, `access`, `remote`) VALUES
(1, 'HBExtras', 'Other', 'a:0:{}', 'class.hbextras.php', '0.5', 1, 'HostBill Extras', 0, 0, '|haveadmin|havetpl|header_js|', '', NULL),
(2, 'AutoUpgrade', 'Other', 'a:0:{}', 'class.autoupgrade.php', '1.2', 1, 'HostBill Auto-Upgrade', 0, 100, '|haveadmin|havetpl|havecron|extras_menu|header_js|', '', NULL);
##########
CREATE TABLE `hb_reports` (
  `id` int(11) NOT NULL auto_increment,
  `type` varchar(32) NOT NULL,
  `name` varchar(255) NOT NULL,
  `query` text NOT NULL,
  `options` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_security_rules` (
  `id` int(11) NOT NULL auto_increment,
  `rule` varchar(32) NOT NULL,
  `action` enum('allow','deny') NOT NULL default 'allow',
  `target` enum('admin','user') NOT NULL default 'admin',
  `target_id` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `reule` (`rule`),
  KEY `target_id` (`target_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
CREATE TABLE `hb_system_log` (
  `id` int(11) NOT NULL auto_increment,
  `date` datetime NOT NULL,
  `what` text NOT NULL,
  `who` varchar(128) NOT NULL,
  `type` enum('none','order','invoice','client','account','domain','transaction','cron_prof','admin','admin_group','product','product_cat','product_add','server','email_tpl') NOT NULL default 'none',
  `item_id` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
##########
