/*
 * Statistic tables
 */
DROP TABLE IF EXISTS wbpageview;
CREATE TABLE `wbpageview` (
  `uid` int(11) NOT NULL DEFAULT '0',
  `addr` varchar(32) NOT NULL DEFAULT '',
  `namespace` enum('site','ajax_content','ajax_call','ajax_xinhadialog','ajax_wxmldialog','pixel') DEFAULT NULL,
  `counter` int(11) NOT NULL DEFAULT '0',
  `elapsedstart` int(11) NOT NULL DEFAULT '0',
  `elapsedlast` int(11) NOT NULL DEFAULT '0',
  `path` varchar(256) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `hint` enum('default','ignore','attack') NOT NULL DEFAULT 'default',
  `trackid` char(32) NOT NULL DEFAULT '',
  KEY `uidx` (`uid`),
  KEY `pathidx` (`path`),
  KEY `created` (`created`),
  KEY `trackid` (`trackid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='List if page views';

DROP TABLE IF EXISTS wbsessionview;
CREATE TABLE `wbsessionview` (
  `uid` int(11) NOT NULL DEFAULT 0,
  `trackid` char(32) NOT NULL DEFAULT '',
  `addr` varchar(32) NOT NULL DEFAULT '',
  `referer` varchar(256) NOT NULL DEFAULT '',
  `useragent` varchar(256) NOT NULL DEFAULT '',
  `acceptlang` varchar(256) NOT NULL DEFAULT '',
  `preferedlang` char(6) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `browser` varchar(64) NOT NULL DEFAULT '',
  `platform` varchar(64) NOT NULL DEFAULT '',
  `devicetype` varchar(64) NOT NULL DEFAULT '',
  `devicemobile` tinyint(1) NOT NULL DEFAULT 0,
  `devicetablet` tinyint(1) NOT NULL DEFAULT 0,
  `majorversion` int(11) NOT NULL DEFAULT 0,
  `minorversion` int(11) NOT NULL DEFAULT 0,
  `hint` enum('default','ignore','attack','spider') NOT NULL DEFAULT 'default',
  KEY `uidx` (`uid`),
  KEY `trackid` (`trackid`),
  KEY `createdidx` (`created`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='List of session views';

DROP TABLE IF EXISTS wbcookiepreferences;
CREATE TABLE wbcookiepreferences (
  uid int(11) NOT NULL DEFAULT '0',
  trackid char(32) NOT NULL DEFAULT '',
  addr varchar(32) NOT NULL DEFAULT '',
  allowed text NOT NULL DEFAULT '',
  created datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  KEY uidx (uid),
  KEY trackid (trackid),
  KEY createdidx (created)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Cookie preferences ';

DROP TABLE IF EXISTS wbgenericview;
CREATE TABLE wbgenericview (
  trackid char(32) NOT NULL DEFAULT '',
  uid int(11) NOT NULL DEFAULT '0',
  namespace char(32) DEFAULT NULL,
  counter int(11) NOT NULL DEFAULT '0',
  path varchar(256) NOT NULL DEFAULT '',
  created datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  KEY uidx (uid),
  KEY pathidx (namespace,path),
  KEY created (created),
  KEY trackid (trackid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='List of generic views';

/*
  * Link tracking
  */
DROP TABLE IF EXISTS `wblinktracking`;
CREATE TABLE `wblinktracking` (
     trackid CHAR(32) NOT NULL DEFAULT ''
     , linkid int(11) NOT NULL DEFAULT 0
     , created DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'
     , KEY (trackid)
     , KEY (linkid)
     , KEY createdidx (created)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Link tracking';

DROP TABLE IF EXISTS `wbtracklink`;
CREATE TABLE `wbtracklink` (
     linkid int(11) NOT NULL auto_increment
     , urlid int(11) NOT NULL DEFAULT 0
     , title varchar(255) NOT NULL DEFAULT ''
     , blurb text NOT NULL DEFAULT ''
     , created DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'
     , PRIMARY KEY (linkid)
     , KEY (urlid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Link tracking URLs and info';

