CREATE TABLE IF NOT EXISTS `bans` (
  `banvalue` varchar(128) NOT NULL,
  `nums` bigint(6) NOT NULL DEFAULT 0,
  `comment` mediumtext NOT NULL DEFAULT '',
  `lastseen` varchar(36) NOT NULL DEFAULT '',
  PRIMARY KEY (`banvalue`),
  KEY `nums` (`nums`),
  KEY `Idx_lastseen` (`lastseen`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gebante und aus dem System ausgeschlossene Avatare für Besucherboards';

CREATE TABLE IF NOT EXISTS `countries_lang` (
  `country` varchar(2) NOT NULL,
  `name` varchar(64) NOT NULL,
  `lang` varchar(2) NOT NULL,
  PRIMARY KEY (`country`),
  KEY `lang` (`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Sprachzuordnung zu Ländern für Besucherboards';

INSERT INTO `countries_lang` (`country`, `name`, `lang`) VALUES
	('ad', 'Andorra', 'ca'),
	('ae', 'United Arab Emirates', 'ar'),
	('af', 'Afghanistan', 'fa'),
	('ag', 'Antigua and Barbuda', 'en'),
	('ai', 'Anguilla', 'en'),
	('al', 'Albania', 'sq'),
	('am', 'Armenia', 'hy'),
	('an', 'Netherlands Antilles', 'nl'),
	('ao', 'Angola', 'pt'),
	('ar', 'Argentina', 'es'),
	('as', 'American Samoa', 'en'),
	('at', 'Austria', 'de'),
	('au', 'Australia', 'en'),
	('aw', 'Aruba', 'nl'),
	('ax', 'Aland Islands', 'sv'),
	('az', 'Azerbaijan', 'az'),
	('ba', 'Bosnia and Herzegovina', 'bs'),
	('bb', 'Barbados', 'en'),
	('bd', 'Bangladesh', 'bn'),
	('be', 'Belgium', 'nl'),
	('bf', 'Burkina Faso', 'fr'),
	('bg', 'Bulgaria', 'bg'),
	('bh', 'Bahrain', 'ar'),
	('bi', 'Burundi', 'fr'),
	('bj', 'Benin', 'fr'),
	('bl', 'Saint Barthelemy', 'fr'),
	('bm', 'Bermuda', 'en'),
	('bn', 'Brunei', 'ms'),
	('bo', 'Bolivia', 'es'),
	('bq', 'Bonaire Saint Eustatius and Saba ', 'nl'),
	('br', 'Brazil', 'pt'),
	('bs', 'Bahamas', 'en'),
	('bt', 'Bhutan', 'dz'),
	('bw', 'Botswana', 'en'),
	('by', 'Belarus', 'be'),
	('bz', 'Belize', 'en'),
	('ca', 'Canada', 'en'),
	('cc', 'Cocos Islands', 'ms'),
	('cd', 'Democratic Republic of the Congo', 'fr'),
	('cf', 'Central African Republic', 'fr'),
	('cg', 'Republic of the Congo', 'fr'),
	('ch', 'Switzerland', 'de'),
	('ci', 'Ivory Coast', 'fr'),
	('ck', 'Cook Islands', 'en'),
	('cl', 'Chile', 'es'),
	('cm', 'Cameroon', 'en'),
	('cn', 'China', 'zh'),
	('co', 'Colombia', 'es'),
	('cr', 'Costa Rica', 'es'),
	('cs', 'Serbia and Montenegro', 'cu'),
	('cu', 'Cuba', 'es'),
	('cv', 'Cabo Verde', 'pt'),
	('cw', 'Curacao', 'nl'),
	('cx', 'Christmas Island', 'en'),
	('cy', 'Cyprus', 'el'),
	('cz', 'Czechia', 'cs'),
	('de', 'Germany', 'de'),
	('dj', 'Djibouti', 'fr'),
	('dk', 'Denmark', 'da'),
	('dm', 'Dominica', 'en'),
	('do', 'Dominican Republic', 'es'),
	('dz', 'Algeria', 'ar'),
	('ec', 'Ecuador', 'es'),
	('ee', 'Estonia', 'et'),
	('eg', 'Egypt', 'ar'),
	('eh', 'Western Sahara', 'ar'),
	('er', 'Eritrea', 'aa'),
	('es', 'Spain', 'es'),
	('et', 'Ethiopia', 'am'),
	('fi', 'Finland', 'fi'),
	('fj', 'Fiji', 'en'),
	('fk', 'Falkland Islands', 'en'),
	('fm', 'Micronesia', 'en'),
	('fo', 'Faroe Islands', 'fo'),
	('fr', 'France', 'fr'),
	('ga', 'Gabon', 'fr'),
	('gb', 'United Kingdom', 'en'),
	('gd', 'Grenada', 'en'),
	('ge', 'Georgia', 'ka'),
	('gf', 'French Guiana', 'fr'),
	('gg', 'Guernsey', 'en'),
	('gh', 'Ghana', 'en'),
	('gi', 'Gibraltar', 'en'),
	('gl', 'Greenland', 'kl'),
	('gm', 'Gambia', 'en'),
	('gn', 'Guinea', 'fr'),
	('gp', 'Guadeloupe', 'fr'),
	('gq', 'Equatorial Guinea', 'es'),
	('gr', 'Greece', 'el'),
	('gs', 'South Georgia and the South Sandwich Islands', 'en'),
	('gt', 'Guatemala', 'es'),
	('gu', 'Guam', 'en'),
	('gw', 'Guinea-Bissau', 'pt'),
	('gy', 'Guyana', 'en'),
	('hk', 'Hong Kong', 'zh'),
	('hn', 'Honduras', 'es'),
	('hr', 'Croatia', 'hr'),
	('ht', 'Haiti', 'ht'),
	('hu', 'Hungary', 'hu'),
	('id', 'Indonesia', 'id'),
	('ie', 'Ireland', 'en'),
	('il', 'Israel', 'he'),
	('im', 'Isle of Man', 'en'),
	('in', 'India', 'en'),
	('io', 'British Indian Ocean Territory', 'en'),
	('iq', 'Iraq', 'ar'),
	('ir', 'Iran', 'fa'),
	('is', 'Iceland', 'is'),
	('it', 'Italy', 'it'),
	('je', 'Jersey', 'en'),
	('jm', 'Jamaica', 'en'),
	('jo', 'Jordan', 'ar'),
	('jp', 'Japan', 'ja'),
	('ke', 'Kenya', 'en'),
	('kg', 'Kyrgyzstan', 'ky'),
	('kh', 'Cambodia', 'km'),
	('ki', 'Kiribati', 'en'),
	('km', 'Comoros', 'ar'),
	('kn', 'Saint Kitts and Nevis', 'en'),
	('kp', 'North Korea', 'ko'),
	('kr', 'South Korea', 'ko'),
	('kw', 'Kuwait', 'ar'),
	('ky', 'Cayman Islands', 'en'),
	('kz', 'Kazakhstan', 'kk'),
	('la', 'Laos', 'lo'),
	('lb', 'Lebanon', 'ar'),
	('lc', 'Saint Lucia', 'en'),
	('li', 'Liechtenstein', 'de'),
	('lk', 'Sri Lanka', 'si'),
	('lr', 'Liberia', 'en'),
	('ls', 'Lesotho', 'en'),
	('lt', 'Lithuania', 'lt'),
	('lu', 'Luxembourg', 'lb'),
	('lv', 'Latvia', 'lv'),
	('ly', 'Libya', 'ar'),
	('ma', 'Morocco', 'ar'),
	('mc', 'Monaco', 'fr'),
	('md', 'Moldova', 'ro'),
	('me', 'Montenegro', 'sr'),
	('mf', 'Saint Martin', 'fr'),
	('mg', 'Madagascar', 'fr'),
	('mh', 'Marshall Islands', 'mh'),
	('mk', 'North Macedonia', 'mk'),
	('ml', 'Mali', 'fr'),
	('mm', 'Myanmar', 'my'),
	('mn', 'Mongolia', 'mn'),
	('mo', 'Macao', 'zh'),
	('mp', 'Northern Mariana Islands', 'fi'),
	('mq', 'Martinique', 'fr'),
	('mr', 'Mauritania', 'ar'),
	('ms', 'Montserrat', 'en'),
	('mt', 'Malta', 'mt'),
	('mu', 'Mauritius', 'en'),
	('mv', 'Maldives', 'dv'),
	('mw', 'Malawi', 'ny'),
	('mx', 'Mexico', 'es'),
	('my', 'Malaysia', 'ms'),
	('mz', 'Mozambique', 'pt'),
	('na', 'Namibia', 'en'),
	('nc', 'New Caledonia', 'fr'),
	('ne', 'Niger', 'fr'),
	('nf', 'Norfolk Island', 'en'),
	('ng', 'Nigeria', 'en'),
	('ni', 'Nicaragua', 'es'),
	('nl', 'Netherlands', 'nl'),
	('no', 'Norway', 'no'),
	('np', 'Nepal', 'ne'),
	('nr', 'Nauru', 'na'),
	('nu', 'Niue', 'ni'),
	('nz', 'New Zealand', 'en'),
	('om', 'Oman', 'ar'),
	('pa', 'Panama', 'es'),
	('pe', 'Peru', 'es'),
	('pf', 'French Polynesia', 'fr'),
	('pg', 'Papua New Guinea', 'en'),
	('ph', 'Philippines', 'tl'),
	('pk', 'Pakistan', 'ur'),
	('pl', 'Poland', 'pl'),
	('pm', 'Saint Pierre and Miquelon', 'fr'),
	('pn', 'Pitcairn', 'en'),
	('pr', 'Puerto Rico', 'en'),
	('ps', 'Palestinian Territory', 'ar'),
	('pt', 'Portugal', 'pt'),
	('pw', 'Palau', 'pa'),
	('py', 'Paraguay', 'es'),
	('qa', 'Qatar', 'ar'),
	('re', 'Reunion', 'fr'),
	('ro', 'Romania', 'ro'),
	('rs', 'Serbia', 'sr'),
	('ru', 'Russia', 'ru'),
	('rw', 'Rwanda', 'rw'),
	('sa', 'Saudi Arabia', 'ar'),
	('sb', 'Solomon Islands', 'en'),
	('sc', 'Seychelles', 'en'),
	('sd', 'Sudan', 'ar'),
	('se', 'Sweden', 'sv'),
	('sg', 'Singapore', 'cm'),
	('sh', 'Saint Helena', 'en'),
	('si', 'Slovenia', 'sl'),
	('sj', 'Svalbard and Jan Mayen', 'no'),
	('sk', 'Slovakia', 'sk'),
	('sl', 'Sierra Leone', 'en'),
	('sm', 'San Marino', 'it'),
	('sn', 'Senegal', 'fr'),
	('so', 'Somalia', 'so'),
	('sr', 'Suriname', 'nl'),
	('ss', 'South Sudan', 'en'),
	('st', 'Sao Tome and Principe', 'pt'),
	('sv', 'El Salvador', 'es'),
	('sx', 'Sint Maarten', 'nl'),
	('sy', 'Syria', 'ar'),
	('sz', 'Eswatini', 'en'),
	('tc', 'Turks and Caicos Islands', 'en'),
	('td', 'Chad', 'fr'),
	('tf', 'French Southern Territories', 'fr'),
	('tg', 'Togo', 'fr'),
	('th', 'Thailand', 'th'),
	('tj', 'Tajikistan', 'tg'),
	('tk', 'Tokelau', 'tk'),
	('tl', 'Timor Leste', 'te'),
	('tm', 'Turkmenistan', 'tk'),
	('tn', 'Tunisia', 'ar'),
	('to', 'Tonga', 'to'),
	('tr', 'Turkey', 'tr'),
	('tt', 'Trinidad and Tobago', 'en'),
	('tv', 'Tuvalu', 'tv'),
	('tw', 'Taiwan', 'zh'),
	('tz', 'Tanzania', 'sw'),
	('ua', 'Ukraine', 'uk'),
	('ug', 'Uganda', 'en'),
	('um', 'United States Minor Outlying Islands', 'en'),
	('us', 'United States', 'en'),
	('uy', 'Uruguay', 'es'),
	('uz', 'Uzbekistan', 'uz'),
	('va', 'Vatican', 'la'),
	('vc', 'Saint Vincent and the Grenadines', 'en'),
	('ve', 'Venezuela', 'es'),
	('vg', 'British Virgin Islands', 'en'),
	('vi', 'U.S. Virgin Islands', 'en'),
	('vn', 'Vietnam', 'vi'),
	('vu', 'Vanuatu', 'bi'),
	('wf', 'Wallis and Futuna', 'wl'),
	('ws', 'Samoa', 'sm'),
	('xk', 'Kosovo', 'sq'),
	('ye', 'Yemen', 'ar'),
	('yt', 'Mayotte', 'fr'),
	('za', 'South Africa', 'zu'),
	('zm', 'Zambia', 'en'),
	('zw', 'Zimbabwe', 'en');

CREATE TABLE IF NOT EXISTS `helpvals` (
  `name` varchar(64) NOT NULL,
  `val` varchar(8192) NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Hilfsdaten für Besucherboards';

CREATE TABLE IF NOT EXISTS `ip_timezones` (
  `ip` varchar(32) NOT NULL,
  `timezone` varchar(64) NOT NULL,
  `country` varchar(4) NOT NULL,
  `unix` bigint(255) NOT NULL,
  PRIMARY KEY (`ip`),
  KEY `unix` (`unix`),
  KEY `country_unix` (`country`,`unix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gecachte Zeitzonen und Landinfos zu IPs (gehashed) für Besucherboards';

CREATE TABLE IF NOT EXISTS `userdata` (
  `id` varchar(36) NOT NULL DEFAULT '',
  `userdata` varchar(8192) NOT NULL,
  `lastreq` bigint(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `lastreq` (`lastreq`),
  KEY `Idx_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Userdaten Cache für Besucherboards';

CREATE TABLE IF NOT EXISTS `_datastore` (
  `id` varchar(64) NOT NULL,
  `data` mediumtext DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Arbeitsdatensätze';